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,568 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hierarchyLayoutPlugin = void 0;
|
|
4
|
+
const d3_hierarchy_1 = require("d3-hierarchy");
|
|
5
|
+
/**
|
|
6
|
+
* Hierarchy layout plugin — handles tree, cluster, treemap, circlepack, and partition layouts.
|
|
7
|
+
*
|
|
8
|
+
* Uses d3-hierarchy for all layout computations. This plugin is `hierarchical: true`,
|
|
9
|
+
* meaning the input data is a single root node object rather than flat nodes+edges arrays.
|
|
10
|
+
*
|
|
11
|
+
* The hierarchy root is passed via `(config as any).__hierarchyRoot`, set by the store
|
|
12
|
+
* before calling computeLayout. The plugin builds the d3 hierarchy internally, runs the
|
|
13
|
+
* appropriate layout algorithm, and populates the nodes/edges arrays.
|
|
14
|
+
*
|
|
15
|
+
* Scene output varies by layout type:
|
|
16
|
+
* - tree/cluster: NetworkCircleNode[] + NetworkCurvedEdge[] (cubic bezier parent-child links)
|
|
17
|
+
* - treemap/partition: NetworkRectNode[] (space-filling rectangles, no edges)
|
|
18
|
+
* - circlepack: NetworkCircleNode[] (nested circles, no edges)
|
|
19
|
+
*/
|
|
20
|
+
exports.hierarchyLayoutPlugin = {
|
|
21
|
+
supportsStreaming: false,
|
|
22
|
+
hierarchical: true,
|
|
23
|
+
computeLayout(nodes, edges, config, size) {
|
|
24
|
+
const hierarchyRoot = config.__hierarchyRoot;
|
|
25
|
+
if (!hierarchyRoot)
|
|
26
|
+
return;
|
|
27
|
+
const layoutType = config.chartType;
|
|
28
|
+
const childrenAccessor = resolveChildrenAccessor(config.childrenAccessor);
|
|
29
|
+
const hierarchySum = config.hierarchySum || ((d) => d.value ?? 0);
|
|
30
|
+
// Build d3 hierarchy from the root data
|
|
31
|
+
const root = (0, d3_hierarchy_1.hierarchy)(hierarchyRoot, childrenAccessor);
|
|
32
|
+
root.sum(hierarchySum);
|
|
33
|
+
root.sort((a, b) => (b.value ?? 0) - (a.value ?? 0));
|
|
34
|
+
const [width, height] = size;
|
|
35
|
+
// Run the appropriate layout algorithm
|
|
36
|
+
switch (layoutType) {
|
|
37
|
+
case "tree":
|
|
38
|
+
computeTreeLayout(root, config, width, height);
|
|
39
|
+
break;
|
|
40
|
+
case "cluster":
|
|
41
|
+
computeClusterLayout(root, config, width, height);
|
|
42
|
+
break;
|
|
43
|
+
case "treemap":
|
|
44
|
+
computeTreemapLayout(root, config, width, height);
|
|
45
|
+
break;
|
|
46
|
+
case "circlepack":
|
|
47
|
+
computeCirclepackLayout(root, config, width, height);
|
|
48
|
+
break;
|
|
49
|
+
case "partition":
|
|
50
|
+
computePartitionLayout(root, config, width, height);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
// Flatten the hierarchy into nodes and edges arrays
|
|
54
|
+
const descendants = root.descendants();
|
|
55
|
+
// Clear and repopulate nodes array
|
|
56
|
+
nodes.length = 0;
|
|
57
|
+
edges.length = 0;
|
|
58
|
+
const nodeMap = new Map();
|
|
59
|
+
for (let i = 0; i < descendants.length; i++) {
|
|
60
|
+
const d = descendants[i];
|
|
61
|
+
const id = resolveNodeId(d, config, i);
|
|
62
|
+
const node = {
|
|
63
|
+
id,
|
|
64
|
+
x: 0,
|
|
65
|
+
y: 0,
|
|
66
|
+
x0: 0,
|
|
67
|
+
x1: 0,
|
|
68
|
+
y0: 0,
|
|
69
|
+
y1: 0,
|
|
70
|
+
width: 0,
|
|
71
|
+
height: 0,
|
|
72
|
+
value: d.value ?? 0,
|
|
73
|
+
depth: d.depth,
|
|
74
|
+
data: d.data,
|
|
75
|
+
createdByFrame: true
|
|
76
|
+
};
|
|
77
|
+
// Set positions based on layout type
|
|
78
|
+
if (layoutType === "tree" || layoutType === "cluster") {
|
|
79
|
+
setTreePositions(node, d, config);
|
|
80
|
+
}
|
|
81
|
+
else if (layoutType === "treemap" || layoutType === "partition") {
|
|
82
|
+
setRectPositions(node, d);
|
|
83
|
+
}
|
|
84
|
+
else if (layoutType === "circlepack") {
|
|
85
|
+
setCirclePositions(node, d);
|
|
86
|
+
}
|
|
87
|
+
// Store the d3 hierarchy node reference for edge building
|
|
88
|
+
;
|
|
89
|
+
node.__hierarchyNode = d;
|
|
90
|
+
nodes.push(node);
|
|
91
|
+
nodeMap.set(d, node);
|
|
92
|
+
}
|
|
93
|
+
// Build parent-child edges (for tree/cluster; treemap/circlepack/partition have no edges)
|
|
94
|
+
if (layoutType === "tree" || layoutType === "cluster") {
|
|
95
|
+
for (const d of descendants) {
|
|
96
|
+
if (d.parent) {
|
|
97
|
+
const sourceNode = nodeMap.get(d.parent);
|
|
98
|
+
const targetNode = nodeMap.get(d);
|
|
99
|
+
if (sourceNode && targetNode) {
|
|
100
|
+
edges.push({
|
|
101
|
+
source: sourceNode,
|
|
102
|
+
target: targetNode,
|
|
103
|
+
value: 1,
|
|
104
|
+
y0: 0,
|
|
105
|
+
y1: 0,
|
|
106
|
+
sankeyWidth: 0,
|
|
107
|
+
data: { depth: d.depth }
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
buildScene(nodes, edges, config, size) {
|
|
115
|
+
const layoutType = config.chartType;
|
|
116
|
+
const nodeStyleFn = config.nodeStyle || (() => ({}));
|
|
117
|
+
const edgeStyleFn = config.edgeStyle || (() => ({}));
|
|
118
|
+
switch (layoutType) {
|
|
119
|
+
case "tree":
|
|
120
|
+
case "cluster":
|
|
121
|
+
return buildTreeScene(nodes, edges, config, size, nodeStyleFn, edgeStyleFn);
|
|
122
|
+
case "treemap":
|
|
123
|
+
case "partition":
|
|
124
|
+
return buildRectScene(nodes, config, size, nodeStyleFn);
|
|
125
|
+
case "circlepack":
|
|
126
|
+
return buildCircleScene(nodes, config, size, nodeStyleFn);
|
|
127
|
+
default:
|
|
128
|
+
return { sceneNodes: [], sceneEdges: [], labels: [] };
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
// ── Layout computation functions ──────────────────────────────────────────
|
|
133
|
+
function computeTreeLayout(root, config, width, height) {
|
|
134
|
+
const orientation = config.treeOrientation || "vertical";
|
|
135
|
+
const layout = (0, d3_hierarchy_1.tree)();
|
|
136
|
+
if (orientation === "horizontal") {
|
|
137
|
+
layout.size([height, width]);
|
|
138
|
+
}
|
|
139
|
+
else if (orientation === "radial") {
|
|
140
|
+
// For radial layout, use a full circle mapped to [0, 2*PI] x [0, radius]
|
|
141
|
+
const radius = Math.min(width, height) / 2;
|
|
142
|
+
layout.size([2 * Math.PI, radius * 0.8]);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
layout.size([width, height]);
|
|
146
|
+
}
|
|
147
|
+
layout(root);
|
|
148
|
+
}
|
|
149
|
+
function computeClusterLayout(root, config, width, height) {
|
|
150
|
+
const orientation = config.treeOrientation || "vertical";
|
|
151
|
+
const layout = (0, d3_hierarchy_1.cluster)();
|
|
152
|
+
if (orientation === "horizontal") {
|
|
153
|
+
layout.size([height, width]);
|
|
154
|
+
}
|
|
155
|
+
else if (orientation === "radial") {
|
|
156
|
+
const radius = Math.min(width, height) / 2;
|
|
157
|
+
layout.size([2 * Math.PI, radius * 0.8]);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
layout.size([width, height]);
|
|
161
|
+
}
|
|
162
|
+
layout(root);
|
|
163
|
+
}
|
|
164
|
+
function computeTreemapLayout(root, config, width, height) {
|
|
165
|
+
const padding = config.padding ?? 4;
|
|
166
|
+
const paddingTop = config.paddingTop ?? 0;
|
|
167
|
+
const layout = (0, d3_hierarchy_1.treemap)()
|
|
168
|
+
.size([width, height])
|
|
169
|
+
.tile(d3_hierarchy_1.treemapBinary)
|
|
170
|
+
.padding(padding);
|
|
171
|
+
if (paddingTop > 0) {
|
|
172
|
+
layout.paddingTop(paddingTop);
|
|
173
|
+
}
|
|
174
|
+
layout(root);
|
|
175
|
+
}
|
|
176
|
+
function computeCirclepackLayout(root, config, width, height) {
|
|
177
|
+
const padding = config.padding ?? 4;
|
|
178
|
+
const layout = (0, d3_hierarchy_1.pack)()
|
|
179
|
+
.size([width, height])
|
|
180
|
+
.padding(padding);
|
|
181
|
+
layout(root);
|
|
182
|
+
}
|
|
183
|
+
function computePartitionLayout(root, config, width, height) {
|
|
184
|
+
const layout = (0, d3_hierarchy_1.partition)()
|
|
185
|
+
.size([width, height])
|
|
186
|
+
.padding(config.padding ?? 1);
|
|
187
|
+
layout(root);
|
|
188
|
+
}
|
|
189
|
+
// ── Position setting helpers ──────────────────────────────────────────────
|
|
190
|
+
function setTreePositions(node, d, config) {
|
|
191
|
+
const orientation = config.treeOrientation || "vertical";
|
|
192
|
+
if (orientation === "radial") {
|
|
193
|
+
// Convert polar coordinates to cartesian
|
|
194
|
+
const angle = d.x;
|
|
195
|
+
const radius = d.y;
|
|
196
|
+
// Compute Cartesian coordinates — the layout is already sized
|
|
197
|
+
// relative to the center of [width, height].
|
|
198
|
+
node.x = radius * Math.cos(angle - Math.PI / 2);
|
|
199
|
+
node.y = radius * Math.sin(angle - Math.PI / 2);
|
|
200
|
+
}
|
|
201
|
+
else if (orientation === "horizontal") {
|
|
202
|
+
// d3 tree with size([height, width]): d.x = vertical pos, d.y = horizontal pos
|
|
203
|
+
node.x = d.y;
|
|
204
|
+
node.y = d.x;
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
// Vertical: d.x = horizontal, d.y = vertical
|
|
208
|
+
node.x = d.x;
|
|
209
|
+
node.y = d.y;
|
|
210
|
+
}
|
|
211
|
+
// Set bounding box around the point (used by hit testing and transitions)
|
|
212
|
+
const r = 5;
|
|
213
|
+
node.x0 = node.x - r;
|
|
214
|
+
node.x1 = node.x + r;
|
|
215
|
+
node.y0 = node.y - r;
|
|
216
|
+
node.y1 = node.y + r;
|
|
217
|
+
node.width = r * 2;
|
|
218
|
+
node.height = r * 2;
|
|
219
|
+
}
|
|
220
|
+
function setRectPositions(node, d) {
|
|
221
|
+
node.x0 = d.x0;
|
|
222
|
+
node.x1 = d.x1;
|
|
223
|
+
node.y0 = d.y0;
|
|
224
|
+
node.y1 = d.y1;
|
|
225
|
+
node.x = (d.x0 + d.x1) / 2;
|
|
226
|
+
node.y = (d.y0 + d.y1) / 2;
|
|
227
|
+
node.width = d.x1 - d.x0;
|
|
228
|
+
node.height = d.y1 - d.y0;
|
|
229
|
+
}
|
|
230
|
+
function setCirclePositions(node, d) {
|
|
231
|
+
const r = d.r ?? 0;
|
|
232
|
+
node.x = d.x;
|
|
233
|
+
node.y = d.y;
|
|
234
|
+
// Set bounding box to enclosing square of the circle
|
|
235
|
+
node.x0 = d.x - r;
|
|
236
|
+
node.x1 = d.x + r;
|
|
237
|
+
node.y0 = d.y - r;
|
|
238
|
+
node.y1 = d.y + r;
|
|
239
|
+
node.width = r * 2;
|
|
240
|
+
node.height = r * 2;
|
|
241
|
+
node.__radius = r;
|
|
242
|
+
}
|
|
243
|
+
// ── Scene building functions ──────────────────────────────────────────────
|
|
244
|
+
function buildTreeScene(nodes, edges, config, size, nodeStyleFn, edgeStyleFn) {
|
|
245
|
+
const sceneNodes = [];
|
|
246
|
+
const sceneEdges = [];
|
|
247
|
+
const labels = [];
|
|
248
|
+
const orientation = config.treeOrientation || "vertical";
|
|
249
|
+
const isRadial = orientation === "radial";
|
|
250
|
+
const cx = size[0] / 2;
|
|
251
|
+
const cy = size[1] / 2;
|
|
252
|
+
const defaultNodeSize = resolveDefaultNodeSize(config.nodeSize);
|
|
253
|
+
// Build circle nodes
|
|
254
|
+
for (const node of nodes) {
|
|
255
|
+
let nx = node.x;
|
|
256
|
+
let ny = node.y;
|
|
257
|
+
// For radial layout, offset to center of chart
|
|
258
|
+
if (isRadial) {
|
|
259
|
+
nx += cx;
|
|
260
|
+
ny += cy;
|
|
261
|
+
}
|
|
262
|
+
const userStyle = nodeStyleFn(node);
|
|
263
|
+
const style = {
|
|
264
|
+
fill: userStyle.fill || "#4d430c",
|
|
265
|
+
stroke: userStyle.stroke || "#fff",
|
|
266
|
+
strokeWidth: userStyle.strokeWidth ?? 1,
|
|
267
|
+
opacity: userStyle.opacity
|
|
268
|
+
};
|
|
269
|
+
sceneNodes.push({
|
|
270
|
+
type: "circle",
|
|
271
|
+
cx: nx,
|
|
272
|
+
cy: ny,
|
|
273
|
+
r: defaultNodeSize,
|
|
274
|
+
style,
|
|
275
|
+
datum: node,
|
|
276
|
+
id: node.id,
|
|
277
|
+
label: node.id,
|
|
278
|
+
depth: node.depth
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
// Build curved edges between parent-child pairs
|
|
282
|
+
const edgeOpacity = config.edgeOpacity ?? 0.5;
|
|
283
|
+
for (const edge of edges) {
|
|
284
|
+
const sourceNode = typeof edge.source === "object" ? edge.source : null;
|
|
285
|
+
const targetNode = typeof edge.target === "object" ? edge.target : null;
|
|
286
|
+
if (!sourceNode || !targetNode)
|
|
287
|
+
continue;
|
|
288
|
+
let sx = sourceNode.x;
|
|
289
|
+
let sy = sourceNode.y;
|
|
290
|
+
let tx = targetNode.x;
|
|
291
|
+
let ty = targetNode.y;
|
|
292
|
+
if (isRadial) {
|
|
293
|
+
sx += cx;
|
|
294
|
+
sy += cy;
|
|
295
|
+
tx += cx;
|
|
296
|
+
ty += cy;
|
|
297
|
+
}
|
|
298
|
+
// Generate cubic bezier path
|
|
299
|
+
const pathD = generateTreeEdgePath(sx, sy, tx, ty, orientation);
|
|
300
|
+
const userStyle = edgeStyleFn(edge);
|
|
301
|
+
const style = {
|
|
302
|
+
fill: "none",
|
|
303
|
+
stroke: userStyle.stroke || "#999",
|
|
304
|
+
strokeWidth: userStyle.strokeWidth ?? 1.5,
|
|
305
|
+
opacity: userStyle.opacity ?? edgeOpacity
|
|
306
|
+
};
|
|
307
|
+
sceneEdges.push({
|
|
308
|
+
type: "curved",
|
|
309
|
+
pathD,
|
|
310
|
+
style,
|
|
311
|
+
datum: edge
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
// Build labels
|
|
315
|
+
if (config.showLabels !== false) {
|
|
316
|
+
const labelFn = resolveLabelFn(config.nodeLabel);
|
|
317
|
+
for (const node of nodes) {
|
|
318
|
+
const text = labelFn ? labelFn(node) : node.id;
|
|
319
|
+
if (!text)
|
|
320
|
+
continue;
|
|
321
|
+
let nx = node.x;
|
|
322
|
+
let ny = node.y;
|
|
323
|
+
if (isRadial) {
|
|
324
|
+
nx += cx;
|
|
325
|
+
ny += cy;
|
|
326
|
+
}
|
|
327
|
+
// Position label based on orientation
|
|
328
|
+
let x;
|
|
329
|
+
let y;
|
|
330
|
+
let anchor;
|
|
331
|
+
if (isRadial) {
|
|
332
|
+
// Radial: position label outward from center
|
|
333
|
+
const dx = nx - cx;
|
|
334
|
+
const dy = ny - cy;
|
|
335
|
+
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
336
|
+
if (dist > 0) {
|
|
337
|
+
x = nx + (dx / dist) * 10;
|
|
338
|
+
y = ny + (dy / dist) * 10;
|
|
339
|
+
anchor = dx >= 0 ? "start" : "end";
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
x = nx;
|
|
343
|
+
y = ny - 12;
|
|
344
|
+
anchor = "middle";
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
else if (orientation === "horizontal") {
|
|
348
|
+
// Horizontal tree: label to the right of leaf nodes, left of root
|
|
349
|
+
const isLeaf = !node.data?.children || node.data.children.length === 0;
|
|
350
|
+
if (isLeaf) {
|
|
351
|
+
x = nx + defaultNodeSize + 6;
|
|
352
|
+
anchor = "start";
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
x = nx - defaultNodeSize - 6;
|
|
356
|
+
anchor = "end";
|
|
357
|
+
}
|
|
358
|
+
y = ny;
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
// Vertical tree: label below
|
|
362
|
+
x = nx;
|
|
363
|
+
y = ny + defaultNodeSize + 14;
|
|
364
|
+
anchor = "middle";
|
|
365
|
+
}
|
|
366
|
+
labels.push({
|
|
367
|
+
x,
|
|
368
|
+
y,
|
|
369
|
+
text: String(text),
|
|
370
|
+
anchor,
|
|
371
|
+
baseline: "middle",
|
|
372
|
+
fontSize: 11
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return { sceneNodes, sceneEdges, labels };
|
|
377
|
+
}
|
|
378
|
+
function buildRectScene(nodes, config, size, nodeStyleFn) {
|
|
379
|
+
const sceneNodes = [];
|
|
380
|
+
const labels = [];
|
|
381
|
+
const depthPalette = [
|
|
382
|
+
"#e8d5b7", "#b8d4e3", "#d4e3b8", "#e3c4d4",
|
|
383
|
+
"#d4d4e3", "#e3d4b8", "#b8e3d4", "#e3b8b8"
|
|
384
|
+
];
|
|
385
|
+
for (const node of nodes) {
|
|
386
|
+
const w = node.x1 - node.x0;
|
|
387
|
+
const h = node.y1 - node.y0;
|
|
388
|
+
if (w <= 0 || h <= 0)
|
|
389
|
+
continue;
|
|
390
|
+
const userStyle = nodeStyleFn(node);
|
|
391
|
+
let fill = userStyle.fill || "#4d430c";
|
|
392
|
+
// Color by depth if enabled
|
|
393
|
+
if (config.colorByDepth && node.depth !== undefined) {
|
|
394
|
+
fill = depthPalette[node.depth % depthPalette.length];
|
|
395
|
+
}
|
|
396
|
+
const style = {
|
|
397
|
+
fill,
|
|
398
|
+
stroke: userStyle.stroke || "#fff",
|
|
399
|
+
strokeWidth: userStyle.strokeWidth ?? 1,
|
|
400
|
+
opacity: userStyle.opacity
|
|
401
|
+
};
|
|
402
|
+
sceneNodes.push({
|
|
403
|
+
type: "rect",
|
|
404
|
+
x: node.x0,
|
|
405
|
+
y: node.y0,
|
|
406
|
+
w,
|
|
407
|
+
h,
|
|
408
|
+
style,
|
|
409
|
+
datum: node,
|
|
410
|
+
id: node.id,
|
|
411
|
+
label: node.id,
|
|
412
|
+
depth: node.depth
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
// Build labels
|
|
416
|
+
if (config.showLabels !== false) {
|
|
417
|
+
const labelFn = resolveLabelFn(config.nodeLabel);
|
|
418
|
+
for (const node of nodes) {
|
|
419
|
+
const w = node.x1 - node.x0;
|
|
420
|
+
const h = node.y1 - node.y0;
|
|
421
|
+
if (w <= 0 || h <= 0)
|
|
422
|
+
continue;
|
|
423
|
+
// Only label leaf nodes by default (for treemap), or all for partition
|
|
424
|
+
const isLeaf = !(node.data?.children && node.data.children.length > 0);
|
|
425
|
+
const isPartition = config.chartType === "partition";
|
|
426
|
+
if (!isLeaf && !isPartition)
|
|
427
|
+
continue;
|
|
428
|
+
const text = labelFn ? labelFn(node) : node.id;
|
|
429
|
+
if (!text)
|
|
430
|
+
continue;
|
|
431
|
+
// Skip labels for very small cells
|
|
432
|
+
if (w < 30 || h < 16)
|
|
433
|
+
continue;
|
|
434
|
+
labels.push({
|
|
435
|
+
x: node.x0 + w / 2,
|
|
436
|
+
y: node.y0 + h / 2,
|
|
437
|
+
text: String(text),
|
|
438
|
+
anchor: "middle",
|
|
439
|
+
baseline: "middle",
|
|
440
|
+
fontSize: Math.min(11, Math.max(8, Math.min(w, h) / 6))
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return { sceneNodes, sceneEdges: [], labels };
|
|
445
|
+
}
|
|
446
|
+
function buildCircleScene(nodes, config, size, nodeStyleFn) {
|
|
447
|
+
const sceneNodes = [];
|
|
448
|
+
const labels = [];
|
|
449
|
+
const circleOpacity = 0.7;
|
|
450
|
+
const depthPalette = [
|
|
451
|
+
"#e8d5b7", "#b8d4e3", "#d4e3b8", "#e3c4d4",
|
|
452
|
+
"#d4d4e3", "#e3d4b8", "#b8e3d4", "#e3b8b8"
|
|
453
|
+
];
|
|
454
|
+
for (const node of nodes) {
|
|
455
|
+
const r = node.__radius ?? 5;
|
|
456
|
+
if (r <= 0)
|
|
457
|
+
continue;
|
|
458
|
+
const userStyle = nodeStyleFn(node);
|
|
459
|
+
let fill = userStyle.fill || "#4d430c";
|
|
460
|
+
// Color by depth if enabled
|
|
461
|
+
if (config.colorByDepth && node.depth !== undefined) {
|
|
462
|
+
fill = depthPalette[node.depth % depthPalette.length];
|
|
463
|
+
}
|
|
464
|
+
const style = {
|
|
465
|
+
fill,
|
|
466
|
+
stroke: userStyle.stroke || "#fff",
|
|
467
|
+
strokeWidth: userStyle.strokeWidth ?? 1,
|
|
468
|
+
opacity: userStyle.opacity ?? circleOpacity
|
|
469
|
+
};
|
|
470
|
+
sceneNodes.push({
|
|
471
|
+
type: "circle",
|
|
472
|
+
cx: node.x,
|
|
473
|
+
cy: node.y,
|
|
474
|
+
r,
|
|
475
|
+
style,
|
|
476
|
+
datum: node,
|
|
477
|
+
id: node.id,
|
|
478
|
+
label: node.id,
|
|
479
|
+
depth: node.depth
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
// Build labels
|
|
483
|
+
if (config.showLabels !== false) {
|
|
484
|
+
const labelFn = resolveLabelFn(config.nodeLabel);
|
|
485
|
+
for (const node of nodes) {
|
|
486
|
+
const r = node.__radius ?? 5;
|
|
487
|
+
const text = labelFn ? labelFn(node) : node.id;
|
|
488
|
+
if (!text)
|
|
489
|
+
continue;
|
|
490
|
+
// Only label nodes with sufficient radius
|
|
491
|
+
if (r < 15)
|
|
492
|
+
continue;
|
|
493
|
+
// Leaf nodes: centered label. Parent nodes: top-center label.
|
|
494
|
+
const isLeaf = !(node.data?.children && node.data.children.length > 0);
|
|
495
|
+
labels.push({
|
|
496
|
+
x: node.x,
|
|
497
|
+
y: isLeaf ? node.y : node.y - r + 14,
|
|
498
|
+
text: String(text),
|
|
499
|
+
anchor: "middle",
|
|
500
|
+
baseline: isLeaf ? "middle" : "hanging",
|
|
501
|
+
fontSize: Math.min(11, Math.max(8, r / 3)),
|
|
502
|
+
fill: isLeaf ? undefined : "#000",
|
|
503
|
+
stroke: isLeaf ? undefined : "#fff",
|
|
504
|
+
strokeWidth: isLeaf ? undefined : 3,
|
|
505
|
+
paintOrder: isLeaf ? undefined : "stroke"
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return { sceneNodes, sceneEdges: [], labels };
|
|
510
|
+
}
|
|
511
|
+
// ── Edge path generation ──────────────────────────────────────────────────
|
|
512
|
+
/**
|
|
513
|
+
* Generate a cubic bezier path string for a tree/cluster edge.
|
|
514
|
+
* Uses different curve strategies based on tree orientation.
|
|
515
|
+
*/
|
|
516
|
+
function generateTreeEdgePath(sx, sy, tx, ty, orientation) {
|
|
517
|
+
if (orientation === "horizontal") {
|
|
518
|
+
// Horizontal: parent on left, child on right
|
|
519
|
+
const midX = (sx + tx) / 2;
|
|
520
|
+
return `M ${sx},${sy} C ${midX},${sy} ${midX},${ty} ${tx},${ty}`;
|
|
521
|
+
}
|
|
522
|
+
else if (orientation === "radial") {
|
|
523
|
+
// Radial: use a simple quadratic curve through the midpoint
|
|
524
|
+
const midX = (sx + tx) / 2;
|
|
525
|
+
const midY = (sy + ty) / 2;
|
|
526
|
+
return `M ${sx},${sy} Q ${midX},${sy} ${midX},${midY} T ${tx},${ty}`;
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
// Vertical (default): parent on top, child on bottom
|
|
530
|
+
const midY = (sy + ty) / 2;
|
|
531
|
+
return `M ${sx},${sy} C ${sx},${midY} ${tx},${midY} ${tx},${ty}`;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
// ── Utility helpers ───────────────────────────────────────────────────────
|
|
535
|
+
function resolveChildrenAccessor(accessor) {
|
|
536
|
+
if (!accessor)
|
|
537
|
+
return undefined;
|
|
538
|
+
if (typeof accessor === "function")
|
|
539
|
+
return accessor;
|
|
540
|
+
return (d) => d[accessor];
|
|
541
|
+
}
|
|
542
|
+
function resolveNodeId(d, config, index) {
|
|
543
|
+
const accessor = config.nodeIDAccessor;
|
|
544
|
+
if (typeof accessor === "function") {
|
|
545
|
+
return String(accessor(d.data));
|
|
546
|
+
}
|
|
547
|
+
if (typeof accessor === "string" && d.data[accessor] !== undefined) {
|
|
548
|
+
return String(d.data[accessor]);
|
|
549
|
+
}
|
|
550
|
+
// Fallback: use name, id, or index
|
|
551
|
+
if (d.data.name !== undefined)
|
|
552
|
+
return String(d.data.name);
|
|
553
|
+
if (d.data.id !== undefined)
|
|
554
|
+
return String(d.data.id);
|
|
555
|
+
return `node-${index}`;
|
|
556
|
+
}
|
|
557
|
+
function resolveLabelFn(nodeLabel) {
|
|
558
|
+
if (!nodeLabel)
|
|
559
|
+
return null;
|
|
560
|
+
if (typeof nodeLabel === "function")
|
|
561
|
+
return nodeLabel;
|
|
562
|
+
return (d) => d.data?.[nodeLabel] || d[nodeLabel] || d.id;
|
|
563
|
+
}
|
|
564
|
+
function resolveDefaultNodeSize(nodeSize) {
|
|
565
|
+
if (typeof nodeSize === "number")
|
|
566
|
+
return nodeSize;
|
|
567
|
+
return 5;
|
|
568
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hierarchyLayoutPlugin = exports.chordLayoutPlugin = exports.forceLayoutPlugin = exports.sankeyLayoutPlugin = exports.networkLayoutRegistry = void 0;
|
|
4
|
+
exports.getLayoutPlugin = getLayoutPlugin;
|
|
5
|
+
const sankeyLayoutPlugin_1 = require("./sankeyLayoutPlugin");
|
|
6
|
+
Object.defineProperty(exports, "sankeyLayoutPlugin", { enumerable: true, get: function () { return sankeyLayoutPlugin_1.sankeyLayoutPlugin; } });
|
|
7
|
+
const forceLayoutPlugin_1 = require("./forceLayoutPlugin");
|
|
8
|
+
Object.defineProperty(exports, "forceLayoutPlugin", { enumerable: true, get: function () { return forceLayoutPlugin_1.forceLayoutPlugin; } });
|
|
9
|
+
const chordLayoutPlugin_1 = require("./chordLayoutPlugin");
|
|
10
|
+
Object.defineProperty(exports, "chordLayoutPlugin", { enumerable: true, get: function () { return chordLayoutPlugin_1.chordLayoutPlugin; } });
|
|
11
|
+
const hierarchyLayoutPlugin_1 = require("./hierarchyLayoutPlugin");
|
|
12
|
+
Object.defineProperty(exports, "hierarchyLayoutPlugin", { enumerable: true, get: function () { return hierarchyLayoutPlugin_1.hierarchyLayoutPlugin; } });
|
|
13
|
+
/**
|
|
14
|
+
* Registry mapping network chart types to their layout plugins.
|
|
15
|
+
*/
|
|
16
|
+
exports.networkLayoutRegistry = {
|
|
17
|
+
sankey: sankeyLayoutPlugin_1.sankeyLayoutPlugin,
|
|
18
|
+
force: forceLayoutPlugin_1.forceLayoutPlugin,
|
|
19
|
+
chord: chordLayoutPlugin_1.chordLayoutPlugin,
|
|
20
|
+
tree: hierarchyLayoutPlugin_1.hierarchyLayoutPlugin,
|
|
21
|
+
cluster: hierarchyLayoutPlugin_1.hierarchyLayoutPlugin,
|
|
22
|
+
treemap: hierarchyLayoutPlugin_1.hierarchyLayoutPlugin,
|
|
23
|
+
circlepack: hierarchyLayoutPlugin_1.hierarchyLayoutPlugin,
|
|
24
|
+
partition: hierarchyLayoutPlugin_1.hierarchyLayoutPlugin
|
|
25
|
+
};
|
|
26
|
+
function getLayoutPlugin(chartType) {
|
|
27
|
+
return exports.networkLayoutRegistry[chartType];
|
|
28
|
+
}
|