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
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
addContinuousNumericYAxis,
|
|
4
|
-
AxesFont,
|
|
2
|
+
type AxesFont,
|
|
5
3
|
AxisLocation,
|
|
6
|
-
ContinuousNumericAxis,
|
|
7
4
|
defaultAxesFont,
|
|
8
|
-
|
|
5
|
+
type SeriesStyle,
|
|
6
|
+
addContinuousNumericXAxis,
|
|
7
|
+
addContinuousNumericYAxis,
|
|
8
|
+
removeContinuousXAxis,
|
|
9
|
+
removeContinuousYAxis,
|
|
10
|
+
type ContinuousNumericAxis
|
|
9
11
|
} from "./axes";
|
|
10
12
|
import {useChart} from "../hooks/useChart";
|
|
11
13
|
import {useEffect, useRef} from "react";
|
|
12
14
|
import * as d3 from "d3";
|
|
13
|
-
import {ScaleContinuousNumeric} from "d3";
|
|
14
|
-
import {Dimensions, Margin} from "../styling/margins";
|
|
15
|
+
import type {ScaleContinuousNumeric} from "d3";
|
|
16
|
+
import type {Dimensions, Margin} from "../styling/margins";
|
|
15
17
|
import {usePlotDimensions} from "../hooks/usePlotDimensions";
|
|
16
|
-
import {Datum} from "../series/timeSeries";
|
|
18
|
+
import type {Datum} from "../series/timeSeries";
|
|
17
19
|
import {AxisInterval} from "./AxisInterval";
|
|
18
20
|
import {ContinuousAxisRange} from "./ContinuousAxisRange";
|
|
21
|
+
import {type AutoScale, clampedDomain, sameAutoScale, warnOnce} from "./autoScale";
|
|
19
22
|
|
|
20
23
|
export interface Props {
|
|
21
24
|
// the unique ID of the axis
|
|
@@ -42,28 +45,69 @@ export interface Props {
|
|
|
42
45
|
// of the raster chart specifies the axis domain as a tuple-literal, then
|
|
43
46
|
// the bounds will get reset to their original value with each render.
|
|
44
47
|
//
|
|
45
|
-
//
|
|
46
|
-
// the
|
|
47
|
-
//
|
|
48
|
-
//
|
|
48
|
+
// For charts that don't scroll, such as the "iterates" chart, we would like
|
|
49
|
+
// the axis bounds to be reset based on a change to the object ref instead.
|
|
50
|
+
// This is because the user may want to change axis-bounds, for example, when
|
|
51
|
+
// for a different "iterates" function is selected. And in such a case, we set
|
|
52
|
+
// this property to false.
|
|
49
53
|
updateAxisBasedOnDomainValues?: boolean
|
|
54
|
+
/**
|
|
55
|
+
* When `true`, the axis' domain grows to fit the data plotted against it: when the data on
|
|
56
|
+
* screen goes above (or below) the domain, the domain grows to include it (plus the
|
|
57
|
+
* `autoScalePadding`), but never past `autoScaleMax` (or `autoScaleMin`). The axis starts out
|
|
58
|
+
* at the `domain` prop, clamped to those limits. The domain only ever grows -- it's restored
|
|
59
|
+
* to its start when the plot's data is replaced (e.g. on a reset), or when the `domain` prop
|
|
60
|
+
* or the limits change. When `false` (the default), the domain is exactly the `domain` prop.
|
|
61
|
+
*
|
|
62
|
+
* For y-axes only (an x-axis' domain follows time, and its zooming and panning), in the plots
|
|
63
|
+
* that support it (the scatter, bar, and outlier plots). Elsewhere, it's ignored, with a warning.
|
|
64
|
+
*/
|
|
65
|
+
autoScale?: boolean
|
|
66
|
+
/**
|
|
67
|
+
* The smallest value an auto-scaling axis' domain may reach. Defaults to `-Infinity` (no
|
|
68
|
+
* limit).
|
|
69
|
+
*/
|
|
70
|
+
autoScaleMin?: number
|
|
71
|
+
/**
|
|
72
|
+
* The largest value an auto-scaling axis' domain may reach. Defaults to `Infinity` (no limit).
|
|
73
|
+
*/
|
|
74
|
+
autoScaleMax?: number
|
|
75
|
+
/**
|
|
76
|
+
* The fraction of the axis' length left beyond the data's extreme when the axis grows, so the
|
|
77
|
+
* extreme point isn't drawn right on the edge (in the scale's own space, e.g. logarithmically
|
|
78
|
+
* for a log scale). From 0 to 0.45 (a larger value is treated as 0.45); defaults to 0.05.
|
|
79
|
+
*/
|
|
80
|
+
autoScalePadding?: number
|
|
81
|
+
/**
|
|
82
|
+
* The auto-scaled domain to start from when auto-scaling starts (e.g. when the axis is
|
|
83
|
+
* created), instead of the `domain` prop -- for keeping the axis' growth across remounts (e.g.
|
|
84
|
+
* navigating away from the chart and back), along with `onAutoScale`. Clamped to the limits.
|
|
85
|
+
*/
|
|
86
|
+
autoScaledDomain?: [min: number, max: number]
|
|
87
|
+
/**
|
|
88
|
+
* Called with the axis' new domain whenever an auto-scaling axis grows, or is restored to its
|
|
89
|
+
* start (e.g. on a reset), so that it can be kept (see `autoScaledDomain`)
|
|
90
|
+
* @param domain The axis' new domain
|
|
91
|
+
*/
|
|
92
|
+
onAutoScale?: (domain: [min: number, max: number]) => void
|
|
50
93
|
}
|
|
51
94
|
|
|
52
95
|
/**
|
|
53
|
-
* Represents a continuous numeric axis (x or y) that can be
|
|
96
|
+
* Represents a continuous numeric axis (x or y) that can be placed on the top, bottom,
|
|
54
97
|
* left, or right of the chart. The domain (axis range) can be managed by this axis
|
|
55
|
-
*
|
|
56
|
-
* React won't render it because we are
|
|
57
|
-
* involved, except to call this function if the props change.
|
|
98
|
+
* component or managed externally (i.e. deferred). This component returns null, meaning
|
|
99
|
+
* React won't render it because we are drawing directly onto the chart's shared canvas and
|
|
100
|
+
* don't want React involved, except to call this function if the props change.
|
|
58
101
|
* @param props The properties for the axis
|
|
102
|
+
* @return `null` (the axis draws onto the chart's canvas)
|
|
59
103
|
*/
|
|
60
104
|
export function ContinuousAxis(props: Props): null {
|
|
61
105
|
const {
|
|
62
106
|
chartId,
|
|
63
|
-
|
|
107
|
+
canvasContext,
|
|
64
108
|
axes,
|
|
65
109
|
color
|
|
66
|
-
} = useChart<Datum,
|
|
110
|
+
} = useChart<Datum, SeriesStyle, unknown, ContinuousAxisRange, ContinuousNumericAxis>()
|
|
67
111
|
|
|
68
112
|
const {
|
|
69
113
|
xAxesState,
|
|
@@ -72,8 +116,9 @@ export function ContinuousAxis(props: Props): null {
|
|
|
72
116
|
addYAxis,
|
|
73
117
|
axisRangeFor,
|
|
74
118
|
setAxisIntervalFor,
|
|
75
|
-
|
|
119
|
+
updateAxisRanges,
|
|
76
120
|
addAxesRangesUpdateHandler,
|
|
121
|
+
removeAxesRangesUpdateHandler,
|
|
77
122
|
} = axes
|
|
78
123
|
|
|
79
124
|
const {
|
|
@@ -88,14 +133,36 @@ export function ContinuousAxis(props: Props): null {
|
|
|
88
133
|
domain,
|
|
89
134
|
updateAxisBasedOnDomainValues = true,
|
|
90
135
|
label,
|
|
136
|
+
autoScale = false,
|
|
137
|
+
autoScaleMin = -Infinity,
|
|
138
|
+
autoScaleMax = Infinity,
|
|
139
|
+
autoScalePadding = 0.05,
|
|
140
|
+
autoScaledDomain,
|
|
141
|
+
onAutoScale,
|
|
91
142
|
} = props
|
|
92
143
|
|
|
144
|
+
// the latest callback for the auto-scaling axis' domain changes (the range-update handler that
|
|
145
|
+
// reports them is registered once, when the axis is created)
|
|
146
|
+
const onAutoScaleRef = useRef(onAutoScale)
|
|
147
|
+
useEffect(
|
|
148
|
+
() => {
|
|
149
|
+
onAutoScaleRef.current = onAutoScale
|
|
150
|
+
},
|
|
151
|
+
[onAutoScale]
|
|
152
|
+
)
|
|
153
|
+
|
|
93
154
|
const axisRef = useRef<ContinuousNumericAxis>(undefined)
|
|
94
155
|
const rangeUpdateHandlerIdRef = useRef<string>(undefined)
|
|
156
|
+
// the axisId this axis was actually created under, so the main effect below can tell "axisId
|
|
157
|
+
// changed since I last ran" apart from "first run" -- see its use for why this matters
|
|
158
|
+
const createdAxisIdRef = useRef<string | undefined>(undefined)
|
|
95
159
|
|
|
96
160
|
const axisIdRef = useRef<string>(axisId)
|
|
97
161
|
const marginRef = useRef<Margin>(margin)
|
|
162
|
+
// holds on the domain from the original props so that we can determine whether the props changed
|
|
163
|
+
// or whether the axis changes from resizing, zoom, scrolling, etc
|
|
98
164
|
const domainRef = useRef<AxisInterval>(AxisInterval.as(domain))
|
|
165
|
+
const domainPropRef = useRef<[min: number, max: number]>(domain)
|
|
99
166
|
useEffect(
|
|
100
167
|
() => {
|
|
101
168
|
axisIdRef.current = axisId
|
|
@@ -106,31 +173,73 @@ export function ContinuousAxis(props: Props): null {
|
|
|
106
173
|
|
|
107
174
|
useEffect(
|
|
108
175
|
() => {
|
|
109
|
-
if (
|
|
110
|
-
|
|
176
|
+
if (canvasContext) {
|
|
177
|
+
// a changed axisId prop means axisRef.current (and its range-update handler) were
|
|
178
|
+
// created under the OLD id -- the separate unmount-cleanup effect below (also keyed
|
|
179
|
+
// on axisId) already unregistered the OLD id's canvas draw handle by the time this
|
|
180
|
+
// runs (React fires that cleanup, closing over the previous axisId, before this
|
|
181
|
+
// effect re-runs). Without resetting axisRef.current here too, the `else` branch
|
|
182
|
+
// below would run instead of re-creating the axis, silently leaving it undrawn
|
|
183
|
+
// under the new id forever -- this mount-once guard otherwise never resets on its
|
|
184
|
+
// own.
|
|
185
|
+
if (createdAxisIdRef.current !== undefined && createdAxisIdRef.current !== axisId) {
|
|
186
|
+
if (rangeUpdateHandlerIdRef.current) {
|
|
187
|
+
removeAxesRangesUpdateHandler(rangeUpdateHandlerIdRef.current)
|
|
188
|
+
rangeUpdateHandlerIdRef.current = undefined
|
|
189
|
+
}
|
|
190
|
+
axisRef.current = undefined
|
|
191
|
+
}
|
|
192
|
+
|
|
111
193
|
const font: AxesFont = {...defaultAxesFont(), color, ...props.font}
|
|
112
194
|
|
|
195
|
+
// the auto-scaling settings, which the plot applies (y-axes only: an x-axis' domain
|
|
196
|
+
// follows time, and its zooming and panning)
|
|
197
|
+
const isYAxis = location === AxisLocation.Left || location === AxisLocation.Right
|
|
198
|
+
if (autoScale && !isYAxis) {
|
|
199
|
+
warnOnce(`Auto-scaling is for y-axes only, so the "autoScale" setting of x-axis "${axisId}" is ignored`)
|
|
200
|
+
}
|
|
201
|
+
const propDomain = AxisInterval.as(domain).asTuple()
|
|
202
|
+
const settings: AutoScale | undefined = autoScale && isYAxis ?
|
|
203
|
+
{
|
|
204
|
+
domain: clampedDomain(propDomain, autoScaleMin, autoScaleMax),
|
|
205
|
+
min: autoScaleMin,
|
|
206
|
+
max: autoScaleMax,
|
|
207
|
+
padding: autoScalePadding
|
|
208
|
+
} :
|
|
209
|
+
undefined
|
|
210
|
+
if (settings !== undefined && settings.domain[0] === settings.domain[1] && propDomain[0] !== propDomain[1]) {
|
|
211
|
+
warnOnce(`The domain of y-axis "${axisId}" lies outside its auto-scaling limits, so it collapses onto a limit`)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// the settings the axis had (none, when it's about to be created)
|
|
215
|
+
const previous = axisRef.current?.autoScale
|
|
216
|
+
|
|
113
217
|
const handleRangeUpdates = (updates: Map<string, ContinuousAxisRange>, plotDim: Dimensions): void => {
|
|
114
218
|
if (rangeUpdateHandlerIdRef.current && axisRef.current) {
|
|
115
219
|
const range = updates.get(axisId)
|
|
116
220
|
if (range) {
|
|
117
221
|
axisRef.current.update(range.current, plotDim, marginRef.current)
|
|
222
|
+
// an auto-scaling axis' domain changes (growth, or a restore) come
|
|
223
|
+
// through here, so report them
|
|
224
|
+
if (axisRef.current.autoScale !== undefined) {
|
|
225
|
+
onAutoScaleRef.current?.(range.current.asTuple())
|
|
226
|
+
}
|
|
118
227
|
}
|
|
119
228
|
}
|
|
120
229
|
}
|
|
121
230
|
|
|
122
231
|
if (axisRef.current === undefined) {
|
|
232
|
+
createdAxisIdRef.current = axisId
|
|
123
233
|
switch (location) {
|
|
124
234
|
case AxisLocation.Bottom:
|
|
125
235
|
case AxisLocation.Top: {
|
|
126
236
|
axisRef.current = addContinuousNumericXAxis(
|
|
127
|
-
|
|
237
|
+
canvasContext, axisId, plotDimensions, location, scale, domain,
|
|
128
238
|
font, margin, label, setAxisIntervalFor
|
|
129
239
|
)
|
|
130
240
|
// add the x-axis to the chart context
|
|
131
241
|
const [start, end] = AxisInterval.as(domain).asTuple()
|
|
132
242
|
addXAxis(axisRef.current, axisId, ContinuousAxisRange.from(start, end))
|
|
133
|
-
// addXAxis(axisRef.current, axisId, AxisInterval.as(domain))
|
|
134
243
|
|
|
135
244
|
// add an update handler
|
|
136
245
|
rangeUpdateHandlerIdRef.current = `x-axis-${chartId}-${axisId}-${location.valueOf()}`
|
|
@@ -142,13 +251,12 @@ export function ContinuousAxis(props: Props): null {
|
|
|
142
251
|
case AxisLocation.Left:
|
|
143
252
|
case AxisLocation.Right: {
|
|
144
253
|
axisRef.current = addContinuousNumericYAxis(
|
|
145
|
-
|
|
254
|
+
canvasContext, axisId, plotDimensions, location, scale, domain,
|
|
146
255
|
font, margin, label, setAxisIntervalFor
|
|
147
256
|
)
|
|
148
257
|
// add the y-axis to the chart context
|
|
149
258
|
const [start, end] = AxisInterval.as(domain).asTuple()
|
|
150
259
|
addYAxis(axisRef.current, axisId, ContinuousAxisRange.from(start, end))
|
|
151
|
-
// addYAxis(axisRef.current, axisId, AxisInterval.as(domain))
|
|
152
260
|
|
|
153
261
|
// add an update handler
|
|
154
262
|
rangeUpdateHandlerIdRef.current = `y-axis-${chartId}-${axisId}-${location.valueOf()}`
|
|
@@ -156,36 +264,124 @@ export function ContinuousAxis(props: Props): null {
|
|
|
156
264
|
}
|
|
157
265
|
}
|
|
158
266
|
} else {
|
|
159
|
-
|
|
160
|
-
|
|
267
|
+
// apply the new auto-scaling settings before any domain update below, so that,
|
|
268
|
+
// for example, a `domain` change that comes with turning auto-scaling off isn't
|
|
269
|
+
// reported (through `onAutoScale`) as an auto-scaled domain
|
|
270
|
+
axisRef.current.autoScale = settings
|
|
271
|
+
|
|
272
|
+
// calculate the current domain for the axis based on the current interval (range)
|
|
273
|
+
const currentDomain = axisRangeFor(axisId)
|
|
161
274
|
.map(range => range.current)
|
|
162
275
|
.getOrElse(AxisInterval.empty())
|
|
163
|
-
if (domain.isNotEmpty()) {
|
|
164
|
-
axisRef.current.update(domain, plotDimensions, margin)
|
|
165
|
-
}
|
|
166
276
|
|
|
277
|
+
// convert the domain from the props to an axis interval for easier comparison
|
|
278
|
+
const propDomain = AxisInterval.as(domain)
|
|
279
|
+
|
|
280
|
+
// select whether to update based on whether we have specified that we update the axis
|
|
281
|
+
// range when the domain from the props changes. If the conditions of the first if
|
|
282
|
+
// statement are met, then we do a full update of the axis (we update the current, original
|
|
283
|
+
// range and make the callback that the range has changed with the updated range map)
|
|
167
284
|
if (
|
|
168
|
-
|
|
169
|
-
(
|
|
285
|
+
// update axis when the domain from the props has changed
|
|
286
|
+
(updateAxisBasedOnDomainValues && !domainRef.current.equals(propDomain)) ||
|
|
287
|
+
// or when the axis range has actually changed, but we don't update from props
|
|
288
|
+
(!updateAxisBasedOnDomainValues && domainPropRef.current !== domain)
|
|
170
289
|
) {
|
|
171
|
-
domainRef.current =
|
|
172
|
-
|
|
173
|
-
|
|
290
|
+
domainRef.current = propDomain
|
|
291
|
+
domainPropRef.current = domain
|
|
292
|
+
// preserve any existing `.original` tracking (e.g. from an in-progress
|
|
293
|
+
// zoom) rather than collapsing it to match this new current. A domain-prop
|
|
294
|
+
// change here reflects the chart's OWN state being round-tripped back in
|
|
295
|
+
// (e.g. a zoom/auto-scroll notifying `onUpdateAxesBounds`, which a caller
|
|
296
|
+
// wrote into a store that feeds this same `domain` prop) at least as often
|
|
297
|
+
// as it reflects a genuine external reset -- and there's no way to tell
|
|
298
|
+
// those apart from here. Zoom math is now incremental (see
|
|
299
|
+
// `ContinuousAxisRange.scaledRange`), so preserving `.original` isn't
|
|
300
|
+
// required for zoom correctness anymore, but it's still the more accurate
|
|
301
|
+
// value to carry forward on an ordinary round-trip. A genuine external reset
|
|
302
|
+
// (e.g. the Reset button) already restores the whole axis explicitly
|
|
303
|
+
// elsewhere, so this doesn't need to special-case it too.
|
|
304
|
+
const updatedRange = axisRangeFor(axisId)
|
|
305
|
+
.map(range => range.update(propDomain.start, propDomain.end) as ContinuousAxisRange)
|
|
306
|
+
.getOrElse(ContinuousAxisRange.from(propDomain.start, propDomain.end))
|
|
307
|
+
updateAxisRanges(new Map([[axisId, updatedRange]]))
|
|
308
|
+
}
|
|
309
|
+
// otherwise, if the domain exists, update the current axis
|
|
310
|
+
else if (currentDomain.isNotEmpty()) {
|
|
311
|
+
axisRef.current.update(currentDomain, plotDimensions, margin)
|
|
174
312
|
}
|
|
175
313
|
|
|
176
|
-
|
|
314
|
+
// keep the label/tick color in sync with the chart's color (e.g. on theme change),
|
|
315
|
+
// without recreating the axis or touching its domain
|
|
316
|
+
axisRef.current.updateFont(font)
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// when the settings change, the axis (re)starts: from the kept auto-scaled domain
|
|
320
|
+
// (if any) when auto-scaling starts, otherwise from its start; and from its own
|
|
321
|
+
// domain when auto-scaling stops
|
|
322
|
+
axisRef.current.autoScale = settings
|
|
323
|
+
if (!sameAutoScale(previous, settings)) {
|
|
324
|
+
const [start, end] = settings === undefined ?
|
|
325
|
+
propDomain :
|
|
326
|
+
previous === undefined && autoScaledDomain !== undefined ?
|
|
327
|
+
clampedDomain(AxisInterval.as(autoScaledDomain).asTuple(), settings.min, settings.max) :
|
|
328
|
+
settings.domain
|
|
329
|
+
updateAxisRanges(new Map([[axisId, axisRangeFor(axisId)
|
|
330
|
+
.map(range => range.update(start, end) as ContinuousAxisRange)
|
|
331
|
+
.getOrElse(ContinuousAxisRange.from(start, end))
|
|
332
|
+
]]))
|
|
177
333
|
}
|
|
178
334
|
}
|
|
179
335
|
},
|
|
180
336
|
[
|
|
181
337
|
chartId, axisId, label, location, props.font, xAxesState, yAxesState, addXAxis, addYAxis, domain,
|
|
182
|
-
scale,
|
|
338
|
+
scale, canvasContext, margin, plotDimensions, setAxisIntervalFor,
|
|
183
339
|
axisRangeFor,
|
|
184
340
|
addAxesRangesUpdateHandler,
|
|
185
|
-
|
|
186
|
-
|
|
341
|
+
removeAxesRangesUpdateHandler,
|
|
342
|
+
updateAxisRanges,
|
|
343
|
+
color, updateAxisBasedOnDomainValues,
|
|
344
|
+
autoScale, autoScaleMin, autoScaleMax, autoScalePadding, autoScaledDomain
|
|
187
345
|
]
|
|
188
346
|
)
|
|
189
347
|
|
|
348
|
+
// unregister the axes-provider range-update handler on a genuine unmount -- the main effect
|
|
349
|
+
// above only removes it on an axisId *change* (line ~130), never on unmount itself, so
|
|
350
|
+
// without this a component that unmounts and later remounts with the same chartId/axisId/
|
|
351
|
+
// location (hence the same computed handlerId) would try to re-register under an ID that's
|
|
352
|
+
// still occupied and throw ("Handler with ID already exists..."). Mirrors OrdinalAxis.tsx's
|
|
353
|
+
// identical cleanup effect.
|
|
354
|
+
useEffect(
|
|
355
|
+
() => {
|
|
356
|
+
return () => {
|
|
357
|
+
if (rangeUpdateHandlerIdRef.current) {
|
|
358
|
+
removeAxesRangesUpdateHandler(rangeUpdateHandlerIdRef.current)
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
[removeAxesRangesUpdateHandler]
|
|
363
|
+
)
|
|
364
|
+
|
|
365
|
+
// unregister the axis' draw function when the axis unmounts (e.g. the chart is torn down, or
|
|
366
|
+
// this axis is swapped out for a different one)
|
|
367
|
+
useEffect(
|
|
368
|
+
() => {
|
|
369
|
+
return () => {
|
|
370
|
+
if (canvasContext) {
|
|
371
|
+
switch (location) {
|
|
372
|
+
case AxisLocation.Bottom:
|
|
373
|
+
case AxisLocation.Top:
|
|
374
|
+
removeContinuousXAxis(canvasContext, axisId)
|
|
375
|
+
break
|
|
376
|
+
case AxisLocation.Left:
|
|
377
|
+
case AxisLocation.Right:
|
|
378
|
+
removeContinuousYAxis(canvasContext, axisId)
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
[canvasContext, axisId, location]
|
|
384
|
+
)
|
|
385
|
+
|
|
190
386
|
return null
|
|
191
387
|
}
|
|
@@ -6,6 +6,13 @@ import {BaseAxisRange} from "./BaseAxisRange";
|
|
|
6
6
|
*/
|
|
7
7
|
export class ContinuousAxisRange extends BaseAxisRange {
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Use {@link ContinuousAxisRange.from} to create an instance
|
|
11
|
+
* @param start The start of the axis-range
|
|
12
|
+
* @param end The end of the axis-range
|
|
13
|
+
* @param [originalStart=start] The original start of the axis-range
|
|
14
|
+
* @param [originalEnd=end] The original end of the axis-range
|
|
15
|
+
*/
|
|
9
16
|
private constructor(start: number, end: number, originalStart: number = start, originalEnd: number = end) {
|
|
10
17
|
super(start, end, originalStart, originalEnd)
|
|
11
18
|
}
|
|
@@ -25,10 +32,11 @@ export class ContinuousAxisRange extends BaseAxisRange {
|
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
/**
|
|
28
|
-
* Scales the axis-range by the specified scale factor
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
35
|
+
* Scales the axis-range by the specified *incremental* scale factor (relative to `.current`,
|
|
36
|
+
* not `.original` -- see {@link BaseAxisRange.scaledRange}) from the specified value. The
|
|
37
|
+
* equations are written so that the zooming (scaling) occurs at the specified value and
|
|
38
|
+
* expands/contracts equally from that value.
|
|
39
|
+
* @param factor The incremental scale factor
|
|
32
40
|
* @param value The value from which to scale the interval
|
|
33
41
|
* @return A new continuous-axis range with updated values
|
|
34
42
|
*/
|
|
@@ -38,10 +46,18 @@ export class ContinuousAxisRange extends BaseAxisRange {
|
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
/**
|
|
41
|
-
* Scales the axis-range by the specified scale factor
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
49
|
+
* Scales the axis-range by the specified *incremental* scale factor (relative to `.current`,
|
|
50
|
+
* not `.original` -- see {@link BaseAxisRange.scaledRange}) from the specified value, while
|
|
51
|
+
* keeping the range within the constraints (start, end). The equations are written so that the
|
|
52
|
+
* zooming (scaling) occurs at the specified value, and expands/contracts equally from that value.
|
|
53
|
+
*
|
|
54
|
+
* Clamps the scaled result to stay *inside* `constraint` (shrinks toward it, never past it) --
|
|
55
|
+
* `constraint` is a hard viewport edge (e.g. the data domain) that the visible range must not
|
|
56
|
+
* scroll or zoom beyond. This is the opposite direction from
|
|
57
|
+
* {@link OrdinalAxisRange.constrainedScale}, which *widens* its result to guarantee coverage
|
|
58
|
+
* of `constraint` instead -- see that method's doc comment for why an ordinal axis needs the
|
|
59
|
+
* opposite behavior. Do not "fix" this difference without reading both.
|
|
60
|
+
* @param factor The incremental scale factor
|
|
45
61
|
* @param value The value from which to scale the interval
|
|
46
62
|
* @param constraint The minimum and maximum values that range bounds can be
|
|
47
63
|
* @return A new continuous-axis range with updated values
|
|
@@ -58,14 +74,16 @@ export class ContinuousAxisRange extends BaseAxisRange {
|
|
|
58
74
|
}
|
|
59
75
|
|
|
60
76
|
/**
|
|
61
|
-
* Translates the axis-range by the specified amount
|
|
77
|
+
* Translates the axis-range by the specified amount, unless that would take it outside the
|
|
78
|
+
* constraint interval (when both ends of the constraint are infinite, there's no constraint)
|
|
62
79
|
* @param amount The amount by which to translate the axis-range
|
|
63
80
|
* @param [constraint=[-Infinity, Infinity]] Optional constraint interval in which the axis range must be within
|
|
64
|
-
* @return An updated {@link ContinuousAxisRange} that has been translated by the specified amount
|
|
81
|
+
* @return An updated {@link ContinuousAxisRange} that has been translated by the specified amount (or an
|
|
82
|
+
* unchanged copy, when the translation would leave the constraint interval)
|
|
65
83
|
*/
|
|
66
84
|
translate(amount: number, constraint: [start: number, end: number] = [-Infinity, Infinity]): ContinuousAxisRange {
|
|
67
85
|
const [cs, ce] = constraint
|
|
68
|
-
// when
|
|
86
|
+
// when both of the constraints are infinite, or the pan keeps the new axis range
|
|
69
87
|
// within the origin axis range (i.e. zoomed in and the panned), then allow the pan,
|
|
70
88
|
// otherwise don't update
|
|
71
89
|
if ((!isFinite(cs) && !isFinite(ce)) || (this.current.start + amount >= cs && this.current.end + amount <= ce)) {
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
AxisLocation,
|
|
3
|
+
addEmptyXAxis,
|
|
4
|
+
addEmptyYAxis,
|
|
5
|
+
defaultAxesFont,
|
|
6
|
+
removeContinuousXAxis,
|
|
7
|
+
removeContinuousYAxis,
|
|
8
|
+
type ContinuousNumericAxis,
|
|
9
|
+
type SeriesStyle
|
|
10
|
+
} from "./axes";
|
|
11
|
+
import {type NoTooltipMetadata, useChart} from "../hooks/useChart";
|
|
3
12
|
import {useEffect, useRef} from "react";
|
|
4
13
|
import * as d3 from "d3";
|
|
5
|
-
import {Margin} from "../styling/margins";
|
|
14
|
+
import type {Margin} from "../styling/margins";
|
|
6
15
|
import {usePlotDimensions} from "../hooks/usePlotDimensions";
|
|
7
|
-
import {Datum} from "../series/timeSeries";
|
|
16
|
+
import type {Datum} from "../series/timeSeries";
|
|
8
17
|
import {AxisInterval} from "./AxisInterval";
|
|
9
18
|
import {ContinuousAxisRange} from "./ContinuousAxisRange";
|
|
10
19
|
|
|
@@ -23,17 +32,20 @@ const EMPTY_AXIS_SCALE = d3.scaleLinear()
|
|
|
23
32
|
const EMPTY_AXIS_DOMAIN: [min: number, max: number] = [0, 1]
|
|
24
33
|
|
|
25
34
|
/**
|
|
26
|
-
* Represents an empty axis (x or y) that can be
|
|
35
|
+
* Represents an empty axis (x or y) that can be placed on the top, bottom,
|
|
27
36
|
* left, or right of the chart. An empty axis is just a line where the axis
|
|
28
|
-
* would be, without any ticks or labels.
|
|
37
|
+
* would be, without any ticks or labels. This component returns null, meaning React won't
|
|
38
|
+
* render it because we are drawing directly onto the chart's shared canvas.
|
|
29
39
|
* @param props The properties for the axis
|
|
40
|
+
* @return `null` (the axis draws onto the chart's canvas)
|
|
30
41
|
*/
|
|
31
42
|
export function EmptyAxis(props: Props): null {
|
|
32
43
|
const {
|
|
33
44
|
chartId,
|
|
34
|
-
|
|
45
|
+
canvasContext,
|
|
35
46
|
axes,
|
|
36
|
-
|
|
47
|
+
color,
|
|
48
|
+
} = useChart<Datum, SeriesStyle, NoTooltipMetadata, ContinuousAxisRange, ContinuousNumericAxis>()
|
|
37
49
|
|
|
38
50
|
const {
|
|
39
51
|
addXAxis,
|
|
@@ -67,16 +79,14 @@ export function EmptyAxis(props: Props): null {
|
|
|
67
79
|
|
|
68
80
|
useEffect(
|
|
69
81
|
() => {
|
|
70
|
-
if (
|
|
71
|
-
const svg = d3.select<SVGSVGElement, any>(container)
|
|
72
|
-
|
|
82
|
+
if (canvasContext) {
|
|
73
83
|
if (axisRef.current === undefined) {
|
|
74
84
|
switch (location) {
|
|
75
85
|
case AxisLocation.Bottom:
|
|
76
86
|
case AxisLocation.Top: {
|
|
77
87
|
axisRef.current = addEmptyXAxis(
|
|
78
|
-
|
|
79
|
-
margin, setAxisIntervalFor, EMPTY_AXIS_DOMAIN
|
|
88
|
+
canvasContext, axisId, plotDimensions, location, EMPTY_AXIS_SCALE,
|
|
89
|
+
margin, setAxisIntervalFor, color, EMPTY_AXIS_DOMAIN
|
|
80
90
|
)
|
|
81
91
|
// add the x-axis to the chart context
|
|
82
92
|
const [start, end] = AxisInterval.as(EMPTY_AXIS_DOMAIN).asTuple()
|
|
@@ -88,8 +98,8 @@ export function EmptyAxis(props: Props): null {
|
|
|
88
98
|
case AxisLocation.Left:
|
|
89
99
|
case AxisLocation.Right: {
|
|
90
100
|
axisRef.current = addEmptyYAxis(
|
|
91
|
-
|
|
92
|
-
margin, setAxisIntervalFor, EMPTY_AXIS_DOMAIN
|
|
101
|
+
canvasContext, axisId, plotDimensions, location, EMPTY_AXIS_SCALE,
|
|
102
|
+
margin, setAxisIntervalFor, color, EMPTY_AXIS_DOMAIN
|
|
93
103
|
)
|
|
94
104
|
// add the y-axis to the chart context
|
|
95
105
|
const [start, end] = AxisInterval.as(EMPTY_AXIS_DOMAIN).asTuple()
|
|
@@ -104,16 +114,41 @@ export function EmptyAxis(props: Props): null {
|
|
|
104
114
|
if (domain.isNotEmpty()) {
|
|
105
115
|
axisRef.current.update(domain, plotDimensions, margin)
|
|
106
116
|
}
|
|
117
|
+
|
|
118
|
+
// keep the line color in sync with the chart's color (e.g. on theme change),
|
|
119
|
+
// without recreating the axis or touching its domain
|
|
120
|
+
axisRef.current.updateFont({...defaultAxesFont(), color})
|
|
107
121
|
}
|
|
108
122
|
}
|
|
109
123
|
},
|
|
110
124
|
[
|
|
111
125
|
chartId, axisId, location, addXAxis, addYAxis,
|
|
112
|
-
|
|
126
|
+
canvasContext, margin, plotDimensions, setAxisIntervalFor,
|
|
113
127
|
axisRangeFor,
|
|
114
128
|
setAxisRangeFor,
|
|
129
|
+
color,
|
|
115
130
|
]
|
|
116
131
|
)
|
|
117
132
|
|
|
133
|
+
// unregister the axis' draw function when the axis unmounts
|
|
134
|
+
useEffect(
|
|
135
|
+
() => {
|
|
136
|
+
return () => {
|
|
137
|
+
if (canvasContext) {
|
|
138
|
+
switch (location) {
|
|
139
|
+
case AxisLocation.Bottom:
|
|
140
|
+
case AxisLocation.Top:
|
|
141
|
+
removeContinuousXAxis(canvasContext, axisId)
|
|
142
|
+
break
|
|
143
|
+
case AxisLocation.Left:
|
|
144
|
+
case AxisLocation.Right:
|
|
145
|
+
removeContinuousYAxis(canvasContext, axisId)
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
[canvasContext, axisId, location]
|
|
151
|
+
)
|
|
152
|
+
|
|
118
153
|
return null
|
|
119
|
-
}
|
|
154
|
+
}
|