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,184 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
// the context is generic over the same type parameters as `UseAxesValues`, but a context
|
|
3
|
+
// object can't itself carry unbound generics -- `useAxes` below casts it back to the caller's
|
|
4
|
+
// concrete types, which is safe because `<AxesProvider/>` is what actually supplies the value
|
|
5
|
+
//
|
|
6
|
+
// IMPORTANT: as with `ChartContext` (see its identical note in useChart.tsx), this is NOT
|
|
7
|
+
// statically enforced across the component tree -- each consumer casts to its own hardcoded
|
|
8
|
+
// AR/A, independent of whatever `<AxesProvider<AR, A>>` ancestor actually supplied. A mismatched
|
|
9
|
+
// axis-range/axis kind only fails at runtime, not at compile time.
|
|
10
|
+
export const AxesContext = createContext(undefined);
|
|
6
11
|
/**
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
const noop = () => {
|
|
10
|
-
/* empty on purpose */
|
|
11
|
-
};
|
|
12
|
-
export const defaultAxesValues = () => ({
|
|
13
|
-
xAxesState: AxesState.empty(),
|
|
14
|
-
yAxesState: AxesState.empty(),
|
|
15
|
-
addXAxis: noop,
|
|
16
|
-
addYAxis: noop,
|
|
17
|
-
setAxisAssignments: noop,
|
|
18
|
-
axisAssignmentsFor: () => ({ xAxis: "", yAxis: "" }),
|
|
19
|
-
updateAxisRanges: noop,
|
|
20
|
-
axesRanges: () => new Map(),
|
|
21
|
-
axisRangeFor: () => Optional.empty(),
|
|
22
|
-
setAxesRanges: noop,
|
|
23
|
-
setAxisRangeFor: noop,
|
|
24
|
-
setAxisIntervalFor: noop,
|
|
25
|
-
setOriginalAxisIntervalFor: noop,
|
|
26
|
-
resetAxisIntervalFor: noop,
|
|
27
|
-
resetAxesRanges: noop,
|
|
28
|
-
addAxesRangesUpdateHandler: () => noop,
|
|
29
|
-
removeAxesRangesUpdateHandler: () => noop,
|
|
30
|
-
});
|
|
31
|
-
// the context for axes
|
|
32
|
-
const AxesContext = createContext(defaultAxesValues());
|
|
33
|
-
/**
|
|
34
|
-
* The React context provider for the {@link UseAxesValues}
|
|
35
|
-
* @param props The properties
|
|
36
|
-
* @return The children wrapped in this provider
|
|
37
|
-
*/
|
|
38
|
-
export default function AxesProvider(props) {
|
|
39
|
-
const { onUpdateAxesInterval, children } = props;
|
|
40
|
-
const plotDimensions = usePlotDimensions();
|
|
41
|
-
const xAxesStateRef = useRef(AxesState.empty());
|
|
42
|
-
const yAxesStateRef = useRef(AxesState.empty());
|
|
43
|
-
const axisAssignmentsRef = useRef(new Map());
|
|
44
|
-
const axesBoundsUpdateHandlersRef = useRef(new Map());
|
|
45
|
-
const axesRangeRef = useRef(new Map());
|
|
46
|
-
/**
|
|
47
|
-
* Retrieves the x-axis and y-axis assignments for the specified series. If the axis does not have
|
|
48
|
-
* an assignment, then we assume it is using the default x- and y-axes.
|
|
49
|
-
* @param seriesName The name of the series for which to retrieve the axes assignments
|
|
50
|
-
* @return An {@link AxesAssignment} for the specified axes.
|
|
51
|
-
*/
|
|
52
|
-
function axisAssignmentsFor(seriesName) {
|
|
53
|
-
return axisAssignmentsRef.current.get(seriesName) || {
|
|
54
|
-
xAxis: xAxesStateRef.current.axisDefaultId().getOrElse(""),
|
|
55
|
-
yAxis: yAxesStateRef.current.axisDefaultId().getOrElse("")
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Called when the domain/range is updated on one or more of the chart's axes (generally x-axes). In turn,
|
|
60
|
-
* dispatches the update to all the internal domain/range update handlers.
|
|
61
|
-
* @param updates A map holding the axis ID to the updated axis time-range (i.e., map(axis_id, axis_time_range))
|
|
62
|
-
*/
|
|
63
|
-
function updateAxisRanges(updates) {
|
|
64
|
-
// update the current time-ranges reference
|
|
65
|
-
updates.forEach((range, id) => {
|
|
66
|
-
axesRangeRef.current.set(id, range);
|
|
67
|
-
});
|
|
68
|
-
// dispatch the updates to all the registered handlers
|
|
69
|
-
axesBoundsUpdateHandlersRef.current
|
|
70
|
-
.forEach((handler) => handler(updates, plotDimensions.plotDimensions));
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Sets the axis ranges specified in the input map
|
|
74
|
-
* @param ranges The ranges to set
|
|
75
|
-
*/
|
|
76
|
-
function setAxesRanges(ranges) {
|
|
77
|
-
ranges.forEach((range, id) => {
|
|
78
|
-
axesRangeRef.current.set(id, range);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Sets the axis range for the specified axis ID
|
|
83
|
-
* @param axisId The axis ID
|
|
84
|
-
* @param range The range to set
|
|
85
|
-
*/
|
|
86
|
-
function setAxisRangeFor(axisId, range) {
|
|
87
|
-
axesRangeRef.current.set(axisId, range);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Sets the axis bounds for the specified axis ID. Note that this does not
|
|
91
|
-
* change the original axis interval
|
|
92
|
-
* @param axisId The axis ID
|
|
93
|
-
* @param interval The interval
|
|
94
|
-
*/
|
|
95
|
-
function setAxisIntervalFor(axisId, interval) {
|
|
96
|
-
Optional.ofNullable(axesRangeRef.current.get(axisId))
|
|
97
|
-
.map(range => range.update(interval.start, interval.end))
|
|
98
|
-
.ifPresent(updatedRange => axesRangeRef.current.set(axisId, updatedRange));
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Sets the original axis interval for the axis range
|
|
102
|
-
* @param axisId The axis ID
|
|
103
|
-
* @param interval The interval to which to set the origin interval
|
|
104
|
-
*/
|
|
105
|
-
function setOriginalAxisIntervalFor(axisId, interval) {
|
|
106
|
-
Optional.ofNullable(axesRangeRef.current.get(axisId))
|
|
107
|
-
.map(range => range.updateOriginal(interval.start, interval.end))
|
|
108
|
-
.ifPresent(updatedRange => axesRangeRef.current.set(axisId, updatedRange));
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Resets the bounds for the specified axis to the original range
|
|
112
|
-
* @param axisId The ID of the axis
|
|
113
|
-
*/
|
|
114
|
-
function resetAxisIntervalFor(axisId) {
|
|
115
|
-
Optional
|
|
116
|
-
.ofNullable(axesRangeRef.current.get(axisId))
|
|
117
|
-
.map(range => new Map([[axisId, range]]))
|
|
118
|
-
.ifPresent(updates => updateAxisRanges(updates));
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Resets the bounds of all the axes to their original value or to the values specified
|
|
122
|
-
* in the optional bounds map.
|
|
123
|
-
* @param [axesRanges=new Map()] An optional map holds bounds for specified axes. The map
|
|
124
|
-
* associates an axis ID with the new bounds.
|
|
125
|
-
*/
|
|
126
|
-
function resetAxesRanges(axesRanges = new Map()) {
|
|
127
|
-
updateAxisRanges(axesRanges);
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Adds a handler to deal with updates to the bounds of the axes
|
|
131
|
-
* @param handlerId the unique ID of the handler
|
|
132
|
-
* @param handler The handler function that accepts a map of updates and a plot dimension
|
|
133
|
-
* @return A map with all the handlers
|
|
134
|
-
*/
|
|
135
|
-
function addAxesRangesUpdateHandler(handlerId, handler) {
|
|
136
|
-
if (axesBoundsUpdateHandlersRef.current.has(handlerId)) {
|
|
137
|
-
throw new Error(`Handler with ID already exists, please remove it before adding it; ` +
|
|
138
|
-
`handler_id: ${handlerId}; ` +
|
|
139
|
-
`existing_handler_ids: [${Array.from(axesBoundsUpdateHandlersRef.current.keys()).join(", ")}]`);
|
|
140
|
-
}
|
|
141
|
-
return axesBoundsUpdateHandlersRef.current.set(handlerId, handler);
|
|
142
|
-
}
|
|
143
|
-
return _jsx(AxesContext.Provider, { value: {
|
|
144
|
-
xAxesState: xAxesStateRef.current,
|
|
145
|
-
yAxesState: yAxesStateRef.current,
|
|
146
|
-
addXAxis: (axis, id, range) => {
|
|
147
|
-
xAxesStateRef.current = xAxesStateRef.current.addAxis(axis, id);
|
|
148
|
-
if (range !== undefined) {
|
|
149
|
-
axesRangeRef.current.set(id, range);
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
addYAxis: (axis, id, range) => {
|
|
153
|
-
yAxesStateRef.current = yAxesStateRef.current.addAxis(axis, id);
|
|
154
|
-
if (range !== undefined) {
|
|
155
|
-
axesRangeRef.current.set(id, range);
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
setAxisAssignments: assignments => axisAssignmentsRef.current = assignments,
|
|
159
|
-
axisAssignmentsFor: seriesName => axisAssignmentsFor(seriesName),
|
|
160
|
-
updateAxisRanges,
|
|
161
|
-
axesRanges: () => new Map(axesRangeRef.current),
|
|
162
|
-
axisRangeFor: axisId => Optional.ofNullable(axesRangeRef.current.get(axisId)),
|
|
163
|
-
setAxesRanges,
|
|
164
|
-
setAxisRangeFor,
|
|
165
|
-
setAxisIntervalFor,
|
|
166
|
-
setOriginalAxisIntervalFor,
|
|
167
|
-
resetAxesRanges,
|
|
168
|
-
resetAxisIntervalFor,
|
|
169
|
-
onUpdateAxesInterval,
|
|
170
|
-
addAxesRangesUpdateHandler,
|
|
171
|
-
removeAxesRangesUpdateHandler: handlerId => axesBoundsUpdateHandlersRef.current.delete(handlerId),
|
|
172
|
-
}, children: children });
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* React hook that sets up the React context for the chart values.
|
|
12
|
+
* React hook for the chart's axes: their state, ranges, and the functions for updating them.
|
|
13
|
+
* Must be used within an {@link AxesProvider} (i.e. within a `<Chart>`).
|
|
176
14
|
* @return The {@link UseAxesValues} held in the React context.
|
|
15
|
+
* @throws Error when used outside an `<AxesProvider>`
|
|
16
|
+
* @template AR The type of the axis range (e.g. {@link ContinuousAxisRange} or {@link OrdinalAxisRange})
|
|
17
|
+
* @template A The axis type
|
|
177
18
|
*/
|
|
178
19
|
export function useAxes() {
|
|
179
20
|
const context = useContext(AxesContext);
|
|
180
|
-
|
|
181
|
-
if (xAxesState === undefined || xAxesState === null) {
|
|
21
|
+
if (context === undefined) {
|
|
182
22
|
throw new Error("useAxes can only be used when the parent is a <AxesProvider/>");
|
|
183
23
|
}
|
|
184
24
|
return context;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAxes.js","sourceRoot":"","sources":["../../../../src/app/charts/hooks/useAxes.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAxes.js","sourceRoot":"","sources":["../../../../src/app/charts/hooks/useAxes.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAC,aAAa,EAAE,UAAU,EAAC,MAAM,OAAO,CAAC;AAgJhD,yFAAyF;AACzF,8FAA8F;AAC9F,8FAA8F;AAC9F,EAAE;AACF,0FAA0F;AAC1F,4FAA4F;AAC5F,iGAAiG;AACjG,mEAAmE;AACnE,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAU,SAAS,CAAC,CAAA;AAE5D;;;;;;;GAOG;AACH,MAAM,UAAU,OAAO;IACnB,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,CAAA;IACvC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAA;IACpF,CAAC;IACD,OAAO,OAA+B,CAAA;AAC1C,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CanvasContext } from "../d3types";
|
|
2
|
+
/**
|
|
3
|
+
* The values exposed through the {@link useCanvasSurface} react hook.
|
|
4
|
+
*/
|
|
5
|
+
export type UseCanvasSurfaceValues = {
|
|
6
|
+
/**
|
|
7
|
+
* The `<canvas>` element backing the chart.
|
|
8
|
+
*/
|
|
9
|
+
canvas: HTMLCanvasElement | null;
|
|
10
|
+
/**
|
|
11
|
+
* The canvas drawing context and redraw-registration API for the chart.
|
|
12
|
+
*/
|
|
13
|
+
canvasContext: CanvasContext | null;
|
|
14
|
+
};
|
|
15
|
+
export declare const CanvasSurfaceContext: import("react").Context<UseCanvasSurfaceValues>;
|
|
16
|
+
/**
|
|
17
|
+
* React hook that reads the canvas element and canvas drawing context from context. This is set
|
|
18
|
+
* up by {@link CanvasSurfaceProvider}, which sizes the canvas from {@link usePlotDimensions} (the
|
|
19
|
+
* single source of truth for the chart's dimensions) rather than from static width/height props,
|
|
20
|
+
* so that the canvas stays correctly sized even if dimensions change via
|
|
21
|
+
* `usePlotDimensions().updateDimensions(...)` independent of any prop.
|
|
22
|
+
* @return The {@link UseCanvasSurfaceValues} held in the React context.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useCanvasSurface(): UseCanvasSurfaceValues;
|
|
25
|
+
//# sourceMappingURL=useCanvasSurface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCanvasSurface.d.ts","sourceRoot":"","sources":["../../../../src/app/charts/hooks/useCanvasSurface.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACjC;;OAEG;IACH,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAChC;;OAEG;IACH,aAAa,EAAE,aAAa,GAAG,IAAI,CAAA;CACtC,CAAA;AAOD,eAAO,MAAM,oBAAoB,iDAAoE,CAAA;AAErG;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,CAEzD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
const defaultCanvasSurfaceValues = {
|
|
3
|
+
canvas: null,
|
|
4
|
+
canvasContext: null,
|
|
5
|
+
};
|
|
6
|
+
export const CanvasSurfaceContext = createContext(defaultCanvasSurfaceValues);
|
|
7
|
+
/**
|
|
8
|
+
* React hook that reads the canvas element and canvas drawing context from context. This is set
|
|
9
|
+
* up by {@link CanvasSurfaceProvider}, which sizes the canvas from {@link usePlotDimensions} (the
|
|
10
|
+
* single source of truth for the chart's dimensions) rather than from static width/height props,
|
|
11
|
+
* so that the canvas stays correctly sized even if dimensions change via
|
|
12
|
+
* `usePlotDimensions().updateDimensions(...)` independent of any prop.
|
|
13
|
+
* @return The {@link UseCanvasSurfaceValues} held in the React context.
|
|
14
|
+
*/
|
|
15
|
+
export function useCanvasSurface() {
|
|
16
|
+
return useContext(CanvasSurfaceContext);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=useCanvasSurface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCanvasSurface.js","sourceRoot":"","sources":["../../../../src/app/charts/hooks/useCanvasSurface.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,UAAU,EAAC,MAAM,OAAO,CAAC;AAiBhD,MAAM,0BAA0B,GAA2B;IACvD,MAAM,EAAE,IAAI;IACZ,aAAa,EAAE,IAAI;CACtB,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAyB,0BAA0B,CAAC,CAAA;AAErG;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB;IAC5B,OAAO,UAAU,CAAC,oBAAoB,CAAC,CAAA;AAC3C,CAAC"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { UseTooltipValues } from "./useTooltip";
|
|
7
|
-
import { SvgStyle } from "../styling/svgStyle";
|
|
1
|
+
import type { CanvasContext } from "../d3types";
|
|
2
|
+
import type { BaseAxis, SeriesStyle } from "../axes/axes";
|
|
3
|
+
import { type UseAxesValues } from "./useAxes";
|
|
4
|
+
import { type UseMouseValues } from "./useMouse";
|
|
5
|
+
import { type UseTooltipValues } from "./useTooltip";
|
|
8
6
|
import { BaseAxisRange } from "../axes/BaseAxisRange";
|
|
9
|
-
export type NoTooltipMetadata =
|
|
7
|
+
export type NoTooltipMetadata = object;
|
|
10
8
|
/**
|
|
11
9
|
* The values exposed through the {@link useChart} react hook
|
|
12
10
|
* @param chartId The unique ID for the chart
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
11
|
+
* @param canvasContext The canvas drawing context and redraw-registration API for the chart
|
|
12
|
+
* @param canvas The `<canvas>` element which is the container for this chart
|
|
15
13
|
* @template D The type of the series' datum
|
|
16
14
|
* @template S The type of the series style
|
|
17
15
|
* @template TM The type of the tooltip's metadata (data about the series data)
|
|
16
|
+
* @template AR The type of the axis range
|
|
17
|
+
* @template A The type of the axis
|
|
18
18
|
*/
|
|
19
19
|
export interface UseChartValues<D, S extends SeriesStyle, TM, AR extends BaseAxisRange, A extends BaseAxis> {
|
|
20
20
|
/**
|
|
@@ -22,62 +22,48 @@ export interface UseChartValues<D, S extends SeriesStyle, TM, AR extends BaseAxi
|
|
|
22
22
|
*/
|
|
23
23
|
chartId: number;
|
|
24
24
|
/**
|
|
25
|
-
* The
|
|
25
|
+
* The canvas drawing context and redraw-registration API for the chart. Axes, plots, and the
|
|
26
|
+
* tracker register a draw function here (via `canvasContext.register(id, drawFn, zIndex)`)
|
|
27
|
+
* instead of creating/updating SVG elements. Replaces the old `mainG`.
|
|
26
28
|
*/
|
|
27
|
-
|
|
29
|
+
canvasContext: CanvasContext | null;
|
|
28
30
|
/**
|
|
29
|
-
* The
|
|
31
|
+
* The `<canvas>` element which is the container for this chart. Replaces the old `container`
|
|
32
|
+
* (root `<svg>` element).
|
|
30
33
|
*/
|
|
31
|
-
|
|
34
|
+
canvas: HTMLCanvasElement | null;
|
|
32
35
|
/**
|
|
33
36
|
* Base color
|
|
34
37
|
*/
|
|
35
38
|
color: string;
|
|
36
39
|
/**
|
|
37
|
-
* The base/default background color. This can be overridden by the {@link
|
|
40
|
+
* The base/default background color. This can be overridden by the {@link ChartProps.svgStyle} property.
|
|
38
41
|
*/
|
|
39
42
|
backgroundColor: string;
|
|
40
|
-
/**
|
|
41
|
-
* Overrides for the SVG style
|
|
42
|
-
*/
|
|
43
|
-
svgStyle: Partial<SvgStyle>;
|
|
44
43
|
/**
|
|
45
44
|
* A `map(series_name -> series_line_style)`
|
|
46
45
|
*/
|
|
47
46
|
seriesStyles: Map<string, S>;
|
|
48
47
|
axes: UseAxesValues<AR, A>;
|
|
49
48
|
/**
|
|
50
|
-
* A regular expression
|
|
49
|
+
* A regular expression used against the series names to determine which series to show in the chart
|
|
51
50
|
*/
|
|
52
51
|
seriesFilter: RegExp;
|
|
53
52
|
mouse: UseMouseValues<D, TM>;
|
|
54
53
|
tooltip: UseTooltipValues<D, TM>;
|
|
55
|
-
/**
|
|
56
|
-
* Ref tracking the currently-hovered series name (null when nothing is hovered).
|
|
57
|
-
* Updated by the Legend; read by plots so new path elements use the correct stroke.
|
|
58
|
-
*/
|
|
59
|
-
hoveredSeriesRef: MutableRefObject<string | null>;
|
|
60
54
|
}
|
|
61
|
-
export
|
|
62
|
-
chartId: number;
|
|
63
|
-
container: SVGSVGElement | null;
|
|
64
|
-
mainG: GSelection | null;
|
|
65
|
-
color: string;
|
|
66
|
-
backgroundColor: string;
|
|
67
|
-
svgStyle: Partial<SvgStyle>;
|
|
68
|
-
seriesStyles?: Map<string, SeriesLineStyle>;
|
|
69
|
-
seriesFilter?: RegExp;
|
|
70
|
-
hoveredSeriesRef: MutableRefObject<string | null>;
|
|
71
|
-
children: JSX.Element | Array<JSX.Element>;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* The React context provider for the {@link UseChartValues}
|
|
75
|
-
* @param props The properties
|
|
76
|
-
* @return The children wrapped in this provider
|
|
77
|
-
*/
|
|
78
|
-
export default function ChartProvider(props: Props): JSX.Element;
|
|
55
|
+
export declare const ChartContext: import("react").Context<unknown>;
|
|
79
56
|
/**
|
|
80
|
-
* React hook
|
|
57
|
+
* React hook for the chart's values: its ID, canvas, colors, styles, axes, mouse and tooltip
|
|
58
|
+
* handlers, and highlighted series. Must be used within a `ChartProvider` (i.e. within a
|
|
59
|
+
* `<Chart>`).
|
|
81
60
|
* @return The {@link UseChartValues} held in the React context.
|
|
61
|
+
* @throws Error when used outside a `<ChartProvider>`
|
|
62
|
+
* @template D The type of the series' datum
|
|
63
|
+
* @template S The type of the series style
|
|
64
|
+
* @template TM The type of the tooltip's metadata (data about the series data)
|
|
65
|
+
* @template AR The type of the axis range
|
|
66
|
+
* @template A The type of the axis
|
|
82
67
|
*/
|
|
83
68
|
export declare function useChart<D, S extends SeriesStyle, TM, AR extends BaseAxisRange, A extends BaseAxis>(): UseChartValues<D, S, TM, AR, A>;
|
|
69
|
+
//# sourceMappingURL=useChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChart.d.ts","sourceRoot":"","sources":["../../../../src/app/charts/hooks/useChart.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAC,QAAQ,EAAE,WAAW,EAAC,MAAM,cAAc,CAAC;AACxD,OAAO,EAAC,KAAK,aAAa,EAAC,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAC,KAAK,cAAc,EAAC,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAC,KAAK,gBAAgB,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AAGpD,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAA;AAEtC;;;;;;;;;;GAUG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,EAAE,EAAE,EAAE,EAAE,SAAS,aAAa,EAAE,CAAC,SAAS,QAAQ;IACtG;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;;;OAIG;IACH,aAAa,EAAE,aAAa,GAAG,IAAI,CAAA;IACnC;;;OAGG;IACH,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAChC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IAK5B,IAAI,EAAE,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;IAK1B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IAKpB,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAC5B,OAAO,EAAE,gBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;CACnC;AAiBD,eAAO,MAAM,YAAY,kCAAkD,CAAA;AAE3E;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,EAAE,EAAE,EAAE,EAAE,SAAS,aAAa,EAAE,CAAC,SAAS,QAAQ,KAAK,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAOtI"}
|
|
@@ -1,54 +1,32 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
import { createContext, useContext } from "react";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
tooltip: defaultTooltipValues(),
|
|
21
|
-
hoveredSeriesRef: { current: null },
|
|
22
|
-
};
|
|
23
|
-
const ChartContext = createContext(defaultUseChartValues);
|
|
2
|
+
import { defaultUseChartValues } from "./defaultUseChartValues";
|
|
3
|
+
// the context is generic over the same type parameters as `UseChartValues`, but a context
|
|
4
|
+
// object can't itself carry unbound generics -- `useChart` below casts it back to the caller's
|
|
5
|
+
// concrete types, which is safe because `<ChartProvider/>` is what actually supplies the value
|
|
6
|
+
//
|
|
7
|
+
// IMPORTANT: this is NOT statically enforced across the component tree. `<Chart<CD, D, S, TM, AR,
|
|
8
|
+
// A>>`'s AR/A are never referenced by its own Props type, so they can't even be inferred from
|
|
9
|
+
// JSX; and every descendant (each axis component) calls `useChart<...>()` with its OWN hardcoded
|
|
10
|
+
// generic arguments, entirely independent of whatever the ancestor `<Chart<...>>` was
|
|
11
|
+
// instantiated with. Nothing at the type level stops e.g. a `<Chart<..., ContinuousAxisRange,
|
|
12
|
+
// ContinuousNumericAxis>>` from having an `<OrdinalAxis>` child that casts this same context to
|
|
13
|
+
// `UseChartValues<..., OrdinalAxisRange, OrdinalStringAxis>` internally -- a real mismatch here
|
|
14
|
+
// only fails at runtime (a bad cast surfacing as a confusing error deeper in axis/plot code), not
|
|
15
|
+
// at compile time. Making this a real compile-time guarantee would need a per-instantiation-typed
|
|
16
|
+
// context (e.g. a context factory called once per concrete AR/A pairing) -- a broader refactor
|
|
17
|
+
// than the type parameters alone might suggest, and not something to casually "fix" locally.
|
|
18
|
+
export const ChartContext = createContext(defaultUseChartValues());
|
|
24
19
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
export default function ChartProvider(props) {
|
|
30
|
-
const { chartId, container, mainG, color, backgroundColor, seriesFilter = defaultUseChartValues.seriesFilter, svgStyle, seriesStyles = new Map(), hoveredSeriesRef, } = props;
|
|
31
|
-
const axes = useAxes();
|
|
32
|
-
const mouse = useMouse();
|
|
33
|
-
const tooltip = useTooltip();
|
|
34
|
-
return _jsx(ChartContext.Provider, { value: {
|
|
35
|
-
chartId,
|
|
36
|
-
color,
|
|
37
|
-
backgroundColor,
|
|
38
|
-
svgStyle,
|
|
39
|
-
seriesStyles,
|
|
40
|
-
seriesFilter,
|
|
41
|
-
mainG,
|
|
42
|
-
container,
|
|
43
|
-
axes,
|
|
44
|
-
mouse,
|
|
45
|
-
tooltip,
|
|
46
|
-
hoveredSeriesRef,
|
|
47
|
-
}, children: props.children });
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* React hook that sets up the React context for the chart values.
|
|
20
|
+
* React hook for the chart's values: its ID, canvas, colors, styles, axes, mouse and tooltip
|
|
21
|
+
* handlers, and highlighted series. Must be used within a `ChartProvider` (i.e. within a
|
|
22
|
+
* `<Chart>`).
|
|
51
23
|
* @return The {@link UseChartValues} held in the React context.
|
|
24
|
+
* @throws Error when used outside a `<ChartProvider>`
|
|
25
|
+
* @template D The type of the series' datum
|
|
26
|
+
* @template S The type of the series style
|
|
27
|
+
* @template TM The type of the tooltip's metadata (data about the series data)
|
|
28
|
+
* @template AR The type of the axis range
|
|
29
|
+
* @template A The type of the axis
|
|
52
30
|
*/
|
|
53
31
|
export function useChart() {
|
|
54
32
|
const context = useContext(ChartContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChart.js","sourceRoot":"","sources":["../../../../src/app/charts/hooks/useChart.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useChart.js","sourceRoot":"","sources":["../../../../src/app/charts/hooks/useChart.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,UAAU,EAAC,MAAM,OAAO,CAAC;AAOhD,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAgE9D,0FAA0F;AAC1F,+FAA+F;AAC/F,+FAA+F;AAC/F,EAAE;AACF,kGAAkG;AAClG,8FAA8F;AAC9F,iGAAiG;AACjG,sFAAsF;AACtF,8FAA8F;AAC9F,gGAAgG;AAChG,gGAAgG;AAChG,kGAAkG;AAClG,kGAAkG;AAClG,+FAA+F;AAC/F,6FAA6F;AAC7F,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAU,qBAAqB,EAAE,CAAC,CAAA;AAE3E;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,QAAQ;IACpB,MAAM,OAAO,GAAG,UAAU,CAAC,YAAY,CAAoC,CAAA;IAC3E,MAAM,EAAC,OAAO,EAAC,GAAG,OAAO,CAAA;IACzB,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAA;IACtF,CAAC;IACD,OAAO,OAAO,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ChartData } from "../observables/ChartData";
|
|
2
|
+
import type { BaseSeries } from "../series/baseSeries";
|
|
3
|
+
import type { StreamingDataSource } from "../datasources/StreamingDataSource";
|
|
4
|
+
/**
|
|
5
|
+
* The chart's data: its data source, the series the source held when it was handed to the chart,
|
|
6
|
+
* and the chart's streaming settings and callbacks
|
|
7
|
+
* @template CD The type of the chart data
|
|
8
|
+
* @template D The type of datum held in each series
|
|
9
|
+
* @template S The type of series
|
|
10
|
+
*/
|
|
11
|
+
export interface ChartDataValues<CD extends ChartData, D, S extends BaseSeries<D> = BaseSeries<D>> {
|
|
12
|
+
/**
|
|
13
|
+
* The data source handed to the chart (its `dataSource` prop)
|
|
14
|
+
*/
|
|
15
|
+
dataSource: StreamingDataSource<CD, D, S>;
|
|
16
|
+
/**
|
|
17
|
+
* The series the data source held when it was handed to the chart (a new data source means
|
|
18
|
+
* new initial data, so plots keyed on it reset)
|
|
19
|
+
*/
|
|
20
|
+
initialData: Array<S>;
|
|
21
|
+
/**
|
|
22
|
+
* The time (ms) over which incoming data is batched before the plot redraws
|
|
23
|
+
*/
|
|
24
|
+
windowingTime: number;
|
|
25
|
+
/**
|
|
26
|
+
* The period (ms) at which the data source's generator emits new data, when known. When
|
|
27
|
+
* provided, batching switches from wall-clock-based to a fixed tick count derived from
|
|
28
|
+
* `windowingTime / dataUpdatePeriod` (see the view drivers in `subscriptions/viewDrivers.ts`).
|
|
29
|
+
*/
|
|
30
|
+
dataUpdatePeriod?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Called when the chart time is updated (e.g. by plots whose axes aren't time)
|
|
33
|
+
* @param time The new chart time
|
|
34
|
+
*/
|
|
35
|
+
onUpdateChartTime: (time: number) => void;
|
|
36
|
+
}
|
|
37
|
+
export declare const ChartDataContext: import("react").Context<unknown>;
|
|
38
|
+
/**
|
|
39
|
+
* @return The {@link StreamingDataSource} handed to the enclosing {@link Chart} through its
|
|
40
|
+
* `dataSource` prop (`undefined` only outside of a chart)
|
|
41
|
+
* @template CD The type of the chart data
|
|
42
|
+
* @template D The type of datum held in each series
|
|
43
|
+
* @template S The type of series
|
|
44
|
+
*/
|
|
45
|
+
export declare function useDataSource<CD extends ChartData, D, S extends BaseSeries<D> = BaseSeries<D>>(): StreamingDataSource<CD, D, S> | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* @return The series the chart's data source held when it was handed to the chart (for
|
|
48
|
+
* components that need the set of series up front, e.g. the legend, or a plot resetting itself
|
|
49
|
+
* for new data)
|
|
50
|
+
* @throws Error when used outside a `<Chart>`
|
|
51
|
+
* @template D The type of the datum held in each series
|
|
52
|
+
*/
|
|
53
|
+
export declare function useInitialData<D>(): {
|
|
54
|
+
initialData: Array<BaseSeries<D>>;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* @return The chart's streaming settings (how updates are batched for rendering) and callbacks
|
|
58
|
+
* @throws Error when used outside a `<Chart>`
|
|
59
|
+
*/
|
|
60
|
+
export declare function useStreamingSettings(): Pick<ChartDataValues<ChartData, unknown>, 'windowingTime' | 'dataUpdatePeriod' | 'onUpdateChartTime'>;
|
|
61
|
+
/**
|
|
62
|
+
* Subscribes the calling component to the data source's running state, so it re-renders when the
|
|
63
|
+
* source starts or stops (e.g. to switch the zoom pivot, or hide markers while running).
|
|
64
|
+
* @param dataSource The data source, or `undefined` (in which case this is always `false`)
|
|
65
|
+
* @return Whether the data source is currently running
|
|
66
|
+
*/
|
|
67
|
+
export declare function useDataSourceRunning<CD extends ChartData, D>(dataSource: StreamingDataSource<CD, D> | undefined): boolean;
|
|
68
|
+
//# sourceMappingURL=useDataSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDataSource.d.ts","sourceRoot":"","sources":["../../../../src/app/charts/hooks/useDataSource.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,oCAAoC,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,WAAW,eAAe,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAC7F;;OAEG;IACH,UAAU,EAAE,mBAAmB,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IACzC;;;OAGG;IACH,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,CAAA;IACrB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;;OAGG;IACH,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAC5C;AAKD,eAAO,MAAM,gBAAgB,kCAAoC,CAAA;AAcjE;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,mBAAmB,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAE3I;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,KAAK;IAAC,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;CAAC,CAGvE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,kBAAkB,GAAG,mBAAmB,CAAC,CAG5I;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,mBAAmB,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,SAAS,GAAG,OAAO,CAWzH"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createContext, useCallback, useContext, useSyncExternalStore } from "react";
|
|
2
|
+
// the context is generic over the same type parameters as `ChartDataValues`, but a context object
|
|
3
|
+
// can't itself carry unbound generics -- the hooks below cast it back to the caller's concrete
|
|
4
|
+
// types, which is safe because `<Chart/>` is what actually supplies the value
|
|
5
|
+
export const ChartDataContext = createContext(undefined);
|
|
6
|
+
/**
|
|
7
|
+
* @return The chart's data, and its streaming settings
|
|
8
|
+
* @throws Error when used outside a `<Chart>`
|
|
9
|
+
*/
|
|
10
|
+
function useChartData() {
|
|
11
|
+
const context = useContext(ChartDataContext);
|
|
12
|
+
if (context === undefined) {
|
|
13
|
+
throw new Error("The chart's data can only be used within a <Chart/>");
|
|
14
|
+
}
|
|
15
|
+
return context;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @return The {@link StreamingDataSource} handed to the enclosing {@link Chart} through its
|
|
19
|
+
* `dataSource` prop (`undefined` only outside of a chart)
|
|
20
|
+
* @template CD The type of the chart data
|
|
21
|
+
* @template D The type of datum held in each series
|
|
22
|
+
* @template S The type of series
|
|
23
|
+
*/
|
|
24
|
+
export function useDataSource() {
|
|
25
|
+
var _a;
|
|
26
|
+
return (_a = useContext(ChartDataContext)) === null || _a === void 0 ? void 0 : _a.dataSource;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @return The series the chart's data source held when it was handed to the chart (for
|
|
30
|
+
* components that need the set of series up front, e.g. the legend, or a plot resetting itself
|
|
31
|
+
* for new data)
|
|
32
|
+
* @throws Error when used outside a `<Chart>`
|
|
33
|
+
* @template D The type of the datum held in each series
|
|
34
|
+
*/
|
|
35
|
+
export function useInitialData() {
|
|
36
|
+
const { initialData } = useChartData();
|
|
37
|
+
return { initialData };
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @return The chart's streaming settings (how updates are batched for rendering) and callbacks
|
|
41
|
+
* @throws Error when used outside a `<Chart>`
|
|
42
|
+
*/
|
|
43
|
+
export function useStreamingSettings() {
|
|
44
|
+
const { windowingTime, dataUpdatePeriod, onUpdateChartTime } = useChartData();
|
|
45
|
+
return { windowingTime, dataUpdatePeriod, onUpdateChartTime };
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Subscribes the calling component to the data source's running state, so it re-renders when the
|
|
49
|
+
* source starts or stops (e.g. to switch the zoom pivot, or hide markers while running).
|
|
50
|
+
* @param dataSource The data source, or `undefined` (in which case this is always `false`)
|
|
51
|
+
* @return Whether the data source is currently running
|
|
52
|
+
*/
|
|
53
|
+
export function useDataSourceRunning(dataSource) {
|
|
54
|
+
const subscribe = useCallback((onChange) => {
|
|
55
|
+
if (dataSource === undefined)
|
|
56
|
+
return () => {
|
|
57
|
+
};
|
|
58
|
+
const subscription = dataSource.isRunningObservable.subscribe(() => onChange());
|
|
59
|
+
return () => subscription.unsubscribe();
|
|
60
|
+
}, [dataSource]);
|
|
61
|
+
return useSyncExternalStore(subscribe, () => { var _a; return (_a = dataSource === null || dataSource === void 0 ? void 0 : dataSource.running) !== null && _a !== void 0 ? _a : false; });
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=useDataSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDataSource.js","sourceRoot":"","sources":["../../../../src/app/charts/hooks/useDataSource.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,oBAAoB,EAAC,MAAM,OAAO,CAAC;AAuCnF,kGAAkG;AAClG,+FAA+F;AAC/F,8EAA8E;AAC9E,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAU,SAAS,CAAC,CAAA;AAEjE;;;GAGG;AACH,SAAS,YAAY;IACjB,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAA;IAC5C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAA;IAC1E,CAAC;IACD,OAAO,OAAoC,CAAA;AAC/C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa;;IACzB,OAAO,MAAC,UAAU,CAAC,gBAAgB,CAA2C,0CAAE,UAAU,CAAA;AAC9F,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc;IAC1B,MAAM,EAAC,WAAW,EAAC,GAAG,YAAY,EAA+B,CAAA;IACjE,OAAO,EAAC,WAAW,EAAC,CAAA;AACxB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IAChC,MAAM,EAAC,aAAa,EAAE,gBAAgB,EAAE,iBAAiB,EAAC,GAAG,YAAY,EAA2C,CAAA;IACpH,OAAO,EAAC,aAAa,EAAE,gBAAgB,EAAE,iBAAiB,EAAC,CAAA;AAC/D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAA0B,UAAkD;IAC5G,MAAM,SAAS,GAAG,WAAW,CACzB,CAAC,QAAoB,EAAgB,EAAE;QACnC,IAAI,UAAU,KAAK,SAAS;YAAE,OAAO,GAAG,EAAE;YAC1C,CAAC,CAAA;QACD,MAAM,YAAY,GAAG,UAAU,CAAC,mBAAmB,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAA;QAC/E,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,CAAA;IAC3C,CAAC,EACD,CAAC,UAAU,CAAC,CACf,CAAA;IACD,OAAO,oBAAoB,CAAC,SAAS,EAAE,GAAG,EAAE,WAAC,OAAA,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,OAAO,mCAAI,KAAK,CAAA,EAAA,CAAC,CAAA;AAC9E,CAAC"}
|