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,356 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dividedLine = exports.bumpChart = exports.cumulativeLine = exports.lineChart = exports.stackedArea = exports.differenceLine = exports.projectLineData = exports.projectSummaryData = void 0;
|
|
4
|
-
exports.funnelize = funnelize;
|
|
5
|
-
const d3_array_1 = require("d3-array");
|
|
6
|
-
const datesForUnique = (d) => (d instanceof Date ? d.getTime() : d);
|
|
7
|
-
const projectSummaryData = ({ data, summaryDataAccessor, xAccessor, yAccessor }) => {
|
|
8
|
-
const projectedData = [];
|
|
9
|
-
summaryDataAccessor.forEach((actualSummaryAccessor) => {
|
|
10
|
-
xAccessor.forEach((actualXAccessor) => {
|
|
11
|
-
yAccessor.forEach((actualYAccessor) => {
|
|
12
|
-
const projection = (d) => actualSummaryAccessor(d).map((p, q) => [
|
|
13
|
-
actualXAccessor(p, q),
|
|
14
|
-
actualYAccessor(p, q)
|
|
15
|
-
]);
|
|
16
|
-
data.forEach((d) => {
|
|
17
|
-
projectedData.push({
|
|
18
|
-
...d,
|
|
19
|
-
_baseData: actualSummaryAccessor(d),
|
|
20
|
-
_xyfCoordinates: projection(d)
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
return projectedData;
|
|
27
|
-
};
|
|
28
|
-
exports.projectSummaryData = projectSummaryData;
|
|
29
|
-
const projectLineData = ({ data, lineDataAccessor, xProp, xPropTop, xPropBottom, yProp, yPropTop, yPropBottom, xAccessor, yAccessor }) => {
|
|
30
|
-
if (!Array.isArray(data)) {
|
|
31
|
-
data = [data];
|
|
32
|
-
}
|
|
33
|
-
const projectedLine = [];
|
|
34
|
-
lineDataAccessor.forEach((actualLineAccessor, lineIndex) => {
|
|
35
|
-
xAccessor.forEach((actualXAccessor, xIndex) => {
|
|
36
|
-
yAccessor.forEach((actualYAccessor, yIndex) => {
|
|
37
|
-
data.forEach((d) => {
|
|
38
|
-
const originalLineData = { ...d, xIndex, yIndex, lineIndex };
|
|
39
|
-
originalLineData.data = actualLineAccessor(d).map((p, q) => {
|
|
40
|
-
const originalCoords = { data: p };
|
|
41
|
-
originalCoords[xProp] = actualXAccessor(p, q);
|
|
42
|
-
originalCoords[xPropTop] = originalCoords[xProp];
|
|
43
|
-
originalCoords[xPropBottom] = originalCoords[xProp];
|
|
44
|
-
originalCoords[yProp] = actualYAccessor(p, q);
|
|
45
|
-
originalCoords[yPropTop] = originalCoords[yProp];
|
|
46
|
-
originalCoords[yPropBottom] = originalCoords[yProp];
|
|
47
|
-
return originalCoords;
|
|
48
|
-
});
|
|
49
|
-
originalLineData.key = originalLineData.key || projectedLine.length;
|
|
50
|
-
projectedLine.push(originalLineData);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
return projectedLine;
|
|
56
|
-
};
|
|
57
|
-
exports.projectLineData = projectLineData;
|
|
58
|
-
const differenceLine = ({ data, yProp, yPropTop, yPropBottom }) => {
|
|
59
|
-
data.forEach((l, i) => {
|
|
60
|
-
l.data.forEach((point, q) => {
|
|
61
|
-
const otherLine = i === 0 ? 1 : 0;
|
|
62
|
-
if (point[yProp] > data[otherLine].data[q][yProp]) {
|
|
63
|
-
point[yPropBottom] = data[otherLine].data[q][yProp];
|
|
64
|
-
point[yPropTop] = point[yProp];
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
point[yPropTop] = point[yProp];
|
|
68
|
-
point[yPropBottom] = point[yProp];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
return data;
|
|
73
|
-
};
|
|
74
|
-
exports.differenceLine = differenceLine;
|
|
75
|
-
const stackedArea = ({ type = "stackedarea", data, xProp, yProp, yPropMiddle, sort, yPropTop, yPropBottom }) => {
|
|
76
|
-
const valueMap = new Map();
|
|
77
|
-
const lineSums = data.map(() => 0);
|
|
78
|
-
let lineIndex = 0;
|
|
79
|
-
for (const line of data) {
|
|
80
|
-
/*
|
|
81
|
-
After we calculate this, we then sort the lines (and the value used for the sorting is in this for loop)
|
|
82
|
-
So, we need to know their original index order in order to use the naively populated coordinate array in valueMap
|
|
83
|
-
Otherwise the coordinates in the map will be in different order than the sorted order of the lines
|
|
84
|
-
*/
|
|
85
|
-
line.__lineIndex = lineIndex;
|
|
86
|
-
for (const coord of line.data) {
|
|
87
|
-
const coordX = datesForUnique(coord[xProp]);
|
|
88
|
-
lineSums[lineIndex] += coord[yProp];
|
|
89
|
-
if (!valueMap.has(coordX)) {
|
|
90
|
-
valueMap.set(coordX, []);
|
|
91
|
-
}
|
|
92
|
-
valueMap.get(coordX)[lineIndex] = coord;
|
|
93
|
-
}
|
|
94
|
-
lineIndex++;
|
|
95
|
-
}
|
|
96
|
-
let stackSort = (a, b) => lineSums[b.key] - lineSums[a.key];
|
|
97
|
-
if (type === "stackedpercent-invert" || type === "stackedarea-invert") {
|
|
98
|
-
stackSort = (a, b) => lineSums[a.key] - lineSums[b.key];
|
|
99
|
-
}
|
|
100
|
-
sort = sort === undefined ? stackSort : sort;
|
|
101
|
-
if (sort !== null) {
|
|
102
|
-
data = data.sort(sort);
|
|
103
|
-
}
|
|
104
|
-
const lineIndexSortLookup = data.map((line) => line.__lineIndex);
|
|
105
|
-
for (const [, coordsAtX] of valueMap) {
|
|
106
|
-
let negativeOffset = 0;
|
|
107
|
-
let positiveOffset = 0;
|
|
108
|
-
const positiveStepTotal = (0, d3_array_1.sum)(coordsAtX, (d) => d?.[yProp] > 0 ? d[yProp] : 0);
|
|
109
|
-
const negativeStepTotal = (0, d3_array_1.sum)(coordsAtX, (d) => d?.[yProp] < 0 ? d[yProp] : 0);
|
|
110
|
-
for (const newIndex of lineIndexSortLookup) {
|
|
111
|
-
const l = coordsAtX[newIndex];
|
|
112
|
-
if (l) {
|
|
113
|
-
if (l[yProp] < 0) {
|
|
114
|
-
if (type === "linepercent" ||
|
|
115
|
-
type === "stackedpercent" ||
|
|
116
|
-
type === "stackedpercent-invert") {
|
|
117
|
-
const percent = l[yProp] / negativeStepTotal;
|
|
118
|
-
l.percent = percent;
|
|
119
|
-
if (type === "linepercent") {
|
|
120
|
-
l[yPropBottom] =
|
|
121
|
-
l[yPropBottom] =
|
|
122
|
-
l[yPropTop] =
|
|
123
|
-
l[yPropMiddle] =
|
|
124
|
-
percent;
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
const adjustment = negativeStepTotal >= 0 ? 0 : percent;
|
|
128
|
-
l[yPropBottom] =
|
|
129
|
-
negativeStepTotal === 0
|
|
130
|
-
? 0
|
|
131
|
-
: -(negativeOffset / negativeStepTotal);
|
|
132
|
-
l[yPropTop] = l[yPropBottom] - adjustment;
|
|
133
|
-
l[yPropMiddle] = l[yPropBottom] - adjustment / 2;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
l[yPropBottom] = negativeOffset;
|
|
138
|
-
l[yPropTop] = negativeOffset + l[yProp];
|
|
139
|
-
l[yPropMiddle] = negativeOffset + l[yProp] / 2;
|
|
140
|
-
}
|
|
141
|
-
negativeOffset += l[yProp];
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
if (type === "linepercent" ||
|
|
145
|
-
type === "stackedpercent" ||
|
|
146
|
-
type === "stackedpercent-invert") {
|
|
147
|
-
const percent = l[yProp] / positiveStepTotal;
|
|
148
|
-
l.percent = percent;
|
|
149
|
-
if (type === "linepercent") {
|
|
150
|
-
l[yPropBottom] = l[yPropTop] = l[yPropMiddle] = percent;
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
const adjustment = positiveStepTotal <= 0 ? 0 : percent;
|
|
154
|
-
l[yPropBottom] =
|
|
155
|
-
positiveStepTotal === 0 ? 0 : positiveOffset / positiveStepTotal;
|
|
156
|
-
l[yPropTop] = l[yPropBottom] + adjustment;
|
|
157
|
-
l[yPropMiddle] = l[yPropBottom] + adjustment / 2;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
l[yPropBottom] = positiveOffset;
|
|
162
|
-
l[yPropTop] = positiveOffset + l[yProp];
|
|
163
|
-
l[yPropMiddle] = positiveOffset + l[yProp] / 2;
|
|
164
|
-
}
|
|
165
|
-
positiveOffset += l[yProp];
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return data;
|
|
171
|
-
};
|
|
172
|
-
exports.stackedArea = stackedArea;
|
|
173
|
-
const lineChart = ({ data, y1, x1, yPropTop, yPropMiddle, yPropBottom, xPropTop, xPropMiddle, xPropBottom }) => {
|
|
174
|
-
if (y1) {
|
|
175
|
-
for (const line of data) {
|
|
176
|
-
for (const point of line.data) {
|
|
177
|
-
point[yPropBottom] = y1(point);
|
|
178
|
-
// Use top position for hover so overlapping-area hover points
|
|
179
|
-
// align with the visible line rather than compressing toward the baseline.
|
|
180
|
-
point[yPropMiddle] = point[yPropTop];
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
if (x1) {
|
|
185
|
-
for (const line of data) {
|
|
186
|
-
for (const point of line.data) {
|
|
187
|
-
point[xPropBottom] = x1(point);
|
|
188
|
-
point[xPropMiddle] = (point[xPropBottom] + point[xPropTop]) / 2;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return data;
|
|
193
|
-
};
|
|
194
|
-
exports.lineChart = lineChart;
|
|
195
|
-
const cumulativeLine = ({ data, y1, yPropTop, yPropMiddle, yPropBottom, type = "cumulative" }) => {
|
|
196
|
-
for (const line of data) {
|
|
197
|
-
let cumulativeValue = 0;
|
|
198
|
-
const dataArray = type === "cumulative-reverse" ? line.data.reverse() : line.data;
|
|
199
|
-
for (const point of dataArray) {
|
|
200
|
-
cumulativeValue += point[yPropTop];
|
|
201
|
-
point[yPropBottom] =
|
|
202
|
-
point[yPropTop] =
|
|
203
|
-
point[yPropMiddle] =
|
|
204
|
-
cumulativeValue;
|
|
205
|
-
if (y1) {
|
|
206
|
-
point[yPropBottom] = y1(point);
|
|
207
|
-
point[yPropMiddle] = point[yPropBottom] + point[yPropTop] / 2;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return data;
|
|
212
|
-
};
|
|
213
|
-
exports.cumulativeLine = cumulativeLine;
|
|
214
|
-
const bumpChart = ({ type = "bumpline", data, xProp, yProp, yPropMiddle, yPropTop, yPropBottom }) => {
|
|
215
|
-
const uniqXValues = new Map();
|
|
216
|
-
for (const line of data) {
|
|
217
|
-
for (const point of line.data) {
|
|
218
|
-
const xValue = datesForUnique(point[xProp]);
|
|
219
|
-
if (!uniqXValues.has(xValue)) {
|
|
220
|
-
uniqXValues.set(xValue, []);
|
|
221
|
-
}
|
|
222
|
-
uniqXValues.get(xValue).push(point);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
let bumpSort = (a, b) => {
|
|
226
|
-
if (a[yProp] > b[yProp]) {
|
|
227
|
-
return 1;
|
|
228
|
-
}
|
|
229
|
-
if (a[yProp] < b[yProp]) {
|
|
230
|
-
return -1;
|
|
231
|
-
}
|
|
232
|
-
return -1;
|
|
233
|
-
};
|
|
234
|
-
if (type === "bumparea-invert" || type === "bumpline-invert") {
|
|
235
|
-
bumpSort = (a, b) => {
|
|
236
|
-
if (a[yProp] < b[yProp]) {
|
|
237
|
-
return 1;
|
|
238
|
-
}
|
|
239
|
-
if (a[yProp] > b[yProp]) {
|
|
240
|
-
return -1;
|
|
241
|
-
}
|
|
242
|
-
return -1;
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
for (const [, pointsAtXArray] of uniqXValues) {
|
|
246
|
-
let negativeOffset = 0;
|
|
247
|
-
let positiveOffset = 0;
|
|
248
|
-
pointsAtXArray.sort(bumpSort);
|
|
249
|
-
let rank = 1;
|
|
250
|
-
for (const point of pointsAtXArray) {
|
|
251
|
-
point._XYFrameRank;
|
|
252
|
-
if (type === "bumparea" || type === "bumparea-invert") {
|
|
253
|
-
if (point[yProp] < 0) {
|
|
254
|
-
point[yPropTop] = negativeOffset + point[yProp];
|
|
255
|
-
point[yPropMiddle] = negativeOffset + point[yProp] / 2;
|
|
256
|
-
point[yPropBottom] = negativeOffset;
|
|
257
|
-
negativeOffset += point[yProp];
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
point[yPropTop] = positiveOffset + point[yProp];
|
|
261
|
-
point[yPropMiddle] = positiveOffset + point[yProp] / 2;
|
|
262
|
-
point[yPropBottom] = positiveOffset;
|
|
263
|
-
positiveOffset += point[yProp];
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
else {
|
|
267
|
-
point[yProp] = rank;
|
|
268
|
-
point[yPropTop] = rank;
|
|
269
|
-
point[yPropBottom] = rank;
|
|
270
|
-
}
|
|
271
|
-
rank++;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
return data;
|
|
275
|
-
};
|
|
276
|
-
exports.bumpChart = bumpChart;
|
|
277
|
-
const dividedLine = (parameters, points, searchIterations = 10) => {
|
|
278
|
-
let currentParameters = parameters(points[0], 0);
|
|
279
|
-
let currentPointsArray = [];
|
|
280
|
-
const dividedLinesData = [
|
|
281
|
-
{ key: currentParameters, points: currentPointsArray }
|
|
282
|
-
];
|
|
283
|
-
points.forEach((point, pointI) => {
|
|
284
|
-
const newParameters = parameters(point, pointI);
|
|
285
|
-
let matchingParams = newParameters === currentParameters;
|
|
286
|
-
const stringNewParams = JSON.stringify(newParameters);
|
|
287
|
-
const stringCurrentParams = JSON.stringify(currentParameters);
|
|
288
|
-
if (typeof currentParameters === "object") {
|
|
289
|
-
matchingParams = stringNewParams === stringCurrentParams;
|
|
290
|
-
}
|
|
291
|
-
if (matchingParams) {
|
|
292
|
-
currentPointsArray.push(point);
|
|
293
|
-
}
|
|
294
|
-
else {
|
|
295
|
-
const lastPoint = currentPointsArray[currentPointsArray.length - 1];
|
|
296
|
-
let pointA = lastPoint;
|
|
297
|
-
let pointB = point;
|
|
298
|
-
let stringBParams = stringNewParams;
|
|
299
|
-
let x = 0;
|
|
300
|
-
while (x < searchIterations && stringNewParams === stringBParams) {
|
|
301
|
-
const keys = Object.keys(pointA);
|
|
302
|
-
const findPoints = simpleSearchFunction({
|
|
303
|
-
pointA,
|
|
304
|
-
pointB,
|
|
305
|
-
currentParameters,
|
|
306
|
-
parameters,
|
|
307
|
-
keys
|
|
308
|
-
});
|
|
309
|
-
pointA = findPoints[0];
|
|
310
|
-
pointB = findPoints[1];
|
|
311
|
-
stringBParams = JSON.stringify(parameters(pointB));
|
|
312
|
-
x++;
|
|
313
|
-
}
|
|
314
|
-
currentPointsArray.push(pointB);
|
|
315
|
-
currentPointsArray = [pointB, point];
|
|
316
|
-
dividedLinesData.push({ key: newParameters, points: currentPointsArray });
|
|
317
|
-
currentParameters = newParameters;
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
return dividedLinesData;
|
|
321
|
-
};
|
|
322
|
-
exports.dividedLine = dividedLine;
|
|
323
|
-
function simpleSearchFunction({ pointA, pointB, currentParameters, parameters, keys }) {
|
|
324
|
-
const betweenPoint = {};
|
|
325
|
-
keys.forEach((key) => {
|
|
326
|
-
betweenPoint[key] =
|
|
327
|
-
typeof pointA[key] === "number"
|
|
328
|
-
? (pointA[key] + pointB[key]) / 2
|
|
329
|
-
: undefined;
|
|
330
|
-
});
|
|
331
|
-
const stringBetween = JSON.stringify(parameters(betweenPoint));
|
|
332
|
-
const stringCurrent = JSON.stringify(currentParameters);
|
|
333
|
-
if (stringBetween === stringCurrent) {
|
|
334
|
-
return [betweenPoint, pointB];
|
|
335
|
-
}
|
|
336
|
-
return [pointA, betweenPoint];
|
|
337
|
-
}
|
|
338
|
-
function funnelize({ data, steps, key }) {
|
|
339
|
-
const funnelData = [];
|
|
340
|
-
if (!Array.isArray(data)) {
|
|
341
|
-
data = [data];
|
|
342
|
-
}
|
|
343
|
-
if (!steps) {
|
|
344
|
-
steps = data.map((d) => Object.keys(d)).reduce((a, b) => a.concat(b), []);
|
|
345
|
-
}
|
|
346
|
-
data.forEach((datum, i) => {
|
|
347
|
-
const datumKey = key ? datum[key] : i;
|
|
348
|
-
steps.forEach((step) => {
|
|
349
|
-
const funnelDatum = { funnelKey: datumKey, stepName: "", stepValue: 0 };
|
|
350
|
-
funnelDatum.stepName = step;
|
|
351
|
-
funnelDatum.stepValue = datum[step] ? datum[step] : 0;
|
|
352
|
-
funnelData.push(funnelDatum);
|
|
353
|
-
});
|
|
354
|
-
});
|
|
355
|
-
return funnelData;
|
|
356
|
-
}
|
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.areaLink = void 0;
|
|
4
|
-
exports.circularAreaLink = circularAreaLink;
|
|
5
|
-
const d3_interpolate_1 = require("d3-interpolate");
|
|
6
|
-
const d3_shape_1 = require("d3-shape");
|
|
7
|
-
const dedupeRibbonPoints = (weight = 1) => (p, c) => {
|
|
8
|
-
const l = p[p.length - 1];
|
|
9
|
-
if (!l ||
|
|
10
|
-
Math.round(l.x / weight) !== Math.round(c.x / weight) ||
|
|
11
|
-
Math.round(l.y / weight) !== Math.round(c.y / weight)) {
|
|
12
|
-
p.push(c);
|
|
13
|
-
}
|
|
14
|
-
return p;
|
|
15
|
-
};
|
|
16
|
-
function linearRibbon() {
|
|
17
|
-
const _lineConstructor = (0, d3_shape_1.line)();
|
|
18
|
-
let _xAccessor = function (d) {
|
|
19
|
-
return d.x;
|
|
20
|
-
};
|
|
21
|
-
let _yAccessor = function (d) {
|
|
22
|
-
return d.y;
|
|
23
|
-
};
|
|
24
|
-
let _rAccessor = function (d) {
|
|
25
|
-
return d.r;
|
|
26
|
-
};
|
|
27
|
-
let _interpolator = d3_shape_1.curveLinearClosed;
|
|
28
|
-
function _ribbon(pathData) {
|
|
29
|
-
if (pathData.multiple) {
|
|
30
|
-
const original_r = _rAccessor;
|
|
31
|
-
const parallelTotal = pathData.multiple.reduce((p, c) => p + c.weight, 0);
|
|
32
|
-
_rAccessor = () => parallelTotal;
|
|
33
|
-
const totalPoints = buildRibbon(pathData.points);
|
|
34
|
-
let currentPoints = totalPoints
|
|
35
|
-
.filter((d) => d.direction === "forward")
|
|
36
|
-
.reduce(dedupeRibbonPoints(), []);
|
|
37
|
-
const allRibbons = [];
|
|
38
|
-
pathData.multiple.forEach((siblingPath, siblingI) => {
|
|
39
|
-
_rAccessor = () => siblingPath.weight;
|
|
40
|
-
const currentRibbon = buildRibbon(currentPoints);
|
|
41
|
-
allRibbons.push(currentRibbon);
|
|
42
|
-
const nextSibling = pathData.multiple[siblingI + 1];
|
|
43
|
-
if (nextSibling) {
|
|
44
|
-
const currentLeftSide = currentRibbon
|
|
45
|
-
.reverse()
|
|
46
|
-
.filter((d) => d.direction === "back")
|
|
47
|
-
.reduce(dedupeRibbonPoints(), []);
|
|
48
|
-
_rAccessor = () => nextSibling.weight;
|
|
49
|
-
const leftHandInflatedRibbon = buildRibbon(currentLeftSide);
|
|
50
|
-
currentPoints = leftHandInflatedRibbon
|
|
51
|
-
.reverse()
|
|
52
|
-
.filter((d) => d.direction === "back")
|
|
53
|
-
.reduce(dedupeRibbonPoints(), []);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
_rAccessor = original_r;
|
|
57
|
-
return allRibbons.map((d) => _lineConstructor.x(_xAccessor).y(_yAccessor).curve(_interpolator)(d));
|
|
58
|
-
}
|
|
59
|
-
const bothPoints = buildRibbon(pathData).reduce(dedupeRibbonPoints(), []);
|
|
60
|
-
return _lineConstructor.x(_xAccessor).y(_yAccessor).curve(_interpolator)(bothPoints);
|
|
61
|
-
}
|
|
62
|
-
_ribbon.x = function (_value) {
|
|
63
|
-
if (!arguments.length)
|
|
64
|
-
return _xAccessor;
|
|
65
|
-
_xAccessor = _value;
|
|
66
|
-
return _ribbon;
|
|
67
|
-
};
|
|
68
|
-
_ribbon.y = function (_value) {
|
|
69
|
-
if (!arguments.length)
|
|
70
|
-
return _yAccessor;
|
|
71
|
-
_yAccessor = _value;
|
|
72
|
-
return _ribbon;
|
|
73
|
-
};
|
|
74
|
-
_ribbon.r = function (_value) {
|
|
75
|
-
if (!arguments.length)
|
|
76
|
-
return _rAccessor;
|
|
77
|
-
_rAccessor = _value;
|
|
78
|
-
return _ribbon;
|
|
79
|
-
};
|
|
80
|
-
_ribbon.interpolate = function (_value) {
|
|
81
|
-
if (!arguments.length)
|
|
82
|
-
return _interpolator;
|
|
83
|
-
_interpolator = _value;
|
|
84
|
-
return _ribbon;
|
|
85
|
-
};
|
|
86
|
-
return _ribbon;
|
|
87
|
-
function offsetEdge(d) {
|
|
88
|
-
const diffX = _yAccessor(d.target) - _yAccessor(d.source);
|
|
89
|
-
const diffY = _xAccessor(d.target) - _xAccessor(d.source);
|
|
90
|
-
const angle0 = Math.atan2(diffY, diffX) + Math.PI / 2;
|
|
91
|
-
const angle1 = angle0 + Math.PI * 0.5;
|
|
92
|
-
const angle2 = angle0 + Math.PI * 0.5;
|
|
93
|
-
const x1 = _xAccessor(d.source) + _rAccessor(d.source) * Math.cos(angle1);
|
|
94
|
-
const y1 = _yAccessor(d.source) - _rAccessor(d.source) * Math.sin(angle1);
|
|
95
|
-
const x2 = _xAccessor(d.target) + _rAccessor(d.target) * Math.cos(angle2);
|
|
96
|
-
const y2 = _yAccessor(d.target) - _rAccessor(d.target) * Math.sin(angle2);
|
|
97
|
-
return { x1: x1, y1: y1, x2: x2, y2: y2 };
|
|
98
|
-
}
|
|
99
|
-
function buildRibbon(points) {
|
|
100
|
-
const bothCode = [];
|
|
101
|
-
let x = 0;
|
|
102
|
-
let transformedPoints = { x1: 0, y1: 0, x2: 0, y2: 0 };
|
|
103
|
-
while (x < points.length) {
|
|
104
|
-
if (x !== points.length - 1) {
|
|
105
|
-
transformedPoints = offsetEdge({
|
|
106
|
-
source: points[x],
|
|
107
|
-
target: points[x + 1]
|
|
108
|
-
});
|
|
109
|
-
const p1 = {
|
|
110
|
-
x: transformedPoints.x1,
|
|
111
|
-
y: transformedPoints.y1,
|
|
112
|
-
direction: "forward"
|
|
113
|
-
};
|
|
114
|
-
const p2 = {
|
|
115
|
-
x: transformedPoints.x2,
|
|
116
|
-
y: transformedPoints.y2,
|
|
117
|
-
direction: "forward"
|
|
118
|
-
};
|
|
119
|
-
bothCode.push(p1, p2);
|
|
120
|
-
if (bothCode.length > 3) {
|
|
121
|
-
const l = bothCode.length - 1;
|
|
122
|
-
const lineA = { a: bothCode[l - 3], b: bothCode[l - 2] };
|
|
123
|
-
const lineB = { a: bothCode[l - 1], b: bothCode[l] };
|
|
124
|
-
const intersect = findIntersect(lineA.a.x, lineA.a.y, lineA.b.x, lineA.b.y, lineB.a.x, lineB.a.y, lineB.b.x, lineB.b.y);
|
|
125
|
-
if (intersect.found === true) {
|
|
126
|
-
lineA.b.x = intersect.x;
|
|
127
|
-
lineA.b.y = intersect.y;
|
|
128
|
-
lineB.a.x = intersect.x;
|
|
129
|
-
lineB.a.y = intersect.y;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
x++;
|
|
134
|
-
}
|
|
135
|
-
x--;
|
|
136
|
-
//Back
|
|
137
|
-
while (x >= 0) {
|
|
138
|
-
if (x !== 0) {
|
|
139
|
-
transformedPoints = offsetEdge({
|
|
140
|
-
source: points[x],
|
|
141
|
-
target: points[x - 1]
|
|
142
|
-
});
|
|
143
|
-
const p1 = {
|
|
144
|
-
x: transformedPoints.x1,
|
|
145
|
-
y: transformedPoints.y1,
|
|
146
|
-
direction: "back"
|
|
147
|
-
};
|
|
148
|
-
const p2 = {
|
|
149
|
-
x: transformedPoints.x2,
|
|
150
|
-
y: transformedPoints.y2,
|
|
151
|
-
direction: "back"
|
|
152
|
-
};
|
|
153
|
-
bothCode.push(p1, p2);
|
|
154
|
-
if (bothCode.length > 3) {
|
|
155
|
-
const l = bothCode.length - 1;
|
|
156
|
-
const lineA = { a: bothCode[l - 3], b: bothCode[l - 2] };
|
|
157
|
-
const lineB = { a: bothCode[l - 1], b: bothCode[l] };
|
|
158
|
-
const intersect = findIntersect(lineA.a.x, lineA.a.y, lineA.b.x, lineA.b.y, lineB.a.x, lineB.a.y, lineB.b.x, lineB.b.y);
|
|
159
|
-
if (intersect.found === true) {
|
|
160
|
-
lineA.b.x = intersect.x;
|
|
161
|
-
lineA.b.y = intersect.y;
|
|
162
|
-
lineB.a.x = intersect.x;
|
|
163
|
-
lineB.a.y = intersect.y;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
x--;
|
|
168
|
-
}
|
|
169
|
-
return bothCode;
|
|
170
|
-
}
|
|
171
|
-
function findIntersect(l1x1, l1y1, l1x2, l1y2, l2x1, l2y1, l2x2, l2y2) {
|
|
172
|
-
let a, b;
|
|
173
|
-
const result = {
|
|
174
|
-
x: null,
|
|
175
|
-
y: null,
|
|
176
|
-
found: false
|
|
177
|
-
};
|
|
178
|
-
const d = (l2y2 - l2y1) * (l1x2 - l1x1) - (l2x2 - l2x1) * (l1y2 - l1y1);
|
|
179
|
-
if (d === 0) {
|
|
180
|
-
return result;
|
|
181
|
-
}
|
|
182
|
-
a = l1y1 - l2y1;
|
|
183
|
-
b = l1x1 - l2x1;
|
|
184
|
-
const n1 = (l2x2 - l2x1) * a - (l2y2 - l2y1) * b;
|
|
185
|
-
const n2 = (l1x2 - l1x1) * a - (l1y2 - l1y1) * b;
|
|
186
|
-
a = n1 / d;
|
|
187
|
-
b = n2 / d;
|
|
188
|
-
result.x = l1x1 + a * (l1x2 - l1x1);
|
|
189
|
-
result.y = l1y1 + a * (l1y2 - l1y1);
|
|
190
|
-
if (a > 0 && a < 1 && b > 0 && b < 1) {
|
|
191
|
-
result.found = true;
|
|
192
|
-
}
|
|
193
|
-
return result;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
const curvature = 0.5;
|
|
197
|
-
const ribbonLink = (d) => {
|
|
198
|
-
const diff = d.direction === "down"
|
|
199
|
-
? Math.abs(d.target.y - d.source.y)
|
|
200
|
-
: Math.abs(d.source.x - d.target.x);
|
|
201
|
-
// const halfWidth = d.width / 2
|
|
202
|
-
const testCoordinates = d.direction === "down"
|
|
203
|
-
? [
|
|
204
|
-
{
|
|
205
|
-
x: d.y0,
|
|
206
|
-
y: d.source.y
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
x: d.y0,
|
|
210
|
-
y: d.source.y + diff / 3
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
x: d.y1,
|
|
214
|
-
y: d.target.y - diff / 3
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
x: d.y1,
|
|
218
|
-
y: d.target.y
|
|
219
|
-
}
|
|
220
|
-
]
|
|
221
|
-
: [
|
|
222
|
-
{
|
|
223
|
-
x: d.source.x0,
|
|
224
|
-
y: d.y0
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
x: d.source.x0 + diff / 3,
|
|
228
|
-
y: d.y0
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
x: d.target.x0 - diff / 3,
|
|
232
|
-
y: d.y1
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
x: d.target.x0,
|
|
236
|
-
y: d.y1
|
|
237
|
-
}
|
|
238
|
-
];
|
|
239
|
-
const linkGenerator = linearRibbon();
|
|
240
|
-
linkGenerator.x((d) => d.x);
|
|
241
|
-
linkGenerator.y((d) => d.y);
|
|
242
|
-
linkGenerator.r(() => d.sankeyWidth / 2);
|
|
243
|
-
return linkGenerator(testCoordinates);
|
|
244
|
-
};
|
|
245
|
-
const areaLink = (d) => {
|
|
246
|
-
let x0, x1, x2, x3, y0, y1, xi, y2, y3;
|
|
247
|
-
if (d.direction === "down") {
|
|
248
|
-
x0 = d.y0 - d.sankeyWidth / 2;
|
|
249
|
-
x1 = d.y1 - d.sankeyWidth / 2;
|
|
250
|
-
x2 = d.y1 + d.sankeyWidth / 2;
|
|
251
|
-
x3 = d.y0 + d.sankeyWidth / 2;
|
|
252
|
-
y0 = d.source.y1;
|
|
253
|
-
y1 = d.target.y0;
|
|
254
|
-
xi = (0, d3_interpolate_1.interpolateNumber)(y0, y1);
|
|
255
|
-
y2 = xi(curvature);
|
|
256
|
-
y3 = xi(1 - curvature);
|
|
257
|
-
return `M${x0},${y0}C${x0},${y2} ${x1},${y3} ${x1},${y1}L${x2},${y1}C${x2},${y3} ${x3},${y2} ${x3},${y0}Z`;
|
|
258
|
-
}
|
|
259
|
-
;
|
|
260
|
-
(x0 = d.source.x1), // eslint-disable-line no-sequences
|
|
261
|
-
(x1 = d.target.x0),
|
|
262
|
-
(xi = (0, d3_interpolate_1.interpolateNumber)(x0, x1)),
|
|
263
|
-
(x2 = xi(curvature)),
|
|
264
|
-
(x3 = xi(1 - curvature)),
|
|
265
|
-
(y0 = d.y0 - d.sankeyWidth / 2),
|
|
266
|
-
(y1 = d.y1 - d.sankeyWidth / 2),
|
|
267
|
-
(y2 = d.y1 + d.sankeyWidth / 2),
|
|
268
|
-
(y3 = d.y0 + d.sankeyWidth / 2);
|
|
269
|
-
return `M${x0},${y0}C${x2},${y0} ${x3},${y1} ${x1},${y1}L${x1},${y2}C${x3},${y2} ${x2},${y3} ${x0},${y3}Z`;
|
|
270
|
-
};
|
|
271
|
-
exports.areaLink = areaLink;
|
|
272
|
-
function circularAreaLink(link) {
|
|
273
|
-
const linkGenerator = linearRibbon();
|
|
274
|
-
linkGenerator.x((d) => d.x);
|
|
275
|
-
linkGenerator.y((d) => d.y);
|
|
276
|
-
linkGenerator.r(() => link.sankeyWidth / 2);
|
|
277
|
-
const xyForLink = link.direction === "down"
|
|
278
|
-
? [
|
|
279
|
-
{
|
|
280
|
-
x: link.circularPathData.sourceY,
|
|
281
|
-
y: link.circularPathData.sourceX
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
x: link.circularPathData.sourceY,
|
|
285
|
-
y: link.circularPathData.leftFullExtent
|
|
286
|
-
},
|
|
287
|
-
{
|
|
288
|
-
x: link.circularPathData.verticalFullExtent,
|
|
289
|
-
y: link.circularPathData.leftFullExtent
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
x: link.circularPathData.verticalFullExtent,
|
|
293
|
-
y: link.circularPathData.rightFullExtent
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
x: link.circularPathData.targetY,
|
|
297
|
-
y: link.circularPathData.rightFullExtent
|
|
298
|
-
},
|
|
299
|
-
{
|
|
300
|
-
x: link.circularPathData.targetY,
|
|
301
|
-
y: link.circularPathData.targetX
|
|
302
|
-
}
|
|
303
|
-
]
|
|
304
|
-
: [
|
|
305
|
-
{
|
|
306
|
-
x: link.circularPathData.sourceX,
|
|
307
|
-
y: link.circularPathData.sourceY
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
x: link.circularPathData.leftFullExtent,
|
|
311
|
-
y: link.circularPathData.sourceY
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
x: link.circularPathData.leftFullExtent,
|
|
315
|
-
y: link.circularPathData.verticalFullExtent
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
x: link.circularPathData.rightFullExtent,
|
|
319
|
-
y: link.circularPathData.verticalFullExtent
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
x: link.circularPathData.rightFullExtent,
|
|
323
|
-
y: link.circularPathData.targetY
|
|
324
|
-
},
|
|
325
|
-
{
|
|
326
|
-
x: link.circularPathData.targetX,
|
|
327
|
-
y: link.circularPathData.targetY
|
|
328
|
-
}
|
|
329
|
-
];
|
|
330
|
-
return linkGenerator(xyForLink);
|
|
331
|
-
}
|