semiotic 2.0.3 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +828 -0
- package/README.md +215 -37
- package/ai/cli.js +48 -0
- package/ai/dist/ai/componentRegistry.js +45 -0
- package/ai/dist/ai/mcp-server.js +99 -0
- package/ai/dist/ai/renderHOCToSVG.js +77 -0
- package/ai/dist/src/components/Annotation.js +358 -0
- package/ai/dist/src/components/AnnotationLayer/AnnotationLayer.js +369 -0
- package/ai/dist/src/components/Axis/Axis.js +374 -0
- package/ai/dist/src/components/Axis/axisTitle.js +14 -0
- package/ai/dist/src/components/Axis/index.js +7 -0
- package/ai/dist/src/components/Axis/summaryGraphic.js +37 -0
- package/ai/dist/src/components/Brush.js +84 -0
- package/ai/dist/src/components/ChartErrorBoundary.js +91 -0
- package/ai/dist/src/components/DividedLine.js +65 -0
- package/ai/dist/src/components/Legend.js +140 -0
- package/ai/dist/src/components/LinkedCharts.js +95 -0
- package/ai/dist/src/components/ThemeProvider.js +79 -0
- package/ai/dist/src/components/Tooltip/Tooltip.js +309 -0
- package/ai/dist/src/components/TooltipPositioner/index.js +132 -0
- package/ai/dist/src/components/annotationLayerBehavior/annotationHandling.js +73 -0
- package/ai/dist/src/components/annotationLayerBehavior/d3labeler.js +254 -0
- package/ai/dist/src/components/annotationRules/baseRules.js +150 -0
- package/ai/dist/src/components/annotationRules/networkframeRules.js +196 -0
- package/ai/dist/src/components/annotationRules/xyframeRules.js +297 -0
- package/ai/dist/src/components/batchWork.js +35 -0
- package/ai/dist/src/components/charts/index.js +109 -0
- package/ai/dist/src/components/charts/network/ChordDiagram.js +142 -0
- package/ai/dist/src/components/charts/network/CirclePack.js +108 -0
- package/ai/dist/src/components/charts/network/ForceDirectedGraph.js +121 -0
- package/ai/dist/src/components/charts/network/SankeyDiagram.js +155 -0
- package/ai/dist/src/components/charts/network/TreeDiagram.js +110 -0
- package/ai/dist/src/components/charts/network/Treemap.js +106 -0
- package/ai/dist/src/components/charts/ordinal/BarChart.js +156 -0
- package/ai/dist/src/components/charts/ordinal/BoxPlot.js +139 -0
- package/ai/dist/src/components/charts/ordinal/DonutChart.js +130 -0
- package/ai/dist/src/components/charts/ordinal/DotPlot.js +126 -0
- package/ai/dist/src/components/charts/ordinal/GroupedBarChart.js +129 -0
- package/ai/dist/src/components/charts/ordinal/Histogram.js +132 -0
- package/ai/dist/src/components/charts/ordinal/PieChart.js +128 -0
- package/ai/dist/src/components/charts/ordinal/RidgelinePlot.js +130 -0
- package/ai/dist/src/components/charts/ordinal/StackedBarChart.js +130 -0
- package/ai/dist/src/components/charts/ordinal/SwarmPlot.js +147 -0
- package/ai/dist/src/components/charts/ordinal/ViolinPlot.js +138 -0
- package/ai/dist/src/components/charts/realtime/RealtimeHeatmap.js +79 -0
- package/ai/dist/src/components/charts/realtime/RealtimeHistogram.js +114 -0
- package/ai/dist/src/components/charts/realtime/RealtimeLineChart.js +93 -0
- package/ai/dist/src/components/charts/realtime/RealtimeSwarmChart.js +105 -0
- package/ai/dist/src/components/charts/realtime/RealtimeWaterfallChart.js +106 -0
- package/ai/dist/src/components/charts/shared/ChartError.js +72 -0
- package/ai/dist/src/components/charts/shared/colorUtils.js +138 -0
- package/ai/dist/src/components/charts/shared/formatUtils.js +213 -0
- package/ai/dist/src/components/charts/shared/hooks.js +49 -0
- package/ai/dist/src/components/charts/shared/legendUtils.js +57 -0
- package/ai/dist/src/components/charts/shared/selectionUtils.js +67 -0
- package/ai/dist/src/components/charts/shared/tooltipUtils.js +79 -0
- package/ai/dist/src/components/charts/shared/types.js +2 -0
- package/ai/dist/src/components/charts/shared/validateChartData.js +82 -0
- package/ai/dist/src/components/charts/shared/validateProps.js +736 -0
- package/ai/dist/src/components/charts/xy/AreaChart.js +230 -0
- package/ai/dist/src/components/charts/xy/BubbleChart.js +251 -0
- package/ai/dist/src/components/charts/xy/Heatmap.js +235 -0
- package/ai/dist/src/components/charts/xy/LineChart.js +307 -0
- package/ai/dist/src/components/charts/xy/MinimapChart.js +298 -0
- package/ai/dist/src/components/charts/xy/Scatterplot.js +172 -0
- package/ai/dist/src/components/charts/xy/ScatterplotMatrix.js +426 -0
- package/ai/dist/src/components/charts/xy/StackedAreaChart.js +231 -0
- package/ai/dist/src/components/constants/coordinateNames.js +11 -0
- package/ai/dist/src/components/constants/frame_props.js +251 -0
- package/ai/dist/src/components/data/dataFunctions.js +487 -0
- package/ai/dist/src/components/data/multiAccessorUtils.js +14 -0
- package/ai/dist/src/components/data/transforms.js +143 -0
- package/ai/dist/src/components/data/unflowedFunctions.js +5 -0
- package/ai/dist/src/components/export/exportChart.js +121 -0
- package/ai/dist/src/components/generic_utilities/functions.js +5 -0
- package/ai/dist/src/components/geometry/areaDrawing.js +312 -0
- package/ai/dist/src/components/geometry/contourLayout.js +73 -0
- package/ai/dist/src/components/geometry/hexbinLayout.js +163 -0
- package/ai/dist/src/components/geometry/lineDrawing.js +356 -0
- package/ai/dist/src/components/geometry/sankeyLinks.js +331 -0
- package/ai/dist/src/components/geometry/summaryLayouts.js +136 -0
- package/ai/dist/src/components/index.js +18 -0
- package/ai/dist/src/components/processing/InteractionItems.js +223 -0
- package/ai/dist/src/components/processing/hierarchyUtils.js +104 -0
- package/ai/dist/src/components/processing/layouts/chordLayout.js +58 -0
- package/ai/dist/src/components/processing/layouts/forceLayout.js +142 -0
- package/ai/dist/src/components/processing/layouts/hierarchyLayout.js +31 -0
- package/ai/dist/src/components/processing/layouts/index.js +32 -0
- package/ai/dist/src/components/processing/layouts/sankeyLayout.js +96 -0
- package/ai/dist/src/components/processing/layouts/simpleLayouts.js +34 -0
- package/ai/dist/src/components/processing/layouts/types.js +2 -0
- package/ai/dist/src/components/processing/networkDefaults.js +39 -0
- package/ai/dist/src/components/realtime/BinAccumulator.js +36 -0
- package/ai/dist/src/components/realtime/IncrementalExtent.js +55 -0
- package/ai/dist/src/components/realtime/RingBuffer.js +104 -0
- package/ai/dist/src/components/realtime/renderers/barRenderer.js +133 -0
- package/ai/dist/src/components/realtime/renderers/candlestickRenderer.js +7 -0
- package/ai/dist/src/components/realtime/renderers/lineRenderer.js +164 -0
- package/ai/dist/src/components/realtime/renderers/swarmRenderer.js +91 -0
- package/ai/dist/src/components/realtime/renderers/types.js +2 -0
- package/ai/dist/src/components/realtime/renderers/waterfallRenderer.js +163 -0
- package/ai/dist/src/components/realtime/types.js +2 -0
- package/ai/dist/src/components/semiotic-ai.js +89 -0
- package/ai/dist/src/components/semiotic-data.js +12 -0
- package/ai/dist/src/components/semiotic-network.js +38 -0
- package/ai/dist/src/components/semiotic-ordinal.js +28 -0
- package/ai/dist/src/components/semiotic-realtime.js +30 -0
- package/ai/dist/src/components/semiotic-server.js +8 -0
- package/ai/dist/src/components/semiotic-xy.js +35 -0
- package/ai/dist/src/components/semiotic.js +109 -0
- package/ai/dist/src/components/server/renderToStaticSVG.js +594 -0
- package/ai/dist/src/components/store/SelectionStore.js +91 -0
- package/ai/dist/src/components/store/ThemeStore.js +78 -0
- package/ai/dist/src/components/store/TooltipStore.js +13 -0
- package/ai/dist/src/components/store/createStore.js +81 -0
- package/ai/dist/src/components/store/useSelection.js +133 -0
- package/ai/dist/src/components/stream/CanvasHitTester.js +164 -0
- package/ai/dist/src/components/stream/DataSourceAdapter.js +99 -0
- package/ai/dist/src/components/stream/MarginalGraphics.js +266 -0
- package/ai/dist/src/components/stream/NetworkCanvasHitTester.js +228 -0
- package/ai/dist/src/components/stream/NetworkPipelineStore.js +498 -0
- package/ai/dist/src/components/stream/NetworkSVGOverlay.js +70 -0
- package/ai/dist/src/components/stream/NetworkSceneGraph.js +38 -0
- package/ai/dist/src/components/stream/OrdinalCanvasHitTester.js +146 -0
- package/ai/dist/src/components/stream/OrdinalPipelineStore.js +786 -0
- package/ai/dist/src/components/stream/OrdinalSVGOverlay.js +130 -0
- package/ai/dist/src/components/stream/ParticlePool.js +174 -0
- package/ai/dist/src/components/stream/PipelineStore.js +1243 -0
- package/ai/dist/src/components/stream/SVGOverlay.js +129 -0
- package/ai/dist/src/components/stream/SceneGraph.js +132 -0
- package/ai/dist/src/components/stream/StreamNetworkFrame.js +561 -0
- package/ai/dist/src/components/stream/StreamOrdinalFrame.js +492 -0
- package/ai/dist/src/components/stream/StreamXYFrame.js +590 -0
- package/ai/dist/src/components/stream/accessorUtils.js +20 -0
- package/ai/dist/src/components/stream/index.js +32 -0
- package/ai/dist/src/components/stream/layouts/chordLayoutPlugin.js +352 -0
- package/ai/dist/src/components/stream/layouts/forceLayoutPlugin.js +230 -0
- package/ai/dist/src/components/stream/layouts/hierarchyLayoutPlugin.js +568 -0
- package/ai/dist/src/components/stream/layouts/index.js +28 -0
- package/ai/dist/src/components/stream/layouts/sankeyLayoutPlugin.js +245 -0
- package/ai/dist/src/components/stream/networkTypes.js +17 -0
- package/ai/dist/src/components/stream/ordinalSceneBuilders/barScene.js +126 -0
- package/ai/dist/src/components/stream/ordinalSceneBuilders/connectorScene.js +62 -0
- package/ai/dist/src/components/stream/ordinalSceneBuilders/pieScene.js +33 -0
- package/ai/dist/src/components/stream/ordinalSceneBuilders/pointScene.js +63 -0
- package/ai/dist/src/components/stream/ordinalSceneBuilders/statisticalScene.js +278 -0
- package/ai/dist/src/components/stream/ordinalSceneBuilders/timelineScene.js +30 -0
- package/ai/dist/src/components/stream/ordinalSceneBuilders/types.js +2 -0
- package/ai/dist/src/components/stream/ordinalTypes.js +2 -0
- package/ai/dist/src/components/stream/renderers/areaCanvasRenderer.js +48 -0
- package/ai/dist/src/components/stream/renderers/barCanvasRenderer.js +70 -0
- package/ai/dist/src/components/stream/renderers/boxplotCanvasRenderer.js +75 -0
- package/ai/dist/src/components/stream/renderers/candlestickCanvasRenderer.js +28 -0
- package/ai/dist/src/components/stream/renderers/connectorCanvasRenderer.js +47 -0
- package/ai/dist/src/components/stream/renderers/heatmapCanvasRenderer.js +31 -0
- package/ai/dist/src/components/stream/renderers/lineCanvasRenderer.js +140 -0
- package/ai/dist/src/components/stream/renderers/networkArcRenderer.js +38 -0
- package/ai/dist/src/components/stream/renderers/networkCircleRenderer.js +37 -0
- package/ai/dist/src/components/stream/renderers/networkEdgeRenderer.js +102 -0
- package/ai/dist/src/components/stream/renderers/networkParticleRenderer.js +63 -0
- package/ai/dist/src/components/stream/renderers/networkRectRenderer.js +35 -0
- package/ai/dist/src/components/stream/renderers/pointCanvasRenderer.js +38 -0
- package/ai/dist/src/components/stream/renderers/swarmCanvasRenderer.js +10 -0
- package/ai/dist/src/components/stream/renderers/types.js +2 -0
- package/ai/dist/src/components/stream/renderers/violinCanvasRenderer.js +47 -0
- package/ai/dist/src/components/stream/renderers/waterfallCanvasRenderer.js +38 -0
- package/ai/dist/src/components/stream/renderers/wedgeCanvasRenderer.js +33 -0
- package/ai/dist/src/components/stream/types.js +2 -0
- package/ai/dist/src/components/types/annotationTypes.js +2 -0
- package/ai/dist/src/components/types/canvasTypes.js +2 -0
- package/ai/dist/src/components/types/generalTypes.js +2 -0
- package/ai/dist/src/components/types/interactionTypes.js +2 -0
- package/ai/dist/src/components/types/legendTypes.js +2 -0
- package/ai/dist/src/components/types/networkTypes.js +2 -0
- package/ai/dist/src/components/types/ordinalTypes.js +2 -0
- package/ai/dist/src/components/types/xyTypes.js +2 -0
- package/ai/dist/src/components/useBoundingRect.js +24 -0
- package/ai/dist/src/components/visualizationLayerBehavior/axis.js +301 -0
- package/ai/dist/src/components/visualizationLayerBehavior/general.js +435 -0
- package/ai/dist/src/setupTests.js +4 -0
- package/ai/examples.md +489 -0
- package/ai/schema.json +1338 -0
- package/ai/system-prompt.md +41 -0
- package/dist/AnnotationLayer/AnnotationLayer.d.ts +0 -1
- package/dist/Axis/axisTitle.d.ts +3 -3
- package/dist/Axis/summaryGraphic.d.ts +1 -1
- package/dist/ChartErrorBoundary.d.ts +39 -0
- package/dist/LinkedCharts.d.ts +42 -0
- package/dist/ThemeProvider.d.ts +12 -0
- package/dist/Tooltip/Tooltip.d.ts +141 -0
- package/dist/TooltipPositioner/index.d.ts +1 -1
- package/dist/annotationLayerBehavior/annotationHandling.d.ts +2 -2
- package/dist/annotationRules/networkframeRules.d.ts +2 -2
- package/dist/annotationRules/xyframeRules.d.ts +2 -2
- package/dist/batchWork.d.ts +1 -1
- package/dist/charts/index.d.ts +74 -0
- package/dist/charts/network/ChordDiagram.d.ts +36 -0
- package/dist/charts/network/CirclePack.d.ts +32 -0
- package/dist/charts/network/ForceDirectedGraph.d.ts +38 -0
- package/dist/charts/network/SankeyDiagram.d.ts +38 -0
- package/dist/charts/network/TreeDiagram.d.ts +34 -0
- package/dist/charts/network/Treemap.d.ts +33 -0
- package/dist/charts/ordinal/BarChart.d.ts +32 -0
- package/dist/charts/ordinal/BoxPlot.d.ts +27 -0
- package/dist/charts/ordinal/DonutChart.d.ts +23 -0
- package/dist/charts/ordinal/DotPlot.d.ts +27 -0
- package/dist/charts/ordinal/GroupedBarChart.d.ts +26 -0
- package/dist/charts/ordinal/Histogram.d.ts +26 -0
- package/dist/charts/ordinal/PieChart.d.ts +21 -0
- package/dist/charts/ordinal/RidgelinePlot.d.ts +34 -0
- package/dist/charts/ordinal/StackedBarChart.d.ts +27 -0
- package/dist/charts/ordinal/SwarmPlot.d.ts +29 -0
- package/dist/charts/ordinal/ViolinPlot.d.ts +28 -0
- package/dist/charts/realtime/RealtimeHeatmap.d.ts +95 -0
- package/dist/charts/realtime/RealtimeHistogram.d.ts +119 -0
- package/dist/charts/realtime/RealtimeLineChart.d.ts +98 -0
- package/dist/charts/realtime/RealtimeSwarmChart.d.ts +100 -0
- package/dist/charts/realtime/RealtimeWaterfallChart.d.ts +97 -0
- package/dist/charts/shared/ChartError.d.ts +19 -0
- package/dist/charts/shared/colorUtils.d.ts +62 -0
- package/dist/charts/shared/formatUtils.d.ts +94 -0
- package/dist/charts/shared/hooks.d.ts +20 -0
- package/dist/charts/shared/legendUtils.d.ts +32 -0
- package/dist/charts/shared/selectionUtils.d.ts +51 -0
- package/dist/charts/shared/tooltipUtils.d.ts +18 -0
- package/dist/charts/shared/types.d.ts +97 -0
- package/dist/charts/shared/validateChartData.d.ts +41 -0
- package/dist/charts/shared/validateProps.d.ts +18 -0
- package/dist/charts/xy/AreaChart.d.ts +130 -0
- package/dist/charts/xy/BubbleChart.d.ts +164 -0
- package/dist/charts/xy/Heatmap.d.ts +156 -0
- package/dist/charts/xy/LineChart.d.ts +196 -0
- package/dist/charts/xy/MinimapChart.d.ts +73 -0
- package/dist/charts/xy/Scatterplot.d.ts +55 -0
- package/dist/charts/xy/ScatterplotMatrix.d.ts +71 -0
- package/dist/charts/xy/StackedAreaChart.d.ts +134 -0
- package/dist/constants/frame_props.d.ts +9 -0
- package/dist/data/dataFunctions.d.ts +10 -11
- package/dist/data/transforms.d.ts +45 -0
- package/dist/export/exportChart.d.ts +16 -0
- package/dist/{svg → geometry}/areaDrawing.d.ts +3 -13
- package/dist/geometry/contourLayout.d.ts +6 -0
- package/dist/geometry/hexbinLayout.d.ts +7 -0
- package/dist/{svg → geometry}/lineDrawing.d.ts +7 -35
- package/dist/geometry/sankeyLinks.d.ts +2 -0
- package/dist/geometry/summaryLayouts.d.ts +45 -0
- package/dist/index.d.ts +1 -125
- package/dist/network.js +7495 -0
- package/dist/network.js.map +1 -0
- package/dist/network.min.js +1 -0
- package/dist/network.module.js +7458 -0
- package/dist/network.module.js.map +1 -0
- package/dist/network.module.min.js +1 -0
- package/dist/ordinal.js +6497 -0
- package/dist/ordinal.js.map +1 -0
- package/dist/ordinal.min.js +1 -0
- package/dist/ordinal.module.js +6465 -0
- package/dist/ordinal.module.js.map +1 -0
- package/dist/ordinal.module.min.js +1 -0
- package/dist/processing/InteractionItems.d.ts +5 -4
- package/dist/processing/hierarchyUtils.d.ts +16 -0
- package/dist/processing/layouts/chordLayout.d.ts +2 -0
- package/dist/processing/layouts/forceLayout.d.ts +3 -0
- package/dist/processing/layouts/hierarchyLayout.d.ts +10 -0
- package/dist/processing/layouts/index.d.ts +8 -0
- package/dist/processing/layouts/sankeyLayout.d.ts +8 -0
- package/dist/processing/layouts/simpleLayouts.d.ts +7 -0
- package/dist/processing/layouts/types.d.ts +17 -0
- package/dist/processing/networkDefaults.d.ts +36 -0
- package/dist/realtime/BinAccumulator.d.ts +8 -0
- package/dist/realtime/IncrementalExtent.d.ts +13 -0
- package/dist/realtime/RingBuffer.d.ts +19 -0
- package/dist/realtime/renderers/barRenderer.d.ts +2 -0
- package/dist/realtime/renderers/candlestickRenderer.d.ts +2 -0
- package/dist/realtime/renderers/lineRenderer.d.ts +2 -0
- package/dist/realtime/renderers/swarmRenderer.d.ts +2 -0
- package/dist/realtime/renderers/types.d.ts +9 -0
- package/dist/realtime/renderers/waterfallRenderer.d.ts +3 -0
- package/dist/realtime/types.d.ts +113 -0
- package/dist/realtime.js +7072 -0
- package/dist/realtime.js.map +1 -0
- package/dist/realtime.min.js +1 -0
- package/dist/realtime.module.js +7043 -0
- package/dist/realtime.module.js.map +1 -0
- package/dist/realtime.module.min.js +1 -0
- package/dist/semiotic-ai.d.ts +36 -0
- package/dist/semiotic-ai.js +13323 -0
- package/dist/semiotic-ai.js.map +1 -0
- package/dist/semiotic-ai.min.js +1 -0
- package/dist/semiotic-ai.module.js +13264 -0
- package/dist/semiotic-ai.module.js.map +1 -0
- package/dist/semiotic-ai.module.min.js +1 -0
- package/dist/semiotic-data.d.ts +5 -0
- package/dist/semiotic-data.js +141 -0
- package/dist/semiotic-data.js.map +1 -0
- package/dist/semiotic-data.min.js +1 -0
- package/dist/semiotic-data.module.js +136 -0
- package/dist/semiotic-data.module.js.map +1 -0
- package/dist/semiotic-data.module.min.js +1 -0
- package/dist/semiotic-network.d.ts +23 -0
- package/dist/semiotic-ordinal.d.ts +19 -0
- package/dist/semiotic-realtime.d.ts +22 -0
- package/dist/semiotic-server.d.ts +1 -0
- package/dist/semiotic-xy.d.ts +21 -0
- package/dist/semiotic.d.ts +41 -28
- package/dist/semiotic.js +16257 -13130
- package/dist/semiotic.js.map +1 -0
- package/dist/semiotic.min.js +1 -0
- package/dist/semiotic.module.js +16198 -13100
- package/dist/semiotic.module.js.map +1 -0
- package/dist/semiotic.module.min.js +1 -0
- package/dist/server/renderToStaticSVG.d.ts +9 -0
- package/dist/server.js +5191 -0
- package/dist/server.js.map +1 -0
- package/dist/server.min.js +1 -0
- package/dist/server.module.js +5166 -0
- package/dist/server.module.js.map +1 -0
- package/dist/server.module.min.js +1 -0
- package/dist/store/SelectionStore.d.ts +29 -0
- package/dist/store/ThemeStore.d.ts +26 -0
- package/dist/store/useSelection.d.ts +66 -0
- package/dist/stream/CanvasHitTester.d.ts +18 -0
- package/dist/stream/DataSourceAdapter.d.ts +32 -0
- package/dist/stream/MarginalGraphics.d.ts +19 -0
- package/dist/stream/NetworkCanvasHitTester.d.ts +14 -0
- package/dist/stream/NetworkPipelineStore.d.ts +74 -0
- package/dist/stream/NetworkSVGOverlay.d.ts +40 -0
- package/dist/stream/NetworkSceneGraph.d.ts +14 -0
- package/dist/stream/OrdinalCanvasHitTester.d.ts +9 -0
- package/dist/stream/OrdinalPipelineStore.d.ts +65 -0
- package/dist/stream/OrdinalSVGOverlay.d.ts +34 -0
- package/dist/stream/ParticlePool.d.ts +28 -0
- package/dist/stream/PipelineStore.d.ts +161 -0
- package/dist/stream/SVGOverlay.d.ts +37 -0
- package/dist/stream/SceneGraph.d.ts +16 -0
- package/dist/stream/StreamNetworkFrame.d.ts +4 -0
- package/dist/stream/StreamOrdinalFrame.d.ts +4 -0
- package/dist/stream/StreamXYFrame.d.ts +4 -0
- package/dist/stream/accessorUtils.d.ts +2 -0
- package/dist/stream/index.d.ts +16 -0
- package/dist/stream/layouts/chordLayoutPlugin.d.ts +8 -0
- package/dist/stream/layouts/forceLayoutPlugin.d.ts +9 -0
- package/dist/stream/layouts/hierarchyLayoutPlugin.d.ts +17 -0
- package/dist/stream/layouts/index.d.ts +11 -0
- package/dist/stream/layouts/sankeyLayoutPlugin.d.ts +8 -0
- package/dist/stream/networkTypes.d.ts +346 -0
- package/dist/stream/ordinalSceneBuilders/barScene.d.ts +4 -0
- package/dist/stream/ordinalSceneBuilders/connectorScene.d.ts +3 -0
- package/dist/stream/ordinalSceneBuilders/pieScene.d.ts +3 -0
- package/dist/stream/ordinalSceneBuilders/pointScene.d.ts +4 -0
- package/dist/stream/ordinalSceneBuilders/statisticalScene.d.ts +6 -0
- package/dist/stream/ordinalSceneBuilders/timelineScene.d.ts +3 -0
- package/dist/stream/ordinalSceneBuilders/types.d.ts +21 -0
- package/dist/stream/ordinalTypes.d.ts +225 -0
- package/dist/stream/renderers/areaCanvasRenderer.d.ts +7 -0
- package/dist/stream/renderers/barCanvasRenderer.d.ts +7 -0
- package/dist/stream/renderers/boxplotCanvasRenderer.d.ts +2 -0
- package/dist/stream/renderers/candlestickCanvasRenderer.d.ts +2 -0
- package/dist/stream/renderers/connectorCanvasRenderer.d.ts +2 -0
- package/dist/stream/renderers/heatmapCanvasRenderer.d.ts +6 -0
- package/dist/stream/renderers/lineCanvasRenderer.d.ts +8 -0
- package/dist/stream/renderers/networkArcRenderer.d.ts +5 -0
- package/dist/stream/renderers/networkCircleRenderer.d.ts +5 -0
- package/dist/stream/renderers/networkEdgeRenderer.d.ts +10 -0
- package/dist/stream/renderers/networkParticleRenderer.d.ts +11 -0
- package/dist/stream/renderers/networkRectRenderer.d.ts +5 -0
- package/dist/stream/renderers/pointCanvasRenderer.d.ts +7 -0
- package/dist/stream/renderers/swarmCanvasRenderer.d.ts +7 -0
- package/dist/stream/renderers/types.d.ts +7 -0
- package/dist/stream/renderers/violinCanvasRenderer.d.ts +2 -0
- package/dist/stream/renderers/waterfallCanvasRenderer.d.ts +8 -0
- package/dist/stream/renderers/wedgeCanvasRenderer.d.ts +2 -0
- package/dist/stream/types.d.ts +307 -0
- package/dist/types/annotationTypes.d.ts +13 -18
- package/dist/types/canvasTypes.d.ts +1 -1
- package/dist/types/generalTypes.d.ts +41 -36
- package/dist/types/interactionTypes.d.ts +7 -9
- package/dist/types/legendTypes.d.ts +2 -2
- package/dist/types/networkTypes.d.ts +40 -30
- package/dist/types/ordinalTypes.d.ts +27 -18
- package/dist/types/xyTypes.d.ts +1 -95
- package/dist/visualizationLayerBehavior/axis.d.ts +3 -5
- package/dist/visualizationLayerBehavior/general.d.ts +8 -12
- package/dist/xy.js +6993 -0
- package/dist/xy.js.map +1 -0
- package/dist/xy.min.js +1 -0
- package/dist/xy.module.js +6957 -0
- package/dist/xy.module.js.map +1 -0
- package/dist/xy.module.min.js +1 -0
- package/package.json +123 -67
- package/dist/AnnotationLayer/helpers.d.ts +0 -6
- package/dist/AnnotationLayer/index.d.ts +0 -2
- package/dist/FacetController.d.ts +0 -12
- package/dist/Frame.d.ts +0 -2
- package/dist/InteractionLayer.d.ts +0 -3
- package/dist/Mark/Mark.d.ts +0 -3
- package/dist/Mark/Mark.types.d.ts +0 -10
- package/dist/Mark/constants/markTransition.d.ts +0 -10
- package/dist/Mark/markBehavior/drawing.d.ts +0 -13
- package/dist/MiniMap.d.ts +0 -14
- package/dist/MinimapXYFrame.d.ts +0 -10
- package/dist/NetworkFrame.d.ts +0 -4
- package/dist/OrdinalFrame.d.ts +0 -4
- package/dist/ResponsiveFrame.d.ts +0 -22
- package/dist/ResponsiveMinimapXYFrame.d.ts +0 -6
- package/dist/ResponsiveNetworkFrame.d.ts +0 -6
- package/dist/ResponsiveOrdinalFrame.d.ts +0 -6
- package/dist/ResponsiveXYFrame.d.ts +0 -6
- package/dist/SpanOrDiv.d.ts +0 -10
- package/dist/SparkFrame.d.ts +0 -14
- package/dist/SparkNetworkFrame.d.ts +0 -5
- package/dist/SparkOrdinalFrame.d.ts +0 -5
- package/dist/SparkXYFrame.d.ts +0 -5
- package/dist/VisualizationLayer.d.ts +0 -33
- package/dist/XYFrame.d.ts +0 -4
- package/dist/annotationRules/orframeRules.d.ts +0 -105
- package/dist/components/Annotation.d.ts +0 -3
- package/dist/components/AnnotationLayer/AnnotationLayer.d.ts +0 -26
- package/dist/components/Axis/Axis.d.ts +0 -7
- package/dist/components/Axis/axisTitle.d.ts +0 -10
- package/dist/components/Axis/index.d.ts +0 -2
- package/dist/components/Axis/summaryGraphic.d.ts +0 -17
- package/dist/components/Brush.d.ts +0 -12
- package/dist/components/DividedLine.d.ts +0 -16
- package/dist/components/FacetController.d.ts +0 -12
- package/dist/components/Frame.d.ts +0 -2
- package/dist/components/InteractionLayer.d.ts +0 -3
- package/dist/components/Legend.d.ts +0 -3
- package/dist/components/Mark/Mark.d.ts +0 -3
- package/dist/components/Mark/Mark.types.d.ts +0 -10
- package/dist/components/Mark/markBehavior/drawing.d.ts +0 -13
- package/dist/components/MiniMap.d.ts +0 -14
- package/dist/components/MinimapXYFrame.d.ts +0 -10
- package/dist/components/NetworkFrame.d.ts +0 -4
- package/dist/components/OrdinalFrame.d.ts +0 -4
- package/dist/components/ResponsiveFrame.d.ts +0 -22
- package/dist/components/ResponsiveMinimapXYFrame.d.ts +0 -6
- package/dist/components/ResponsiveNetworkFrame.d.ts +0 -6
- package/dist/components/ResponsiveOrdinalFrame.d.ts +0 -6
- package/dist/components/ResponsiveXYFrame.d.ts +0 -6
- package/dist/components/SpanOrDiv.d.ts +0 -10
- package/dist/components/SparkFrame.d.ts +0 -14
- package/dist/components/SparkNetworkFrame.d.ts +0 -5
- package/dist/components/SparkOrdinalFrame.d.ts +0 -5
- package/dist/components/SparkXYFrame.d.ts +0 -5
- package/dist/components/TooltipPositioner/index.d.ts +0 -7
- package/dist/components/VisualizationLayer.d.ts +0 -33
- package/dist/components/XYFrame.d.ts +0 -4
- package/dist/components/annotationLayerBehavior/annotationHandling.d.ts +0 -19
- package/dist/components/annotationLayerBehavior/d3labeler.d.ts +0 -9
- package/dist/components/annotationRules/baseRules.d.ts +0 -25
- package/dist/components/annotationRules/networkframeRules.d.ts +0 -48
- package/dist/components/annotationRules/orframeRules.d.ts +0 -105
- package/dist/components/annotationRules/xyframeRules.d.ts +0 -117
- package/dist/components/batchWork.d.ts +0 -6
- package/dist/components/constants/coordinateNames.d.ts +0 -8
- package/dist/components/constants/frame_props.d.ts +0 -4
- package/dist/components/constants/jsx.d.ts +0 -19
- package/dist/components/data/dataFunctions.d.ts +0 -46
- package/dist/components/data/multiAccessorUtils.d.ts +0 -1
- package/dist/components/data/unflowedFunctions.d.ts +0 -1
- package/dist/components/generic_utilities/functions.d.ts +0 -1
- package/dist/components/index.d.ts +0 -125
- package/dist/components/interactionLayerBehavior/InteractionCanvas.d.ts +0 -20
- package/dist/components/processing/InteractionItems.d.ts +0 -12
- package/dist/components/processing/network.d.ts +0 -114
- package/dist/components/processing/ordinal.d.ts +0 -102
- package/dist/components/processing/xyDrawing.d.ts +0 -135
- package/dist/components/semiotic.d.ts +0 -35
- package/dist/components/store/TooltipStore.d.ts +0 -2
- package/dist/components/store/createStore.d.ts +0 -1
- package/dist/components/svg/SvgHelper.d.ts +0 -37
- package/dist/components/svg/areaDrawing.d.ts +0 -31
- package/dist/components/svg/ckmeans.d.ts +0 -69
- package/dist/components/svg/frameFunctions.d.ts +0 -119
- package/dist/components/svg/lineDrawing.d.ts +0 -99
- package/dist/components/svg/networkDrawing.d.ts +0 -134
- package/dist/components/svg/pieceDrawing.d.ts +0 -13
- package/dist/components/svg/pieceLayouts.d.ts +0 -71
- package/dist/components/svg/summaryLayouts.d.ts +0 -74
- package/dist/components/types/annotationTypes.d.ts +0 -140
- package/dist/components/types/canvasTypes.d.ts +0 -9
- package/dist/components/types/generalTypes.d.ts +0 -236
- package/dist/components/types/interactionTypes.d.ts +0 -74
- package/dist/components/types/legendTypes.d.ts +0 -20
- package/dist/components/types/networkTypes.d.ts +0 -165
- package/dist/components/types/ordinalTypes.d.ts +0 -103
- package/dist/components/types/xyTypes.d.ts +0 -118
- package/dist/components/useBoundingRect.d.ts +0 -2
- package/dist/components/useDerivedStateFromProps.d.ts +0 -1
- package/dist/components/useLegacyUnmountCallback.d.ts +0 -1
- package/dist/components/visualizationLayerBehavior/axis.d.ts +0 -38
- package/dist/components/visualizationLayerBehavior/general.d.ts +0 -84
- package/dist/constants/jsx.d.ts +0 -19
- package/dist/interactionLayerBehavior/InteractionCanvas.d.ts +0 -20
- package/dist/processing/network.d.ts +0 -114
- package/dist/processing/ordinal.d.ts +0 -102
- package/dist/processing/xyDrawing.d.ts +0 -135
- package/dist/setupTests.d.ts +0 -1
- package/dist/svg/SvgHelper.d.ts +0 -37
- package/dist/svg/ckmeans.d.ts +0 -69
- package/dist/svg/frameFunctions.d.ts +0 -119
- package/dist/svg/networkDrawing.d.ts +0 -134
- package/dist/svg/pieceDrawing.d.ts +0 -13
- package/dist/svg/pieceLayouts.d.ts +0 -71
- package/dist/svg/summaryLayouts.d.ts +0 -74
- package/dist/useDerivedStateFromProps.d.ts +0 -1
- package/dist/useLegacyUnmountCallback.d.ts +0 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.drawSummaries = void 0;
|
|
37
|
+
exports.orFrameSummaryRenderer = orFrameSummaryRenderer;
|
|
38
|
+
exports.summaryInstructionsToMarks = summaryInstructionsToMarks;
|
|
39
|
+
const React = __importStar(require("react"));
|
|
40
|
+
function orFrameSummaryRenderer({ data, type, renderMode, eventListenersGenerator, styleFn, classFn, projection, adjustedSize, chartSize, margin, axisCreator }) {
|
|
41
|
+
if (typeof type.type === "function") {
|
|
42
|
+
return type.type({
|
|
43
|
+
data,
|
|
44
|
+
type,
|
|
45
|
+
renderMode,
|
|
46
|
+
eventListenersGenerator,
|
|
47
|
+
styleFn,
|
|
48
|
+
classFn,
|
|
49
|
+
projection,
|
|
50
|
+
adjustedSize,
|
|
51
|
+
chartSize,
|
|
52
|
+
margin,
|
|
53
|
+
axisCreator
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
console.error(`Invalid summary type: ${type.type} - Must be a function`);
|
|
57
|
+
return {};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Main drawing function for summary visualizations
|
|
61
|
+
*/
|
|
62
|
+
const drawSummaries = ({ data, type, renderMode, eventListenersGenerator, styleFn, classFn, projection, adjustedSize, margin, axisCreator }) => {
|
|
63
|
+
if (!type || !type.type)
|
|
64
|
+
return;
|
|
65
|
+
type = typeof type === "string" ? { type } : type;
|
|
66
|
+
const chartSize = projection === "vertical" ? adjustedSize[1] : adjustedSize[0];
|
|
67
|
+
return orFrameSummaryRenderer({
|
|
68
|
+
data: data,
|
|
69
|
+
type: type,
|
|
70
|
+
renderMode,
|
|
71
|
+
eventListenersGenerator,
|
|
72
|
+
styleFn,
|
|
73
|
+
classFn,
|
|
74
|
+
projection,
|
|
75
|
+
adjustedSize,
|
|
76
|
+
chartSize,
|
|
77
|
+
margin,
|
|
78
|
+
axisCreator
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
exports.drawSummaries = drawSummaries;
|
|
82
|
+
/**
|
|
83
|
+
* Converts summary instructions to rendered SVG elements
|
|
84
|
+
*/
|
|
85
|
+
function summaryInstructionsToMarks(data) {
|
|
86
|
+
const renderedSummaries = [];
|
|
87
|
+
for (const container of data) {
|
|
88
|
+
const renderedElements = [];
|
|
89
|
+
const { elements, containerProps } = container;
|
|
90
|
+
if (container.Mark) {
|
|
91
|
+
renderedSummaries.push(container.Mark);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
for (let i = 0; i < elements.length; i++) {
|
|
95
|
+
const element = elements[i];
|
|
96
|
+
const { markType, style = {}, ...restProps } = element;
|
|
97
|
+
// Merge style object into direct props for cleaner SVG
|
|
98
|
+
const elementProps = { ...restProps };
|
|
99
|
+
if (style.fill !== undefined)
|
|
100
|
+
elementProps.fill = style.fill;
|
|
101
|
+
if (style.stroke !== undefined)
|
|
102
|
+
elementProps.stroke = style.stroke;
|
|
103
|
+
if (style.strokeWidth !== undefined)
|
|
104
|
+
elementProps.strokeWidth = style.strokeWidth;
|
|
105
|
+
if (style.opacity !== undefined)
|
|
106
|
+
elementProps.opacity = style.opacity;
|
|
107
|
+
if (style.fillOpacity !== undefined)
|
|
108
|
+
elementProps.fillOpacity = style.fillOpacity;
|
|
109
|
+
if (style.strokeOpacity !== undefined)
|
|
110
|
+
elementProps.strokeOpacity = style.strokeOpacity;
|
|
111
|
+
// Keep remaining styles
|
|
112
|
+
const remainingStyles = { ...style };
|
|
113
|
+
delete remainingStyles.fill;
|
|
114
|
+
delete remainingStyles.stroke;
|
|
115
|
+
delete remainingStyles.strokeWidth;
|
|
116
|
+
delete remainingStyles.opacity;
|
|
117
|
+
delete remainingStyles.fillOpacity;
|
|
118
|
+
delete remainingStyles.strokeOpacity;
|
|
119
|
+
if (Object.keys(remainingStyles).length > 0) {
|
|
120
|
+
elementProps.style = remainingStyles;
|
|
121
|
+
}
|
|
122
|
+
elementProps.key = element.key || i;
|
|
123
|
+
if (markType) {
|
|
124
|
+
renderedElements.push(React.createElement(markType, elementProps));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (containerProps) {
|
|
128
|
+
renderedSummaries.push(React.createElement("g", { ...containerProps }, renderedElements));
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
renderedSummaries.push(...renderedElements);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return renderedSummaries;
|
|
136
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// Re-export everything from the main entry point
|
|
18
|
+
__exportStar(require("./semiotic"), exports);
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.calculateOverlay = exports.brushEnd = exports.brushing = exports.brushStart = exports.doubleclickVoronoi = exports.clickVoronoi = exports.changeVoronoi = void 0;
|
|
37
|
+
const React = __importStar(require("react"));
|
|
38
|
+
const coordinateNames_1 = require("../constants/coordinateNames");
|
|
39
|
+
const d3_array_1 = require("d3-array");
|
|
40
|
+
const d3_delaunay_1 = require("d3-delaunay");
|
|
41
|
+
const constructDataObject = (d, points) => {
|
|
42
|
+
if (d === undefined)
|
|
43
|
+
return d;
|
|
44
|
+
return d && d.data ? { points, ...d.data, ...d } : { points, ...d };
|
|
45
|
+
};
|
|
46
|
+
const changeVoronoi = (voronoiHover, d, customHoverTypes, customHoverBehavior, points, e) => {
|
|
47
|
+
//Until semiotic 2
|
|
48
|
+
const dataObject = constructDataObject(d, points);
|
|
49
|
+
if (customHoverBehavior)
|
|
50
|
+
customHoverBehavior(dataObject);
|
|
51
|
+
if (!d)
|
|
52
|
+
voronoiHover(null);
|
|
53
|
+
else if (customHoverTypes === true) {
|
|
54
|
+
const vorD = Object.assign({}, dataObject);
|
|
55
|
+
vorD.type = vorD.type === "column-hover" ? "column-hover" : "frame-hover";
|
|
56
|
+
voronoiHover(vorD, e);
|
|
57
|
+
}
|
|
58
|
+
else if (customHoverTypes) {
|
|
59
|
+
const arrayWrappedHoverTypes = Array.isArray(customHoverTypes)
|
|
60
|
+
? customHoverTypes
|
|
61
|
+
: [customHoverTypes];
|
|
62
|
+
const mappedHoverTypes = arrayWrappedHoverTypes
|
|
63
|
+
.map((c) => {
|
|
64
|
+
const finalC = typeof c === "function" ? c(dataObject) : c;
|
|
65
|
+
if (!finalC)
|
|
66
|
+
return undefined;
|
|
67
|
+
return Object.assign({}, dataObject, finalC);
|
|
68
|
+
})
|
|
69
|
+
.filter((d) => d);
|
|
70
|
+
voronoiHover(mappedHoverTypes, e);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
exports.changeVoronoi = changeVoronoi;
|
|
74
|
+
const clickVoronoi = (d, customClickBehavior, points, e) => {
|
|
75
|
+
//Until semiotic 2
|
|
76
|
+
const dataObject = constructDataObject(d, points);
|
|
77
|
+
if (customClickBehavior)
|
|
78
|
+
customClickBehavior(dataObject, e);
|
|
79
|
+
};
|
|
80
|
+
exports.clickVoronoi = clickVoronoi;
|
|
81
|
+
const doubleclickVoronoi = (d, customDoubleClickBehavior, points, e) => {
|
|
82
|
+
//Until semiotic 2
|
|
83
|
+
const dataObject = constructDataObject(d, points);
|
|
84
|
+
if (customDoubleClickBehavior)
|
|
85
|
+
customDoubleClickBehavior(dataObject, e);
|
|
86
|
+
};
|
|
87
|
+
exports.doubleclickVoronoi = doubleclickVoronoi;
|
|
88
|
+
const brushStart = (e, columnName, data, columnData, interaction) => {
|
|
89
|
+
if (interaction && interaction.start)
|
|
90
|
+
interaction.start(e, columnName, data, columnData);
|
|
91
|
+
};
|
|
92
|
+
exports.brushStart = brushStart;
|
|
93
|
+
const brushing = (e, columnName, data, columnData, interaction) => {
|
|
94
|
+
if (interaction && interaction.during)
|
|
95
|
+
interaction.during(e, columnName, data, columnData);
|
|
96
|
+
};
|
|
97
|
+
exports.brushing = brushing;
|
|
98
|
+
const brushEnd = (e, columnName, data, columnData, interaction) => {
|
|
99
|
+
if (interaction && interaction.end)
|
|
100
|
+
interaction.end(e, columnName, data, columnData);
|
|
101
|
+
};
|
|
102
|
+
exports.brushEnd = brushEnd;
|
|
103
|
+
const calculateOverlay = (props, voronoiHover) => {
|
|
104
|
+
let voronoiPaths = [];
|
|
105
|
+
const { xScale, yScale, points, projectedX, showLinePoints, size, overlay, interactionOverflow = { top: 0, bottom: 0, left: 0, right: 0 }, customClickBehavior, customDoubleClickBehavior, customHoverBehavior, hoverAnnotation, margin, advancedSettings = {} } = props;
|
|
106
|
+
const whichPoints = {
|
|
107
|
+
top: coordinateNames_1.projectedYTop,
|
|
108
|
+
bottom: coordinateNames_1.projectedYBottom
|
|
109
|
+
};
|
|
110
|
+
const pointerStyle = customClickBehavior || customDoubleClickBehavior
|
|
111
|
+
? { cursor: "pointer" }
|
|
112
|
+
: {};
|
|
113
|
+
if (points && hoverAnnotation && !overlay) {
|
|
114
|
+
const { voronoiFilter = () => true } = advancedSettings;
|
|
115
|
+
const voronoiDataset = [];
|
|
116
|
+
const voronoiUniqueMap = new Map();
|
|
117
|
+
for (const d of points) {
|
|
118
|
+
if (voronoiFilter({ ...d, ...d.data })) {
|
|
119
|
+
const xValue = Math.floor(xScale(d[projectedX]));
|
|
120
|
+
const yValue = Math.floor(yScale(showLinePoints && d[whichPoints[showLinePoints]] !== undefined
|
|
121
|
+
? d[whichPoints[showLinePoints]]
|
|
122
|
+
: d[coordinateNames_1.projectedYMiddle] !== undefined
|
|
123
|
+
? d[coordinateNames_1.projectedYMiddle]
|
|
124
|
+
: d[coordinateNames_1.projectedY]));
|
|
125
|
+
if (xValue >= 0 - margin.left &&
|
|
126
|
+
xValue <= size[0] + margin.right &&
|
|
127
|
+
yValue >= 0 - margin.top &&
|
|
128
|
+
yValue <= size[1] + margin.bottom &&
|
|
129
|
+
xValue !== undefined &&
|
|
130
|
+
yValue !== undefined &&
|
|
131
|
+
isNaN(xValue) === false &&
|
|
132
|
+
isNaN(yValue) === false) {
|
|
133
|
+
const pointKey = `${xValue},${yValue}`;
|
|
134
|
+
if (!voronoiUniqueMap.has(pointKey)) {
|
|
135
|
+
const voronoiPoint = {
|
|
136
|
+
...d,
|
|
137
|
+
coincidentPoints: [d],
|
|
138
|
+
voronoiX: xValue,
|
|
139
|
+
voronoiY: yValue
|
|
140
|
+
};
|
|
141
|
+
voronoiDataset.push(voronoiPoint);
|
|
142
|
+
voronoiUniqueMap.set(pointKey, voronoiPoint);
|
|
143
|
+
}
|
|
144
|
+
else
|
|
145
|
+
voronoiUniqueMap.get(pointKey).coincidentPoints.push(d);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
let voronoiXExtent = (0, d3_array_1.extent)(voronoiDataset.map((d) => d.voronoiX));
|
|
150
|
+
let voronoiYExtent = (0, d3_array_1.extent)(voronoiDataset.map((d) => d.voronoiY));
|
|
151
|
+
if (voronoiXExtent[0] == null || voronoiYExtent == null) {
|
|
152
|
+
voronoiXExtent = [0, 0];
|
|
153
|
+
voronoiYExtent = [0, 0];
|
|
154
|
+
}
|
|
155
|
+
const voronoiExtent = [
|
|
156
|
+
Math.min(voronoiXExtent[0] - 5, -interactionOverflow.left),
|
|
157
|
+
Math.min(voronoiYExtent[0] - 5, -interactionOverflow.top),
|
|
158
|
+
Math.max(voronoiXExtent[1] + 5, size[0] + interactionOverflow.right),
|
|
159
|
+
Math.max(voronoiYExtent[1] + 5, size[1] + interactionOverflow.bottom)
|
|
160
|
+
];
|
|
161
|
+
const delaunay = d3_delaunay_1.Delaunay.from(voronoiDataset, (d) => d.voronoiX, (d) => d.voronoiY);
|
|
162
|
+
const voronoi = delaunay.voronoi(voronoiExtent);
|
|
163
|
+
voronoiPaths = voronoiDataset.map((d, i) => {
|
|
164
|
+
let clipPath = null;
|
|
165
|
+
if (advancedSettings.voronoiClipping) {
|
|
166
|
+
const circleSize = advancedSettings.voronoiClipping === true
|
|
167
|
+
? 50
|
|
168
|
+
: advancedSettings.voronoiClipping;
|
|
169
|
+
clipPath = (React.createElement("clipPath", { id: `voronoi-${i}` },
|
|
170
|
+
React.createElement("circle", { r: circleSize, cx: d.voronoiX, cy: d.voronoiY })));
|
|
171
|
+
}
|
|
172
|
+
return (React.createElement("g", { key: `voronoi-${i}` },
|
|
173
|
+
React.createElement("path", { onClick: (e) => {
|
|
174
|
+
(0, exports.clickVoronoi)(voronoiDataset[i], customClickBehavior, points, e);
|
|
175
|
+
}, onDoubleClick: (e) => {
|
|
176
|
+
(0, exports.doubleclickVoronoi)(voronoiDataset[i], customDoubleClickBehavior, points, e);
|
|
177
|
+
}, onMouseEnter: (e) => {
|
|
178
|
+
(0, exports.changeVoronoi)(voronoiHover, voronoiDataset[i], hoverAnnotation, customHoverBehavior, points, e);
|
|
179
|
+
}, onMouseLeave: (e) => {
|
|
180
|
+
(0, exports.changeVoronoi)(voronoiHover, undefined, undefined, customHoverBehavior, undefined, e);
|
|
181
|
+
}, key: `interactionVoronoi${i}`, d: voronoi.renderCell(i), style: {
|
|
182
|
+
fillOpacity: 0,
|
|
183
|
+
...pointerStyle
|
|
184
|
+
}, clipPath: `url(#voronoi-${i})` }),
|
|
185
|
+
clipPath));
|
|
186
|
+
}, this);
|
|
187
|
+
return voronoiPaths;
|
|
188
|
+
}
|
|
189
|
+
else if (overlay) {
|
|
190
|
+
const renderedOverlay = overlay.map((overlayRegion, i) => {
|
|
191
|
+
const { overlayData, ...rest } = overlayRegion;
|
|
192
|
+
const overlayProps = {
|
|
193
|
+
key: `overlay-${i}`,
|
|
194
|
+
onMouseEnter: (e) => {
|
|
195
|
+
(0, exports.changeVoronoi)(voronoiHover, overlayData, props.hoverAnnotation, customHoverBehavior, points, e);
|
|
196
|
+
},
|
|
197
|
+
onMouseLeave: (e) => {
|
|
198
|
+
(0, exports.changeVoronoi)(voronoiHover, undefined, undefined, customHoverBehavior, undefined, e);
|
|
199
|
+
},
|
|
200
|
+
onClick: (e) => {
|
|
201
|
+
(0, exports.clickVoronoi)(overlayData, customClickBehavior, points, e);
|
|
202
|
+
},
|
|
203
|
+
onDoubleClick: (e) => {
|
|
204
|
+
(0, exports.doubleclickVoronoi)(overlayData, customDoubleClickBehavior, points, e);
|
|
205
|
+
},
|
|
206
|
+
style: { opacity: 0, ...pointerStyle }
|
|
207
|
+
};
|
|
208
|
+
if (React.isValidElement(overlayRegion.renderElement)) {
|
|
209
|
+
return React.cloneElement(overlayRegion.renderElement, overlayProps);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
const { markType, ...restProps } = rest;
|
|
213
|
+
return React.createElement(markType || 'path', {
|
|
214
|
+
...restProps,
|
|
215
|
+
key: `overlay-${i}`,
|
|
216
|
+
...overlayProps
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
return renderedOverlay;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
exports.calculateOverlay = calculateOverlay;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.matrixify = exports.nodesEdgesFromHierarchy = exports.defaultHierarchicalIDAccessor = void 0;
|
|
4
|
+
exports.recursiveIDAccessor = recursiveIDAccessor;
|
|
5
|
+
exports.breadthFirstCompontents = breadthFirstCompontents;
|
|
6
|
+
const d3_hierarchy_1 = require("d3-hierarchy");
|
|
7
|
+
function recursiveIDAccessor(idAccessor, node, accessorString) {
|
|
8
|
+
if (node.parent) {
|
|
9
|
+
accessorString = `${accessorString}-${recursiveIDAccessor(idAccessor, { ...node.parent, ...node.parent.data }, accessorString)}`;
|
|
10
|
+
}
|
|
11
|
+
return `${accessorString}-${idAccessor({ ...node, ...node.data })}`;
|
|
12
|
+
}
|
|
13
|
+
const defaultHierarchicalIDAccessor = (d) => d.id || d.descendantIndex;
|
|
14
|
+
exports.defaultHierarchicalIDAccessor = defaultHierarchicalIDAccessor;
|
|
15
|
+
const nodesEdgesFromHierarchy = (baseRootNode, idAccessor = exports.defaultHierarchicalIDAccessor) => {
|
|
16
|
+
const edges = [];
|
|
17
|
+
const nodes = [];
|
|
18
|
+
const rootNode = baseRootNode.descendants
|
|
19
|
+
? baseRootNode
|
|
20
|
+
: (0, d3_hierarchy_1.hierarchy)(baseRootNode);
|
|
21
|
+
const descendants = rootNode.descendants();
|
|
22
|
+
let i = 0;
|
|
23
|
+
for (const node of descendants) {
|
|
24
|
+
node.descendantIndex = i;
|
|
25
|
+
i++;
|
|
26
|
+
}
|
|
27
|
+
for (const node of descendants) {
|
|
28
|
+
const generatedID = `${idAccessor({
|
|
29
|
+
...node,
|
|
30
|
+
...node.data
|
|
31
|
+
}) ?? (0, exports.defaultHierarchicalIDAccessor)(node)}-${node.parent
|
|
32
|
+
? recursiveIDAccessor(idAccessor, { ...node.parent, ...node.parent.data }, "") ?? node.parent.name
|
|
33
|
+
: "root"}`;
|
|
34
|
+
const dataD = Object.assign(node, node.data || {}, {
|
|
35
|
+
hierarchicalID: generatedID
|
|
36
|
+
});
|
|
37
|
+
nodes.push(dataD);
|
|
38
|
+
if (node.parent !== null) {
|
|
39
|
+
const dataParent = Object.assign(node.parent, node.parent.data || {});
|
|
40
|
+
edges.push({
|
|
41
|
+
source: dataParent,
|
|
42
|
+
target: dataD,
|
|
43
|
+
depth: node.depth,
|
|
44
|
+
weight: 1,
|
|
45
|
+
value: 1,
|
|
46
|
+
_NWFEdgeKey: generatedID
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return { edges, nodes };
|
|
51
|
+
};
|
|
52
|
+
exports.nodesEdgesFromHierarchy = nodesEdgesFromHierarchy;
|
|
53
|
+
function breadthFirstCompontents(baseNodes, hash) {
|
|
54
|
+
const componentMap = {
|
|
55
|
+
"0": { componentNodes: [], componentEdges: [] }
|
|
56
|
+
};
|
|
57
|
+
const components = [componentMap["0"]];
|
|
58
|
+
let componentID = 0;
|
|
59
|
+
traverseNodesBF(baseNodes, true);
|
|
60
|
+
function traverseNodesBF(nodes, top) {
|
|
61
|
+
for (const node of nodes) {
|
|
62
|
+
const hashNode = hash.get(node);
|
|
63
|
+
if (!hashNode) {
|
|
64
|
+
componentMap["0"].componentNodes.push(node);
|
|
65
|
+
}
|
|
66
|
+
else if (hashNode.component === -99) {
|
|
67
|
+
if (top === true) {
|
|
68
|
+
componentID++;
|
|
69
|
+
componentMap[componentID] = {
|
|
70
|
+
componentNodes: [],
|
|
71
|
+
componentEdges: []
|
|
72
|
+
};
|
|
73
|
+
components.push(componentMap[componentID]);
|
|
74
|
+
}
|
|
75
|
+
hashNode.component = componentID;
|
|
76
|
+
componentMap[componentID].componentNodes.push(node);
|
|
77
|
+
componentMap[componentID].componentEdges.push(...hashNode.edges);
|
|
78
|
+
const traversibleNodes = [...hashNode.connectedNodes];
|
|
79
|
+
traverseNodesBF(traversibleNodes, hash);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return components.sort((a, b) => b.componentNodes.length - a.componentNodes.length);
|
|
84
|
+
}
|
|
85
|
+
const matrixify = ({ edgeHash, nodes, edgeWidthAccessor, nodeIDAccessor }) => {
|
|
86
|
+
const matrix = [];
|
|
87
|
+
for (const nodeSource of nodes) {
|
|
88
|
+
const nodeSourceID = nodeIDAccessor(nodeSource);
|
|
89
|
+
const sourceRow = [];
|
|
90
|
+
matrix.push(sourceRow);
|
|
91
|
+
for (const nodeTarget of nodes) {
|
|
92
|
+
const nodeTargetID = nodeIDAccessor(nodeTarget);
|
|
93
|
+
const theEdge = edgeHash.get(`${nodeSourceID}|${nodeTargetID}`);
|
|
94
|
+
if (theEdge) {
|
|
95
|
+
sourceRow.push(edgeWidthAccessor(theEdge));
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
sourceRow.push(0);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return matrix;
|
|
103
|
+
};
|
|
104
|
+
exports.matrixify = matrixify;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.chordLayout = void 0;
|
|
7
|
+
const d3_chord_1 = require("d3-chord");
|
|
8
|
+
const d3_shape_1 = require("d3-shape");
|
|
9
|
+
const svg_path_bounding_box_1 = __importDefault(require("svg-path-bounding-box"));
|
|
10
|
+
const hierarchyUtils_1 = require("../hierarchyUtils");
|
|
11
|
+
const chordLayout = ({ projectedNodes, projectedEdges, networkSettings, adjustedSize, edgeHash, nodeIDAccessor, edgeWidthAccessor }) => {
|
|
12
|
+
const radius = adjustedSize[1] / 2;
|
|
13
|
+
const { groupWidth = 20, padAngle = 0.01, sortGroups } = networkSettings;
|
|
14
|
+
const arcGenerator = (0, d3_shape_1.arc)()
|
|
15
|
+
.innerRadius(radius - groupWidth)
|
|
16
|
+
.outerRadius(radius);
|
|
17
|
+
const ribbonGenerator = (0, d3_chord_1.ribbon)().radius(radius - groupWidth);
|
|
18
|
+
const matrixifiedNetwork = (0, hierarchyUtils_1.matrixify)({
|
|
19
|
+
edgeHash: edgeHash,
|
|
20
|
+
nodes: projectedNodes,
|
|
21
|
+
edgeWidthAccessor,
|
|
22
|
+
nodeIDAccessor
|
|
23
|
+
});
|
|
24
|
+
const chordGenerator = (0, d3_chord_1.chord)().padAngle(padAngle);
|
|
25
|
+
if (sortGroups) {
|
|
26
|
+
chordGenerator.sortGroups(sortGroups);
|
|
27
|
+
}
|
|
28
|
+
const chords = chordGenerator(matrixifiedNetwork);
|
|
29
|
+
const groups = chords.groups;
|
|
30
|
+
groups.forEach((group) => {
|
|
31
|
+
const groupCentroid = arcGenerator.centroid(group);
|
|
32
|
+
const groupD = arcGenerator(group);
|
|
33
|
+
const groupNode = projectedNodes[group.index];
|
|
34
|
+
groupNode.d = groupD;
|
|
35
|
+
groupNode.index = group.index;
|
|
36
|
+
groupNode.x = groupCentroid[0] + adjustedSize[0] / 2;
|
|
37
|
+
groupNode.y = groupCentroid[1] + adjustedSize[1] / 2;
|
|
38
|
+
});
|
|
39
|
+
chords.forEach((generatedChord) => {
|
|
40
|
+
const chordD = ribbonGenerator(generatedChord);
|
|
41
|
+
const nodeSourceID = nodeIDAccessor(projectedNodes[generatedChord.source.index]);
|
|
42
|
+
const nodeTargetID = nodeIDAccessor(projectedNodes[generatedChord.target.index]);
|
|
43
|
+
// d3-chord always emits source.index < target.index, which may
|
|
44
|
+
// not match the original edge direction. Try both key orders.
|
|
45
|
+
const chordEdge = edgeHash.get(`${nodeSourceID}|${nodeTargetID}`) ||
|
|
46
|
+
edgeHash.get(`${nodeTargetID}|${nodeSourceID}`);
|
|
47
|
+
if (chordEdge) {
|
|
48
|
+
chordEdge.d = chordD;
|
|
49
|
+
const chordBounds = (0, svg_path_bounding_box_1.default)(chordD);
|
|
50
|
+
chordEdge.x =
|
|
51
|
+
adjustedSize[0] / 2 + (chordBounds.x1 + chordBounds.x2) / 2;
|
|
52
|
+
chordEdge.y =
|
|
53
|
+
adjustedSize[1] / 2 + (chordBounds.y1 + chordBounds.y2) / 2;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return { projectedNodes, projectedEdges };
|
|
57
|
+
};
|
|
58
|
+
exports.chordLayout = chordLayout;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.motifsLayout = exports.forceLayout = void 0;
|
|
4
|
+
const d3_force_1 = require("d3-force");
|
|
5
|
+
const d3_scale_1 = require("d3-scale");
|
|
6
|
+
const d3_array_1 = require("d3-array");
|
|
7
|
+
const hierarchyUtils_1 = require("../hierarchyUtils");
|
|
8
|
+
const forceLayout = ({ projectedNodes, projectedEdges, networkSettings, adjustedSize, nodeSizeAccessor }) => {
|
|
9
|
+
// Adaptive iteration count for force layout: reduce iterations for large networks
|
|
10
|
+
const nodeCount = projectedNodes.length;
|
|
11
|
+
const adaptiveIterations = Math.max(50, Math.min(300, Math.floor(300 - (nodeCount - 30) * 2)));
|
|
12
|
+
const { iterations = adaptiveIterations, edgeStrength = 0.1, distanceMax = Infinity, edgeDistance, forceManyBody: nsForceMB = (d) => -25 * nodeSizeAccessor(d) } = networkSettings;
|
|
13
|
+
// Set deterministic initial positions for nodes that don't have x/y yet.
|
|
14
|
+
// d3-force uses Math.random() for unpositioned nodes which produces
|
|
15
|
+
// different layouts on every render. A phyllotaxis spiral gives
|
|
16
|
+
// evenly-distributed starting positions based on index alone.
|
|
17
|
+
const cx = adjustedSize[0] / 2;
|
|
18
|
+
const cy = adjustedSize[1] / 2;
|
|
19
|
+
const goldenAngle = Math.PI * (3 - Math.sqrt(5));
|
|
20
|
+
projectedNodes.forEach((node, i) => {
|
|
21
|
+
if (node.x == null || node.y == null) {
|
|
22
|
+
const r = Math.sqrt(i + 0.5) * 10;
|
|
23
|
+
const theta = i * goldenAngle;
|
|
24
|
+
node.x = cx + r * Math.cos(theta);
|
|
25
|
+
node.y = cy + r * Math.sin(theta);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const linkForce = (0, d3_force_1.forceLink)().strength((d) => Math.min(2.5, d.weight ? d.weight * edgeStrength : edgeStrength));
|
|
29
|
+
if (edgeDistance) {
|
|
30
|
+
linkForce.distance(edgeDistance);
|
|
31
|
+
}
|
|
32
|
+
const simulation = networkSettings.simulation ||
|
|
33
|
+
(0, d3_force_1.forceSimulation)().force("charge", (0, d3_force_1.forceManyBody)().distanceMax(distanceMax).strength(nsForceMB));
|
|
34
|
+
simulation.nodes(projectedNodes);
|
|
35
|
+
const forceMod = adjustedSize[1] / adjustedSize[0];
|
|
36
|
+
if (!simulation.force("x")) {
|
|
37
|
+
simulation.force("x", (0, d3_force_1.forceX)(adjustedSize[0] / 2).strength(forceMod * 0.1));
|
|
38
|
+
}
|
|
39
|
+
if (!simulation.force("y")) {
|
|
40
|
+
simulation.force("y", (0, d3_force_1.forceY)(adjustedSize[1] / 2).strength(0.1));
|
|
41
|
+
}
|
|
42
|
+
if (projectedEdges.length !== 0 && !simulation.force("link")) {
|
|
43
|
+
simulation.force("link", linkForce);
|
|
44
|
+
simulation.force("link").links(projectedEdges);
|
|
45
|
+
}
|
|
46
|
+
//reset alpha if it's too cold
|
|
47
|
+
if (simulation.alpha() < 0.1) {
|
|
48
|
+
simulation.alpha(1);
|
|
49
|
+
}
|
|
50
|
+
simulation.stop();
|
|
51
|
+
for (let i = 0; i < iterations; ++i) {
|
|
52
|
+
simulation.tick();
|
|
53
|
+
}
|
|
54
|
+
return { projectedNodes, projectedEdges };
|
|
55
|
+
};
|
|
56
|
+
exports.forceLayout = forceLayout;
|
|
57
|
+
const motifsLayout = ({ projectedNodes, projectedEdges, networkSettings, adjustedSize, nodeSizeAccessor, size }) => {
|
|
58
|
+
const componentMap = new Map();
|
|
59
|
+
projectedEdges.forEach((edge) => {
|
|
60
|
+
;
|
|
61
|
+
[edge.source, edge.target].forEach((node) => {
|
|
62
|
+
if (!componentMap.get(node)) {
|
|
63
|
+
componentMap.set(node, {
|
|
64
|
+
node,
|
|
65
|
+
component: -99,
|
|
66
|
+
connectedNodes: [],
|
|
67
|
+
edges: []
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
componentMap.get(edge.source).connectedNodes.push(edge.target);
|
|
72
|
+
componentMap.get(edge.target).connectedNodes.push(edge.source);
|
|
73
|
+
componentMap.get(edge.source).edges.push(edge);
|
|
74
|
+
});
|
|
75
|
+
const components = (0, hierarchyUtils_1.breadthFirstCompontents)(projectedNodes, componentMap);
|
|
76
|
+
const largestComponent = Math.max(projectedNodes.length / 3, components[0].componentNodes.length);
|
|
77
|
+
const layoutSize = size[0] > size[1] ? size[1] : size[0];
|
|
78
|
+
const layoutDirection = size[0] > size[1] ? "horizontal" : "vertical";
|
|
79
|
+
// Adaptive iteration count for motifs layout (same as force layout)
|
|
80
|
+
const nodeCount = projectedNodes.length;
|
|
81
|
+
const adaptiveIterations = Math.max(50, Math.min(300, Math.floor(300 - (nodeCount - 30) * 2)));
|
|
82
|
+
const { iterations = adaptiveIterations, edgeStrength = 0.1, edgeDistance, padding = 0 } = networkSettings;
|
|
83
|
+
let currentX = padding;
|
|
84
|
+
let currentY = padding;
|
|
85
|
+
components.forEach(({ componentNodes, componentEdges }) => {
|
|
86
|
+
const linkForce = (0, d3_force_1.forceLink)().strength((d) => Math.min(2.5, d.weight ? d.weight * edgeStrength : edgeStrength));
|
|
87
|
+
if (edgeDistance) {
|
|
88
|
+
linkForce.distance(edgeDistance);
|
|
89
|
+
}
|
|
90
|
+
const componentLayoutSize = Math.max(componentNodes.length / largestComponent, 0.2) * layoutSize;
|
|
91
|
+
const xBound = componentLayoutSize + currentX;
|
|
92
|
+
const yBound = componentLayoutSize + currentY;
|
|
93
|
+
if (layoutDirection === "horizontal") {
|
|
94
|
+
if (yBound > size[1]) {
|
|
95
|
+
currentX = componentLayoutSize + currentX + padding;
|
|
96
|
+
currentY = componentLayoutSize + padding;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
currentY = componentLayoutSize + currentY + padding;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
if (xBound > size[0]) {
|
|
104
|
+
currentY = componentLayoutSize + currentY + padding;
|
|
105
|
+
currentX = componentLayoutSize + padding;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
currentX = componentLayoutSize + currentX + padding;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const xCenter = currentX - componentLayoutSize / 2;
|
|
112
|
+
const yCenter = currentY - componentLayoutSize / 2;
|
|
113
|
+
const simulation = (0, d3_force_1.forceSimulation)()
|
|
114
|
+
.force("charge", (0, d3_force_1.forceManyBody)().strength(networkSettings.forceManyBody ||
|
|
115
|
+
((d) => -25 * nodeSizeAccessor(d))))
|
|
116
|
+
.force("link", linkForce);
|
|
117
|
+
simulation
|
|
118
|
+
.force("x", (0, d3_force_1.forceX)(xCenter))
|
|
119
|
+
.force("y", (0, d3_force_1.forceY)(yCenter))
|
|
120
|
+
.nodes(componentNodes);
|
|
121
|
+
simulation.force("link").links(componentEdges);
|
|
122
|
+
simulation.stop();
|
|
123
|
+
for (let i = 0; i < iterations; ++i)
|
|
124
|
+
simulation.tick();
|
|
125
|
+
const maxX = (0, d3_array_1.max)(componentNodes.map((d) => d.x));
|
|
126
|
+
const maxY = (0, d3_array_1.max)(componentNodes.map((d) => d.y));
|
|
127
|
+
const minX = (0, d3_array_1.min)(componentNodes.map((d) => d.x));
|
|
128
|
+
const minY = (0, d3_array_1.min)(componentNodes.map((d) => d.y));
|
|
129
|
+
const resetX = (0, d3_scale_1.scaleLinear)()
|
|
130
|
+
.domain([minX, maxX])
|
|
131
|
+
.range([currentX - componentLayoutSize, currentX - 20]);
|
|
132
|
+
const resetY = (0, d3_scale_1.scaleLinear)()
|
|
133
|
+
.domain([minY, maxY])
|
|
134
|
+
.range([currentY - componentLayoutSize, currentY - 20]);
|
|
135
|
+
componentNodes.forEach((node) => {
|
|
136
|
+
node.x = resetX(node.x);
|
|
137
|
+
node.y = resetY(node.y);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
return { projectedNodes, projectedEdges, components };
|
|
141
|
+
};
|
|
142
|
+
exports.motifsLayout = motifsLayout;
|