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,91 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
var _a;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.useSelectionSelector = exports.SelectionProvider = void 0;
|
|
6
|
-
exports.buildPredicate = buildPredicate;
|
|
7
|
-
const createStore_1 = require("./createStore");
|
|
8
|
-
// ── Predicate builders ─────────────────────────────────────────────────────
|
|
9
|
-
function buildClausePredicate(clause) {
|
|
10
|
-
const fieldTests = [];
|
|
11
|
-
for (const [field, constraint] of Object.entries(clause.fields)) {
|
|
12
|
-
if (constraint.type === "point") {
|
|
13
|
-
fieldTests.push((d) => constraint.values.has(d[field]));
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
const [lo, hi] = constraint.range;
|
|
17
|
-
fieldTests.push((d) => {
|
|
18
|
-
const v = d[field];
|
|
19
|
-
return v >= lo && v <= hi;
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
// All fields in a clause must match (AND within clause)
|
|
24
|
-
return (d) => fieldTests.every((fn) => fn(d));
|
|
25
|
-
}
|
|
26
|
-
function buildPredicate(selection, requestingClientId) {
|
|
27
|
-
const clausePredicates = [];
|
|
28
|
-
for (const [clientId, clause] of selection.clauses) {
|
|
29
|
-
// In crossfilter mode, exclude the requesting client's own clause
|
|
30
|
-
if (selection.resolution === "crossfilter" && clientId === requestingClientId)
|
|
31
|
-
continue;
|
|
32
|
-
clausePredicates.push(buildClausePredicate(clause));
|
|
33
|
-
}
|
|
34
|
-
if (clausePredicates.length === 0)
|
|
35
|
-
return () => true;
|
|
36
|
-
return selection.resolution === "intersect"
|
|
37
|
-
? (d) => clausePredicates.every((fn) => fn(d))
|
|
38
|
-
: (d) => clausePredicates.some((fn) => fn(d));
|
|
39
|
-
}
|
|
40
|
-
// ── Store factory ──────────────────────────────────────────────────────────
|
|
41
|
-
function ensureSelection(selections, name) {
|
|
42
|
-
let sel = selections.get(name);
|
|
43
|
-
if (!sel) {
|
|
44
|
-
sel = { name, resolution: "union", clauses: new Map() };
|
|
45
|
-
selections.set(name, sel);
|
|
46
|
-
}
|
|
47
|
-
return sel;
|
|
48
|
-
}
|
|
49
|
-
_a = (0, createStore_1.createStore)((set) => ({
|
|
50
|
-
selections: new Map(),
|
|
51
|
-
setClause(selectionName, clause) {
|
|
52
|
-
set((current) => {
|
|
53
|
-
const selections = new Map(current.selections);
|
|
54
|
-
const sel = ensureSelection(selections, selectionName);
|
|
55
|
-
const clauses = new Map(sel.clauses);
|
|
56
|
-
clauses.set(clause.clientId, clause);
|
|
57
|
-
selections.set(selectionName, { ...sel, clauses });
|
|
58
|
-
return { selections };
|
|
59
|
-
});
|
|
60
|
-
},
|
|
61
|
-
clearClause(selectionName, clientId) {
|
|
62
|
-
set((current) => {
|
|
63
|
-
const existing = current.selections.get(selectionName);
|
|
64
|
-
if (!existing)
|
|
65
|
-
return {};
|
|
66
|
-
const selections = new Map(current.selections);
|
|
67
|
-
const clauses = new Map(existing.clauses);
|
|
68
|
-
clauses.delete(clientId);
|
|
69
|
-
selections.set(selectionName, { ...existing, clauses });
|
|
70
|
-
return { selections };
|
|
71
|
-
});
|
|
72
|
-
},
|
|
73
|
-
setResolution(selectionName, mode) {
|
|
74
|
-
set((current) => {
|
|
75
|
-
const selections = new Map(current.selections);
|
|
76
|
-
const sel = ensureSelection(selections, selectionName);
|
|
77
|
-
selections.set(selectionName, { ...sel, resolution: mode });
|
|
78
|
-
return { selections };
|
|
79
|
-
});
|
|
80
|
-
},
|
|
81
|
-
clearSelection(selectionName) {
|
|
82
|
-
set((current) => {
|
|
83
|
-
const selections = new Map(current.selections);
|
|
84
|
-
const sel = selections.get(selectionName);
|
|
85
|
-
if (sel) {
|
|
86
|
-
selections.set(selectionName, { ...sel, clauses: new Map() });
|
|
87
|
-
}
|
|
88
|
-
return { selections };
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
})), exports.SelectionProvider = _a[0], exports.useSelectionSelector = _a[1];
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
var _a;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.useThemeSelector = exports.ThemeProvider = exports.DARK_THEME = exports.LIGHT_THEME = void 0;
|
|
6
|
-
const createStore_1 = require("./createStore");
|
|
7
|
-
// ── Presets ─────────────────────────────────────────────────────────────────
|
|
8
|
-
exports.LIGHT_THEME = {
|
|
9
|
-
mode: "light",
|
|
10
|
-
colors: {
|
|
11
|
-
primary: "#00a2ce",
|
|
12
|
-
categorical: [
|
|
13
|
-
"#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd",
|
|
14
|
-
"#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"
|
|
15
|
-
],
|
|
16
|
-
sequential: "blues",
|
|
17
|
-
background: "transparent",
|
|
18
|
-
text: "#333",
|
|
19
|
-
textSecondary: "#666",
|
|
20
|
-
grid: "#e0e0e0",
|
|
21
|
-
border: "#ccc"
|
|
22
|
-
},
|
|
23
|
-
typography: {
|
|
24
|
-
fontFamily: "sans-serif",
|
|
25
|
-
titleSize: 16,
|
|
26
|
-
labelSize: 12,
|
|
27
|
-
tickSize: 10
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
exports.DARK_THEME = {
|
|
31
|
-
mode: "dark",
|
|
32
|
-
colors: {
|
|
33
|
-
primary: "#4fc3f7",
|
|
34
|
-
categorical: [
|
|
35
|
-
"#4fc3f7", "#ffb74d", "#81c784", "#ef5350", "#ba68c8",
|
|
36
|
-
"#a1887f", "#f06292", "#90a4ae", "#dce775", "#4dd0e1"
|
|
37
|
-
],
|
|
38
|
-
sequential: "blues",
|
|
39
|
-
background: "#1a1a2e",
|
|
40
|
-
text: "#e0e0e0",
|
|
41
|
-
textSecondary: "#aaa",
|
|
42
|
-
grid: "#333",
|
|
43
|
-
border: "#555"
|
|
44
|
-
},
|
|
45
|
-
typography: {
|
|
46
|
-
fontFamily: "sans-serif",
|
|
47
|
-
titleSize: 16,
|
|
48
|
-
labelSize: 12,
|
|
49
|
-
tickSize: 10
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
_a = (0, createStore_1.createStore)((set) => ({
|
|
53
|
-
theme: exports.LIGHT_THEME,
|
|
54
|
-
setTheme(theme) {
|
|
55
|
-
set((current) => {
|
|
56
|
-
if (theme === "light") {
|
|
57
|
-
return { theme: exports.LIGHT_THEME };
|
|
58
|
-
}
|
|
59
|
-
if (theme === "dark") {
|
|
60
|
-
return { theme: exports.DARK_THEME };
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
theme: {
|
|
64
|
-
...current.theme,
|
|
65
|
-
...theme,
|
|
66
|
-
colors: {
|
|
67
|
-
...current.theme.colors,
|
|
68
|
-
...(theme.colors || {})
|
|
69
|
-
},
|
|
70
|
-
typography: {
|
|
71
|
-
...current.theme.typography,
|
|
72
|
-
...(theme.typography || {})
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
})), exports.ThemeProvider = _a[0], exports.useThemeSelector = _a[1];
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.useTooltip = exports.TooltipProvider = void 0;
|
|
5
|
-
const createStore_1 = require("./createStore");
|
|
6
|
-
let [TooltipProvider, useTooltip] = (0, createStore_1.createStore)((set) => ({
|
|
7
|
-
tooltip: null,
|
|
8
|
-
changeTooltip(tooltip) {
|
|
9
|
-
set(() => ({ tooltip }));
|
|
10
|
-
}
|
|
11
|
-
}));
|
|
12
|
-
exports.TooltipProvider = TooltipProvider;
|
|
13
|
-
exports.useTooltip = useTooltip;
|
|
@@ -1,81 +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.createStore = createStore;
|
|
38
|
-
const React = __importStar(require("react"));
|
|
39
|
-
const react_1 = require("react");
|
|
40
|
-
function useSyncExternalStoreShim(subscribe, getSnapshot) {
|
|
41
|
-
const [value, setValue] = (0, react_1.useState)(getSnapshot);
|
|
42
|
-
(0, react_1.useLayoutEffect)(() => {
|
|
43
|
-
return subscribe(() => setValue(getSnapshot));
|
|
44
|
-
}, [subscribe]);
|
|
45
|
-
return value;
|
|
46
|
-
}
|
|
47
|
-
function createStore(fn) {
|
|
48
|
-
let Ctx = (0, react_1.createContext)(null);
|
|
49
|
-
// Shared fallback source for when there's no provider in the tree.
|
|
50
|
-
// This allows hooks to be called unconditionally (rules of hooks)
|
|
51
|
-
// without crashing. The fallback state is inert (empty selections, etc.).
|
|
52
|
-
let fallbackSource = createSource(fn);
|
|
53
|
-
function Provider({ children }) {
|
|
54
|
-
let source = (0, react_1.useMemo)(() => createSource(fn), []);
|
|
55
|
-
return React.createElement(Ctx.Provider, { value: source, children: children });
|
|
56
|
-
}
|
|
57
|
-
let useSelector = (selector) => {
|
|
58
|
-
let source = (0, react_1.useContext)(Ctx) ?? fallbackSource;
|
|
59
|
-
let getSnapshot = () => selector(source.getState());
|
|
60
|
-
return useSyncExternalStoreShim(source.subscribe, getSnapshot);
|
|
61
|
-
};
|
|
62
|
-
return [Provider, useSelector];
|
|
63
|
-
}
|
|
64
|
-
function createSource(fn) {
|
|
65
|
-
let events = new EventTarget();
|
|
66
|
-
let state = fn(set);
|
|
67
|
-
function set(fn) {
|
|
68
|
-
state = Object.assign(state, fn(state));
|
|
69
|
-
events.dispatchEvent(new CustomEvent("update"));
|
|
70
|
-
}
|
|
71
|
-
function subscribe(cb) {
|
|
72
|
-
events.addEventListener("update", cb);
|
|
73
|
-
return () => events.removeEventListener("update", cb);
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
getState() {
|
|
77
|
-
return state;
|
|
78
|
-
},
|
|
79
|
-
subscribe
|
|
80
|
-
};
|
|
81
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.useSelection = useSelection;
|
|
5
|
-
exports.useLinkedHover = useLinkedHover;
|
|
6
|
-
exports.useBrushSelection = useBrushSelection;
|
|
7
|
-
exports.useFilteredData = useFilteredData;
|
|
8
|
-
const react_1 = require("react");
|
|
9
|
-
const SelectionStore_1 = require("./SelectionStore");
|
|
10
|
-
function useSelection(options) {
|
|
11
|
-
const autoId = (0, react_1.useId)();
|
|
12
|
-
const clientId = options.clientId || autoId;
|
|
13
|
-
const { name } = options;
|
|
14
|
-
const selection = (0, SelectionStore_1.useSelectionSelector)((state) => state.selections.get(name));
|
|
15
|
-
const setClause = (0, SelectionStore_1.useSelectionSelector)((state) => state.setClause);
|
|
16
|
-
const clearClauseFn = (0, SelectionStore_1.useSelectionSelector)((state) => state.clearClause);
|
|
17
|
-
const isActive = (0, react_1.useMemo)(() => {
|
|
18
|
-
if (!selection)
|
|
19
|
-
return false;
|
|
20
|
-
return selection.clauses.size > 0;
|
|
21
|
-
}, [selection]);
|
|
22
|
-
const predicate = (0, react_1.useMemo)(() => {
|
|
23
|
-
if (!selection || selection.clauses.size === 0)
|
|
24
|
-
return () => true;
|
|
25
|
-
return (0, SelectionStore_1.buildPredicate)(selection, clientId);
|
|
26
|
-
}, [selection, clientId]);
|
|
27
|
-
const selectPoints = (0, react_1.useCallback)((fieldValues) => {
|
|
28
|
-
const fields = {};
|
|
29
|
-
for (const [field, values] of Object.entries(fieldValues)) {
|
|
30
|
-
fields[field] = { type: "point", values: new Set(values) };
|
|
31
|
-
}
|
|
32
|
-
const clause = {
|
|
33
|
-
clientId,
|
|
34
|
-
type: "point",
|
|
35
|
-
fields
|
|
36
|
-
};
|
|
37
|
-
setClause(name, clause);
|
|
38
|
-
}, [clientId, name, setClause]);
|
|
39
|
-
const selectInterval = (0, react_1.useCallback)((fieldRanges) => {
|
|
40
|
-
const fields = {};
|
|
41
|
-
for (const [field, range] of Object.entries(fieldRanges)) {
|
|
42
|
-
fields[field] = { type: "interval", range };
|
|
43
|
-
}
|
|
44
|
-
const clause = {
|
|
45
|
-
clientId,
|
|
46
|
-
type: "interval",
|
|
47
|
-
fields
|
|
48
|
-
};
|
|
49
|
-
setClause(name, clause);
|
|
50
|
-
}, [clientId, name, setClause]);
|
|
51
|
-
const clear = (0, react_1.useCallback)(() => {
|
|
52
|
-
clearClauseFn(name, clientId);
|
|
53
|
-
}, [clearClauseFn, name, clientId]);
|
|
54
|
-
return { predicate, isActive, selectPoints, selectInterval, clear, clientId };
|
|
55
|
-
}
|
|
56
|
-
function useLinkedHover(options) {
|
|
57
|
-
const selName = options.name || "hover";
|
|
58
|
-
const { fields } = options;
|
|
59
|
-
const { predicate, isActive, selectPoints, clear, clientId } = useSelection({
|
|
60
|
-
name: selName,
|
|
61
|
-
fields
|
|
62
|
-
});
|
|
63
|
-
const onHover = (0, react_1.useCallback)((datum) => {
|
|
64
|
-
if (!datum) {
|
|
65
|
-
clear();
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
const fieldValues = {};
|
|
69
|
-
for (const field of fields) {
|
|
70
|
-
const val = datum[field];
|
|
71
|
-
if (val !== undefined) {
|
|
72
|
-
fieldValues[field] = [val];
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (Object.keys(fieldValues).length > 0) {
|
|
76
|
-
selectPoints(fieldValues);
|
|
77
|
-
}
|
|
78
|
-
}, [fields, selectPoints, clear]);
|
|
79
|
-
return { onHover, predicate, isActive };
|
|
80
|
-
}
|
|
81
|
-
function useBrushSelection(options) {
|
|
82
|
-
const { name, xField, yField } = options;
|
|
83
|
-
const { predicate, isActive, selectInterval, clear, clientId } = useSelection({
|
|
84
|
-
name,
|
|
85
|
-
fields: [xField, yField].filter(Boolean)
|
|
86
|
-
});
|
|
87
|
-
const brushType = xField && yField ? "xyBrush" : xField ? "xBrush" : "yBrush";
|
|
88
|
-
const handleBrush = (0, react_1.useCallback)((extent) => {
|
|
89
|
-
if (!extent) {
|
|
90
|
-
clear();
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const fieldRanges = {};
|
|
94
|
-
if (brushType === "xyBrush" && Array.isArray(extent) && extent.length === 2) {
|
|
95
|
-
// extent = [[x0, y0], [x1, y1]]
|
|
96
|
-
if (xField)
|
|
97
|
-
fieldRanges[xField] = [Math.min(extent[0][0], extent[1][0]), Math.max(extent[0][0], extent[1][0])];
|
|
98
|
-
if (yField)
|
|
99
|
-
fieldRanges[yField] = [Math.min(extent[0][1], extent[1][1]), Math.max(extent[0][1], extent[1][1])];
|
|
100
|
-
}
|
|
101
|
-
else if (brushType === "xBrush" && Array.isArray(extent)) {
|
|
102
|
-
if (xField)
|
|
103
|
-
fieldRanges[xField] = [Math.min(...extent), Math.max(...extent)];
|
|
104
|
-
}
|
|
105
|
-
else if (brushType === "yBrush" && Array.isArray(extent)) {
|
|
106
|
-
if (yField)
|
|
107
|
-
fieldRanges[yField] = [Math.min(...extent), Math.max(...extent)];
|
|
108
|
-
}
|
|
109
|
-
if (Object.keys(fieldRanges).length > 0) {
|
|
110
|
-
selectInterval(fieldRanges);
|
|
111
|
-
}
|
|
112
|
-
}, [brushType, xField, yField, selectInterval, clear]);
|
|
113
|
-
const brushInteraction = (0, react_1.useMemo)(() => ({
|
|
114
|
-
brush: brushType,
|
|
115
|
-
during: handleBrush,
|
|
116
|
-
end: handleBrush
|
|
117
|
-
}), [brushType, handleBrush]);
|
|
118
|
-
return { brushInteraction, predicate, isActive, clear };
|
|
119
|
-
}
|
|
120
|
-
// ── useFilteredData ────────────────────────────────────────────────────────
|
|
121
|
-
/**
|
|
122
|
-
* Returns the subset of `data` that matches the given selection.
|
|
123
|
-
* In crossfilter mode, pass the consumer's clientId so its own clause is excluded.
|
|
124
|
-
*/
|
|
125
|
-
function useFilteredData(data, selectionName, clientId) {
|
|
126
|
-
const selection = (0, SelectionStore_1.useSelectionSelector)((state) => state.selections.get(selectionName));
|
|
127
|
-
return (0, react_1.useMemo)(() => {
|
|
128
|
-
if (!selection || selection.clauses.size === 0)
|
|
129
|
-
return data;
|
|
130
|
-
const pred = (0, SelectionStore_1.buildPredicate)(selection, clientId);
|
|
131
|
-
return data.filter(pred);
|
|
132
|
-
}, [data, selection, clientId]);
|
|
133
|
-
}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findNearestNode = findNearestNode;
|
|
4
|
-
exports.findNearestIndex = findNearestIndex;
|
|
5
|
-
/**
|
|
6
|
-
* Find the nearest scene node to the given pixel coordinates.
|
|
7
|
-
* Dispatches to type-specific hit testers for optimal performance.
|
|
8
|
-
*/
|
|
9
|
-
function findNearestNode(scene, px, py, maxDistance = 30) {
|
|
10
|
-
let best = null;
|
|
11
|
-
for (const node of scene) {
|
|
12
|
-
let result = null;
|
|
13
|
-
switch (node.type) {
|
|
14
|
-
case "point":
|
|
15
|
-
result = hitTestPoint(node, px, py);
|
|
16
|
-
break;
|
|
17
|
-
case "line":
|
|
18
|
-
result = hitTestLine(node, px, py);
|
|
19
|
-
break;
|
|
20
|
-
case "rect":
|
|
21
|
-
result = hitTestRect(node, px, py);
|
|
22
|
-
break;
|
|
23
|
-
case "heatcell":
|
|
24
|
-
result = hitTestHeatcell(node, px, py);
|
|
25
|
-
break;
|
|
26
|
-
case "area":
|
|
27
|
-
// Skip non-interactive areas (e.g. decorative bounds bands)
|
|
28
|
-
if (node.interactive === false)
|
|
29
|
-
break;
|
|
30
|
-
// Areas are hit-tested by finding nearest x on the top path
|
|
31
|
-
result = hitTestAreaPath(node, px, py);
|
|
32
|
-
break;
|
|
33
|
-
case "candlestick":
|
|
34
|
-
result = hitTestCandlestick(node, px, py);
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
if (result && result.distance < maxDistance) {
|
|
38
|
-
if (!best || result.distance < best.distance) {
|
|
39
|
-
best = result;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return best;
|
|
44
|
-
}
|
|
45
|
-
function hitTestPoint(node, px, py) {
|
|
46
|
-
const dx = px - node.x;
|
|
47
|
-
const dy = py - node.y;
|
|
48
|
-
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
49
|
-
// Hit radius includes the point's visual radius plus a tolerance
|
|
50
|
-
if (dist > node.r + 5)
|
|
51
|
-
return null;
|
|
52
|
-
return { node, datum: node.datum, x: node.x, y: node.y, distance: dist };
|
|
53
|
-
}
|
|
54
|
-
function hitTestLine(node, px, py) {
|
|
55
|
-
if (node.path.length === 0)
|
|
56
|
-
return null;
|
|
57
|
-
// Binary search for nearest x in the path
|
|
58
|
-
const idx = binarySearchPath(node.path, px);
|
|
59
|
-
if (idx < 0)
|
|
60
|
-
return null;
|
|
61
|
-
const [nx, ny] = node.path[idx];
|
|
62
|
-
const dx = px - nx;
|
|
63
|
-
const dy = py - ny;
|
|
64
|
-
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
65
|
-
// For line data, the datum is the array; return the index as well
|
|
66
|
-
const datum = Array.isArray(node.datum) && node.datum[idx]
|
|
67
|
-
? node.datum[idx]
|
|
68
|
-
: node.datum;
|
|
69
|
-
return { node, datum, x: nx, y: ny, distance: dist };
|
|
70
|
-
}
|
|
71
|
-
function hitTestRect(node, px, py) {
|
|
72
|
-
if (px >= node.x && px <= node.x + node.w && py >= node.y && py <= node.y + node.h) {
|
|
73
|
-
// Center of rect
|
|
74
|
-
const cx = node.x + node.w / 2;
|
|
75
|
-
const cy = node.y + node.h / 2;
|
|
76
|
-
return { node, datum: node.datum, x: cx, y: cy, distance: 0 };
|
|
77
|
-
}
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
function hitTestHeatcell(node, px, py) {
|
|
81
|
-
if (px >= node.x && px <= node.x + node.w && py >= node.y && py <= node.y + node.h) {
|
|
82
|
-
const cx = node.x + node.w / 2;
|
|
83
|
-
const cy = node.y + node.h / 2;
|
|
84
|
-
return { node, datum: node.datum, x: cx, y: cy, distance: 0 };
|
|
85
|
-
}
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
function hitTestCandlestick(node, px, py) {
|
|
89
|
-
const halfBody = node.bodyWidth / 2;
|
|
90
|
-
// Hit the body area (wider target)
|
|
91
|
-
const bodyTop = Math.min(node.openY, node.closeY);
|
|
92
|
-
const bodyBottom = Math.max(node.openY, node.closeY);
|
|
93
|
-
const bodyHeight = Math.max(bodyBottom - bodyTop, 1);
|
|
94
|
-
if (px >= node.x - halfBody - 3 && px <= node.x + halfBody + 3 &&
|
|
95
|
-
py >= node.highY - 3 && py <= node.lowY + 3) {
|
|
96
|
-
// Hover target: center of the body
|
|
97
|
-
const cy = bodyTop + bodyHeight / 2;
|
|
98
|
-
const dx = px - node.x;
|
|
99
|
-
const dy = py - cy;
|
|
100
|
-
return { node, datum: node.datum, x: node.x, y: cy, distance: Math.sqrt(dx * dx + dy * dy) };
|
|
101
|
-
}
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
function hitTestAreaPath(node, px, py) {
|
|
105
|
-
if (node.topPath.length === 0)
|
|
106
|
-
return null;
|
|
107
|
-
const idx = binarySearchPath(node.topPath, px);
|
|
108
|
-
if (idx < 0)
|
|
109
|
-
return null;
|
|
110
|
-
const [nx, ny] = node.topPath[idx];
|
|
111
|
-
const dx = px - nx;
|
|
112
|
-
const dy = py - ny;
|
|
113
|
-
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
114
|
-
return { node: node, datum: node.datum, x: nx, y: ny, distance: dist };
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Binary search for the nearest point by x-coordinate in a sorted path.
|
|
118
|
-
*/
|
|
119
|
-
function binarySearchPath(path, targetX) {
|
|
120
|
-
if (path.length === 0)
|
|
121
|
-
return -1;
|
|
122
|
-
let lo = 0;
|
|
123
|
-
let hi = path.length - 1;
|
|
124
|
-
while (lo < hi) {
|
|
125
|
-
const mid = (lo + hi) >> 1;
|
|
126
|
-
if (path[mid][0] < targetX)
|
|
127
|
-
lo = mid + 1;
|
|
128
|
-
else
|
|
129
|
-
hi = mid;
|
|
130
|
-
}
|
|
131
|
-
// Check if lo-1 is closer
|
|
132
|
-
if (lo > 0) {
|
|
133
|
-
const dLo = Math.abs(path[lo][0] - targetX);
|
|
134
|
-
const dPrev = Math.abs(path[lo - 1][0] - targetX);
|
|
135
|
-
if (dPrev <= dLo)
|
|
136
|
-
return lo - 1;
|
|
137
|
-
}
|
|
138
|
-
return lo;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Binary search for nearest point by time value in a RingBuffer.
|
|
142
|
-
*/
|
|
143
|
-
function findNearestIndex(buf, targetTime, getTime) {
|
|
144
|
-
if (buf.size === 0)
|
|
145
|
-
return -1;
|
|
146
|
-
let lo = 0;
|
|
147
|
-
let hi = buf.size - 1;
|
|
148
|
-
while (lo < hi) {
|
|
149
|
-
const mid = (lo + hi) >> 1;
|
|
150
|
-
const t = getTime(buf.get(mid));
|
|
151
|
-
if (t < targetTime)
|
|
152
|
-
lo = mid + 1;
|
|
153
|
-
else
|
|
154
|
-
hi = mid;
|
|
155
|
-
}
|
|
156
|
-
if (lo > 0) {
|
|
157
|
-
const tLo = getTime(buf.get(lo));
|
|
158
|
-
const tPrev = getTime(buf.get(lo - 1));
|
|
159
|
-
if (Math.abs(tPrev - targetTime) <= Math.abs(tLo - targetTime)) {
|
|
160
|
-
return lo - 1;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return lo;
|
|
164
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DataSourceAdapter = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* DataSourceAdapter normalizes all data ingestion paths into uniform changesets:
|
|
6
|
-
*
|
|
7
|
-
* 1. Bounded (props): `data` array → changeset(s) with `bounded: true`
|
|
8
|
-
* 2. Streaming (push): `ref.push()` → micro-changeset with `bounded: false`
|
|
9
|
-
* 3. Hybrid: `data` prop first, then `push()` — seamless transition
|
|
10
|
-
*
|
|
11
|
-
* For large bounded datasets (above CHUNK_THRESHOLD), data is automatically
|
|
12
|
-
* chunked and ingested progressively across multiple animation frames. This
|
|
13
|
-
* keeps the UI responsive while the chart draws incrementally. The first chunk
|
|
14
|
-
* renders immediately so the user sees data right away.
|
|
15
|
-
*/
|
|
16
|
-
/** Datasets larger than this are chunked for progressive rendering */
|
|
17
|
-
const CHUNK_THRESHOLD = 5000;
|
|
18
|
-
/** Number of items per progressive chunk */
|
|
19
|
-
const CHUNK_SIZE = 5000;
|
|
20
|
-
class DataSourceAdapter {
|
|
21
|
-
constructor(callback) {
|
|
22
|
-
this.lastBoundedData = null;
|
|
23
|
-
this.chunkTimer = 0;
|
|
24
|
-
this.callback = callback;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Ingest a bounded data array (from props).
|
|
28
|
-
*
|
|
29
|
-
* Small datasets emit a single changeset synchronously.
|
|
30
|
-
* Large datasets (> CHUNK_THRESHOLD) are split into chunks that render
|
|
31
|
-
* progressively: the first chunk fires immediately (bounded: true to
|
|
32
|
-
* reset + seed the buffer), subsequent chunks arrive on successive
|
|
33
|
-
* animation frames (bounded: false so they append without clearing).
|
|
34
|
-
*/
|
|
35
|
-
setBoundedData(data) {
|
|
36
|
-
if (data === this.lastBoundedData)
|
|
37
|
-
return;
|
|
38
|
-
this.lastBoundedData = data;
|
|
39
|
-
// Cancel any in-flight progressive ingestion
|
|
40
|
-
if (this.chunkTimer) {
|
|
41
|
-
cancelAnimationFrame(this.chunkTimer);
|
|
42
|
-
this.chunkTimer = 0;
|
|
43
|
-
}
|
|
44
|
-
if (data.length <= CHUNK_THRESHOLD) {
|
|
45
|
-
// Small dataset — ingest all at once
|
|
46
|
-
this.callback({ inserts: data, bounded: true });
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
// Large dataset — progressive chunked ingestion.
|
|
50
|
-
// First chunk is bounded: true (resets buffer and sizes it to full length).
|
|
51
|
-
// Subsequent chunks are bounded: false (appends without clearing).
|
|
52
|
-
this.callback({ inserts: data.slice(0, CHUNK_SIZE), bounded: true, totalSize: data.length });
|
|
53
|
-
let offset = CHUNK_SIZE;
|
|
54
|
-
const scheduleNext = () => {
|
|
55
|
-
if (offset >= data.length)
|
|
56
|
-
return;
|
|
57
|
-
// Check that this is still the active dataset
|
|
58
|
-
if (data !== this.lastBoundedData)
|
|
59
|
-
return;
|
|
60
|
-
const end = Math.min(offset + CHUNK_SIZE, data.length);
|
|
61
|
-
this.callback({ inserts: data.slice(offset, end), bounded: false });
|
|
62
|
-
offset = end;
|
|
63
|
-
if (offset < data.length) {
|
|
64
|
-
this.chunkTimer = requestAnimationFrame(scheduleNext);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
this.chunkTimer = 0;
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
this.chunkTimer = requestAnimationFrame(scheduleNext);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Push a single datum (streaming mode).
|
|
74
|
-
* Emits a micro-changeset with `bounded: false`.
|
|
75
|
-
*/
|
|
76
|
-
push(datum) {
|
|
77
|
-
this.callback({ inserts: [datum], bounded: false });
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Push multiple data (streaming batch).
|
|
81
|
-
* Emits a single changeset with `bounded: false`.
|
|
82
|
-
*/
|
|
83
|
-
pushMany(data) {
|
|
84
|
-
if (data.length === 0)
|
|
85
|
-
return;
|
|
86
|
-
this.callback({ inserts: data, bounded: false });
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Reset the adapter state.
|
|
90
|
-
*/
|
|
91
|
-
clear() {
|
|
92
|
-
if (this.chunkTimer) {
|
|
93
|
-
cancelAnimationFrame(this.chunkTimer);
|
|
94
|
-
this.chunkTimer = 0;
|
|
95
|
-
}
|
|
96
|
-
this.lastBoundedData = null;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.DataSourceAdapter = DataSourceAdapter;
|