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,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.exportChart = exportChart;
|
|
4
|
-
/**
|
|
5
|
-
* Export a semiotic chart to SVG or PNG from the browser.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```tsx
|
|
9
|
-
* const ref = useRef<HTMLDivElement>(null)
|
|
10
|
-
* // ... render chart inside ref ...
|
|
11
|
-
* <button onClick={() => exportChart(ref.current!)}>Download</button>
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
async function exportChart(container, options) {
|
|
15
|
-
const { format = "svg", filename = "chart", scale = 2, background = "white" } = options || {};
|
|
16
|
-
// Find the SVG element inside the container
|
|
17
|
-
const svgElement = container.querySelector("svg");
|
|
18
|
-
if (!svgElement) {
|
|
19
|
-
throw new Error("No SVG element found in the container");
|
|
20
|
-
}
|
|
21
|
-
// Clone the SVG to avoid modifying the original
|
|
22
|
-
const clone = svgElement.cloneNode(true);
|
|
23
|
-
// Ensure the clone has explicit width/height attributes
|
|
24
|
-
const bbox = svgElement.getBoundingClientRect();
|
|
25
|
-
if (!clone.getAttribute("width")) {
|
|
26
|
-
clone.setAttribute("width", String(bbox.width));
|
|
27
|
-
}
|
|
28
|
-
if (!clone.getAttribute("height")) {
|
|
29
|
-
clone.setAttribute("height", String(bbox.height));
|
|
30
|
-
}
|
|
31
|
-
// Add xmlns if missing
|
|
32
|
-
if (!clone.getAttribute("xmlns")) {
|
|
33
|
-
clone.setAttribute("xmlns", "http://www.w3.org/2000/svg");
|
|
34
|
-
}
|
|
35
|
-
// Inline computed styles for standalone rendering
|
|
36
|
-
inlineStyles(svgElement, clone);
|
|
37
|
-
if (format === "svg") {
|
|
38
|
-
const serializer = new XMLSerializer();
|
|
39
|
-
const svgString = serializer.serializeToString(clone);
|
|
40
|
-
const blob = new Blob([svgString], { type: "image/svg+xml;charset=utf-8" });
|
|
41
|
-
downloadBlob(blob, `${filename}.svg`);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
// PNG: render SVG to canvas
|
|
45
|
-
const width = bbox.width * scale;
|
|
46
|
-
const height = bbox.height * scale;
|
|
47
|
-
const serializer = new XMLSerializer();
|
|
48
|
-
const svgString = serializer.serializeToString(clone);
|
|
49
|
-
const svgBlob = new Blob([svgString], { type: "image/svg+xml;charset=utf-8" });
|
|
50
|
-
const url = URL.createObjectURL(svgBlob);
|
|
51
|
-
const img = new Image();
|
|
52
|
-
img.width = bbox.width;
|
|
53
|
-
img.height = bbox.height;
|
|
54
|
-
await new Promise((resolve, reject) => {
|
|
55
|
-
img.onload = () => {
|
|
56
|
-
const canvas = document.createElement("canvas");
|
|
57
|
-
canvas.width = width;
|
|
58
|
-
canvas.height = height;
|
|
59
|
-
const ctx = canvas.getContext("2d");
|
|
60
|
-
// Fill background
|
|
61
|
-
ctx.fillStyle = background;
|
|
62
|
-
ctx.fillRect(0, 0, width, height);
|
|
63
|
-
// Scale and draw
|
|
64
|
-
ctx.scale(scale, scale);
|
|
65
|
-
ctx.drawImage(img, 0, 0);
|
|
66
|
-
canvas.toBlob((blob) => {
|
|
67
|
-
if (blob) {
|
|
68
|
-
downloadBlob(blob, `${filename}.png`);
|
|
69
|
-
resolve();
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
reject(new Error("Failed to create PNG blob"));
|
|
73
|
-
}
|
|
74
|
-
}, "image/png");
|
|
75
|
-
URL.revokeObjectURL(url);
|
|
76
|
-
};
|
|
77
|
-
img.onerror = () => {
|
|
78
|
-
URL.revokeObjectURL(url);
|
|
79
|
-
reject(new Error("Failed to load SVG image"));
|
|
80
|
-
};
|
|
81
|
-
img.src = url;
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Inline computed styles from source SVG elements into clone elements.
|
|
87
|
-
* This ensures the exported SVG/PNG looks the same as on screen.
|
|
88
|
-
*/
|
|
89
|
-
function inlineStyles(source, target) {
|
|
90
|
-
const sourceChildren = source.children;
|
|
91
|
-
const targetChildren = target.children;
|
|
92
|
-
// Copy computed styles for the element itself
|
|
93
|
-
const computed = window.getComputedStyle(source);
|
|
94
|
-
const important = ["fill", "stroke", "stroke-width", "stroke-dasharray",
|
|
95
|
-
"opacity", "fill-opacity", "stroke-opacity", "font-family",
|
|
96
|
-
"font-size", "font-weight", "text-anchor", "dominant-baseline"];
|
|
97
|
-
for (const prop of important) {
|
|
98
|
-
const value = computed.getPropertyValue(prop);
|
|
99
|
-
if (value && value !== "none" && value !== "") {
|
|
100
|
-
;
|
|
101
|
-
target.style?.setProperty(prop, value);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
// Recurse into children
|
|
105
|
-
for (let i = 0; i < Math.min(sourceChildren.length, targetChildren.length); i++) {
|
|
106
|
-
inlineStyles(sourceChildren[i], targetChildren[i]);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Trigger a file download from a blob.
|
|
111
|
-
*/
|
|
112
|
-
function downloadBlob(blob, filename) {
|
|
113
|
-
const url = URL.createObjectURL(blob);
|
|
114
|
-
const a = document.createElement("a");
|
|
115
|
-
a.href = url;
|
|
116
|
-
a.download = filename;
|
|
117
|
-
document.body.appendChild(a);
|
|
118
|
-
a.click();
|
|
119
|
-
document.body.removeChild(a);
|
|
120
|
-
URL.revokeObjectURL(url);
|
|
121
|
-
}
|
|
@@ -1,312 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.hexbinning = exports.contouring = void 0;
|
|
40
|
-
exports.lineBounding = lineBounding;
|
|
41
|
-
exports.heatmapping = heatmapping;
|
|
42
|
-
exports.trendlining = trendlining;
|
|
43
|
-
exports.shapeBounds = shapeBounds;
|
|
44
|
-
const React = __importStar(require("react"));
|
|
45
|
-
const d3_scale_1 = require("d3-scale");
|
|
46
|
-
const regression_1 = __importDefault(require("regression"));
|
|
47
|
-
const d3_shape_1 = require("d3-shape");
|
|
48
|
-
// Re-export from new locations for backwards compatibility
|
|
49
|
-
var contourLayout_1 = require("./contourLayout");
|
|
50
|
-
Object.defineProperty(exports, "contouring", { enumerable: true, get: function () { return contourLayout_1.contouring; } });
|
|
51
|
-
var hexbinLayout_1 = require("./hexbinLayout");
|
|
52
|
-
Object.defineProperty(exports, "hexbinning", { enumerable: true, get: function () { return hexbinLayout_1.hexbinning; } });
|
|
53
|
-
const generateLineBounds = (xydata, basedata, topBoundingAccessor, bottomBoundingAccessor) => {
|
|
54
|
-
const tops = xydata.map((d, i) => [
|
|
55
|
-
d[0],
|
|
56
|
-
d[1] + topBoundingAccessor(basedata[i])
|
|
57
|
-
]);
|
|
58
|
-
const bottoms = xydata.map((d, i) => [
|
|
59
|
-
d[0],
|
|
60
|
-
d[1] - bottomBoundingAccessor(basedata[i])
|
|
61
|
-
]);
|
|
62
|
-
return [...tops, ...bottoms.reverse()];
|
|
63
|
-
};
|
|
64
|
-
function lineBounding({ summaryType, data, defined }) {
|
|
65
|
-
let projectedSummaries = [];
|
|
66
|
-
if (!summaryType.type) {
|
|
67
|
-
summaryType = { type: summaryType };
|
|
68
|
-
}
|
|
69
|
-
const { boundingAccessor, topBoundingAccessor = boundingAccessor, bottomBoundingAccessor = boundingAccessor } = summaryType;
|
|
70
|
-
data.forEach((lineData) => {
|
|
71
|
-
const definedData = lineData._baseData.map(defined);
|
|
72
|
-
let currentBaseData = [];
|
|
73
|
-
let currentXYFC = [];
|
|
74
|
-
const boundingPieces = [
|
|
75
|
-
{
|
|
76
|
-
xyf: currentXYFC,
|
|
77
|
-
base: currentBaseData
|
|
78
|
-
}
|
|
79
|
-
];
|
|
80
|
-
definedData.forEach((d, i) => {
|
|
81
|
-
if (d === true) {
|
|
82
|
-
currentBaseData.push(lineData._baseData[i]);
|
|
83
|
-
currentXYFC.push(lineData._xyfCoordinates[i]);
|
|
84
|
-
}
|
|
85
|
-
else if (definedData[i + 1]) {
|
|
86
|
-
currentBaseData = [];
|
|
87
|
-
currentXYFC = [];
|
|
88
|
-
boundingPieces.push({
|
|
89
|
-
xyf: currentXYFC,
|
|
90
|
-
base: currentBaseData
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
boundingPieces.forEach(({ xyf, base }) => {
|
|
95
|
-
const boundingProjectedSummary = {
|
|
96
|
-
data: lineData,
|
|
97
|
-
parentSummary: lineData,
|
|
98
|
-
_xyfCoordinates: generateLineBounds(xyf, base, topBoundingAccessor, bottomBoundingAccessor)
|
|
99
|
-
};
|
|
100
|
-
projectedSummaries = [...projectedSummaries, boundingProjectedSummary];
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
return projectedSummaries;
|
|
104
|
-
}
|
|
105
|
-
function heatmapping({ preprocess = true, processedData = false, summaryType: baseSummaryType, data: baseData, finalXExtent = [
|
|
106
|
-
Math.min(...baseData.coordinates.map((d) => d.x)),
|
|
107
|
-
Math.max(...baseData.coordinates.map((d) => d.x))
|
|
108
|
-
], finalYExtent = [
|
|
109
|
-
Math.min(...baseData.coordinates.map((d) => d.y)),
|
|
110
|
-
Math.max(...baseData.coordinates.map((d) => d.y))
|
|
111
|
-
], size, xScaleType = (0, d3_scale_1.scaleLinear)(), yScaleType = (0, d3_scale_1.scaleLinear)(), margin, styleFn, classFn, renderFn, chartSize }) {
|
|
112
|
-
if (processedData && baseData) {
|
|
113
|
-
return baseData.coordinates;
|
|
114
|
-
}
|
|
115
|
-
if (baseData.coordinates && !baseData._xyfCoordinates) {
|
|
116
|
-
baseData._xyfCoordinates = baseData.coordinates.map((d) => [d.x, d.y]);
|
|
117
|
-
}
|
|
118
|
-
const data = Array.isArray(baseData) ? baseData : [baseData];
|
|
119
|
-
let projectedSummaries = [];
|
|
120
|
-
let summaryType;
|
|
121
|
-
if (!baseSummaryType.type) {
|
|
122
|
-
summaryType = { type: summaryType };
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
summaryType = baseSummaryType;
|
|
126
|
-
}
|
|
127
|
-
const {
|
|
128
|
-
// binGraphic = "square",
|
|
129
|
-
binValue = (d) => d.length, xBins = summaryType.yBins || 0.05, yBins = xBins, xCellPx = !summaryType.xBins && summaryType.xCellPx, yCellPx = !summaryType.yBins && summaryType.yCellPx, customMark, binMax } = summaryType;
|
|
130
|
-
const xBinPercent = xBins < 1 ? xBins : 1 / xBins;
|
|
131
|
-
const yBinPercent = yBins < 1 ? yBins : 1 / yBins;
|
|
132
|
-
const heatmapBinXScale = xScaleType.domain(finalXExtent).range([0, size[0]]);
|
|
133
|
-
const heatmapBinYScale = yScaleType.domain(finalYExtent).range([size[1], 0]);
|
|
134
|
-
const actualResolution = [
|
|
135
|
-
Math.ceil(((xCellPx && xCellPx / size[0]) || xBinPercent) * size[0] * 10) /
|
|
136
|
-
10,
|
|
137
|
-
Math.ceil(((yCellPx && yCellPx / size[1]) || yBinPercent) * size[1] * 10) /
|
|
138
|
-
10
|
|
139
|
-
];
|
|
140
|
-
let maxValue = -Infinity;
|
|
141
|
-
data.forEach((heatmapData) => {
|
|
142
|
-
const grid = [];
|
|
143
|
-
const flatGrid = [];
|
|
144
|
-
let cell;
|
|
145
|
-
let gridColumn;
|
|
146
|
-
for (let i = 0; Math.ceil(i) < size[0]; i += actualResolution[0]) {
|
|
147
|
-
const x = heatmapBinXScale.invert(i);
|
|
148
|
-
const x1 = heatmapBinXScale.invert(i + actualResolution[0]);
|
|
149
|
-
gridColumn = [];
|
|
150
|
-
grid.push(gridColumn);
|
|
151
|
-
for (let j = 0; Math.ceil(j) < size[1]; j += actualResolution[1]) {
|
|
152
|
-
const y = heatmapBinYScale.invert(j);
|
|
153
|
-
const y1 = heatmapBinYScale.invert(j + actualResolution[1]);
|
|
154
|
-
cell = {
|
|
155
|
-
gx: i,
|
|
156
|
-
gy: j,
|
|
157
|
-
gw: actualResolution[0],
|
|
158
|
-
gh: actualResolution[1],
|
|
159
|
-
x: (x + x1) / 2,
|
|
160
|
-
y: (y + y1) / 2,
|
|
161
|
-
binItems: [],
|
|
162
|
-
value: 0,
|
|
163
|
-
_xyfCoordinates: [
|
|
164
|
-
[x, y],
|
|
165
|
-
[x1, y],
|
|
166
|
-
[x1, y1],
|
|
167
|
-
[x, y1]
|
|
168
|
-
],
|
|
169
|
-
parentSummary: heatmapData
|
|
170
|
-
};
|
|
171
|
-
gridColumn.push(cell);
|
|
172
|
-
flatGrid.push(cell);
|
|
173
|
-
}
|
|
174
|
-
gridColumn.push(cell);
|
|
175
|
-
}
|
|
176
|
-
grid.push(gridColumn);
|
|
177
|
-
heatmapData._xyfCoordinates.forEach((d, di) => {
|
|
178
|
-
const baseX = heatmapBinXScale(d[0]);
|
|
179
|
-
const baseY = heatmapBinYScale(d[1]);
|
|
180
|
-
const xCoordinate = Math.floor(baseX / actualResolution[0]);
|
|
181
|
-
const yCoordinate = Math.floor(baseY / actualResolution[1]);
|
|
182
|
-
if (grid[xCoordinate][yCoordinate]) {
|
|
183
|
-
grid[xCoordinate][yCoordinate].binItems.push(heatmapData.coordinates[di]);
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
flatGrid.forEach((d) => {
|
|
187
|
-
d.value = binValue(d.binItems);
|
|
188
|
-
maxValue = Math.max(maxValue, d.value);
|
|
189
|
-
});
|
|
190
|
-
flatGrid.forEach((d) => {
|
|
191
|
-
d.percent = d.value / maxValue;
|
|
192
|
-
d.customMark = customMark && (React.createElement("g", { transform: `translate(${d.gx},${d.gy})` }, customMark({
|
|
193
|
-
d,
|
|
194
|
-
margin,
|
|
195
|
-
styleFn,
|
|
196
|
-
classFn,
|
|
197
|
-
renderFn,
|
|
198
|
-
chartSize,
|
|
199
|
-
adjustedSize: size
|
|
200
|
-
})));
|
|
201
|
-
});
|
|
202
|
-
projectedSummaries = [...projectedSummaries, ...flatGrid];
|
|
203
|
-
});
|
|
204
|
-
if (binMax) {
|
|
205
|
-
binMax(maxValue);
|
|
206
|
-
}
|
|
207
|
-
if (preprocess) {
|
|
208
|
-
const preprocessedSummary = {
|
|
209
|
-
type: "heatmap",
|
|
210
|
-
processedData: true,
|
|
211
|
-
_baseData: [],
|
|
212
|
-
_xyfCoordinates: [],
|
|
213
|
-
data: [],
|
|
214
|
-
bounds: [],
|
|
215
|
-
x: 0,
|
|
216
|
-
y: 0,
|
|
217
|
-
coordinates: projectedSummaries,
|
|
218
|
-
binMax: maxValue
|
|
219
|
-
};
|
|
220
|
-
return preprocessedSummary;
|
|
221
|
-
}
|
|
222
|
-
return projectedSummaries;
|
|
223
|
-
}
|
|
224
|
-
function trendlining({ preprocess = false, summaryType: baseSummaryType, data: baseData, finalXExtent = [
|
|
225
|
-
Math.min(...baseData.coordinates.map((d) => d.x)),
|
|
226
|
-
Math.max(...baseData.coordinates.map((d) => d.x))
|
|
227
|
-
], xScaleType = (0, d3_scale_1.scaleLinear)() }) {
|
|
228
|
-
if (preprocess) {
|
|
229
|
-
return baseData[0].coordinates;
|
|
230
|
-
}
|
|
231
|
-
let projectedSummaries = [];
|
|
232
|
-
let summaryType;
|
|
233
|
-
if (!baseSummaryType.type) {
|
|
234
|
-
summaryType = { type: summaryType };
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
summaryType = baseSummaryType;
|
|
238
|
-
}
|
|
239
|
-
const { regressionType: baseRegressionType = "linear", order = 2, precision = 4, controlPoints = 20, curve = d3_shape_1.curveCardinal } = summaryType;
|
|
240
|
-
let regressionType = baseRegressionType;
|
|
241
|
-
if (finalXExtent[0] < 0 &&
|
|
242
|
-
(baseRegressionType === "logarithmic" ||
|
|
243
|
-
baseRegressionType === "power" ||
|
|
244
|
-
baseRegressionType === "exponential")) {
|
|
245
|
-
console.error(`Cannot use this ${baseRegressionType} regressionType type with value range that goes below 0, defaulting to linear`);
|
|
246
|
-
regressionType = "linear";
|
|
247
|
-
}
|
|
248
|
-
if (baseData.coordinates && !baseData._xyfCoordinates) {
|
|
249
|
-
baseData._xyfCoordinates = baseData.coordinates.map((d) => [d.x, d.y]);
|
|
250
|
-
}
|
|
251
|
-
const data = Array.isArray(baseData) ? baseData : [baseData];
|
|
252
|
-
const xScale = xScaleType.domain([0, 1]).range(finalXExtent);
|
|
253
|
-
projectedSummaries = [];
|
|
254
|
-
data.forEach((bdata) => {
|
|
255
|
-
const regressionLine = regression_1.default[regressionType](bdata._xyfCoordinates.map((d) => {
|
|
256
|
-
let x = d[0];
|
|
257
|
-
let y = d[1];
|
|
258
|
-
if (typeof x !== "number") {
|
|
259
|
-
x = x.getTime();
|
|
260
|
-
}
|
|
261
|
-
if (typeof y !== "number") {
|
|
262
|
-
y = y.getTime();
|
|
263
|
-
}
|
|
264
|
-
return [x, y];
|
|
265
|
-
}), {
|
|
266
|
-
order,
|
|
267
|
-
precision
|
|
268
|
-
});
|
|
269
|
-
const controlStep = 1 / controlPoints;
|
|
270
|
-
let steps = [0, 1];
|
|
271
|
-
if (regressionType !== "linear") {
|
|
272
|
-
steps = [];
|
|
273
|
-
for (let step = 0; step < 1 + controlStep; step += controlStep) {
|
|
274
|
-
steps.push(step);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
const controlPointArray = [];
|
|
278
|
-
steps.forEach((controlPoint) => {
|
|
279
|
-
controlPointArray.push(regressionLine.predict(xScale(controlPoint)));
|
|
280
|
-
});
|
|
281
|
-
projectedSummaries.push({
|
|
282
|
-
centroid: false,
|
|
283
|
-
customMark: undefined,
|
|
284
|
-
data: bdata,
|
|
285
|
-
parentSummary: bdata,
|
|
286
|
-
value: regressionLine.string,
|
|
287
|
-
r2: regressionLine.r2,
|
|
288
|
-
curve,
|
|
289
|
-
_xyfCoordinates: controlPointArray
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
return projectedSummaries;
|
|
293
|
-
}
|
|
294
|
-
function shapeBounds(coordinates) {
|
|
295
|
-
let left = [Infinity, 0];
|
|
296
|
-
let right = [-Infinity, 0];
|
|
297
|
-
let top = [0, Infinity];
|
|
298
|
-
let bottom = [0, -Infinity];
|
|
299
|
-
coordinates.forEach((d) => {
|
|
300
|
-
left = d[0] < left[0] ? d : left;
|
|
301
|
-
right = d[0] > right[0] ? d : right;
|
|
302
|
-
bottom = d[1] > bottom[1] ? d : bottom;
|
|
303
|
-
top = d[1] < top[1] ? d : top;
|
|
304
|
-
});
|
|
305
|
-
return {
|
|
306
|
-
center: [(left[0] + right[0]) / 2, (top[1] + bottom[1]) / 2],
|
|
307
|
-
top,
|
|
308
|
-
left,
|
|
309
|
-
right,
|
|
310
|
-
bottom
|
|
311
|
-
};
|
|
312
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.contouring = contouring;
|
|
4
|
-
const d3_contour_1 = require("d3-contour");
|
|
5
|
-
const d3_scale_1 = require("d3-scale");
|
|
6
|
-
function shapeBounds(coordinates) {
|
|
7
|
-
let left = [Infinity, 0];
|
|
8
|
-
let right = [-Infinity, 0];
|
|
9
|
-
let top = [0, Infinity];
|
|
10
|
-
let bottom = [0, -Infinity];
|
|
11
|
-
coordinates.forEach((d) => {
|
|
12
|
-
left = d[0] < left[0] ? d : left;
|
|
13
|
-
right = d[0] > right[0] ? d : right;
|
|
14
|
-
bottom = d[1] > bottom[1] ? d : bottom;
|
|
15
|
-
top = d[1] < top[1] ? d : top;
|
|
16
|
-
});
|
|
17
|
-
return {
|
|
18
|
-
center: [(left[0] + right[0]) / 2, (top[1] + bottom[1]) / 2],
|
|
19
|
-
top,
|
|
20
|
-
left,
|
|
21
|
-
right,
|
|
22
|
-
bottom
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function contouring({ summaryType, data, finalXExtent, finalYExtent }) {
|
|
26
|
-
let projectedSummaries = [];
|
|
27
|
-
if (!summaryType.type) {
|
|
28
|
-
summaryType = { type: summaryType };
|
|
29
|
-
}
|
|
30
|
-
const { resolution = 500, thresholds = 10, bandwidth = 20, neighborhood } = summaryType;
|
|
31
|
-
const xScale = (0, d3_scale_1.scaleLinear)()
|
|
32
|
-
.domain(finalXExtent)
|
|
33
|
-
.rangeRound([0, resolution])
|
|
34
|
-
.nice();
|
|
35
|
-
const yScale = (0, d3_scale_1.scaleLinear)()
|
|
36
|
-
.domain(finalYExtent)
|
|
37
|
-
.rangeRound([resolution, 0])
|
|
38
|
-
.nice();
|
|
39
|
-
data.forEach((contourData) => {
|
|
40
|
-
let contourProjectedSummaries = (0, d3_contour_1.contourDensity)()
|
|
41
|
-
.size([resolution, resolution])
|
|
42
|
-
.x((d) => xScale(d[0]))
|
|
43
|
-
.y((d) => yScale(d[1]))
|
|
44
|
-
.thresholds(thresholds)
|
|
45
|
-
.bandwidth(bandwidth)(contourData._xyfCoordinates);
|
|
46
|
-
if (neighborhood) {
|
|
47
|
-
contourProjectedSummaries = [contourProjectedSummaries[0]];
|
|
48
|
-
}
|
|
49
|
-
const max = Math.max(...contourProjectedSummaries.map((d) => d.value));
|
|
50
|
-
contourProjectedSummaries.forEach((summary) => {
|
|
51
|
-
summary.parentSummary = contourData;
|
|
52
|
-
summary.bounds = [];
|
|
53
|
-
summary.percent = summary.value / max;
|
|
54
|
-
summary.coordinates.forEach((poly) => {
|
|
55
|
-
poly.forEach((subpoly, i) => {
|
|
56
|
-
poly[i] = subpoly.map((coordpair) => {
|
|
57
|
-
coordpair = [
|
|
58
|
-
xScale.invert(coordpair[0]),
|
|
59
|
-
yScale.invert(coordpair[1])
|
|
60
|
-
];
|
|
61
|
-
return coordpair;
|
|
62
|
-
});
|
|
63
|
-
//Only push bounds for the main poly, not its interior rings, otherwise you end up labeling interior cutouts
|
|
64
|
-
if (i === 0) {
|
|
65
|
-
summary.bounds.push(shapeBounds(poly[i]));
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
projectedSummaries = [...projectedSummaries, ...contourProjectedSummaries];
|
|
71
|
-
});
|
|
72
|
-
return projectedSummaries;
|
|
73
|
-
}
|
|
@@ -1,163 +0,0 @@
|
|
|
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.hexbinning = hexbinning;
|
|
37
|
-
const React = __importStar(require("react"));
|
|
38
|
-
const d3_hexbin_1 = require("d3-hexbin");
|
|
39
|
-
const d3_scale_1 = require("d3-scale");
|
|
40
|
-
function hexbinning({ preprocess = true, processedData = false, summaryType: baseSummaryType, data: baseData, finalXExtent: baseXExtent, finalYExtent: baseYExtent, size, xScaleType = (0, d3_scale_1.scaleLinear)(), yScaleType = (0, d3_scale_1.scaleLinear)(), margin, styleFn, classFn, renderFn, chartSize }) {
|
|
41
|
-
let finalXExtent = baseXExtent;
|
|
42
|
-
let finalYExtent = baseYExtent;
|
|
43
|
-
if (!finalXExtent) {
|
|
44
|
-
const xData = baseData.coordinates.map((p) => p.x);
|
|
45
|
-
finalXExtent = [Math.min(...xData), Math.max(...xData)];
|
|
46
|
-
}
|
|
47
|
-
if (!finalYExtent) {
|
|
48
|
-
const yData = baseData.coordinates.map((p) => p.y);
|
|
49
|
-
finalYExtent = [Math.min(...yData), Math.max(...yData)];
|
|
50
|
-
}
|
|
51
|
-
if (processedData && baseData) {
|
|
52
|
-
return baseData.coordinates;
|
|
53
|
-
}
|
|
54
|
-
let projectedSummaries = [];
|
|
55
|
-
let summaryType;
|
|
56
|
-
if (!baseSummaryType.type) {
|
|
57
|
-
summaryType = { type: summaryType };
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
summaryType = baseSummaryType;
|
|
61
|
-
}
|
|
62
|
-
const { bins = 0.05, cellPx, binValue = (d) => d.length, binMax, customMark } = summaryType;
|
|
63
|
-
if (baseData.coordinates && !baseData._xyfCoordinates) {
|
|
64
|
-
baseData._xyfCoordinates = baseData.coordinates.map((d) => [d.x, d.y]);
|
|
65
|
-
}
|
|
66
|
-
const data = Array.isArray(baseData) ? baseData : [baseData];
|
|
67
|
-
const hexBinXScale = xScaleType.domain(finalXExtent).range([0, size[0]]);
|
|
68
|
-
const hexBinYScale = yScaleType.domain(finalYExtent).range([0, size[1]]);
|
|
69
|
-
const actualResolution = (cellPx && cellPx / 2) || ((bins > 1 ? 1 / bins : bins) * size[0]) / 2;
|
|
70
|
-
const hexbinner = (0, d3_hexbin_1.hexbin)()
|
|
71
|
-
.x((d) => hexBinXScale(d._xyfPoint[0]))
|
|
72
|
-
.y((d) => hexBinYScale(d._xyfPoint[1]))
|
|
73
|
-
.radius(actualResolution)
|
|
74
|
-
.size(size);
|
|
75
|
-
let hexMax;
|
|
76
|
-
const allHexes = hexbinner.centers();
|
|
77
|
-
data.forEach((hexbinData) => {
|
|
78
|
-
hexMax = 0;
|
|
79
|
-
const hexes = hexbinner(hexbinData._xyfCoordinates.map((d, i) => ({
|
|
80
|
-
_xyfPoint: d,
|
|
81
|
-
...hexbinData.coordinates[i]
|
|
82
|
-
})));
|
|
83
|
-
const centerHash = {};
|
|
84
|
-
hexes.forEach((d) => {
|
|
85
|
-
centerHash[`${parseInt(d.x)}-${parseInt(d.y)}`] = true;
|
|
86
|
-
});
|
|
87
|
-
allHexes.forEach((hexCenter) => {
|
|
88
|
-
if (!centerHash[`${parseInt(hexCenter[0])}-${parseInt(hexCenter[1])}`]) {
|
|
89
|
-
const newHex = [];
|
|
90
|
-
newHex.x = hexCenter[0];
|
|
91
|
-
newHex.y = hexCenter[1];
|
|
92
|
-
hexes.push(newHex);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
hexMax = Math.max(...hexes.map((d) => binValue(d)));
|
|
96
|
-
if (binMax) {
|
|
97
|
-
binMax(hexMax);
|
|
98
|
-
}
|
|
99
|
-
const hexBase = [
|
|
100
|
-
[0, -1],
|
|
101
|
-
[0.866, -0.5],
|
|
102
|
-
[0.866, 0.5],
|
|
103
|
-
[0, 1],
|
|
104
|
-
[-0.866, 0.5],
|
|
105
|
-
[-0.866, -0.5]
|
|
106
|
-
];
|
|
107
|
-
const hexWidth = hexBinXScale.invert(actualResolution) - finalXExtent[0];
|
|
108
|
-
const hexHeight = hexBinYScale.invert(actualResolution) - finalYExtent[0];
|
|
109
|
-
const hexacoordinates = hexBase.map((d) => [
|
|
110
|
-
d[0] * hexWidth,
|
|
111
|
-
d[1] * hexHeight
|
|
112
|
-
]);
|
|
113
|
-
const hexbinProjectedSummaries = hexes.map((d) => {
|
|
114
|
-
const hexValue = binValue(d);
|
|
115
|
-
const gx = d.x;
|
|
116
|
-
const gy = d.y;
|
|
117
|
-
d.x = hexBinXScale.invert(d.x);
|
|
118
|
-
d.y = hexBinYScale.invert(d.y);
|
|
119
|
-
const percent = hexValue / hexMax;
|
|
120
|
-
return {
|
|
121
|
-
customMark: customMark && (React.createElement("g", { transform: `translate(${gx},${size[1] - gy})` }, customMark({
|
|
122
|
-
d: {
|
|
123
|
-
...d,
|
|
124
|
-
binItems: d,
|
|
125
|
-
percent,
|
|
126
|
-
value: hexValue,
|
|
127
|
-
radius: actualResolution,
|
|
128
|
-
hexCoordinates: hexBase.map((d) => [
|
|
129
|
-
d[0] * actualResolution,
|
|
130
|
-
d[1] * actualResolution
|
|
131
|
-
])
|
|
132
|
-
},
|
|
133
|
-
margin,
|
|
134
|
-
styleFn,
|
|
135
|
-
classFn,
|
|
136
|
-
renderFn,
|
|
137
|
-
chartSize,
|
|
138
|
-
adjustedSize: size
|
|
139
|
-
}))),
|
|
140
|
-
_xyfCoordinates: hexacoordinates.map((p) => [p[0] + d.x, p[1] + d.y]),
|
|
141
|
-
value: hexValue,
|
|
142
|
-
percent,
|
|
143
|
-
data: d,
|
|
144
|
-
parentSummary: hexbinData,
|
|
145
|
-
centroid: true
|
|
146
|
-
};
|
|
147
|
-
});
|
|
148
|
-
projectedSummaries = [...projectedSummaries, ...hexbinProjectedSummaries];
|
|
149
|
-
});
|
|
150
|
-
if (preprocess) {
|
|
151
|
-
projectedSummaries.forEach((d) => {
|
|
152
|
-
d.x = d.data.x;
|
|
153
|
-
d.y = d.data.y;
|
|
154
|
-
});
|
|
155
|
-
return {
|
|
156
|
-
type: "hexbin",
|
|
157
|
-
processedData: true,
|
|
158
|
-
coordinates: projectedSummaries,
|
|
159
|
-
binMax: hexMax
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
return projectedSummaries;
|
|
163
|
-
}
|