semiotic 2.0.3 → 3.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (424) hide show
  1. package/CLAUDE.md +530 -0
  2. package/README.md +190 -37
  3. package/ai/cli.js +48 -0
  4. package/ai/dist/ai/componentRegistry.js +45 -0
  5. package/ai/dist/ai/mcp-server.js +99 -0
  6. package/ai/dist/ai/renderHOCToSVG.js +77 -0
  7. package/ai/dist/src/components/Annotation.js +358 -0
  8. package/ai/dist/src/components/AnnotationLayer/AnnotationLayer.js +369 -0
  9. package/ai/dist/src/components/Axis/Axis.js +373 -0
  10. package/ai/dist/src/components/Axis/axisTitle.js +14 -0
  11. package/ai/dist/src/components/Axis/index.js +7 -0
  12. package/ai/dist/src/components/Axis/summaryGraphic.js +37 -0
  13. package/ai/dist/src/components/Brush.js +84 -0
  14. package/ai/dist/src/components/DividedLine.js +65 -0
  15. package/ai/dist/src/components/FacetController.js +259 -0
  16. package/ai/dist/src/components/Frame.js +139 -0
  17. package/ai/dist/src/components/InteractionLayer.js +328 -0
  18. package/ai/dist/src/components/Legend.js +140 -0
  19. package/ai/dist/src/components/MiniMap.js +75 -0
  20. package/ai/dist/src/components/MinimapXYFrame.js +99 -0
  21. package/ai/dist/src/components/NetworkFrame.js +335 -0
  22. package/ai/dist/src/components/OrdinalFrame.js +437 -0
  23. package/ai/dist/src/components/ResponsiveFrame.js +68 -0
  24. package/ai/dist/src/components/ResponsiveMinimapXYFrame.js +11 -0
  25. package/ai/dist/src/components/ResponsiveNetworkFrame.js +11 -0
  26. package/ai/dist/src/components/ResponsiveOrdinalFrame.js +11 -0
  27. package/ai/dist/src/components/ResponsiveXYFrame.js +10 -0
  28. package/ai/dist/src/components/SparkFrame.js +113 -0
  29. package/ai/dist/src/components/SparkNetworkFrame.js +11 -0
  30. package/ai/dist/src/components/SparkOrdinalFrame.js +11 -0
  31. package/ai/dist/src/components/SparkXYFrame.js +11 -0
  32. package/ai/dist/src/components/Tooltip/Tooltip.js +304 -0
  33. package/ai/dist/src/components/TooltipPositioner/index.js +132 -0
  34. package/ai/dist/src/components/VisualizationLayer.js +395 -0
  35. package/ai/dist/src/components/XYFrame.js +524 -0
  36. package/ai/dist/src/components/annotationLayerBehavior/annotationHandling.js +73 -0
  37. package/ai/dist/src/components/annotationLayerBehavior/d3labeler.js +254 -0
  38. package/ai/dist/src/components/annotationRules/baseRules.js +150 -0
  39. package/ai/dist/src/components/annotationRules/networkframeRules.js +198 -0
  40. package/ai/dist/src/components/annotationRules/orframeRules.js +695 -0
  41. package/ai/dist/src/components/annotationRules/xyframeRules.js +299 -0
  42. package/ai/dist/src/components/batchWork.js +35 -0
  43. package/ai/dist/src/components/charts/index.js +96 -0
  44. package/ai/dist/src/components/charts/network/ChordDiagram.js +245 -0
  45. package/ai/dist/src/components/charts/network/CirclePack.js +177 -0
  46. package/ai/dist/src/components/charts/network/ForceDirectedGraph.js +248 -0
  47. package/ai/dist/src/components/charts/network/SankeyDiagram.js +305 -0
  48. package/ai/dist/src/components/charts/network/TreeDiagram.js +268 -0
  49. package/ai/dist/src/components/charts/network/Treemap.js +177 -0
  50. package/ai/dist/src/components/charts/ordinal/BarChart.js +191 -0
  51. package/ai/dist/src/components/charts/ordinal/BoxPlot.js +235 -0
  52. package/ai/dist/src/components/charts/ordinal/DonutChart.js +178 -0
  53. package/ai/dist/src/components/charts/ordinal/DotPlot.js +194 -0
  54. package/ai/dist/src/components/charts/ordinal/GroupedBarChart.js +194 -0
  55. package/ai/dist/src/components/charts/ordinal/PieChart.js +155 -0
  56. package/ai/dist/src/components/charts/ordinal/StackedBarChart.js +213 -0
  57. package/ai/dist/src/components/charts/ordinal/SwarmPlot.js +219 -0
  58. package/ai/dist/src/components/charts/realtime/RealtimeBarChart.js +91 -0
  59. package/ai/dist/src/components/charts/realtime/RealtimeLineChart.js +73 -0
  60. package/ai/dist/src/components/charts/realtime/RealtimeSwarmChart.js +85 -0
  61. package/ai/dist/src/components/charts/realtime/RealtimeWaterfallChart.js +86 -0
  62. package/ai/dist/src/components/charts/shared/ChartError.js +72 -0
  63. package/ai/dist/src/components/charts/shared/colorUtils.js +138 -0
  64. package/ai/dist/src/components/charts/shared/formatUtils.js +176 -0
  65. package/ai/dist/src/components/charts/shared/hooks.js +49 -0
  66. package/ai/dist/src/components/charts/shared/legendUtils.js +57 -0
  67. package/ai/dist/src/components/charts/shared/types.js +2 -0
  68. package/ai/dist/src/components/charts/shared/validateChartData.js +82 -0
  69. package/ai/dist/src/components/charts/shared/validateProps.js +640 -0
  70. package/ai/dist/src/components/charts/xy/AreaChart.js +220 -0
  71. package/ai/dist/src/components/charts/xy/BubbleChart.js +222 -0
  72. package/ai/dist/src/components/charts/xy/Heatmap.js +230 -0
  73. package/ai/dist/src/components/charts/xy/LineChart.js +302 -0
  74. package/ai/dist/src/components/charts/xy/Scatterplot.js +136 -0
  75. package/ai/dist/src/components/charts/xy/StackedAreaChart.js +220 -0
  76. package/ai/dist/src/components/constants/coordinateNames.js +11 -0
  77. package/ai/dist/src/components/constants/frame_props.js +251 -0
  78. package/ai/dist/src/components/constants/jsx.js +71 -0
  79. package/ai/dist/src/components/data/dataFunctions.js +473 -0
  80. package/ai/dist/src/components/data/multiAccessorUtils.js +14 -0
  81. package/ai/dist/src/components/data/networkPipelineCache.js +43 -0
  82. package/ai/dist/src/components/data/ordinalPipelineCache.js +53 -0
  83. package/ai/dist/src/components/data/unflowedFunctions.js +5 -0
  84. package/ai/dist/src/components/data/xyPipelineCache.js +49 -0
  85. package/ai/dist/src/components/generic_utilities/functions.js +5 -0
  86. package/ai/dist/src/components/index.js +145 -0
  87. package/ai/dist/src/components/interactionLayerBehavior/InteractionCanvas.js +128 -0
  88. package/ai/dist/src/components/processing/InteractionItems.js +223 -0
  89. package/ai/dist/src/components/processing/hierarchyUtils.js +104 -0
  90. package/ai/dist/src/components/processing/layouts/chordLayout.js +58 -0
  91. package/ai/dist/src/components/processing/layouts/forceLayout.js +142 -0
  92. package/ai/dist/src/components/processing/layouts/hierarchyLayout.js +31 -0
  93. package/ai/dist/src/components/processing/layouts/index.js +32 -0
  94. package/ai/dist/src/components/processing/layouts/sankeyLayout.js +96 -0
  95. package/ai/dist/src/components/processing/layouts/simpleLayouts.js +34 -0
  96. package/ai/dist/src/components/processing/layouts/types.js +2 -0
  97. package/ai/dist/src/components/processing/network.js +771 -0
  98. package/ai/dist/src/components/processing/networkDefaults.js +39 -0
  99. package/ai/dist/src/components/processing/networkLayoutHelpers.js +98 -0
  100. package/ai/dist/src/components/processing/ordinal.js +889 -0
  101. package/ai/dist/src/components/processing/ordinalConstants.js +23 -0
  102. package/ai/dist/src/components/processing/ordinalOverlays.js +88 -0
  103. package/ai/dist/src/components/processing/ordinalRenderPipeline.js +196 -0
  104. package/ai/dist/src/components/processing/xyDrawing.js +484 -0
  105. package/ai/dist/src/components/realtime/BinAccumulator.js +36 -0
  106. package/ai/dist/src/components/realtime/IncrementalExtent.js +55 -0
  107. package/ai/dist/src/components/realtime/RealtimeFrame.js +710 -0
  108. package/ai/dist/src/components/realtime/RingBuffer.js +104 -0
  109. package/ai/dist/src/components/realtime/renderers/barRenderer.js +133 -0
  110. package/ai/dist/src/components/realtime/renderers/candlestickRenderer.js +7 -0
  111. package/ai/dist/src/components/realtime/renderers/lineRenderer.js +164 -0
  112. package/ai/dist/src/components/realtime/renderers/swarmRenderer.js +91 -0
  113. package/ai/dist/src/components/realtime/renderers/types.js +2 -0
  114. package/ai/dist/src/components/realtime/renderers/waterfallRenderer.js +163 -0
  115. package/ai/dist/src/components/realtime/types.js +2 -0
  116. package/ai/dist/src/components/semiotic-ai.js +66 -0
  117. package/ai/dist/src/components/semiotic-network.js +30 -0
  118. package/ai/dist/src/components/semiotic-ordinal.js +28 -0
  119. package/ai/dist/src/components/semiotic-realtime.js +37 -0
  120. package/ai/dist/src/components/semiotic-server.js +8 -0
  121. package/ai/dist/src/components/semiotic-xy.js +41 -0
  122. package/ai/dist/src/components/semiotic.js +101 -0
  123. package/ai/dist/src/components/server/renderToStaticSVG.js +392 -0
  124. package/ai/dist/src/components/store/TooltipStore.js +13 -0
  125. package/ai/dist/src/components/store/createStore.js +77 -0
  126. package/ai/dist/src/components/svg/SvgHelper.js +308 -0
  127. package/ai/dist/src/components/svg/areaDrawing.js +312 -0
  128. package/ai/dist/src/components/svg/boxplotRenderer.js +441 -0
  129. package/ai/dist/src/components/svg/bucketizedRenderer.js +677 -0
  130. package/ai/dist/src/components/svg/ckbinsRenderer.js +92 -0
  131. package/ai/dist/src/components/svg/ckmeans.js +238 -0
  132. package/ai/dist/src/components/svg/contourLayout.js +73 -0
  133. package/ai/dist/src/components/svg/contourRenderer.js +53 -0
  134. package/ai/dist/src/components/svg/edgeGenerators.js +181 -0
  135. package/ai/dist/src/components/svg/frameFunctions.js +579 -0
  136. package/ai/dist/src/components/svg/graphAlgorithms.js +138 -0
  137. package/ai/dist/src/components/svg/hexbinLayout.js +163 -0
  138. package/ai/dist/src/components/svg/lineDrawing.js +427 -0
  139. package/ai/dist/src/components/svg/networkDrawing.js +207 -0
  140. package/ai/dist/src/components/svg/nodeGenerators.js +131 -0
  141. package/ai/dist/src/components/svg/pieceDrawing.js +110 -0
  142. package/ai/dist/src/components/svg/pieceLayouts.js +588 -0
  143. package/ai/dist/src/components/svg/sankeyLinks.js +143 -0
  144. package/ai/dist/src/components/svg/summaryAxis.js +48 -0
  145. package/ai/dist/src/components/svg/summaryLayouts.js +202 -0
  146. package/ai/dist/src/components/svg/swarmLayout.js +128 -0
  147. package/ai/dist/src/components/types/annotationTypes.js +2 -0
  148. package/ai/dist/src/components/types/canvasTypes.js +2 -0
  149. package/ai/dist/src/components/types/generalTypes.js +2 -0
  150. package/ai/dist/src/components/types/interactionTypes.js +2 -0
  151. package/ai/dist/src/components/types/legendTypes.js +2 -0
  152. package/ai/dist/src/components/types/networkTypes.js +2 -0
  153. package/ai/dist/src/components/types/ordinalTypes.js +2 -0
  154. package/ai/dist/src/components/types/xyTypes.js +2 -0
  155. package/ai/dist/src/components/useBoundingRect.js +24 -0
  156. package/ai/dist/src/components/useDerivedStateFromProps.js +25 -0
  157. package/ai/dist/src/components/useLegacyUnmountCallback.js +21 -0
  158. package/ai/dist/src/components/visualizationLayerBehavior/axis.js +249 -0
  159. package/ai/dist/src/components/visualizationLayerBehavior/general.js +435 -0
  160. package/ai/dist/src/setupTests.js +4 -0
  161. package/ai/examples.md +394 -0
  162. package/ai/schema.json +1178 -0
  163. package/ai/system-prompt.md +38 -0
  164. package/dist/AnnotationLayer/AnnotationLayer.d.ts +0 -1
  165. package/dist/Axis/axisTitle.d.ts +3 -3
  166. package/dist/Axis/summaryGraphic.d.ts +1 -1
  167. package/dist/FacetController.d.ts +1 -1
  168. package/dist/MinimapXYFrame.d.ts +2 -2
  169. package/dist/NetworkFrame.d.ts +5 -1
  170. package/dist/OrdinalFrame.d.ts +5 -1
  171. package/dist/ResponsiveFrame.d.ts +2 -2
  172. package/dist/ResponsiveMinimapXYFrame.d.ts +3 -6
  173. package/dist/ResponsiveNetworkFrame.d.ts +3 -6
  174. package/dist/ResponsiveOrdinalFrame.d.ts +3 -6
  175. package/dist/ResponsiveXYFrame.d.ts +3 -6
  176. package/dist/SparkFrame.d.ts +1 -1
  177. package/dist/SparkNetworkFrame.d.ts +3 -3
  178. package/dist/SparkOrdinalFrame.d.ts +3 -3
  179. package/dist/SparkXYFrame.d.ts +3 -3
  180. package/dist/Tooltip/Tooltip.d.ts +141 -0
  181. package/dist/TooltipPositioner/index.d.ts +1 -1
  182. package/dist/VisualizationLayer.d.ts +3 -3
  183. package/dist/XYFrame.d.ts +5 -1
  184. package/dist/annotationLayerBehavior/annotationHandling.d.ts +2 -2
  185. package/dist/annotationRules/networkframeRules.d.ts +2 -2
  186. package/dist/annotationRules/orframeRules.d.ts +2 -4
  187. package/dist/annotationRules/xyframeRules.d.ts +2 -2
  188. package/dist/batchWork.d.ts +1 -1
  189. package/dist/charts/index.d.ts +62 -0
  190. package/dist/charts/network/ChordDiagram.d.ts +181 -0
  191. package/dist/charts/network/CirclePack.d.ts +103 -0
  192. package/dist/charts/network/ForceDirectedGraph.d.ts +192 -0
  193. package/dist/charts/network/SankeyDiagram.d.ts +195 -0
  194. package/dist/charts/network/TreeDiagram.d.ts +200 -0
  195. package/dist/charts/network/Treemap.d.ts +98 -0
  196. package/dist/charts/ordinal/BarChart.d.ts +119 -0
  197. package/dist/charts/ordinal/BoxPlot.d.ts +125 -0
  198. package/dist/charts/ordinal/DonutChart.d.ts +95 -0
  199. package/dist/charts/ordinal/DotPlot.d.ts +128 -0
  200. package/dist/charts/ordinal/GroupedBarChart.d.ts +113 -0
  201. package/dist/charts/ordinal/PieChart.d.ts +83 -0
  202. package/dist/charts/ordinal/StackedBarChart.d.ts +119 -0
  203. package/dist/charts/ordinal/SwarmPlot.d.ts +137 -0
  204. package/dist/charts/realtime/RealtimeBarChart.d.ts +102 -0
  205. package/dist/charts/realtime/RealtimeLineChart.d.ts +78 -0
  206. package/dist/charts/realtime/RealtimeSwarmChart.d.ts +88 -0
  207. package/dist/charts/realtime/RealtimeWaterfallChart.d.ts +85 -0
  208. package/dist/charts/shared/ChartError.d.ts +19 -0
  209. package/dist/charts/shared/colorUtils.d.ts +62 -0
  210. package/dist/charts/shared/formatUtils.d.ts +82 -0
  211. package/dist/charts/shared/hooks.d.ts +20 -0
  212. package/dist/charts/shared/legendUtils.d.ts +32 -0
  213. package/dist/charts/shared/types.d.ts +58 -0
  214. package/dist/charts/shared/validateChartData.d.ts +41 -0
  215. package/dist/charts/shared/validateProps.d.ts +18 -0
  216. package/dist/charts/xy/AreaChart.d.ts +127 -0
  217. package/dist/charts/xy/BubbleChart.d.ts +157 -0
  218. package/dist/charts/xy/Heatmap.d.ts +153 -0
  219. package/dist/charts/xy/LineChart.d.ts +193 -0
  220. package/dist/charts/xy/Scatterplot.d.ts +50 -0
  221. package/dist/charts/xy/StackedAreaChart.d.ts +131 -0
  222. package/dist/constants/frame_props.d.ts +9 -0
  223. package/dist/constants/jsx.d.ts +2 -2
  224. package/dist/data/dataFunctions.d.ts +11 -12
  225. package/dist/data/networkPipelineCache.d.ts +27 -0
  226. package/dist/data/ordinalPipelineCache.d.ts +33 -0
  227. package/dist/data/xyPipelineCache.d.ts +35 -0
  228. package/dist/index.d.ts +70 -62
  229. package/dist/interactionLayerBehavior/InteractionCanvas.d.ts +1 -1
  230. package/dist/network.js +8520 -0
  231. package/dist/network.js.map +1 -0
  232. package/dist/network.min.js +1 -0
  233. package/dist/network.module.js +8484 -0
  234. package/dist/network.module.js.map +1 -0
  235. package/dist/network.module.min.js +1 -0
  236. package/dist/ordinal.js +9276 -0
  237. package/dist/ordinal.js.map +1 -0
  238. package/dist/ordinal.min.js +1 -0
  239. package/dist/ordinal.module.js +9242 -0
  240. package/dist/ordinal.module.js.map +1 -0
  241. package/dist/ordinal.module.min.js +1 -0
  242. package/dist/processing/InteractionItems.d.ts +5 -4
  243. package/dist/processing/hierarchyUtils.d.ts +16 -0
  244. package/dist/processing/layouts/chordLayout.d.ts +2 -0
  245. package/dist/processing/layouts/forceLayout.d.ts +3 -0
  246. package/dist/processing/layouts/hierarchyLayout.d.ts +10 -0
  247. package/dist/processing/layouts/index.d.ts +8 -0
  248. package/dist/processing/layouts/sankeyLayout.d.ts +8 -0
  249. package/dist/processing/layouts/simpleLayouts.d.ts +7 -0
  250. package/dist/processing/layouts/types.d.ts +17 -0
  251. package/dist/processing/network.d.ts +25 -28
  252. package/dist/processing/networkDefaults.d.ts +36 -0
  253. package/dist/processing/networkLayoutHelpers.d.ts +54 -0
  254. package/dist/processing/ordinal.d.ts +43 -43
  255. package/dist/processing/ordinalConstants.d.ts +33 -0
  256. package/dist/processing/ordinalOverlays.d.ts +33 -0
  257. package/dist/processing/ordinalRenderPipeline.d.ts +148 -0
  258. package/dist/processing/xyDrawing.d.ts +46 -41
  259. package/dist/realtime/BinAccumulator.d.ts +8 -0
  260. package/dist/realtime/IncrementalExtent.d.ts +13 -0
  261. package/dist/realtime/RealtimeFrame.d.ts +4 -0
  262. package/dist/realtime/RingBuffer.d.ts +19 -0
  263. package/dist/realtime/renderers/barRenderer.d.ts +2 -0
  264. package/dist/realtime/renderers/candlestickRenderer.d.ts +2 -0
  265. package/dist/realtime/renderers/lineRenderer.d.ts +2 -0
  266. package/dist/realtime/renderers/swarmRenderer.d.ts +2 -0
  267. package/dist/realtime/renderers/types.d.ts +9 -0
  268. package/dist/realtime/renderers/waterfallRenderer.d.ts +3 -0
  269. package/dist/realtime/types.d.ts +113 -0
  270. package/dist/realtime.js +1598 -0
  271. package/dist/realtime.js.map +1 -0
  272. package/dist/realtime.min.js +1 -0
  273. package/dist/realtime.module.js +1566 -0
  274. package/dist/realtime.module.js.map +1 -0
  275. package/dist/realtime.module.min.js +1 -0
  276. package/dist/semiotic-ai.d.ts +28 -0
  277. package/dist/semiotic-ai.js +18722 -0
  278. package/dist/semiotic-ai.js.map +1 -0
  279. package/dist/semiotic-ai.min.js +1 -0
  280. package/dist/semiotic-ai.module.js +18668 -0
  281. package/dist/semiotic-ai.module.js.map +1 -0
  282. package/dist/semiotic-ai.module.min.js +1 -0
  283. package/dist/semiotic-network.d.ts +19 -0
  284. package/dist/semiotic-ordinal.d.ts +18 -0
  285. package/dist/semiotic-realtime.d.ts +23 -0
  286. package/dist/semiotic-server.d.ts +1 -0
  287. package/dist/semiotic-xy.d.ts +24 -0
  288. package/dist/semiotic.d.ts +19 -3
  289. package/dist/semiotic.js +18707 -12983
  290. package/dist/semiotic.js.map +1 -0
  291. package/dist/semiotic.min.js +1 -0
  292. package/dist/semiotic.module.js +18651 -12953
  293. package/dist/semiotic.module.js.map +1 -0
  294. package/dist/semiotic.module.min.js +1 -0
  295. package/dist/server/renderToStaticSVG.d.ts +9 -0
  296. package/dist/server.js +8360 -0
  297. package/dist/server.js.map +1 -0
  298. package/dist/server.min.js +1 -0
  299. package/dist/server.module.js +8331 -0
  300. package/dist/server.module.js.map +1 -0
  301. package/dist/server.module.min.js +1 -0
  302. package/dist/svg/SvgHelper.d.ts +1 -5
  303. package/dist/svg/areaDrawing.d.ts +3 -13
  304. package/dist/svg/boxplotRenderer.d.ts +15 -0
  305. package/dist/svg/bucketizedRenderer.d.ts +16 -0
  306. package/dist/svg/ckbinsRenderer.d.ts +20 -0
  307. package/dist/svg/contourLayout.d.ts +6 -0
  308. package/dist/svg/contourRenderer.d.ts +12 -0
  309. package/dist/svg/edgeGenerators.d.ts +51 -0
  310. package/dist/svg/frameFunctions.d.ts +17 -28
  311. package/dist/svg/graphAlgorithms.d.ts +14 -0
  312. package/dist/svg/hexbinLayout.d.ts +7 -0
  313. package/dist/svg/lineDrawing.d.ts +8 -8
  314. package/dist/svg/networkDrawing.d.ts +5 -123
  315. package/dist/svg/nodeGenerators.d.ts +58 -0
  316. package/dist/svg/pieceDrawing.d.ts +1 -2
  317. package/dist/svg/pieceLayouts.d.ts +5 -23
  318. package/dist/svg/sankeyLinks.d.ts +3 -0
  319. package/dist/svg/summaryAxis.d.ts +6 -0
  320. package/dist/svg/summaryLayouts.d.ts +36 -57
  321. package/dist/svg/swarmLayout.d.ts +13 -0
  322. package/dist/types/annotationTypes.d.ts +13 -18
  323. package/dist/types/canvasTypes.d.ts +1 -1
  324. package/dist/types/generalTypes.d.ts +37 -35
  325. package/dist/types/interactionTypes.d.ts +7 -9
  326. package/dist/types/legendTypes.d.ts +2 -2
  327. package/dist/types/networkTypes.d.ts +40 -30
  328. package/dist/types/ordinalTypes.d.ts +27 -18
  329. package/dist/types/xyTypes.d.ts +13 -16
  330. package/dist/useLegacyUnmountCallback.d.ts +2 -1
  331. package/dist/visualizationLayerBehavior/axis.d.ts +3 -5
  332. package/dist/visualizationLayerBehavior/general.d.ts +8 -12
  333. package/dist/xy.js +7944 -0
  334. package/dist/xy.js.map +1 -0
  335. package/dist/xy.min.js +1 -0
  336. package/dist/xy.module.js +7903 -0
  337. package/dist/xy.module.js.map +1 -0
  338. package/dist/xy.module.min.js +1 -0
  339. package/package.json +116 -66
  340. package/dist/AnnotationLayer/helpers.d.ts +0 -6
  341. package/dist/AnnotationLayer/index.d.ts +0 -2
  342. package/dist/Mark/Mark.d.ts +0 -3
  343. package/dist/Mark/Mark.types.d.ts +0 -10
  344. package/dist/Mark/constants/markTransition.d.ts +0 -10
  345. package/dist/Mark/markBehavior/drawing.d.ts +0 -13
  346. package/dist/SpanOrDiv.d.ts +0 -10
  347. package/dist/components/Annotation.d.ts +0 -3
  348. package/dist/components/AnnotationLayer/AnnotationLayer.d.ts +0 -26
  349. package/dist/components/Axis/Axis.d.ts +0 -7
  350. package/dist/components/Axis/axisTitle.d.ts +0 -10
  351. package/dist/components/Axis/index.d.ts +0 -2
  352. package/dist/components/Axis/summaryGraphic.d.ts +0 -17
  353. package/dist/components/Brush.d.ts +0 -12
  354. package/dist/components/DividedLine.d.ts +0 -16
  355. package/dist/components/FacetController.d.ts +0 -12
  356. package/dist/components/Frame.d.ts +0 -2
  357. package/dist/components/InteractionLayer.d.ts +0 -3
  358. package/dist/components/Legend.d.ts +0 -3
  359. package/dist/components/Mark/Mark.d.ts +0 -3
  360. package/dist/components/Mark/Mark.types.d.ts +0 -10
  361. package/dist/components/Mark/markBehavior/drawing.d.ts +0 -13
  362. package/dist/components/MiniMap.d.ts +0 -14
  363. package/dist/components/MinimapXYFrame.d.ts +0 -10
  364. package/dist/components/NetworkFrame.d.ts +0 -4
  365. package/dist/components/OrdinalFrame.d.ts +0 -4
  366. package/dist/components/ResponsiveFrame.d.ts +0 -22
  367. package/dist/components/ResponsiveMinimapXYFrame.d.ts +0 -6
  368. package/dist/components/ResponsiveNetworkFrame.d.ts +0 -6
  369. package/dist/components/ResponsiveOrdinalFrame.d.ts +0 -6
  370. package/dist/components/ResponsiveXYFrame.d.ts +0 -6
  371. package/dist/components/SpanOrDiv.d.ts +0 -10
  372. package/dist/components/SparkFrame.d.ts +0 -14
  373. package/dist/components/SparkNetworkFrame.d.ts +0 -5
  374. package/dist/components/SparkOrdinalFrame.d.ts +0 -5
  375. package/dist/components/SparkXYFrame.d.ts +0 -5
  376. package/dist/components/TooltipPositioner/index.d.ts +0 -7
  377. package/dist/components/VisualizationLayer.d.ts +0 -33
  378. package/dist/components/XYFrame.d.ts +0 -4
  379. package/dist/components/annotationLayerBehavior/annotationHandling.d.ts +0 -19
  380. package/dist/components/annotationLayerBehavior/d3labeler.d.ts +0 -9
  381. package/dist/components/annotationRules/baseRules.d.ts +0 -25
  382. package/dist/components/annotationRules/networkframeRules.d.ts +0 -48
  383. package/dist/components/annotationRules/orframeRules.d.ts +0 -105
  384. package/dist/components/annotationRules/xyframeRules.d.ts +0 -117
  385. package/dist/components/batchWork.d.ts +0 -6
  386. package/dist/components/constants/coordinateNames.d.ts +0 -8
  387. package/dist/components/constants/frame_props.d.ts +0 -4
  388. package/dist/components/constants/jsx.d.ts +0 -19
  389. package/dist/components/data/dataFunctions.d.ts +0 -46
  390. package/dist/components/data/multiAccessorUtils.d.ts +0 -1
  391. package/dist/components/data/unflowedFunctions.d.ts +0 -1
  392. package/dist/components/generic_utilities/functions.d.ts +0 -1
  393. package/dist/components/index.d.ts +0 -125
  394. package/dist/components/interactionLayerBehavior/InteractionCanvas.d.ts +0 -20
  395. package/dist/components/processing/InteractionItems.d.ts +0 -12
  396. package/dist/components/processing/network.d.ts +0 -114
  397. package/dist/components/processing/ordinal.d.ts +0 -102
  398. package/dist/components/processing/xyDrawing.d.ts +0 -135
  399. package/dist/components/semiotic.d.ts +0 -35
  400. package/dist/components/store/TooltipStore.d.ts +0 -2
  401. package/dist/components/store/createStore.d.ts +0 -1
  402. package/dist/components/svg/SvgHelper.d.ts +0 -37
  403. package/dist/components/svg/areaDrawing.d.ts +0 -31
  404. package/dist/components/svg/ckmeans.d.ts +0 -69
  405. package/dist/components/svg/frameFunctions.d.ts +0 -119
  406. package/dist/components/svg/lineDrawing.d.ts +0 -99
  407. package/dist/components/svg/networkDrawing.d.ts +0 -134
  408. package/dist/components/svg/pieceDrawing.d.ts +0 -13
  409. package/dist/components/svg/pieceLayouts.d.ts +0 -71
  410. package/dist/components/svg/summaryLayouts.d.ts +0 -74
  411. package/dist/components/types/annotationTypes.d.ts +0 -140
  412. package/dist/components/types/canvasTypes.d.ts +0 -9
  413. package/dist/components/types/generalTypes.d.ts +0 -236
  414. package/dist/components/types/interactionTypes.d.ts +0 -74
  415. package/dist/components/types/legendTypes.d.ts +0 -20
  416. package/dist/components/types/networkTypes.d.ts +0 -165
  417. package/dist/components/types/ordinalTypes.d.ts +0 -103
  418. package/dist/components/types/xyTypes.d.ts +0 -118
  419. package/dist/components/useBoundingRect.d.ts +0 -2
  420. package/dist/components/useDerivedStateFromProps.d.ts +0 -1
  421. package/dist/components/useLegacyUnmountCallback.d.ts +0 -1
  422. package/dist/components/visualizationLayerBehavior/axis.d.ts +0 -38
  423. package/dist/components/visualizationLayerBehavior/general.d.ts +0 -84
  424. package/dist/setupTests.d.ts +0 -1
@@ -0,0 +1,1566 @@
1
+ "use client";
2
+ import * as React from 'react';
3
+ import { forwardRef, useMemo, useRef, useState, useCallback, useImperativeHandle, useEffect } from 'react';
4
+ import { scaleLinear } from 'd3-scale';
5
+
6
+ class RingBuffer {
7
+ constructor(_capacity) {
8
+ this._capacity = _capacity;
9
+ this.head = 0;
10
+ this._size = 0;
11
+ if (_capacity < 1) {
12
+ throw new Error("RingBuffer capacity must be at least 1");
13
+ }
14
+ this.buffer = new Array(_capacity);
15
+ }
16
+ push(value) {
17
+ let evicted;
18
+ if (this._size === this._capacity) {
19
+ // Buffer is full — the slot at head is the oldest item
20
+ evicted = this.buffer[this.head];
21
+ }
22
+ else {
23
+ this._size++;
24
+ }
25
+ this.buffer[this.head] = value;
26
+ this.head = (this.head + 1) % this._capacity;
27
+ return evicted;
28
+ }
29
+ pushMany(values) {
30
+ const evicted = [];
31
+ for (const v of values) {
32
+ const e = this.push(v);
33
+ if (e !== undefined) {
34
+ evicted.push(e);
35
+ }
36
+ }
37
+ return evicted;
38
+ }
39
+ get(index) {
40
+ if (index < 0 || index >= this._size)
41
+ return undefined;
42
+ const realIndex = (this.head - this._size + index + this._capacity) % this._capacity;
43
+ return this.buffer[realIndex];
44
+ }
45
+ peek() {
46
+ if (this._size === 0)
47
+ return undefined;
48
+ return this.buffer[(this.head - 1 + this._capacity) % this._capacity];
49
+ }
50
+ peekOldest() {
51
+ if (this._size === 0)
52
+ return undefined;
53
+ return this.buffer[(this.head - this._size + this._capacity) % this._capacity];
54
+ }
55
+ [Symbol.iterator]() {
56
+ let i = 0;
57
+ const self = this;
58
+ return {
59
+ next() {
60
+ if (i >= self._size)
61
+ return { done: true, value: undefined };
62
+ return { done: false, value: self.get(i++) };
63
+ }
64
+ };
65
+ }
66
+ toArray() {
67
+ const result = [];
68
+ for (const item of this) {
69
+ result.push(item);
70
+ }
71
+ return result;
72
+ }
73
+ resize(newCapacity) {
74
+ if (newCapacity < 1) {
75
+ throw new Error("RingBuffer capacity must be at least 1");
76
+ }
77
+ const items = this.toArray();
78
+ const evicted = [];
79
+ while (items.length > newCapacity) {
80
+ evicted.push(items.shift());
81
+ }
82
+ this._capacity = newCapacity;
83
+ this.buffer = new Array(newCapacity);
84
+ this.head = 0;
85
+ this._size = 0;
86
+ for (const item of items) {
87
+ this.push(item);
88
+ }
89
+ return evicted;
90
+ }
91
+ clear() {
92
+ this.buffer = new Array(this._capacity);
93
+ this.head = 0;
94
+ this._size = 0;
95
+ }
96
+ get size() {
97
+ return this._size;
98
+ }
99
+ get capacity() {
100
+ return this._capacity;
101
+ }
102
+ get full() {
103
+ return this._size === this._capacity;
104
+ }
105
+ }
106
+
107
+ class IncrementalExtent {
108
+ constructor() {
109
+ this._min = Infinity;
110
+ this._max = -Infinity;
111
+ this._dirty = false;
112
+ }
113
+ push(value) {
114
+ if (Number.isNaN(value))
115
+ return;
116
+ if (value < this._min)
117
+ this._min = value;
118
+ if (value > this._max)
119
+ this._max = value;
120
+ }
121
+ evict(value) {
122
+ if (value === this._min || value === this._max) {
123
+ this._dirty = true;
124
+ }
125
+ }
126
+ recalculate(values, accessor) {
127
+ this._min = Infinity;
128
+ this._max = -Infinity;
129
+ for (const v of values) {
130
+ const n = accessor ? accessor(v) : v;
131
+ if (Number.isNaN(n))
132
+ continue;
133
+ if (n < this._min)
134
+ this._min = n;
135
+ if (n > this._max)
136
+ this._max = n;
137
+ }
138
+ this._dirty = false;
139
+ }
140
+ clear() {
141
+ this._min = Infinity;
142
+ this._max = -Infinity;
143
+ this._dirty = false;
144
+ }
145
+ get extent() {
146
+ return [this._min, this._max];
147
+ }
148
+ get min() {
149
+ return this._min;
150
+ }
151
+ get max() {
152
+ return this._max;
153
+ }
154
+ get dirty() {
155
+ return this._dirty;
156
+ }
157
+ }
158
+
159
+ function resolveColor$1(value, thresholds, baseColor) {
160
+ let color = baseColor;
161
+ for (const t of thresholds) {
162
+ if (t.thresholdType === "lesser") {
163
+ if (value < t.value)
164
+ color = t.color;
165
+ }
166
+ else {
167
+ if (value > t.value)
168
+ color = t.color;
169
+ }
170
+ }
171
+ return color;
172
+ }
173
+ const lineRenderer = (ctx, data, scales, layout, style, accessors, annotations) => {
174
+ const { time: timeScale, value: valueScale } = scales;
175
+ const { timeAxis } = layout;
176
+ const { time: getTime, value: getValue } = accessors;
177
+ const baseColor = style.stroke || "#007bff";
178
+ // Extract color thresholds from annotations
179
+ const colorThresholds = annotations
180
+ ? annotations
181
+ .filter((a) => a.type === "threshold" && a.color)
182
+ .map((a) => ({
183
+ value: a.value,
184
+ color: a.color,
185
+ thresholdType: (a.thresholdType || "greater")
186
+ }))
187
+ : null;
188
+ const hasColorThresholds = colorThresholds && colorThresholds.length > 0;
189
+ // Fast path: no color thresholds — single-path draw, zero overhead
190
+ if (!hasColorThresholds) {
191
+ ctx.beginPath();
192
+ ctx.strokeStyle = baseColor;
193
+ ctx.lineWidth = style.strokeWidth || 2;
194
+ if (style.strokeDasharray) {
195
+ ctx.setLineDash(style.strokeDasharray.split(/[\s,]+/).map(Number));
196
+ }
197
+ else {
198
+ ctx.setLineDash([]);
199
+ }
200
+ let started = false;
201
+ for (const d of data) {
202
+ const t = getTime(d);
203
+ const v = getValue(d);
204
+ if (t == null || v == null || Number.isNaN(t) || Number.isNaN(v)) {
205
+ started = false;
206
+ continue;
207
+ }
208
+ const tPixel = timeScale(t);
209
+ const vPixel = valueScale(v);
210
+ const x = timeAxis === "x" ? tPixel : vPixel;
211
+ const y = timeAxis === "x" ? vPixel : tPixel;
212
+ if (!started) {
213
+ ctx.moveTo(x, y);
214
+ started = true;
215
+ }
216
+ else {
217
+ ctx.lineTo(x, y);
218
+ }
219
+ }
220
+ ctx.stroke();
221
+ return;
222
+ }
223
+ // Threshold mode: segment-based drawing
224
+ ctx.lineWidth = style.strokeWidth || 2;
225
+ if (style.strokeDasharray) {
226
+ ctx.setLineDash(style.strokeDasharray.split(/[\s,]+/).map(Number));
227
+ }
228
+ else {
229
+ ctx.setLineDash([]);
230
+ }
231
+ let prevX = null;
232
+ let prevY = null;
233
+ let prevValue = null;
234
+ let prevColor = null;
235
+ let pathStarted = false;
236
+ function toPixel(t, v) {
237
+ const tPixel = timeScale(t);
238
+ const vPixel = valueScale(v);
239
+ return timeAxis === "x" ? [tPixel, vPixel] : [vPixel, tPixel];
240
+ }
241
+ function startSegment(color, x, y) {
242
+ ctx.beginPath();
243
+ ctx.strokeStyle = color;
244
+ ctx.moveTo(x, y);
245
+ pathStarted = true;
246
+ }
247
+ function endSegment() {
248
+ if (pathStarted) {
249
+ ctx.stroke();
250
+ pathStarted = false;
251
+ }
252
+ }
253
+ for (const d of data) {
254
+ const t = getTime(d);
255
+ const v = getValue(d);
256
+ if (t == null || v == null || Number.isNaN(t) || Number.isNaN(v)) {
257
+ endSegment();
258
+ prevX = null;
259
+ prevY = null;
260
+ prevValue = null;
261
+ prevColor = null;
262
+ continue;
263
+ }
264
+ const [x, y] = toPixel(t, v);
265
+ const currColor = resolveColor$1(v, colorThresholds, baseColor);
266
+ if (prevX === null || prevColor === null || prevValue === null) {
267
+ // First valid point
268
+ startSegment(currColor, x, y);
269
+ prevX = x;
270
+ prevY = y;
271
+ prevValue = v;
272
+ prevColor = currColor;
273
+ continue;
274
+ }
275
+ if (currColor === prevColor) {
276
+ ctx.lineTo(x, y);
277
+ }
278
+ else {
279
+ // Find all thresholds crossed between prevValue and v, sorted by interpolation t
280
+ const crossings = [];
281
+ for (const threshold of colorThresholds) {
282
+ const tv = threshold.value;
283
+ // Check if the threshold value lies between prevValue and v
284
+ if ((prevValue <= tv && v >= tv) || (prevValue >= tv && v <= tv)) {
285
+ // Don't add crossing at exact endpoints
286
+ if (prevValue !== tv && v !== tv) {
287
+ const interpT = (tv - prevValue) / (v - prevValue);
288
+ crossings.push({ t: interpT, color: "" }); // color resolved after sorting
289
+ }
290
+ }
291
+ }
292
+ // Sort crossings by interpolation parameter
293
+ crossings.sort((a, b) => a.t - b.t);
294
+ for (const crossing of crossings) {
295
+ const midX = prevX + (x - prevX) * crossing.t;
296
+ const midY = prevY + (y - prevY) * crossing.t;
297
+ // Nudge slightly past the crossing to determine the color on the other side
298
+ const nudgedValue = prevValue + (v - prevValue) * Math.min(crossing.t + 0.0001, 1);
299
+ const nextColor = resolveColor$1(nudgedValue, colorThresholds, baseColor);
300
+ ctx.lineTo(midX, midY);
301
+ endSegment();
302
+ startSegment(nextColor, midX, midY);
303
+ }
304
+ ctx.lineTo(x, y);
305
+ }
306
+ prevX = x;
307
+ prevY = y;
308
+ prevValue = v;
309
+ prevColor = currColor;
310
+ }
311
+ endSegment();
312
+ };
313
+
314
+ const DEFAULT_PALETTE$1 = [
315
+ "#007bff", "#28a745", "#dc3545", "#fd7e14", "#6f42c1",
316
+ "#20c997", "#e83e8c", "#17a2b8", "#6610f2", "#ffc107"
317
+ ];
318
+ function resolveColor(value, thresholds, baseColor) {
319
+ let color = baseColor;
320
+ for (const t of thresholds) {
321
+ if (t.thresholdType === "lesser") {
322
+ if (value < t.value)
323
+ color = t.color;
324
+ }
325
+ else {
326
+ if (value > t.value)
327
+ color = t.color;
328
+ }
329
+ }
330
+ return color;
331
+ }
332
+ const swarmRenderer = (ctx, data, scales, layout, style, accessors, annotations, options) => {
333
+ var _a, _b, _c, _d, _e;
334
+ const { time: timeScale, value: valueScale } = scales;
335
+ const { timeAxis } = layout;
336
+ const { time: getTime, value: getValue, category: getCategory } = accessors;
337
+ const ss = options === null || options === void 0 ? void 0 : options.swarmStyle;
338
+ const barColors = options === null || options === void 0 ? void 0 : options.barColors;
339
+ const radius = (_a = ss === null || ss === void 0 ? void 0 : ss.radius) !== null && _a !== void 0 ? _a : 3;
340
+ const defaultFill = (_c = (_b = ss === null || ss === void 0 ? void 0 : ss.fill) !== null && _b !== void 0 ? _b : style.stroke) !== null && _c !== void 0 ? _c : "#007bff";
341
+ const opacity = (_d = ss === null || ss === void 0 ? void 0 : ss.opacity) !== null && _d !== void 0 ? _d : 0.7;
342
+ const hasStroke = (ss === null || ss === void 0 ? void 0 : ss.stroke) != null;
343
+ // Extract color thresholds from annotations
344
+ const colorThresholds = annotations
345
+ ? annotations
346
+ .filter((a) => a.type === "threshold" && a.color)
347
+ .map((a) => ({
348
+ value: a.value,
349
+ color: a.color,
350
+ thresholdType: (a.thresholdType || "greater")
351
+ }))
352
+ : null;
353
+ const hasColorThresholds = colorThresholds && colorThresholds.length > 0;
354
+ ctx.globalAlpha = opacity;
355
+ let paletteIndex = 0;
356
+ const categoryColorCache = {};
357
+ for (const d of data) {
358
+ const t = getTime(d);
359
+ const v = getValue(d);
360
+ if (v == null || Number.isNaN(v))
361
+ continue;
362
+ let x, y;
363
+ if (timeAxis === "x") {
364
+ x = timeScale(t);
365
+ y = valueScale(v);
366
+ }
367
+ else {
368
+ x = valueScale(v);
369
+ y = timeScale(t);
370
+ }
371
+ // Determine fill color
372
+ let fill = defaultFill;
373
+ if (getCategory) {
374
+ const cat = getCategory(d);
375
+ if (barColors && barColors[cat]) {
376
+ fill = barColors[cat];
377
+ }
378
+ else {
379
+ if (!(cat in categoryColorCache)) {
380
+ categoryColorCache[cat] = DEFAULT_PALETTE$1[paletteIndex % DEFAULT_PALETTE$1.length];
381
+ paletteIndex++;
382
+ }
383
+ fill = categoryColorCache[cat];
384
+ }
385
+ }
386
+ // Threshold coloring overrides category/default fill
387
+ if (hasColorThresholds) {
388
+ fill = resolveColor(v, colorThresholds, fill);
389
+ }
390
+ ctx.fillStyle = fill;
391
+ ctx.beginPath();
392
+ ctx.arc(x, y, radius, 0, Math.PI * 2);
393
+ ctx.fill();
394
+ if (hasStroke) {
395
+ ctx.strokeStyle = ss.stroke;
396
+ ctx.lineWidth = (_e = ss === null || ss === void 0 ? void 0 : ss.strokeWidth) !== null && _e !== void 0 ? _e : 1;
397
+ ctx.stroke();
398
+ }
399
+ }
400
+ ctx.globalAlpha = 1;
401
+ };
402
+
403
+ const candlestickRenderer = () => {
404
+ throw new Error("candlestickRenderer: Not yet implemented");
405
+ };
406
+
407
+ const DEFAULT_POSITIVE_COLOR = "#28a745";
408
+ const DEFAULT_NEGATIVE_COLOR = "#dc3545";
409
+ function computeWaterfallExtent(data, getValue) {
410
+ let min = 0;
411
+ let max = 0;
412
+ let cumulative = 0;
413
+ for (const d of data) {
414
+ const v = getValue(d);
415
+ if (v == null || Number.isNaN(v))
416
+ continue;
417
+ cumulative += v;
418
+ if (cumulative < min)
419
+ min = cumulative;
420
+ if (cumulative > max)
421
+ max = cumulative;
422
+ }
423
+ return [min, max];
424
+ }
425
+ const waterfallRenderer = (ctx, data, scales, layout, style, accessors, annotations, options) => {
426
+ var _a, _b, _c, _d, _e, _f, _g;
427
+ const { time: timeScale, value: valueScale } = scales;
428
+ const { timeAxis, width, height } = layout;
429
+ const { time: getTime, value: getValue } = accessors;
430
+ const ws = options === null || options === void 0 ? void 0 : options.waterfallStyle;
431
+ const positiveColor = (_a = ws === null || ws === void 0 ? void 0 : ws.positiveColor) !== null && _a !== void 0 ? _a : DEFAULT_POSITIVE_COLOR;
432
+ const negativeColor = (_b = ws === null || ws === void 0 ? void 0 : ws.negativeColor) !== null && _b !== void 0 ? _b : DEFAULT_NEGATIVE_COLOR;
433
+ const gap = (_c = ws === null || ws === void 0 ? void 0 : ws.gap) !== null && _c !== void 0 ? _c : 1;
434
+ const connectorStroke = ws === null || ws === void 0 ? void 0 : ws.connectorStroke;
435
+ const connectorWidth = (_d = ws === null || ws === void 0 ? void 0 : ws.connectorWidth) !== null && _d !== void 0 ? _d : 1;
436
+ const hasStroke = (ws === null || ws === void 0 ? void 0 : ws.stroke) != null;
437
+ if (hasStroke) {
438
+ ctx.strokeStyle = ws.stroke;
439
+ ctx.lineWidth = (_e = ws === null || ws === void 0 ? void 0 : ws.strokeWidth) !== null && _e !== void 0 ? _e : 1;
440
+ }
441
+ // Collect into array for random access (skip NaN/null values)
442
+ const arr = [];
443
+ for (const d of data) {
444
+ const v = getValue(d);
445
+ if (v == null || Number.isNaN(v))
446
+ continue;
447
+ arr.push(d);
448
+ }
449
+ if (arr.length === 0)
450
+ return;
451
+ let baseline = 0;
452
+ // Track the end edge of the previous bar and its cumulative value for connectors
453
+ let prevEdge = null;
454
+ let prevCumulative = null;
455
+ for (let i = 0; i < arr.length; i++) {
456
+ const d = arr[i];
457
+ const t = getTime(d);
458
+ const delta = getValue(d);
459
+ const cumEnd = baseline + delta;
460
+ // Compute bar width from time gap to next point
461
+ let barWidthTime;
462
+ if (i < arr.length - 1) {
463
+ barWidthTime = getTime(arr[i + 1]) - t;
464
+ }
465
+ else if (i > 0) {
466
+ barWidthTime = t - getTime(arr[i - 1]);
467
+ }
468
+ else {
469
+ // Single point fallback: use 0 to trigger pixel fallback
470
+ barWidthTime = 0;
471
+ }
472
+ ctx.fillStyle = delta >= 0 ? positiveColor : negativeColor;
473
+ if (timeAxis === "x") {
474
+ let rawX0, rawX1;
475
+ if (barWidthTime !== 0) {
476
+ rawX0 = timeScale(t);
477
+ rawX1 = timeScale(t + barWidthTime);
478
+ }
479
+ else {
480
+ rawX0 = timeScale(t);
481
+ rawX1 = rawX0 + width / 10;
482
+ }
483
+ const x0 = Math.min(rawX0, rawX1) + gap / 2;
484
+ const x1 = Math.max(rawX0, rawX1) - gap / 2;
485
+ const barWidth = x1 - x0;
486
+ if (barWidth <= 0) {
487
+ baseline = cumEnd;
488
+ prevEdge = x1;
489
+ prevCumulative = cumEnd;
490
+ continue;
491
+ }
492
+ const yBaseline = valueScale(baseline);
493
+ const yTop = valueScale(cumEnd);
494
+ const rectY = Math.min(yBaseline, yTop);
495
+ const rectH = Math.abs(yBaseline - yTop);
496
+ // Connector line at the baseline level from previous bar's right edge to this bar's left edge
497
+ if (connectorStroke && prevEdge != null && prevCumulative != null) {
498
+ ctx.save();
499
+ ctx.strokeStyle = connectorStroke;
500
+ ctx.lineWidth = connectorWidth;
501
+ const connY = valueScale(prevCumulative);
502
+ ctx.beginPath();
503
+ ctx.moveTo(prevEdge, connY);
504
+ ctx.lineTo(x0, connY);
505
+ ctx.stroke();
506
+ ctx.restore();
507
+ if (hasStroke) {
508
+ ctx.strokeStyle = ws.stroke;
509
+ ctx.lineWidth = (_f = ws === null || ws === void 0 ? void 0 : ws.strokeWidth) !== null && _f !== void 0 ? _f : 1;
510
+ }
511
+ }
512
+ ctx.fillRect(x0, rectY, barWidth, rectH);
513
+ if (hasStroke)
514
+ ctx.strokeRect(x0, rectY, barWidth, rectH);
515
+ prevEdge = x1;
516
+ }
517
+ else {
518
+ // timeAxis === "y": horizontal bars
519
+ let rawY0, rawY1;
520
+ if (barWidthTime !== 0) {
521
+ rawY0 = timeScale(t);
522
+ rawY1 = timeScale(t + barWidthTime);
523
+ }
524
+ else {
525
+ rawY0 = timeScale(t);
526
+ rawY1 = rawY0 + height / 10;
527
+ }
528
+ const y0 = Math.min(rawY0, rawY1) + gap / 2;
529
+ const y1 = Math.max(rawY0, rawY1) - gap / 2;
530
+ const barHeight = y1 - y0;
531
+ if (barHeight <= 0) {
532
+ baseline = cumEnd;
533
+ prevEdge = y1;
534
+ prevCumulative = cumEnd;
535
+ continue;
536
+ }
537
+ const xBaseline = valueScale(baseline);
538
+ const xEnd = valueScale(cumEnd);
539
+ const rectX = Math.min(xBaseline, xEnd);
540
+ const rectW = Math.abs(xEnd - xBaseline);
541
+ // Connector line at the baseline level from previous bar's bottom edge to this bar's top edge
542
+ if (connectorStroke && prevEdge != null && prevCumulative != null) {
543
+ ctx.save();
544
+ ctx.strokeStyle = connectorStroke;
545
+ ctx.lineWidth = connectorWidth;
546
+ const connX = valueScale(prevCumulative);
547
+ ctx.beginPath();
548
+ ctx.moveTo(connX, prevEdge);
549
+ ctx.lineTo(connX, y0);
550
+ ctx.stroke();
551
+ ctx.restore();
552
+ if (hasStroke) {
553
+ ctx.strokeStyle = ws.stroke;
554
+ ctx.lineWidth = (_g = ws === null || ws === void 0 ? void 0 : ws.strokeWidth) !== null && _g !== void 0 ? _g : 1;
555
+ }
556
+ }
557
+ ctx.fillRect(rectX, y0, rectW, barHeight);
558
+ if (hasStroke)
559
+ ctx.strokeRect(rectX, y0, rectW, barHeight);
560
+ prevEdge = y1;
561
+ }
562
+ baseline = cumEnd;
563
+ prevCumulative = cumEnd;
564
+ }
565
+ };
566
+
567
+ function computeBins(data, getTime, getValue, binSize, getCategory) {
568
+ const bins = new Map();
569
+ for (const d of data) {
570
+ const t = getTime(d);
571
+ const v = getValue(d);
572
+ if (t == null || v == null || Number.isNaN(t) || Number.isNaN(v))
573
+ continue;
574
+ const binStart = Math.floor(t / binSize) * binSize;
575
+ let bin = bins.get(binStart);
576
+ if (!bin) {
577
+ bin = { start: binStart, end: binStart + binSize, total: 0, categories: new Map() };
578
+ bins.set(binStart, bin);
579
+ }
580
+ bin.total += v;
581
+ if (getCategory) {
582
+ const cat = getCategory(d);
583
+ bin.categories.set(cat, (bin.categories.get(cat) || 0) + v);
584
+ }
585
+ }
586
+ return bins;
587
+ }
588
+ function computeBinExtent(data, getTime, getValue, binSize, getCategory) {
589
+ const bins = computeBins(data, getTime, getValue, binSize, getCategory);
590
+ if (bins.size === 0)
591
+ return [0, 0];
592
+ let maxTotal = 0;
593
+ for (const bin of bins.values()) {
594
+ if (bin.total > maxTotal)
595
+ maxTotal = bin.total;
596
+ }
597
+ return [0, maxTotal];
598
+ }
599
+
600
+ const DEFAULT_PALETTE = [
601
+ "#4e79a7", "#f28e2b", "#e15759", "#76b7b2",
602
+ "#59a14f", "#edc948", "#b07aa1", "#ff9da7",
603
+ "#9c755f", "#bab0ac"
604
+ ];
605
+ const barRenderer = (ctx, data, scales, layout, style, accessors, annotations, options) => {
606
+ var _a, _b;
607
+ const binSize = options === null || options === void 0 ? void 0 : options.binSize;
608
+ if (!binSize)
609
+ return;
610
+ const { time: timeScale, value: valueScale } = scales;
611
+ const { timeAxis } = layout;
612
+ const { time: getTime, value: getValue, category: getCategory } = accessors;
613
+ const barColors = options === null || options === void 0 ? void 0 : options.barColors;
614
+ const barStyle = options === null || options === void 0 ? void 0 : options.barStyle;
615
+ const bins = computeBins(data, getTime, getValue, binSize, getCategory);
616
+ if (bins.size === 0)
617
+ return;
618
+ const [domainMin, domainMax] = timeScale.domain();
619
+ const gap = (_a = barStyle === null || barStyle === void 0 ? void 0 : barStyle.gap) !== null && _a !== void 0 ? _a : 1;
620
+ const hasCategories = getCategory != null;
621
+ // Determine category order: barColors keys first, then alphabetical for unlisted
622
+ let categoryOrder = null;
623
+ if (hasCategories) {
624
+ const allCategories = new Set();
625
+ for (const bin of bins.values()) {
626
+ for (const cat of bin.categories.keys()) {
627
+ allCategories.add(cat);
628
+ }
629
+ }
630
+ const colorKeys = barColors ? Object.keys(barColors) : [];
631
+ const listed = new Set(colorKeys);
632
+ const unlisted = Array.from(allCategories).filter(c => !listed.has(c)).sort();
633
+ categoryOrder = [...colorKeys.filter(k => allCategories.has(k)), ...unlisted];
634
+ }
635
+ // Bar stroke settings
636
+ const hasBarStroke = (barStyle === null || barStyle === void 0 ? void 0 : barStyle.stroke) != null;
637
+ if (hasBarStroke) {
638
+ ctx.strokeStyle = barStyle.stroke;
639
+ ctx.lineWidth = (_b = barStyle === null || barStyle === void 0 ? void 0 : barStyle.strokeWidth) !== null && _b !== void 0 ? _b : 1;
640
+ }
641
+ for (const bin of bins.values()) {
642
+ if (timeAxis === "x") {
643
+ const clampedStart = Math.max(bin.start, domainMin);
644
+ const clampedEnd = Math.min(bin.end, domainMax);
645
+ if (clampedStart >= clampedEnd)
646
+ continue;
647
+ const rawX0 = timeScale(clampedStart);
648
+ const rawX1 = timeScale(clampedEnd);
649
+ const x0 = Math.min(rawX0, rawX1) + gap / 2;
650
+ const x1 = Math.max(rawX0, rawX1) - gap / 2;
651
+ const barWidth = x1 - x0;
652
+ if (barWidth <= 0)
653
+ continue;
654
+ if (hasCategories && categoryOrder) {
655
+ let cumulativeBase = 0;
656
+ let paletteIdx = 0;
657
+ for (const cat of categoryOrder) {
658
+ const catVal = bin.categories.get(cat) || 0;
659
+ if (catVal === 0)
660
+ continue;
661
+ const yBottom = valueScale(cumulativeBase);
662
+ const yTop = valueScale(cumulativeBase + catVal);
663
+ const rectY = Math.min(yBottom, yTop);
664
+ const rectH = Math.abs(yBottom - yTop);
665
+ ctx.fillStyle = (barColors && barColors[cat]) || DEFAULT_PALETTE[paletteIdx % DEFAULT_PALETTE.length];
666
+ ctx.fillRect(x0, rectY, barWidth, rectH);
667
+ if (hasBarStroke)
668
+ ctx.strokeRect(x0, rectY, barWidth, rectH);
669
+ cumulativeBase += catVal;
670
+ paletteIdx++;
671
+ }
672
+ }
673
+ else {
674
+ const yZero = valueScale(0);
675
+ const yTop = valueScale(bin.total);
676
+ const rectY = Math.min(yZero, yTop);
677
+ const rectH = Math.abs(yZero - yTop);
678
+ ctx.fillStyle = (barStyle === null || barStyle === void 0 ? void 0 : barStyle.fill) || style.stroke || "#007bff";
679
+ ctx.fillRect(x0, rectY, barWidth, rectH);
680
+ if (hasBarStroke)
681
+ ctx.strokeRect(x0, rectY, barWidth, rectH);
682
+ }
683
+ }
684
+ else {
685
+ // timeAxis === "y": horizontal bars
686
+ const clampedStart = Math.max(bin.start, domainMin);
687
+ const clampedEnd = Math.min(bin.end, domainMax);
688
+ if (clampedStart >= clampedEnd)
689
+ continue;
690
+ const rawY0 = timeScale(clampedStart);
691
+ const rawY1 = timeScale(clampedEnd);
692
+ const y0 = Math.min(rawY0, rawY1) + gap / 2;
693
+ const y1 = Math.max(rawY0, rawY1) - gap / 2;
694
+ const barHeight = y1 - y0;
695
+ if (barHeight <= 0)
696
+ continue;
697
+ if (hasCategories && categoryOrder) {
698
+ let cumulativeBase = 0;
699
+ let paletteIdx = 0;
700
+ for (const cat of categoryOrder) {
701
+ const catVal = bin.categories.get(cat) || 0;
702
+ if (catVal === 0)
703
+ continue;
704
+ const xLeft = valueScale(cumulativeBase);
705
+ const xRight = valueScale(cumulativeBase + catVal);
706
+ const rectX = Math.min(xLeft, xRight);
707
+ const rectW = Math.abs(xRight - xLeft);
708
+ ctx.fillStyle = (barColors && barColors[cat]) || DEFAULT_PALETTE[paletteIdx % DEFAULT_PALETTE.length];
709
+ ctx.fillRect(rectX, y0, rectW, barHeight);
710
+ if (hasBarStroke)
711
+ ctx.strokeRect(rectX, y0, rectW, barHeight);
712
+ cumulativeBase += catVal;
713
+ paletteIdx++;
714
+ }
715
+ }
716
+ else {
717
+ const xZero = valueScale(0);
718
+ const xEnd = valueScale(bin.total);
719
+ const rectX = Math.min(xZero, xEnd);
720
+ const rectW = Math.abs(xEnd - xZero);
721
+ ctx.fillStyle = (barStyle === null || barStyle === void 0 ? void 0 : barStyle.fill) || style.stroke || "#007bff";
722
+ ctx.fillRect(rectX, y0, rectW, barHeight);
723
+ if (hasBarStroke)
724
+ ctx.strokeRect(rectX, y0, rectW, barHeight);
725
+ }
726
+ }
727
+ }
728
+ };
729
+
730
+ const RENDERERS = {
731
+ line: lineRenderer,
732
+ swarm: swarmRenderer,
733
+ candlestick: candlestickRenderer,
734
+ waterfall: waterfallRenderer,
735
+ bar: barRenderer
736
+ };
737
+ const DEFAULT_MARGIN = { top: 20, right: 20, bottom: 30, left: 40 };
738
+ const DEFAULT_LINE_STYLE = {};
739
+ function resolveAccessor(accessor, fallback) {
740
+ if (typeof accessor === "function")
741
+ return (d) => +accessor(d);
742
+ const key = accessor || fallback;
743
+ return (d) => +d[key];
744
+ }
745
+ function getTimeAxis(arrowOfTime) {
746
+ return arrowOfTime === "up" || arrowOfTime === "down" ? "y" : "x";
747
+ }
748
+ function buildScales(arrowOfTime, timeExtent, valueExtent, width, height) {
749
+ const timeAxis = getTimeAxis(arrowOfTime);
750
+ let timeRange;
751
+ let valueRange;
752
+ if (timeAxis === "x") {
753
+ timeRange = arrowOfTime === "right" ? [0, width] : [width, 0];
754
+ valueRange = [height, 0];
755
+ }
756
+ else {
757
+ timeRange = arrowOfTime === "down" ? [0, height] : [height, 0];
758
+ valueRange = [0, width];
759
+ }
760
+ return {
761
+ time: scaleLinear().domain(timeExtent).range(timeRange),
762
+ value: scaleLinear().domain(valueExtent).range(valueRange)
763
+ };
764
+ }
765
+ function defaultTickFormat(v) {
766
+ return String(Math.round(v * 100) / 100);
767
+ }
768
+ const LIGHT_THEME = {
769
+ axisStroke: "#ccc",
770
+ tickText: "#666",
771
+ crosshair: "rgba(0, 0, 0, 0.25)",
772
+ hoverFill: "rgba(255, 255, 255, 0.3)",
773
+ hoverStroke: "rgba(0, 0, 0, 0.4)",
774
+ pointRing: "white"
775
+ };
776
+ /** Read CSS custom properties from an element to build theme-aware colors */
777
+ function resolveThemeColors(el) {
778
+ if (!el)
779
+ return LIGHT_THEME;
780
+ const style = getComputedStyle(el);
781
+ const textSecondary = style.getPropertyValue("--text-secondary").trim();
782
+ const textPrimary = style.getPropertyValue("--text-primary").trim();
783
+ const surface3 = style.getPropertyValue("--surface-3").trim();
784
+ const surface0 = style.getPropertyValue("--surface-0").trim();
785
+ // If no CSS custom properties are found, fall back to light defaults
786
+ if (!textSecondary && !textPrimary)
787
+ return LIGHT_THEME;
788
+ return {
789
+ axisStroke: surface3 || LIGHT_THEME.axisStroke,
790
+ tickText: textSecondary || LIGHT_THEME.tickText,
791
+ crosshair: textSecondary ? `${textSecondary}66` : LIGHT_THEME.crosshair,
792
+ hoverFill: surface0 ? `${surface0}4D` : LIGHT_THEME.hoverFill,
793
+ hoverStroke: textSecondary ? `${textSecondary}99` : LIGHT_THEME.hoverStroke,
794
+ pointRing: surface0 || LIGHT_THEME.pointRing
795
+ };
796
+ }
797
+ function drawAxes(ctx, arrowOfTime, timeScale, valueScale, width, height, tickFormatTime, tickFormatValue, theme) {
798
+ const timeAxis = getTimeAxis(arrowOfTime);
799
+ const fmtValue = tickFormatValue || defaultTickFormat;
800
+ const colors = theme || LIGHT_THEME;
801
+ ctx.strokeStyle = colors.axisStroke;
802
+ ctx.lineWidth = 1;
803
+ ctx.fillStyle = colors.tickText;
804
+ ctx.font = "10px sans-serif";
805
+ ctx.textAlign = "center";
806
+ ctx.textBaseline = "top";
807
+ if (timeAxis === "x") {
808
+ ctx.beginPath();
809
+ ctx.moveTo(0, height);
810
+ ctx.lineTo(width, height);
811
+ ctx.stroke();
812
+ ctx.beginPath();
813
+ ctx.moveTo(0, 0);
814
+ ctx.lineTo(0, height);
815
+ ctx.stroke();
816
+ const timeTicks = timeScale.ticks(5);
817
+ ctx.textAlign = "center";
818
+ ctx.textBaseline = "top";
819
+ for (const tick of timeTicks) {
820
+ const x = timeScale(tick);
821
+ ctx.beginPath();
822
+ ctx.moveTo(x, height);
823
+ ctx.lineTo(x, height + 5);
824
+ ctx.stroke();
825
+ if (tickFormatTime) {
826
+ ctx.fillText(tickFormatTime(tick), x, height + 7);
827
+ }
828
+ }
829
+ ctx.textAlign = "right";
830
+ ctx.textBaseline = "middle";
831
+ const valueTicks = valueScale.ticks(5);
832
+ for (const tick of valueTicks) {
833
+ const y = valueScale(tick);
834
+ ctx.beginPath();
835
+ ctx.moveTo(-5, y);
836
+ ctx.lineTo(0, y);
837
+ ctx.stroke();
838
+ ctx.fillText(fmtValue(tick), -8, y);
839
+ }
840
+ }
841
+ else {
842
+ ctx.beginPath();
843
+ ctx.moveTo(0, 0);
844
+ ctx.lineTo(0, height);
845
+ ctx.stroke();
846
+ ctx.beginPath();
847
+ ctx.moveTo(0, timeAxis === "y" && arrowOfTime === "down" ? 0 : height);
848
+ ctx.lineTo(width, timeAxis === "y" && arrowOfTime === "down" ? 0 : height);
849
+ ctx.stroke();
850
+ ctx.textAlign = "center";
851
+ ctx.textBaseline = "top";
852
+ const valueTicks = valueScale.ticks(5);
853
+ for (const tick of valueTicks) {
854
+ const x = valueScale(tick);
855
+ ctx.beginPath();
856
+ ctx.moveTo(x, height);
857
+ ctx.lineTo(x, height + 5);
858
+ ctx.stroke();
859
+ ctx.fillText(fmtValue(tick), x, height + 7);
860
+ }
861
+ ctx.textAlign = "right";
862
+ ctx.textBaseline = "middle";
863
+ const timeTicks = timeScale.ticks(5);
864
+ for (const tick of timeTicks) {
865
+ const y = timeScale(tick);
866
+ ctx.beginPath();
867
+ ctx.moveTo(-5, y);
868
+ ctx.lineTo(0, y);
869
+ ctx.stroke();
870
+ if (tickFormatTime) {
871
+ ctx.fillText(tickFormatTime(tick), -8, y);
872
+ }
873
+ }
874
+ }
875
+ }
876
+ // Binary search: find the index of the nearest point by time value
877
+ function findNearestIndex(buf, targetTime, getTime) {
878
+ if (buf.size === 0)
879
+ return -1;
880
+ let lo = 0;
881
+ let hi = buf.size - 1;
882
+ while (lo < hi) {
883
+ const mid = (lo + hi) >> 1;
884
+ const t = getTime(buf.get(mid));
885
+ if (t < targetTime)
886
+ lo = mid + 1;
887
+ else
888
+ hi = mid;
889
+ }
890
+ // lo is first point with time >= targetTime; check if lo-1 is closer
891
+ if (lo > 0) {
892
+ const tLo = getTime(buf.get(lo));
893
+ const tPrev = getTime(buf.get(lo - 1));
894
+ if (Math.abs(tPrev - targetTime) <= Math.abs(tLo - targetTime)) {
895
+ return lo - 1;
896
+ }
897
+ }
898
+ return lo;
899
+ }
900
+ function drawCrosshair(ctx, hover, width, height, config, pointColor, theme) {
901
+ const showCrosshair = config.crosshair !== false;
902
+ if (!showCrosshair)
903
+ return;
904
+ const colors = theme || LIGHT_THEME;
905
+ ctx.save();
906
+ const crossStyle = typeof config.crosshair === "object" ? config.crosshair : {};
907
+ ctx.strokeStyle = crossStyle.stroke || colors.crosshair;
908
+ ctx.lineWidth = crossStyle.strokeWidth || 1;
909
+ if (crossStyle.strokeDasharray) {
910
+ ctx.setLineDash(crossStyle.strokeDasharray.split(/[\s,]+/).map(Number));
911
+ }
912
+ else {
913
+ ctx.setLineDash([4, 4]);
914
+ }
915
+ // Vertical guide
916
+ ctx.beginPath();
917
+ ctx.moveTo(hover.x, 0);
918
+ ctx.lineTo(hover.x, height);
919
+ ctx.stroke();
920
+ // Horizontal guide
921
+ ctx.beginPath();
922
+ ctx.moveTo(0, hover.y);
923
+ ctx.lineTo(width, hover.y);
924
+ ctx.stroke();
925
+ ctx.restore();
926
+ // Point indicator
927
+ ctx.beginPath();
928
+ ctx.arc(hover.x, hover.y, 4, 0, Math.PI * 2);
929
+ ctx.fillStyle = pointColor;
930
+ ctx.fill();
931
+ ctx.strokeStyle = colors.pointRing;
932
+ ctx.lineWidth = 2;
933
+ ctx.stroke();
934
+ }
935
+ const defaultTooltipStyle = {
936
+ background: "rgba(0, 0, 0, 0.85)",
937
+ color: "white",
938
+ padding: "6px 10px",
939
+ borderRadius: 4,
940
+ fontSize: 12,
941
+ lineHeight: 1.5,
942
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
943
+ pointerEvents: "none",
944
+ whiteSpace: "nowrap"
945
+ };
946
+ function DefaultTooltip({ hover, formatTime }) {
947
+ const fmtValue = (v) => Number.isInteger(v) ? String(v) : v.toFixed(2);
948
+ const fmtTime = formatTime || fmtValue;
949
+ const colorMap = hover.data.barColors;
950
+ const hoveredCat = hover.data.hoveredCategory;
951
+ const hoveredCatVal = hover.data.hoveredCategoryValue;
952
+ return (React.createElement("div", { className: "semiotic-tooltip", style: defaultTooltipStyle },
953
+ hoveredCat != null && hoveredCatVal != null ? (React.createElement(React.Fragment, null,
954
+ React.createElement("div", { style: { display: "flex", alignItems: "center", gap: 5, fontWeight: 600, marginBottom: 2 } },
955
+ colorMap && colorMap[hoveredCat] && (React.createElement("span", { style: { width: 8, height: 8, borderRadius: "50%", background: colorMap[hoveredCat], flexShrink: 0 } })),
956
+ React.createElement("span", null, hoveredCat),
957
+ React.createElement("span", { style: { marginLeft: "auto" } }, fmtValue(hoveredCatVal))),
958
+ React.createElement("div", { style: { opacity: 0.6, fontSize: 11 } },
959
+ "total ",
960
+ fmtValue(hover.value)))) : (React.createElement("div", { style: { fontWeight: 600, marginBottom: 2 } }, fmtValue(hover.value))),
961
+ React.createElement("div", { style: { opacity: 0.7, fontSize: 11 } }, fmtTime(hover.time))));
962
+ }
963
+ const RealtimeFrame = forwardRef(function RealtimeFrame(props, ref) {
964
+ const { chartType = "line", arrowOfTime = "right", windowMode = "sliding", windowSize = 200, data, timeAccessor, valueAccessor, timeExtent: fixedTimeExtent, valueExtent: fixedValueExtent, extentPadding = 0.1, size = [500, 300], margin: marginProp, className, lineStyle = DEFAULT_LINE_STYLE, annotations, svgAnnotationRules, hoverAnnotation, tooltipContent, customHoverBehavior, showAxes = true, background, categoryAccessor, binSize, barColors, barStyle, waterfallStyle, swarmStyle, tickFormatTime, tickFormatValue } = props;
965
+ const margin = Object.assign(Object.assign({}, DEFAULT_MARGIN), marginProp);
966
+ const adjustedWidth = size[0] - margin.left - margin.right;
967
+ const adjustedHeight = size[1] - margin.top - margin.bottom;
968
+ // Memoize accessors so they don't change every render.
969
+ // Without this, the data effect re-runs on every render
970
+ // (new function reference), which triggers cascading re-renders.
971
+ // eslint-disable-next-line react-hooks/exhaustive-deps
972
+ const getTime = useMemo(() => resolveAccessor(timeAccessor, "time"), [timeAccessor]);
973
+ // eslint-disable-next-line react-hooks/exhaustive-deps
974
+ const getValue = useMemo(() => resolveAccessor(valueAccessor, "value"), [valueAccessor]);
975
+ const getCategory = useMemo(() => categoryAccessor
976
+ ? (typeof categoryAccessor === "function" ? categoryAccessor : (d) => d[categoryAccessor])
977
+ : undefined, [categoryAccessor]);
978
+ const bufferRef = useRef(new RingBuffer(windowSize));
979
+ const timeExtentRef = useRef(new IncrementalExtent());
980
+ const valueExtentRef = useRef(new IncrementalExtent());
981
+ const canvasRef = useRef(null);
982
+ const rafRef = useRef(0);
983
+ const dirtyRef = useRef(false);
984
+ const scalesRef = useRef(null);
985
+ const [annotationFrame, setAnnotationFrame] = useState(0);
986
+ const growingCapRef = useRef(windowSize);
987
+ // Hover state: ref for canvas (sync), React state for tooltip (async)
988
+ const hoverRef = useRef(null);
989
+ const [hoverPoint, setHoverPoint] = useState(null);
990
+ // Store the render function in a ref so scheduleRender is stable
991
+ // and never goes stale. The ref is updated every React render
992
+ // (below the hooks) so it always captures fresh props/closures.
993
+ const renderFnRef = useRef(() => { });
994
+ // Stable scheduleRender — never recreated, so no stale closure chain
995
+ const scheduleRender = useCallback(() => {
996
+ if (rafRef.current)
997
+ return;
998
+ rafRef.current = requestAnimationFrame(() => renderFnRef.current());
999
+ }, []);
1000
+ const pushPoint = useCallback((point) => {
1001
+ const buf = bufferRef.current;
1002
+ const t = getTime(point);
1003
+ const v = getValue(point);
1004
+ if (windowMode === "growing" && buf.full) {
1005
+ growingCapRef.current *= 2;
1006
+ buf.resize(growingCapRef.current);
1007
+ }
1008
+ const evicted = buf.push(point);
1009
+ timeExtentRef.current.push(t);
1010
+ valueExtentRef.current.push(v);
1011
+ if (evicted != null) {
1012
+ timeExtentRef.current.evict(getTime(evicted));
1013
+ valueExtentRef.current.evict(getValue(evicted));
1014
+ }
1015
+ dirtyRef.current = true;
1016
+ scheduleRender();
1017
+ }, [windowMode, getTime, getValue, scheduleRender]);
1018
+ const pushManyPoints = useCallback((points) => {
1019
+ for (const p of points) {
1020
+ pushPoint(p);
1021
+ }
1022
+ }, [pushPoint]);
1023
+ const clearAll = useCallback(() => {
1024
+ bufferRef.current.clear();
1025
+ timeExtentRef.current.clear();
1026
+ valueExtentRef.current.clear();
1027
+ dirtyRef.current = true;
1028
+ scheduleRender();
1029
+ }, [scheduleRender]);
1030
+ useImperativeHandle(ref, () => ({
1031
+ push: pushPoint,
1032
+ pushMany: pushManyPoints,
1033
+ clear: clearAll,
1034
+ getData: () => bufferRef.current.toArray()
1035
+ }), [pushPoint, pushManyPoints, clearAll]);
1036
+ // Controlled data prop
1037
+ useEffect(() => {
1038
+ if (!data)
1039
+ return;
1040
+ bufferRef.current.clear();
1041
+ timeExtentRef.current.clear();
1042
+ valueExtentRef.current.clear();
1043
+ for (const d of data) {
1044
+ bufferRef.current.push(d);
1045
+ timeExtentRef.current.push(getTime(d));
1046
+ valueExtentRef.current.push(getValue(d));
1047
+ }
1048
+ dirtyRef.current = true;
1049
+ scheduleRender();
1050
+ }, [data, getTime, getValue, scheduleRender]);
1051
+ // Hover mouse handler — stored in ref so it always captures fresh closures
1052
+ const hoverHandlerRef = useRef(() => { });
1053
+ const hoverLeaveRef = useRef(() => { });
1054
+ hoverHandlerRef.current = (e) => {
1055
+ if (!hoverAnnotation)
1056
+ return;
1057
+ const canvas = canvasRef.current;
1058
+ if (!canvas)
1059
+ return;
1060
+ const rect = canvas.getBoundingClientRect();
1061
+ // Mouse position in chart coordinates (canvas is full-size, ctx translated by margin)
1062
+ const chartX = e.clientX - rect.left - margin.left;
1063
+ const chartY = e.clientY - rect.top - margin.top;
1064
+ // Outside chart area → clear hover
1065
+ if (chartX < 0 || chartX > adjustedWidth || chartY < 0 || chartY > adjustedHeight) {
1066
+ if (hoverRef.current) {
1067
+ hoverRef.current = null;
1068
+ setHoverPoint(null);
1069
+ if (customHoverBehavior)
1070
+ customHoverBehavior(null);
1071
+ scheduleRender();
1072
+ }
1073
+ return;
1074
+ }
1075
+ const scales = scalesRef.current;
1076
+ if (!scales)
1077
+ return;
1078
+ const buf = bufferRef.current;
1079
+ if (buf.size === 0)
1080
+ return;
1081
+ const timeAxis = getTimeAxis(arrowOfTime);
1082
+ const timePixel = timeAxis === "x" ? chartX : chartY;
1083
+ const targetTime = scales.time.invert(timePixel);
1084
+ let hover;
1085
+ if (chartType === "bar" && binSize) {
1086
+ // Snap to the bin the cursor is in
1087
+ const bins = computeBins(buf, getTime, getValue, binSize, getCategory);
1088
+ const binStart = Math.floor(targetTime / binSize) * binSize;
1089
+ const bin = bins.get(binStart);
1090
+ if (!bin)
1091
+ return;
1092
+ const [domainMin, domainMax] = scales.time.domain();
1093
+ const clampedStart = Math.max(bin.start, domainMin);
1094
+ const clampedEnd = Math.min(bin.end, domainMax);
1095
+ const midTime = clampedStart + (clampedEnd - clampedStart) / 2;
1096
+ const tPixel = scales.time(midTime);
1097
+ const vPixel = scales.value(bin.total);
1098
+ const x = timeAxis === "x" ? tPixel : vPixel;
1099
+ const y = timeAxis === "x" ? vPixel : tPixel;
1100
+ // Hit-test which category segment the cursor is in
1101
+ let hoveredCategory;
1102
+ let hoveredCategoryValue;
1103
+ if (getCategory && bin.categories.size > 0) {
1104
+ const colorKeys = barColors ? Object.keys(barColors) : [];
1105
+ const listed = new Set(colorKeys);
1106
+ const unlisted = Array.from(bin.categories.keys()).filter(c => !listed.has(c)).sort();
1107
+ const catOrder = [...colorKeys.filter(k => bin.categories.has(k)), ...unlisted];
1108
+ const valuePixel = timeAxis === "x" ? chartY : chartX;
1109
+ let cumBase = 0;
1110
+ for (const cat of catOrder) {
1111
+ const catVal = bin.categories.get(cat) || 0;
1112
+ if (catVal === 0)
1113
+ continue;
1114
+ const edgeA = scales.value(cumBase);
1115
+ const edgeB = scales.value(cumBase + catVal);
1116
+ const lo = Math.min(edgeA, edgeB);
1117
+ const hi = Math.max(edgeA, edgeB);
1118
+ if (valuePixel >= lo && valuePixel <= hi) {
1119
+ hoveredCategory = cat;
1120
+ hoveredCategoryValue = catVal;
1121
+ break;
1122
+ }
1123
+ cumBase += catVal;
1124
+ }
1125
+ }
1126
+ hover = {
1127
+ data: {
1128
+ binStart: bin.start, binEnd: bin.end, total: bin.total,
1129
+ categories: Object.fromEntries(bin.categories),
1130
+ barColors: barColors || {},
1131
+ hoveredCategory,
1132
+ hoveredCategoryValue
1133
+ },
1134
+ time: midTime,
1135
+ value: bin.total,
1136
+ x,
1137
+ y
1138
+ };
1139
+ }
1140
+ else {
1141
+ const idx = findNearestIndex(buf, targetTime, getTime);
1142
+ if (idx < 0)
1143
+ return;
1144
+ const d = buf.get(idx);
1145
+ const t = getTime(d);
1146
+ const v = getValue(d);
1147
+ const tPixel = scales.time(t);
1148
+ const vPixel = scales.value(v);
1149
+ const x = timeAxis === "x" ? tPixel : vPixel;
1150
+ const y = timeAxis === "x" ? vPixel : tPixel;
1151
+ hover = { data: d, time: t, value: v, x, y };
1152
+ }
1153
+ hoverRef.current = hover;
1154
+ setHoverPoint(hover);
1155
+ if (customHoverBehavior)
1156
+ customHoverBehavior(hover);
1157
+ scheduleRender();
1158
+ };
1159
+ hoverLeaveRef.current = () => {
1160
+ if (hoverRef.current) {
1161
+ hoverRef.current = null;
1162
+ setHoverPoint(null);
1163
+ if (customHoverBehavior)
1164
+ customHoverBehavior(null);
1165
+ scheduleRender();
1166
+ }
1167
+ };
1168
+ // Stable event handlers that delegate to refs
1169
+ const onMouseMove = useCallback((e) => hoverHandlerRef.current(e), []);
1170
+ const onMouseLeave = useCallback(() => hoverLeaveRef.current(), []);
1171
+ // Update the render function ref on every React render.
1172
+ // This captures the latest props (arrowOfTime, chartType, lineStyle,
1173
+ // annotations, etc.) without needing useCallback dependency chains.
1174
+ // The rAF loop calls this via renderFnRef, so it always sees fresh values.
1175
+ renderFnRef.current = () => {
1176
+ var _a;
1177
+ rafRef.current = 0;
1178
+ const canvas = canvasRef.current;
1179
+ if (!canvas)
1180
+ return;
1181
+ const ctx = canvas.getContext("2d");
1182
+ if (!ctx)
1183
+ return;
1184
+ const buf = bufferRef.current;
1185
+ const tExtent = timeExtentRef.current;
1186
+ const vExtent = valueExtentRef.current;
1187
+ if (tExtent.dirty) {
1188
+ tExtent.recalculate(buf, getTime);
1189
+ }
1190
+ if (vExtent.dirty) {
1191
+ vExtent.recalculate(buf, getValue);
1192
+ }
1193
+ let tDomain = fixedTimeExtent || tExtent.extent;
1194
+ let vDomain = fixedValueExtent || vExtent.extent;
1195
+ if (chartType === "bar" && binSize && !fixedValueExtent && buf.size > 0) {
1196
+ const [, maxTotal] = computeBinExtent(buf, getTime, getValue, binSize, getCategory);
1197
+ vDomain = [0, maxTotal + maxTotal * extentPadding];
1198
+ }
1199
+ else if (chartType === "waterfall" && !fixedValueExtent && buf.size > 0) {
1200
+ const [minCum, maxCum] = computeWaterfallExtent(buf, getValue);
1201
+ const range = maxCum - minCum;
1202
+ const pad = range > 0 ? range * extentPadding : 1;
1203
+ vDomain = [
1204
+ Math.min(0, minCum - Math.abs(pad)),
1205
+ Math.max(0, maxCum + Math.abs(pad))
1206
+ ];
1207
+ }
1208
+ else if (!fixedValueExtent && vDomain[0] !== Infinity) {
1209
+ const range = vDomain[1] - vDomain[0];
1210
+ const pad = range > 0 ? range * extentPadding : 1;
1211
+ vDomain = [vDomain[0] - pad, vDomain[1] + pad];
1212
+ }
1213
+ if (tDomain[0] === Infinity || tDomain[1] === -Infinity) {
1214
+ tDomain = [0, 1];
1215
+ }
1216
+ if (vDomain[0] === Infinity || vDomain[1] === -Infinity) {
1217
+ vDomain = [0, 1];
1218
+ }
1219
+ const scales = buildScales(arrowOfTime, tDomain, vDomain, adjustedWidth, adjustedHeight);
1220
+ scalesRef.current = scales;
1221
+ const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
1222
+ canvas.width = size[0] * dpr;
1223
+ canvas.height = size[1] * dpr;
1224
+ canvas.style.width = `${size[0]}px`;
1225
+ canvas.style.height = `${size[1]}px`;
1226
+ ctx.scale(dpr, dpr);
1227
+ ctx.translate(margin.left, margin.top);
1228
+ ctx.clearRect(-margin.left, -margin.top, size[0], size[1]);
1229
+ // Resolve theme colors from CSS custom properties for theme-aware rendering
1230
+ const theme = resolveThemeColors(canvas);
1231
+ if (background) {
1232
+ ctx.fillStyle = background;
1233
+ ctx.fillRect(0, 0, adjustedWidth, adjustedHeight);
1234
+ }
1235
+ if (showAxes) {
1236
+ ctx.save();
1237
+ drawAxes(ctx, arrowOfTime, scales.time, scales.value, adjustedWidth, adjustedHeight, tickFormatTime, tickFormatValue, theme);
1238
+ ctx.restore();
1239
+ }
1240
+ const renderer = RENDERERS[chartType];
1241
+ if (renderer) {
1242
+ const layout = {
1243
+ width: adjustedWidth,
1244
+ height: adjustedHeight,
1245
+ timeAxis: getTimeAxis(arrowOfTime)
1246
+ };
1247
+ renderer(ctx, buf, scales, layout, lineStyle, { time: getTime, value: getValue, category: getCategory }, annotations, chartType === "bar" ? { binSize, barColors, barStyle }
1248
+ : chartType === "waterfall" ? { waterfallStyle }
1249
+ : chartType === "swarm" ? { swarmStyle, barColors }
1250
+ : undefined);
1251
+ }
1252
+ // Draw bar highlight on hovered bin/segment
1253
+ if (hoverAnnotation && hoverRef.current && chartType === "bar" && binSize) {
1254
+ const hd = hoverRef.current.data;
1255
+ if (hd.binStart != null) {
1256
+ const gap = (_a = barStyle === null || barStyle === void 0 ? void 0 : barStyle.gap) !== null && _a !== void 0 ? _a : 1;
1257
+ const tAxis = getTimeAxis(arrowOfTime);
1258
+ // Determine which segment to highlight
1259
+ const segBase = hd.hoveredCategory != null
1260
+ ? (() => {
1261
+ // Walk categories to find the cumulative base of the hovered segment
1262
+ const cats = hd.categories || {};
1263
+ const colorKeys = barColors ? Object.keys(barColors) : [];
1264
+ const listed = new Set(colorKeys);
1265
+ const unlisted = Object.keys(cats).filter((c) => !listed.has(c)).sort();
1266
+ const catOrder = [...colorKeys.filter((k) => k in cats), ...unlisted];
1267
+ let base = 0;
1268
+ for (const cat of catOrder) {
1269
+ if (cat === hd.hoveredCategory)
1270
+ return base;
1271
+ base += cats[cat] || 0;
1272
+ }
1273
+ return base;
1274
+ })()
1275
+ : 0;
1276
+ const segTop = hd.hoveredCategory != null
1277
+ ? segBase + (hd.hoveredCategoryValue || 0)
1278
+ : hd.total;
1279
+ const [domainMin, domainMax] = scales.time.domain();
1280
+ const clampedBinStart = Math.max(hd.binStart, domainMin);
1281
+ const clampedBinEnd = Math.min(hd.binEnd, domainMax);
1282
+ if (tAxis === "x") {
1283
+ const rawX0 = scales.time(clampedBinStart);
1284
+ const rawX1 = scales.time(clampedBinEnd);
1285
+ const x0 = Math.min(rawX0, rawX1) + gap / 2;
1286
+ const x1 = Math.max(rawX0, rawX1) - gap / 2;
1287
+ const yBot = scales.value(segBase);
1288
+ const yTop = scales.value(segTop);
1289
+ const ry = Math.min(yBot, yTop);
1290
+ const rh = Math.abs(yBot - yTop);
1291
+ ctx.fillStyle = theme.hoverFill;
1292
+ ctx.fillRect(x0, ry, x1 - x0, rh);
1293
+ ctx.strokeStyle = theme.hoverStroke;
1294
+ ctx.lineWidth = 1;
1295
+ ctx.setLineDash([]);
1296
+ ctx.strokeRect(x0, ry, x1 - x0, rh);
1297
+ }
1298
+ else {
1299
+ const rawY0 = scales.time(clampedBinStart);
1300
+ const rawY1 = scales.time(clampedBinEnd);
1301
+ const y0 = Math.min(rawY0, rawY1) + gap / 2;
1302
+ const y1 = Math.max(rawY0, rawY1) - gap / 2;
1303
+ const xLeft = scales.value(segBase);
1304
+ const xRight = scales.value(segTop);
1305
+ const rx = Math.min(xLeft, xRight);
1306
+ const rw = Math.abs(xRight - xLeft);
1307
+ ctx.fillStyle = theme.hoverFill;
1308
+ ctx.fillRect(rx, y0, rw, y1 - y0);
1309
+ ctx.strokeStyle = theme.hoverStroke;
1310
+ ctx.lineWidth = 1;
1311
+ ctx.setLineDash([]);
1312
+ ctx.strokeRect(rx, y0, rw, y1 - y0);
1313
+ }
1314
+ }
1315
+ }
1316
+ // Draw crosshair after chart data so it renders on top
1317
+ if (hoverAnnotation && hoverRef.current) {
1318
+ const config = typeof hoverAnnotation === "object" ? hoverAnnotation : {};
1319
+ drawCrosshair(ctx, hoverRef.current, adjustedWidth, adjustedHeight, config, lineStyle.stroke || "#007bff", theme);
1320
+ }
1321
+ const wasDirty = dirtyRef.current;
1322
+ dirtyRef.current = false;
1323
+ // Trigger React re-render so SVG annotations recompute positions
1324
+ // using the scales we just stored in scalesRef.
1325
+ // Only do this when data actually changed (wasDirty) to avoid
1326
+ // setAnnotationFrame → re-render → effect → scheduleRender → loop.
1327
+ if (wasDirty && annotations && annotations.length > 0 && svgAnnotationRules) {
1328
+ setAnnotationFrame(f => f + 1);
1329
+ }
1330
+ };
1331
+ // Initial render and cleanup
1332
+ useEffect(() => {
1333
+ scheduleRender();
1334
+ return () => {
1335
+ if (rafRef.current) {
1336
+ cancelAnimationFrame(rafRef.current);
1337
+ }
1338
+ };
1339
+ }, [scheduleRender]);
1340
+ // Re-render canvas when visual props change
1341
+ useEffect(() => {
1342
+ dirtyRef.current = true;
1343
+ scheduleRender();
1344
+ }, [arrowOfTime, chartType, adjustedWidth, adjustedHeight, showAxes, background, lineStyle, scheduleRender]);
1345
+ // Compute annotation elements during React render using latest scales
1346
+ const renderedAnnotations = React.useMemo(() => {
1347
+ if (!annotations || annotations.length === 0 || !svgAnnotationRules) {
1348
+ return null;
1349
+ }
1350
+ const scales = scalesRef.current;
1351
+ const timeAxis = getTimeAxis(arrowOfTime);
1352
+ return annotations
1353
+ .map((annotation, i) => svgAnnotationRules(annotation, i, {
1354
+ scales,
1355
+ timeAxis,
1356
+ width: adjustedWidth,
1357
+ height: adjustedHeight
1358
+ }))
1359
+ .filter(Boolean);
1360
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1361
+ }, [annotations, svgAnnotationRules, arrowOfTime, adjustedWidth, adjustedHeight, annotationFrame]);
1362
+ const hasAnnotations = renderedAnnotations && renderedAnnotations.length > 0;
1363
+ // Tooltip positioning: anchor at the hovered point, flip if near edges
1364
+ const tooltipElement = hoverAnnotation && hoverPoint ? (React.createElement("div", { className: "realtime-frame-tooltip", style: {
1365
+ position: "absolute",
1366
+ left: margin.left + hoverPoint.x,
1367
+ top: margin.top + hoverPoint.y,
1368
+ transform: `translate(${hoverPoint.x > adjustedWidth * 0.7 ? "calc(-100% - 12px)" : "12px"}, ${hoverPoint.y < adjustedHeight * 0.3 ? "4px" : "calc(-100% - 4px)"})`,
1369
+ pointerEvents: "none",
1370
+ zIndex: 1
1371
+ } }, tooltipContent
1372
+ ? tooltipContent(hoverPoint)
1373
+ : React.createElement(DefaultTooltip, { hover: hoverPoint, formatTime: tickFormatTime }))) : null;
1374
+ return (React.createElement("div", { className: `realtime-frame${className ? ` ${className}` : ""}`, style: {
1375
+ position: "relative",
1376
+ width: size[0],
1377
+ height: size[1]
1378
+ }, onMouseMove: hoverAnnotation ? onMouseMove : undefined, onMouseLeave: hoverAnnotation ? onMouseLeave : undefined },
1379
+ React.createElement("canvas", { ref: canvasRef, style: {
1380
+ position: "absolute",
1381
+ left: 0,
1382
+ top: 0
1383
+ } }),
1384
+ hasAnnotations && (React.createElement("svg", { width: size[0], height: size[1], style: {
1385
+ position: "absolute",
1386
+ top: 0,
1387
+ left: 0,
1388
+ pointerEvents: "none"
1389
+ } },
1390
+ React.createElement("g", { transform: `translate(${margin.left},${margin.top})` }, renderedAnnotations))),
1391
+ tooltipElement));
1392
+ });
1393
+
1394
+ /**
1395
+ * RealtimeLineChart - Simplified wrapper for streaming line charts.
1396
+ *
1397
+ * Wraps RealtimeFrame with `chartType="line"` and exposes stroke/strokeWidth
1398
+ * as top-level props instead of requiring a `lineStyle` object.
1399
+ *
1400
+ * @example
1401
+ * ```tsx
1402
+ * const ref = useRef<RealtimeFrameHandle>(null)
1403
+ *
1404
+ * <RealtimeLineChart
1405
+ * ref={ref}
1406
+ * stroke="#007bff"
1407
+ * strokeWidth={2}
1408
+ * windowSize={200}
1409
+ * enableHover
1410
+ * />
1411
+ * ```
1412
+ */
1413
+ const RealtimeLineChart = forwardRef(function RealtimeLineChart(props, ref) {
1414
+ const { size = [500, 300], margin, className, arrowOfTime = "right", windowMode = "sliding", windowSize = 200, data, timeAccessor, valueAccessor, timeExtent, valueExtent, extentPadding, stroke = "#007bff", strokeWidth = 2, strokeDasharray, showAxes = true, background, enableHover, tooltipContent, onHover, annotations, svgAnnotationRules, tickFormatTime, tickFormatValue } = props;
1415
+ const frameRef = useRef(null);
1416
+ useImperativeHandle(ref, () => ({
1417
+ push: (point) => { var _a; return (_a = frameRef.current) === null || _a === void 0 ? void 0 : _a.push(point); },
1418
+ pushMany: (points) => { var _a; return (_a = frameRef.current) === null || _a === void 0 ? void 0 : _a.pushMany(points); },
1419
+ clear: () => { var _a; return (_a = frameRef.current) === null || _a === void 0 ? void 0 : _a.clear(); },
1420
+ getData: () => { var _a, _b; return (_b = (_a = frameRef.current) === null || _a === void 0 ? void 0 : _a.getData()) !== null && _b !== void 0 ? _b : []; }
1421
+ }));
1422
+ const lineStyle = { stroke, strokeWidth, strokeDasharray };
1423
+ return (React.createElement(RealtimeFrame, { ref: frameRef, chartType: "line", size: size, margin: margin, className: className, arrowOfTime: arrowOfTime, windowMode: windowMode, windowSize: windowSize, data: data, timeAccessor: timeAccessor, valueAccessor: valueAccessor, timeExtent: timeExtent, valueExtent: valueExtent, extentPadding: extentPadding, lineStyle: lineStyle, showAxes: showAxes, background: background, hoverAnnotation: enableHover, tooltipContent: tooltipContent, customHoverBehavior: onHover, annotations: annotations, svgAnnotationRules: svgAnnotationRules, tickFormatTime: tickFormatTime, tickFormatValue: tickFormatValue }));
1424
+ });
1425
+
1426
+ /**
1427
+ * RealtimeBarChart - Simplified wrapper for streaming temporal histograms.
1428
+ *
1429
+ * Wraps RealtimeFrame with `chartType="bar"` and exposes bar styling as
1430
+ * top-level props. Supports both simple and stacked (categorical) modes.
1431
+ *
1432
+ * Edge bins that only partially fall within the visible time window are
1433
+ * rendered at proportionally narrower widths (Datadog-style).
1434
+ *
1435
+ * @example
1436
+ * ```tsx
1437
+ * // Simple histogram
1438
+ * <RealtimeBarChart
1439
+ * ref={ref}
1440
+ * binSize={20}
1441
+ * fill="#007bff"
1442
+ * enableHover
1443
+ * />
1444
+ *
1445
+ * // Stacked by category
1446
+ * <RealtimeBarChart
1447
+ * ref={ref}
1448
+ * binSize={25}
1449
+ * categoryAccessor="category"
1450
+ * colors={{ errors: "#dc3545", warnings: "#fd7e14", info: "#007bff" }}
1451
+ * enableHover
1452
+ * />
1453
+ * ```
1454
+ */
1455
+ const RealtimeBarChart = forwardRef(function RealtimeBarChart(props, ref) {
1456
+ const { binSize, size = [500, 300], margin, className, arrowOfTime = "right", windowMode = "sliding", windowSize = 200, data, timeAccessor, valueAccessor, timeExtent, valueExtent, extentPadding, categoryAccessor, colors, fill, stroke, strokeWidth, gap, showAxes = true, background, enableHover, tooltipContent, onHover, annotations, svgAnnotationRules, tickFormatTime, tickFormatValue } = props;
1457
+ const frameRef = useRef(null);
1458
+ useImperativeHandle(ref, () => ({
1459
+ push: (point) => { var _a; return (_a = frameRef.current) === null || _a === void 0 ? void 0 : _a.push(point); },
1460
+ pushMany: (points) => { var _a; return (_a = frameRef.current) === null || _a === void 0 ? void 0 : _a.pushMany(points); },
1461
+ clear: () => { var _a; return (_a = frameRef.current) === null || _a === void 0 ? void 0 : _a.clear(); },
1462
+ getData: () => { var _a, _b; return (_b = (_a = frameRef.current) === null || _a === void 0 ? void 0 : _a.getData()) !== null && _b !== void 0 ? _b : []; }
1463
+ }));
1464
+ const barStyle = {};
1465
+ if (fill != null)
1466
+ barStyle.fill = fill;
1467
+ if (stroke != null)
1468
+ barStyle.stroke = stroke;
1469
+ if (strokeWidth != null)
1470
+ barStyle.strokeWidth = strokeWidth;
1471
+ if (gap != null)
1472
+ barStyle.gap = gap;
1473
+ return (React.createElement(RealtimeFrame, { ref: frameRef, chartType: "bar", size: size, margin: margin, className: className, arrowOfTime: arrowOfTime, windowMode: windowMode, windowSize: windowSize, data: data, timeAccessor: timeAccessor, valueAccessor: valueAccessor, timeExtent: timeExtent, valueExtent: valueExtent, extentPadding: extentPadding, binSize: binSize, categoryAccessor: categoryAccessor, barColors: colors, barStyle: barStyle, showAxes: showAxes, background: background, hoverAnnotation: enableHover, tooltipContent: tooltipContent, customHoverBehavior: onHover, annotations: annotations, svgAnnotationRules: svgAnnotationRules, tickFormatTime: tickFormatTime, tickFormatValue: tickFormatValue }));
1474
+ });
1475
+
1476
+ /**
1477
+ * RealtimeSwarmChart - Simplified wrapper for streaming dot/swarm charts.
1478
+ *
1479
+ * Wraps RealtimeFrame with `chartType="swarm"` and exposes dot styling as
1480
+ * top-level props. Each data point renders as an individual dot at its
1481
+ * (time, value) coordinates.
1482
+ *
1483
+ * Supports threshold coloring via annotations to recolor dots that cross
1484
+ * value boundaries.
1485
+ *
1486
+ * @example
1487
+ * ```tsx
1488
+ * <RealtimeSwarmChart
1489
+ * ref={ref}
1490
+ * radius={4}
1491
+ * opacity={0.8}
1492
+ * categoryAccessor="sensor"
1493
+ * colors={{ sensor1: "#007bff", sensor2: "#28a745" }}
1494
+ * />
1495
+ * ```
1496
+ */
1497
+ const RealtimeSwarmChart = forwardRef(function RealtimeSwarmChart(props, ref) {
1498
+ const { size = [500, 300], margin, className, arrowOfTime = "right", windowMode = "sliding", windowSize = 200, data, timeAccessor, valueAccessor, timeExtent, valueExtent, extentPadding, categoryAccessor, colors, radius, fill, opacity, stroke, strokeWidth, showAxes = true, background, enableHover, tooltipContent, onHover, annotations, svgAnnotationRules, tickFormatTime, tickFormatValue } = props;
1499
+ const frameRef = useRef(null);
1500
+ useImperativeHandle(ref, () => ({
1501
+ push: (point) => { var _a; return (_a = frameRef.current) === null || _a === void 0 ? void 0 : _a.push(point); },
1502
+ pushMany: (points) => { var _a; return (_a = frameRef.current) === null || _a === void 0 ? void 0 : _a.pushMany(points); },
1503
+ clear: () => { var _a; return (_a = frameRef.current) === null || _a === void 0 ? void 0 : _a.clear(); },
1504
+ getData: () => { var _a, _b; return (_b = (_a = frameRef.current) === null || _a === void 0 ? void 0 : _a.getData()) !== null && _b !== void 0 ? _b : []; }
1505
+ }));
1506
+ const swarmStyle = {};
1507
+ if (radius != null)
1508
+ swarmStyle.radius = radius;
1509
+ if (fill != null)
1510
+ swarmStyle.fill = fill;
1511
+ if (opacity != null)
1512
+ swarmStyle.opacity = opacity;
1513
+ if (stroke != null)
1514
+ swarmStyle.stroke = stroke;
1515
+ if (strokeWidth != null)
1516
+ swarmStyle.strokeWidth = strokeWidth;
1517
+ return (React.createElement(RealtimeFrame, { ref: frameRef, chartType: "swarm", size: size, margin: margin, className: className, arrowOfTime: arrowOfTime, windowMode: windowMode, windowSize: windowSize, data: data, timeAccessor: timeAccessor, valueAccessor: valueAccessor, timeExtent: timeExtent, valueExtent: valueExtent, extentPadding: extentPadding, categoryAccessor: categoryAccessor, barColors: colors, swarmStyle: swarmStyle, showAxes: showAxes, background: background, hoverAnnotation: enableHover, tooltipContent: tooltipContent, customHoverBehavior: onHover, annotations: annotations, svgAnnotationRules: svgAnnotationRules, tickFormatTime: tickFormatTime, tickFormatValue: tickFormatValue }));
1518
+ });
1519
+
1520
+ /**
1521
+ * RealtimeWaterfallChart - Simplified wrapper for streaming waterfall charts.
1522
+ *
1523
+ * Wraps RealtimeFrame with `chartType="waterfall"` and exposes waterfall styling
1524
+ * as top-level props. Visualizes cumulative deltas as connected bars rising and
1525
+ * falling from a running baseline.
1526
+ *
1527
+ * @example
1528
+ * ```tsx
1529
+ * <RealtimeWaterfallChart
1530
+ * ref={ref}
1531
+ * positiveColor="#28a745"
1532
+ * negativeColor="#dc3545"
1533
+ * connectorStroke="#999"
1534
+ * windowSize={300}
1535
+ * />
1536
+ * ```
1537
+ */
1538
+ const RealtimeWaterfallChart = forwardRef(function RealtimeWaterfallChart(props, ref) {
1539
+ const { size = [500, 300], margin, className, arrowOfTime = "right", windowMode = "sliding", windowSize = 200, data, timeAccessor, valueAccessor, timeExtent, valueExtent, extentPadding, positiveColor, negativeColor, connectorStroke, connectorWidth, gap, stroke, strokeWidth, showAxes = true, background, enableHover, tooltipContent, onHover, annotations, svgAnnotationRules, tickFormatTime, tickFormatValue } = props;
1540
+ const frameRef = useRef(null);
1541
+ useImperativeHandle(ref, () => ({
1542
+ push: (point) => { var _a; return (_a = frameRef.current) === null || _a === void 0 ? void 0 : _a.push(point); },
1543
+ pushMany: (points) => { var _a; return (_a = frameRef.current) === null || _a === void 0 ? void 0 : _a.pushMany(points); },
1544
+ clear: () => { var _a; return (_a = frameRef.current) === null || _a === void 0 ? void 0 : _a.clear(); },
1545
+ getData: () => { var _a, _b; return (_b = (_a = frameRef.current) === null || _a === void 0 ? void 0 : _a.getData()) !== null && _b !== void 0 ? _b : []; }
1546
+ }));
1547
+ const waterfallStyle = {};
1548
+ if (positiveColor != null)
1549
+ waterfallStyle.positiveColor = positiveColor;
1550
+ if (negativeColor != null)
1551
+ waterfallStyle.negativeColor = negativeColor;
1552
+ if (connectorStroke != null)
1553
+ waterfallStyle.connectorStroke = connectorStroke;
1554
+ if (connectorWidth != null)
1555
+ waterfallStyle.connectorWidth = connectorWidth;
1556
+ if (gap != null)
1557
+ waterfallStyle.gap = gap;
1558
+ if (stroke != null)
1559
+ waterfallStyle.stroke = stroke;
1560
+ if (strokeWidth != null)
1561
+ waterfallStyle.strokeWidth = strokeWidth;
1562
+ return (React.createElement(RealtimeFrame, { ref: frameRef, chartType: "waterfall", size: size, margin: margin, className: className, arrowOfTime: arrowOfTime, windowMode: windowMode, windowSize: windowSize, data: data, timeAccessor: timeAccessor, valueAccessor: valueAccessor, timeExtent: timeExtent, valueExtent: valueExtent, extentPadding: extentPadding, waterfallStyle: waterfallStyle, showAxes: showAxes, background: background, hoverAnnotation: enableHover, tooltipContent: tooltipContent, customHoverBehavior: onHover, annotations: annotations, svgAnnotationRules: svgAnnotationRules, tickFormatTime: tickFormatTime, tickFormatValue: tickFormatValue }));
1563
+ });
1564
+
1565
+ export { IncrementalExtent, RealtimeBarChart, RealtimeFrame, RealtimeLineChart, RealtimeSwarmChart, RealtimeWaterfallChart, RingBuffer, barRenderer, candlestickRenderer, lineRenderer, swarmRenderer, waterfallRenderer };
1566
+ //# sourceMappingURL=realtime.module.js.map