semiotic 2.0.3 → 3.0.0-beta.2
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.
- package/CLAUDE.md +828 -0
- package/README.md +215 -37
- package/ai/cli.js +48 -0
- package/ai/dist/ai/componentRegistry.js +45 -0
- package/ai/dist/ai/mcp-server.js +99 -0
- package/ai/dist/ai/renderHOCToSVG.js +77 -0
- package/ai/dist/src/components/Annotation.js +358 -0
- package/ai/dist/src/components/AnnotationLayer/AnnotationLayer.js +369 -0
- package/ai/dist/src/components/Axis/Axis.js +374 -0
- package/ai/dist/src/components/Axis/axisTitle.js +14 -0
- package/ai/dist/src/components/Axis/index.js +7 -0
- package/ai/dist/src/components/Axis/summaryGraphic.js +37 -0
- package/ai/dist/src/components/Brush.js +84 -0
- package/ai/dist/src/components/ChartErrorBoundary.js +91 -0
- package/ai/dist/src/components/DividedLine.js +65 -0
- package/ai/dist/src/components/Legend.js +140 -0
- package/ai/dist/src/components/LinkedCharts.js +95 -0
- package/ai/dist/src/components/ThemeProvider.js +79 -0
- package/ai/dist/src/components/Tooltip/Tooltip.js +309 -0
- package/ai/dist/src/components/TooltipPositioner/index.js +132 -0
- package/ai/dist/src/components/annotationLayerBehavior/annotationHandling.js +73 -0
- package/ai/dist/src/components/annotationLayerBehavior/d3labeler.js +254 -0
- package/ai/dist/src/components/annotationRules/baseRules.js +150 -0
- package/ai/dist/src/components/annotationRules/networkframeRules.js +196 -0
- package/ai/dist/src/components/annotationRules/xyframeRules.js +297 -0
- package/ai/dist/src/components/batchWork.js +35 -0
- package/ai/dist/src/components/charts/index.js +109 -0
- package/ai/dist/src/components/charts/network/ChordDiagram.js +142 -0
- package/ai/dist/src/components/charts/network/CirclePack.js +108 -0
- package/ai/dist/src/components/charts/network/ForceDirectedGraph.js +121 -0
- package/ai/dist/src/components/charts/network/SankeyDiagram.js +155 -0
- package/ai/dist/src/components/charts/network/TreeDiagram.js +110 -0
- package/ai/dist/src/components/charts/network/Treemap.js +106 -0
- package/ai/dist/src/components/charts/ordinal/BarChart.js +156 -0
- package/ai/dist/src/components/charts/ordinal/BoxPlot.js +139 -0
- package/ai/dist/src/components/charts/ordinal/DonutChart.js +130 -0
- package/ai/dist/src/components/charts/ordinal/DotPlot.js +126 -0
- package/ai/dist/src/components/charts/ordinal/GroupedBarChart.js +129 -0
- package/ai/dist/src/components/charts/ordinal/Histogram.js +132 -0
- package/ai/dist/src/components/charts/ordinal/PieChart.js +128 -0
- package/ai/dist/src/components/charts/ordinal/RidgelinePlot.js +130 -0
- package/ai/dist/src/components/charts/ordinal/StackedBarChart.js +130 -0
- package/ai/dist/src/components/charts/ordinal/SwarmPlot.js +147 -0
- package/ai/dist/src/components/charts/ordinal/ViolinPlot.js +138 -0
- package/ai/dist/src/components/charts/realtime/RealtimeHeatmap.js +79 -0
- package/ai/dist/src/components/charts/realtime/RealtimeHistogram.js +114 -0
- package/ai/dist/src/components/charts/realtime/RealtimeLineChart.js +93 -0
- package/ai/dist/src/components/charts/realtime/RealtimeSwarmChart.js +105 -0
- package/ai/dist/src/components/charts/realtime/RealtimeWaterfallChart.js +106 -0
- package/ai/dist/src/components/charts/shared/ChartError.js +72 -0
- package/ai/dist/src/components/charts/shared/colorUtils.js +138 -0
- package/ai/dist/src/components/charts/shared/formatUtils.js +213 -0
- package/ai/dist/src/components/charts/shared/hooks.js +49 -0
- package/ai/dist/src/components/charts/shared/legendUtils.js +57 -0
- package/ai/dist/src/components/charts/shared/selectionUtils.js +67 -0
- package/ai/dist/src/components/charts/shared/tooltipUtils.js +79 -0
- package/ai/dist/src/components/charts/shared/types.js +2 -0
- package/ai/dist/src/components/charts/shared/validateChartData.js +82 -0
- package/ai/dist/src/components/charts/shared/validateProps.js +736 -0
- package/ai/dist/src/components/charts/xy/AreaChart.js +230 -0
- package/ai/dist/src/components/charts/xy/BubbleChart.js +251 -0
- package/ai/dist/src/components/charts/xy/Heatmap.js +235 -0
- package/ai/dist/src/components/charts/xy/LineChart.js +307 -0
- package/ai/dist/src/components/charts/xy/MinimapChart.js +298 -0
- package/ai/dist/src/components/charts/xy/Scatterplot.js +172 -0
- package/ai/dist/src/components/charts/xy/ScatterplotMatrix.js +426 -0
- package/ai/dist/src/components/charts/xy/StackedAreaChart.js +231 -0
- package/ai/dist/src/components/constants/coordinateNames.js +11 -0
- package/ai/dist/src/components/constants/frame_props.js +251 -0
- package/ai/dist/src/components/data/dataFunctions.js +487 -0
- package/ai/dist/src/components/data/multiAccessorUtils.js +14 -0
- package/ai/dist/src/components/data/transforms.js +143 -0
- package/ai/dist/src/components/data/unflowedFunctions.js +5 -0
- package/ai/dist/src/components/export/exportChart.js +121 -0
- package/ai/dist/src/components/generic_utilities/functions.js +5 -0
- package/ai/dist/src/components/geometry/areaDrawing.js +312 -0
- package/ai/dist/src/components/geometry/contourLayout.js +73 -0
- package/ai/dist/src/components/geometry/hexbinLayout.js +163 -0
- package/ai/dist/src/components/geometry/lineDrawing.js +356 -0
- package/ai/dist/src/components/geometry/sankeyLinks.js +331 -0
- package/ai/dist/src/components/geometry/summaryLayouts.js +136 -0
- package/ai/dist/src/components/index.js +18 -0
- package/ai/dist/src/components/processing/InteractionItems.js +223 -0
- package/ai/dist/src/components/processing/hierarchyUtils.js +104 -0
- package/ai/dist/src/components/processing/layouts/chordLayout.js +58 -0
- package/ai/dist/src/components/processing/layouts/forceLayout.js +142 -0
- package/ai/dist/src/components/processing/layouts/hierarchyLayout.js +31 -0
- package/ai/dist/src/components/processing/layouts/index.js +32 -0
- package/ai/dist/src/components/processing/layouts/sankeyLayout.js +96 -0
- package/ai/dist/src/components/processing/layouts/simpleLayouts.js +34 -0
- package/ai/dist/src/components/processing/layouts/types.js +2 -0
- package/ai/dist/src/components/processing/networkDefaults.js +39 -0
- package/ai/dist/src/components/realtime/BinAccumulator.js +36 -0
- package/ai/dist/src/components/realtime/IncrementalExtent.js +55 -0
- package/ai/dist/src/components/realtime/RingBuffer.js +104 -0
- package/ai/dist/src/components/realtime/renderers/barRenderer.js +133 -0
- package/ai/dist/src/components/realtime/renderers/candlestickRenderer.js +7 -0
- package/ai/dist/src/components/realtime/renderers/lineRenderer.js +164 -0
- package/ai/dist/src/components/realtime/renderers/swarmRenderer.js +91 -0
- package/ai/dist/src/components/realtime/renderers/types.js +2 -0
- package/ai/dist/src/components/realtime/renderers/waterfallRenderer.js +163 -0
- package/ai/dist/src/components/realtime/types.js +2 -0
- package/ai/dist/src/components/semiotic-ai.js +89 -0
- package/ai/dist/src/components/semiotic-data.js +12 -0
- package/ai/dist/src/components/semiotic-network.js +38 -0
- package/ai/dist/src/components/semiotic-ordinal.js +28 -0
- package/ai/dist/src/components/semiotic-realtime.js +30 -0
- package/ai/dist/src/components/semiotic-server.js +8 -0
- package/ai/dist/src/components/semiotic-xy.js +35 -0
- package/ai/dist/src/components/semiotic.js +109 -0
- package/ai/dist/src/components/server/renderToStaticSVG.js +594 -0
- package/ai/dist/src/components/store/SelectionStore.js +91 -0
- package/ai/dist/src/components/store/ThemeStore.js +78 -0
- package/ai/dist/src/components/store/TooltipStore.js +13 -0
- package/ai/dist/src/components/store/createStore.js +81 -0
- package/ai/dist/src/components/store/useSelection.js +133 -0
- package/ai/dist/src/components/stream/CanvasHitTester.js +164 -0
- package/ai/dist/src/components/stream/DataSourceAdapter.js +99 -0
- package/ai/dist/src/components/stream/MarginalGraphics.js +266 -0
- package/ai/dist/src/components/stream/NetworkCanvasHitTester.js +228 -0
- package/ai/dist/src/components/stream/NetworkPipelineStore.js +498 -0
- package/ai/dist/src/components/stream/NetworkSVGOverlay.js +70 -0
- package/ai/dist/src/components/stream/NetworkSceneGraph.js +38 -0
- package/ai/dist/src/components/stream/OrdinalCanvasHitTester.js +146 -0
- package/ai/dist/src/components/stream/OrdinalPipelineStore.js +786 -0
- package/ai/dist/src/components/stream/OrdinalSVGOverlay.js +130 -0
- package/ai/dist/src/components/stream/ParticlePool.js +174 -0
- package/ai/dist/src/components/stream/PipelineStore.js +1243 -0
- package/ai/dist/src/components/stream/SVGOverlay.js +129 -0
- package/ai/dist/src/components/stream/SceneGraph.js +132 -0
- package/ai/dist/src/components/stream/StreamNetworkFrame.js +561 -0
- package/ai/dist/src/components/stream/StreamOrdinalFrame.js +492 -0
- package/ai/dist/src/components/stream/StreamXYFrame.js +590 -0
- package/ai/dist/src/components/stream/accessorUtils.js +20 -0
- package/ai/dist/src/components/stream/index.js +32 -0
- package/ai/dist/src/components/stream/layouts/chordLayoutPlugin.js +352 -0
- package/ai/dist/src/components/stream/layouts/forceLayoutPlugin.js +230 -0
- package/ai/dist/src/components/stream/layouts/hierarchyLayoutPlugin.js +568 -0
- package/ai/dist/src/components/stream/layouts/index.js +28 -0
- package/ai/dist/src/components/stream/layouts/sankeyLayoutPlugin.js +245 -0
- package/ai/dist/src/components/stream/networkTypes.js +17 -0
- package/ai/dist/src/components/stream/ordinalSceneBuilders/barScene.js +126 -0
- package/ai/dist/src/components/stream/ordinalSceneBuilders/connectorScene.js +62 -0
- package/ai/dist/src/components/stream/ordinalSceneBuilders/pieScene.js +33 -0
- package/ai/dist/src/components/stream/ordinalSceneBuilders/pointScene.js +63 -0
- package/ai/dist/src/components/stream/ordinalSceneBuilders/statisticalScene.js +278 -0
- package/ai/dist/src/components/stream/ordinalSceneBuilders/timelineScene.js +30 -0
- package/ai/dist/src/components/stream/ordinalSceneBuilders/types.js +2 -0
- package/ai/dist/src/components/stream/ordinalTypes.js +2 -0
- package/ai/dist/src/components/stream/renderers/areaCanvasRenderer.js +48 -0
- package/ai/dist/src/components/stream/renderers/barCanvasRenderer.js +70 -0
- package/ai/dist/src/components/stream/renderers/boxplotCanvasRenderer.js +75 -0
- package/ai/dist/src/components/stream/renderers/candlestickCanvasRenderer.js +28 -0
- package/ai/dist/src/components/stream/renderers/connectorCanvasRenderer.js +47 -0
- package/ai/dist/src/components/stream/renderers/heatmapCanvasRenderer.js +31 -0
- package/ai/dist/src/components/stream/renderers/lineCanvasRenderer.js +140 -0
- package/ai/dist/src/components/stream/renderers/networkArcRenderer.js +38 -0
- package/ai/dist/src/components/stream/renderers/networkCircleRenderer.js +37 -0
- package/ai/dist/src/components/stream/renderers/networkEdgeRenderer.js +102 -0
- package/ai/dist/src/components/stream/renderers/networkParticleRenderer.js +63 -0
- package/ai/dist/src/components/stream/renderers/networkRectRenderer.js +35 -0
- package/ai/dist/src/components/stream/renderers/pointCanvasRenderer.js +38 -0
- package/ai/dist/src/components/stream/renderers/swarmCanvasRenderer.js +10 -0
- package/ai/dist/src/components/stream/renderers/types.js +2 -0
- package/ai/dist/src/components/stream/renderers/violinCanvasRenderer.js +47 -0
- package/ai/dist/src/components/stream/renderers/waterfallCanvasRenderer.js +38 -0
- package/ai/dist/src/components/stream/renderers/wedgeCanvasRenderer.js +33 -0
- package/ai/dist/src/components/stream/types.js +2 -0
- package/ai/dist/src/components/types/annotationTypes.js +2 -0
- package/ai/dist/src/components/types/canvasTypes.js +2 -0
- package/ai/dist/src/components/types/generalTypes.js +2 -0
- package/ai/dist/src/components/types/interactionTypes.js +2 -0
- package/ai/dist/src/components/types/legendTypes.js +2 -0
- package/ai/dist/src/components/types/networkTypes.js +2 -0
- package/ai/dist/src/components/types/ordinalTypes.js +2 -0
- package/ai/dist/src/components/types/xyTypes.js +2 -0
- package/ai/dist/src/components/useBoundingRect.js +24 -0
- package/ai/dist/src/components/visualizationLayerBehavior/axis.js +301 -0
- package/ai/dist/src/components/visualizationLayerBehavior/general.js +435 -0
- package/ai/dist/src/setupTests.js +4 -0
- package/ai/examples.md +489 -0
- package/ai/schema.json +1338 -0
- package/ai/system-prompt.md +41 -0
- package/dist/AnnotationLayer/AnnotationLayer.d.ts +0 -1
- package/dist/Axis/axisTitle.d.ts +3 -3
- package/dist/Axis/summaryGraphic.d.ts +1 -1
- package/dist/ChartErrorBoundary.d.ts +39 -0
- package/dist/LinkedCharts.d.ts +42 -0
- package/dist/ThemeProvider.d.ts +12 -0
- package/dist/Tooltip/Tooltip.d.ts +141 -0
- package/dist/TooltipPositioner/index.d.ts +1 -1
- package/dist/annotationLayerBehavior/annotationHandling.d.ts +2 -2
- package/dist/annotationRules/networkframeRules.d.ts +2 -2
- package/dist/annotationRules/xyframeRules.d.ts +2 -2
- package/dist/batchWork.d.ts +1 -1
- package/dist/charts/index.d.ts +74 -0
- package/dist/charts/network/ChordDiagram.d.ts +36 -0
- package/dist/charts/network/CirclePack.d.ts +32 -0
- package/dist/charts/network/ForceDirectedGraph.d.ts +38 -0
- package/dist/charts/network/SankeyDiagram.d.ts +38 -0
- package/dist/charts/network/TreeDiagram.d.ts +34 -0
- package/dist/charts/network/Treemap.d.ts +33 -0
- package/dist/charts/ordinal/BarChart.d.ts +32 -0
- package/dist/charts/ordinal/BoxPlot.d.ts +27 -0
- package/dist/charts/ordinal/DonutChart.d.ts +23 -0
- package/dist/charts/ordinal/DotPlot.d.ts +27 -0
- package/dist/charts/ordinal/GroupedBarChart.d.ts +26 -0
- package/dist/charts/ordinal/Histogram.d.ts +26 -0
- package/dist/charts/ordinal/PieChart.d.ts +21 -0
- package/dist/charts/ordinal/RidgelinePlot.d.ts +34 -0
- package/dist/charts/ordinal/StackedBarChart.d.ts +27 -0
- package/dist/charts/ordinal/SwarmPlot.d.ts +29 -0
- package/dist/charts/ordinal/ViolinPlot.d.ts +28 -0
- package/dist/charts/realtime/RealtimeHeatmap.d.ts +95 -0
- package/dist/charts/realtime/RealtimeHistogram.d.ts +119 -0
- package/dist/charts/realtime/RealtimeLineChart.d.ts +98 -0
- package/dist/charts/realtime/RealtimeSwarmChart.d.ts +100 -0
- package/dist/charts/realtime/RealtimeWaterfallChart.d.ts +97 -0
- package/dist/charts/shared/ChartError.d.ts +19 -0
- package/dist/charts/shared/colorUtils.d.ts +62 -0
- package/dist/charts/shared/formatUtils.d.ts +94 -0
- package/dist/charts/shared/hooks.d.ts +20 -0
- package/dist/charts/shared/legendUtils.d.ts +32 -0
- package/dist/charts/shared/selectionUtils.d.ts +51 -0
- package/dist/charts/shared/tooltipUtils.d.ts +18 -0
- package/dist/charts/shared/types.d.ts +97 -0
- package/dist/charts/shared/validateChartData.d.ts +41 -0
- package/dist/charts/shared/validateProps.d.ts +18 -0
- package/dist/charts/xy/AreaChart.d.ts +130 -0
- package/dist/charts/xy/BubbleChart.d.ts +164 -0
- package/dist/charts/xy/Heatmap.d.ts +156 -0
- package/dist/charts/xy/LineChart.d.ts +196 -0
- package/dist/charts/xy/MinimapChart.d.ts +73 -0
- package/dist/charts/xy/Scatterplot.d.ts +55 -0
- package/dist/charts/xy/ScatterplotMatrix.d.ts +71 -0
- package/dist/charts/xy/StackedAreaChart.d.ts +134 -0
- package/dist/constants/frame_props.d.ts +9 -0
- package/dist/data/dataFunctions.d.ts +10 -11
- package/dist/data/transforms.d.ts +45 -0
- package/dist/export/exportChart.d.ts +16 -0
- package/dist/{svg → geometry}/areaDrawing.d.ts +3 -13
- package/dist/geometry/contourLayout.d.ts +6 -0
- package/dist/geometry/hexbinLayout.d.ts +7 -0
- package/dist/{svg → geometry}/lineDrawing.d.ts +7 -35
- package/dist/geometry/sankeyLinks.d.ts +2 -0
- package/dist/geometry/summaryLayouts.d.ts +45 -0
- package/dist/index.d.ts +1 -125
- package/dist/network.js +7495 -0
- package/dist/network.js.map +1 -0
- package/dist/network.min.js +1 -0
- package/dist/network.module.js +7458 -0
- package/dist/network.module.js.map +1 -0
- package/dist/network.module.min.js +1 -0
- package/dist/ordinal.js +6497 -0
- package/dist/ordinal.js.map +1 -0
- package/dist/ordinal.min.js +1 -0
- package/dist/ordinal.module.js +6465 -0
- package/dist/ordinal.module.js.map +1 -0
- package/dist/ordinal.module.min.js +1 -0
- package/dist/processing/InteractionItems.d.ts +5 -4
- package/dist/processing/hierarchyUtils.d.ts +16 -0
- package/dist/processing/layouts/chordLayout.d.ts +2 -0
- package/dist/processing/layouts/forceLayout.d.ts +3 -0
- package/dist/processing/layouts/hierarchyLayout.d.ts +10 -0
- package/dist/processing/layouts/index.d.ts +8 -0
- package/dist/processing/layouts/sankeyLayout.d.ts +8 -0
- package/dist/processing/layouts/simpleLayouts.d.ts +7 -0
- package/dist/processing/layouts/types.d.ts +17 -0
- package/dist/processing/networkDefaults.d.ts +36 -0
- package/dist/realtime/BinAccumulator.d.ts +8 -0
- package/dist/realtime/IncrementalExtent.d.ts +13 -0
- package/dist/realtime/RingBuffer.d.ts +19 -0
- package/dist/realtime/renderers/barRenderer.d.ts +2 -0
- package/dist/realtime/renderers/candlestickRenderer.d.ts +2 -0
- package/dist/realtime/renderers/lineRenderer.d.ts +2 -0
- package/dist/realtime/renderers/swarmRenderer.d.ts +2 -0
- package/dist/realtime/renderers/types.d.ts +9 -0
- package/dist/realtime/renderers/waterfallRenderer.d.ts +3 -0
- package/dist/realtime/types.d.ts +113 -0
- package/dist/realtime.js +7072 -0
- package/dist/realtime.js.map +1 -0
- package/dist/realtime.min.js +1 -0
- package/dist/realtime.module.js +7043 -0
- package/dist/realtime.module.js.map +1 -0
- package/dist/realtime.module.min.js +1 -0
- package/dist/semiotic-ai.d.ts +36 -0
- package/dist/semiotic-ai.js +13323 -0
- package/dist/semiotic-ai.js.map +1 -0
- package/dist/semiotic-ai.min.js +1 -0
- package/dist/semiotic-ai.module.js +13264 -0
- package/dist/semiotic-ai.module.js.map +1 -0
- package/dist/semiotic-ai.module.min.js +1 -0
- package/dist/semiotic-data.d.ts +5 -0
- package/dist/semiotic-data.js +141 -0
- package/dist/semiotic-data.js.map +1 -0
- package/dist/semiotic-data.min.js +1 -0
- package/dist/semiotic-data.module.js +136 -0
- package/dist/semiotic-data.module.js.map +1 -0
- package/dist/semiotic-data.module.min.js +1 -0
- package/dist/semiotic-network.d.ts +23 -0
- package/dist/semiotic-ordinal.d.ts +19 -0
- package/dist/semiotic-realtime.d.ts +22 -0
- package/dist/semiotic-server.d.ts +1 -0
- package/dist/semiotic-xy.d.ts +21 -0
- package/dist/semiotic.d.ts +41 -28
- package/dist/semiotic.js +16257 -13130
- package/dist/semiotic.js.map +1 -0
- package/dist/semiotic.min.js +1 -0
- package/dist/semiotic.module.js +16198 -13100
- package/dist/semiotic.module.js.map +1 -0
- package/dist/semiotic.module.min.js +1 -0
- package/dist/server/renderToStaticSVG.d.ts +9 -0
- package/dist/server.js +5191 -0
- package/dist/server.js.map +1 -0
- package/dist/server.min.js +1 -0
- package/dist/server.module.js +5166 -0
- package/dist/server.module.js.map +1 -0
- package/dist/server.module.min.js +1 -0
- package/dist/store/SelectionStore.d.ts +29 -0
- package/dist/store/ThemeStore.d.ts +26 -0
- package/dist/store/useSelection.d.ts +66 -0
- package/dist/stream/CanvasHitTester.d.ts +18 -0
- package/dist/stream/DataSourceAdapter.d.ts +32 -0
- package/dist/stream/MarginalGraphics.d.ts +19 -0
- package/dist/stream/NetworkCanvasHitTester.d.ts +14 -0
- package/dist/stream/NetworkPipelineStore.d.ts +74 -0
- package/dist/stream/NetworkSVGOverlay.d.ts +40 -0
- package/dist/stream/NetworkSceneGraph.d.ts +14 -0
- package/dist/stream/OrdinalCanvasHitTester.d.ts +9 -0
- package/dist/stream/OrdinalPipelineStore.d.ts +65 -0
- package/dist/stream/OrdinalSVGOverlay.d.ts +34 -0
- package/dist/stream/ParticlePool.d.ts +28 -0
- package/dist/stream/PipelineStore.d.ts +161 -0
- package/dist/stream/SVGOverlay.d.ts +37 -0
- package/dist/stream/SceneGraph.d.ts +16 -0
- package/dist/stream/StreamNetworkFrame.d.ts +4 -0
- package/dist/stream/StreamOrdinalFrame.d.ts +4 -0
- package/dist/stream/StreamXYFrame.d.ts +4 -0
- package/dist/stream/accessorUtils.d.ts +2 -0
- package/dist/stream/index.d.ts +16 -0
- package/dist/stream/layouts/chordLayoutPlugin.d.ts +8 -0
- package/dist/stream/layouts/forceLayoutPlugin.d.ts +9 -0
- package/dist/stream/layouts/hierarchyLayoutPlugin.d.ts +17 -0
- package/dist/stream/layouts/index.d.ts +11 -0
- package/dist/stream/layouts/sankeyLayoutPlugin.d.ts +8 -0
- package/dist/stream/networkTypes.d.ts +346 -0
- package/dist/stream/ordinalSceneBuilders/barScene.d.ts +4 -0
- package/dist/stream/ordinalSceneBuilders/connectorScene.d.ts +3 -0
- package/dist/stream/ordinalSceneBuilders/pieScene.d.ts +3 -0
- package/dist/stream/ordinalSceneBuilders/pointScene.d.ts +4 -0
- package/dist/stream/ordinalSceneBuilders/statisticalScene.d.ts +6 -0
- package/dist/stream/ordinalSceneBuilders/timelineScene.d.ts +3 -0
- package/dist/stream/ordinalSceneBuilders/types.d.ts +21 -0
- package/dist/stream/ordinalTypes.d.ts +225 -0
- package/dist/stream/renderers/areaCanvasRenderer.d.ts +7 -0
- package/dist/stream/renderers/barCanvasRenderer.d.ts +7 -0
- package/dist/stream/renderers/boxplotCanvasRenderer.d.ts +2 -0
- package/dist/stream/renderers/candlestickCanvasRenderer.d.ts +2 -0
- package/dist/stream/renderers/connectorCanvasRenderer.d.ts +2 -0
- package/dist/stream/renderers/heatmapCanvasRenderer.d.ts +6 -0
- package/dist/stream/renderers/lineCanvasRenderer.d.ts +8 -0
- package/dist/stream/renderers/networkArcRenderer.d.ts +5 -0
- package/dist/stream/renderers/networkCircleRenderer.d.ts +5 -0
- package/dist/stream/renderers/networkEdgeRenderer.d.ts +10 -0
- package/dist/stream/renderers/networkParticleRenderer.d.ts +11 -0
- package/dist/stream/renderers/networkRectRenderer.d.ts +5 -0
- package/dist/stream/renderers/pointCanvasRenderer.d.ts +7 -0
- package/dist/stream/renderers/swarmCanvasRenderer.d.ts +7 -0
- package/dist/stream/renderers/types.d.ts +7 -0
- package/dist/stream/renderers/violinCanvasRenderer.d.ts +2 -0
- package/dist/stream/renderers/waterfallCanvasRenderer.d.ts +8 -0
- package/dist/stream/renderers/wedgeCanvasRenderer.d.ts +2 -0
- package/dist/stream/types.d.ts +307 -0
- package/dist/types/annotationTypes.d.ts +13 -18
- package/dist/types/canvasTypes.d.ts +1 -1
- package/dist/types/generalTypes.d.ts +41 -36
- package/dist/types/interactionTypes.d.ts +7 -9
- package/dist/types/legendTypes.d.ts +2 -2
- package/dist/types/networkTypes.d.ts +40 -30
- package/dist/types/ordinalTypes.d.ts +27 -18
- package/dist/types/xyTypes.d.ts +1 -95
- package/dist/visualizationLayerBehavior/axis.d.ts +3 -5
- package/dist/visualizationLayerBehavior/general.d.ts +8 -12
- package/dist/xy.js +6993 -0
- package/dist/xy.js.map +1 -0
- package/dist/xy.min.js +1 -0
- package/dist/xy.module.js +6957 -0
- package/dist/xy.module.js.map +1 -0
- package/dist/xy.module.min.js +1 -0
- package/package.json +123 -67
- package/dist/AnnotationLayer/helpers.d.ts +0 -6
- package/dist/AnnotationLayer/index.d.ts +0 -2
- package/dist/FacetController.d.ts +0 -12
- package/dist/Frame.d.ts +0 -2
- package/dist/InteractionLayer.d.ts +0 -3
- package/dist/Mark/Mark.d.ts +0 -3
- package/dist/Mark/Mark.types.d.ts +0 -10
- package/dist/Mark/constants/markTransition.d.ts +0 -10
- package/dist/Mark/markBehavior/drawing.d.ts +0 -13
- package/dist/MiniMap.d.ts +0 -14
- package/dist/MinimapXYFrame.d.ts +0 -10
- package/dist/NetworkFrame.d.ts +0 -4
- package/dist/OrdinalFrame.d.ts +0 -4
- package/dist/ResponsiveFrame.d.ts +0 -22
- package/dist/ResponsiveMinimapXYFrame.d.ts +0 -6
- package/dist/ResponsiveNetworkFrame.d.ts +0 -6
- package/dist/ResponsiveOrdinalFrame.d.ts +0 -6
- package/dist/ResponsiveXYFrame.d.ts +0 -6
- package/dist/SpanOrDiv.d.ts +0 -10
- package/dist/SparkFrame.d.ts +0 -14
- package/dist/SparkNetworkFrame.d.ts +0 -5
- package/dist/SparkOrdinalFrame.d.ts +0 -5
- package/dist/SparkXYFrame.d.ts +0 -5
- package/dist/VisualizationLayer.d.ts +0 -33
- package/dist/XYFrame.d.ts +0 -4
- package/dist/annotationRules/orframeRules.d.ts +0 -105
- package/dist/components/Annotation.d.ts +0 -3
- package/dist/components/AnnotationLayer/AnnotationLayer.d.ts +0 -26
- package/dist/components/Axis/Axis.d.ts +0 -7
- package/dist/components/Axis/axisTitle.d.ts +0 -10
- package/dist/components/Axis/index.d.ts +0 -2
- package/dist/components/Axis/summaryGraphic.d.ts +0 -17
- package/dist/components/Brush.d.ts +0 -12
- package/dist/components/DividedLine.d.ts +0 -16
- package/dist/components/FacetController.d.ts +0 -12
- package/dist/components/Frame.d.ts +0 -2
- package/dist/components/InteractionLayer.d.ts +0 -3
- package/dist/components/Legend.d.ts +0 -3
- package/dist/components/Mark/Mark.d.ts +0 -3
- package/dist/components/Mark/Mark.types.d.ts +0 -10
- package/dist/components/Mark/markBehavior/drawing.d.ts +0 -13
- package/dist/components/MiniMap.d.ts +0 -14
- package/dist/components/MinimapXYFrame.d.ts +0 -10
- package/dist/components/NetworkFrame.d.ts +0 -4
- package/dist/components/OrdinalFrame.d.ts +0 -4
- package/dist/components/ResponsiveFrame.d.ts +0 -22
- package/dist/components/ResponsiveMinimapXYFrame.d.ts +0 -6
- package/dist/components/ResponsiveNetworkFrame.d.ts +0 -6
- package/dist/components/ResponsiveOrdinalFrame.d.ts +0 -6
- package/dist/components/ResponsiveXYFrame.d.ts +0 -6
- package/dist/components/SpanOrDiv.d.ts +0 -10
- package/dist/components/SparkFrame.d.ts +0 -14
- package/dist/components/SparkNetworkFrame.d.ts +0 -5
- package/dist/components/SparkOrdinalFrame.d.ts +0 -5
- package/dist/components/SparkXYFrame.d.ts +0 -5
- package/dist/components/TooltipPositioner/index.d.ts +0 -7
- package/dist/components/VisualizationLayer.d.ts +0 -33
- package/dist/components/XYFrame.d.ts +0 -4
- package/dist/components/annotationLayerBehavior/annotationHandling.d.ts +0 -19
- package/dist/components/annotationLayerBehavior/d3labeler.d.ts +0 -9
- package/dist/components/annotationRules/baseRules.d.ts +0 -25
- package/dist/components/annotationRules/networkframeRules.d.ts +0 -48
- package/dist/components/annotationRules/orframeRules.d.ts +0 -105
- package/dist/components/annotationRules/xyframeRules.d.ts +0 -117
- package/dist/components/batchWork.d.ts +0 -6
- package/dist/components/constants/coordinateNames.d.ts +0 -8
- package/dist/components/constants/frame_props.d.ts +0 -4
- package/dist/components/constants/jsx.d.ts +0 -19
- package/dist/components/data/dataFunctions.d.ts +0 -46
- package/dist/components/data/multiAccessorUtils.d.ts +0 -1
- package/dist/components/data/unflowedFunctions.d.ts +0 -1
- package/dist/components/generic_utilities/functions.d.ts +0 -1
- package/dist/components/index.d.ts +0 -125
- package/dist/components/interactionLayerBehavior/InteractionCanvas.d.ts +0 -20
- package/dist/components/processing/InteractionItems.d.ts +0 -12
- package/dist/components/processing/network.d.ts +0 -114
- package/dist/components/processing/ordinal.d.ts +0 -102
- package/dist/components/processing/xyDrawing.d.ts +0 -135
- package/dist/components/semiotic.d.ts +0 -35
- package/dist/components/store/TooltipStore.d.ts +0 -2
- package/dist/components/store/createStore.d.ts +0 -1
- package/dist/components/svg/SvgHelper.d.ts +0 -37
- package/dist/components/svg/areaDrawing.d.ts +0 -31
- package/dist/components/svg/ckmeans.d.ts +0 -69
- package/dist/components/svg/frameFunctions.d.ts +0 -119
- package/dist/components/svg/lineDrawing.d.ts +0 -99
- package/dist/components/svg/networkDrawing.d.ts +0 -134
- package/dist/components/svg/pieceDrawing.d.ts +0 -13
- package/dist/components/svg/pieceLayouts.d.ts +0 -71
- package/dist/components/svg/summaryLayouts.d.ts +0 -74
- package/dist/components/types/annotationTypes.d.ts +0 -140
- package/dist/components/types/canvasTypes.d.ts +0 -9
- package/dist/components/types/generalTypes.d.ts +0 -236
- package/dist/components/types/interactionTypes.d.ts +0 -74
- package/dist/components/types/legendTypes.d.ts +0 -20
- package/dist/components/types/networkTypes.d.ts +0 -165
- package/dist/components/types/ordinalTypes.d.ts +0 -103
- package/dist/components/types/xyTypes.d.ts +0 -118
- package/dist/components/useBoundingRect.d.ts +0 -2
- package/dist/components/useDerivedStateFromProps.d.ts +0 -1
- package/dist/components/useLegacyUnmountCallback.d.ts +0 -1
- package/dist/components/visualizationLayerBehavior/axis.d.ts +0 -38
- package/dist/components/visualizationLayerBehavior/general.d.ts +0 -84
- package/dist/constants/jsx.d.ts +0 -19
- package/dist/interactionLayerBehavior/InteractionCanvas.d.ts +0 -20
- package/dist/processing/network.d.ts +0 -114
- package/dist/processing/ordinal.d.ts +0 -102
- package/dist/processing/xyDrawing.d.ts +0 -135
- package/dist/setupTests.d.ts +0 -1
- package/dist/svg/SvgHelper.d.ts +0 -37
- package/dist/svg/ckmeans.d.ts +0 -69
- package/dist/svg/frameFunctions.d.ts +0 -119
- package/dist/svg/networkDrawing.d.ts +0 -134
- package/dist/svg/pieceDrawing.d.ts +0 -13
- package/dist/svg/pieceLayouts.d.ts +0 -71
- package/dist/svg/summaryLayouts.d.ts +0 -74
- package/dist/useDerivedStateFromProps.d.ts +0 -1
- package/dist/useLegacyUnmountCallback.d.ts +0 -1
|
@@ -0,0 +1,142 @@
|
|
|
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.ChordDiagram = ChordDiagram;
|
|
41
|
+
const React = __importStar(require("react"));
|
|
42
|
+
const react_1 = require("react");
|
|
43
|
+
const StreamNetworkFrame_1 = __importDefault(require("../../stream/StreamNetworkFrame"));
|
|
44
|
+
const colorUtils_1 = require("../shared/colorUtils");
|
|
45
|
+
const Tooltip_1 = require("../../Tooltip/Tooltip");
|
|
46
|
+
const hooks_1 = require("../shared/hooks");
|
|
47
|
+
const ChartError_1 = __importDefault(require("../shared/ChartError"));
|
|
48
|
+
const validateChartData_1 = require("../shared/validateChartData");
|
|
49
|
+
/**
|
|
50
|
+
* ChordDiagram - Visualize directed relationships with circular chord layout
|
|
51
|
+
*
|
|
52
|
+
* Wraps StreamNetworkFrame (canvas-first) for chord relationship visualization.
|
|
53
|
+
*/
|
|
54
|
+
function ChordDiagram(props) {
|
|
55
|
+
const { nodes, edges, width = 600, height = 600, margin = { top: 50, bottom: 50, left: 50, right: 50 }, className, title, sourceAccessor = "source", targetAccessor = "target", valueAccessor = "value", nodeIdAccessor = "id", colorBy, colorScheme = "category10", edgeColorBy = "source", padAngle = 0.01, groupWidth = 20, sortGroups, nodeLabel, showLabels = true, enableHover = true, edgeOpacity = 0.5, tooltip, frameProps = {} } = props;
|
|
56
|
+
const safeEdges = edges || [];
|
|
57
|
+
// Infer nodes from edges if not provided
|
|
58
|
+
const inferredNodes = (0, react_1.useMemo)(() => {
|
|
59
|
+
if (nodes && nodes.length > 0)
|
|
60
|
+
return nodes;
|
|
61
|
+
const nodeSet = new Set();
|
|
62
|
+
safeEdges.forEach((edge) => {
|
|
63
|
+
const sourceId = typeof sourceAccessor === "function" ? sourceAccessor(edge) : edge[sourceAccessor];
|
|
64
|
+
const targetId = typeof targetAccessor === "function" ? targetAccessor(edge) : edge[targetAccessor];
|
|
65
|
+
nodeSet.add(sourceId);
|
|
66
|
+
nodeSet.add(targetId);
|
|
67
|
+
});
|
|
68
|
+
return Array.from(nodeSet).map((id) => ({ id }));
|
|
69
|
+
}, [nodes, safeEdges, sourceAccessor, targetAccessor]);
|
|
70
|
+
const colorScale = (0, hooks_1.useColorScale)(inferredNodes, colorBy, colorScheme);
|
|
71
|
+
// Node style function — d is a RealtimeNode, user data on d.data
|
|
72
|
+
const nodeStyle = (0, react_1.useMemo)(() => {
|
|
73
|
+
return (d, i) => {
|
|
74
|
+
const baseStyle = {
|
|
75
|
+
stroke: "black",
|
|
76
|
+
strokeWidth: 1
|
|
77
|
+
};
|
|
78
|
+
if (colorBy) {
|
|
79
|
+
baseStyle.fill = (0, colorUtils_1.getColor)(d.data || d, colorBy, colorScale);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
const palette = Array.isArray(colorScheme) ? colorScheme : (colorUtils_1.COLOR_SCHEMES[colorScheme] || colorUtils_1.DEFAULT_COLORS);
|
|
83
|
+
const colors = Array.isArray(palette) ? palette : colorUtils_1.DEFAULT_COLORS;
|
|
84
|
+
const index = d.index ?? i ?? 0;
|
|
85
|
+
baseStyle.fill = colors[index % colors.length];
|
|
86
|
+
}
|
|
87
|
+
return baseStyle;
|
|
88
|
+
};
|
|
89
|
+
}, [colorBy, colorScale, colorScheme]);
|
|
90
|
+
// Edge style function — d is a RealtimeEdge
|
|
91
|
+
const edgeStyle = (0, react_1.useMemo)(() => {
|
|
92
|
+
return (d) => {
|
|
93
|
+
const baseStyle = {
|
|
94
|
+
stroke: "black",
|
|
95
|
+
strokeWidth: 0.5,
|
|
96
|
+
fillOpacity: edgeOpacity,
|
|
97
|
+
strokeOpacity: edgeOpacity
|
|
98
|
+
};
|
|
99
|
+
if (typeof edgeColorBy === "function") {
|
|
100
|
+
baseStyle.fill = edgeColorBy(d);
|
|
101
|
+
}
|
|
102
|
+
else if (edgeColorBy === "source") {
|
|
103
|
+
const src = typeof d.source === "object" ? d.source : null;
|
|
104
|
+
if (colorBy && src) {
|
|
105
|
+
baseStyle.fill = (0, colorUtils_1.getColor)(src.data || src, colorBy, colorScale);
|
|
106
|
+
}
|
|
107
|
+
else if (src) {
|
|
108
|
+
baseStyle.fill = nodeStyle(src, src.index).fill;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else if (edgeColorBy === "target") {
|
|
112
|
+
const tgt = typeof d.target === "object" ? d.target : null;
|
|
113
|
+
if (colorBy && tgt) {
|
|
114
|
+
baseStyle.fill = (0, colorUtils_1.getColor)(tgt.data || tgt, colorBy, colorScale);
|
|
115
|
+
}
|
|
116
|
+
else if (tgt) {
|
|
117
|
+
baseStyle.fill = nodeStyle(tgt, tgt.index).fill;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return baseStyle;
|
|
121
|
+
};
|
|
122
|
+
}, [edgeColorBy, colorBy, colorScale, nodeStyle, edgeOpacity]);
|
|
123
|
+
// Node label accessor
|
|
124
|
+
const nodeLabelFn = (0, react_1.useMemo)(() => {
|
|
125
|
+
if (!showLabels)
|
|
126
|
+
return undefined;
|
|
127
|
+
const accessor = nodeLabel || nodeIdAccessor;
|
|
128
|
+
if (typeof accessor === "function")
|
|
129
|
+
return accessor;
|
|
130
|
+
return (d) => d[accessor];
|
|
131
|
+
}, [showLabels, nodeLabel, nodeIdAccessor]);
|
|
132
|
+
// Validate
|
|
133
|
+
const error = (0, validateChartData_1.validateNetworkData)({
|
|
134
|
+
componentName: "ChordDiagram",
|
|
135
|
+
edges,
|
|
136
|
+
edgesRequired: true,
|
|
137
|
+
});
|
|
138
|
+
if (error)
|
|
139
|
+
return React.createElement(ChartError_1.default, { componentName: "ChordDiagram", message: error, width: width, height: height });
|
|
140
|
+
return (React.createElement(StreamNetworkFrame_1.default, { chartType: "chord", nodes: inferredNodes, edges: safeEdges, size: [width, height], margin: margin, nodeIDAccessor: nodeIdAccessor, sourceAccessor: sourceAccessor, targetAccessor: targetAccessor, valueAccessor: valueAccessor, padAngle: padAngle, groupWidth: groupWidth, sortGroups: sortGroups, nodeStyle: nodeStyle, edgeStyle: edgeStyle, colorBy: colorBy, colorScheme: colorScheme, edgeColorBy: edgeColorBy, edgeOpacity: edgeOpacity, nodeLabel: nodeLabelFn, showLabels: showLabels, enableHover: enableHover, tooltipContent: tooltip ? (d) => (0, Tooltip_1.normalizeTooltip)(tooltip)(d.data) : undefined, className: className, title: title, ...frameProps }));
|
|
141
|
+
}
|
|
142
|
+
ChordDiagram.displayName = "ChordDiagram";
|
|
@@ -0,0 +1,108 @@
|
|
|
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.CirclePack = CirclePack;
|
|
41
|
+
const React = __importStar(require("react"));
|
|
42
|
+
const react_1 = require("react");
|
|
43
|
+
const StreamNetworkFrame_1 = __importDefault(require("../../stream/StreamNetworkFrame"));
|
|
44
|
+
const colorUtils_1 = require("../shared/colorUtils");
|
|
45
|
+
const Tooltip_1 = require("../../Tooltip/Tooltip");
|
|
46
|
+
const hooks_1 = require("../shared/hooks");
|
|
47
|
+
const ChartError_1 = __importDefault(require("../shared/ChartError"));
|
|
48
|
+
const validateChartData_1 = require("../shared/validateChartData");
|
|
49
|
+
/**
|
|
50
|
+
* CirclePack - Visualize hierarchical data as nested circles.
|
|
51
|
+
*
|
|
52
|
+
* Wraps StreamNetworkFrame (canvas-first) for circle-pack visualization.
|
|
53
|
+
*/
|
|
54
|
+
function CirclePack(props) {
|
|
55
|
+
const { data, width = 600, height = 600, margin = { top: 10, bottom: 10, left: 10, right: 10 }, className, title, childrenAccessor = "children", valueAccessor = "value", nodeIdAccessor = "name", colorBy, colorScheme = "category10", colorByDepth = false, showLabels = true, nodeLabel, circleOpacity = 0.7, padding: paddingProp = 4, enableHover = true, tooltip, frameProps = {} } = props;
|
|
56
|
+
const allNodes = (0, react_1.useMemo)(() => {
|
|
57
|
+
if (!data)
|
|
58
|
+
return [];
|
|
59
|
+
const nodes = [];
|
|
60
|
+
const traverse = (node) => {
|
|
61
|
+
nodes.push(node);
|
|
62
|
+
const children = typeof childrenAccessor === "function" ? childrenAccessor(node) : node[childrenAccessor];
|
|
63
|
+
if (children && Array.isArray(children))
|
|
64
|
+
children.forEach(traverse);
|
|
65
|
+
};
|
|
66
|
+
traverse(data);
|
|
67
|
+
return nodes;
|
|
68
|
+
}, [data, childrenAccessor]);
|
|
69
|
+
const colorScale = (0, react_1.useMemo)(() => {
|
|
70
|
+
if (colorByDepth)
|
|
71
|
+
return undefined;
|
|
72
|
+
if (!colorBy || typeof colorBy === "function")
|
|
73
|
+
return undefined;
|
|
74
|
+
return (0, colorUtils_1.createColorScale)(allNodes, colorBy, colorScheme);
|
|
75
|
+
}, [allNodes, colorBy, colorByDepth, colorScheme]);
|
|
76
|
+
const nodeStyleFn = (0, react_1.useMemo)(() => {
|
|
77
|
+
const DEPTH_PASTELS = ["#f0f0f0", "#b5d4ea", "#f4c2a1", "#b8dab2", "#d4b5e0", "#f9e0a2", "#a8d8d8"];
|
|
78
|
+
return (d) => {
|
|
79
|
+
const baseStyle = {
|
|
80
|
+
stroke: "currentColor",
|
|
81
|
+
strokeWidth: 1,
|
|
82
|
+
strokeOpacity: 0.3,
|
|
83
|
+
fillOpacity: circleOpacity
|
|
84
|
+
};
|
|
85
|
+
if (colorByDepth) {
|
|
86
|
+
baseStyle.fill = DEPTH_PASTELS[(d.depth || 0) % DEPTH_PASTELS.length];
|
|
87
|
+
}
|
|
88
|
+
else if (colorBy) {
|
|
89
|
+
baseStyle.fill = (0, colorUtils_1.getColor)(d.data || d, colorBy, colorScale);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
baseStyle.fill = hooks_1.DEFAULT_COLOR;
|
|
93
|
+
}
|
|
94
|
+
return baseStyle;
|
|
95
|
+
};
|
|
96
|
+
}, [colorBy, colorByDepth, colorScale, circleOpacity]);
|
|
97
|
+
const hierarchySumFn = (0, react_1.useMemo)(() => {
|
|
98
|
+
if (typeof valueAccessor === "function")
|
|
99
|
+
return valueAccessor;
|
|
100
|
+
return (d) => d[valueAccessor] || 1;
|
|
101
|
+
}, [valueAccessor]);
|
|
102
|
+
// Validate
|
|
103
|
+
const error = (0, validateChartData_1.validateObjectData)({ componentName: "CirclePack", data });
|
|
104
|
+
if (error)
|
|
105
|
+
return React.createElement(ChartError_1.default, { componentName: "CirclePack", message: error, width: width, height: height });
|
|
106
|
+
return (React.createElement(StreamNetworkFrame_1.default, { chartType: "circlepack", data: data, size: [width, height], margin: margin, nodeIDAccessor: nodeIdAccessor, childrenAccessor: childrenAccessor, hierarchySum: hierarchySumFn, padding: paddingProp, nodeStyle: nodeStyleFn, colorBy: colorBy, colorScheme: colorScheme, colorByDepth: colorByDepth, nodeLabel: showLabels ? (nodeLabel || nodeIdAccessor) : undefined, showLabels: showLabels, enableHover: enableHover, tooltipContent: tooltip ? (d) => (0, Tooltip_1.normalizeTooltip)(tooltip)(d.data) : undefined, className: className, title: title, ...frameProps }));
|
|
107
|
+
}
|
|
108
|
+
CirclePack.displayName = "CirclePack";
|
|
@@ -0,0 +1,121 @@
|
|
|
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.ForceDirectedGraph = ForceDirectedGraph;
|
|
41
|
+
const React = __importStar(require("react"));
|
|
42
|
+
const react_1 = require("react");
|
|
43
|
+
const StreamNetworkFrame_1 = __importDefault(require("../../stream/StreamNetworkFrame"));
|
|
44
|
+
const colorUtils_1 = require("../shared/colorUtils");
|
|
45
|
+
const legendUtils_1 = require("../shared/legendUtils");
|
|
46
|
+
const Tooltip_1 = require("../../Tooltip/Tooltip");
|
|
47
|
+
const hooks_1 = require("../shared/hooks");
|
|
48
|
+
const ChartError_1 = __importDefault(require("../shared/ChartError"));
|
|
49
|
+
const validateChartData_1 = require("../shared/validateChartData");
|
|
50
|
+
/**
|
|
51
|
+
* ForceDirectedGraph - Visualize network relationships with force-directed layout
|
|
52
|
+
*
|
|
53
|
+
* Wraps StreamNetworkFrame (canvas-first) for force-directed network visualization.
|
|
54
|
+
*/
|
|
55
|
+
function ForceDirectedGraph(props) {
|
|
56
|
+
const { nodes, edges, width = 600, height = 600, margin: userMargin, className, title, nodeIDAccessor = "id", sourceAccessor = "source", targetAccessor = "target", nodeLabel, colorBy, colorScheme = "category10", nodeSize = 8, nodeSizeRange = [5, 20], edgeWidth = 1, edgeColor = "#999", edgeOpacity = 0.6, iterations = 300, forceStrength = 0.1, showLabels = false, enableHover = true, showLegend, tooltip, frameProps = {} } = props;
|
|
57
|
+
const safeNodes = nodes || [];
|
|
58
|
+
const safeEdges = edges || [];
|
|
59
|
+
const colorScale = (0, hooks_1.useColorScale)(safeNodes, colorBy, colorScheme);
|
|
60
|
+
// Node style function — d is a RealtimeNode, user data on d.data
|
|
61
|
+
const nodeStyle = (0, react_1.useMemo)(() => {
|
|
62
|
+
return (d) => {
|
|
63
|
+
const baseStyle = {};
|
|
64
|
+
if (colorBy) {
|
|
65
|
+
baseStyle.fill = (0, colorUtils_1.getColor)(d.data || d, colorBy, colorScale);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
baseStyle.fill = hooks_1.DEFAULT_COLOR;
|
|
69
|
+
}
|
|
70
|
+
if (typeof nodeSize === "number") {
|
|
71
|
+
baseStyle.r = nodeSize;
|
|
72
|
+
}
|
|
73
|
+
return baseStyle;
|
|
74
|
+
};
|
|
75
|
+
}, [colorBy, colorScale, nodeSize]);
|
|
76
|
+
// Edge style function
|
|
77
|
+
const edgeStyle = (0, react_1.useMemo)(() => {
|
|
78
|
+
return (d) => ({
|
|
79
|
+
stroke: edgeColor,
|
|
80
|
+
strokeWidth: typeof edgeWidth === "number" ? edgeWidth : typeof edgeWidth === "function" ? edgeWidth(d) : d[edgeWidth] || 1,
|
|
81
|
+
opacity: edgeOpacity
|
|
82
|
+
});
|
|
83
|
+
}, [edgeWidth, edgeColor, edgeOpacity]);
|
|
84
|
+
// Node label function
|
|
85
|
+
const nodeLabelFn = (0, react_1.useMemo)(() => {
|
|
86
|
+
if (!showLabels || !nodeLabel)
|
|
87
|
+
return undefined;
|
|
88
|
+
if (typeof nodeLabel === "function")
|
|
89
|
+
return nodeLabel;
|
|
90
|
+
return (d) => d[nodeLabel];
|
|
91
|
+
}, [showLabels, nodeLabel]);
|
|
92
|
+
// Legend
|
|
93
|
+
const shouldShowLegend = showLegend !== undefined ? showLegend : !!colorBy;
|
|
94
|
+
const legend = (0, react_1.useMemo)(() => {
|
|
95
|
+
if (!shouldShowLegend || !colorBy)
|
|
96
|
+
return undefined;
|
|
97
|
+
return (0, legendUtils_1.createLegend)({ data: safeNodes, colorBy, colorScale, getColor: colorUtils_1.getColor });
|
|
98
|
+
}, [shouldShowLegend, colorBy, safeNodes, colorScale]);
|
|
99
|
+
// Adjust margin for legend
|
|
100
|
+
const margin = (0, react_1.useMemo)(() => {
|
|
101
|
+
const defaultMargin = { top: 20, bottom: 20, left: 20, right: 20 };
|
|
102
|
+
const finalMargin = { ...defaultMargin, ...userMargin };
|
|
103
|
+
if (legend && finalMargin.right < 120) {
|
|
104
|
+
finalMargin.right = 120;
|
|
105
|
+
}
|
|
106
|
+
return finalMargin;
|
|
107
|
+
}, [userMargin, legend]);
|
|
108
|
+
// Validate
|
|
109
|
+
const error = (0, validateChartData_1.validateNetworkData)({
|
|
110
|
+
componentName: "ForceDirectedGraph",
|
|
111
|
+
nodes,
|
|
112
|
+
edges,
|
|
113
|
+
nodesRequired: true,
|
|
114
|
+
edgesRequired: true,
|
|
115
|
+
accessors: { nodeIDAccessor },
|
|
116
|
+
});
|
|
117
|
+
if (error)
|
|
118
|
+
return React.createElement(ChartError_1.default, { componentName: "ForceDirectedGraph", message: error, width: width, height: height });
|
|
119
|
+
return (React.createElement(StreamNetworkFrame_1.default, { chartType: "force", nodes: safeNodes, edges: safeEdges, size: [width, height], margin: margin, nodeIDAccessor: nodeIDAccessor, sourceAccessor: sourceAccessor, targetAccessor: targetAccessor, iterations: iterations, forceStrength: forceStrength, nodeStyle: nodeStyle, edgeStyle: edgeStyle, colorBy: colorBy, colorScheme: colorScheme, nodeSize: nodeSize, nodeSizeRange: nodeSizeRange, nodeLabel: nodeLabelFn, showLabels: showLabels, enableHover: enableHover, tooltipContent: tooltip ? (d) => (0, Tooltip_1.normalizeTooltip)(tooltip)(d.data) : undefined, legend: legend, className: className, title: title, ...frameProps }));
|
|
120
|
+
}
|
|
121
|
+
ForceDirectedGraph.displayName = "ForceDirectedGraph";
|
|
@@ -0,0 +1,155 @@
|
|
|
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.SankeyDiagram = SankeyDiagram;
|
|
41
|
+
const React = __importStar(require("react"));
|
|
42
|
+
const react_1 = require("react");
|
|
43
|
+
const StreamNetworkFrame_1 = __importDefault(require("../../stream/StreamNetworkFrame"));
|
|
44
|
+
const colorUtils_1 = require("../shared/colorUtils");
|
|
45
|
+
const hooks_1 = require("../shared/hooks");
|
|
46
|
+
const ChartError_1 = __importDefault(require("../shared/ChartError"));
|
|
47
|
+
const validateChartData_1 = require("../shared/validateChartData");
|
|
48
|
+
/**
|
|
49
|
+
* SankeyDiagram - Visualize flow and magnitude of movement between nodes
|
|
50
|
+
*
|
|
51
|
+
* Wraps StreamNetworkFrame (canvas-first) for Sankey flow visualization.
|
|
52
|
+
*/
|
|
53
|
+
function SankeyDiagram(props) {
|
|
54
|
+
const { nodes, edges, width = 800, height = 600, margin = { top: 50, bottom: 50, left: 50, right: 50 }, className, title, sourceAccessor = "source", targetAccessor = "target", valueAccessor = "value", nodeIdAccessor = "id", colorBy, colorScheme = "category10", edgeColorBy = "source", orientation = "horizontal", nodeAlign = "justify", nodePaddingRatio = 0.05, nodeWidth = 15, nodeLabel, showLabels = true, enableHover = true, edgeOpacity = 0.5, edgeSort, tooltip, frameProps = {} } = props;
|
|
55
|
+
// Safe data defaults (hooks must always run)
|
|
56
|
+
const safeEdges = edges || [];
|
|
57
|
+
// Infer nodes from edges if not provided
|
|
58
|
+
const inferredNodes = (0, react_1.useMemo)(() => {
|
|
59
|
+
if (nodes && nodes.length > 0)
|
|
60
|
+
return nodes;
|
|
61
|
+
const nodeSet = new Set();
|
|
62
|
+
safeEdges.forEach((edge) => {
|
|
63
|
+
const sourceId = typeof sourceAccessor === "function"
|
|
64
|
+
? sourceAccessor(edge)
|
|
65
|
+
: edge[sourceAccessor];
|
|
66
|
+
const targetId = typeof targetAccessor === "function"
|
|
67
|
+
? targetAccessor(edge)
|
|
68
|
+
: edge[targetAccessor];
|
|
69
|
+
nodeSet.add(sourceId);
|
|
70
|
+
nodeSet.add(targetId);
|
|
71
|
+
});
|
|
72
|
+
return Array.from(nodeSet).map((id) => ({ id }));
|
|
73
|
+
}, [nodes, safeEdges, sourceAccessor, targetAccessor]);
|
|
74
|
+
// Create color scale if colorBy is specified
|
|
75
|
+
const colorScale = (0, hooks_1.useColorScale)(inferredNodes, colorBy, colorScheme);
|
|
76
|
+
// Node style function
|
|
77
|
+
// d is a RealtimeNode — user data lives on d.data
|
|
78
|
+
const nodeStyle = (0, react_1.useMemo)(() => {
|
|
79
|
+
return (d) => {
|
|
80
|
+
const baseStyle = {
|
|
81
|
+
stroke: "black",
|
|
82
|
+
strokeWidth: 1
|
|
83
|
+
};
|
|
84
|
+
if (colorBy) {
|
|
85
|
+
baseStyle.fill = (0, colorUtils_1.getColor)(d.data || d, colorBy, colorScale);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
baseStyle.fill = "#4d430c";
|
|
89
|
+
}
|
|
90
|
+
return baseStyle;
|
|
91
|
+
};
|
|
92
|
+
}, [colorBy, colorScale]);
|
|
93
|
+
// Edge style function
|
|
94
|
+
// d is a RealtimeEdge — d.source/d.target are RealtimeNode objects
|
|
95
|
+
const edgeStyle = (0, react_1.useMemo)(() => {
|
|
96
|
+
return (d) => {
|
|
97
|
+
const baseStyle = {
|
|
98
|
+
stroke: "none",
|
|
99
|
+
strokeWidth: 0,
|
|
100
|
+
fillOpacity: edgeOpacity
|
|
101
|
+
};
|
|
102
|
+
if (typeof edgeColorBy === "function") {
|
|
103
|
+
baseStyle.fill = edgeColorBy(d);
|
|
104
|
+
}
|
|
105
|
+
else if (edgeColorBy === "source") {
|
|
106
|
+
const src = typeof d.source === "object" ? d.source : null;
|
|
107
|
+
if (colorBy && src) {
|
|
108
|
+
baseStyle.fill = (0, colorUtils_1.getColor)(src.data || src, colorBy, colorScale);
|
|
109
|
+
}
|
|
110
|
+
else if (src) {
|
|
111
|
+
baseStyle.fill = nodeStyle(src).fill;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else if (edgeColorBy === "target") {
|
|
115
|
+
const tgt = typeof d.target === "object" ? d.target : null;
|
|
116
|
+
if (colorBy && tgt) {
|
|
117
|
+
baseStyle.fill = (0, colorUtils_1.getColor)(tgt.data || tgt, colorBy, colorScale);
|
|
118
|
+
}
|
|
119
|
+
else if (tgt) {
|
|
120
|
+
baseStyle.fill = nodeStyle(tgt).fill;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else if (edgeColorBy === "gradient") {
|
|
124
|
+
baseStyle.fill = "#999";
|
|
125
|
+
baseStyle.fillOpacity = edgeOpacity * 0.7;
|
|
126
|
+
}
|
|
127
|
+
return baseStyle;
|
|
128
|
+
};
|
|
129
|
+
}, [edgeColorBy, colorBy, colorScale, nodeStyle, edgeOpacity]);
|
|
130
|
+
// Node label accessor
|
|
131
|
+
const nodeLabelFn = (0, react_1.useMemo)(() => {
|
|
132
|
+
if (!showLabels)
|
|
133
|
+
return undefined;
|
|
134
|
+
const accessor = nodeLabel || nodeIdAccessor;
|
|
135
|
+
if (typeof accessor === "function")
|
|
136
|
+
return accessor;
|
|
137
|
+
return (d) => d[accessor];
|
|
138
|
+
}, [showLabels, nodeLabel, nodeIdAccessor]);
|
|
139
|
+
// Tooltip
|
|
140
|
+
const tooltipFn = (0, react_1.useMemo)(() => {
|
|
141
|
+
if (typeof tooltip === "function")
|
|
142
|
+
return tooltip;
|
|
143
|
+
return undefined;
|
|
144
|
+
}, [tooltip]);
|
|
145
|
+
// Validate data (after all hooks)
|
|
146
|
+
const error = (0, validateChartData_1.validateNetworkData)({
|
|
147
|
+
componentName: "SankeyDiagram",
|
|
148
|
+
edges,
|
|
149
|
+
edgesRequired: true,
|
|
150
|
+
});
|
|
151
|
+
if (error)
|
|
152
|
+
return React.createElement(ChartError_1.default, { componentName: "SankeyDiagram", message: error, width: width, height: height });
|
|
153
|
+
return (React.createElement(StreamNetworkFrame_1.default, { chartType: "sankey", nodes: inferredNodes, edges: safeEdges, size: [width, height], margin: margin, nodeIDAccessor: nodeIdAccessor, sourceAccessor: sourceAccessor, targetAccessor: targetAccessor, valueAccessor: valueAccessor, orientation: orientation, nodeAlign: nodeAlign, nodePaddingRatio: nodePaddingRatio, nodeWidth: nodeWidth, nodeStyle: nodeStyle, edgeStyle: edgeStyle, colorBy: colorBy, colorScheme: colorScheme, edgeColorBy: edgeColorBy, edgeOpacity: edgeOpacity, edgeSort: edgeSort, nodeLabel: nodeLabelFn, showLabels: showLabels, enableHover: enableHover, tooltipContent: tooltipFn ? (d) => tooltipFn(d.data) : undefined, className: className, title: title, ...frameProps }));
|
|
154
|
+
}
|
|
155
|
+
SankeyDiagram.displayName = "SankeyDiagram";
|
|
@@ -0,0 +1,110 @@
|
|
|
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.TreeDiagram = TreeDiagram;
|
|
41
|
+
const React = __importStar(require("react"));
|
|
42
|
+
const react_1 = require("react");
|
|
43
|
+
const StreamNetworkFrame_1 = __importDefault(require("../../stream/StreamNetworkFrame"));
|
|
44
|
+
const colorUtils_1 = require("../shared/colorUtils");
|
|
45
|
+
const Tooltip_1 = require("../../Tooltip/Tooltip");
|
|
46
|
+
const hooks_1 = require("../shared/hooks");
|
|
47
|
+
const ChartError_1 = __importDefault(require("../shared/ChartError"));
|
|
48
|
+
const validateChartData_1 = require("../shared/validateChartData");
|
|
49
|
+
/**
|
|
50
|
+
* TreeDiagram - Visualize hierarchical data structures
|
|
51
|
+
*
|
|
52
|
+
* Wraps StreamNetworkFrame (canvas-first) for hierarchical tree visualization.
|
|
53
|
+
*/
|
|
54
|
+
function TreeDiagram(props) {
|
|
55
|
+
const { data, width = 600, height = 600, margin = { top: 50, bottom: 50, left: 50, right: 50 }, className, title, layout = "tree", orientation = "vertical", childrenAccessor = "children", valueAccessor = "value", nodeIdAccessor = "name", colorBy, colorScheme = "category10", colorByDepth = false, edgeStyle = "curve", nodeLabel, showLabels = true, nodeSize = 5, enableHover = true, tooltip, frameProps = {} } = props;
|
|
56
|
+
// Node style function
|
|
57
|
+
const allNodes = (0, react_1.useMemo)(() => {
|
|
58
|
+
if (!data)
|
|
59
|
+
return [];
|
|
60
|
+
const nodes = [];
|
|
61
|
+
const traverse = (node) => {
|
|
62
|
+
nodes.push(node);
|
|
63
|
+
const children = typeof childrenAccessor === "function" ? childrenAccessor(node) : node[childrenAccessor];
|
|
64
|
+
if (children && Array.isArray(children))
|
|
65
|
+
children.forEach(traverse);
|
|
66
|
+
};
|
|
67
|
+
traverse(data);
|
|
68
|
+
return nodes;
|
|
69
|
+
}, [data, childrenAccessor]);
|
|
70
|
+
const colorScale = (0, react_1.useMemo)(() => {
|
|
71
|
+
if (colorByDepth)
|
|
72
|
+
return (0, colorUtils_1.createColorScale)(allNodes.map((_, idx) => ({ depth: idx % 5 })), "depth", colorScheme);
|
|
73
|
+
if (!colorBy || typeof colorBy === "function")
|
|
74
|
+
return undefined;
|
|
75
|
+
return (0, colorUtils_1.createColorScale)(allNodes, colorBy, colorScheme);
|
|
76
|
+
}, [allNodes, colorBy, colorByDepth, colorScheme]);
|
|
77
|
+
// d is a RealtimeNode — user data on d.data, depth on d.depth
|
|
78
|
+
const nodeStyleFn = (0, react_1.useMemo)(() => {
|
|
79
|
+
return (d) => {
|
|
80
|
+
const baseStyle = { stroke: "black", strokeWidth: 1 };
|
|
81
|
+
if (colorByDepth) {
|
|
82
|
+
baseStyle.fill = (0, colorUtils_1.getColor)({ depth: d.depth || 0 }, "depth", colorScale);
|
|
83
|
+
}
|
|
84
|
+
else if (colorBy) {
|
|
85
|
+
baseStyle.fill = (0, colorUtils_1.getColor)(d.data || d, colorBy, colorScale);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
baseStyle.fill = hooks_1.DEFAULT_COLOR;
|
|
89
|
+
}
|
|
90
|
+
return baseStyle;
|
|
91
|
+
};
|
|
92
|
+
}, [colorBy, colorByDepth, colorScale]);
|
|
93
|
+
const edgeStyleFn = (0, react_1.useMemo)(() => {
|
|
94
|
+
return () => ({ stroke: "#999", strokeWidth: 1, fill: "none" });
|
|
95
|
+
}, []);
|
|
96
|
+
const hierarchySumFn = (0, react_1.useMemo)(() => {
|
|
97
|
+
if (layout === "treemap" || layout === "circlepack" || layout === "partition") {
|
|
98
|
+
if (typeof valueAccessor === "function")
|
|
99
|
+
return valueAccessor;
|
|
100
|
+
return (d) => d[valueAccessor] || 1;
|
|
101
|
+
}
|
|
102
|
+
return undefined;
|
|
103
|
+
}, [layout, valueAccessor]);
|
|
104
|
+
// Validate
|
|
105
|
+
const error = (0, validateChartData_1.validateObjectData)({ componentName: "TreeDiagram", data });
|
|
106
|
+
if (error)
|
|
107
|
+
return React.createElement(ChartError_1.default, { componentName: "TreeDiagram", message: error, width: width, height: height });
|
|
108
|
+
return (React.createElement(StreamNetworkFrame_1.default, { chartType: layout, data: data, size: [width, height], margin: margin, nodeIDAccessor: nodeIdAccessor, childrenAccessor: childrenAccessor, hierarchySum: hierarchySumFn, treeOrientation: orientation, edgeType: edgeStyle, nodeStyle: nodeStyleFn, edgeStyle: edgeStyleFn, colorBy: colorBy, colorScheme: colorScheme, colorByDepth: colorByDepth, nodeSize: nodeSize, nodeLabel: showLabels ? (nodeLabel || nodeIdAccessor) : undefined, showLabels: showLabels, enableHover: enableHover, tooltipContent: tooltip ? (d) => (0, Tooltip_1.normalizeTooltip)(tooltip)(d.data) : undefined, className: className, title: title, ...frameProps }));
|
|
109
|
+
}
|
|
110
|
+
TreeDiagram.displayName = "TreeDiagram";
|