semiotic 3.0.0-beta.2 → 3.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +93 -753
- package/README.md +92 -7
- package/ai/dist/componentRegistry.js +26 -0
- package/ai/dist/{ai/mcp-server.js → mcp-server.js} +1 -1
- package/ai/dist/{ai/renderHOCToSVG.js → renderHOCToSVG.js} +2 -2
- package/dist/ChartContainer.d.ts +60 -0
- package/dist/DetailsPanel.d.ts +37 -0
- package/dist/LinkedCharts.d.ts +2 -0
- package/dist/Tooltip/Tooltip.d.ts +2 -2
- package/dist/charts/index.d.ts +1 -1
- package/dist/charts/ordinal/BarChart.d.ts +1 -0
- package/dist/charts/ordinal/BoxPlot.d.ts +1 -0
- package/dist/charts/ordinal/DonutChart.d.ts +1 -0
- package/dist/charts/ordinal/DotPlot.d.ts +1 -0
- package/dist/charts/ordinal/GroupedBarChart.d.ts +1 -0
- package/dist/charts/ordinal/Histogram.d.ts +1 -0
- package/dist/charts/ordinal/PieChart.d.ts +1 -0
- package/dist/charts/ordinal/RidgelinePlot.d.ts +1 -0
- package/dist/charts/ordinal/StackedBarChart.d.ts +1 -0
- package/dist/charts/ordinal/SwarmPlot.d.ts +1 -0
- package/dist/charts/ordinal/ViolinPlot.d.ts +1 -0
- package/dist/charts/realtime/RealtimeHeatmap.d.ts +11 -0
- package/dist/charts/realtime/RealtimeHistogram.d.ts +15 -1
- package/dist/charts/realtime/RealtimeLineChart.d.ts +6 -0
- package/dist/charts/realtime/RealtimeSwarmChart.d.ts +6 -0
- package/dist/charts/realtime/RealtimeWaterfallChart.d.ts +6 -0
- package/dist/charts/shared/annotationRules.d.ts +3 -0
- package/dist/charts/shared/colorUtils.d.ts +17 -11
- package/dist/charts/shared/hooks.d.ts +96 -1
- package/dist/charts/shared/loess.d.ts +13 -0
- package/dist/charts/shared/networkUtils.d.ts +31 -0
- package/dist/charts/shared/tooltipUtils.d.ts +16 -0
- package/dist/charts/shared/types.d.ts +17 -2
- package/dist/charts/shared/validateChartData.d.ts +2 -3
- package/dist/charts/shared/validateProps.d.ts +18 -0
- package/dist/charts/xy/AreaChart.d.ts +4 -0
- package/dist/charts/xy/BubbleChart.d.ts +6 -0
- package/dist/charts/xy/Heatmap.d.ts +4 -0
- package/dist/charts/xy/LineChart.d.ts +6 -0
- package/dist/charts/xy/Scatterplot.d.ts +4 -0
- package/dist/charts/xy/StackedAreaChart.d.ts +4 -0
- package/dist/data/fromVegaLite.d.ts +48 -0
- package/dist/export/chartConfig.d.ts +29 -0
- package/dist/export/selectionSerializer.d.ts +20 -0
- package/dist/geometry/sankeyLinks.d.ts +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime/types.d.ts +20 -6
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai.d.ts +14 -0
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-data.d.ts +2 -0
- package/dist/semiotic-data.min.js +1 -1
- package/dist/semiotic-data.module.min.js +1 -1
- package/dist/semiotic-network.d.ts +9 -19
- package/dist/semiotic-ordinal.d.ts +12 -14
- package/dist/semiotic-xy.d.ts +12 -18
- package/dist/semiotic.d.ts +16 -13
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/store/ObservationStore.d.ts +61 -0
- package/dist/store/SelectionStore.d.ts +9 -1
- package/dist/store/ThemeStore.d.ts +6 -1
- package/dist/store/TooltipStore.d.ts +3 -1
- package/dist/store/createStore.d.ts +4 -1
- package/dist/store/useObservation.d.ts +18 -0
- package/dist/stream/MarginalGraphics.d.ts +1 -1
- package/dist/stream/NetworkPipelineStore.d.ts +44 -0
- package/dist/stream/OrdinalCanvasHitTester.d.ts +1 -0
- package/dist/stream/OrdinalSVGOverlay.d.ts +6 -2
- package/dist/stream/ParticlePool.d.ts +2 -1
- package/dist/stream/PipelineStore.d.ts +11 -0
- package/dist/stream/SVGOverlay.d.ts +21 -2
- package/dist/stream/SceneGraph.d.ts +1 -1
- package/dist/stream/networkTypes.d.ts +58 -1
- package/dist/stream/ordinalTypes.d.ts +13 -0
- package/dist/stream/types.d.ts +14 -0
- package/dist/types/annotationTypes.d.ts +10 -0
- package/dist/types/networkTypes.d.ts +1 -2
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +30 -42
- package/ai/dist/ai/componentRegistry.js +0 -45
- package/ai/dist/src/components/Annotation.js +0 -358
- package/ai/dist/src/components/AnnotationLayer/AnnotationLayer.js +0 -369
- package/ai/dist/src/components/Axis/Axis.js +0 -374
- package/ai/dist/src/components/Axis/axisTitle.js +0 -14
- package/ai/dist/src/components/Axis/index.js +0 -7
- package/ai/dist/src/components/Axis/summaryGraphic.js +0 -37
- package/ai/dist/src/components/Brush.js +0 -84
- package/ai/dist/src/components/ChartErrorBoundary.js +0 -91
- package/ai/dist/src/components/DividedLine.js +0 -65
- package/ai/dist/src/components/Legend.js +0 -140
- package/ai/dist/src/components/LinkedCharts.js +0 -95
- package/ai/dist/src/components/ThemeProvider.js +0 -79
- package/ai/dist/src/components/Tooltip/Tooltip.js +0 -309
- package/ai/dist/src/components/TooltipPositioner/index.js +0 -132
- package/ai/dist/src/components/annotationLayerBehavior/annotationHandling.js +0 -73
- package/ai/dist/src/components/annotationLayerBehavior/d3labeler.js +0 -254
- package/ai/dist/src/components/annotationRules/baseRules.js +0 -150
- package/ai/dist/src/components/annotationRules/networkframeRules.js +0 -196
- package/ai/dist/src/components/annotationRules/xyframeRules.js +0 -297
- package/ai/dist/src/components/batchWork.js +0 -35
- package/ai/dist/src/components/charts/index.js +0 -109
- package/ai/dist/src/components/charts/network/ChordDiagram.js +0 -142
- package/ai/dist/src/components/charts/network/CirclePack.js +0 -108
- package/ai/dist/src/components/charts/network/ForceDirectedGraph.js +0 -121
- package/ai/dist/src/components/charts/network/SankeyDiagram.js +0 -155
- package/ai/dist/src/components/charts/network/TreeDiagram.js +0 -110
- package/ai/dist/src/components/charts/network/Treemap.js +0 -106
- package/ai/dist/src/components/charts/ordinal/BarChart.js +0 -156
- package/ai/dist/src/components/charts/ordinal/BoxPlot.js +0 -139
- package/ai/dist/src/components/charts/ordinal/DonutChart.js +0 -130
- package/ai/dist/src/components/charts/ordinal/DotPlot.js +0 -126
- package/ai/dist/src/components/charts/ordinal/GroupedBarChart.js +0 -129
- package/ai/dist/src/components/charts/ordinal/Histogram.js +0 -132
- package/ai/dist/src/components/charts/ordinal/PieChart.js +0 -128
- package/ai/dist/src/components/charts/ordinal/RidgelinePlot.js +0 -130
- package/ai/dist/src/components/charts/ordinal/StackedBarChart.js +0 -130
- package/ai/dist/src/components/charts/ordinal/SwarmPlot.js +0 -147
- package/ai/dist/src/components/charts/ordinal/ViolinPlot.js +0 -138
- package/ai/dist/src/components/charts/realtime/RealtimeHeatmap.js +0 -79
- package/ai/dist/src/components/charts/realtime/RealtimeHistogram.js +0 -114
- package/ai/dist/src/components/charts/realtime/RealtimeLineChart.js +0 -93
- package/ai/dist/src/components/charts/realtime/RealtimeSwarmChart.js +0 -105
- package/ai/dist/src/components/charts/realtime/RealtimeWaterfallChart.js +0 -106
- package/ai/dist/src/components/charts/shared/ChartError.js +0 -72
- package/ai/dist/src/components/charts/shared/colorUtils.js +0 -138
- package/ai/dist/src/components/charts/shared/formatUtils.js +0 -213
- package/ai/dist/src/components/charts/shared/hooks.js +0 -49
- package/ai/dist/src/components/charts/shared/legendUtils.js +0 -57
- package/ai/dist/src/components/charts/shared/selectionUtils.js +0 -67
- package/ai/dist/src/components/charts/shared/tooltipUtils.js +0 -79
- package/ai/dist/src/components/charts/shared/types.js +0 -2
- package/ai/dist/src/components/charts/shared/validateChartData.js +0 -82
- package/ai/dist/src/components/charts/shared/validateProps.js +0 -736
- package/ai/dist/src/components/charts/xy/AreaChart.js +0 -230
- package/ai/dist/src/components/charts/xy/BubbleChart.js +0 -251
- package/ai/dist/src/components/charts/xy/Heatmap.js +0 -235
- package/ai/dist/src/components/charts/xy/LineChart.js +0 -307
- package/ai/dist/src/components/charts/xy/MinimapChart.js +0 -298
- package/ai/dist/src/components/charts/xy/Scatterplot.js +0 -172
- package/ai/dist/src/components/charts/xy/ScatterplotMatrix.js +0 -426
- package/ai/dist/src/components/charts/xy/StackedAreaChart.js +0 -231
- package/ai/dist/src/components/constants/coordinateNames.js +0 -11
- package/ai/dist/src/components/constants/frame_props.js +0 -251
- package/ai/dist/src/components/data/dataFunctions.js +0 -487
- package/ai/dist/src/components/data/multiAccessorUtils.js +0 -14
- package/ai/dist/src/components/data/transforms.js +0 -143
- package/ai/dist/src/components/data/unflowedFunctions.js +0 -5
- package/ai/dist/src/components/export/exportChart.js +0 -121
- package/ai/dist/src/components/generic_utilities/functions.js +0 -5
- package/ai/dist/src/components/geometry/areaDrawing.js +0 -312
- package/ai/dist/src/components/geometry/contourLayout.js +0 -73
- package/ai/dist/src/components/geometry/hexbinLayout.js +0 -163
- package/ai/dist/src/components/geometry/lineDrawing.js +0 -356
- package/ai/dist/src/components/geometry/sankeyLinks.js +0 -331
- package/ai/dist/src/components/geometry/summaryLayouts.js +0 -136
- package/ai/dist/src/components/index.js +0 -18
- package/ai/dist/src/components/processing/InteractionItems.js +0 -223
- package/ai/dist/src/components/processing/hierarchyUtils.js +0 -104
- package/ai/dist/src/components/processing/layouts/chordLayout.js +0 -58
- package/ai/dist/src/components/processing/layouts/forceLayout.js +0 -142
- package/ai/dist/src/components/processing/layouts/hierarchyLayout.js +0 -31
- package/ai/dist/src/components/processing/layouts/index.js +0 -32
- package/ai/dist/src/components/processing/layouts/sankeyLayout.js +0 -96
- package/ai/dist/src/components/processing/layouts/simpleLayouts.js +0 -34
- package/ai/dist/src/components/processing/layouts/types.js +0 -2
- package/ai/dist/src/components/processing/networkDefaults.js +0 -39
- package/ai/dist/src/components/realtime/BinAccumulator.js +0 -36
- package/ai/dist/src/components/realtime/IncrementalExtent.js +0 -55
- package/ai/dist/src/components/realtime/RingBuffer.js +0 -104
- package/ai/dist/src/components/realtime/renderers/barRenderer.js +0 -133
- package/ai/dist/src/components/realtime/renderers/candlestickRenderer.js +0 -7
- package/ai/dist/src/components/realtime/renderers/lineRenderer.js +0 -164
- package/ai/dist/src/components/realtime/renderers/swarmRenderer.js +0 -91
- package/ai/dist/src/components/realtime/renderers/types.js +0 -2
- package/ai/dist/src/components/realtime/renderers/waterfallRenderer.js +0 -163
- package/ai/dist/src/components/realtime/types.js +0 -2
- package/ai/dist/src/components/semiotic-ai.js +0 -89
- package/ai/dist/src/components/semiotic-data.js +0 -12
- package/ai/dist/src/components/semiotic-network.js +0 -38
- package/ai/dist/src/components/semiotic-ordinal.js +0 -28
- package/ai/dist/src/components/semiotic-realtime.js +0 -30
- package/ai/dist/src/components/semiotic-server.js +0 -8
- package/ai/dist/src/components/semiotic-xy.js +0 -35
- package/ai/dist/src/components/semiotic.js +0 -109
- package/ai/dist/src/components/server/renderToStaticSVG.js +0 -594
- package/ai/dist/src/components/store/SelectionStore.js +0 -91
- package/ai/dist/src/components/store/ThemeStore.js +0 -78
- package/ai/dist/src/components/store/TooltipStore.js +0 -13
- package/ai/dist/src/components/store/createStore.js +0 -81
- package/ai/dist/src/components/store/useSelection.js +0 -133
- package/ai/dist/src/components/stream/CanvasHitTester.js +0 -164
- package/ai/dist/src/components/stream/DataSourceAdapter.js +0 -99
- package/ai/dist/src/components/stream/MarginalGraphics.js +0 -266
- package/ai/dist/src/components/stream/NetworkCanvasHitTester.js +0 -228
- package/ai/dist/src/components/stream/NetworkPipelineStore.js +0 -498
- package/ai/dist/src/components/stream/NetworkSVGOverlay.js +0 -70
- package/ai/dist/src/components/stream/NetworkSceneGraph.js +0 -38
- package/ai/dist/src/components/stream/OrdinalCanvasHitTester.js +0 -146
- package/ai/dist/src/components/stream/OrdinalPipelineStore.js +0 -786
- package/ai/dist/src/components/stream/OrdinalSVGOverlay.js +0 -130
- package/ai/dist/src/components/stream/ParticlePool.js +0 -174
- package/ai/dist/src/components/stream/PipelineStore.js +0 -1243
- package/ai/dist/src/components/stream/SVGOverlay.js +0 -129
- package/ai/dist/src/components/stream/SceneGraph.js +0 -132
- package/ai/dist/src/components/stream/StreamNetworkFrame.js +0 -561
- package/ai/dist/src/components/stream/StreamOrdinalFrame.js +0 -492
- package/ai/dist/src/components/stream/StreamXYFrame.js +0 -590
- package/ai/dist/src/components/stream/accessorUtils.js +0 -20
- package/ai/dist/src/components/stream/index.js +0 -32
- package/ai/dist/src/components/stream/layouts/chordLayoutPlugin.js +0 -352
- package/ai/dist/src/components/stream/layouts/forceLayoutPlugin.js +0 -230
- package/ai/dist/src/components/stream/layouts/hierarchyLayoutPlugin.js +0 -568
- package/ai/dist/src/components/stream/layouts/index.js +0 -28
- package/ai/dist/src/components/stream/layouts/sankeyLayoutPlugin.js +0 -245
- package/ai/dist/src/components/stream/networkTypes.js +0 -17
- package/ai/dist/src/components/stream/ordinalSceneBuilders/barScene.js +0 -126
- package/ai/dist/src/components/stream/ordinalSceneBuilders/connectorScene.js +0 -62
- package/ai/dist/src/components/stream/ordinalSceneBuilders/pieScene.js +0 -33
- package/ai/dist/src/components/stream/ordinalSceneBuilders/pointScene.js +0 -63
- package/ai/dist/src/components/stream/ordinalSceneBuilders/statisticalScene.js +0 -278
- package/ai/dist/src/components/stream/ordinalSceneBuilders/timelineScene.js +0 -30
- package/ai/dist/src/components/stream/ordinalSceneBuilders/types.js +0 -2
- package/ai/dist/src/components/stream/ordinalTypes.js +0 -2
- package/ai/dist/src/components/stream/renderers/areaCanvasRenderer.js +0 -48
- package/ai/dist/src/components/stream/renderers/barCanvasRenderer.js +0 -70
- package/ai/dist/src/components/stream/renderers/boxplotCanvasRenderer.js +0 -75
- package/ai/dist/src/components/stream/renderers/candlestickCanvasRenderer.js +0 -28
- package/ai/dist/src/components/stream/renderers/connectorCanvasRenderer.js +0 -47
- package/ai/dist/src/components/stream/renderers/heatmapCanvasRenderer.js +0 -31
- package/ai/dist/src/components/stream/renderers/lineCanvasRenderer.js +0 -140
- package/ai/dist/src/components/stream/renderers/networkArcRenderer.js +0 -38
- package/ai/dist/src/components/stream/renderers/networkCircleRenderer.js +0 -37
- package/ai/dist/src/components/stream/renderers/networkEdgeRenderer.js +0 -102
- package/ai/dist/src/components/stream/renderers/networkParticleRenderer.js +0 -63
- package/ai/dist/src/components/stream/renderers/networkRectRenderer.js +0 -35
- package/ai/dist/src/components/stream/renderers/pointCanvasRenderer.js +0 -38
- package/ai/dist/src/components/stream/renderers/swarmCanvasRenderer.js +0 -10
- package/ai/dist/src/components/stream/renderers/types.js +0 -2
- package/ai/dist/src/components/stream/renderers/violinCanvasRenderer.js +0 -47
- package/ai/dist/src/components/stream/renderers/waterfallCanvasRenderer.js +0 -38
- package/ai/dist/src/components/stream/renderers/wedgeCanvasRenderer.js +0 -33
- package/ai/dist/src/components/stream/types.js +0 -2
- package/ai/dist/src/components/types/annotationTypes.js +0 -2
- package/ai/dist/src/components/types/canvasTypes.js +0 -2
- package/ai/dist/src/components/types/generalTypes.js +0 -2
- package/ai/dist/src/components/types/interactionTypes.js +0 -2
- package/ai/dist/src/components/types/legendTypes.js +0 -2
- package/ai/dist/src/components/types/networkTypes.js +0 -2
- package/ai/dist/src/components/types/ordinalTypes.js +0 -2
- package/ai/dist/src/components/types/xyTypes.js +0 -2
- package/ai/dist/src/components/useBoundingRect.js +0 -24
- package/ai/dist/src/components/visualizationLayerBehavior/axis.js +0 -301
- package/ai/dist/src/components/visualizationLayerBehavior/general.js +0 -435
- package/ai/dist/src/setupTests.js +0 -4
- package/dist/AnnotationLayer/AnnotationLayer.d.ts +0 -25
- package/dist/Axis/Axis.d.ts +0 -7
- package/dist/Axis/axisTitle.d.ts +0 -10
- package/dist/Axis/index.d.ts +0 -2
- package/dist/Axis/summaryGraphic.d.ts +0 -17
- package/dist/Brush.d.ts +0 -12
- package/dist/DividedLine.d.ts +0 -16
- package/dist/TooltipPositioner/index.d.ts +0 -7
- package/dist/annotationLayerBehavior/annotationHandling.d.ts +0 -19
- package/dist/annotationLayerBehavior/d3labeler.d.ts +0 -9
- package/dist/annotationRules/baseRules.d.ts +0 -25
- package/dist/annotationRules/networkframeRules.d.ts +0 -48
- package/dist/annotationRules/xyframeRules.d.ts +0 -117
- package/dist/batchWork.d.ts +0 -6
- package/dist/constants/coordinateNames.d.ts +0 -8
- package/dist/constants/frame_props.d.ts +0 -13
- package/dist/data/dataFunctions.d.ts +0 -45
- package/dist/data/multiAccessorUtils.d.ts +0 -1
- package/dist/data/unflowedFunctions.d.ts +0 -1
- package/dist/generic_utilities/functions.d.ts +0 -1
- package/dist/geometry/areaDrawing.d.ts +0 -21
- package/dist/geometry/contourLayout.d.ts +0 -6
- package/dist/geometry/hexbinLayout.d.ts +0 -7
- package/dist/geometry/lineDrawing.d.ts +0 -71
- package/dist/geometry/summaryLayouts.d.ts +0 -45
- package/dist/index.d.ts +0 -1
- package/dist/network.js +0 -7495
- package/dist/network.js.map +0 -1
- package/dist/network.module.js +0 -7458
- package/dist/network.module.js.map +0 -1
- package/dist/ordinal.js +0 -6497
- package/dist/ordinal.js.map +0 -1
- package/dist/ordinal.module.js +0 -6465
- package/dist/ordinal.module.js.map +0 -1
- package/dist/processing/InteractionItems.d.ts +0 -13
- package/dist/processing/hierarchyUtils.d.ts +0 -16
- package/dist/processing/layouts/chordLayout.d.ts +0 -2
- package/dist/processing/layouts/forceLayout.d.ts +0 -3
- package/dist/processing/layouts/hierarchyLayout.d.ts +0 -10
- package/dist/processing/layouts/index.d.ts +0 -8
- package/dist/processing/layouts/sankeyLayout.d.ts +0 -8
- package/dist/processing/layouts/simpleLayouts.d.ts +0 -7
- package/dist/processing/layouts/types.d.ts +0 -17
- package/dist/processing/networkDefaults.d.ts +0 -36
- package/dist/realtime/renderers/barRenderer.d.ts +0 -2
- package/dist/realtime/renderers/candlestickRenderer.d.ts +0 -2
- package/dist/realtime/renderers/lineRenderer.d.ts +0 -2
- package/dist/realtime/renderers/swarmRenderer.d.ts +0 -2
- package/dist/realtime.js +0 -7072
- package/dist/realtime.js.map +0 -1
- package/dist/realtime.module.js +0 -7043
- package/dist/realtime.module.js.map +0 -1
- package/dist/semiotic-ai.js +0 -13323
- package/dist/semiotic-ai.js.map +0 -1
- package/dist/semiotic-ai.module.js +0 -13264
- package/dist/semiotic-ai.module.js.map +0 -1
- package/dist/semiotic-data.js +0 -141
- package/dist/semiotic-data.js.map +0 -1
- package/dist/semiotic-data.module.js +0 -136
- package/dist/semiotic-data.module.js.map +0 -1
- package/dist/semiotic.js +0 -16351
- package/dist/semiotic.js.map +0 -1
- package/dist/semiotic.module.js +0 -16265
- package/dist/semiotic.module.js.map +0 -1
- package/dist/server.js +0 -5191
- package/dist/server.js.map +0 -1
- package/dist/server.module.js +0 -5166
- package/dist/server.module.js.map +0 -1
- package/dist/stream/NetworkSceneGraph.d.ts +0 -14
- package/dist/stream/index.d.ts +0 -16
- package/dist/types/canvasTypes.d.ts +0 -9
- package/dist/types/xyTypes.d.ts +0 -24
- package/dist/useBoundingRect.d.ts +0 -2
- package/dist/visualizationLayerBehavior/axis.d.ts +0 -36
- package/dist/visualizationLayerBehavior/general.d.ts +0 -80
- package/dist/xy.js +0 -6993
- package/dist/xy.js.map +0 -1
- package/dist/xy.module.js +0 -6957
- package/dist/xy.module.js.map +0 -1
|
@@ -1,266 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.normalizeMarginalConfig = normalizeMarginalConfig;
|
|
38
|
-
exports.MarginalGraphics = MarginalGraphics;
|
|
39
|
-
const React = __importStar(require("react"));
|
|
40
|
-
const react_1 = require("react");
|
|
41
|
-
const d3_array_1 = require("d3-array");
|
|
42
|
-
/** Resolve a string shorthand or full config into a MarginalConfig */
|
|
43
|
-
function normalizeMarginalConfig(input) {
|
|
44
|
-
if (typeof input === "string") {
|
|
45
|
-
return { type: input };
|
|
46
|
-
}
|
|
47
|
-
return input;
|
|
48
|
-
}
|
|
49
|
-
const DEFAULTS = {
|
|
50
|
-
bins: 20,
|
|
51
|
-
fill: "#4e79a7",
|
|
52
|
-
fillOpacity: 0.5,
|
|
53
|
-
stroke: "none",
|
|
54
|
-
strokeWidth: 1
|
|
55
|
-
};
|
|
56
|
-
function resolveConfig(config) {
|
|
57
|
-
return {
|
|
58
|
-
type: config.type,
|
|
59
|
-
bins: config.bins ?? DEFAULTS.bins,
|
|
60
|
-
fill: config.fill ?? DEFAULTS.fill,
|
|
61
|
-
fillOpacity: config.fillOpacity ?? DEFAULTS.fillOpacity,
|
|
62
|
-
stroke: config.stroke ?? DEFAULTS.stroke,
|
|
63
|
-
strokeWidth: config.strokeWidth ?? DEFAULTS.strokeWidth
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
/** Compute quartiles and whiskers for boxplot */
|
|
67
|
-
function boxplotStats(values) {
|
|
68
|
-
const sorted = [...values].sort((a, b) => a - b);
|
|
69
|
-
const n = sorted.length;
|
|
70
|
-
if (n === 0)
|
|
71
|
-
return null;
|
|
72
|
-
const q1 = sorted[Math.floor(n * 0.25)];
|
|
73
|
-
const median = sorted[Math.floor(n * 0.5)];
|
|
74
|
-
const q3 = sorted[Math.floor(n * 0.75)];
|
|
75
|
-
const iqr = q3 - q1;
|
|
76
|
-
const whiskerLow = Math.max(sorted[0], q1 - 1.5 * iqr);
|
|
77
|
-
const whiskerHigh = Math.min(sorted[n - 1], q3 + 1.5 * iqr);
|
|
78
|
-
return { q1, median, q3, whiskerLow, whiskerHigh };
|
|
79
|
-
}
|
|
80
|
-
function MarginalGraphics({ orient, config: rawConfig, values, scale, size, length }) {
|
|
81
|
-
const config = resolveConfig(rawConfig);
|
|
82
|
-
const padding = 4;
|
|
83
|
-
const isHorizontal = orient === "top" || orient === "bottom";
|
|
84
|
-
const content = (0, react_1.useMemo)(() => {
|
|
85
|
-
if (values.length === 0)
|
|
86
|
-
return null;
|
|
87
|
-
const domain = scale.domain();
|
|
88
|
-
const availableSize = size - padding * 2;
|
|
89
|
-
if (config.type === "boxplot") {
|
|
90
|
-
const stats = boxplotStats(values);
|
|
91
|
-
if (!stats)
|
|
92
|
-
return null;
|
|
93
|
-
const { q1, median, q3, whiskerLow, whiskerHigh } = stats;
|
|
94
|
-
const boxThickness = Math.min(availableSize * 0.5, 20);
|
|
95
|
-
const offset = (availableSize - boxThickness) / 2 + padding;
|
|
96
|
-
if (isHorizontal) {
|
|
97
|
-
const x1 = scale(q1);
|
|
98
|
-
const x2 = scale(q3);
|
|
99
|
-
const xMed = scale(median);
|
|
100
|
-
const xWLow = scale(whiskerLow);
|
|
101
|
-
const xWHigh = scale(whiskerHigh);
|
|
102
|
-
const growDir = orient === "top" ? -1 : 1;
|
|
103
|
-
const baseY = orient === "top" ? 0 : 0;
|
|
104
|
-
return (React.createElement("g", { "data-testid": `marginal-boxplot-${orient}` },
|
|
105
|
-
React.createElement("line", { x1: xWLow, y1: baseY + growDir * (offset + boxThickness / 2), x2: xWHigh, y2: baseY + growDir * (offset + boxThickness / 2), stroke: config.fill, strokeWidth: config.strokeWidth }),
|
|
106
|
-
React.createElement("line", { x1: xWLow, y1: baseY + growDir * offset, x2: xWLow, y2: baseY + growDir * (offset + boxThickness), stroke: config.fill, strokeWidth: config.strokeWidth }),
|
|
107
|
-
React.createElement("line", { x1: xWHigh, y1: baseY + growDir * offset, x2: xWHigh, y2: baseY + growDir * (offset + boxThickness), stroke: config.fill, strokeWidth: config.strokeWidth }),
|
|
108
|
-
React.createElement("rect", { x: Math.min(x1, x2), y: orient === "top" ? baseY - offset - boxThickness : baseY + offset, width: Math.abs(x2 - x1), height: boxThickness, fill: config.fill, fillOpacity: config.fillOpacity, stroke: config.stroke === "none" ? config.fill : config.stroke, strokeWidth: config.strokeWidth }),
|
|
109
|
-
React.createElement("line", { x1: xMed, y1: orient === "top" ? baseY - offset - boxThickness : baseY + offset, x2: xMed, y2: orient === "top" ? baseY - offset : baseY + offset + boxThickness, stroke: config.fill, strokeWidth: 2 })));
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
// Vertical: left/right
|
|
113
|
-
const y1 = scale(q1);
|
|
114
|
-
const y2 = scale(q3);
|
|
115
|
-
const yMed = scale(median);
|
|
116
|
-
const yWLow = scale(whiskerLow);
|
|
117
|
-
const yWHigh = scale(whiskerHigh);
|
|
118
|
-
const growDir = orient === "left" ? -1 : 1;
|
|
119
|
-
const baseX = 0;
|
|
120
|
-
return (React.createElement("g", { "data-testid": `marginal-boxplot-${orient}` },
|
|
121
|
-
React.createElement("line", { x1: baseX + growDir * (offset + boxThickness / 2), y1: yWLow, x2: baseX + growDir * (offset + boxThickness / 2), y2: yWHigh, stroke: config.fill, strokeWidth: config.strokeWidth }),
|
|
122
|
-
React.createElement("line", { x1: baseX + growDir * offset, y1: yWLow, x2: baseX + growDir * (offset + boxThickness), y2: yWLow, stroke: config.fill, strokeWidth: config.strokeWidth }),
|
|
123
|
-
React.createElement("line", { x1: baseX + growDir * offset, y1: yWHigh, x2: baseX + growDir * (offset + boxThickness), y2: yWHigh, stroke: config.fill, strokeWidth: config.strokeWidth }),
|
|
124
|
-
React.createElement("rect", { x: orient === "left" ? baseX - offset - boxThickness : baseX + offset, y: Math.min(y1, y2), width: boxThickness, height: Math.abs(y2 - y1), fill: config.fill, fillOpacity: config.fillOpacity, stroke: config.stroke === "none" ? config.fill : config.stroke, strokeWidth: config.strokeWidth }),
|
|
125
|
-
React.createElement("line", { x1: orient === "left" ? baseX - offset - boxThickness : baseX + offset, y1: yMed, x2: orient === "left" ? baseX - offset : baseX + offset + boxThickness, y2: yMed, stroke: config.fill, strokeWidth: 2 })));
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
// Binned types: histogram, violin, ridgeline
|
|
129
|
-
const binner = (0, d3_array_1.bin)()
|
|
130
|
-
.domain(domain)
|
|
131
|
-
.thresholds(config.bins);
|
|
132
|
-
const bins = binner(values);
|
|
133
|
-
if (bins.length === 0)
|
|
134
|
-
return null;
|
|
135
|
-
const maxCount = Math.max(...bins.map(b => b.length));
|
|
136
|
-
if (maxCount === 0)
|
|
137
|
-
return null;
|
|
138
|
-
if (config.type === "histogram") {
|
|
139
|
-
return (React.createElement("g", { "data-testid": `marginal-histogram-${orient}` }, bins.map((bin, i) => {
|
|
140
|
-
if (bin.x0 == null || bin.x1 == null)
|
|
141
|
-
return null;
|
|
142
|
-
const count = bin.length;
|
|
143
|
-
const barSize = (count / maxCount) * availableSize;
|
|
144
|
-
if (isHorizontal) {
|
|
145
|
-
const x = scale(bin.x0);
|
|
146
|
-
const w = scale(bin.x1) - scale(bin.x0);
|
|
147
|
-
const y = orient === "top" ? -padding - barSize : padding;
|
|
148
|
-
return (React.createElement("rect", { key: i, x: x, y: y, width: Math.max(w, 0.5), height: barSize, fill: config.fill, fillOpacity: config.fillOpacity, stroke: config.stroke, strokeWidth: config.strokeWidth }));
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
const y = scale(bin.x0);
|
|
152
|
-
const h = scale(bin.x1) - scale(bin.x0);
|
|
153
|
-
const x = orient === "left" ? -padding - barSize : padding;
|
|
154
|
-
return (React.createElement("rect", { key: i, x: x, y: Math.min(y, y + h), width: barSize, height: Math.abs(h), fill: config.fill, fillOpacity: config.fillOpacity, stroke: config.stroke, strokeWidth: config.strokeWidth }));
|
|
155
|
-
}
|
|
156
|
-
})));
|
|
157
|
-
}
|
|
158
|
-
if (config.type === "violin") {
|
|
159
|
-
// Symmetric density path around the midline
|
|
160
|
-
const midline = availableSize / 2 + padding;
|
|
161
|
-
const points = [];
|
|
162
|
-
// Forward pass (one side)
|
|
163
|
-
for (const bin of bins) {
|
|
164
|
-
if (bin.x0 == null || bin.x1 == null)
|
|
165
|
-
continue;
|
|
166
|
-
const mid = (bin.x0 + bin.x1) / 2;
|
|
167
|
-
const w = (bin.length / maxCount) * (availableSize / 2);
|
|
168
|
-
const pos = scale(mid);
|
|
169
|
-
if (isHorizontal) {
|
|
170
|
-
const y = orient === "top" ? -(midline - w) : midline - w;
|
|
171
|
-
points.push(`${pos},${y}`);
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
const x = orient === "left" ? -(midline - w) : midline - w;
|
|
175
|
-
points.push(`${x},${pos}`);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
// Reverse pass (other side)
|
|
179
|
-
for (let i = bins.length - 1; i >= 0; i--) {
|
|
180
|
-
const bin = bins[i];
|
|
181
|
-
if (bin.x0 == null || bin.x1 == null)
|
|
182
|
-
continue;
|
|
183
|
-
const mid = (bin.x0 + bin.x1) / 2;
|
|
184
|
-
const w = (bin.length / maxCount) * (availableSize / 2);
|
|
185
|
-
const pos = scale(mid);
|
|
186
|
-
if (isHorizontal) {
|
|
187
|
-
const y = orient === "top" ? -(midline + w) : midline + w;
|
|
188
|
-
points.push(`${pos},${y}`);
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
const x = orient === "left" ? -(midline + w) : midline + w;
|
|
192
|
-
points.push(`${x},${pos}`);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return (React.createElement("g", { "data-testid": `marginal-violin-${orient}` },
|
|
196
|
-
React.createElement("polygon", { points: points.join(" "), fill: config.fill, fillOpacity: config.fillOpacity, stroke: config.stroke === "none" ? config.fill : config.stroke, strokeWidth: config.strokeWidth })));
|
|
197
|
-
}
|
|
198
|
-
if (config.type === "ridgeline") {
|
|
199
|
-
// One-sided area fill from baseline into the margin
|
|
200
|
-
const pathParts = [];
|
|
201
|
-
if (isHorizontal) {
|
|
202
|
-
const baseY = orient === "top" ? 0 : 0;
|
|
203
|
-
// Start at baseline
|
|
204
|
-
const startX = bins[0].x0 != null ? scale(bins[0].x0) : 0;
|
|
205
|
-
pathParts.push(`M${startX},${baseY}`);
|
|
206
|
-
for (const bin of bins) {
|
|
207
|
-
if (bin.x0 == null || bin.x1 == null)
|
|
208
|
-
continue;
|
|
209
|
-
const mid = (bin.x0 + bin.x1) / 2;
|
|
210
|
-
const h = (bin.length / maxCount) * availableSize;
|
|
211
|
-
const x = scale(mid);
|
|
212
|
-
const y = orient === "top" ? -h - padding : h + padding;
|
|
213
|
-
pathParts.push(`L${x},${y}`);
|
|
214
|
-
}
|
|
215
|
-
// Close back to baseline
|
|
216
|
-
const endX = bins[bins.length - 1].x1 != null ? scale(bins[bins.length - 1].x1) : length;
|
|
217
|
-
pathParts.push(`L${endX},${baseY}`);
|
|
218
|
-
pathParts.push("Z");
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
const baseX = 0;
|
|
222
|
-
const startY = bins[0].x0 != null ? scale(bins[0].x0) : 0;
|
|
223
|
-
pathParts.push(`M${baseX},${startY}`);
|
|
224
|
-
for (const bin of bins) {
|
|
225
|
-
if (bin.x0 == null || bin.x1 == null)
|
|
226
|
-
continue;
|
|
227
|
-
const mid = (bin.x0 + bin.x1) / 2;
|
|
228
|
-
const w = (bin.length / maxCount) * availableSize;
|
|
229
|
-
const y = scale(mid);
|
|
230
|
-
const x = orient === "left" ? -w - padding : w + padding;
|
|
231
|
-
pathParts.push(`L${x},${y}`);
|
|
232
|
-
}
|
|
233
|
-
const endY = bins[bins.length - 1].x1 != null ? scale(bins[bins.length - 1].x1) : length;
|
|
234
|
-
pathParts.push(`L${baseX},${endY}`);
|
|
235
|
-
pathParts.push("Z");
|
|
236
|
-
}
|
|
237
|
-
return (React.createElement("g", { "data-testid": `marginal-ridgeline-${orient}` },
|
|
238
|
-
React.createElement("path", { d: pathParts.join(" "), fill: config.fill, fillOpacity: config.fillOpacity, stroke: config.stroke === "none" ? config.fill : config.stroke, strokeWidth: config.strokeWidth })));
|
|
239
|
-
}
|
|
240
|
-
return null;
|
|
241
|
-
}, [values, scale, config, size, length, orient, isHorizontal, padding]);
|
|
242
|
-
if (!content)
|
|
243
|
-
return null;
|
|
244
|
-
// Position the <g> at the margin edge
|
|
245
|
-
let transform;
|
|
246
|
-
switch (orient) {
|
|
247
|
-
case "top":
|
|
248
|
-
transform = `translate(0, 0)`; // top edge of chart area
|
|
249
|
-
break;
|
|
250
|
-
case "bottom":
|
|
251
|
-
transform = `translate(0, ${length})`; // wait — length is chart width for top/bottom
|
|
252
|
-
break;
|
|
253
|
-
case "left":
|
|
254
|
-
transform = `translate(0, 0)`; // left edge of chart area
|
|
255
|
-
break;
|
|
256
|
-
case "right":
|
|
257
|
-
transform = `translate(${length}, 0)`; // length is chart width for left/right? No.
|
|
258
|
-
break;
|
|
259
|
-
}
|
|
260
|
-
// For top/bottom: length = chart width. The g is already inside the margin-translated group.
|
|
261
|
-
// For left/right: length = chart height.
|
|
262
|
-
// orient=bottom means we're at y=chartHeight (bottom of chart area)
|
|
263
|
-
// orient=right means we're at x=chartWidth (right of chart area)
|
|
264
|
-
// Actually, let the parent handle positioning. This component just draws relative to origin.
|
|
265
|
-
return (React.createElement("g", { className: `marginal-${orient}`, "data-testid": `marginal-${orient}` }, content));
|
|
266
|
-
}
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findNearestNetworkNode = findNearestNetworkNode;
|
|
4
|
-
/**
|
|
5
|
-
* Hit test against network scene nodes and edges.
|
|
6
|
-
*
|
|
7
|
-
* Checks nodes first (they're on top), then edges.
|
|
8
|
-
*/
|
|
9
|
-
function findNearestNetworkNode(sceneNodes, sceneEdges, px, py, maxDistance = 30) {
|
|
10
|
-
// Check nodes — for nested rects (treemap) we want the smallest
|
|
11
|
-
// containing rect, so we track rect hits by area separately.
|
|
12
|
-
let bestNode = null;
|
|
13
|
-
let bestDist = maxDistance;
|
|
14
|
-
let bestRectArea = Infinity;
|
|
15
|
-
for (const node of sceneNodes) {
|
|
16
|
-
const result = hitTestNode(node, px, py);
|
|
17
|
-
if (!result)
|
|
18
|
-
continue;
|
|
19
|
-
if (node.type === "rect") {
|
|
20
|
-
// For rects: prefer the smallest area (deepest cell)
|
|
21
|
-
const area = node.w * node.h;
|
|
22
|
-
if (area < bestRectArea) {
|
|
23
|
-
bestNode = result;
|
|
24
|
-
bestRectArea = area;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
else if (result.distance < bestDist) {
|
|
28
|
-
bestNode = result;
|
|
29
|
-
bestDist = result.distance;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (bestNode)
|
|
33
|
-
return bestNode;
|
|
34
|
-
// Check edges if no node hit
|
|
35
|
-
for (const edge of sceneEdges) {
|
|
36
|
-
const result = hitTestEdge(edge, px, py);
|
|
37
|
-
if (result && result.distance < bestDist) {
|
|
38
|
-
bestNode = result;
|
|
39
|
-
bestDist = result.distance;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return bestNode;
|
|
43
|
-
}
|
|
44
|
-
// ── Node hit testing ────────────────────────────────────────────────────
|
|
45
|
-
function hitTestNode(node, px, py) {
|
|
46
|
-
switch (node.type) {
|
|
47
|
-
case "circle":
|
|
48
|
-
return hitTestCircle(node, px, py);
|
|
49
|
-
case "rect":
|
|
50
|
-
return hitTestRect(node, px, py);
|
|
51
|
-
case "arc":
|
|
52
|
-
return hitTestArc(node, px, py);
|
|
53
|
-
default:
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function hitTestCircle(node, px, py) {
|
|
58
|
-
const dx = px - node.cx;
|
|
59
|
-
const dy = py - node.cy;
|
|
60
|
-
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
61
|
-
const tolerance = Math.max(node.r, 5) + 5;
|
|
62
|
-
if (dist <= tolerance) {
|
|
63
|
-
return {
|
|
64
|
-
type: "node",
|
|
65
|
-
datum: node.datum,
|
|
66
|
-
x: node.cx,
|
|
67
|
-
y: node.cy,
|
|
68
|
-
distance: dist
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
function hitTestRect(node, px, py) {
|
|
74
|
-
if (px >= node.x &&
|
|
75
|
-
px <= node.x + node.w &&
|
|
76
|
-
py >= node.y &&
|
|
77
|
-
py <= node.y + node.h) {
|
|
78
|
-
return {
|
|
79
|
-
type: "node",
|
|
80
|
-
datum: node.datum,
|
|
81
|
-
x: node.x + node.w / 2,
|
|
82
|
-
y: node.y + node.h / 2,
|
|
83
|
-
distance: 0
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
function hitTestArc(node, px, py) {
|
|
89
|
-
// Convert to polar coordinates relative to arc center
|
|
90
|
-
const dx = px - node.cx;
|
|
91
|
-
const dy = py - node.cy;
|
|
92
|
-
const radius = Math.sqrt(dx * dx + dy * dy);
|
|
93
|
-
// Check radius bounds
|
|
94
|
-
if (radius < node.innerR - 2 || radius > node.outerR + 2)
|
|
95
|
-
return null;
|
|
96
|
-
// Check angle bounds
|
|
97
|
-
let angle = Math.atan2(dy, dx);
|
|
98
|
-
// Normalize angle to be positive
|
|
99
|
-
if (angle < 0)
|
|
100
|
-
angle += Math.PI * 2;
|
|
101
|
-
let start = node.startAngle;
|
|
102
|
-
let end = node.endAngle;
|
|
103
|
-
// Normalize start/end angles
|
|
104
|
-
if (start < 0)
|
|
105
|
-
start += Math.PI * 2;
|
|
106
|
-
if (end < 0)
|
|
107
|
-
end += Math.PI * 2;
|
|
108
|
-
let inArc;
|
|
109
|
-
if (start <= end) {
|
|
110
|
-
inArc = angle >= start && angle <= end;
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
// Wraps around 0
|
|
114
|
-
inArc = angle >= start || angle <= end;
|
|
115
|
-
}
|
|
116
|
-
if (inArc) {
|
|
117
|
-
const midAngle = (node.startAngle + node.endAngle) / 2;
|
|
118
|
-
const midR = (node.innerR + node.outerR) / 2;
|
|
119
|
-
return {
|
|
120
|
-
type: "node",
|
|
121
|
-
datum: node.datum,
|
|
122
|
-
x: node.cx + midR * Math.cos(midAngle),
|
|
123
|
-
y: node.cy + midR * Math.sin(midAngle),
|
|
124
|
-
distance: 0
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
// ── Edge hit testing ────────────────────────────────────────────────────
|
|
130
|
-
function hitTestEdge(edge, px, py) {
|
|
131
|
-
switch (edge.type) {
|
|
132
|
-
case "bezier":
|
|
133
|
-
return hitTestBezierEdge(edge, px, py);
|
|
134
|
-
case "line":
|
|
135
|
-
return hitTestLineEdge(edge, px, py);
|
|
136
|
-
case "ribbon":
|
|
137
|
-
return hitTestPathEdge(edge, px, py);
|
|
138
|
-
case "curved":
|
|
139
|
-
return hitTestPathEdge(edge, px, py);
|
|
140
|
-
default:
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
function hitTestBezierEdge(edge, px, py) {
|
|
145
|
-
// Use Path2D for approximate point-in-path testing
|
|
146
|
-
if (!edge.pathD)
|
|
147
|
-
return null;
|
|
148
|
-
try {
|
|
149
|
-
const path = new Path2D(edge.pathD);
|
|
150
|
-
// Create an offscreen canvas context for isPointInPath
|
|
151
|
-
// For performance, use a simple bounding-box approximation
|
|
152
|
-
// and rely on the filled path test
|
|
153
|
-
const canvas = document.createElement("canvas");
|
|
154
|
-
const ctx = canvas.getContext("2d");
|
|
155
|
-
if (!ctx)
|
|
156
|
-
return null;
|
|
157
|
-
if (ctx.isPointInPath(path, px, py)) {
|
|
158
|
-
// Return midpoint of the band as hover position
|
|
159
|
-
const sourceNode = typeof edge.datum?.source === "object" ? edge.datum.source : null;
|
|
160
|
-
const targetNode = typeof edge.datum?.target === "object" ? edge.datum.target : null;
|
|
161
|
-
const midX = sourceNode && targetNode
|
|
162
|
-
? (sourceNode.x1 + targetNode.x0) / 2
|
|
163
|
-
: px;
|
|
164
|
-
const midY = edge.datum
|
|
165
|
-
? (edge.datum.y0 + edge.datum.y1) / 2
|
|
166
|
-
: py;
|
|
167
|
-
return {
|
|
168
|
-
type: "edge",
|
|
169
|
-
datum: edge.datum,
|
|
170
|
-
x: midX,
|
|
171
|
-
y: midY,
|
|
172
|
-
distance: 0
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
catch {
|
|
177
|
-
// Path2D may not be supported in all environments
|
|
178
|
-
}
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
181
|
-
function hitTestLineEdge(edge, px, py) {
|
|
182
|
-
// Point-to-line-segment distance
|
|
183
|
-
const dx = edge.x2 - edge.x1;
|
|
184
|
-
const dy = edge.y2 - edge.y1;
|
|
185
|
-
const len2 = dx * dx + dy * dy;
|
|
186
|
-
if (len2 === 0)
|
|
187
|
-
return null;
|
|
188
|
-
let t = ((px - edge.x1) * dx + (py - edge.y1) * dy) / len2;
|
|
189
|
-
t = Math.max(0, Math.min(1, t));
|
|
190
|
-
const nearX = edge.x1 + t * dx;
|
|
191
|
-
const nearY = edge.y1 + t * dy;
|
|
192
|
-
const dist = Math.sqrt((px - nearX) ** 2 + (py - nearY) ** 2);
|
|
193
|
-
const tolerance = 5;
|
|
194
|
-
if (dist <= tolerance) {
|
|
195
|
-
return {
|
|
196
|
-
type: "edge",
|
|
197
|
-
datum: edge.datum,
|
|
198
|
-
x: nearX,
|
|
199
|
-
y: nearY,
|
|
200
|
-
distance: dist
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
return null;
|
|
204
|
-
}
|
|
205
|
-
function hitTestPathEdge(edge, px, py) {
|
|
206
|
-
if (!edge.pathD)
|
|
207
|
-
return null;
|
|
208
|
-
try {
|
|
209
|
-
const path = new Path2D(edge.pathD);
|
|
210
|
-
const canvas = document.createElement("canvas");
|
|
211
|
-
const ctx = canvas.getContext("2d");
|
|
212
|
-
if (!ctx)
|
|
213
|
-
return null;
|
|
214
|
-
if (ctx.isPointInPath(path, px, py)) {
|
|
215
|
-
return {
|
|
216
|
-
type: "edge",
|
|
217
|
-
datum: edge.datum,
|
|
218
|
-
x: px,
|
|
219
|
-
y: py,
|
|
220
|
-
distance: 0
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
catch {
|
|
225
|
-
// Fallback — no hit
|
|
226
|
-
}
|
|
227
|
-
return null;
|
|
228
|
-
}
|