semiotic 3.0.0-beta.2 → 3.0.0-beta.4

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 (342) hide show
  1. package/CLAUDE.md +93 -753
  2. package/README.md +92 -7
  3. package/ai/dist/componentRegistry.js +26 -0
  4. package/ai/dist/{ai/mcp-server.js → mcp-server.js} +1 -1
  5. package/ai/dist/{ai/renderHOCToSVG.js → renderHOCToSVG.js} +2 -2
  6. package/dist/ChartContainer.d.ts +60 -0
  7. package/dist/DetailsPanel.d.ts +37 -0
  8. package/dist/LinkedCharts.d.ts +2 -0
  9. package/dist/Tooltip/Tooltip.d.ts +2 -2
  10. package/dist/charts/index.d.ts +1 -1
  11. package/dist/charts/ordinal/BarChart.d.ts +1 -0
  12. package/dist/charts/ordinal/BoxPlot.d.ts +1 -0
  13. package/dist/charts/ordinal/DonutChart.d.ts +1 -0
  14. package/dist/charts/ordinal/DotPlot.d.ts +1 -0
  15. package/dist/charts/ordinal/GroupedBarChart.d.ts +1 -0
  16. package/dist/charts/ordinal/Histogram.d.ts +1 -0
  17. package/dist/charts/ordinal/PieChart.d.ts +1 -0
  18. package/dist/charts/ordinal/RidgelinePlot.d.ts +1 -0
  19. package/dist/charts/ordinal/StackedBarChart.d.ts +1 -0
  20. package/dist/charts/ordinal/SwarmPlot.d.ts +1 -0
  21. package/dist/charts/ordinal/ViolinPlot.d.ts +1 -0
  22. package/dist/charts/realtime/RealtimeHeatmap.d.ts +11 -0
  23. package/dist/charts/realtime/RealtimeHistogram.d.ts +15 -1
  24. package/dist/charts/realtime/RealtimeLineChart.d.ts +6 -0
  25. package/dist/charts/realtime/RealtimeSwarmChart.d.ts +6 -0
  26. package/dist/charts/realtime/RealtimeWaterfallChart.d.ts +6 -0
  27. package/dist/charts/shared/annotationRules.d.ts +3 -0
  28. package/dist/charts/shared/colorUtils.d.ts +17 -11
  29. package/dist/charts/shared/hooks.d.ts +96 -1
  30. package/dist/charts/shared/loess.d.ts +13 -0
  31. package/dist/charts/shared/networkUtils.d.ts +31 -0
  32. package/dist/charts/shared/tooltipUtils.d.ts +16 -0
  33. package/dist/charts/shared/types.d.ts +17 -2
  34. package/dist/charts/shared/validateChartData.d.ts +2 -3
  35. package/dist/charts/shared/validateProps.d.ts +18 -0
  36. package/dist/charts/xy/AreaChart.d.ts +4 -0
  37. package/dist/charts/xy/BubbleChart.d.ts +6 -0
  38. package/dist/charts/xy/Heatmap.d.ts +4 -0
  39. package/dist/charts/xy/LineChart.d.ts +6 -0
  40. package/dist/charts/xy/Scatterplot.d.ts +4 -0
  41. package/dist/charts/xy/StackedAreaChart.d.ts +4 -0
  42. package/dist/data/fromVegaLite.d.ts +48 -0
  43. package/dist/export/chartConfig.d.ts +29 -0
  44. package/dist/export/selectionSerializer.d.ts +20 -0
  45. package/dist/geometry/sankeyLinks.d.ts +1 -1
  46. package/dist/network.min.js +1 -1
  47. package/dist/network.module.min.js +1 -1
  48. package/dist/ordinal.min.js +1 -1
  49. package/dist/ordinal.module.min.js +1 -1
  50. package/dist/realtime/types.d.ts +20 -6
  51. package/dist/realtime.min.js +1 -1
  52. package/dist/realtime.module.min.js +1 -1
  53. package/dist/semiotic-ai.d.ts +14 -0
  54. package/dist/semiotic-ai.min.js +1 -1
  55. package/dist/semiotic-ai.module.min.js +1 -1
  56. package/dist/semiotic-data.d.ts +2 -0
  57. package/dist/semiotic-data.min.js +1 -1
  58. package/dist/semiotic-data.module.min.js +1 -1
  59. package/dist/semiotic-network.d.ts +9 -19
  60. package/dist/semiotic-ordinal.d.ts +12 -14
  61. package/dist/semiotic-xy.d.ts +12 -18
  62. package/dist/semiotic.d.ts +16 -13
  63. package/dist/semiotic.min.js +1 -1
  64. package/dist/semiotic.module.min.js +1 -1
  65. package/dist/server.min.js +1 -1
  66. package/dist/server.module.min.js +1 -1
  67. package/dist/store/ObservationStore.d.ts +61 -0
  68. package/dist/store/SelectionStore.d.ts +9 -1
  69. package/dist/store/ThemeStore.d.ts +6 -1
  70. package/dist/store/TooltipStore.d.ts +3 -1
  71. package/dist/store/createStore.d.ts +4 -1
  72. package/dist/store/useObservation.d.ts +18 -0
  73. package/dist/stream/MarginalGraphics.d.ts +1 -1
  74. package/dist/stream/NetworkPipelineStore.d.ts +44 -0
  75. package/dist/stream/OrdinalCanvasHitTester.d.ts +1 -0
  76. package/dist/stream/OrdinalSVGOverlay.d.ts +6 -2
  77. package/dist/stream/ParticlePool.d.ts +2 -1
  78. package/dist/stream/PipelineStore.d.ts +11 -0
  79. package/dist/stream/SVGOverlay.d.ts +21 -2
  80. package/dist/stream/SceneGraph.d.ts +1 -1
  81. package/dist/stream/networkTypes.d.ts +58 -1
  82. package/dist/stream/ordinalTypes.d.ts +13 -0
  83. package/dist/stream/types.d.ts +14 -0
  84. package/dist/types/annotationTypes.d.ts +10 -0
  85. package/dist/types/networkTypes.d.ts +1 -2
  86. package/dist/xy.min.js +1 -1
  87. package/dist/xy.module.min.js +1 -1
  88. package/package.json +30 -42
  89. package/ai/dist/ai/componentRegistry.js +0 -45
  90. package/ai/dist/src/components/Annotation.js +0 -358
  91. package/ai/dist/src/components/AnnotationLayer/AnnotationLayer.js +0 -369
  92. package/ai/dist/src/components/Axis/Axis.js +0 -374
  93. package/ai/dist/src/components/Axis/axisTitle.js +0 -14
  94. package/ai/dist/src/components/Axis/index.js +0 -7
  95. package/ai/dist/src/components/Axis/summaryGraphic.js +0 -37
  96. package/ai/dist/src/components/Brush.js +0 -84
  97. package/ai/dist/src/components/ChartErrorBoundary.js +0 -91
  98. package/ai/dist/src/components/DividedLine.js +0 -65
  99. package/ai/dist/src/components/Legend.js +0 -140
  100. package/ai/dist/src/components/LinkedCharts.js +0 -95
  101. package/ai/dist/src/components/ThemeProvider.js +0 -79
  102. package/ai/dist/src/components/Tooltip/Tooltip.js +0 -309
  103. package/ai/dist/src/components/TooltipPositioner/index.js +0 -132
  104. package/ai/dist/src/components/annotationLayerBehavior/annotationHandling.js +0 -73
  105. package/ai/dist/src/components/annotationLayerBehavior/d3labeler.js +0 -254
  106. package/ai/dist/src/components/annotationRules/baseRules.js +0 -150
  107. package/ai/dist/src/components/annotationRules/networkframeRules.js +0 -196
  108. package/ai/dist/src/components/annotationRules/xyframeRules.js +0 -297
  109. package/ai/dist/src/components/batchWork.js +0 -35
  110. package/ai/dist/src/components/charts/index.js +0 -109
  111. package/ai/dist/src/components/charts/network/ChordDiagram.js +0 -142
  112. package/ai/dist/src/components/charts/network/CirclePack.js +0 -108
  113. package/ai/dist/src/components/charts/network/ForceDirectedGraph.js +0 -121
  114. package/ai/dist/src/components/charts/network/SankeyDiagram.js +0 -155
  115. package/ai/dist/src/components/charts/network/TreeDiagram.js +0 -110
  116. package/ai/dist/src/components/charts/network/Treemap.js +0 -106
  117. package/ai/dist/src/components/charts/ordinal/BarChart.js +0 -156
  118. package/ai/dist/src/components/charts/ordinal/BoxPlot.js +0 -139
  119. package/ai/dist/src/components/charts/ordinal/DonutChart.js +0 -130
  120. package/ai/dist/src/components/charts/ordinal/DotPlot.js +0 -126
  121. package/ai/dist/src/components/charts/ordinal/GroupedBarChart.js +0 -129
  122. package/ai/dist/src/components/charts/ordinal/Histogram.js +0 -132
  123. package/ai/dist/src/components/charts/ordinal/PieChart.js +0 -128
  124. package/ai/dist/src/components/charts/ordinal/RidgelinePlot.js +0 -130
  125. package/ai/dist/src/components/charts/ordinal/StackedBarChart.js +0 -130
  126. package/ai/dist/src/components/charts/ordinal/SwarmPlot.js +0 -147
  127. package/ai/dist/src/components/charts/ordinal/ViolinPlot.js +0 -138
  128. package/ai/dist/src/components/charts/realtime/RealtimeHeatmap.js +0 -79
  129. package/ai/dist/src/components/charts/realtime/RealtimeHistogram.js +0 -114
  130. package/ai/dist/src/components/charts/realtime/RealtimeLineChart.js +0 -93
  131. package/ai/dist/src/components/charts/realtime/RealtimeSwarmChart.js +0 -105
  132. package/ai/dist/src/components/charts/realtime/RealtimeWaterfallChart.js +0 -106
  133. package/ai/dist/src/components/charts/shared/ChartError.js +0 -72
  134. package/ai/dist/src/components/charts/shared/colorUtils.js +0 -138
  135. package/ai/dist/src/components/charts/shared/formatUtils.js +0 -213
  136. package/ai/dist/src/components/charts/shared/hooks.js +0 -49
  137. package/ai/dist/src/components/charts/shared/legendUtils.js +0 -57
  138. package/ai/dist/src/components/charts/shared/selectionUtils.js +0 -67
  139. package/ai/dist/src/components/charts/shared/tooltipUtils.js +0 -79
  140. package/ai/dist/src/components/charts/shared/types.js +0 -2
  141. package/ai/dist/src/components/charts/shared/validateChartData.js +0 -82
  142. package/ai/dist/src/components/charts/shared/validateProps.js +0 -736
  143. package/ai/dist/src/components/charts/xy/AreaChart.js +0 -230
  144. package/ai/dist/src/components/charts/xy/BubbleChart.js +0 -251
  145. package/ai/dist/src/components/charts/xy/Heatmap.js +0 -235
  146. package/ai/dist/src/components/charts/xy/LineChart.js +0 -307
  147. package/ai/dist/src/components/charts/xy/MinimapChart.js +0 -298
  148. package/ai/dist/src/components/charts/xy/Scatterplot.js +0 -172
  149. package/ai/dist/src/components/charts/xy/ScatterplotMatrix.js +0 -426
  150. package/ai/dist/src/components/charts/xy/StackedAreaChart.js +0 -231
  151. package/ai/dist/src/components/constants/coordinateNames.js +0 -11
  152. package/ai/dist/src/components/constants/frame_props.js +0 -251
  153. package/ai/dist/src/components/data/dataFunctions.js +0 -487
  154. package/ai/dist/src/components/data/multiAccessorUtils.js +0 -14
  155. package/ai/dist/src/components/data/transforms.js +0 -143
  156. package/ai/dist/src/components/data/unflowedFunctions.js +0 -5
  157. package/ai/dist/src/components/export/exportChart.js +0 -121
  158. package/ai/dist/src/components/generic_utilities/functions.js +0 -5
  159. package/ai/dist/src/components/geometry/areaDrawing.js +0 -312
  160. package/ai/dist/src/components/geometry/contourLayout.js +0 -73
  161. package/ai/dist/src/components/geometry/hexbinLayout.js +0 -163
  162. package/ai/dist/src/components/geometry/lineDrawing.js +0 -356
  163. package/ai/dist/src/components/geometry/sankeyLinks.js +0 -331
  164. package/ai/dist/src/components/geometry/summaryLayouts.js +0 -136
  165. package/ai/dist/src/components/index.js +0 -18
  166. package/ai/dist/src/components/processing/InteractionItems.js +0 -223
  167. package/ai/dist/src/components/processing/hierarchyUtils.js +0 -104
  168. package/ai/dist/src/components/processing/layouts/chordLayout.js +0 -58
  169. package/ai/dist/src/components/processing/layouts/forceLayout.js +0 -142
  170. package/ai/dist/src/components/processing/layouts/hierarchyLayout.js +0 -31
  171. package/ai/dist/src/components/processing/layouts/index.js +0 -32
  172. package/ai/dist/src/components/processing/layouts/sankeyLayout.js +0 -96
  173. package/ai/dist/src/components/processing/layouts/simpleLayouts.js +0 -34
  174. package/ai/dist/src/components/processing/layouts/types.js +0 -2
  175. package/ai/dist/src/components/processing/networkDefaults.js +0 -39
  176. package/ai/dist/src/components/realtime/BinAccumulator.js +0 -36
  177. package/ai/dist/src/components/realtime/IncrementalExtent.js +0 -55
  178. package/ai/dist/src/components/realtime/RingBuffer.js +0 -104
  179. package/ai/dist/src/components/realtime/renderers/barRenderer.js +0 -133
  180. package/ai/dist/src/components/realtime/renderers/candlestickRenderer.js +0 -7
  181. package/ai/dist/src/components/realtime/renderers/lineRenderer.js +0 -164
  182. package/ai/dist/src/components/realtime/renderers/swarmRenderer.js +0 -91
  183. package/ai/dist/src/components/realtime/renderers/types.js +0 -2
  184. package/ai/dist/src/components/realtime/renderers/waterfallRenderer.js +0 -163
  185. package/ai/dist/src/components/realtime/types.js +0 -2
  186. package/ai/dist/src/components/semiotic-ai.js +0 -89
  187. package/ai/dist/src/components/semiotic-data.js +0 -12
  188. package/ai/dist/src/components/semiotic-network.js +0 -38
  189. package/ai/dist/src/components/semiotic-ordinal.js +0 -28
  190. package/ai/dist/src/components/semiotic-realtime.js +0 -30
  191. package/ai/dist/src/components/semiotic-server.js +0 -8
  192. package/ai/dist/src/components/semiotic-xy.js +0 -35
  193. package/ai/dist/src/components/semiotic.js +0 -109
  194. package/ai/dist/src/components/server/renderToStaticSVG.js +0 -594
  195. package/ai/dist/src/components/store/SelectionStore.js +0 -91
  196. package/ai/dist/src/components/store/ThemeStore.js +0 -78
  197. package/ai/dist/src/components/store/TooltipStore.js +0 -13
  198. package/ai/dist/src/components/store/createStore.js +0 -81
  199. package/ai/dist/src/components/store/useSelection.js +0 -133
  200. package/ai/dist/src/components/stream/CanvasHitTester.js +0 -164
  201. package/ai/dist/src/components/stream/DataSourceAdapter.js +0 -99
  202. package/ai/dist/src/components/stream/MarginalGraphics.js +0 -266
  203. package/ai/dist/src/components/stream/NetworkCanvasHitTester.js +0 -228
  204. package/ai/dist/src/components/stream/NetworkPipelineStore.js +0 -498
  205. package/ai/dist/src/components/stream/NetworkSVGOverlay.js +0 -70
  206. package/ai/dist/src/components/stream/NetworkSceneGraph.js +0 -38
  207. package/ai/dist/src/components/stream/OrdinalCanvasHitTester.js +0 -146
  208. package/ai/dist/src/components/stream/OrdinalPipelineStore.js +0 -786
  209. package/ai/dist/src/components/stream/OrdinalSVGOverlay.js +0 -130
  210. package/ai/dist/src/components/stream/ParticlePool.js +0 -174
  211. package/ai/dist/src/components/stream/PipelineStore.js +0 -1243
  212. package/ai/dist/src/components/stream/SVGOverlay.js +0 -129
  213. package/ai/dist/src/components/stream/SceneGraph.js +0 -132
  214. package/ai/dist/src/components/stream/StreamNetworkFrame.js +0 -561
  215. package/ai/dist/src/components/stream/StreamOrdinalFrame.js +0 -492
  216. package/ai/dist/src/components/stream/StreamXYFrame.js +0 -590
  217. package/ai/dist/src/components/stream/accessorUtils.js +0 -20
  218. package/ai/dist/src/components/stream/index.js +0 -32
  219. package/ai/dist/src/components/stream/layouts/chordLayoutPlugin.js +0 -352
  220. package/ai/dist/src/components/stream/layouts/forceLayoutPlugin.js +0 -230
  221. package/ai/dist/src/components/stream/layouts/hierarchyLayoutPlugin.js +0 -568
  222. package/ai/dist/src/components/stream/layouts/index.js +0 -28
  223. package/ai/dist/src/components/stream/layouts/sankeyLayoutPlugin.js +0 -245
  224. package/ai/dist/src/components/stream/networkTypes.js +0 -17
  225. package/ai/dist/src/components/stream/ordinalSceneBuilders/barScene.js +0 -126
  226. package/ai/dist/src/components/stream/ordinalSceneBuilders/connectorScene.js +0 -62
  227. package/ai/dist/src/components/stream/ordinalSceneBuilders/pieScene.js +0 -33
  228. package/ai/dist/src/components/stream/ordinalSceneBuilders/pointScene.js +0 -63
  229. package/ai/dist/src/components/stream/ordinalSceneBuilders/statisticalScene.js +0 -278
  230. package/ai/dist/src/components/stream/ordinalSceneBuilders/timelineScene.js +0 -30
  231. package/ai/dist/src/components/stream/ordinalSceneBuilders/types.js +0 -2
  232. package/ai/dist/src/components/stream/ordinalTypes.js +0 -2
  233. package/ai/dist/src/components/stream/renderers/areaCanvasRenderer.js +0 -48
  234. package/ai/dist/src/components/stream/renderers/barCanvasRenderer.js +0 -70
  235. package/ai/dist/src/components/stream/renderers/boxplotCanvasRenderer.js +0 -75
  236. package/ai/dist/src/components/stream/renderers/candlestickCanvasRenderer.js +0 -28
  237. package/ai/dist/src/components/stream/renderers/connectorCanvasRenderer.js +0 -47
  238. package/ai/dist/src/components/stream/renderers/heatmapCanvasRenderer.js +0 -31
  239. package/ai/dist/src/components/stream/renderers/lineCanvasRenderer.js +0 -140
  240. package/ai/dist/src/components/stream/renderers/networkArcRenderer.js +0 -38
  241. package/ai/dist/src/components/stream/renderers/networkCircleRenderer.js +0 -37
  242. package/ai/dist/src/components/stream/renderers/networkEdgeRenderer.js +0 -102
  243. package/ai/dist/src/components/stream/renderers/networkParticleRenderer.js +0 -63
  244. package/ai/dist/src/components/stream/renderers/networkRectRenderer.js +0 -35
  245. package/ai/dist/src/components/stream/renderers/pointCanvasRenderer.js +0 -38
  246. package/ai/dist/src/components/stream/renderers/swarmCanvasRenderer.js +0 -10
  247. package/ai/dist/src/components/stream/renderers/types.js +0 -2
  248. package/ai/dist/src/components/stream/renderers/violinCanvasRenderer.js +0 -47
  249. package/ai/dist/src/components/stream/renderers/waterfallCanvasRenderer.js +0 -38
  250. package/ai/dist/src/components/stream/renderers/wedgeCanvasRenderer.js +0 -33
  251. package/ai/dist/src/components/stream/types.js +0 -2
  252. package/ai/dist/src/components/types/annotationTypes.js +0 -2
  253. package/ai/dist/src/components/types/canvasTypes.js +0 -2
  254. package/ai/dist/src/components/types/generalTypes.js +0 -2
  255. package/ai/dist/src/components/types/interactionTypes.js +0 -2
  256. package/ai/dist/src/components/types/legendTypes.js +0 -2
  257. package/ai/dist/src/components/types/networkTypes.js +0 -2
  258. package/ai/dist/src/components/types/ordinalTypes.js +0 -2
  259. package/ai/dist/src/components/types/xyTypes.js +0 -2
  260. package/ai/dist/src/components/useBoundingRect.js +0 -24
  261. package/ai/dist/src/components/visualizationLayerBehavior/axis.js +0 -301
  262. package/ai/dist/src/components/visualizationLayerBehavior/general.js +0 -435
  263. package/ai/dist/src/setupTests.js +0 -4
  264. package/dist/AnnotationLayer/AnnotationLayer.d.ts +0 -25
  265. package/dist/Axis/Axis.d.ts +0 -7
  266. package/dist/Axis/axisTitle.d.ts +0 -10
  267. package/dist/Axis/index.d.ts +0 -2
  268. package/dist/Axis/summaryGraphic.d.ts +0 -17
  269. package/dist/Brush.d.ts +0 -12
  270. package/dist/DividedLine.d.ts +0 -16
  271. package/dist/TooltipPositioner/index.d.ts +0 -7
  272. package/dist/annotationLayerBehavior/annotationHandling.d.ts +0 -19
  273. package/dist/annotationLayerBehavior/d3labeler.d.ts +0 -9
  274. package/dist/annotationRules/baseRules.d.ts +0 -25
  275. package/dist/annotationRules/networkframeRules.d.ts +0 -48
  276. package/dist/annotationRules/xyframeRules.d.ts +0 -117
  277. package/dist/batchWork.d.ts +0 -6
  278. package/dist/constants/coordinateNames.d.ts +0 -8
  279. package/dist/constants/frame_props.d.ts +0 -13
  280. package/dist/data/dataFunctions.d.ts +0 -45
  281. package/dist/data/multiAccessorUtils.d.ts +0 -1
  282. package/dist/data/unflowedFunctions.d.ts +0 -1
  283. package/dist/generic_utilities/functions.d.ts +0 -1
  284. package/dist/geometry/areaDrawing.d.ts +0 -21
  285. package/dist/geometry/contourLayout.d.ts +0 -6
  286. package/dist/geometry/hexbinLayout.d.ts +0 -7
  287. package/dist/geometry/lineDrawing.d.ts +0 -71
  288. package/dist/geometry/summaryLayouts.d.ts +0 -45
  289. package/dist/index.d.ts +0 -1
  290. package/dist/network.js +0 -7495
  291. package/dist/network.js.map +0 -1
  292. package/dist/network.module.js +0 -7458
  293. package/dist/network.module.js.map +0 -1
  294. package/dist/ordinal.js +0 -6497
  295. package/dist/ordinal.js.map +0 -1
  296. package/dist/ordinal.module.js +0 -6465
  297. package/dist/ordinal.module.js.map +0 -1
  298. package/dist/processing/InteractionItems.d.ts +0 -13
  299. package/dist/processing/hierarchyUtils.d.ts +0 -16
  300. package/dist/processing/layouts/chordLayout.d.ts +0 -2
  301. package/dist/processing/layouts/forceLayout.d.ts +0 -3
  302. package/dist/processing/layouts/hierarchyLayout.d.ts +0 -10
  303. package/dist/processing/layouts/index.d.ts +0 -8
  304. package/dist/processing/layouts/sankeyLayout.d.ts +0 -8
  305. package/dist/processing/layouts/simpleLayouts.d.ts +0 -7
  306. package/dist/processing/layouts/types.d.ts +0 -17
  307. package/dist/processing/networkDefaults.d.ts +0 -36
  308. package/dist/realtime/renderers/barRenderer.d.ts +0 -2
  309. package/dist/realtime/renderers/candlestickRenderer.d.ts +0 -2
  310. package/dist/realtime/renderers/lineRenderer.d.ts +0 -2
  311. package/dist/realtime/renderers/swarmRenderer.d.ts +0 -2
  312. package/dist/realtime.js +0 -7072
  313. package/dist/realtime.js.map +0 -1
  314. package/dist/realtime.module.js +0 -7043
  315. package/dist/realtime.module.js.map +0 -1
  316. package/dist/semiotic-ai.js +0 -13323
  317. package/dist/semiotic-ai.js.map +0 -1
  318. package/dist/semiotic-ai.module.js +0 -13264
  319. package/dist/semiotic-ai.module.js.map +0 -1
  320. package/dist/semiotic-data.js +0 -141
  321. package/dist/semiotic-data.js.map +0 -1
  322. package/dist/semiotic-data.module.js +0 -136
  323. package/dist/semiotic-data.module.js.map +0 -1
  324. package/dist/semiotic.js +0 -16351
  325. package/dist/semiotic.js.map +0 -1
  326. package/dist/semiotic.module.js +0 -16265
  327. package/dist/semiotic.module.js.map +0 -1
  328. package/dist/server.js +0 -5191
  329. package/dist/server.js.map +0 -1
  330. package/dist/server.module.js +0 -5166
  331. package/dist/server.module.js.map +0 -1
  332. package/dist/stream/NetworkSceneGraph.d.ts +0 -14
  333. package/dist/stream/index.d.ts +0 -16
  334. package/dist/types/canvasTypes.d.ts +0 -9
  335. package/dist/types/xyTypes.d.ts +0 -24
  336. package/dist/useBoundingRect.d.ts +0 -2
  337. package/dist/visualizationLayerBehavior/axis.d.ts +0 -36
  338. package/dist/visualizationLayerBehavior/general.d.ts +0 -80
  339. package/dist/xy.js +0 -6993
  340. package/dist/xy.js.map +0 -1
  341. package/dist/xy.module.js +0 -6957
  342. package/dist/xy.module.js.map +0 -1
@@ -1,426 +0,0 @@
1
- "use client";
2
- "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || (function () {
20
- var ownKeys = function(o) {
21
- ownKeys = Object.getOwnPropertyNames || function (o) {
22
- var ar = [];
23
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
- return ar;
25
- };
26
- return ownKeys(o);
27
- };
28
- return function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
35
- })();
36
- var __importDefault = (this && this.__importDefault) || function (mod) {
37
- return (mod && mod.__esModule) ? mod : { "default": mod };
38
- };
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.ScatterplotMatrix = ScatterplotMatrix;
41
- const React = __importStar(require("react"));
42
- const react_1 = require("react");
43
- const StreamXYFrame_1 = __importDefault(require("../../stream/StreamXYFrame"));
44
- const d3_brush_1 = require("d3-brush");
45
- const d3_selection_1 = require("d3-selection");
46
- const colorUtils_1 = require("../shared/colorUtils");
47
- const hooks_1 = require("../shared/hooks");
48
- const LinkedCharts_1 = require("../../LinkedCharts");
49
- const useSelection_1 = require("../../store/useSelection");
50
- const SelectionStore_1 = require("../../store/SelectionStore");
51
- // Internal field used to identify datums across cells
52
- const SPLOM_IDX = "__splomIdx";
53
- // Shared clientId for all hover writers — ensures each new hover REPLACES
54
- // the previous one (same key in the clause Map) instead of accumulating.
55
- const HOVER_CLIENT_ID = "splom-hover-source";
56
- const CELL_MARGIN = { top: 4, bottom: 4, left: 4, right: 4 };
57
- function CellBrushOverlay({ frameRef, cellSize, xField, yField, onBrush }) {
58
- const svgRef = (0, react_1.useRef)(null);
59
- const chartW = cellSize - CELL_MARGIN.left - CELL_MARGIN.right;
60
- const chartH = cellSize - CELL_MARGIN.top - CELL_MARGIN.bottom;
61
- (0, react_1.useEffect)(() => {
62
- if (!svgRef.current)
63
- return;
64
- const g = (0, d3_selection_1.select)(svgRef.current).select(".brush-g");
65
- const brush = (0, d3_brush_1.brush)()
66
- .extent([[0, 0], [chartW, chartH]])
67
- .on("brush end", (event) => {
68
- const scales = frameRef.current?.getScales();
69
- if (!scales)
70
- return;
71
- if (!event.selection) {
72
- onBrush(null);
73
- return;
74
- }
75
- const [[px0, py0], [px1, py1]] = event.selection;
76
- const dataExtent = [
77
- [scales.x.invert(px0), scales.y.invert(py0)],
78
- [scales.x.invert(px1), scales.y.invert(py1)]
79
- ];
80
- onBrush(dataExtent);
81
- });
82
- g.call(brush);
83
- // Style the brush
84
- g.select(".selection")
85
- .attr("fill", "steelblue")
86
- .attr("fill-opacity", 0.15)
87
- .attr("stroke", "steelblue")
88
- .attr("stroke-width", 1);
89
- return () => {
90
- brush.on("brush end", null);
91
- };
92
- }, [chartW, chartH, frameRef, onBrush]);
93
- return (React.createElement("svg", { ref: svgRef, width: cellSize, height: cellSize, style: { position: "absolute", top: 0, left: 0 } },
94
- React.createElement("g", { className: "brush-g", transform: `translate(${CELL_MARGIN.left},${CELL_MARGIN.top})` })));
95
- }
96
- function ScatterplotCell({ data, xField, yField, fieldLabels, cellSize, pointRadius, pointOpacity, colorBy, colorScale, brushSelectionName, hoverSelectionName, unselectedOpacity, showGrid, tooltip, mode, onPointHover }) {
97
- const frameRef = (0, react_1.useRef)(null);
98
- const clientId = `splom-${xField}-${yField}`;
99
- // Brush selection (crossfilter) — only used in brush mode
100
- const brushSelectionHook = (0, useSelection_1.useSelection)({
101
- name: brushSelectionName,
102
- clientId,
103
- fields: [xField, yField]
104
- });
105
- const brushHook = (0, useSelection_1.useBrushSelection)({
106
- name: brushSelectionName,
107
- xField,
108
- yField
109
- });
110
- // Hover selection — all cells share HOVER_CLIENT_ID so each new hover
111
- // REPLACES the previous cell's clause instead of accumulating.
112
- const hoverHook = (0, useSelection_1.useSelection)({
113
- name: hoverSelectionName,
114
- clientId: HOVER_CLIENT_ID,
115
- fields: [SPLOM_IDX]
116
- });
117
- const hoverSelectPoints = hoverHook.selectPoints;
118
- // Brush callback: convert d3-brush data-space extent to useBrushSelection format
119
- const handleBrush = (0, react_1.useCallback)((extent) => {
120
- if (!extent) {
121
- brushHook.brushInteraction.end(null);
122
- return;
123
- }
124
- brushHook.brushInteraction.during(extent);
125
- }, [brushHook.brushInteraction]);
126
- const customHoverBehavior = (0, react_1.useCallback)((hover) => {
127
- if (!hover) {
128
- onPointHover?.(null);
129
- return;
130
- }
131
- const d = hover.data;
132
- const idx = d?.[SPLOM_IDX];
133
- if (idx !== undefined) {
134
- hoverSelectPoints({ [SPLOM_IDX]: [idx] });
135
- onPointHover?.(d, hover.x + CELL_MARGIN.left, hover.y + CELL_MARGIN.top);
136
- }
137
- }, [hoverSelectPoints, onPointHover]);
138
- const pointStyle = (0, react_1.useCallback)((d) => {
139
- const style = {
140
- opacity: pointOpacity,
141
- r: pointRadius
142
- };
143
- if (colorBy) {
144
- style.fill = (0, colorUtils_1.getColor)(d, colorBy, colorScale);
145
- }
146
- else {
147
- style.fill = hooks_1.DEFAULT_COLOR;
148
- }
149
- if (mode === "hover") {
150
- const hoverHighlighted = hoverHook.isActive && hoverHook.predicate(d);
151
- if (hoverHighlighted) {
152
- style.opacity = 1;
153
- style.r = pointRadius * 2.5;
154
- style.stroke = "#333";
155
- style.strokeWidth = 1.5;
156
- }
157
- else if (hoverHook.isActive) {
158
- style.opacity = pointOpacity * 0.6;
159
- }
160
- }
161
- else {
162
- // brush mode
163
- const brushDimmed = brushSelectionHook.isActive && !brushSelectionHook.predicate(d);
164
- if (brushDimmed) {
165
- style.opacity = unselectedOpacity;
166
- }
167
- }
168
- return style;
169
- }, [colorBy, colorScale, pointOpacity, pointRadius, mode, brushSelectionHook.isActive, brushSelectionHook.predicate, hoverHook.isActive, hoverHook.predicate, unselectedOpacity]);
170
- return (React.createElement("div", { style: { position: "relative", width: cellSize, height: cellSize } },
171
- React.createElement(StreamXYFrame_1.default, { ref: frameRef, chartType: "scatter", data: data, size: [cellSize, cellSize], xAccessor: xField, yAccessor: yField, pointStyle: pointStyle, margin: CELL_MARGIN, showAxes: false, enableHover: mode === "hover", customHoverBehavior: mode === "hover" ? customHoverBehavior : undefined, tooltipContent: mode === "hover" ? (() => null) : undefined }),
172
- mode === "brush" && (React.createElement(CellBrushOverlay, { frameRef: frameRef, cellSize: cellSize, xField: xField, yField: yField, onBrush: handleBrush }))));
173
- }
174
- function DiagonalCell({ data, field, label, cellSize, bins, colorBy, colorScale, brushSelectionName, hoverSelectionName, unselectedOpacity, mode }) {
175
- const brushHook = (0, useSelection_1.useSelection)({
176
- name: brushSelectionName,
177
- clientId: `splom-diag-${field}`,
178
- fields: [field]
179
- });
180
- const hoverHook = (0, useSelection_1.useSelection)({
181
- name: hoverSelectionName,
182
- clientId: `splom-diag-${field}-hover`,
183
- fields: [SPLOM_IDX]
184
- });
185
- // Use the active mode's predicate
186
- const activeHook = mode === "hover" ? hoverHook : brushHook;
187
- const isActive = activeHook.isActive;
188
- const activePredicate = activeHook.predicate;
189
- const histogram = (0, react_1.useMemo)(() => {
190
- const values = data.map((d) => d[field]).filter((v) => v != null && !isNaN(v));
191
- if (values.length === 0)
192
- return { bars: [], selectedBars: [], max: 0 };
193
- const min = Math.min(...values);
194
- const max = Math.max(...values);
195
- const binWidth = (max - min) / bins || 1;
196
- const counts = new Array(bins).fill(0);
197
- const selectedCounts = new Array(bins).fill(0);
198
- for (const d of data) {
199
- const v = d[field];
200
- if (v == null || isNaN(v))
201
- continue;
202
- const idx = Math.min(Math.floor((v - min) / binWidth), bins - 1);
203
- counts[idx]++;
204
- if (!isActive || activePredicate(d)) {
205
- selectedCounts[idx]++;
206
- }
207
- }
208
- const maxCount = Math.max(...counts, 1);
209
- return {
210
- bars: counts.map((c, i) => ({
211
- x: (i / bins) * cellSize,
212
- w: (cellSize / bins) - 1,
213
- h: (c / maxCount) * (cellSize - 24),
214
- count: c
215
- })),
216
- selectedBars: selectedCounts.map((c, i) => ({
217
- x: (i / bins) * cellSize,
218
- w: (cellSize / bins) - 1,
219
- h: (c / maxCount) * (cellSize - 24),
220
- count: c
221
- })),
222
- max: maxCount
223
- };
224
- }, [data, field, bins, cellSize, isActive, activePredicate]);
225
- return (React.createElement("svg", { width: cellSize, height: cellSize, style: { overflow: "hidden" } },
226
- React.createElement("text", { x: cellSize / 2, y: 14, textAnchor: "middle", fontSize: 11, fontWeight: "bold", fill: "#333" }, label),
227
- histogram.bars.map((bar, i) => (React.createElement("rect", { key: `bg-${i}`, x: bar.x, y: cellSize - bar.h, width: Math.max(bar.w, 1), height: bar.h, fill: "#ccc", opacity: isActive ? 0.3 : 0.6 }))),
228
- isActive &&
229
- histogram.selectedBars.map((bar, i) => (React.createElement("rect", { key: `sel-${i}`, x: bar.x, y: cellSize - bar.h, width: Math.max(bar.w, 1), height: bar.h, fill: hooks_1.DEFAULT_COLOR, opacity: 0.7 })))));
230
- }
231
- // ── Label Cell ─────────────────────────────────────────────────────────────
232
- function LabelCell({ label, cellSize }) {
233
- return (React.createElement("svg", { width: cellSize, height: cellSize },
234
- React.createElement("text", { x: cellSize / 2, y: cellSize / 2, textAnchor: "middle", dominantBaseline: "middle", fontSize: 12, fontWeight: "bold", fill: "#333" }, label)));
235
- }
236
- // ── ScatterplotMatrix ──────────────────────────────────────────────────────
237
- function ScatterplotMatrixInner(props) {
238
- const { data, fields, fieldLabels = {}, colorBy, colorScheme = "category10", cellSize = 150, cellGap = 4, pointRadius = 2, pointOpacity = 0.5, diagonal = "histogram", histogramBins = 20, brushMode = "crossfilter", hoverMode = true, unselectedOpacity = 0.1, showGrid = false, tooltip, showLegend, idAccessor, width, height, className } = props;
239
- const brushSelectionName = "splom";
240
- const hoverSelectionName = "splom-hover";
241
- // Brush and hover are mutually exclusive: hover wins when enabled
242
- const cellMode = hoverMode ? "hover" : (brushMode ? "brush" : "hover");
243
- // Grid-level hover state — single tooltip for the entire matrix
244
- const clearSelection = (0, SelectionStore_1.useSelectionSelector)((s) => s.clearSelection);
245
- const [hoveredInfo, setHoveredInfo] = (0, react_1.useState)(null);
246
- // Clear all hover state when mouse leaves the grid
247
- const handleGridMouseLeave = (0, react_1.useCallback)(() => {
248
- clearSelection(hoverSelectionName);
249
- setHoveredInfo(null);
250
- }, [clearSelection, hoverSelectionName]);
251
- // Stamp each datum with a stable index for cross-cell identity matching
252
- const indexedData = (0, react_1.useMemo)(() => {
253
- return (data || []).map((d, i) => {
254
- if (d[SPLOM_IDX] !== undefined)
255
- return d;
256
- return { ...d, [SPLOM_IDX]: i };
257
- });
258
- }, [data]);
259
- const colorScale = (0, hooks_1.useColorScale)(indexedData, colorBy, colorScheme);
260
- const n = fields.length;
261
- const labelWidth = 40;
262
- // Legend
263
- const shouldShowLegend = showLegend !== undefined ? showLegend : !!colorBy;
264
- const legend = (0, react_1.useMemo)(() => {
265
- if (!shouldShowLegend || !colorBy)
266
- return null;
267
- const colorField = typeof colorBy === "string" ? colorBy : null;
268
- if (!colorField)
269
- return null;
270
- const categories = [...new Set(indexedData.map((d) => d[colorField]))];
271
- return categories.map((cat) => ({
272
- label: String(cat),
273
- color: colorScale ? colorScale(String(cat)) : hooks_1.DEFAULT_COLOR
274
- }));
275
- }, [shouldShowLegend, colorBy, indexedData, colorScale]);
276
- const gridStyle = (0, react_1.useMemo)(() => ({
277
- display: "grid",
278
- gridTemplateColumns: `${labelWidth}px ${fields.map(() => `${cellSize}px`).join(" ")}`,
279
- gridTemplateRows: `${fields.map(() => `${cellSize}px`).join(" ")} ${labelWidth}px`,
280
- gap: `${cellGap}px`,
281
- width: "fit-content"
282
- }), [fields, cellSize, cellGap, labelWidth]);
283
- return (React.createElement("div", { className: className, style: { position: "relative" } },
284
- legend && (React.createElement("div", { style: { display: "flex", gap: 12, marginBottom: 8, flexWrap: "wrap" } }, legend.map((item) => (React.createElement("div", { key: item.label, style: { display: "flex", alignItems: "center", gap: 4 } },
285
- React.createElement("span", { style: {
286
- display: "inline-block",
287
- width: 10,
288
- height: 10,
289
- borderRadius: "50%",
290
- backgroundColor: item.color
291
- } }),
292
- React.createElement("span", { style: { fontSize: 11 } }, item.label)))))),
293
- React.createElement("div", { style: gridStyle, onMouseLeave: cellMode === "hover" ? handleGridMouseLeave : undefined },
294
- fields.map((rowField, row) => (React.createElement(React.Fragment, { key: `row-${rowField}` },
295
- React.createElement("div", { style: {
296
- display: "flex",
297
- alignItems: "center",
298
- justifyContent: "center",
299
- writingMode: "vertical-rl",
300
- transform: "rotate(180deg)",
301
- fontSize: 11,
302
- fontWeight: "bold",
303
- color: "#333"
304
- } }, fieldLabels[rowField] || rowField),
305
- fields.map((colField, col) => {
306
- if (row === col) {
307
- // Diagonal
308
- if (diagonal === "label") {
309
- return (React.createElement(LabelCell, { key: `diag-${rowField}`, label: fieldLabels[rowField] || rowField, cellSize: cellSize }));
310
- }
311
- return (React.createElement(DiagonalCell, { key: `diag-${rowField}`, data: indexedData, field: rowField, label: fieldLabels[rowField] || rowField, cellSize: cellSize, bins: histogramBins, colorBy: colorBy, colorScale: colorScale, brushSelectionName: brushSelectionName, hoverSelectionName: hoverSelectionName, unselectedOpacity: unselectedOpacity, mode: cellMode }));
312
- }
313
- return (React.createElement(ScatterplotCell, { key: `cell-${rowField}-${colField}`, data: indexedData, xField: colField, yField: rowField, fieldLabels: fieldLabels, cellSize: cellSize, pointRadius: pointRadius, pointOpacity: pointOpacity, colorBy: colorBy, colorScale: colorScale, brushSelectionName: brushSelectionName, hoverSelectionName: hoverSelectionName, unselectedOpacity: unselectedOpacity, showGrid: showGrid, tooltip: tooltip, mode: cellMode, onPointHover: cellMode === "hover" ? (datum, px, py) => {
314
- if (datum) {
315
- setHoveredInfo({
316
- datum,
317
- xField: colField,
318
- yField: rowField,
319
- colIndex: col,
320
- rowIndex: row,
321
- px: px ?? 0,
322
- py: py ?? 0
323
- });
324
- }
325
- else {
326
- setHoveredInfo(null);
327
- }
328
- } : undefined }));
329
- })))),
330
- React.createElement("div", null),
331
- " ",
332
- fields.map((field) => (React.createElement("div", { key: `col-label-${field}`, style: {
333
- display: "flex",
334
- alignItems: "center",
335
- justifyContent: "center",
336
- fontSize: 11,
337
- fontWeight: "bold",
338
- color: "#333"
339
- } }, fieldLabels[field] || field)))),
340
- hoveredInfo && cellMode === "hover" && (() => {
341
- const d = hoveredInfo.datum;
342
- const xFieldLabel = fieldLabels[hoveredInfo.xField] || hoveredInfo.xField;
343
- const yFieldLabel = fieldLabels[hoveredInfo.yField] || hoveredInfo.yField;
344
- const colorLabel = colorBy
345
- ? typeof colorBy === "function" ? colorBy(d) : d[colorBy]
346
- : null;
347
- // Resolve ID for header
348
- const idLabel = idAccessor
349
- ? (typeof idAccessor === "function" ? idAccessor(d) : d[idAccessor])
350
- : `Row ${d[SPLOM_IDX]}`;
351
- // Cell origin in grid coordinates
352
- const cellLeft = labelWidth + hoveredInfo.colIndex * (cellSize + cellGap);
353
- const cellTop = hoveredInfo.rowIndex * (cellSize + cellGap);
354
- // Point position within the cell
355
- const tooltipLeft = cellLeft + hoveredInfo.px;
356
- const tooltipTop = cellTop + hoveredInfo.py - 8; // 8px above the point
357
- return (React.createElement("div", { style: {
358
- position: "absolute",
359
- left: tooltipLeft,
360
- top: tooltipTop,
361
- transform: "translate(-50%, -100%)",
362
- color: "#333",
363
- background: "rgba(255,255,255,0.95)",
364
- border: "1px solid #ddd",
365
- borderRadius: 3,
366
- padding: "4px 8px",
367
- fontSize: 11,
368
- lineHeight: 1.4,
369
- whiteSpace: "nowrap",
370
- pointerEvents: "none",
371
- zIndex: 10
372
- } },
373
- React.createElement("div", { style: { fontWeight: "bold", marginBottom: 2 } }, String(idLabel)),
374
- React.createElement("div", null,
375
- xFieldLabel,
376
- ": ",
377
- d[hoveredInfo.xField] != null ? Number(d[hoveredInfo.xField]).toFixed(1) : "–"),
378
- React.createElement("div", null,
379
- yFieldLabel,
380
- ": ",
381
- d[hoveredInfo.yField] != null ? Number(d[hoveredInfo.yField]).toFixed(1) : "–"),
382
- colorLabel != null && React.createElement("div", { style: { opacity: 0.8 } },
383
- typeof colorBy === "string" ? colorBy : "group",
384
- ": ",
385
- String(colorLabel))));
386
- })()));
387
- }
388
- /**
389
- * ScatterplotMatrix (SPLOM) — multi-dimensional scatter visualization
390
- *
391
- * Renders an N×N grid of scatterplots for all pairwise combinations of the
392
- * specified fields. Diagonal cells show histograms. Supports two interaction
393
- * modes:
394
- *
395
- * - **Hover** (default): hover a point to cross-highlight the same datum
396
- * in every cell. Set `hoverMode={true}` (the default).
397
- * - **Brush**: drag to select a region in one cell; matching points are
398
- * highlighted across all cells (crossfilter: the brushed cell excludes
399
- * its own filter). Set `hoverMode={false}` to enable brush mode.
400
- *
401
- * The two modes are mutually exclusive — hover takes priority when enabled.
402
- *
403
- * @example
404
- * ```tsx
405
- * <ScatterplotMatrix
406
- * data={iris}
407
- * fields={["sepalLength", "sepalWidth", "petalLength", "petalWidth"]}
408
- * colorBy="species"
409
- * cellSize={160}
410
- * diagonal="histogram"
411
- * />
412
- * ```
413
- */
414
- function ScatterplotMatrix(props) {
415
- const { brushMode = "crossfilter", hoverMode = true } = props;
416
- const selectionConfig = {};
417
- if (!hoverMode && brushMode) {
418
- selectionConfig.splom = { resolution: brushMode };
419
- }
420
- if (hoverMode) {
421
- selectionConfig["splom-hover"] = { resolution: "union" };
422
- }
423
- return (React.createElement(LinkedCharts_1.LinkedCharts, { selections: selectionConfig },
424
- React.createElement(ScatterplotMatrixInner, { ...props })));
425
- }
426
- ScatterplotMatrix.displayName = "ScatterplotMatrix";
@@ -1,231 +0,0 @@
1
- "use client";
2
- "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || (function () {
20
- var ownKeys = function(o) {
21
- ownKeys = Object.getOwnPropertyNames || function (o) {
22
- var ar = [];
23
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
- return ar;
25
- };
26
- return ownKeys(o);
27
- };
28
- return function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
35
- })();
36
- var __importDefault = (this && this.__importDefault) || function (mod) {
37
- return (mod && mod.__esModule) ? mod : { "default": mod };
38
- };
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.StackedAreaChart = StackedAreaChart;
41
- const React = __importStar(require("react"));
42
- const react_1 = require("react");
43
- const StreamXYFrame_1 = __importDefault(require("../../stream/StreamXYFrame"));
44
- const colorUtils_1 = require("../shared/colorUtils");
45
- const hooks_1 = require("../shared/hooks");
46
- const legendUtils_1 = require("../shared/legendUtils");
47
- const Tooltip_1 = require("../../Tooltip/Tooltip");
48
- const tooltipUtils_1 = require("../shared/tooltipUtils");
49
- const ChartError_1 = __importDefault(require("../shared/ChartError"));
50
- const validateChartData_1 = require("../shared/validateChartData");
51
- const selectionUtils_1 = require("../shared/selectionUtils");
52
- const useSelection_1 = require("../../store/useSelection");
53
- const useSelection_2 = require("../../store/useSelection");
54
- /**
55
- * StackedAreaChart - Visualize quantities stacked on top of each other over continuous intervals
56
- *
57
- * Each series is stacked so that the total height represents the sum of all series.
58
- * Use `normalize` for 100% stacked (proportional) areas.
59
- *
60
- * For overlapping (non-stacked) areas use {@link AreaChart}.
61
- *
62
- * @example
63
- * ```tsx
64
- * <StackedAreaChart
65
- * data={[
66
- * {x: 1, y: 10, category: 'A'},
67
- * {x: 2, y: 20, category: 'A'},
68
- * {x: 1, y: 15, category: 'B'},
69
- * {x: 2, y: 25, category: 'B'}
70
- * ]}
71
- * areaBy="category"
72
- * colorBy="category"
73
- * xLabel="Time"
74
- * yLabel="Value"
75
- * />
76
- * ```
77
- */
78
- function StackedAreaChart(props) {
79
- const { data, width = 600, height = 400, margin: userMargin, className, title, xLabel, yLabel, xFormat, yFormat, xAccessor = "x", yAccessor = "y", areaBy, lineDataAccessor = "coordinates", colorBy, colorScheme = "category10", curve = "monotoneX", areaOpacity = 0.7, showLine = true, lineWidth = 2, normalize = false, enableHover = true, showGrid = false, showLegend, tooltip, frameProps = {}, selection, linkedHover } = props;
80
- const safeData = data || [];
81
- // ── Selection hooks (always called, conditional logic inside) ──────────
82
- const hoverConfig = (0, selectionUtils_1.normalizeLinkedHover)(linkedHover, colorBy ? [typeof colorBy === "string" ? colorBy : ""] : []);
83
- const selectionHook = (0, useSelection_1.useSelection)({
84
- name: selection?.name || "__unused__",
85
- fields: []
86
- });
87
- const linkedHoverHook = (0, useSelection_2.useLinkedHover)({
88
- name: hoverConfig?.name || "hover",
89
- fields: hoverConfig?.fields || []
90
- });
91
- // Only use the hooks when the corresponding props are provided
92
- const activeSelectionHook = selection ? { isActive: selectionHook.isActive, predicate: selectionHook.predicate } : null;
93
- // ── Core chart logic ───────────────────────────────────────────────────
94
- // Check if data is in area objects format (has lineDataAccessor field)
95
- const isAreaObjectFormat = safeData[0]?.[lineDataAccessor] !== undefined;
96
- // Transform data to line/area format if needed
97
- const areaData = (0, react_1.useMemo)(() => {
98
- if (isAreaObjectFormat) {
99
- // Data is already in area objects format
100
- return safeData;
101
- }
102
- if (areaBy) {
103
- // Group data by areaBy field
104
- const grouped = safeData.reduce((acc, d) => {
105
- const key = typeof areaBy === "function" ? areaBy(d) : d[areaBy];
106
- if (!acc[key]) {
107
- const areaObj = { [lineDataAccessor]: [] };
108
- // Add the grouping field
109
- if (typeof areaBy === "string") {
110
- areaObj[areaBy] = key;
111
- }
112
- acc[key] = areaObj;
113
- }
114
- acc[key][lineDataAccessor].push(d);
115
- return acc;
116
- }, {});
117
- return Object.values(grouped);
118
- }
119
- // Single area - wrap in area object
120
- return [{ [lineDataAccessor]: safeData }];
121
- }, [safeData, areaBy, lineDataAccessor, isAreaObjectFormat]);
122
- // Create color scale if colorBy is specified
123
- const colorScale = (0, hooks_1.useColorScale)(safeData, colorBy, colorScheme);
124
- // Area/line style function
125
- const baseLineStyle = (0, react_1.useMemo)(() => {
126
- return (d) => {
127
- const baseStyle = {};
128
- // Apply color
129
- const color = colorBy ? (0, colorUtils_1.getColor)(d, colorBy, colorScale) : hooks_1.DEFAULT_COLOR;
130
- baseStyle.fill = color;
131
- baseStyle.fillOpacity = areaOpacity;
132
- if (showLine) {
133
- baseStyle.stroke = color;
134
- baseStyle.strokeWidth = lineWidth;
135
- }
136
- else {
137
- baseStyle.stroke = "none";
138
- }
139
- return baseStyle;
140
- };
141
- }, [colorBy, colorScale, areaOpacity, showLine, lineWidth]);
142
- const lineStyle = (0, react_1.useMemo)(() => (0, selectionUtils_1.wrapStyleWithSelection)(baseLineStyle, activeSelectionHook, selection), [baseLineStyle, activeSelectionHook, selection]);
143
- // Determine if we should show legend
144
- const shouldShowLegend = showLegend !== undefined ? showLegend : areaData.length > 1;
145
- // Build legend if needed
146
- const legend = (0, react_1.useMemo)(() => {
147
- if (!shouldShowLegend || !colorBy)
148
- return undefined;
149
- return (0, legendUtils_1.createLegend)({
150
- data: areaData,
151
- colorBy,
152
- colorScale,
153
- getColor: colorUtils_1.getColor
154
- });
155
- }, [shouldShowLegend, colorBy, areaData, colorScale]);
156
- // Adjust margin for legend if present
157
- const margin = (0, react_1.useMemo)(() => {
158
- const defaultMargin = { top: 50, bottom: 60, left: 70, right: 40 };
159
- const finalMargin = { ...defaultMargin, ...userMargin };
160
- // If legend is present and right margin is too small, increase it
161
- if (legend && finalMargin.right < 120) {
162
- finalMargin.right = 120;
163
- }
164
- return finalMargin;
165
- }, [userMargin, legend]);
166
- // ── Hover behavior ─────────────────────────────────────────────────────
167
- const customHoverBehavior = (0, react_1.useCallback)((d) => {
168
- if (linkedHover) {
169
- linkedHoverHook.onHover(d);
170
- }
171
- }, [linkedHover, linkedHoverHook]);
172
- // Default tooltip showing all configured fields
173
- const groupField = areaBy || colorBy;
174
- const defaultTooltipContent = (0, react_1.useMemo)(() => (0, tooltipUtils_1.buildDefaultTooltip)([
175
- { label: xLabel || (0, tooltipUtils_1.accessorName)(xAccessor), accessor: xAccessor, role: "x" },
176
- { label: yLabel || (0, tooltipUtils_1.accessorName)(yAccessor), accessor: yAccessor, role: "y" },
177
- ...(groupField ? [{ label: (0, tooltipUtils_1.accessorName)(groupField), accessor: groupField, role: "group" }] : []),
178
- ]), [xAccessor, yAccessor, xLabel, yLabel, groupField]);
179
- // Validate data (after all hooks)
180
- const error = (0, validateChartData_1.validateArrayData)({
181
- componentName: "StackedAreaChart",
182
- data: safeData,
183
- accessors: {
184
- xAccessor,
185
- yAccessor,
186
- },
187
- });
188
- if (error)
189
- return React.createElement(ChartError_1.default, { componentName: "StackedAreaChart", message: error, width: width, height: height });
190
- // Flatten area data into a single array for StreamXYFrame
191
- const flattenedData = (0, react_1.useMemo)(() => {
192
- if (isAreaObjectFormat || areaBy) {
193
- return areaData.flatMap((area) => {
194
- const coords = area[lineDataAccessor] || [];
195
- if (areaBy && typeof areaBy === "string") {
196
- return coords.map((c) => ({ ...c, [areaBy]: area[areaBy] }));
197
- }
198
- return coords;
199
- });
200
- }
201
- return safeData;
202
- }, [areaData, lineDataAccessor, isAreaObjectFormat, areaBy, safeData]);
203
- // Build StreamXYFrame props
204
- const streamProps = {
205
- chartType: "stackedarea",
206
- data: flattenedData,
207
- xAccessor,
208
- yAccessor,
209
- groupAccessor: areaBy || undefined,
210
- curve,
211
- normalize,
212
- lineStyle,
213
- size: [width, height],
214
- margin,
215
- showAxes: true,
216
- xLabel,
217
- yLabel,
218
- xFormat,
219
- yFormat,
220
- enableHover,
221
- showGrid,
222
- ...(legend && { legend }),
223
- ...(title && { title }),
224
- ...(className && { className }),
225
- tooltipContent: (tooltip ? (0, Tooltip_1.normalizeTooltip)(tooltip) : defaultTooltipContent),
226
- ...(linkedHover && { customHoverBehavior }),
227
- ...frameProps
228
- };
229
- return React.createElement(StreamXYFrame_1.default, { ...streamProps });
230
- }
231
- StackedAreaChart.displayName = "StackedAreaChart";
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.projectedXBottom = exports.projectedXTop = exports.projectedXMiddle = exports.projectedYBottom = exports.projectedYTop = exports.projectedYMiddle = exports.projectedY = exports.projectedX = void 0;
4
- exports.projectedX = "x";
5
- exports.projectedY = "y";
6
- exports.projectedYMiddle = "yMiddle";
7
- exports.projectedYTop = "yTop";
8
- exports.projectedYBottom = "yBottom";
9
- exports.projectedXMiddle = "xMiddle";
10
- exports.projectedXTop = "xTop";
11
- exports.projectedXBottom = "xBottom";