semiotic 3.0.0-beta.2 → 3.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +93 -753
- package/README.md +92 -7
- package/ai/dist/componentRegistry.js +26 -0
- package/ai/dist/{ai/mcp-server.js → mcp-server.js} +1 -1
- package/ai/dist/{ai/renderHOCToSVG.js → renderHOCToSVG.js} +2 -2
- package/dist/ChartContainer.d.ts +60 -0
- package/dist/DetailsPanel.d.ts +37 -0
- package/dist/LinkedCharts.d.ts +2 -0
- package/dist/Tooltip/Tooltip.d.ts +2 -2
- package/dist/charts/index.d.ts +1 -1
- package/dist/charts/ordinal/BarChart.d.ts +1 -0
- package/dist/charts/ordinal/BoxPlot.d.ts +1 -0
- package/dist/charts/ordinal/DonutChart.d.ts +1 -0
- package/dist/charts/ordinal/DotPlot.d.ts +1 -0
- package/dist/charts/ordinal/GroupedBarChart.d.ts +1 -0
- package/dist/charts/ordinal/Histogram.d.ts +1 -0
- package/dist/charts/ordinal/PieChart.d.ts +1 -0
- package/dist/charts/ordinal/RidgelinePlot.d.ts +1 -0
- package/dist/charts/ordinal/StackedBarChart.d.ts +1 -0
- package/dist/charts/ordinal/SwarmPlot.d.ts +1 -0
- package/dist/charts/ordinal/ViolinPlot.d.ts +1 -0
- package/dist/charts/realtime/RealtimeHeatmap.d.ts +11 -0
- package/dist/charts/realtime/RealtimeHistogram.d.ts +15 -1
- package/dist/charts/realtime/RealtimeLineChart.d.ts +6 -0
- package/dist/charts/realtime/RealtimeSwarmChart.d.ts +6 -0
- package/dist/charts/realtime/RealtimeWaterfallChart.d.ts +6 -0
- package/dist/charts/shared/annotationRules.d.ts +3 -0
- package/dist/charts/shared/colorUtils.d.ts +17 -11
- package/dist/charts/shared/hooks.d.ts +96 -1
- package/dist/charts/shared/loess.d.ts +13 -0
- package/dist/charts/shared/networkUtils.d.ts +31 -0
- package/dist/charts/shared/tooltipUtils.d.ts +16 -0
- package/dist/charts/shared/types.d.ts +17 -2
- package/dist/charts/shared/validateChartData.d.ts +2 -3
- package/dist/charts/shared/validateProps.d.ts +18 -0
- package/dist/charts/xy/AreaChart.d.ts +4 -0
- package/dist/charts/xy/BubbleChart.d.ts +6 -0
- package/dist/charts/xy/Heatmap.d.ts +4 -0
- package/dist/charts/xy/LineChart.d.ts +6 -0
- package/dist/charts/xy/Scatterplot.d.ts +4 -0
- package/dist/charts/xy/StackedAreaChart.d.ts +4 -0
- package/dist/data/fromVegaLite.d.ts +48 -0
- package/dist/export/chartConfig.d.ts +29 -0
- package/dist/export/selectionSerializer.d.ts +20 -0
- package/dist/geometry/sankeyLinks.d.ts +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime/types.d.ts +20 -6
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai.d.ts +14 -0
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-data.d.ts +2 -0
- package/dist/semiotic-data.min.js +1 -1
- package/dist/semiotic-data.module.min.js +1 -1
- package/dist/semiotic-network.d.ts +9 -19
- package/dist/semiotic-ordinal.d.ts +12 -14
- package/dist/semiotic-xy.d.ts +12 -18
- package/dist/semiotic.d.ts +16 -13
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/store/ObservationStore.d.ts +61 -0
- package/dist/store/SelectionStore.d.ts +9 -1
- package/dist/store/ThemeStore.d.ts +6 -1
- package/dist/store/TooltipStore.d.ts +3 -1
- package/dist/store/createStore.d.ts +4 -1
- package/dist/store/useObservation.d.ts +18 -0
- package/dist/stream/MarginalGraphics.d.ts +1 -1
- package/dist/stream/NetworkPipelineStore.d.ts +44 -0
- package/dist/stream/OrdinalCanvasHitTester.d.ts +1 -0
- package/dist/stream/OrdinalSVGOverlay.d.ts +6 -2
- package/dist/stream/ParticlePool.d.ts +2 -1
- package/dist/stream/PipelineStore.d.ts +11 -0
- package/dist/stream/SVGOverlay.d.ts +21 -2
- package/dist/stream/SceneGraph.d.ts +1 -1
- package/dist/stream/networkTypes.d.ts +58 -1
- package/dist/stream/ordinalTypes.d.ts +13 -0
- package/dist/stream/types.d.ts +14 -0
- package/dist/types/annotationTypes.d.ts +10 -0
- package/dist/types/networkTypes.d.ts +1 -2
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +30 -42
- package/ai/dist/ai/componentRegistry.js +0 -45
- package/ai/dist/src/components/Annotation.js +0 -358
- package/ai/dist/src/components/AnnotationLayer/AnnotationLayer.js +0 -369
- package/ai/dist/src/components/Axis/Axis.js +0 -374
- package/ai/dist/src/components/Axis/axisTitle.js +0 -14
- package/ai/dist/src/components/Axis/index.js +0 -7
- package/ai/dist/src/components/Axis/summaryGraphic.js +0 -37
- package/ai/dist/src/components/Brush.js +0 -84
- package/ai/dist/src/components/ChartErrorBoundary.js +0 -91
- package/ai/dist/src/components/DividedLine.js +0 -65
- package/ai/dist/src/components/Legend.js +0 -140
- package/ai/dist/src/components/LinkedCharts.js +0 -95
- package/ai/dist/src/components/ThemeProvider.js +0 -79
- package/ai/dist/src/components/Tooltip/Tooltip.js +0 -309
- package/ai/dist/src/components/TooltipPositioner/index.js +0 -132
- package/ai/dist/src/components/annotationLayerBehavior/annotationHandling.js +0 -73
- package/ai/dist/src/components/annotationLayerBehavior/d3labeler.js +0 -254
- package/ai/dist/src/components/annotationRules/baseRules.js +0 -150
- package/ai/dist/src/components/annotationRules/networkframeRules.js +0 -196
- package/ai/dist/src/components/annotationRules/xyframeRules.js +0 -297
- package/ai/dist/src/components/batchWork.js +0 -35
- package/ai/dist/src/components/charts/index.js +0 -109
- package/ai/dist/src/components/charts/network/ChordDiagram.js +0 -142
- package/ai/dist/src/components/charts/network/CirclePack.js +0 -108
- package/ai/dist/src/components/charts/network/ForceDirectedGraph.js +0 -121
- package/ai/dist/src/components/charts/network/SankeyDiagram.js +0 -155
- package/ai/dist/src/components/charts/network/TreeDiagram.js +0 -110
- package/ai/dist/src/components/charts/network/Treemap.js +0 -106
- package/ai/dist/src/components/charts/ordinal/BarChart.js +0 -156
- package/ai/dist/src/components/charts/ordinal/BoxPlot.js +0 -139
- package/ai/dist/src/components/charts/ordinal/DonutChart.js +0 -130
- package/ai/dist/src/components/charts/ordinal/DotPlot.js +0 -126
- package/ai/dist/src/components/charts/ordinal/GroupedBarChart.js +0 -129
- package/ai/dist/src/components/charts/ordinal/Histogram.js +0 -132
- package/ai/dist/src/components/charts/ordinal/PieChart.js +0 -128
- package/ai/dist/src/components/charts/ordinal/RidgelinePlot.js +0 -130
- package/ai/dist/src/components/charts/ordinal/StackedBarChart.js +0 -130
- package/ai/dist/src/components/charts/ordinal/SwarmPlot.js +0 -147
- package/ai/dist/src/components/charts/ordinal/ViolinPlot.js +0 -138
- package/ai/dist/src/components/charts/realtime/RealtimeHeatmap.js +0 -79
- package/ai/dist/src/components/charts/realtime/RealtimeHistogram.js +0 -114
- package/ai/dist/src/components/charts/realtime/RealtimeLineChart.js +0 -93
- package/ai/dist/src/components/charts/realtime/RealtimeSwarmChart.js +0 -105
- package/ai/dist/src/components/charts/realtime/RealtimeWaterfallChart.js +0 -106
- package/ai/dist/src/components/charts/shared/ChartError.js +0 -72
- package/ai/dist/src/components/charts/shared/colorUtils.js +0 -138
- package/ai/dist/src/components/charts/shared/formatUtils.js +0 -213
- package/ai/dist/src/components/charts/shared/hooks.js +0 -49
- package/ai/dist/src/components/charts/shared/legendUtils.js +0 -57
- package/ai/dist/src/components/charts/shared/selectionUtils.js +0 -67
- package/ai/dist/src/components/charts/shared/tooltipUtils.js +0 -79
- package/ai/dist/src/components/charts/shared/types.js +0 -2
- package/ai/dist/src/components/charts/shared/validateChartData.js +0 -82
- package/ai/dist/src/components/charts/shared/validateProps.js +0 -736
- package/ai/dist/src/components/charts/xy/AreaChart.js +0 -230
- package/ai/dist/src/components/charts/xy/BubbleChart.js +0 -251
- package/ai/dist/src/components/charts/xy/Heatmap.js +0 -235
- package/ai/dist/src/components/charts/xy/LineChart.js +0 -307
- package/ai/dist/src/components/charts/xy/MinimapChart.js +0 -298
- package/ai/dist/src/components/charts/xy/Scatterplot.js +0 -172
- package/ai/dist/src/components/charts/xy/ScatterplotMatrix.js +0 -426
- package/ai/dist/src/components/charts/xy/StackedAreaChart.js +0 -231
- package/ai/dist/src/components/constants/coordinateNames.js +0 -11
- package/ai/dist/src/components/constants/frame_props.js +0 -251
- package/ai/dist/src/components/data/dataFunctions.js +0 -487
- package/ai/dist/src/components/data/multiAccessorUtils.js +0 -14
- package/ai/dist/src/components/data/transforms.js +0 -143
- package/ai/dist/src/components/data/unflowedFunctions.js +0 -5
- package/ai/dist/src/components/export/exportChart.js +0 -121
- package/ai/dist/src/components/generic_utilities/functions.js +0 -5
- package/ai/dist/src/components/geometry/areaDrawing.js +0 -312
- package/ai/dist/src/components/geometry/contourLayout.js +0 -73
- package/ai/dist/src/components/geometry/hexbinLayout.js +0 -163
- package/ai/dist/src/components/geometry/lineDrawing.js +0 -356
- package/ai/dist/src/components/geometry/sankeyLinks.js +0 -331
- package/ai/dist/src/components/geometry/summaryLayouts.js +0 -136
- package/ai/dist/src/components/index.js +0 -18
- package/ai/dist/src/components/processing/InteractionItems.js +0 -223
- package/ai/dist/src/components/processing/hierarchyUtils.js +0 -104
- package/ai/dist/src/components/processing/layouts/chordLayout.js +0 -58
- package/ai/dist/src/components/processing/layouts/forceLayout.js +0 -142
- package/ai/dist/src/components/processing/layouts/hierarchyLayout.js +0 -31
- package/ai/dist/src/components/processing/layouts/index.js +0 -32
- package/ai/dist/src/components/processing/layouts/sankeyLayout.js +0 -96
- package/ai/dist/src/components/processing/layouts/simpleLayouts.js +0 -34
- package/ai/dist/src/components/processing/layouts/types.js +0 -2
- package/ai/dist/src/components/processing/networkDefaults.js +0 -39
- package/ai/dist/src/components/realtime/BinAccumulator.js +0 -36
- package/ai/dist/src/components/realtime/IncrementalExtent.js +0 -55
- package/ai/dist/src/components/realtime/RingBuffer.js +0 -104
- package/ai/dist/src/components/realtime/renderers/barRenderer.js +0 -133
- package/ai/dist/src/components/realtime/renderers/candlestickRenderer.js +0 -7
- package/ai/dist/src/components/realtime/renderers/lineRenderer.js +0 -164
- package/ai/dist/src/components/realtime/renderers/swarmRenderer.js +0 -91
- package/ai/dist/src/components/realtime/renderers/types.js +0 -2
- package/ai/dist/src/components/realtime/renderers/waterfallRenderer.js +0 -163
- package/ai/dist/src/components/realtime/types.js +0 -2
- package/ai/dist/src/components/semiotic-ai.js +0 -89
- package/ai/dist/src/components/semiotic-data.js +0 -12
- package/ai/dist/src/components/semiotic-network.js +0 -38
- package/ai/dist/src/components/semiotic-ordinal.js +0 -28
- package/ai/dist/src/components/semiotic-realtime.js +0 -30
- package/ai/dist/src/components/semiotic-server.js +0 -8
- package/ai/dist/src/components/semiotic-xy.js +0 -35
- package/ai/dist/src/components/semiotic.js +0 -109
- package/ai/dist/src/components/server/renderToStaticSVG.js +0 -594
- package/ai/dist/src/components/store/SelectionStore.js +0 -91
- package/ai/dist/src/components/store/ThemeStore.js +0 -78
- package/ai/dist/src/components/store/TooltipStore.js +0 -13
- package/ai/dist/src/components/store/createStore.js +0 -81
- package/ai/dist/src/components/store/useSelection.js +0 -133
- package/ai/dist/src/components/stream/CanvasHitTester.js +0 -164
- package/ai/dist/src/components/stream/DataSourceAdapter.js +0 -99
- package/ai/dist/src/components/stream/MarginalGraphics.js +0 -266
- package/ai/dist/src/components/stream/NetworkCanvasHitTester.js +0 -228
- package/ai/dist/src/components/stream/NetworkPipelineStore.js +0 -498
- package/ai/dist/src/components/stream/NetworkSVGOverlay.js +0 -70
- package/ai/dist/src/components/stream/NetworkSceneGraph.js +0 -38
- package/ai/dist/src/components/stream/OrdinalCanvasHitTester.js +0 -146
- package/ai/dist/src/components/stream/OrdinalPipelineStore.js +0 -786
- package/ai/dist/src/components/stream/OrdinalSVGOverlay.js +0 -130
- package/ai/dist/src/components/stream/ParticlePool.js +0 -174
- package/ai/dist/src/components/stream/PipelineStore.js +0 -1243
- package/ai/dist/src/components/stream/SVGOverlay.js +0 -129
- package/ai/dist/src/components/stream/SceneGraph.js +0 -132
- package/ai/dist/src/components/stream/StreamNetworkFrame.js +0 -561
- package/ai/dist/src/components/stream/StreamOrdinalFrame.js +0 -492
- package/ai/dist/src/components/stream/StreamXYFrame.js +0 -590
- package/ai/dist/src/components/stream/accessorUtils.js +0 -20
- package/ai/dist/src/components/stream/index.js +0 -32
- package/ai/dist/src/components/stream/layouts/chordLayoutPlugin.js +0 -352
- package/ai/dist/src/components/stream/layouts/forceLayoutPlugin.js +0 -230
- package/ai/dist/src/components/stream/layouts/hierarchyLayoutPlugin.js +0 -568
- package/ai/dist/src/components/stream/layouts/index.js +0 -28
- package/ai/dist/src/components/stream/layouts/sankeyLayoutPlugin.js +0 -245
- package/ai/dist/src/components/stream/networkTypes.js +0 -17
- package/ai/dist/src/components/stream/ordinalSceneBuilders/barScene.js +0 -126
- package/ai/dist/src/components/stream/ordinalSceneBuilders/connectorScene.js +0 -62
- package/ai/dist/src/components/stream/ordinalSceneBuilders/pieScene.js +0 -33
- package/ai/dist/src/components/stream/ordinalSceneBuilders/pointScene.js +0 -63
- package/ai/dist/src/components/stream/ordinalSceneBuilders/statisticalScene.js +0 -278
- package/ai/dist/src/components/stream/ordinalSceneBuilders/timelineScene.js +0 -30
- package/ai/dist/src/components/stream/ordinalSceneBuilders/types.js +0 -2
- package/ai/dist/src/components/stream/ordinalTypes.js +0 -2
- package/ai/dist/src/components/stream/renderers/areaCanvasRenderer.js +0 -48
- package/ai/dist/src/components/stream/renderers/barCanvasRenderer.js +0 -70
- package/ai/dist/src/components/stream/renderers/boxplotCanvasRenderer.js +0 -75
- package/ai/dist/src/components/stream/renderers/candlestickCanvasRenderer.js +0 -28
- package/ai/dist/src/components/stream/renderers/connectorCanvasRenderer.js +0 -47
- package/ai/dist/src/components/stream/renderers/heatmapCanvasRenderer.js +0 -31
- package/ai/dist/src/components/stream/renderers/lineCanvasRenderer.js +0 -140
- package/ai/dist/src/components/stream/renderers/networkArcRenderer.js +0 -38
- package/ai/dist/src/components/stream/renderers/networkCircleRenderer.js +0 -37
- package/ai/dist/src/components/stream/renderers/networkEdgeRenderer.js +0 -102
- package/ai/dist/src/components/stream/renderers/networkParticleRenderer.js +0 -63
- package/ai/dist/src/components/stream/renderers/networkRectRenderer.js +0 -35
- package/ai/dist/src/components/stream/renderers/pointCanvasRenderer.js +0 -38
- package/ai/dist/src/components/stream/renderers/swarmCanvasRenderer.js +0 -10
- package/ai/dist/src/components/stream/renderers/types.js +0 -2
- package/ai/dist/src/components/stream/renderers/violinCanvasRenderer.js +0 -47
- package/ai/dist/src/components/stream/renderers/waterfallCanvasRenderer.js +0 -38
- package/ai/dist/src/components/stream/renderers/wedgeCanvasRenderer.js +0 -33
- package/ai/dist/src/components/stream/types.js +0 -2
- package/ai/dist/src/components/types/annotationTypes.js +0 -2
- package/ai/dist/src/components/types/canvasTypes.js +0 -2
- package/ai/dist/src/components/types/generalTypes.js +0 -2
- package/ai/dist/src/components/types/interactionTypes.js +0 -2
- package/ai/dist/src/components/types/legendTypes.js +0 -2
- package/ai/dist/src/components/types/networkTypes.js +0 -2
- package/ai/dist/src/components/types/ordinalTypes.js +0 -2
- package/ai/dist/src/components/types/xyTypes.js +0 -2
- package/ai/dist/src/components/useBoundingRect.js +0 -24
- package/ai/dist/src/components/visualizationLayerBehavior/axis.js +0 -301
- package/ai/dist/src/components/visualizationLayerBehavior/general.js +0 -435
- package/ai/dist/src/setupTests.js +0 -4
- package/dist/AnnotationLayer/AnnotationLayer.d.ts +0 -25
- package/dist/Axis/Axis.d.ts +0 -7
- package/dist/Axis/axisTitle.d.ts +0 -10
- package/dist/Axis/index.d.ts +0 -2
- package/dist/Axis/summaryGraphic.d.ts +0 -17
- package/dist/Brush.d.ts +0 -12
- package/dist/DividedLine.d.ts +0 -16
- package/dist/TooltipPositioner/index.d.ts +0 -7
- package/dist/annotationLayerBehavior/annotationHandling.d.ts +0 -19
- package/dist/annotationLayerBehavior/d3labeler.d.ts +0 -9
- package/dist/annotationRules/baseRules.d.ts +0 -25
- package/dist/annotationRules/networkframeRules.d.ts +0 -48
- package/dist/annotationRules/xyframeRules.d.ts +0 -117
- package/dist/batchWork.d.ts +0 -6
- package/dist/constants/coordinateNames.d.ts +0 -8
- package/dist/constants/frame_props.d.ts +0 -13
- package/dist/data/dataFunctions.d.ts +0 -45
- package/dist/data/multiAccessorUtils.d.ts +0 -1
- package/dist/data/unflowedFunctions.d.ts +0 -1
- package/dist/generic_utilities/functions.d.ts +0 -1
- package/dist/geometry/areaDrawing.d.ts +0 -21
- package/dist/geometry/contourLayout.d.ts +0 -6
- package/dist/geometry/hexbinLayout.d.ts +0 -7
- package/dist/geometry/lineDrawing.d.ts +0 -71
- package/dist/geometry/summaryLayouts.d.ts +0 -45
- package/dist/index.d.ts +0 -1
- package/dist/network.js +0 -7495
- package/dist/network.js.map +0 -1
- package/dist/network.module.js +0 -7458
- package/dist/network.module.js.map +0 -1
- package/dist/ordinal.js +0 -6497
- package/dist/ordinal.js.map +0 -1
- package/dist/ordinal.module.js +0 -6465
- package/dist/ordinal.module.js.map +0 -1
- package/dist/processing/InteractionItems.d.ts +0 -13
- package/dist/processing/hierarchyUtils.d.ts +0 -16
- package/dist/processing/layouts/chordLayout.d.ts +0 -2
- package/dist/processing/layouts/forceLayout.d.ts +0 -3
- package/dist/processing/layouts/hierarchyLayout.d.ts +0 -10
- package/dist/processing/layouts/index.d.ts +0 -8
- package/dist/processing/layouts/sankeyLayout.d.ts +0 -8
- package/dist/processing/layouts/simpleLayouts.d.ts +0 -7
- package/dist/processing/layouts/types.d.ts +0 -17
- package/dist/processing/networkDefaults.d.ts +0 -36
- package/dist/realtime/renderers/barRenderer.d.ts +0 -2
- package/dist/realtime/renderers/candlestickRenderer.d.ts +0 -2
- package/dist/realtime/renderers/lineRenderer.d.ts +0 -2
- package/dist/realtime/renderers/swarmRenderer.d.ts +0 -2
- package/dist/realtime.js +0 -7072
- package/dist/realtime.js.map +0 -1
- package/dist/realtime.module.js +0 -7043
- package/dist/realtime.module.js.map +0 -1
- package/dist/semiotic-ai.js +0 -13323
- package/dist/semiotic-ai.js.map +0 -1
- package/dist/semiotic-ai.module.js +0 -13264
- package/dist/semiotic-ai.module.js.map +0 -1
- package/dist/semiotic-data.js +0 -141
- package/dist/semiotic-data.js.map +0 -1
- package/dist/semiotic-data.module.js +0 -136
- package/dist/semiotic-data.module.js.map +0 -1
- package/dist/semiotic.js +0 -16351
- package/dist/semiotic.js.map +0 -1
- package/dist/semiotic.module.js +0 -16265
- package/dist/semiotic.module.js.map +0 -1
- package/dist/server.js +0 -5191
- package/dist/server.js.map +0 -1
- package/dist/server.module.js +0 -5166
- package/dist/server.module.js.map +0 -1
- package/dist/stream/NetworkSceneGraph.d.ts +0 -14
- package/dist/stream/index.d.ts +0 -16
- package/dist/types/canvasTypes.d.ts +0 -9
- package/dist/types/xyTypes.d.ts +0 -24
- package/dist/useBoundingRect.d.ts +0 -2
- package/dist/visualizationLayerBehavior/axis.d.ts +0 -36
- package/dist/visualizationLayerBehavior/general.d.ts +0 -80
- package/dist/xy.js +0 -6993
- package/dist/xy.js.map +0 -1
- package/dist/xy.module.js +0 -6957
- package/dist/xy.module.js.map +0 -1
|
@@ -1,568 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
-
}
|