stream-charts 1.2.0 → 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 +40 -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,23 +1,16 @@
|
|
|
1
1
|
import {AxesState} from "../axes/AxesState";
|
|
2
|
-
import {BaseAxis} from "../axes/axes";
|
|
3
|
-
import {AxesAssignment} from "../plots/plot";
|
|
4
|
-
import {createContext,
|
|
5
|
-
import {Dimensions} from "../styling/margins";
|
|
6
|
-
import {usePlotDimensions} from "./usePlotDimensions";
|
|
2
|
+
import type {BaseAxis} from "../axes/axes";
|
|
3
|
+
import type {AxesAssignment} from "../plots/plot";
|
|
4
|
+
import {createContext, useContext} from "react";
|
|
5
|
+
import type {Dimensions} from "../styling/margins";
|
|
7
6
|
import {BaseAxisRange} from "../axes/BaseAxisRange";
|
|
8
7
|
import {AxisInterval} from "../axes/AxisInterval";
|
|
9
8
|
import {Optional} from "result-fn";
|
|
10
9
|
|
|
11
|
-
/**
|
|
12
|
-
* No operation function for use when a default function is needed
|
|
13
|
-
*/
|
|
14
|
-
const noop = () => {
|
|
15
|
-
/* empty on purpose */
|
|
16
|
-
}
|
|
17
|
-
|
|
18
10
|
/**
|
|
19
11
|
* The values exposed by the hook
|
|
20
12
|
* @template AR The type of the axis range (e.g. {@link ContinuousAxisRange} or {@link OrdinalAxisRange})
|
|
13
|
+
* @template A The axis type
|
|
21
14
|
*/
|
|
22
15
|
export type UseAxesValues<AR extends BaseAxisRange, A extends BaseAxis> = {
|
|
23
16
|
/**
|
|
@@ -32,7 +25,7 @@ export type UseAxesValues<AR extends BaseAxisRange, A extends BaseAxis> = {
|
|
|
32
25
|
*/
|
|
33
26
|
addXAxis: (axis: A, id: string, range?: AR) => void
|
|
34
27
|
/**
|
|
35
|
-
* The y-axes state holds the currently set
|
|
28
|
+
* The y-axes state holds the currently set y-axes, manipulation and accessor functions
|
|
36
29
|
*/
|
|
37
30
|
yAxesState: AxesState<A>
|
|
38
31
|
/**
|
|
@@ -49,17 +42,20 @@ export type UseAxesValues<AR extends BaseAxisRange, A extends BaseAxis> = {
|
|
|
49
42
|
*/
|
|
50
43
|
setAxisAssignments: (assignments: Map<string, AxesAssignment>) => void
|
|
51
44
|
/**
|
|
52
|
-
* Retrieves the
|
|
45
|
+
* Retrieves the axes assigned to the specified series (the default x- and y-axes, when the
|
|
46
|
+
* series has no assignment)
|
|
47
|
+
* @param seriesName The name of the series
|
|
53
48
|
* @return The axes assigned to the specified series
|
|
54
49
|
*/
|
|
55
50
|
axisAssignmentsFor: (seriesName: string) => AxesAssignment
|
|
56
51
|
/**
|
|
57
|
-
* Sets the axis ranges specified in the input map
|
|
52
|
+
* Sets the axis ranges specified in the input map (without dispatching them to the update
|
|
53
|
+
* handlers -- see {@link updateAxisRanges} for that)
|
|
58
54
|
* @param ranges A map holding the axis ID to the axis range
|
|
59
55
|
*/
|
|
60
56
|
setAxesRanges: (ranges: Map<string, AR>) => void
|
|
61
57
|
/**
|
|
62
|
-
* Sets the axis range for the specified axis ID
|
|
58
|
+
* Sets the axis range for the specified axis ID (without dispatching it to the update handlers)
|
|
63
59
|
* @param axisId The ID of the axis for which to set the range
|
|
64
60
|
* @param range The new axis range
|
|
65
61
|
*/
|
|
@@ -68,42 +64,52 @@ export type UseAxesValues<AR extends BaseAxisRange, A extends BaseAxis> = {
|
|
|
68
64
|
* Retrieves the current axis range for the specified axis ID
|
|
69
65
|
* @param axisId The ID of the axis for which to retrieve the range
|
|
70
66
|
* @return The current axis range for the specified axis ID wrapped
|
|
71
|
-
* in
|
|
67
|
+
* in an {@link Optional}, or an empty {@link Optional} if the axis
|
|
72
68
|
* ID is not found
|
|
73
69
|
*/
|
|
74
70
|
axisRangeFor: (axisId: string) => Optional<AR>
|
|
75
71
|
/**
|
|
76
|
-
* Sets the domain (interval)
|
|
72
|
+
* Sets the domain (interval) of the specified axis' current range, leaving its original range
|
|
73
|
+
* as it is (does nothing when the axis has no range yet; doesn't dispatch the change to the
|
|
74
|
+
* update handlers)
|
|
77
75
|
* @param axisId The ID of the axis for which to set the range
|
|
78
|
-
* @param domain The new domain
|
|
76
|
+
* @param domain The new domain
|
|
79
77
|
*/
|
|
80
78
|
setAxisIntervalFor: (axisId: string, domain: AxisInterval) => void
|
|
81
79
|
/**
|
|
82
|
-
* Sets the original axis bounds for the specified axis ID to the specified range
|
|
80
|
+
* Sets the original axis bounds for the specified axis ID to the specified range (does nothing
|
|
81
|
+
* when the axis has no range yet)
|
|
83
82
|
* @param axisId The ID of the axis for which to set the range
|
|
84
|
-
* @param range The new range
|
|
83
|
+
* @param range The new original range
|
|
85
84
|
*/
|
|
86
85
|
setOriginalAxisIntervalFor: (axisId: string, range: AxisInterval) => void
|
|
87
86
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
87
|
+
* Updates the ranges of the specified axes, and dispatches the updates to every registered
|
|
88
|
+
* update handler (see {@link addAxesRangesUpdateHandler}) -- e.g. the axes, which redraw with
|
|
89
|
+
* their new domains. Called when the ranges change because of a zoom action, a pan action, or
|
|
90
|
+
* as new data is streamed in.
|
|
90
91
|
* @param domains A `map(axis_id -> domain)` that associates the axis ID with the
|
|
91
92
|
* current time range.
|
|
92
93
|
*/
|
|
93
94
|
updateAxisRanges: (domains: Map<string, AR>) => void
|
|
94
95
|
/**
|
|
95
|
-
* Retrieves the current
|
|
96
|
-
* @return
|
|
96
|
+
* Retrieves the current ranges of all the axes
|
|
97
|
+
* @return A copy of the current axis ranges, as a map(axis_id, range)
|
|
97
98
|
*/
|
|
98
99
|
axesRanges: () => Map<string, AR>
|
|
99
100
|
/**
|
|
100
|
-
*
|
|
101
|
+
* Re-applies the specified axis' stored range: dispatches it, unchanged, to the update handlers
|
|
102
|
+
* (so that the axis redraws with it). Note that, despite its name, this does *not* restore the
|
|
103
|
+
* axis' original range, and the `<AxesProvider>`'s implementation ignores `axisBounds`.
|
|
101
104
|
* @param axisId The ID of the axis
|
|
102
|
-
* @param [axisBounds]
|
|
105
|
+
* @param [axisBounds] Unused
|
|
103
106
|
*/
|
|
104
107
|
resetAxisIntervalFor: (axisId: string, axisBounds?: AxisInterval) => void
|
|
105
108
|
/**
|
|
106
|
-
*
|
|
109
|
+
* Sets the ranges of the axes in the specified map, and dispatches them to the update handlers
|
|
110
|
+
* (the same as {@link updateAxisRanges}). Axes that aren't in the map are left as they are, so
|
|
111
|
+
* calling this without a map changes nothing -- despite its name, it doesn't restore the axes'
|
|
112
|
+
* original ranges.
|
|
107
113
|
* @param [axesBounds] An optional map holds the new bounds for specified axes. The map
|
|
108
114
|
* associates an axis ID with the new bounds.
|
|
109
115
|
*/
|
|
@@ -119,6 +125,15 @@ export type UseAxesValues<AR extends BaseAxisRange, A extends BaseAxis> = {
|
|
|
119
125
|
/**
|
|
120
126
|
* Adds a handler for when the axes are updated. An axis domain/range could change because of a zoom action,
|
|
121
127
|
* a pan action, or as new data is streamed in.
|
|
128
|
+
*
|
|
129
|
+
* Throws if `handlerId` is already registered, rather than silently replacing or ignoring the
|
|
130
|
+
* new one -- a custom axis/plot component that could ever remount (not just re-render) with
|
|
131
|
+
* the same `handlerId` (e.g. one derived from a stable chart/axis ID) must call
|
|
132
|
+
* {@link removeAxesRangesUpdateHandler} in its own unmount cleanup before this would ever be
|
|
133
|
+
* called again for that ID, or the remount will throw here. See {@link ContinuousAxis}/
|
|
134
|
+
* {@link OrdinalAxis} for the reference pattern: a `useEffect` whose only job is calling
|
|
135
|
+
* `removeAxesRangesUpdateHandler` on unmount, kept separate from whatever other effect(s)
|
|
136
|
+
* register the handler.
|
|
122
137
|
* @param handlerId The unique ID of the handler to register/add
|
|
123
138
|
* @param handler The handler function that accepts a map of updates and a plot dimension
|
|
124
139
|
*/
|
|
@@ -130,211 +145,28 @@ export type UseAxesValues<AR extends BaseAxisRange, A extends BaseAxis> = {
|
|
|
130
145
|
removeAxesRangesUpdateHandler: (handlerId: string) => void
|
|
131
146
|
}
|
|
132
147
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
axisRangeFor: () => Optional.empty(),
|
|
143
|
-
setAxesRanges: noop,
|
|
144
|
-
setAxisRangeFor: noop,
|
|
145
|
-
setAxisIntervalFor: noop,
|
|
146
|
-
setOriginalAxisIntervalFor: noop,
|
|
147
|
-
resetAxisIntervalFor: noop,
|
|
148
|
-
resetAxesRanges: noop,
|
|
149
|
-
addAxesRangesUpdateHandler: () => noop,
|
|
150
|
-
removeAxesRangesUpdateHandler: () => noop,
|
|
151
|
-
})
|
|
152
|
-
|
|
153
|
-
// the context for axes
|
|
154
|
-
const AxesContext = createContext<UseAxesValues<any, any>>(defaultAxesValues())
|
|
155
|
-
|
|
156
|
-
export type Props = {
|
|
157
|
-
/**y
|
|
158
|
-
* Callback when axes bounds change.
|
|
159
|
-
* @param ranges The ranges (start, end) for each axis in the plot
|
|
160
|
-
*/
|
|
161
|
-
onUpdateAxesInterval?: (ranges: Map<string, AxisInterval>) => void
|
|
162
|
-
|
|
163
|
-
children: JSX.Element | Array<JSX.Element>
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* The React context provider for the {@link UseAxesValues}
|
|
168
|
-
* @param props The properties
|
|
169
|
-
* @return The children wrapped in this provider
|
|
170
|
-
*/
|
|
171
|
-
export default function AxesProvider<AR extends BaseAxisRange, A extends BaseAxis>(props: Props): JSX.Element {
|
|
172
|
-
const {onUpdateAxesInterval, children} = props
|
|
173
|
-
|
|
174
|
-
const plotDimensions = usePlotDimensions()
|
|
175
|
-
|
|
176
|
-
const xAxesStateRef = useRef<AxesState<A>>(AxesState.empty<A>())
|
|
177
|
-
const yAxesStateRef = useRef<AxesState<A>>(AxesState.empty<A>())
|
|
178
|
-
const axisAssignmentsRef = useRef<Map<string, AxesAssignment>>(new Map())
|
|
179
|
-
const axesBoundsUpdateHandlersRef = useRef<Map<string, (updates: Map<string, AR>, plotDim: Dimensions) => void>>(new Map())
|
|
180
|
-
const axesRangeRef = useRef<Map<string, AR>>(new Map())
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Retrieves the x-axis and y-axis assignments for the specified series. If the axis does not have
|
|
184
|
-
* an assignment, then we assume it is using the default x- and y-axes.
|
|
185
|
-
* @param seriesName The name of the series for which to retrieve the axes assignments
|
|
186
|
-
* @return An {@link AxesAssignment} for the specified axes.
|
|
187
|
-
*/
|
|
188
|
-
function axisAssignmentsFor(seriesName: string): AxesAssignment {
|
|
189
|
-
return axisAssignmentsRef.current.get(seriesName) || {
|
|
190
|
-
xAxis: xAxesStateRef.current.axisDefaultId().getOrElse(""),
|
|
191
|
-
yAxis: yAxesStateRef.current.axisDefaultId().getOrElse("")
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Called when the domain/range is updated on one or more of the chart's axes (generally x-axes). In turn,
|
|
197
|
-
* dispatches the update to all the internal domain/range update handlers.
|
|
198
|
-
* @param updates A map holding the axis ID to the updated axis time-range (i.e., map(axis_id, axis_time_range))
|
|
199
|
-
*/
|
|
200
|
-
function updateAxisRanges(updates: Map<string, AR>): void {
|
|
201
|
-
// update the current time-ranges reference
|
|
202
|
-
updates.forEach((range, id) => {
|
|
203
|
-
axesRangeRef.current.set(id, range)
|
|
204
|
-
})
|
|
205
|
-
// dispatch the updates to all the registered handlers
|
|
206
|
-
axesBoundsUpdateHandlersRef.current
|
|
207
|
-
.forEach((handler, ) => handler(updates, plotDimensions.plotDimensions))
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Sets the axis ranges specified in the input map
|
|
212
|
-
* @param ranges The ranges to set
|
|
213
|
-
*/
|
|
214
|
-
function setAxesRanges(ranges: Map<string, AR>): void {
|
|
215
|
-
ranges.forEach((range, id) => {
|
|
216
|
-
axesRangeRef.current.set(id, range)
|
|
217
|
-
})
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Sets the axis range for the specified axis ID
|
|
222
|
-
* @param axisId The axis ID
|
|
223
|
-
* @param range The range to set
|
|
224
|
-
*/
|
|
225
|
-
function setAxisRangeFor(axisId: string, range: AR): void {
|
|
226
|
-
axesRangeRef.current.set(axisId, range)
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Sets the axis bounds for the specified axis ID. Note that this does not
|
|
231
|
-
* change the original axis interval
|
|
232
|
-
* @param axisId The axis ID
|
|
233
|
-
* @param interval The interval
|
|
234
|
-
*/
|
|
235
|
-
function setAxisIntervalFor(axisId: string, interval: AxisInterval): void {
|
|
236
|
-
Optional.ofNullable(axesRangeRef.current.get(axisId))
|
|
237
|
-
.map(range => range.update(interval.start, interval.end) as AR)
|
|
238
|
-
.ifPresent(updatedRange => axesRangeRef.current.set(axisId, updatedRange))
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Sets the original axis interval for the axis range
|
|
243
|
-
* @param axisId The axis ID
|
|
244
|
-
* @param interval The interval to which to set the origin interval
|
|
245
|
-
*/
|
|
246
|
-
function setOriginalAxisIntervalFor(axisId: string, interval: AxisInterval): void {
|
|
247
|
-
Optional.ofNullable(axesRangeRef.current.get(axisId))
|
|
248
|
-
.map(range => range.updateOriginal(interval.start, interval.end) as AR)
|
|
249
|
-
.ifPresent(updatedRange => axesRangeRef.current.set(axisId, updatedRange))
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Resets the bounds for the specified axis to the original range
|
|
254
|
-
* @param axisId The ID of the axis
|
|
255
|
-
*/
|
|
256
|
-
function resetAxisIntervalFor(axisId: string): void {
|
|
257
|
-
Optional
|
|
258
|
-
.ofNullable(axesRangeRef.current.get(axisId))
|
|
259
|
-
.map(range => new Map<string, AR>([[axisId, range]]))
|
|
260
|
-
.ifPresent(updates => updateAxisRanges(updates))
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Resets the bounds of all the axes to their original value or to the values specified
|
|
265
|
-
* in the optional bounds map.
|
|
266
|
-
* @param [axesRanges=new Map()] An optional map holds bounds for specified axes. The map
|
|
267
|
-
* associates an axis ID with the new bounds.
|
|
268
|
-
*/
|
|
269
|
-
function resetAxesRanges(axesRanges: Map<string, AR> = new Map()): void {
|
|
270
|
-
updateAxisRanges(axesRanges)
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Adds a handler to deal with updates to the bounds of the axes
|
|
275
|
-
* @param handlerId the unique ID of the handler
|
|
276
|
-
* @param handler The handler function that accepts a map of updates and a plot dimension
|
|
277
|
-
* @return A map with all the handlers
|
|
278
|
-
*/
|
|
279
|
-
function addAxesRangesUpdateHandler(
|
|
280
|
-
handlerId: string,
|
|
281
|
-
handler: (updates: Map<string, AR>, plotDim: Dimensions) => void
|
|
282
|
-
): Map<string, (updates: Map<string, AR>, plotDim: Dimensions) => void> {
|
|
283
|
-
if (axesBoundsUpdateHandlersRef.current.has(handlerId)) {
|
|
284
|
-
throw new Error(
|
|
285
|
-
`Handler with ID already exists, please remove it before adding it; ` +
|
|
286
|
-
`handler_id: ${handlerId}; ` +
|
|
287
|
-
`existing_handler_ids: [${Array.from(axesBoundsUpdateHandlersRef.current.keys()).join(", ")}]`
|
|
288
|
-
)
|
|
289
|
-
}
|
|
290
|
-
return axesBoundsUpdateHandlersRef.current.set(handlerId, handler)
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
return <AxesContext.Provider
|
|
294
|
-
value={{
|
|
295
|
-
xAxesState: xAxesStateRef.current,
|
|
296
|
-
yAxesState: yAxesStateRef.current,
|
|
297
|
-
addXAxis: (axis, id, range: AR) => {
|
|
298
|
-
xAxesStateRef.current = xAxesStateRef.current.addAxis(axis, id)
|
|
299
|
-
if (range !== undefined) {
|
|
300
|
-
axesRangeRef.current.set(id, range)
|
|
301
|
-
}
|
|
302
|
-
},
|
|
303
|
-
addYAxis: (axis, id, range: AR) => {
|
|
304
|
-
yAxesStateRef.current = yAxesStateRef.current.addAxis(axis, id)
|
|
305
|
-
if (range !== undefined) {
|
|
306
|
-
axesRangeRef.current.set(id, range)
|
|
307
|
-
}
|
|
308
|
-
},
|
|
309
|
-
setAxisAssignments: assignments => axisAssignmentsRef.current = assignments,
|
|
310
|
-
axisAssignmentsFor: seriesName => axisAssignmentsFor(seriesName),
|
|
311
|
-
updateAxisRanges,
|
|
312
|
-
axesRanges: () => new Map<string, AR>(axesRangeRef.current),
|
|
313
|
-
axisRangeFor: axisId => Optional.ofNullable(axesRangeRef.current.get(axisId)),
|
|
314
|
-
setAxesRanges,
|
|
315
|
-
setAxisRangeFor,
|
|
316
|
-
setAxisIntervalFor,
|
|
317
|
-
setOriginalAxisIntervalFor,
|
|
318
|
-
resetAxesRanges,
|
|
319
|
-
resetAxisIntervalFor,
|
|
320
|
-
onUpdateAxesInterval,
|
|
321
|
-
addAxesRangesUpdateHandler,
|
|
322
|
-
removeAxesRangesUpdateHandler: handlerId => axesBoundsUpdateHandlersRef.current.delete(handlerId),
|
|
323
|
-
}}
|
|
324
|
-
>
|
|
325
|
-
{children}
|
|
326
|
-
</AxesContext.Provider>
|
|
327
|
-
}
|
|
148
|
+
// the context is generic over the same type parameters as `UseAxesValues`, but a context
|
|
149
|
+
// object can't itself carry unbound generics -- `useAxes` below casts it back to the caller's
|
|
150
|
+
// concrete types, which is safe because `<AxesProvider/>` is what actually supplies the value
|
|
151
|
+
//
|
|
152
|
+
// IMPORTANT: as with `ChartContext` (see its identical note in useChart.tsx), this is NOT
|
|
153
|
+
// statically enforced across the component tree -- each consumer casts to its own hardcoded
|
|
154
|
+
// AR/A, independent of whatever `<AxesProvider<AR, A>>` ancestor actually supplied. A mismatched
|
|
155
|
+
// axis-range/axis kind only fails at runtime, not at compile time.
|
|
156
|
+
export const AxesContext = createContext<unknown>(undefined)
|
|
328
157
|
|
|
329
158
|
/**
|
|
330
|
-
* React hook
|
|
159
|
+
* React hook for the chart's axes: their state, ranges, and the functions for updating them.
|
|
160
|
+
* Must be used within an {@link AxesProvider} (i.e. within a `<Chart>`).
|
|
331
161
|
* @return The {@link UseAxesValues} held in the React context.
|
|
162
|
+
* @throws Error when used outside an `<AxesProvider>`
|
|
163
|
+
* @template AR The type of the axis range (e.g. {@link ContinuousAxisRange} or {@link OrdinalAxisRange})
|
|
164
|
+
* @template A The axis type
|
|
332
165
|
*/
|
|
333
166
|
export function useAxes<AR extends BaseAxisRange, A extends BaseAxis>(): UseAxesValues<AR, A> {
|
|
334
|
-
const context = useContext
|
|
335
|
-
|
|
336
|
-
if (xAxesState === undefined || xAxesState === null) {
|
|
167
|
+
const context = useContext(AxesContext)
|
|
168
|
+
if (context === undefined) {
|
|
337
169
|
throw new Error("useAxes can only be used when the parent is a <AxesProvider/>")
|
|
338
170
|
}
|
|
339
|
-
return context
|
|
171
|
+
return context as UseAxesValues<AR, A>
|
|
340
172
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {createContext, useContext} from "react";
|
|
2
|
+
import type {CanvasContext} from "../d3types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The values exposed through the {@link useCanvasSurface} react hook.
|
|
6
|
+
*/
|
|
7
|
+
export type UseCanvasSurfaceValues = {
|
|
8
|
+
/**
|
|
9
|
+
* The `<canvas>` element backing the chart.
|
|
10
|
+
*/
|
|
11
|
+
canvas: HTMLCanvasElement | null
|
|
12
|
+
/**
|
|
13
|
+
* The canvas drawing context and redraw-registration API for the chart.
|
|
14
|
+
*/
|
|
15
|
+
canvasContext: CanvasContext | null
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const defaultCanvasSurfaceValues: UseCanvasSurfaceValues = {
|
|
19
|
+
canvas: null,
|
|
20
|
+
canvasContext: null,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const CanvasSurfaceContext = createContext<UseCanvasSurfaceValues>(defaultCanvasSurfaceValues)
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* React hook that reads the canvas element and canvas drawing context from context. This is set
|
|
27
|
+
* up by {@link CanvasSurfaceProvider}, which sizes the canvas from {@link usePlotDimensions} (the
|
|
28
|
+
* single source of truth for the chart's dimensions) rather than from static width/height props,
|
|
29
|
+
* so that the canvas stays correctly sized even if dimensions change via
|
|
30
|
+
* `usePlotDimensions().updateDimensions(...)` independent of any prop.
|
|
31
|
+
* @return The {@link UseCanvasSurfaceValues} held in the React context.
|
|
32
|
+
*/
|
|
33
|
+
export function useCanvasSurface(): UseCanvasSurfaceValues {
|
|
34
|
+
return useContext(CanvasSurfaceContext)
|
|
35
|
+
}
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import {createContext,
|
|
2
|
-
import {
|
|
3
|
-
import {BaseAxis,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {SvgStyle} from "../styling/svgStyle";
|
|
1
|
+
import {createContext, useContext} from "react";
|
|
2
|
+
import type {CanvasContext} from "../d3types";
|
|
3
|
+
import type {BaseAxis, SeriesStyle} from "../axes/axes";
|
|
4
|
+
import {type UseAxesValues} from "./useAxes";
|
|
5
|
+
import {type UseMouseValues} from "./useMouse";
|
|
6
|
+
import {type UseTooltipValues} from "./useTooltip";
|
|
8
7
|
import {BaseAxisRange} from "../axes/BaseAxisRange";
|
|
8
|
+
import {defaultUseChartValues} from "./defaultUseChartValues";
|
|
9
9
|
|
|
10
|
-
export type NoTooltipMetadata =
|
|
10
|
+
export type NoTooltipMetadata = object
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* The values exposed through the {@link useChart} react hook
|
|
14
14
|
* @param chartId The unique ID for the chart
|
|
15
|
-
* @param
|
|
16
|
-
* @param
|
|
15
|
+
* @param canvasContext The canvas drawing context and redraw-registration API for the chart
|
|
16
|
+
* @param canvas The `<canvas>` element which is the container for this chart
|
|
17
17
|
* @template D The type of the series' datum
|
|
18
18
|
* @template S The type of the series style
|
|
19
19
|
* @template TM The type of the tooltip's metadata (data about the series data)
|
|
20
|
+
* @template AR The type of the axis range
|
|
21
|
+
* @template A The type of the axis
|
|
20
22
|
*/
|
|
21
23
|
export interface UseChartValues<D, S extends SeriesStyle, TM, AR extends BaseAxisRange, A extends BaseAxis> {
|
|
22
24
|
/**
|
|
@@ -24,25 +26,24 @@ export interface UseChartValues<D, S extends SeriesStyle, TM, AR extends BaseAxi
|
|
|
24
26
|
*/
|
|
25
27
|
chartId: number
|
|
26
28
|
/**
|
|
27
|
-
* The
|
|
29
|
+
* The canvas drawing context and redraw-registration API for the chart. Axes, plots, and the
|
|
30
|
+
* tracker register a draw function here (via `canvasContext.register(id, drawFn, zIndex)`)
|
|
31
|
+
* instead of creating/updating SVG elements. Replaces the old `mainG`.
|
|
28
32
|
*/
|
|
29
|
-
|
|
33
|
+
canvasContext: CanvasContext | null
|
|
30
34
|
/**
|
|
31
|
-
* The
|
|
35
|
+
* The `<canvas>` element which is the container for this chart. Replaces the old `container`
|
|
36
|
+
* (root `<svg>` element).
|
|
32
37
|
*/
|
|
33
|
-
|
|
38
|
+
canvas: HTMLCanvasElement | null
|
|
34
39
|
/**
|
|
35
40
|
* Base color
|
|
36
41
|
*/
|
|
37
42
|
color: string
|
|
38
43
|
/**
|
|
39
|
-
* The base/default background color. This can be overridden by the {@link
|
|
44
|
+
* The base/default background color. This can be overridden by the {@link ChartProps.svgStyle} property.
|
|
40
45
|
*/
|
|
41
46
|
backgroundColor: string
|
|
42
|
-
/**
|
|
43
|
-
* Overrides for the SVG style
|
|
44
|
-
*/
|
|
45
|
-
svgStyle: Partial<SvgStyle>
|
|
46
47
|
/**
|
|
47
48
|
* A `map(series_name -> series_line_style)`
|
|
48
49
|
*/
|
|
@@ -57,7 +58,7 @@ export interface UseChartValues<D, S extends SeriesStyle, TM, AR extends BaseAxi
|
|
|
57
58
|
| DATA PROCESSING
|
|
58
59
|
*/
|
|
59
60
|
/**
|
|
60
|
-
* A regular expression
|
|
61
|
+
* A regular expression used against the series names to determine which series to show in the chart
|
|
61
62
|
*/
|
|
62
63
|
seriesFilter: RegExp
|
|
63
64
|
|
|
@@ -66,99 +67,39 @@ export interface UseChartValues<D, S extends SeriesStyle, TM, AR extends BaseAxi
|
|
|
66
67
|
*/
|
|
67
68
|
mouse: UseMouseValues<D, TM>
|
|
68
69
|
tooltip: UseTooltipValues<D, TM>
|
|
69
|
-
/**
|
|
70
|
-
* Ref tracking the currently-hovered series name (null when nothing is hovered).
|
|
71
|
-
* Updated by the Legend; read by plots so new path elements use the correct stroke.
|
|
72
|
-
*/
|
|
73
|
-
hoveredSeriesRef: MutableRefObject<string | null>
|
|
74
70
|
}
|
|
75
71
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
mouse: defaultMouseValues(),
|
|
93
|
-
tooltip: defaultTooltipValues(),
|
|
94
|
-
hoveredSeriesRef: { current: null },
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const ChartContext = createContext<UseChartValues<any, any, any, any, any>>(defaultUseChartValues)
|
|
98
|
-
|
|
99
|
-
export interface Props {
|
|
100
|
-
chartId: number
|
|
101
|
-
container: SVGSVGElement | null
|
|
102
|
-
mainG: GSelection | null
|
|
103
|
-
color: string
|
|
104
|
-
backgroundColor: string
|
|
105
|
-
svgStyle: Partial<SvgStyle>
|
|
106
|
-
seriesStyles?: Map<string, SeriesLineStyle>
|
|
107
|
-
seriesFilter?: RegExp
|
|
108
|
-
hoveredSeriesRef: MutableRefObject<string | null>
|
|
109
|
-
|
|
110
|
-
children: JSX.Element | Array<JSX.Element>
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* The React context provider for the {@link UseChartValues}
|
|
115
|
-
* @param props The properties
|
|
116
|
-
* @return The children wrapped in this provider
|
|
117
|
-
*/
|
|
118
|
-
export default function ChartProvider(props: Props): JSX.Element {
|
|
119
|
-
const {
|
|
120
|
-
chartId,
|
|
121
|
-
container,
|
|
122
|
-
mainG,
|
|
123
|
-
color,
|
|
124
|
-
backgroundColor,
|
|
125
|
-
seriesFilter = defaultUseChartValues.seriesFilter,
|
|
126
|
-
svgStyle,
|
|
127
|
-
seriesStyles = new Map<string, SeriesLineStyle>(),
|
|
128
|
-
hoveredSeriesRef,
|
|
129
|
-
} = props
|
|
130
|
-
|
|
131
|
-
const axes = useAxes()
|
|
132
|
-
const mouse = useMouse()
|
|
133
|
-
const tooltip = useTooltip()
|
|
134
|
-
|
|
135
|
-
return <ChartContext.Provider
|
|
136
|
-
value={{
|
|
137
|
-
chartId,
|
|
138
|
-
color,
|
|
139
|
-
backgroundColor,
|
|
140
|
-
svgStyle,
|
|
141
|
-
seriesStyles,
|
|
142
|
-
seriesFilter,
|
|
143
|
-
mainG,
|
|
144
|
-
container,
|
|
145
|
-
|
|
146
|
-
axes,
|
|
147
|
-
mouse,
|
|
148
|
-
tooltip,
|
|
149
|
-
hoveredSeriesRef,
|
|
150
|
-
}}
|
|
151
|
-
>
|
|
152
|
-
{props.children}
|
|
153
|
-
</ChartContext.Provider>
|
|
154
|
-
}
|
|
72
|
+
// the context is generic over the same type parameters as `UseChartValues`, but a context
|
|
73
|
+
// object can't itself carry unbound generics -- `useChart` below casts it back to the caller's
|
|
74
|
+
// concrete types, which is safe because `<ChartProvider/>` is what actually supplies the value
|
|
75
|
+
//
|
|
76
|
+
// IMPORTANT: this is NOT statically enforced across the component tree. `<Chart<CD, D, S, TM, AR,
|
|
77
|
+
// A>>`'s AR/A are never referenced by its own Props type, so they can't even be inferred from
|
|
78
|
+
// JSX; and every descendant (each axis component) calls `useChart<...>()` with its OWN hardcoded
|
|
79
|
+
// generic arguments, entirely independent of whatever the ancestor `<Chart<...>>` was
|
|
80
|
+
// instantiated with. Nothing at the type level stops e.g. a `<Chart<..., ContinuousAxisRange,
|
|
81
|
+
// ContinuousNumericAxis>>` from having an `<OrdinalAxis>` child that casts this same context to
|
|
82
|
+
// `UseChartValues<..., OrdinalAxisRange, OrdinalStringAxis>` internally -- a real mismatch here
|
|
83
|
+
// only fails at runtime (a bad cast surfacing as a confusing error deeper in axis/plot code), not
|
|
84
|
+
// at compile time. Making this a real compile-time guarantee would need a per-instantiation-typed
|
|
85
|
+
// context (e.g. a context factory called once per concrete AR/A pairing) -- a broader refactor
|
|
86
|
+
// than the type parameters alone might suggest, and not something to casually "fix" locally.
|
|
87
|
+
export const ChartContext = createContext<unknown>(defaultUseChartValues())
|
|
155
88
|
|
|
156
89
|
/**
|
|
157
|
-
* React hook
|
|
90
|
+
* React hook for the chart's values: its ID, canvas, colors, styles, axes, mouse and tooltip
|
|
91
|
+
* handlers, and highlighted series. Must be used within a `ChartProvider` (i.e. within a
|
|
92
|
+
* `<Chart>`).
|
|
158
93
|
* @return The {@link UseChartValues} held in the React context.
|
|
94
|
+
* @throws Error when used outside a `<ChartProvider>`
|
|
95
|
+
* @template D The type of the series' datum
|
|
96
|
+
* @template S The type of the series style
|
|
97
|
+
* @template TM The type of the tooltip's metadata (data about the series data)
|
|
98
|
+
* @template AR The type of the axis range
|
|
99
|
+
* @template A The type of the axis
|
|
159
100
|
*/
|
|
160
101
|
export function useChart<D, S extends SeriesStyle, TM, AR extends BaseAxisRange, A extends BaseAxis>(): UseChartValues<D, S, TM, AR, A> {
|
|
161
|
-
const context = useContext
|
|
102
|
+
const context = useContext(ChartContext) as UseChartValues<D, S, TM, AR, A>
|
|
162
103
|
const {chartId} = context
|
|
163
104
|
if (isNaN(chartId)) {
|
|
164
105
|
throw new Error("useChart can only be used when the parent is a <ChartProvider/>")
|