stream-charts 1.2.1 → 2.0.0
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/LICENSE +21 -0
- package/README.md +809 -1022
- package/changes.md +36 -0
- package/dist/app/charts/Chart.d.ts +35 -139
- package/dist/app/charts/Chart.d.ts.map +1 -0
- package/dist/app/charts/Chart.js +74 -65
- package/dist/app/charts/Chart.js.map +1 -1
- package/dist/app/charts/axes/AxesState.d.ts +26 -18
- package/dist/app/charts/axes/AxesState.d.ts.map +1 -0
- package/dist/app/charts/axes/AxesState.js +26 -24
- package/dist/app/charts/axes/AxesState.js.map +1 -1
- package/dist/app/charts/axes/AxisInterval.d.ts +44 -26
- package/dist/app/charts/axes/AxisInterval.d.ts.map +1 -0
- package/dist/app/charts/axes/AxisInterval.js +48 -29
- package/dist/app/charts/axes/AxisInterval.js.map +1 -1
- package/dist/app/charts/axes/BaseAxisRange.d.ts +46 -22
- package/dist/app/charts/axes/BaseAxisRange.d.ts.map +1 -0
- package/dist/app/charts/axes/BaseAxisRange.js +17 -12
- package/dist/app/charts/axes/BaseAxisRange.js.map +1 -1
- package/dist/app/charts/axes/ContinuousAxis.d.ts +47 -6
- package/dist/app/charts/axes/ContinuousAxis.d.ts.map +1 -0
- package/dist/app/charts/axes/ContinuousAxis.js +160 -27
- package/dist/app/charts/axes/ContinuousAxis.js.map +1 -1
- package/dist/app/charts/axes/ContinuousAxisRange.d.ts +29 -10
- package/dist/app/charts/axes/ContinuousAxisRange.d.ts.map +1 -0
- package/dist/app/charts/axes/ContinuousAxisRange.js +29 -11
- package/dist/app/charts/axes/ContinuousAxisRange.js.map +1 -1
- package/dist/app/charts/axes/EmptyAxis.d.ts +5 -2
- package/dist/app/charts/axes/EmptyAxis.d.ts.map +1 -0
- package/dist/app/charts/axes/EmptyAxis.js +30 -9
- package/dist/app/charts/axes/EmptyAxis.js.map +1 -1
- package/dist/app/charts/axes/OrdinalAxis.d.ts +5 -3
- package/dist/app/charts/axes/OrdinalAxis.d.ts.map +1 -0
- package/dist/app/charts/axes/OrdinalAxis.js +39 -16
- package/dist/app/charts/axes/OrdinalAxis.js.map +1 -1
- package/dist/app/charts/axes/OrdinalAxisRange.d.ts +76 -13
- package/dist/app/charts/axes/OrdinalAxisRange.d.ts.map +1 -0
- package/dist/app/charts/axes/OrdinalAxisRange.js +95 -16
- package/dist/app/charts/axes/OrdinalAxisRange.js.map +1 -1
- package/dist/app/charts/axes/autoScale.d.ts +111 -0
- package/dist/app/charts/axes/autoScale.d.ts.map +1 -0
- package/dist/app/charts/axes/autoScale.js +188 -0
- package/dist/app/charts/axes/autoScale.js.map +1 -0
- package/dist/app/charts/axes/axes.d.ts +273 -150
- package/dist/app/charts/axes/axes.d.ts.map +1 -0
- package/dist/app/charts/axes/axes.js +808 -583
- package/dist/app/charts/axes/axes.js.map +1 -1
- package/dist/app/charts/d3types.d.ts +40 -11
- package/dist/app/charts/d3types.d.ts.map +1 -0
- package/dist/app/charts/d3types.js +3 -0
- package/dist/app/charts/d3types.js.map +1 -1
- package/dist/app/charts/datasources/StreamingDataSource.d.ts +149 -0
- package/dist/app/charts/datasources/StreamingDataSource.d.ts.map +1 -0
- package/dist/app/charts/datasources/StreamingDataSource.js +110 -0
- package/dist/app/charts/datasources/StreamingDataSource.js.map +1 -0
- package/dist/app/charts/datasources/iteratesDataSource.d.ts +73 -0
- package/dist/app/charts/datasources/iteratesDataSource.d.ts.map +1 -0
- package/dist/app/charts/datasources/iteratesDataSource.js +87 -0
- package/dist/app/charts/datasources/iteratesDataSource.js.map +1 -0
- package/dist/app/charts/datasources/ordinalDataSource.d.ts +75 -0
- package/dist/app/charts/datasources/ordinalDataSource.d.ts.map +1 -0
- package/dist/app/charts/datasources/ordinalDataSource.js +135 -0
- package/dist/app/charts/datasources/ordinalDataSource.js.map +1 -0
- package/dist/app/charts/datasources/outlierDataSource.d.ts +53 -0
- package/dist/app/charts/datasources/outlierDataSource.d.ts.map +1 -0
- package/dist/app/charts/datasources/outlierDataSource.js +57 -0
- package/dist/app/charts/datasources/outlierDataSource.js.map +1 -0
- package/dist/app/charts/datasources/timeSeriesDataSource.d.ts +77 -0
- package/dist/app/charts/datasources/timeSeriesDataSource.d.ts.map +1 -0
- package/dist/app/charts/datasources/timeSeriesDataSource.js +85 -0
- package/dist/app/charts/datasources/timeSeriesDataSource.js.map +1 -0
- package/dist/app/charts/filters/regexFilter.d.ts +31 -4
- package/dist/app/charts/filters/regexFilter.d.ts.map +1 -0
- package/dist/app/charts/filters/regexFilter.js +38 -4
- package/dist/app/charts/filters/regexFilter.js.map +1 -1
- package/dist/app/charts/hooks/AxesProvider.d.ts +21 -0
- package/dist/app/charts/hooks/AxesProvider.d.ts.map +1 -0
- package/dist/app/charts/hooks/AxesProvider.js +213 -0
- package/dist/app/charts/hooks/AxesProvider.js.map +1 -0
- package/dist/app/charts/hooks/CanvasSurfaceProvider.d.ts +25 -0
- package/dist/app/charts/hooks/CanvasSurfaceProvider.d.ts.map +1 -0
- package/dist/app/charts/hooks/CanvasSurfaceProvider.js +76 -0
- package/dist/app/charts/hooks/CanvasSurfaceProvider.js.map +1 -0
- package/dist/app/charts/hooks/ChartProvider.d.ts +40 -0
- package/dist/app/charts/hooks/ChartProvider.d.ts.map +1 -0
- package/dist/app/charts/hooks/ChartProvider.js +33 -0
- package/dist/app/charts/hooks/ChartProvider.js.map +1 -0
- package/dist/app/charts/hooks/InteractionProvider.d.ts +23 -0
- package/dist/app/charts/hooks/InteractionProvider.d.ts.map +1 -0
- package/dist/app/charts/hooks/InteractionProvider.js +60 -0
- package/dist/app/charts/hooks/InteractionProvider.js.map +1 -0
- package/dist/app/charts/hooks/PlotDimensionsProvider.d.ts +16 -0
- package/dist/app/charts/hooks/PlotDimensionsProvider.d.ts.map +1 -0
- package/dist/app/charts/hooks/PlotDimensionsProvider.js +76 -0
- package/dist/app/charts/hooks/PlotDimensionsProvider.js.map +1 -0
- package/dist/app/charts/hooks/defaultAxesValues.d.ts +11 -0
- package/dist/app/charts/hooks/defaultAxesValues.d.ts.map +1 -0
- package/dist/app/charts/hooks/defaultAxesValues.js +36 -0
- package/dist/app/charts/hooks/defaultAxesValues.js.map +1 -0
- package/dist/app/charts/hooks/defaultMouseValues.d.ts +9 -0
- package/dist/app/charts/hooks/defaultMouseValues.d.ts.map +1 -0
- package/dist/app/charts/hooks/defaultMouseValues.js +23 -0
- package/dist/app/charts/hooks/defaultMouseValues.js.map +1 -0
- package/dist/app/charts/hooks/defaultPlotDimensions.d.ts +13 -0
- package/dist/app/charts/hooks/defaultPlotDimensions.d.ts.map +1 -0
- package/dist/app/charts/hooks/defaultPlotDimensions.js +23 -0
- package/dist/app/charts/hooks/defaultPlotDimensions.js.map +1 -0
- package/dist/app/charts/hooks/defaultTooltipValues.d.ts +9 -0
- package/dist/app/charts/hooks/defaultTooltipValues.d.ts.map +1 -0
- package/dist/app/charts/hooks/defaultTooltipValues.js +21 -0
- package/dist/app/charts/hooks/defaultTooltipValues.js.map +1 -0
- package/dist/app/charts/hooks/defaultUseChartValues.d.ts +14 -0
- package/dist/app/charts/hooks/defaultUseChartValues.d.ts.map +1 -0
- package/dist/app/charts/hooks/defaultUseChartValues.js +30 -0
- package/dist/app/charts/hooks/defaultUseChartValues.js.map +1 -0
- package/dist/app/charts/hooks/useAxes.d.ts +49 -36
- package/dist/app/charts/hooks/useAxes.d.ts.map +1 -0
- package/dist/app/charts/hooks/useAxes.js +16 -176
- package/dist/app/charts/hooks/useAxes.js.map +1 -1
- package/dist/app/charts/hooks/useCanvasSurface.d.ts +25 -0
- package/dist/app/charts/hooks/useCanvasSurface.d.ts.map +1 -0
- package/dist/app/charts/hooks/useCanvasSurface.js +18 -0
- package/dist/app/charts/hooks/useCanvasSurface.js.map +1 -0
- package/dist/app/charts/hooks/useChart.d.ts +30 -44
- package/dist/app/charts/hooks/useChart.d.ts.map +1 -0
- package/dist/app/charts/hooks/useChart.js +26 -48
- package/dist/app/charts/hooks/useChart.js.map +1 -1
- package/dist/app/charts/hooks/useDataSource.d.ts +68 -0
- package/dist/app/charts/hooks/useDataSource.d.ts.map +1 -0
- package/dist/app/charts/hooks/useDataSource.js +63 -0
- package/dist/app/charts/hooks/useDataSource.js.map +1 -0
- package/dist/app/charts/hooks/useHoveredSeries.d.ts +25 -0
- package/dist/app/charts/hooks/useHoveredSeries.d.ts.map +1 -0
- package/dist/app/charts/hooks/useHoveredSeries.js +15 -0
- package/dist/app/charts/hooks/useHoveredSeries.js.map +1 -0
- package/dist/app/charts/hooks/useMouse.d.ts +46 -22
- package/dist/app/charts/hooks/useMouse.d.ts.map +1 -0
- package/dist/app/charts/hooks/useMouse.js +12 -56
- package/dist/app/charts/hooks/useMouse.js.map +1 -1
- package/dist/app/charts/hooks/usePlotDimensions.d.ts +25 -13
- package/dist/app/charts/hooks/usePlotDimensions.d.ts.map +1 -0
- package/dist/app/charts/hooks/usePlotDimensions.js +6 -62
- package/dist/app/charts/hooks/usePlotDimensions.js.map +1 -1
- package/dist/app/charts/hooks/useTooltip.d.ts +24 -26
- package/dist/app/charts/hooks/useTooltip.d.ts.map +1 -0
- package/dist/app/charts/hooks/useTooltip.js +12 -42
- package/dist/app/charts/hooks/useTooltip.js.map +1 -1
- package/dist/app/charts/index.d.ts +66 -0
- package/dist/app/charts/index.d.ts.map +1 -0
- package/dist/app/charts/index.js +87 -0
- package/dist/app/charts/index.js.map +1 -0
- package/dist/app/charts/legends/Legend.d.ts +33 -12
- package/dist/app/charts/legends/Legend.d.ts.map +1 -0
- package/dist/app/charts/legends/Legend.js +138 -379
- package/dist/app/charts/legends/Legend.js.map +1 -1
- package/dist/app/charts/legends/constants.d.ts +19 -0
- package/dist/app/charts/legends/constants.d.ts.map +1 -0
- package/dist/app/charts/legends/constants.js +34 -0
- package/dist/app/charts/legends/constants.js.map +1 -0
- package/dist/app/charts/observables/ChartData.d.ts +1 -0
- package/dist/app/charts/observables/ChartData.d.ts.map +1 -0
- package/dist/app/charts/observables/iterates.d.ts +13 -7
- package/dist/app/charts/observables/iterates.d.ts.map +1 -0
- package/dist/app/charts/observables/iterates.js +42 -9
- package/dist/app/charts/observables/iterates.js.map +1 -1
- package/dist/app/charts/observables/ordinals.d.ts +70 -12
- package/dist/app/charts/observables/ordinals.d.ts.map +1 -0
- package/dist/app/charts/observables/ordinals.js +127 -48
- package/dist/app/charts/observables/ordinals.js.map +1 -1
- package/dist/app/charts/observables/outliers.d.ts +18 -0
- package/dist/app/charts/observables/outliers.d.ts.map +1 -0
- package/dist/app/charts/observables/outliers.js +2 -0
- package/dist/app/charts/observables/outliers.js.map +1 -0
- package/dist/app/charts/plots/BarPlot.d.ts +87 -13
- package/dist/app/charts/plots/BarPlot.d.ts.map +1 -0
- package/dist/app/charts/plots/BarPlot.js +603 -356
- package/dist/app/charts/plots/BarPlot.js.map +1 -1
- package/dist/app/charts/plots/OutlierPlot.d.ts +123 -0
- package/dist/app/charts/plots/OutlierPlot.d.ts.map +1 -0
- package/dist/app/charts/plots/OutlierPlot.js +430 -0
- package/dist/app/charts/plots/OutlierPlot.js.map +1 -0
- package/dist/app/charts/plots/PoincarePlot.d.ts +92 -14
- package/dist/app/charts/plots/PoincarePlot.d.ts.map +1 -0
- package/dist/app/charts/plots/PoincarePlot.js +523 -364
- package/dist/app/charts/plots/PoincarePlot.js.map +1 -1
- package/dist/app/charts/plots/RasterPlot.d.ts +31 -10
- package/dist/app/charts/plots/RasterPlot.d.ts.map +1 -0
- package/dist/app/charts/plots/RasterPlot.js +198 -306
- package/dist/app/charts/plots/RasterPlot.js.map +1 -1
- package/dist/app/charts/plots/ScatterPlot.d.ts +77 -21
- package/dist/app/charts/plots/ScatterPlot.d.ts.map +1 -0
- package/dist/app/charts/plots/ScatterPlot.js +359 -302
- package/dist/app/charts/plots/ScatterPlot.js.map +1 -1
- package/dist/app/charts/plots/autoScaleYAxes.d.ts +43 -0
- package/dist/app/charts/plots/autoScaleYAxes.d.ts.map +1 -0
- package/dist/app/charts/plots/autoScaleYAxes.js +71 -0
- package/dist/app/charts/plots/autoScaleYAxes.js.map +1 -0
- package/dist/app/charts/plots/colorizedLine.d.ts +61 -0
- package/dist/app/charts/plots/colorizedLine.d.ts.map +1 -0
- package/dist/app/charts/plots/colorizedLine.js +157 -0
- package/dist/app/charts/plots/colorizedLine.js.map +1 -0
- package/dist/app/charts/plots/constants.d.ts +7 -0
- package/dist/app/charts/plots/constants.d.ts.map +1 -0
- package/dist/app/charts/plots/constants.js +11 -0
- package/dist/app/charts/plots/constants.js.map +1 -0
- package/dist/app/charts/plots/hitTesting.d.ts +88 -0
- package/dist/app/charts/plots/hitTesting.d.ts.map +1 -0
- package/dist/app/charts/plots/hitTesting.js +136 -0
- package/dist/app/charts/plots/hitTesting.js.map +1 -0
- package/dist/app/charts/plots/plot.d.ts +52 -16
- package/dist/app/charts/plots/plot.d.ts.map +1 -0
- package/dist/app/charts/plots/plot.js +108 -35
- package/dist/app/charts/plots/plot.js.map +1 -1
- package/dist/app/charts/plots/useCanvasZoomPan.d.ts +119 -0
- package/dist/app/charts/plots/useCanvasZoomPan.d.ts.map +1 -0
- package/dist/app/charts/plots/useCanvasZoomPan.js +113 -0
- package/dist/app/charts/plots/useCanvasZoomPan.js.map +1 -0
- package/dist/app/charts/plots/useStreamingTimeAxes.d.ts +103 -0
- package/dist/app/charts/plots/useStreamingTimeAxes.d.ts.map +1 -0
- package/dist/app/charts/plots/useStreamingTimeAxes.js +257 -0
- package/dist/app/charts/plots/useStreamingTimeAxes.js.map +1 -0
- package/dist/app/charts/series/baseSeries.d.ts +60 -8
- package/dist/app/charts/series/baseSeries.d.ts.map +1 -0
- package/dist/app/charts/series/baseSeries.js +53 -8
- package/dist/app/charts/series/baseSeries.js.map +1 -1
- package/dist/app/charts/series/iterateSeries.d.ts +9 -8
- package/dist/app/charts/series/iterateSeries.d.ts.map +1 -0
- package/dist/app/charts/series/iterateSeries.js +7 -7
- package/dist/app/charts/series/iterateSeries.js.map +1 -1
- package/dist/app/charts/series/ordinalSeries.d.ts +27 -13
- package/dist/app/charts/series/ordinalSeries.d.ts.map +1 -0
- package/dist/app/charts/series/ordinalSeries.js +29 -15
- package/dist/app/charts/series/ordinalSeries.js.map +1 -1
- package/dist/app/charts/series/outlierSeries.d.ts +142 -0
- package/dist/app/charts/series/outlierSeries.d.ts.map +1 -0
- package/dist/app/charts/series/outlierSeries.js +82 -0
- package/dist/app/charts/series/outlierSeries.js.map +1 -0
- package/dist/app/charts/series/timeSeries.d.ts +13 -9
- package/dist/app/charts/series/timeSeries.d.ts.map +1 -0
- package/dist/app/charts/series/timeSeries.js +6 -3
- package/dist/app/charts/series/timeSeries.js.map +1 -1
- package/dist/app/charts/series/timeSeriesChartData.d.ts +18 -10
- package/dist/app/charts/series/timeSeriesChartData.d.ts.map +1 -0
- package/dist/app/charts/series/timeSeriesChartData.js +28 -14
- package/dist/app/charts/series/timeSeriesChartData.js.map +1 -1
- package/dist/app/charts/styling/barPlotStyle.d.ts +46 -2
- package/dist/app/charts/styling/barPlotStyle.d.ts.map +1 -0
- package/dist/app/charts/styling/barPlotStyle.js +37 -3
- package/dist/app/charts/styling/barPlotStyle.js.map +1 -1
- package/dist/app/charts/styling/canvasStyle.d.ts +53 -0
- package/dist/app/charts/styling/canvasStyle.d.ts.map +1 -0
- package/dist/app/charts/styling/canvasStyle.js +71 -0
- package/dist/app/charts/styling/canvasStyle.js.map +1 -0
- package/dist/app/charts/styling/margins.d.ts +21 -2
- package/dist/app/charts/styling/margins.d.ts.map +1 -0
- package/dist/app/charts/styling/margins.js +25 -4
- package/dist/app/charts/styling/margins.js.map +1 -1
- package/dist/app/charts/styling/svgStyle.d.ts +10 -56
- package/dist/app/charts/styling/svgStyle.d.ts.map +1 -0
- package/dist/app/charts/styling/svgStyle.js +3 -78
- package/dist/app/charts/styling/svgStyle.js.map +1 -1
- package/dist/app/charts/subscriptions/viewDrivers.d.ts +124 -0
- package/dist/app/charts/subscriptions/viewDrivers.d.ts.map +1 -0
- package/dist/app/charts/subscriptions/viewDrivers.js +338 -0
- package/dist/app/charts/subscriptions/viewDrivers.js.map +1 -0
- package/dist/app/charts/tooltips/BarPlotTooltipContent.d.ts +12 -78
- package/dist/app/charts/tooltips/BarPlotTooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/BarPlotTooltipContent.js +65 -257
- package/dist/app/charts/tooltips/BarPlotTooltipContent.js.map +1 -1
- package/dist/app/charts/tooltips/DefaultOutlierTooltipContent.d.ts +9 -0
- package/dist/app/charts/tooltips/DefaultOutlierTooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/DefaultOutlierTooltipContent.js +16 -0
- package/dist/app/charts/tooltips/DefaultOutlierTooltipContent.js.map +1 -0
- package/dist/app/charts/tooltips/OutlierPlotTooltipContent.d.ts +30 -0
- package/dist/app/charts/tooltips/OutlierPlotTooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/OutlierPlotTooltipContent.js +26 -0
- package/dist/app/charts/tooltips/OutlierPlotTooltipContent.js.map +1 -0
- package/dist/app/charts/tooltips/PoincarePlotTooltipContent.d.ts +22 -72
- package/dist/app/charts/tooltips/PoincarePlotTooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/PoincarePlotTooltipContent.js +104 -171
- package/dist/app/charts/tooltips/PoincarePlotTooltipContent.js.map +1 -1
- package/dist/app/charts/tooltips/RasterPlotTooltipContent.d.ts +32 -8
- package/dist/app/charts/tooltips/RasterPlotTooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/RasterPlotTooltipContent.js +62 -115
- package/dist/app/charts/tooltips/RasterPlotTooltipContent.js.map +1 -1
- package/dist/app/charts/tooltips/ScatterPlotTooltipContent.d.ts +39 -12
- package/dist/app/charts/tooltips/ScatterPlotTooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/ScatterPlotTooltipContent.js +162 -134
- package/dist/app/charts/tooltips/ScatterPlotTooltipContent.js.map +1 -1
- package/dist/app/charts/tooltips/Tooltip.d.ts +27 -32
- package/dist/app/charts/tooltips/Tooltip.d.ts.map +1 -0
- package/dist/app/charts/tooltips/Tooltip.js +37 -81
- package/dist/app/charts/tooltips/Tooltip.js.map +1 -1
- package/dist/app/charts/tooltips/TooltipContent.d.ts +81 -0
- package/dist/app/charts/tooltips/TooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/TooltipContent.js +99 -0
- package/dist/app/charts/tooltips/TooltipContent.js.map +1 -0
- package/dist/app/charts/tooltips/tooltipUtils.d.ts +186 -36
- package/dist/app/charts/tooltips/tooltipUtils.d.ts.map +1 -0
- package/dist/app/charts/tooltips/tooltipUtils.js +277 -48
- package/dist/app/charts/tooltips/tooltipUtils.js.map +1 -1
- package/dist/app/charts/tooltips/useOutlierTooltip.d.ts +59 -0
- package/dist/app/charts/tooltips/useOutlierTooltip.d.ts.map +1 -0
- package/dist/app/charts/tooltips/useOutlierTooltip.js +16 -0
- package/dist/app/charts/tooltips/useOutlierTooltip.js.map +1 -0
- package/dist/app/charts/tooltips/useTooltipPlacement.d.ts +51 -0
- package/dist/app/charts/tooltips/useTooltipPlacement.d.ts.map +1 -0
- package/dist/app/charts/tooltips/useTooltipPlacement.js +52 -0
- package/dist/app/charts/tooltips/useTooltipPlacement.js.map +1 -0
- package/dist/app/charts/tooltips/useTooltipStyle.d.ts +11 -0
- package/dist/app/charts/tooltips/useTooltipStyle.d.ts.map +1 -0
- package/dist/app/charts/tooltips/useTooltipStyle.js +14 -0
- package/dist/app/charts/tooltips/useTooltipStyle.js.map +1 -0
- package/dist/app/charts/trackers/Tracker.d.ts +22 -6
- package/dist/app/charts/trackers/Tracker.d.ts.map +1 -0
- package/dist/app/charts/trackers/Tracker.js +36 -22
- package/dist/app/charts/trackers/Tracker.js.map +1 -1
- package/dist/app/charts/trackers/trackerUtils.d.ts +40 -18
- package/dist/app/charts/trackers/trackerUtils.d.ts.map +1 -0
- package/dist/app/charts/trackers/trackerUtils.js +213 -300
- package/dist/app/charts/trackers/trackerUtils.js.map +1 -1
- package/dist/app/charts/utils.d.ts +72 -33
- package/dist/app/charts/utils.d.ts.map +1 -0
- package/dist/app/charts/utils.js +87 -42
- package/dist/app/charts/utils.js.map +1 -1
- package/dist/index.d.ts +2 -45
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -72
- package/dist/index.js.map +1 -1
- package/package.json +87 -46
- package/src/app/charts/Chart.tsx +132 -168
- package/src/app/charts/axes/AxesState.ts +27 -29
- package/src/app/charts/axes/AxisInterval.ts +57 -32
- package/src/app/charts/axes/BaseAxisRange.ts +47 -27
- package/src/app/charts/axes/ContinuousAxis.tsx +235 -39
- package/src/app/charts/axes/ContinuousAxisRange.ts +29 -11
- package/src/app/charts/axes/EmptyAxis.tsx +52 -17
- package/src/app/charts/axes/OrdinalAxis.tsx +54 -28
- package/src/app/charts/axes/OrdinalAxisRange.ts +96 -16
- package/src/app/charts/axes/autoScale.ts +244 -0
- package/src/app/charts/axes/axes.ts +954 -735
- package/src/app/charts/d3types.ts +42 -13
- package/src/app/charts/datasources/StreamingDataSource.ts +214 -0
- package/src/app/charts/datasources/iteratesDataSource.ts +122 -0
- package/src/app/charts/datasources/ordinalDataSource.ts +205 -0
- package/src/app/charts/datasources/outlierDataSource.ts +90 -0
- package/src/app/charts/datasources/timeSeriesDataSource.ts +133 -0
- package/src/app/charts/filters/regexFilter.ts +45 -5
- package/src/app/charts/hooks/AxesProvider.tsx +301 -0
- package/src/app/charts/hooks/CanvasSurfaceProvider.tsx +117 -0
- package/src/app/charts/hooks/ChartProvider.tsx +79 -0
- package/src/app/charts/hooks/InteractionProvider.tsx +88 -0
- package/src/app/charts/hooks/PlotDimensionsProvider.tsx +109 -0
- package/src/app/charts/hooks/defaultAxesValues.ts +40 -0
- package/src/app/charts/hooks/defaultMouseValues.ts +24 -0
- package/src/app/charts/hooks/defaultPlotDimensions.ts +27 -0
- package/src/app/charts/hooks/defaultTooltipValues.tsx +23 -0
- package/src/app/charts/hooks/defaultUseChartValues.tsx +36 -0
- package/src/app/charts/hooks/useAxes.tsx +60 -228
- package/src/app/charts/hooks/useCanvasSurface.tsx +35 -0
- package/src/app/charts/hooks/useChart.tsx +47 -106
- package/src/app/charts/hooks/useDataSource.tsx +106 -0
- package/src/app/charts/hooks/useHoveredSeries.tsx +33 -0
- package/src/app/charts/hooks/useMouse.tsx +58 -82
- package/src/app/charts/hooks/usePlotDimensions.tsx +25 -89
- package/src/app/charts/hooks/useTooltip.tsx +32 -63
- package/src/app/charts/index.ts +213 -0
- package/src/app/charts/legends/Legend.tsx +198 -479
- package/src/app/charts/legends/constants.ts +37 -0
- package/src/app/charts/observables/iterates.ts +32 -12
- package/src/app/charts/observables/ordinals.ts +141 -67
- package/src/app/charts/observables/outliers.ts +20 -0
- package/src/app/charts/plots/BarPlot.tsx +784 -666
- package/src/app/charts/plots/OutlierPlot.tsx +685 -0
- package/src/app/charts/plots/PoincarePlot.tsx +707 -489
- package/src/app/charts/plots/RasterPlot.tsx +253 -445
- package/src/app/charts/plots/ScatterPlot.tsx +480 -463
- package/src/app/charts/plots/autoScaleYAxes.ts +102 -0
- package/src/app/charts/plots/colorizedLine.ts +185 -0
- package/src/app/charts/plots/constants.ts +16 -0
- package/src/app/charts/plots/hitTesting.ts +198 -0
- package/src/app/charts/plots/plot.ts +138 -44
- package/src/app/charts/plots/useCanvasZoomPan.ts +240 -0
- package/src/app/charts/plots/useStreamingTimeAxes.ts +384 -0
- package/src/app/charts/series/baseSeries.ts +81 -14
- package/src/app/charts/series/iterateSeries.ts +8 -8
- package/src/app/charts/series/ordinalSeries.ts +35 -20
- package/src/app/charts/series/outlierSeries.ts +188 -0
- package/src/app/charts/series/timeSeries.ts +14 -12
- package/src/app/charts/series/timeSeriesChartData.ts +31 -17
- package/src/app/charts/styling/barPlotStyle.ts +48 -5
- package/src/app/charts/styling/canvasStyle.ts +86 -0
- package/src/app/charts/styling/margins.ts +28 -4
- package/src/app/charts/styling/svgStyle.ts +10 -91
- package/src/app/charts/subscriptions/viewDrivers.ts +447 -0
- package/src/app/charts/tooltips/BarPlotTooltipContent.tsx +156 -380
- package/src/app/charts/tooltips/DefaultOutlierTooltipContent.tsx +40 -0
- package/src/app/charts/tooltips/OutlierPlotTooltipContent.tsx +67 -0
- package/src/app/charts/tooltips/PoincarePlotTooltipContent.tsx +229 -292
- package/src/app/charts/tooltips/RasterPlotTooltipContent.tsx +164 -217
- package/src/app/charts/tooltips/ScatterPlotTooltipContent.tsx +373 -236
- package/src/app/charts/tooltips/Tooltip.tsx +58 -124
- package/src/app/charts/tooltips/TooltipContent.tsx +177 -0
- package/src/app/charts/tooltips/tooltipUtils.ts +359 -61
- package/src/app/charts/tooltips/useOutlierTooltip.tsx +68 -0
- package/src/app/charts/tooltips/useTooltipPlacement.ts +86 -0
- package/src/app/charts/tooltips/useTooltipStyle.ts +15 -0
- package/src/app/charts/trackers/Tracker.tsx +68 -33
- package/src/app/charts/trackers/trackerUtils.ts +263 -376
- package/src/app/charts/utils.ts +90 -48
- package/src/index.ts +2 -322
- package/dist/app/charts/axes/AxesState.test.d.ts +0 -1
- package/dist/app/charts/axes/AxesState.test.js +0 -30
- package/dist/app/charts/axes/AxesState.test.js.map +0 -1
- package/dist/app/charts/axes/AxisInterval.test.d.ts +0 -1
- package/dist/app/charts/axes/AxisInterval.test.js +0 -120
- package/dist/app/charts/axes/AxisInterval.test.js.map +0 -1
- package/dist/app/charts/axes/ContinuousAxisRange.test.d.ts +0 -1
- package/dist/app/charts/axes/ContinuousAxisRange.test.js +0 -47
- package/dist/app/charts/axes/ContinuousAxisRange.test.js.map +0 -1
- package/dist/app/charts/axes/OrdinalAxisRange.test.d.ts +0 -1
- package/dist/app/charts/axes/OrdinalAxisRange.test.js +0 -48
- package/dist/app/charts/axes/OrdinalAxisRange.test.js.map +0 -1
- package/dist/app/charts/filters/regexFilter.test.d.ts +0 -1
- package/dist/app/charts/filters/regexFilter.test.js +0 -11
- package/dist/app/charts/filters/regexFilter.test.js.map +0 -1
- package/dist/app/charts/hooks/useDataObservable.d.ts +0 -72
- package/dist/app/charts/hooks/useDataObservable.js +0 -74
- package/dist/app/charts/hooks/useDataObservable.js.map +0 -1
- package/dist/app/charts/hooks/useInitialData.d.ts +0 -36
- package/dist/app/charts/hooks/useInitialData.js +0 -28
- package/dist/app/charts/hooks/useInitialData.js.map +0 -1
- package/dist/app/charts/observables/iterates.test.d.ts +0 -1
- package/dist/app/charts/observables/iterates.test.js +0 -180
- package/dist/app/charts/observables/iterates.test.js.map +0 -1
- package/dist/app/charts/observables/ordinals.test.d.ts +0 -1
- package/dist/app/charts/observables/ordinals.test.js +0 -102
- package/dist/app/charts/observables/ordinals.test.js.map +0 -1
- package/dist/app/charts/series/datumSeries.test.d.ts +0 -1
- package/dist/app/charts/series/datumSeries.test.js +0 -50
- package/dist/app/charts/series/datumSeries.test.js.map +0 -1
- package/dist/app/charts/styling/margins.test.d.ts +0 -1
- package/dist/app/charts/styling/margins.test.js +0 -19
- package/dist/app/charts/styling/margins.test.js.map +0 -1
- package/dist/app/charts/subscriptions/subscription.test.d.ts +0 -1
- package/dist/app/charts/subscriptions/subscription.test.js +0 -395
- package/dist/app/charts/subscriptions/subscription.test.js.map +0 -1
- package/dist/app/charts/subscriptions/subscriptions.d.ts +0 -100
- package/dist/app/charts/subscriptions/subscriptions.js +0 -449
- package/dist/app/charts/subscriptions/subscriptions.js.map +0 -1
- package/src/app/charts/axes/AxesState.test.ts +0 -34
- package/src/app/charts/axes/AxisInterval.test.ts +0 -143
- package/src/app/charts/axes/ContinuousAxisRange.test.ts +0 -55
- package/src/app/charts/axes/OrdinalAxisRange.test.ts +0 -55
- package/src/app/charts/filters/regexFilter.test.ts +0 -13
- package/src/app/charts/hooks/useDataObservable.tsx +0 -170
- package/src/app/charts/hooks/useInitialData.tsx +0 -64
- package/src/app/charts/observables/iterates.test.ts +0 -201
- package/src/app/charts/observables/ordinals.test.ts +0 -135
- package/src/app/charts/series/datumSeries.test.ts +0 -60
- package/src/app/charts/styling/margins.test.ts +0 -22
- package/src/app/charts/subscriptions/subscription.test.ts +0 -499
- package/src/app/charts/subscriptions/subscriptions.ts +0 -635
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// Canvas has no per-shape mouse events (no SVG `.on("mouseover", ...)` equivalent) -- everything is
|
|
2
|
+
// just pixels on a bitmap. So instead of attaching a handler to each `<path>`/`<circle>`, plots
|
|
3
|
+
// register their drawn geometry (in canvas/pixel coordinates) here, and a single `mousemove`
|
|
4
|
+
// listener on the shared canvas element hit-tests the mouse position against that geometry to
|
|
5
|
+
// figure out which series (if any) the mouse is over.
|
|
6
|
+
/**
|
|
7
|
+
* Squared distance from a point to a line segment (avoids a sqrt when just comparing distances).
|
|
8
|
+
* @param px The point's x-coordinate
|
|
9
|
+
* @param py The point's y-coordinate
|
|
10
|
+
* @param x1 The x-coordinate of the segment's start
|
|
11
|
+
* @param y1 The y-coordinate of the segment's start
|
|
12
|
+
* @param x2 The x-coordinate of the segment's end
|
|
13
|
+
* @param y2 The y-coordinate of the segment's end
|
|
14
|
+
* @return The squared distance from the point to the nearest point on the segment
|
|
15
|
+
*/
|
|
16
|
+
function distanceSquaredToSegment(px, py, x1, y1, x2, y2) {
|
|
17
|
+
const dx = x2 - x1;
|
|
18
|
+
const dy = y2 - y1;
|
|
19
|
+
const lengthSquared = dx * dx + dy * dy;
|
|
20
|
+
if (lengthSquared === 0) {
|
|
21
|
+
const ddx = px - x1;
|
|
22
|
+
const ddy = py - y1;
|
|
23
|
+
return ddx * ddx + ddy * ddy;
|
|
24
|
+
}
|
|
25
|
+
// project point onto the segment, clamped to the segment's extent
|
|
26
|
+
let t = ((px - x1) * dx + (py - y1) * dy) / lengthSquared;
|
|
27
|
+
t = Math.max(0, Math.min(1, t));
|
|
28
|
+
const closestX = x1 + t * dx;
|
|
29
|
+
const closestY = y1 + t * dy;
|
|
30
|
+
const ddx = px - closestX;
|
|
31
|
+
const ddy = py - closestY;
|
|
32
|
+
return ddx * ddx + ddy * ddy;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Finds the series (and specific point/segment within it) hit by the given mouse position.
|
|
36
|
+
* Entries are checked in *reverse* insertion order -- i.e. most-recently-added first -- and the
|
|
37
|
+
* first entry with any qualifying match wins, matching normal DOM/SVG hit-testing (the topmost
|
|
38
|
+
* element captures the pointer) rather than picking whichever entry happens to report the smallest
|
|
39
|
+
* geometric distance across all entries.
|
|
40
|
+
*
|
|
41
|
+
* This distinction matters whenever two entries visually overlap: e.g. a bar-chart's value-line
|
|
42
|
+
* segment is drawn on top of (and can extend slightly beyond) its min/max bar's rect. A rect is a
|
|
43
|
+
* containment test -- any point inside it is unambiguously "hit," with no notion of "how close" --
|
|
44
|
+
* so comparing it against a segment's proximity-based distance would let the rect win everywhere
|
|
45
|
+
* the two overlap, even dead-center on the line, since 0 distance beats any nonzero one. Since
|
|
46
|
+
* plots insert geometry in the same order they draw it, checking entries topmost-first resolves
|
|
47
|
+
* this the way it looks on screen: whichever shape is drawn last (visually on top) claims the
|
|
48
|
+
* pointer first, and only falls through to earlier (lower) entries where it doesn't match at all.
|
|
49
|
+
*
|
|
50
|
+
* Within a single entry (e.g. Scatter's many polyline segments, or Raster's many disjoint spikes)
|
|
51
|
+
* the closest qualifying point/segment still wins, since there's no z-order to speak of among
|
|
52
|
+
* pieces of the same drawn shape.
|
|
53
|
+
* @param mouseX The mouse's x-coordinate, in the same canvas coordinate space the geometry was recorded in
|
|
54
|
+
* @param mouseY The mouse's y-coordinate, in the same canvas coordinate space the geometry was recorded in
|
|
55
|
+
* @param geometry A `map(series_name -> SeriesGeometry)` as last drawn, in draw order
|
|
56
|
+
* @return The hit series and matched index, or `undefined` if the mouse isn't over any series
|
|
57
|
+
*/
|
|
58
|
+
export function seriesAt(mouseX, mouseY, geometry) {
|
|
59
|
+
const entries = Array.from(geometry.entries()).reverse();
|
|
60
|
+
for (const [name, { points, asLine, segments, rects, hitRadius }] of entries) {
|
|
61
|
+
const hitRadiusSquared = hitRadius * hitRadius;
|
|
62
|
+
if (rects !== undefined) {
|
|
63
|
+
const index = rects.findIndex(rect => mouseX >= rect.x && mouseX <= rect.x + rect.width &&
|
|
64
|
+
mouseY >= rect.y && mouseY <= rect.y + rect.height);
|
|
65
|
+
if (index >= 0)
|
|
66
|
+
return { name, index };
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (segments !== undefined) {
|
|
70
|
+
let bestIndex = -1;
|
|
71
|
+
let bestDistanceSquared = Infinity;
|
|
72
|
+
segments.forEach(([[x1, y1], [x2, y2]], index) => {
|
|
73
|
+
const distanceSquared = distanceSquaredToSegment(mouseX, mouseY, x1, y1, x2, y2);
|
|
74
|
+
if (distanceSquared <= hitRadiusSquared && distanceSquared < bestDistanceSquared) {
|
|
75
|
+
bestDistanceSquared = distanceSquared;
|
|
76
|
+
bestIndex = index;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
if (bestIndex >= 0)
|
|
80
|
+
return { name, index: bestIndex };
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (points.length === 0)
|
|
84
|
+
continue;
|
|
85
|
+
if (asLine) {
|
|
86
|
+
let bestIndex = -1;
|
|
87
|
+
let bestDistanceSquared = Infinity;
|
|
88
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
89
|
+
const [x1, y1] = points[i];
|
|
90
|
+
const [x2, y2] = points[i + 1];
|
|
91
|
+
const distanceSquared = distanceSquaredToSegment(mouseX, mouseY, x1, y1, x2, y2);
|
|
92
|
+
if (distanceSquared <= hitRadiusSquared && distanceSquared < bestDistanceSquared) {
|
|
93
|
+
bestDistanceSquared = distanceSquared;
|
|
94
|
+
// attribute the hit to whichever endpoint of the segment is nearer
|
|
95
|
+
const toStart = (mouseX - x1) ** 2 + (mouseY - y1) ** 2;
|
|
96
|
+
const toEnd = (mouseX - x2) ** 2 + (mouseY - y2) ** 2;
|
|
97
|
+
bestIndex = toStart <= toEnd ? i : i + 1;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (bestIndex >= 0)
|
|
101
|
+
return { name, index: bestIndex };
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
let bestIndex = -1;
|
|
105
|
+
let bestDistanceSquared = Infinity;
|
|
106
|
+
points.forEach(([x, y], index) => {
|
|
107
|
+
const distanceSquared = (mouseX - x) ** 2 + (mouseY - y) ** 2;
|
|
108
|
+
if (distanceSquared <= hitRadiusSquared && distanceSquared < bestDistanceSquared) {
|
|
109
|
+
bestDistanceSquared = distanceSquared;
|
|
110
|
+
bestIndex = index;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
if (bestIndex >= 0)
|
|
114
|
+
return { name, index: bestIndex };
|
|
115
|
+
}
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Converts a `MouseEvent` (as received by a `canvas.addEventListener('mousemove', ...)` handler)
|
|
120
|
+
* into canvas-local coordinates, accounting for the canvas's on-page position and any CSS scaling
|
|
121
|
+
* between the canvas's backing-store size and its displayed size.
|
|
122
|
+
* @param event The mouse event
|
|
123
|
+
* @param canvas The canvas element the event was dispatched to
|
|
124
|
+
* @return The `[x, y]` position of the event, in the canvas's own CSS-pixel coordinate space
|
|
125
|
+
* (i.e. the same space `ctx` drawing calls use once the devicePixelRatio transform is applied)
|
|
126
|
+
*/
|
|
127
|
+
export function canvasLocalPoint(event, canvas) {
|
|
128
|
+
const rect = canvas.getBoundingClientRect();
|
|
129
|
+
const scaleX = rect.width > 0 ? canvas.clientWidth / rect.width : 1;
|
|
130
|
+
const scaleY = rect.height > 0 ? canvas.clientHeight / rect.height : 1;
|
|
131
|
+
return [
|
|
132
|
+
(event.clientX - rect.left) * scaleX,
|
|
133
|
+
(event.clientY - rect.top) * scaleY
|
|
134
|
+
];
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=hitTesting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hitTesting.js","sourceRoot":"","sources":["../../../../src/app/charts/plots/hitTesting.ts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C,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM;KACtC,CAAA;AACL,CAAC"}
|
|
@@ -1,24 +1,52 @@
|
|
|
1
|
-
import { Dimensions } from "../styling/margins";
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import type { Dimensions } from "../styling/margins";
|
|
2
|
+
import type { CanvasContext } from "../d3types";
|
|
3
|
+
import type { FastShiftArray } from "fast-shift-array";
|
|
4
|
+
import type { BaseAxisRange } from "../axes/BaseAxisRange";
|
|
5
|
+
import type { AxisInterval } from "../axes/AxisInterval";
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
7
|
+
* A series' data: a plain array, or the `FastShiftArray` that backs a {@link BaseSeries}
|
|
8
|
+
*/
|
|
9
|
+
export type Series<D> = Array<D> | FastShiftArray<D>;
|
|
10
|
+
/**
|
|
11
|
+
* Creates the {@link CanvasContext} for the chart -- the drawing context plus the redraw
|
|
12
|
+
* registration/scheduling API that axes, plots, and the tracker use to (re)paint themselves.
|
|
13
|
+
* Replaces the old `createPlotContainer`, which appended the root SVG `<g>`.
|
|
14
|
+
* Each redraw clears the canvas, and then calls every registered draw function in z-index order
|
|
15
|
+
* (lowest first); a draw function that throws is logged and skipped, so it doesn't blank the rest.
|
|
16
|
+
* The canvas isn't sized here: call {@link resizeCanvasTo} immediately after this with the actual
|
|
17
|
+
* container dimensions.
|
|
6
18
|
* @param chartId A unique value identifying the chart.
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* @
|
|
19
|
+
* @param canvas The `<canvas>` DOM element backing the chart.
|
|
20
|
+
* @param color The default `color` used for text/strokes when nothing more specific is set.
|
|
21
|
+
* @return The canvas context
|
|
22
|
+
* @throws Error when the canvas has no 2D rendering context
|
|
23
|
+
*/
|
|
24
|
+
export declare function createCanvasContext(chartId: number, canvas: HTMLCanvasElement, color: string): CanvasContext;
|
|
25
|
+
/**
|
|
26
|
+
* Resizes the canvas's backing store to match `dimensions` at the current devicePixelRatio, so
|
|
27
|
+
* that drawing stays crisp on high-DPI displays, and re-applies the dpr scale to the drawing
|
|
28
|
+
* context so that one drawing-unit equals one CSS pixel. Replaces the old SVG `width`/`height`
|
|
29
|
+
* attribute updates. Call this whenever the container's pixel dimensions change, before the next
|
|
30
|
+
* redraw.
|
|
31
|
+
* @param context The canvas context
|
|
32
|
+
* @param dimensions The new overall (plot + margin) dimensions, in CSS pixels
|
|
10
33
|
*/
|
|
11
|
-
export declare function
|
|
34
|
+
export declare function resizeCanvasTo(context: CanvasContext, dimensions: Dimensions): void;
|
|
12
35
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* this
|
|
16
|
-
*
|
|
17
|
-
* @param
|
|
18
|
-
* @param
|
|
19
|
-
* @
|
|
36
|
+
* Clips subsequent drawing to a rectangular area. Replaces the old SVG `<clipPath>`/
|
|
37
|
+
* `setClipPathG`/`setClipPath`. Canvas clip regions are stack-based: callers must `ctx.save()`
|
|
38
|
+
* before calling this and `ctx.restore()` once the clipped drawing is done, or the clip will leak
|
|
39
|
+
* into unrelated draw calls later in the same frame.
|
|
40
|
+
* @param context The canvas context
|
|
41
|
+
* @param dimensions The dimensions of the area to clip to
|
|
42
|
+
* @param origin The top-left corner of the clip area, in canvas drawing coordinates (defaults to
|
|
43
|
+
* `(0, 0)`; pass the margin's `(left, top)` when clipping to the plot area, which is offset from
|
|
44
|
+
* the canvas origin)
|
|
20
45
|
*/
|
|
21
|
-
export declare function
|
|
46
|
+
export declare function clipToArea(context: CanvasContext, dimensions: Dimensions, origin?: {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
}): void;
|
|
22
50
|
/**
|
|
23
51
|
* Represents the assignment of an x-axis and y-axis to a series. Plots (see, for example,
|
|
24
52
|
* {@link ScatterPlot} and {@link RasterPlot}) use this interface to manage the assignment
|
|
@@ -35,3 +63,11 @@ export interface AxesAssignment {
|
|
|
35
63
|
* @return An {@link AxesAssignment}
|
|
36
64
|
*/
|
|
37
65
|
export declare const assignAxes: (xAxis: string, yAxis: string) => AxesAssignment;
|
|
66
|
+
/**
|
|
67
|
+
* Converts a map holding the axes' ranges into a map holding the axes' current intervals. Used
|
|
68
|
+
* when reporting the axes' bounds to the code using the chart (see the plots' `onUpdateAxesInterval`).
|
|
69
|
+
* @param ranges A map associating an axis ID with that axis' range
|
|
70
|
+
* @return A map associating an axis ID with that axis' current interval
|
|
71
|
+
*/
|
|
72
|
+
export declare function currentIntervalsFrom(ranges: Map<string, BaseAxisRange>): Map<string, AxisInterval>;
|
|
73
|
+
//# sourceMappingURL=plot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plot.d.ts","sourceRoot":"","sources":["../../../../src/app/charts/plots/plot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAC,aAAa,EAAqB,MAAM,YAAY,CAAC;AAClE,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAA;AAQpD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAC/B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,MAAM,GACd,aAAa,CA4Df;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,CAWnF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CACtB,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,UAAU,EACtB,MAAM,GAAE;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAgB,GAC9C,IAAI,CAIN;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CAChB;AAED;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,KAAG,cAAkC,CAAA;AAE5F;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAIlG"}
|
|
@@ -1,44 +1,106 @@
|
|
|
1
|
-
import * as d3 from "d3";
|
|
2
1
|
/**
|
|
3
|
-
* Creates the
|
|
2
|
+
* Creates the {@link CanvasContext} for the chart -- the drawing context plus the redraw
|
|
3
|
+
* registration/scheduling API that axes, plots, and the tracker use to (re)paint themselves.
|
|
4
|
+
* Replaces the old `createPlotContainer`, which appended the root SVG `<g>`.
|
|
5
|
+
* Each redraw clears the canvas, and then calls every registered draw function in z-index order
|
|
6
|
+
* (lowest first); a draw function that throws is logged and skipped, so it doesn't blank the rest.
|
|
7
|
+
* The canvas isn't sized here: call {@link resizeCanvasTo} immediately after this with the actual
|
|
8
|
+
* container dimensions.
|
|
4
9
|
* @param chartId A unique value identifying the chart.
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @
|
|
10
|
+
* @param canvas The `<canvas>` DOM element backing the chart.
|
|
11
|
+
* @param color The default `color` used for text/strokes when nothing more specific is set.
|
|
12
|
+
* @return The canvas context
|
|
13
|
+
* @throws Error when the canvas has no 2D rendering context
|
|
8
14
|
*/
|
|
9
|
-
export function
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
export function createCanvasContext(chartId, canvas, color) {
|
|
16
|
+
const context = canvas.getContext('2d');
|
|
17
|
+
if (!context) {
|
|
18
|
+
throw new Error(`Unable to acquire a 2D rendering context for chart ${chartId}`);
|
|
19
|
+
}
|
|
20
|
+
const dpr = window.devicePixelRatio || 1;
|
|
21
|
+
context.textBaseline = 'alphabetic';
|
|
22
|
+
context.strokeStyle = color;
|
|
23
|
+
context.fillStyle = color;
|
|
24
|
+
const drawFns = new Map();
|
|
25
|
+
let animationFrameId = null;
|
|
26
|
+
const redrawNow = () => {
|
|
27
|
+
animationFrameId = null;
|
|
28
|
+
// clear the full backing-store (not just the CSS-pixel size, since the backing store is
|
|
29
|
+
// scaled by devicePixelRatio and the current transform includes that scale)
|
|
30
|
+
context.save();
|
|
31
|
+
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
32
|
+
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
33
|
+
context.restore();
|
|
34
|
+
Array.from(drawFns.entries())
|
|
35
|
+
.sort(([, a], [, b]) => a.zIndex - b.zIndex)
|
|
36
|
+
.forEach(([id, { draw }]) => {
|
|
37
|
+
try {
|
|
38
|
+
draw(canvasContext);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
// one registrant's draw failure (e.g. a misconfigured axis assignment) must not
|
|
42
|
+
// blank every other plot/axis/tracker sharing this canvas for the frame -- and
|
|
43
|
+
// since this runs on every subsequent data tick too, an uncaught throw here would
|
|
44
|
+
// otherwise wedge the chart's rendering permanently rather than just once
|
|
45
|
+
console.error(`Error while drawing "${id}"; chart_id: ${chartId}`, error);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const canvasContext = {
|
|
50
|
+
chartId,
|
|
51
|
+
canvas,
|
|
52
|
+
context2D: context,
|
|
53
|
+
dpr,
|
|
54
|
+
register: (id, draw, zIndex = 0) => {
|
|
55
|
+
drawFns.set(id, { draw, zIndex });
|
|
56
|
+
canvasContext.requestRedraw();
|
|
57
|
+
},
|
|
58
|
+
unregister: (id) => {
|
|
59
|
+
drawFns.delete(id);
|
|
60
|
+
canvasContext.requestRedraw();
|
|
61
|
+
},
|
|
62
|
+
requestRedraw: () => {
|
|
63
|
+
if (animationFrameId === null) {
|
|
64
|
+
animationFrameId = window.requestAnimationFrame(redrawNow);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
return canvasContext;
|
|
17
69
|
}
|
|
18
70
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @param
|
|
25
|
-
* @
|
|
71
|
+
* Resizes the canvas's backing store to match `dimensions` at the current devicePixelRatio, so
|
|
72
|
+
* that drawing stays crisp on high-DPI displays, and re-applies the dpr scale to the drawing
|
|
73
|
+
* context so that one drawing-unit equals one CSS pixel. Replaces the old SVG `width`/`height`
|
|
74
|
+
* attribute updates. Call this whenever the container's pixel dimensions change, before the next
|
|
75
|
+
* redraw.
|
|
76
|
+
* @param context The canvas context
|
|
77
|
+
* @param dimensions The new overall (plot + margin) dimensions, in CSS pixels
|
|
26
78
|
*/
|
|
27
|
-
export function
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
79
|
+
export function resizeCanvasTo(context, dimensions) {
|
|
80
|
+
const { canvas, context2D, dpr } = context;
|
|
81
|
+
const width = Math.max(0, dimensions.width);
|
|
82
|
+
const height = Math.max(0, dimensions.height);
|
|
83
|
+
canvas.style.width = `${width}px`;
|
|
84
|
+
canvas.style.height = `${height}px`;
|
|
85
|
+
canvas.width = Math.round(width * dpr);
|
|
86
|
+
canvas.height = Math.round(height * dpr);
|
|
87
|
+
context2D.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Clips subsequent drawing to a rectangular area. Replaces the old SVG `<clipPath>`/
|
|
91
|
+
* `setClipPathG`/`setClipPath`. Canvas clip regions are stack-based: callers must `ctx.save()`
|
|
92
|
+
* before calling this and `ctx.restore()` once the clipped drawing is done, or the clip will leak
|
|
93
|
+
* into unrelated draw calls later in the same frame.
|
|
94
|
+
* @param context The canvas context
|
|
95
|
+
* @param dimensions The dimensions of the area to clip to
|
|
96
|
+
* @param origin The top-left corner of the clip area, in canvas drawing coordinates (defaults to
|
|
97
|
+
* `(0, 0)`; pass the margin's `(left, top)` when clipping to the plot area, which is offset from
|
|
98
|
+
* the canvas origin)
|
|
99
|
+
*/
|
|
100
|
+
export function clipToArea(context, dimensions, origin = { x: 0, y: 0 }) {
|
|
101
|
+
context.context2D.beginPath();
|
|
102
|
+
context.context2D.rect(origin.x, origin.y, Math.max(0, dimensions.width), Math.max(0, dimensions.height));
|
|
103
|
+
context.context2D.clip();
|
|
42
104
|
}
|
|
43
105
|
/**
|
|
44
106
|
* Factory function for the assignment of axes to series
|
|
@@ -47,4 +109,15 @@ export function setClipPathG(chartId, plotGroup, plotDimensions) {
|
|
|
47
109
|
* @return An {@link AxesAssignment}
|
|
48
110
|
*/
|
|
49
111
|
export const assignAxes = (xAxis, yAxis) => ({ xAxis, yAxis });
|
|
112
|
+
/**
|
|
113
|
+
* Converts a map holding the axes' ranges into a map holding the axes' current intervals. Used
|
|
114
|
+
* when reporting the axes' bounds to the code using the chart (see the plots' `onUpdateAxesInterval`).
|
|
115
|
+
* @param ranges A map associating an axis ID with that axis' range
|
|
116
|
+
* @return A map associating an axis ID with that axis' current interval
|
|
117
|
+
*/
|
|
118
|
+
export function currentIntervalsFrom(ranges) {
|
|
119
|
+
const intervals = new Map();
|
|
120
|
+
ranges.forEach((range, axisId) => intervals.set(axisId, range.current));
|
|
121
|
+
return intervals;
|
|
122
|
+
}
|
|
50
123
|
//# sourceMappingURL=plot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plot.js","sourceRoot":"","sources":["../../../../src/app/charts/plots/plot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plot.js","sourceRoot":"","sources":["../../../../src/app/charts/plots/plot.ts"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,mBAAmB,CAC/B,OAAe,EACf,MAAyB,EACzB,KAAa;IAEb,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACvC,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,sDAAsD,OAAO,EAAE,CAAC,CAAA;IACpF,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,CAAC,gBAAgB,IAAI,CAAC,CAAA;IACxC,OAAO,CAAC,YAAY,GAAG,YAAY,CAAA;IACnC,OAAO,CAAC,WAAW,GAAG,KAAK,CAAA;IAC3B,OAAO,CAAC,SAAS,GAAG,KAAK,CAAA;IAEzB,MAAM,OAAO,GAAG,IAAI,GAAG,EAA8B,CAAA;IACrD,IAAI,gBAAgB,GAAkB,IAAI,CAAA;IAE1C,MAAM,SAAS,GAAG,GAAS,EAAE;QACzB,gBAAgB,GAAG,IAAI,CAAA;QAEvB,wFAAwF;QACxF,4EAA4E;QAC5E,OAAO,CAAC,IAAI,EAAE,CAAA;QACd,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;QACtC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;QACpD,OAAO,CAAC,OAAO,EAAE,CAAA;QAEjB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;aACxB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CA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AC,CAAC,CAAA;AAE5F;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAkC;IACnE,MAAM,SAAS,GAAG,IAAI,GAAG,EAAwB,CAAA;IACjD,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;IACvE,OAAO,SAAS,CAAA;AACpB,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { CanvasContext } from "../d3types";
|
|
2
|
+
/**
|
|
3
|
+
* A zoom gesture's step, as the plot's zoom handler gets it
|
|
4
|
+
*/
|
|
5
|
+
export interface ZoomStep {
|
|
6
|
+
/**
|
|
7
|
+
* The zoom factor of this step alone, relative to the previous step (d3-zoom's own scale is
|
|
8
|
+
* cumulative; the zoom math in `axes.ts` is incremental -- see `ContinuousAxisRange.scale`)
|
|
9
|
+
*/
|
|
10
|
+
factor: number;
|
|
11
|
+
/**
|
|
12
|
+
* d3-zoom's cumulative scale (e.g. for ordinal axes, whose zoom snaps back to the original
|
|
13
|
+
* range exactly at 1 -- see `OrdinalAxisRange.scale`)
|
|
14
|
+
*/
|
|
15
|
+
k: number;
|
|
16
|
+
/**
|
|
17
|
+
* Where the mouse is, relative to the canvas
|
|
18
|
+
*/
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The options for {@link useCanvasZoomPan}
|
|
24
|
+
*/
|
|
25
|
+
export interface CanvasZoomPanOptions {
|
|
26
|
+
/**
|
|
27
|
+
* Whether dragging pans the plot
|
|
28
|
+
*/
|
|
29
|
+
panEnabled: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the mouse wheel zooms the plot
|
|
32
|
+
*/
|
|
33
|
+
zoomEnabled: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether zooming requires the shift (or ctrl) key to be held down
|
|
36
|
+
*/
|
|
37
|
+
keyModifiersRequired: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The smallest and largest (cumulative) zoom scales
|
|
40
|
+
*/
|
|
41
|
+
scaleExtent: [min: number, max: number];
|
|
42
|
+
/**
|
|
43
|
+
* Whether the wheel changes d3-zoom's scale the opposite way to d3-zoom's default, so that all
|
|
44
|
+
* the plots zoom the same way for the same gesture. Plots differ in which way their axes move
|
|
45
|
+
* with the scale: a continuous axis's range *widens* as the scale goes up (an incremental factor
|
|
46
|
+
* above 1 grows it), while an ordinal axis's (pixel) range widens its bands as the scale goes
|
|
47
|
+
* up. So the continuous-axis plots use d3-zoom's default, and the bar plot (with its ordinal
|
|
48
|
+
* axis) inverts the wheel to match them. Defaults to `false`.
|
|
49
|
+
*/
|
|
50
|
+
invertWheel?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* The plot's margin and dimensions, which bound the zoom's translation
|
|
53
|
+
*/
|
|
54
|
+
translateExtent: [[left: number, top: number], [right: number, bottom: number]];
|
|
55
|
+
/**
|
|
56
|
+
* Called when a pan (drag) starts (e.g. to suppress tooltips while panning)
|
|
57
|
+
*/
|
|
58
|
+
onPanStart?: () => void;
|
|
59
|
+
/**
|
|
60
|
+
* Called for each step of a pan
|
|
61
|
+
* @param dx The horizontal distance (px) moved since the previous step
|
|
62
|
+
* @param dy The vertical distance (px) moved since the previous step
|
|
63
|
+
*/
|
|
64
|
+
onPan: (dx: number, dy: number) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Called when a pan ends
|
|
67
|
+
*/
|
|
68
|
+
onPanEnd?: () => void;
|
|
69
|
+
/**
|
|
70
|
+
* Called for each step of a zoom gesture (a real one: programmatic changes to d3-zoom's
|
|
71
|
+
* transform, e.g. a reset, aren't reported)
|
|
72
|
+
* @param step The step's zoom factor, d3-zoom's cumulative scale, and the mouse position
|
|
73
|
+
*/
|
|
74
|
+
onZoom: (step: ZoomStep) => void;
|
|
75
|
+
/**
|
|
76
|
+
* The plot's `onZoomReset` property: called (whenever zooming is set up) with a function that
|
|
77
|
+
* resets the zoom -- d3-zoom's own transform, and then the plot's view (see `resetView`)
|
|
78
|
+
*/
|
|
79
|
+
onZoomReset?: (resetZoom: () => void) => void;
|
|
80
|
+
/**
|
|
81
|
+
* Restores the plot's view (its axes' original ranges) when the zoom is reset (see `onZoomReset`)
|
|
82
|
+
*/
|
|
83
|
+
resetView?: () => void;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The zoom controls a plot gets back from {@link useCanvasZoomPan}
|
|
87
|
+
*/
|
|
88
|
+
export interface CanvasZoomPanControls {
|
|
89
|
+
/**
|
|
90
|
+
* Resets d3-zoom's own (cumulative) transform to identity, e.g. when the plot's axes are reset
|
|
91
|
+
* to their original ranges -- otherwise the next zoom gesture would continue from the stale,
|
|
92
|
+
* accumulated scale
|
|
93
|
+
*/
|
|
94
|
+
resetZoomTransform: () => void;
|
|
95
|
+
/**
|
|
96
|
+
* Sets d3-zoom's own (cumulative) scale, e.g. when restoring a saved zoom state. Sets it
|
|
97
|
+
* directly (where d3-zoom keeps it), without dispatching a "zoom" event.
|
|
98
|
+
* @param k The scale
|
|
99
|
+
*/
|
|
100
|
+
setZoomScale: (k: number) => void;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Sets up panning (dragging) and zooming (the mouse wheel) on a plot's canvas, with d3's drag and
|
|
104
|
+
* zoom behaviors, and detaches them when the plot unmounts (or the canvas, or the settings they
|
|
105
|
+
* depend on, change).
|
|
106
|
+
*
|
|
107
|
+
* - Zooming only responds to wheel events (and, when required, only with the shift or ctrl key
|
|
108
|
+
* down): d3-zoom also handles mouse drags on its own, which would otherwise fire zoom events for
|
|
109
|
+
* the same gesture the dedicated drag behavior pans with.
|
|
110
|
+
* - d3-zoom's scale is cumulative; each zoom step is also handed to the plot as an incremental
|
|
111
|
+
* factor (relative to the previous step), which is reset whenever d3-zoom's transform is.
|
|
112
|
+
* - The handlers are always the plot's latest ones, so the behaviors needn't be re-attached when
|
|
113
|
+
* the handlers change.
|
|
114
|
+
* @param canvasContext The plot's canvas context (`null` until the canvas exists)
|
|
115
|
+
* @param options Whether panning and zooming are enabled, their extents, and the handlers
|
|
116
|
+
* @return The controls for d3-zoom's own transform (reset it, or set its scale)
|
|
117
|
+
*/
|
|
118
|
+
export declare function useCanvasZoomPan(canvasContext: CanvasContext | null, options: CanvasZoomPanOptions): CanvasZoomPanControls;
|
|
119
|
+
//# sourceMappingURL=useCanvasZoomPan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCanvasZoomPan.d.ts","sourceRoot":"","sources":["../../../../src/app/charts/plots/useCanvasZoomPan.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,QAAQ;IACrB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,CAAC,EAAE,MAAM,CAAA;IACT;;OAEG;IACH,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC;;OAEG;IACH,UAAU,EAAE,OAAO,CAAA;IACnB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,oBAAoB,EAAE,OAAO,CAAA;IAC7B;;OAEG;IACH,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAA;IACvC;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;OAEG;IACH,eAAe,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAC/E;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,IAAI,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