semiotic 2.0.2 → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +530 -0
- package/README.md +190 -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 +373 -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/DividedLine.js +65 -0
- package/ai/dist/src/components/FacetController.js +259 -0
- package/ai/dist/src/components/Frame.js +139 -0
- package/ai/dist/src/components/InteractionLayer.js +328 -0
- package/ai/dist/src/components/Legend.js +140 -0
- package/ai/dist/src/components/MiniMap.js +75 -0
- package/ai/dist/src/components/MinimapXYFrame.js +99 -0
- package/ai/dist/src/components/NetworkFrame.js +335 -0
- package/ai/dist/src/components/OrdinalFrame.js +437 -0
- package/ai/dist/src/components/ResponsiveFrame.js +68 -0
- package/ai/dist/src/components/ResponsiveMinimapXYFrame.js +11 -0
- package/ai/dist/src/components/ResponsiveNetworkFrame.js +11 -0
- package/ai/dist/src/components/ResponsiveOrdinalFrame.js +11 -0
- package/ai/dist/src/components/ResponsiveXYFrame.js +10 -0
- package/ai/dist/src/components/SparkFrame.js +113 -0
- package/ai/dist/src/components/SparkNetworkFrame.js +11 -0
- package/ai/dist/src/components/SparkOrdinalFrame.js +11 -0
- package/ai/dist/src/components/SparkXYFrame.js +11 -0
- package/ai/dist/src/components/Tooltip/Tooltip.js +304 -0
- package/ai/dist/src/components/TooltipPositioner/index.js +132 -0
- package/ai/dist/src/components/VisualizationLayer.js +395 -0
- package/ai/dist/src/components/XYFrame.js +524 -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 +198 -0
- package/ai/dist/src/components/annotationRules/orframeRules.js +695 -0
- package/ai/dist/src/components/annotationRules/xyframeRules.js +299 -0
- package/ai/dist/src/components/batchWork.js +35 -0
- package/ai/dist/src/components/charts/index.js +96 -0
- package/ai/dist/src/components/charts/network/ChordDiagram.js +245 -0
- package/ai/dist/src/components/charts/network/CirclePack.js +177 -0
- package/ai/dist/src/components/charts/network/ForceDirectedGraph.js +248 -0
- package/ai/dist/src/components/charts/network/SankeyDiagram.js +305 -0
- package/ai/dist/src/components/charts/network/TreeDiagram.js +268 -0
- package/ai/dist/src/components/charts/network/Treemap.js +177 -0
- package/ai/dist/src/components/charts/ordinal/BarChart.js +191 -0
- package/ai/dist/src/components/charts/ordinal/BoxPlot.js +235 -0
- package/ai/dist/src/components/charts/ordinal/DonutChart.js +178 -0
- package/ai/dist/src/components/charts/ordinal/DotPlot.js +194 -0
- package/ai/dist/src/components/charts/ordinal/GroupedBarChart.js +194 -0
- package/ai/dist/src/components/charts/ordinal/PieChart.js +155 -0
- package/ai/dist/src/components/charts/ordinal/StackedBarChart.js +213 -0
- package/ai/dist/src/components/charts/ordinal/SwarmPlot.js +219 -0
- package/ai/dist/src/components/charts/realtime/RealtimeBarChart.js +91 -0
- package/ai/dist/src/components/charts/realtime/RealtimeLineChart.js +73 -0
- package/ai/dist/src/components/charts/realtime/RealtimeSwarmChart.js +85 -0
- package/ai/dist/src/components/charts/realtime/RealtimeWaterfallChart.js +86 -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 +176 -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/types.js +2 -0
- package/ai/dist/src/components/charts/shared/validateChartData.js +82 -0
- package/ai/dist/src/components/charts/shared/validateProps.js +640 -0
- package/ai/dist/src/components/charts/xy/AreaChart.js +220 -0
- package/ai/dist/src/components/charts/xy/BubbleChart.js +222 -0
- package/ai/dist/src/components/charts/xy/Heatmap.js +230 -0
- package/ai/dist/src/components/charts/xy/LineChart.js +302 -0
- package/ai/dist/src/components/charts/xy/Scatterplot.js +136 -0
- package/ai/dist/src/components/charts/xy/StackedAreaChart.js +220 -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/constants/jsx.js +71 -0
- package/ai/dist/src/components/data/dataFunctions.js +473 -0
- package/ai/dist/src/components/data/multiAccessorUtils.js +14 -0
- package/ai/dist/src/components/data/networkPipelineCache.js +43 -0
- package/ai/dist/src/components/data/ordinalPipelineCache.js +53 -0
- package/ai/dist/src/components/data/unflowedFunctions.js +5 -0
- package/ai/dist/src/components/data/xyPipelineCache.js +49 -0
- package/ai/dist/src/components/generic_utilities/functions.js +5 -0
- package/ai/dist/src/components/index.js +145 -0
- package/ai/dist/src/components/interactionLayerBehavior/InteractionCanvas.js +128 -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/network.js +771 -0
- package/ai/dist/src/components/processing/networkDefaults.js +39 -0
- package/ai/dist/src/components/processing/networkLayoutHelpers.js +98 -0
- package/ai/dist/src/components/processing/ordinal.js +889 -0
- package/ai/dist/src/components/processing/ordinalConstants.js +23 -0
- package/ai/dist/src/components/processing/ordinalOverlays.js +88 -0
- package/ai/dist/src/components/processing/ordinalRenderPipeline.js +196 -0
- package/ai/dist/src/components/processing/xyDrawing.js +484 -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/RealtimeFrame.js +710 -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 +66 -0
- package/ai/dist/src/components/semiotic-network.js +30 -0
- package/ai/dist/src/components/semiotic-ordinal.js +28 -0
- package/ai/dist/src/components/semiotic-realtime.js +37 -0
- package/ai/dist/src/components/semiotic-server.js +8 -0
- package/ai/dist/src/components/semiotic-xy.js +41 -0
- package/ai/dist/src/components/semiotic.js +101 -0
- package/ai/dist/src/components/server/renderToStaticSVG.js +392 -0
- package/ai/dist/src/components/store/TooltipStore.js +13 -0
- package/ai/dist/src/components/store/createStore.js +77 -0
- package/ai/dist/src/components/svg/SvgHelper.js +308 -0
- package/ai/dist/src/components/svg/areaDrawing.js +312 -0
- package/ai/dist/src/components/svg/boxplotRenderer.js +441 -0
- package/ai/dist/src/components/svg/bucketizedRenderer.js +677 -0
- package/ai/dist/src/components/svg/ckbinsRenderer.js +92 -0
- package/ai/dist/src/components/svg/ckmeans.js +238 -0
- package/ai/dist/src/components/svg/contourLayout.js +73 -0
- package/ai/dist/src/components/svg/contourRenderer.js +53 -0
- package/ai/dist/src/components/svg/edgeGenerators.js +181 -0
- package/ai/dist/src/components/svg/frameFunctions.js +579 -0
- package/ai/dist/src/components/svg/graphAlgorithms.js +138 -0
- package/ai/dist/src/components/svg/hexbinLayout.js +163 -0
- package/ai/dist/src/components/svg/lineDrawing.js +427 -0
- package/ai/dist/src/components/svg/networkDrawing.js +207 -0
- package/ai/dist/src/components/svg/nodeGenerators.js +131 -0
- package/ai/dist/src/components/svg/pieceDrawing.js +110 -0
- package/ai/dist/src/components/svg/pieceLayouts.js +588 -0
- package/ai/dist/src/components/svg/sankeyLinks.js +143 -0
- package/ai/dist/src/components/svg/summaryAxis.js +48 -0
- package/ai/dist/src/components/svg/summaryLayouts.js +202 -0
- package/ai/dist/src/components/svg/swarmLayout.js +128 -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/useDerivedStateFromProps.js +25 -0
- package/ai/dist/src/components/useLegacyUnmountCallback.js +21 -0
- package/ai/dist/src/components/visualizationLayerBehavior/axis.js +249 -0
- package/ai/dist/src/components/visualizationLayerBehavior/general.js +435 -0
- package/ai/dist/src/setupTests.js +4 -0
- package/ai/examples.md +394 -0
- package/ai/schema.json +1178 -0
- package/ai/system-prompt.md +38 -0
- package/dist/Annotation.d.ts +3 -0
- package/dist/AnnotationLayer/AnnotationLayer.d.ts +25 -0
- package/dist/Axis/Axis.d.ts +7 -0
- package/dist/Axis/axisTitle.d.ts +10 -0
- package/dist/Axis/index.d.ts +2 -0
- package/dist/Axis/summaryGraphic.d.ts +17 -0
- package/dist/Brush.d.ts +12 -0
- package/dist/DividedLine.d.ts +16 -0
- package/dist/FacetController.d.ts +12 -0
- package/dist/Frame.d.ts +2 -0
- package/dist/InteractionLayer.d.ts +3 -0
- package/dist/Legend.d.ts +3 -0
- package/dist/MiniMap.d.ts +14 -0
- package/dist/MinimapXYFrame.d.ts +10 -0
- package/dist/NetworkFrame.d.ts +8 -0
- package/dist/OrdinalFrame.d.ts +8 -0
- package/dist/ResponsiveFrame.d.ts +22 -0
- package/dist/ResponsiveMinimapXYFrame.d.ts +3 -0
- package/dist/ResponsiveNetworkFrame.d.ts +3 -0
- package/dist/ResponsiveOrdinalFrame.d.ts +3 -0
- package/dist/ResponsiveXYFrame.d.ts +3 -0
- package/dist/SparkFrame.d.ts +14 -0
- package/dist/SparkNetworkFrame.d.ts +5 -0
- package/dist/SparkOrdinalFrame.d.ts +5 -0
- package/dist/SparkXYFrame.d.ts +5 -0
- package/dist/Tooltip/Tooltip.d.ts +141 -0
- package/dist/TooltipPositioner/index.d.ts +7 -0
- package/dist/VisualizationLayer.d.ts +33 -0
- package/dist/XYFrame.d.ts +8 -0
- package/dist/annotationLayerBehavior/annotationHandling.d.ts +19 -0
- package/dist/annotationLayerBehavior/d3labeler.d.ts +9 -0
- package/dist/annotationRules/baseRules.d.ts +25 -0
- package/dist/annotationRules/networkframeRules.d.ts +48 -0
- package/dist/annotationRules/orframeRules.d.ts +103 -0
- package/dist/annotationRules/xyframeRules.d.ts +117 -0
- package/dist/batchWork.d.ts +6 -0
- package/dist/charts/index.d.ts +62 -0
- package/dist/charts/network/ChordDiagram.d.ts +181 -0
- package/dist/charts/network/CirclePack.d.ts +103 -0
- package/dist/charts/network/ForceDirectedGraph.d.ts +192 -0
- package/dist/charts/network/SankeyDiagram.d.ts +195 -0
- package/dist/charts/network/TreeDiagram.d.ts +200 -0
- package/dist/charts/network/Treemap.d.ts +98 -0
- package/dist/charts/ordinal/BarChart.d.ts +119 -0
- package/dist/charts/ordinal/BoxPlot.d.ts +125 -0
- package/dist/charts/ordinal/DonutChart.d.ts +95 -0
- package/dist/charts/ordinal/DotPlot.d.ts +128 -0
- package/dist/charts/ordinal/GroupedBarChart.d.ts +113 -0
- package/dist/charts/ordinal/PieChart.d.ts +83 -0
- package/dist/charts/ordinal/StackedBarChart.d.ts +119 -0
- package/dist/charts/ordinal/SwarmPlot.d.ts +137 -0
- package/dist/charts/realtime/RealtimeBarChart.d.ts +102 -0
- package/dist/charts/realtime/RealtimeLineChart.d.ts +78 -0
- package/dist/charts/realtime/RealtimeSwarmChart.d.ts +88 -0
- package/dist/charts/realtime/RealtimeWaterfallChart.d.ts +85 -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 +82 -0
- package/dist/charts/shared/hooks.d.ts +20 -0
- package/dist/charts/shared/legendUtils.d.ts +32 -0
- package/dist/charts/shared/types.d.ts +58 -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 +127 -0
- package/dist/charts/xy/BubbleChart.d.ts +157 -0
- package/dist/charts/xy/Heatmap.d.ts +153 -0
- package/dist/charts/xy/LineChart.d.ts +193 -0
- package/dist/charts/xy/Scatterplot.d.ts +50 -0
- package/dist/charts/xy/StackedAreaChart.d.ts +131 -0
- package/dist/constants/coordinateNames.d.ts +8 -0
- package/dist/constants/frame_props.d.ts +13 -0
- package/dist/constants/jsx.d.ts +19 -0
- package/dist/data/dataFunctions.d.ts +45 -0
- package/dist/data/multiAccessorUtils.d.ts +1 -0
- package/dist/data/networkPipelineCache.d.ts +27 -0
- package/dist/data/ordinalPipelineCache.d.ts +33 -0
- package/dist/data/unflowedFunctions.d.ts +1 -0
- package/dist/data/xyPipelineCache.d.ts +35 -0
- package/dist/generic_utilities/functions.d.ts +1 -0
- package/dist/index.d.ts +133 -0
- package/dist/interactionLayerBehavior/InteractionCanvas.d.ts +20 -0
- package/dist/network.js +8520 -0
- package/dist/network.js.map +1 -0
- package/dist/network.min.js +1 -0
- package/dist/network.module.js +8484 -0
- package/dist/network.module.js.map +1 -0
- package/dist/network.module.min.js +1 -0
- package/dist/ordinal.js +9276 -0
- package/dist/ordinal.js.map +1 -0
- package/dist/ordinal.min.js +1 -0
- package/dist/ordinal.module.js +9242 -0
- package/dist/ordinal.module.js.map +1 -0
- package/dist/ordinal.module.min.js +1 -0
- package/dist/processing/InteractionItems.d.ts +13 -0
- 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/network.d.ts +111 -0
- package/dist/processing/networkDefaults.d.ts +36 -0
- package/dist/processing/networkLayoutHelpers.d.ts +54 -0
- package/dist/processing/ordinal.d.ts +102 -0
- package/dist/processing/ordinalConstants.d.ts +33 -0
- package/dist/processing/ordinalOverlays.d.ts +33 -0
- package/dist/processing/ordinalRenderPipeline.d.ts +148 -0
- package/dist/processing/xyDrawing.d.ts +140 -0
- package/dist/realtime/BinAccumulator.d.ts +8 -0
- package/dist/realtime/IncrementalExtent.d.ts +13 -0
- package/dist/realtime/RealtimeFrame.d.ts +4 -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 +1598 -0
- package/dist/realtime.js.map +1 -0
- package/dist/realtime.min.js +1 -0
- package/dist/realtime.module.js +1566 -0
- package/dist/realtime.module.js.map +1 -0
- package/dist/realtime.module.min.js +1 -0
- package/dist/semiotic-ai.d.ts +28 -0
- package/dist/semiotic-ai.js +18722 -0
- package/dist/semiotic-ai.js.map +1 -0
- package/dist/semiotic-ai.min.js +1 -0
- package/dist/semiotic-ai.module.js +18668 -0
- package/dist/semiotic-ai.module.js.map +1 -0
- package/dist/semiotic-ai.module.min.js +1 -0
- package/dist/semiotic-network.d.ts +19 -0
- package/dist/semiotic-ordinal.d.ts +18 -0
- package/dist/semiotic-realtime.d.ts +23 -0
- package/dist/semiotic-server.d.ts +1 -0
- package/dist/semiotic-xy.d.ts +24 -0
- package/dist/semiotic.d.ts +51 -0
- package/dist/semiotic.js +18723 -12996
- package/dist/semiotic.js.map +1 -0
- package/dist/semiotic.min.js +1 -0
- package/dist/semiotic.module.js +18666 -12965
- 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 +8360 -0
- package/dist/server.js.map +1 -0
- package/dist/server.min.js +1 -0
- package/dist/server.module.js +8331 -0
- package/dist/server.module.js.map +1 -0
- package/dist/server.module.min.js +1 -0
- package/dist/store/TooltipStore.d.ts +2 -0
- package/dist/store/createStore.d.ts +1 -0
- package/dist/svg/SvgHelper.d.ts +33 -0
- package/dist/svg/areaDrawing.d.ts +21 -0
- package/dist/svg/boxplotRenderer.d.ts +15 -0
- package/dist/svg/bucketizedRenderer.d.ts +16 -0
- package/dist/svg/ckbinsRenderer.d.ts +20 -0
- package/dist/svg/ckmeans.d.ts +69 -0
- package/dist/svg/contourLayout.d.ts +6 -0
- package/dist/svg/contourRenderer.d.ts +12 -0
- package/dist/svg/edgeGenerators.d.ts +51 -0
- package/dist/svg/frameFunctions.d.ts +108 -0
- package/dist/svg/graphAlgorithms.d.ts +14 -0
- package/dist/svg/hexbinLayout.d.ts +7 -0
- package/dist/svg/lineDrawing.d.ts +99 -0
- package/dist/svg/networkDrawing.d.ts +16 -0
- package/dist/svg/nodeGenerators.d.ts +58 -0
- package/dist/svg/pieceDrawing.d.ts +12 -0
- package/dist/svg/pieceLayouts.d.ts +53 -0
- package/dist/svg/sankeyLinks.d.ts +3 -0
- package/dist/svg/summaryAxis.d.ts +6 -0
- package/dist/svg/summaryLayouts.d.ts +53 -0
- package/dist/svg/swarmLayout.d.ts +13 -0
- package/dist/types/annotationTypes.d.ts +135 -0
- package/dist/types/canvasTypes.d.ts +9 -0
- package/dist/types/generalTypes.d.ts +238 -0
- package/dist/types/interactionTypes.d.ts +72 -0
- package/dist/types/legendTypes.d.ts +20 -0
- package/dist/types/networkTypes.d.ts +175 -0
- package/dist/types/ordinalTypes.d.ts +112 -0
- package/dist/types/xyTypes.d.ts +115 -0
- package/dist/useBoundingRect.d.ts +2 -0
- package/dist/useDerivedStateFromProps.d.ts +1 -0
- package/dist/useLegacyUnmountCallback.d.ts +2 -0
- package/dist/visualizationLayerBehavior/axis.d.ts +36 -0
- package/dist/visualizationLayerBehavior/general.d.ts +80 -0
- package/dist/xy.js +7944 -0
- package/dist/xy.js.map +1 -0
- package/dist/xy.min.js +1 -0
- package/dist/xy.module.js +7903 -0
- package/dist/xy.module.js.map +1 -0
- package/dist/xy.module.min.js +1 -0
- package/package.json +116 -65
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.ChordDiagram = ChordDiagram;
|
|
41
|
+
const React = __importStar(require("react"));
|
|
42
|
+
const react_1 = require("react");
|
|
43
|
+
const NetworkFrame_1 = __importDefault(require("../../NetworkFrame"));
|
|
44
|
+
const colorUtils_1 = require("../shared/colorUtils");
|
|
45
|
+
const Tooltip_1 = require("../../Tooltip/Tooltip");
|
|
46
|
+
const hooks_1 = require("../shared/hooks");
|
|
47
|
+
const ChartError_1 = __importDefault(require("../shared/ChartError"));
|
|
48
|
+
const validateChartData_1 = require("../shared/validateChartData");
|
|
49
|
+
const chordLayout_1 = require("../../processing/layouts/chordLayout");
|
|
50
|
+
/**
|
|
51
|
+
* ChordDiagram - Visualize directed relationships with circular chord layout
|
|
52
|
+
*
|
|
53
|
+
* A simplified wrapper around NetworkFrame for creating chord diagrams.
|
|
54
|
+
* Perfect for showing flow and relationships between entities, especially
|
|
55
|
+
* when there are reciprocal connections and self-loops.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* // Simple chord diagram
|
|
60
|
+
* <ChordDiagram
|
|
61
|
+
* edges={[
|
|
62
|
+
* {source: 'A', target: 'B', value: 100},
|
|
63
|
+
* {source: 'B', target: 'A', value: 80},
|
|
64
|
+
* {source: 'A', target: 'A', value: 50}
|
|
65
|
+
* ]}
|
|
66
|
+
* colorBy={(d) => d.id}
|
|
67
|
+
* />
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```tsx
|
|
72
|
+
* // With custom styling and padding
|
|
73
|
+
* <ChordDiagram
|
|
74
|
+
* edges={edges}
|
|
75
|
+
* nodes={nodes}
|
|
76
|
+
* colorBy="category"
|
|
77
|
+
* edgeColorBy="source"
|
|
78
|
+
* padAngle={0.05}
|
|
79
|
+
* groupWidth={30}
|
|
80
|
+
* />
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```tsx
|
|
85
|
+
* // With sorting and labels
|
|
86
|
+
* <ChordDiagram
|
|
87
|
+
* edges={edges}
|
|
88
|
+
* sortGroups={(a, b) => b.value - a.value}
|
|
89
|
+
* nodeLabel="name"
|
|
90
|
+
* showLabels={true}
|
|
91
|
+
* />
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @remarks
|
|
95
|
+
* This component wraps {@link NetworkFrame} with sensible defaults for chord diagrams.
|
|
96
|
+
* Chord diagrams work best when there are asymmetric relationships and self-loops.
|
|
97
|
+
*
|
|
98
|
+
* **Data Requirements:**
|
|
99
|
+
* - Edges must have source, target, and value properties
|
|
100
|
+
* - Self-loops (source === target) are displayed as curved arcs
|
|
101
|
+
* - Reciprocal edges show the asymmetry in relationships
|
|
102
|
+
*
|
|
103
|
+
* **Breadcrumb to advanced usage:**
|
|
104
|
+
* - Use the `frameProps` prop to pass any NetworkFrame prop
|
|
105
|
+
* - See NetworkFrame documentation: https://semiotic.nteract.io/guides/network-frame
|
|
106
|
+
* - All NetworkFrame props are available via `frameProps`
|
|
107
|
+
*
|
|
108
|
+
* @param props - ChordDiagram configuration
|
|
109
|
+
* @returns Rendered chord diagram
|
|
110
|
+
*/
|
|
111
|
+
function ChordDiagram(props) {
|
|
112
|
+
const { nodes, edges, width = 600, height = 600, margin = { top: 50, bottom: 50, left: 50, right: 50 }, className, title, sourceAccessor = "source", targetAccessor = "target", valueAccessor = "value", nodeIdAccessor = "id", colorBy, colorScheme = "category10", edgeColorBy = "source", padAngle = 0.01, groupWidth = 20, sortGroups, nodeLabel, showLabels = true, enableHover = true, edgeOpacity = 0.5, tooltip, frameProps = {} } = props;
|
|
113
|
+
// Safe data defaults (hooks must always run)
|
|
114
|
+
const safeEdges = edges || [];
|
|
115
|
+
// Infer nodes from edges if not provided
|
|
116
|
+
const inferredNodes = (0, react_1.useMemo)(() => {
|
|
117
|
+
if (nodes && nodes.length > 0)
|
|
118
|
+
return nodes;
|
|
119
|
+
const nodeSet = new Set();
|
|
120
|
+
safeEdges.forEach((edge) => {
|
|
121
|
+
const sourceId = typeof sourceAccessor === "function"
|
|
122
|
+
? sourceAccessor(edge)
|
|
123
|
+
: edge[sourceAccessor];
|
|
124
|
+
const targetId = typeof targetAccessor === "function"
|
|
125
|
+
? targetAccessor(edge)
|
|
126
|
+
: edge[targetAccessor];
|
|
127
|
+
nodeSet.add(sourceId);
|
|
128
|
+
nodeSet.add(targetId);
|
|
129
|
+
});
|
|
130
|
+
return Array.from(nodeSet).map((id) => ({ id }));
|
|
131
|
+
}, [nodes, safeEdges, sourceAccessor, targetAccessor]);
|
|
132
|
+
// Create color scale if colorBy is specified
|
|
133
|
+
const colorScale = (0, hooks_1.useColorScale)(inferredNodes, colorBy, colorScheme);
|
|
134
|
+
// Node style function
|
|
135
|
+
const nodeStyle = (0, react_1.useMemo)(() => {
|
|
136
|
+
return (d, i) => {
|
|
137
|
+
const baseStyle = {
|
|
138
|
+
stroke: "black",
|
|
139
|
+
strokeWidth: 1
|
|
140
|
+
};
|
|
141
|
+
// Apply color
|
|
142
|
+
if (colorBy) {
|
|
143
|
+
baseStyle.fill = (0, colorUtils_1.getColor)(d, colorBy, colorScale);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
// Default: color by index using the color scheme
|
|
147
|
+
const palette = Array.isArray(colorScheme)
|
|
148
|
+
? colorScheme
|
|
149
|
+
: (colorUtils_1.COLOR_SCHEMES[colorScheme] || colorUtils_1.DEFAULT_COLORS);
|
|
150
|
+
const colors = Array.isArray(palette) ? palette : colorUtils_1.DEFAULT_COLORS;
|
|
151
|
+
baseStyle.fill = colors[i % colors.length];
|
|
152
|
+
}
|
|
153
|
+
return baseStyle;
|
|
154
|
+
};
|
|
155
|
+
}, [colorBy, colorScale, colorScheme, inferredNodes]);
|
|
156
|
+
// Edge style function
|
|
157
|
+
const edgeStyle = (0, react_1.useMemo)(() => {
|
|
158
|
+
return (d) => {
|
|
159
|
+
const baseStyle = {
|
|
160
|
+
stroke: "black",
|
|
161
|
+
strokeWidth: 0.5,
|
|
162
|
+
fillOpacity: edgeOpacity,
|
|
163
|
+
strokeOpacity: edgeOpacity
|
|
164
|
+
};
|
|
165
|
+
// Apply color based on edge coloring strategy
|
|
166
|
+
if (typeof edgeColorBy === "function") {
|
|
167
|
+
baseStyle.fill = edgeColorBy(d);
|
|
168
|
+
}
|
|
169
|
+
else if (edgeColorBy === "source") {
|
|
170
|
+
if (colorBy) {
|
|
171
|
+
baseStyle.fill = (0, colorUtils_1.getColor)(d.source, colorBy, colorScale);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
baseStyle.fill = nodeStyle(d.source, d.source.index).fill;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
else if (edgeColorBy === "target") {
|
|
178
|
+
if (colorBy) {
|
|
179
|
+
baseStyle.fill = (0, colorUtils_1.getColor)(d.target, colorBy, colorScale);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
baseStyle.fill = nodeStyle(d.target, d.target.index).fill;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return baseStyle;
|
|
186
|
+
};
|
|
187
|
+
}, [edgeColorBy, colorBy, colorScale, nodeStyle, edgeOpacity]);
|
|
188
|
+
// Node label function
|
|
189
|
+
const nodeLabelFn = (0, react_1.useMemo)(() => {
|
|
190
|
+
if (!showLabels)
|
|
191
|
+
return undefined;
|
|
192
|
+
const accessor = nodeLabel || nodeIdAccessor;
|
|
193
|
+
return (d) => {
|
|
194
|
+
if (typeof accessor === "function")
|
|
195
|
+
return accessor(d);
|
|
196
|
+
return d[accessor];
|
|
197
|
+
};
|
|
198
|
+
}, [showLabels, nodeLabel, nodeIdAccessor]);
|
|
199
|
+
// Build network type configuration
|
|
200
|
+
const networkType = (0, react_1.useMemo)(() => {
|
|
201
|
+
const config = {
|
|
202
|
+
type: "chord",
|
|
203
|
+
padAngle,
|
|
204
|
+
groupWidth
|
|
205
|
+
};
|
|
206
|
+
if (sortGroups) {
|
|
207
|
+
config.sortGroups = sortGroups;
|
|
208
|
+
}
|
|
209
|
+
return config;
|
|
210
|
+
}, [padAngle, groupWidth, sortGroups]);
|
|
211
|
+
// Validate data (after all hooks)
|
|
212
|
+
const error = (0, validateChartData_1.validateNetworkData)({
|
|
213
|
+
componentName: "ChordDiagram",
|
|
214
|
+
edges,
|
|
215
|
+
edgesRequired: true,
|
|
216
|
+
});
|
|
217
|
+
if (error)
|
|
218
|
+
return React.createElement(ChartError_1.default, { componentName: "ChordDiagram", message: error, width: width, height: height });
|
|
219
|
+
// Build NetworkFrame props
|
|
220
|
+
const networkFrameProps = {
|
|
221
|
+
size: [width, height],
|
|
222
|
+
nodes: inferredNodes,
|
|
223
|
+
edges: safeEdges,
|
|
224
|
+
nodeStyle,
|
|
225
|
+
edgeStyle,
|
|
226
|
+
nodeIDAccessor: nodeIdAccessor,
|
|
227
|
+
sourceAccessor,
|
|
228
|
+
targetAccessor,
|
|
229
|
+
edgeWidthAccessor: valueAccessor,
|
|
230
|
+
networkType,
|
|
231
|
+
hoverAnnotation: enableHover,
|
|
232
|
+
margin,
|
|
233
|
+
nodeSizeAccessor: () => 5, // Small size for hover target
|
|
234
|
+
...(nodeLabelFn && { nodeLabels: nodeLabelFn }),
|
|
235
|
+
...(className && { className }),
|
|
236
|
+
...(title && { title }),
|
|
237
|
+
// Add tooltip support
|
|
238
|
+
...(tooltip && { tooltipContent: (0, Tooltip_1.normalizeTooltip)(tooltip) }),
|
|
239
|
+
// Allow frameProps to override defaults
|
|
240
|
+
transition: true,
|
|
241
|
+
...frameProps,
|
|
242
|
+
_layoutMap: { chord: chordLayout_1.chordLayout }
|
|
243
|
+
};
|
|
244
|
+
return React.createElement(NetworkFrame_1.default, { ...networkFrameProps });
|
|
245
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.CirclePack = CirclePack;
|
|
41
|
+
const React = __importStar(require("react"));
|
|
42
|
+
const react_1 = require("react");
|
|
43
|
+
const NetworkFrame_1 = __importDefault(require("../../NetworkFrame"));
|
|
44
|
+
const colorUtils_1 = require("../shared/colorUtils");
|
|
45
|
+
const Tooltip_1 = require("../../Tooltip/Tooltip");
|
|
46
|
+
const hooks_1 = require("../shared/hooks");
|
|
47
|
+
const ChartError_1 = __importDefault(require("../shared/ChartError"));
|
|
48
|
+
const validateChartData_1 = require("../shared/validateChartData");
|
|
49
|
+
const hierarchyLayout_1 = require("../../processing/layouts/hierarchyLayout");
|
|
50
|
+
/**
|
|
51
|
+
* CirclePack - Visualize hierarchical data as nested circles.
|
|
52
|
+
*
|
|
53
|
+
* A simplified wrapper around NetworkFrame with circlepack layout.
|
|
54
|
+
* Each circle's area is proportional to its value.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```tsx
|
|
58
|
+
* <CirclePack
|
|
59
|
+
* data={{
|
|
60
|
+
* name: 'root',
|
|
61
|
+
* children: [
|
|
62
|
+
* {name: 'A', value: 100},
|
|
63
|
+
* {name: 'B', value: 200},
|
|
64
|
+
* {name: 'C', value: 150}
|
|
65
|
+
* ]
|
|
66
|
+
* }}
|
|
67
|
+
* colorByDepth
|
|
68
|
+
* />
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
function CirclePack(props) {
|
|
72
|
+
const { data, width = 600, height = 600, margin = { top: 10, bottom: 10, left: 10, right: 10 }, className, title, childrenAccessor = "children", valueAccessor = "value", nodeIdAccessor = "name", colorBy, colorScheme = "category10", colorByDepth = false, showLabels = true, nodeLabel, circleOpacity = 0.7, enableHover = true, tooltip, frameProps = {} } = props;
|
|
73
|
+
// Flatten hierarchy to get all nodes for color scale
|
|
74
|
+
const allNodes = (0, react_1.useMemo)(() => {
|
|
75
|
+
if (!data)
|
|
76
|
+
return [];
|
|
77
|
+
const nodes = [];
|
|
78
|
+
const traverse = (node) => {
|
|
79
|
+
nodes.push(node);
|
|
80
|
+
const children = typeof childrenAccessor === "function"
|
|
81
|
+
? childrenAccessor(node)
|
|
82
|
+
: node[childrenAccessor];
|
|
83
|
+
if (children && Array.isArray(children)) {
|
|
84
|
+
children.forEach(traverse);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
traverse(data);
|
|
88
|
+
return nodes;
|
|
89
|
+
}, [data, childrenAccessor]);
|
|
90
|
+
// Create color scale
|
|
91
|
+
const colorScale = (0, react_1.useMemo)(() => {
|
|
92
|
+
if (colorByDepth) {
|
|
93
|
+
return (0, colorUtils_1.createColorScale)(allNodes.map((_, idx) => ({ depth: idx % 5 })), "depth", colorScheme);
|
|
94
|
+
}
|
|
95
|
+
if (!colorBy || typeof colorBy === "function") {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
return (0, colorUtils_1.createColorScale)(allNodes, colorBy, colorScheme);
|
|
99
|
+
}, [allNodes, colorBy, colorByDepth, colorScheme]);
|
|
100
|
+
// Node style function
|
|
101
|
+
const nodeStyleFn = (0, react_1.useMemo)(() => {
|
|
102
|
+
return (d) => {
|
|
103
|
+
const baseStyle = {
|
|
104
|
+
stroke: "currentColor",
|
|
105
|
+
strokeWidth: 1,
|
|
106
|
+
strokeOpacity: 0.3,
|
|
107
|
+
fillOpacity: circleOpacity
|
|
108
|
+
};
|
|
109
|
+
if (colorByDepth) {
|
|
110
|
+
baseStyle.fill = (0, colorUtils_1.getColor)({ depth: d.depth || 0 }, "depth", colorScale);
|
|
111
|
+
}
|
|
112
|
+
else if (colorBy) {
|
|
113
|
+
baseStyle.fill = (0, colorUtils_1.getColor)(d, colorBy, colorScale);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
baseStyle.fill = hooks_1.DEFAULT_COLOR;
|
|
117
|
+
}
|
|
118
|
+
return baseStyle;
|
|
119
|
+
};
|
|
120
|
+
}, [colorBy, colorByDepth, colorScale, circleOpacity]);
|
|
121
|
+
// Hierarchy configuration
|
|
122
|
+
const hierarchyChildren = (0, react_1.useMemo)(() => {
|
|
123
|
+
if (typeof childrenAccessor === "function") {
|
|
124
|
+
return childrenAccessor;
|
|
125
|
+
}
|
|
126
|
+
return (d) => d[childrenAccessor];
|
|
127
|
+
}, [childrenAccessor]);
|
|
128
|
+
const hierarchySum = (0, react_1.useMemo)(() => {
|
|
129
|
+
if (typeof valueAccessor === "function") {
|
|
130
|
+
return valueAccessor;
|
|
131
|
+
}
|
|
132
|
+
return (d) => d[valueAccessor] || 1;
|
|
133
|
+
}, [valueAccessor]);
|
|
134
|
+
// Node label function
|
|
135
|
+
const nodeLabelFn = (0, react_1.useMemo)(() => {
|
|
136
|
+
if (!showLabels)
|
|
137
|
+
return undefined;
|
|
138
|
+
if (nodeLabel) {
|
|
139
|
+
if (typeof nodeLabel === "function")
|
|
140
|
+
return nodeLabel;
|
|
141
|
+
return (d) => d[nodeLabel];
|
|
142
|
+
}
|
|
143
|
+
if (typeof nodeIdAccessor === "function")
|
|
144
|
+
return nodeIdAccessor;
|
|
145
|
+
return (d) => d[nodeIdAccessor];
|
|
146
|
+
}, [showLabels, nodeLabel, nodeIdAccessor]);
|
|
147
|
+
// Validate data (after all hooks)
|
|
148
|
+
const error = (0, validateChartData_1.validateObjectData)({
|
|
149
|
+
componentName: "CirclePack",
|
|
150
|
+
data,
|
|
151
|
+
});
|
|
152
|
+
if (error)
|
|
153
|
+
return React.createElement(ChartError_1.default, { componentName: "CirclePack", message: error, width: width, height: height });
|
|
154
|
+
// Build NetworkFrame props
|
|
155
|
+
const networkFrameProps = {
|
|
156
|
+
size: [width, height],
|
|
157
|
+
edges: data,
|
|
158
|
+
nodeStyle: nodeStyleFn,
|
|
159
|
+
edgeStyle: () => ({ fill: "none", stroke: "none" }),
|
|
160
|
+
nodeIDAccessor: nodeIdAccessor,
|
|
161
|
+
networkType: { type: "circlepack" },
|
|
162
|
+
hoverAnnotation: enableHover,
|
|
163
|
+
margin,
|
|
164
|
+
...(hierarchyChildren && {
|
|
165
|
+
hierarchyChildren: hierarchyChildren
|
|
166
|
+
}),
|
|
167
|
+
...(hierarchySum && { hierarchySum: hierarchySum }),
|
|
168
|
+
...(nodeLabelFn && { nodeLabels: nodeLabelFn }),
|
|
169
|
+
...(className && { className }),
|
|
170
|
+
...(title && { title }),
|
|
171
|
+
...(tooltip && { tooltipContent: (0, Tooltip_1.normalizeTooltip)(tooltip) }),
|
|
172
|
+
transition: true,
|
|
173
|
+
...frameProps,
|
|
174
|
+
_layoutMap: { circlepack: hierarchyLayout_1.hierarchyLayouts.circlepack }
|
|
175
|
+
};
|
|
176
|
+
return React.createElement(NetworkFrame_1.default, { ...networkFrameProps });
|
|
177
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.ForceDirectedGraph = ForceDirectedGraph;
|
|
41
|
+
const React = __importStar(require("react"));
|
|
42
|
+
const react_1 = require("react");
|
|
43
|
+
const NetworkFrame_1 = __importDefault(require("../../NetworkFrame"));
|
|
44
|
+
const colorUtils_1 = require("../shared/colorUtils");
|
|
45
|
+
const legendUtils_1 = require("../shared/legendUtils");
|
|
46
|
+
const Tooltip_1 = require("../../Tooltip/Tooltip");
|
|
47
|
+
const hooks_1 = require("../shared/hooks");
|
|
48
|
+
const ChartError_1 = __importDefault(require("../shared/ChartError"));
|
|
49
|
+
const validateChartData_1 = require("../shared/validateChartData");
|
|
50
|
+
const forceLayout_1 = require("../../processing/layouts/forceLayout");
|
|
51
|
+
/**
|
|
52
|
+
* ForceDirectedGraph - Visualize network relationships with force-directed layout
|
|
53
|
+
*
|
|
54
|
+
* A simplified wrapper around NetworkFrame for creating force-directed graphs.
|
|
55
|
+
* Perfect for visualizing connections, communities, and network structures.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* // Simple force-directed graph
|
|
60
|
+
* <ForceDirectedGraph
|
|
61
|
+
* nodes={[
|
|
62
|
+
* {id: 'A', label: 'Node A'},
|
|
63
|
+
* {id: 'B', label: 'Node B'},
|
|
64
|
+
* {id: 'C', label: 'Node C'}
|
|
65
|
+
* ]}
|
|
66
|
+
* edges={[
|
|
67
|
+
* {source: 'A', target: 'B'},
|
|
68
|
+
* {source: 'B', target: 'C'}
|
|
69
|
+
* ]}
|
|
70
|
+
* />
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```tsx
|
|
75
|
+
* // With color and size encoding
|
|
76
|
+
* <ForceDirectedGraph
|
|
77
|
+
* nodes={nodes}
|
|
78
|
+
* edges={edges}
|
|
79
|
+
* colorBy="group"
|
|
80
|
+
* nodeSize="connections"
|
|
81
|
+
* nodeSizeRange={[5, 25]}
|
|
82
|
+
* showLabels={true}
|
|
83
|
+
* iterations={500}
|
|
84
|
+
* />
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```tsx
|
|
89
|
+
* // Advanced: Override NetworkFrame props
|
|
90
|
+
* <ForceDirectedGraph
|
|
91
|
+
* nodes={nodes}
|
|
92
|
+
* edges={edges}
|
|
93
|
+
* frameProps={{
|
|
94
|
+
* networkType: { type: "force", iterations: 500, edgeStrength: 2 },
|
|
95
|
+
* customNodeIcon: ({ d }) => <circle r={10} fill="gold" />
|
|
96
|
+
* }}
|
|
97
|
+
* />
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @remarks
|
|
101
|
+
* This component wraps {@link NetworkFrame} with sensible defaults for force-directed graphs.
|
|
102
|
+
* For more advanced features like custom layouts, hierarchical networks, or complex interactions,
|
|
103
|
+
* use NetworkFrame directly.
|
|
104
|
+
*
|
|
105
|
+
* **Breadcrumb to advanced usage:**
|
|
106
|
+
* - Use the `frameProps` prop to pass any NetworkFrame prop
|
|
107
|
+
* - See NetworkFrame documentation: https://semiotic.nteract.io/guides/network-frame
|
|
108
|
+
* - All NetworkFrame props are available via `frameProps`
|
|
109
|
+
*
|
|
110
|
+
* @param props - ForceDirectedGraph configuration
|
|
111
|
+
* @returns Rendered force-directed graph
|
|
112
|
+
*/
|
|
113
|
+
function ForceDirectedGraph(props) {
|
|
114
|
+
const { nodes, edges, width = 600, height = 600, margin: userMargin, className, title, nodeIDAccessor = "id", sourceAccessor = "source", targetAccessor = "target", nodeLabel, colorBy, colorScheme = "category10", nodeSize = 8, nodeSizeRange = [5, 20], edgeWidth = 1, edgeColor = "#999", edgeOpacity = 0.6, iterations = 300, forceStrength = 0.1, showLabels = false, enableHover = true, showLegend, tooltip, frameProps = {} } = props;
|
|
115
|
+
// Safe data defaults (hooks must always run)
|
|
116
|
+
const safeNodes = nodes || [];
|
|
117
|
+
const safeEdges = edges || [];
|
|
118
|
+
// Create color scale if colorBy is specified
|
|
119
|
+
const colorScale = (0, hooks_1.useColorScale)(safeNodes, colorBy, colorScheme);
|
|
120
|
+
// Calculate node size domain if dynamic sizing
|
|
121
|
+
const nodeSizeDomain = (0, react_1.useMemo)(() => {
|
|
122
|
+
if (typeof nodeSize === "number")
|
|
123
|
+
return undefined;
|
|
124
|
+
if (!nodeSize)
|
|
125
|
+
return undefined;
|
|
126
|
+
const sizes = safeNodes.map((d) => {
|
|
127
|
+
if (typeof nodeSize === "function") {
|
|
128
|
+
return nodeSize(d);
|
|
129
|
+
}
|
|
130
|
+
return d[nodeSize];
|
|
131
|
+
});
|
|
132
|
+
return [Math.min(...sizes), Math.max(...sizes)];
|
|
133
|
+
}, [safeNodes, nodeSize]);
|
|
134
|
+
// Node style function
|
|
135
|
+
const nodeStyle = (0, react_1.useMemo)(() => {
|
|
136
|
+
return (d) => {
|
|
137
|
+
const baseStyle = {};
|
|
138
|
+
// Apply color
|
|
139
|
+
if (colorBy) {
|
|
140
|
+
baseStyle.fill = (0, colorUtils_1.getColor)(d, colorBy, colorScale);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
baseStyle.fill = hooks_1.DEFAULT_COLOR;
|
|
144
|
+
}
|
|
145
|
+
// Apply size
|
|
146
|
+
if (typeof nodeSize === "number") {
|
|
147
|
+
baseStyle.r = nodeSize;
|
|
148
|
+
}
|
|
149
|
+
else if (nodeSize) {
|
|
150
|
+
baseStyle.r = (0, colorUtils_1.getSize)(d, nodeSize, nodeSizeRange, nodeSizeDomain);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
baseStyle.r = 8;
|
|
154
|
+
}
|
|
155
|
+
return baseStyle;
|
|
156
|
+
};
|
|
157
|
+
}, [colorBy, colorScale, nodeSize, nodeSizeRange, nodeSizeDomain]);
|
|
158
|
+
// Edge style function
|
|
159
|
+
const edgeStyle = (0, react_1.useMemo)(() => {
|
|
160
|
+
return (d) => {
|
|
161
|
+
const baseStyle = {
|
|
162
|
+
stroke: edgeColor,
|
|
163
|
+
strokeOpacity: edgeOpacity
|
|
164
|
+
};
|
|
165
|
+
// Apply width
|
|
166
|
+
if (typeof edgeWidth === "number") {
|
|
167
|
+
baseStyle.strokeWidth = edgeWidth;
|
|
168
|
+
}
|
|
169
|
+
else if (typeof edgeWidth === "function") {
|
|
170
|
+
baseStyle.strokeWidth = edgeWidth(d);
|
|
171
|
+
}
|
|
172
|
+
else if (edgeWidth) {
|
|
173
|
+
baseStyle.strokeWidth = d[edgeWidth];
|
|
174
|
+
}
|
|
175
|
+
return baseStyle;
|
|
176
|
+
};
|
|
177
|
+
}, [edgeWidth, edgeColor, edgeOpacity]);
|
|
178
|
+
// Node label function
|
|
179
|
+
const nodeLabelFn = (0, react_1.useMemo)(() => {
|
|
180
|
+
if (!showLabels || !nodeLabel)
|
|
181
|
+
return undefined;
|
|
182
|
+
return (d) => {
|
|
183
|
+
if (typeof nodeLabel === "function") {
|
|
184
|
+
return nodeLabel(d);
|
|
185
|
+
}
|
|
186
|
+
return d[nodeLabel];
|
|
187
|
+
};
|
|
188
|
+
}, [showLabels, nodeLabel]);
|
|
189
|
+
// Determine if we should show legend
|
|
190
|
+
const shouldShowLegend = showLegend !== undefined ? showLegend : !!colorBy;
|
|
191
|
+
// Build legend if needed
|
|
192
|
+
const legend = (0, react_1.useMemo)(() => {
|
|
193
|
+
if (!shouldShowLegend || !colorBy)
|
|
194
|
+
return undefined;
|
|
195
|
+
return (0, legendUtils_1.createLegend)({
|
|
196
|
+
data: safeNodes,
|
|
197
|
+
colorBy,
|
|
198
|
+
colorScale,
|
|
199
|
+
getColor: colorUtils_1.getColor
|
|
200
|
+
});
|
|
201
|
+
}, [shouldShowLegend, colorBy, safeNodes, colorScale]);
|
|
202
|
+
// Adjust margin for legend if present
|
|
203
|
+
const margin = (0, react_1.useMemo)(() => {
|
|
204
|
+
const defaultMargin = { top: 20, bottom: 20, left: 20, right: 20 };
|
|
205
|
+
const finalMargin = { ...defaultMargin, ...userMargin };
|
|
206
|
+
// If legend is present and right margin is too small, increase it
|
|
207
|
+
if (legend && finalMargin.right < 120) {
|
|
208
|
+
finalMargin.right = 120;
|
|
209
|
+
}
|
|
210
|
+
return finalMargin;
|
|
211
|
+
}, [userMargin, legend]);
|
|
212
|
+
// Validate data (after all hooks)
|
|
213
|
+
const error = (0, validateChartData_1.validateNetworkData)({
|
|
214
|
+
componentName: "ForceDirectedGraph",
|
|
215
|
+
nodes,
|
|
216
|
+
edges,
|
|
217
|
+
nodesRequired: true,
|
|
218
|
+
edgesRequired: true,
|
|
219
|
+
accessors: { nodeIDAccessor },
|
|
220
|
+
});
|
|
221
|
+
if (error)
|
|
222
|
+
return React.createElement(ChartError_1.default, { componentName: "ForceDirectedGraph", message: error, width: width, height: height });
|
|
223
|
+
// Build NetworkFrame props
|
|
224
|
+
const networkFrameProps = {
|
|
225
|
+
size: [width, height],
|
|
226
|
+
nodes: safeNodes,
|
|
227
|
+
edges: safeEdges,
|
|
228
|
+
nodeIDAccessor,
|
|
229
|
+
sourceAccessor,
|
|
230
|
+
targetAccessor,
|
|
231
|
+
networkType: { type: "force", iterations, edgeStrength: forceStrength },
|
|
232
|
+
nodeStyle,
|
|
233
|
+
edgeStyle,
|
|
234
|
+
hoverAnnotation: enableHover,
|
|
235
|
+
margin,
|
|
236
|
+
...(legend && { legend }),
|
|
237
|
+
...(nodeLabelFn && { nodeLabels: nodeLabelFn }),
|
|
238
|
+
...(className && { className }),
|
|
239
|
+
...(title && { title }),
|
|
240
|
+
// Add tooltip support
|
|
241
|
+
...(tooltip && { tooltipContent: (0, Tooltip_1.normalizeTooltip)(tooltip) }),
|
|
242
|
+
// Allow frameProps to override defaults
|
|
243
|
+
transition: true,
|
|
244
|
+
...frameProps,
|
|
245
|
+
_layoutMap: { force: forceLayout_1.forceLayout }
|
|
246
|
+
};
|
|
247
|
+
return React.createElement(NetworkFrame_1.default, { ...networkFrameProps });
|
|
248
|
+
}
|