stream-charts 1.2.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +809 -1022
- package/changes.md +36 -0
- package/dist/app/charts/Chart.d.ts +35 -139
- package/dist/app/charts/Chart.d.ts.map +1 -0
- package/dist/app/charts/Chart.js +74 -65
- package/dist/app/charts/Chart.js.map +1 -1
- package/dist/app/charts/axes/AxesState.d.ts +26 -18
- package/dist/app/charts/axes/AxesState.d.ts.map +1 -0
- package/dist/app/charts/axes/AxesState.js +26 -24
- package/dist/app/charts/axes/AxesState.js.map +1 -1
- package/dist/app/charts/axes/AxisInterval.d.ts +44 -26
- package/dist/app/charts/axes/AxisInterval.d.ts.map +1 -0
- package/dist/app/charts/axes/AxisInterval.js +48 -29
- package/dist/app/charts/axes/AxisInterval.js.map +1 -1
- package/dist/app/charts/axes/BaseAxisRange.d.ts +46 -22
- package/dist/app/charts/axes/BaseAxisRange.d.ts.map +1 -0
- package/dist/app/charts/axes/BaseAxisRange.js +17 -12
- package/dist/app/charts/axes/BaseAxisRange.js.map +1 -1
- package/dist/app/charts/axes/ContinuousAxis.d.ts +47 -6
- package/dist/app/charts/axes/ContinuousAxis.d.ts.map +1 -0
- package/dist/app/charts/axes/ContinuousAxis.js +160 -27
- package/dist/app/charts/axes/ContinuousAxis.js.map +1 -1
- package/dist/app/charts/axes/ContinuousAxisRange.d.ts +29 -10
- package/dist/app/charts/axes/ContinuousAxisRange.d.ts.map +1 -0
- package/dist/app/charts/axes/ContinuousAxisRange.js +29 -11
- package/dist/app/charts/axes/ContinuousAxisRange.js.map +1 -1
- package/dist/app/charts/axes/EmptyAxis.d.ts +5 -2
- package/dist/app/charts/axes/EmptyAxis.d.ts.map +1 -0
- package/dist/app/charts/axes/EmptyAxis.js +30 -9
- package/dist/app/charts/axes/EmptyAxis.js.map +1 -1
- package/dist/app/charts/axes/OrdinalAxis.d.ts +5 -3
- package/dist/app/charts/axes/OrdinalAxis.d.ts.map +1 -0
- package/dist/app/charts/axes/OrdinalAxis.js +39 -16
- package/dist/app/charts/axes/OrdinalAxis.js.map +1 -1
- package/dist/app/charts/axes/OrdinalAxisRange.d.ts +76 -13
- package/dist/app/charts/axes/OrdinalAxisRange.d.ts.map +1 -0
- package/dist/app/charts/axes/OrdinalAxisRange.js +95 -16
- package/dist/app/charts/axes/OrdinalAxisRange.js.map +1 -1
- package/dist/app/charts/axes/autoScale.d.ts +111 -0
- package/dist/app/charts/axes/autoScale.d.ts.map +1 -0
- package/dist/app/charts/axes/autoScale.js +188 -0
- package/dist/app/charts/axes/autoScale.js.map +1 -0
- package/dist/app/charts/axes/axes.d.ts +273 -150
- package/dist/app/charts/axes/axes.d.ts.map +1 -0
- package/dist/app/charts/axes/axes.js +808 -583
- package/dist/app/charts/axes/axes.js.map +1 -1
- package/dist/app/charts/d3types.d.ts +40 -11
- package/dist/app/charts/d3types.d.ts.map +1 -0
- package/dist/app/charts/d3types.js +3 -0
- package/dist/app/charts/d3types.js.map +1 -1
- package/dist/app/charts/datasources/StreamingDataSource.d.ts +149 -0
- package/dist/app/charts/datasources/StreamingDataSource.d.ts.map +1 -0
- package/dist/app/charts/datasources/StreamingDataSource.js +110 -0
- package/dist/app/charts/datasources/StreamingDataSource.js.map +1 -0
- package/dist/app/charts/datasources/iteratesDataSource.d.ts +73 -0
- package/dist/app/charts/datasources/iteratesDataSource.d.ts.map +1 -0
- package/dist/app/charts/datasources/iteratesDataSource.js +87 -0
- package/dist/app/charts/datasources/iteratesDataSource.js.map +1 -0
- package/dist/app/charts/datasources/ordinalDataSource.d.ts +75 -0
- package/dist/app/charts/datasources/ordinalDataSource.d.ts.map +1 -0
- package/dist/app/charts/datasources/ordinalDataSource.js +135 -0
- package/dist/app/charts/datasources/ordinalDataSource.js.map +1 -0
- package/dist/app/charts/datasources/outlierDataSource.d.ts +53 -0
- package/dist/app/charts/datasources/outlierDataSource.d.ts.map +1 -0
- package/dist/app/charts/datasources/outlierDataSource.js +57 -0
- package/dist/app/charts/datasources/outlierDataSource.js.map +1 -0
- package/dist/app/charts/datasources/timeSeriesDataSource.d.ts +77 -0
- package/dist/app/charts/datasources/timeSeriesDataSource.d.ts.map +1 -0
- package/dist/app/charts/datasources/timeSeriesDataSource.js +85 -0
- package/dist/app/charts/datasources/timeSeriesDataSource.js.map +1 -0
- package/dist/app/charts/filters/regexFilter.d.ts +31 -4
- package/dist/app/charts/filters/regexFilter.d.ts.map +1 -0
- package/dist/app/charts/filters/regexFilter.js +38 -4
- package/dist/app/charts/filters/regexFilter.js.map +1 -1
- package/dist/app/charts/hooks/AxesProvider.d.ts +21 -0
- package/dist/app/charts/hooks/AxesProvider.d.ts.map +1 -0
- package/dist/app/charts/hooks/AxesProvider.js +213 -0
- package/dist/app/charts/hooks/AxesProvider.js.map +1 -0
- package/dist/app/charts/hooks/CanvasSurfaceProvider.d.ts +25 -0
- package/dist/app/charts/hooks/CanvasSurfaceProvider.d.ts.map +1 -0
- package/dist/app/charts/hooks/CanvasSurfaceProvider.js +76 -0
- package/dist/app/charts/hooks/CanvasSurfaceProvider.js.map +1 -0
- package/dist/app/charts/hooks/ChartProvider.d.ts +40 -0
- package/dist/app/charts/hooks/ChartProvider.d.ts.map +1 -0
- package/dist/app/charts/hooks/ChartProvider.js +33 -0
- package/dist/app/charts/hooks/ChartProvider.js.map +1 -0
- package/dist/app/charts/hooks/InteractionProvider.d.ts +23 -0
- package/dist/app/charts/hooks/InteractionProvider.d.ts.map +1 -0
- package/dist/app/charts/hooks/InteractionProvider.js +60 -0
- package/dist/app/charts/hooks/InteractionProvider.js.map +1 -0
- package/dist/app/charts/hooks/PlotDimensionsProvider.d.ts +16 -0
- package/dist/app/charts/hooks/PlotDimensionsProvider.d.ts.map +1 -0
- package/dist/app/charts/hooks/PlotDimensionsProvider.js +76 -0
- package/dist/app/charts/hooks/PlotDimensionsProvider.js.map +1 -0
- package/dist/app/charts/hooks/defaultAxesValues.d.ts +11 -0
- package/dist/app/charts/hooks/defaultAxesValues.d.ts.map +1 -0
- package/dist/app/charts/hooks/defaultAxesValues.js +36 -0
- package/dist/app/charts/hooks/defaultAxesValues.js.map +1 -0
- package/dist/app/charts/hooks/defaultMouseValues.d.ts +9 -0
- package/dist/app/charts/hooks/defaultMouseValues.d.ts.map +1 -0
- package/dist/app/charts/hooks/defaultMouseValues.js +23 -0
- package/dist/app/charts/hooks/defaultMouseValues.js.map +1 -0
- package/dist/app/charts/hooks/defaultPlotDimensions.d.ts +13 -0
- package/dist/app/charts/hooks/defaultPlotDimensions.d.ts.map +1 -0
- package/dist/app/charts/hooks/defaultPlotDimensions.js +23 -0
- package/dist/app/charts/hooks/defaultPlotDimensions.js.map +1 -0
- package/dist/app/charts/hooks/defaultTooltipValues.d.ts +9 -0
- package/dist/app/charts/hooks/defaultTooltipValues.d.ts.map +1 -0
- package/dist/app/charts/hooks/defaultTooltipValues.js +21 -0
- package/dist/app/charts/hooks/defaultTooltipValues.js.map +1 -0
- package/dist/app/charts/hooks/defaultUseChartValues.d.ts +14 -0
- package/dist/app/charts/hooks/defaultUseChartValues.d.ts.map +1 -0
- package/dist/app/charts/hooks/defaultUseChartValues.js +30 -0
- package/dist/app/charts/hooks/defaultUseChartValues.js.map +1 -0
- package/dist/app/charts/hooks/useAxes.d.ts +49 -36
- package/dist/app/charts/hooks/useAxes.d.ts.map +1 -0
- package/dist/app/charts/hooks/useAxes.js +16 -176
- package/dist/app/charts/hooks/useAxes.js.map +1 -1
- package/dist/app/charts/hooks/useCanvasSurface.d.ts +25 -0
- package/dist/app/charts/hooks/useCanvasSurface.d.ts.map +1 -0
- package/dist/app/charts/hooks/useCanvasSurface.js +18 -0
- package/dist/app/charts/hooks/useCanvasSurface.js.map +1 -0
- package/dist/app/charts/hooks/useChart.d.ts +30 -44
- package/dist/app/charts/hooks/useChart.d.ts.map +1 -0
- package/dist/app/charts/hooks/useChart.js +26 -48
- package/dist/app/charts/hooks/useChart.js.map +1 -1
- package/dist/app/charts/hooks/useDataSource.d.ts +68 -0
- package/dist/app/charts/hooks/useDataSource.d.ts.map +1 -0
- package/dist/app/charts/hooks/useDataSource.js +63 -0
- package/dist/app/charts/hooks/useDataSource.js.map +1 -0
- package/dist/app/charts/hooks/useHoveredSeries.d.ts +25 -0
- package/dist/app/charts/hooks/useHoveredSeries.d.ts.map +1 -0
- package/dist/app/charts/hooks/useHoveredSeries.js +15 -0
- package/dist/app/charts/hooks/useHoveredSeries.js.map +1 -0
- package/dist/app/charts/hooks/useMouse.d.ts +46 -22
- package/dist/app/charts/hooks/useMouse.d.ts.map +1 -0
- package/dist/app/charts/hooks/useMouse.js +12 -56
- package/dist/app/charts/hooks/useMouse.js.map +1 -1
- package/dist/app/charts/hooks/usePlotDimensions.d.ts +25 -13
- package/dist/app/charts/hooks/usePlotDimensions.d.ts.map +1 -0
- package/dist/app/charts/hooks/usePlotDimensions.js +6 -62
- package/dist/app/charts/hooks/usePlotDimensions.js.map +1 -1
- package/dist/app/charts/hooks/useTooltip.d.ts +24 -26
- package/dist/app/charts/hooks/useTooltip.d.ts.map +1 -0
- package/dist/app/charts/hooks/useTooltip.js +12 -42
- package/dist/app/charts/hooks/useTooltip.js.map +1 -1
- package/dist/app/charts/index.d.ts +66 -0
- package/dist/app/charts/index.d.ts.map +1 -0
- package/dist/app/charts/index.js +87 -0
- package/dist/app/charts/index.js.map +1 -0
- package/dist/app/charts/legends/Legend.d.ts +33 -12
- package/dist/app/charts/legends/Legend.d.ts.map +1 -0
- package/dist/app/charts/legends/Legend.js +138 -379
- package/dist/app/charts/legends/Legend.js.map +1 -1
- package/dist/app/charts/legends/constants.d.ts +19 -0
- package/dist/app/charts/legends/constants.d.ts.map +1 -0
- package/dist/app/charts/legends/constants.js +34 -0
- package/dist/app/charts/legends/constants.js.map +1 -0
- package/dist/app/charts/observables/ChartData.d.ts +1 -0
- package/dist/app/charts/observables/ChartData.d.ts.map +1 -0
- package/dist/app/charts/observables/iterates.d.ts +13 -7
- package/dist/app/charts/observables/iterates.d.ts.map +1 -0
- package/dist/app/charts/observables/iterates.js +42 -9
- package/dist/app/charts/observables/iterates.js.map +1 -1
- package/dist/app/charts/observables/ordinals.d.ts +70 -12
- package/dist/app/charts/observables/ordinals.d.ts.map +1 -0
- package/dist/app/charts/observables/ordinals.js +127 -48
- package/dist/app/charts/observables/ordinals.js.map +1 -1
- package/dist/app/charts/observables/outliers.d.ts +18 -0
- package/dist/app/charts/observables/outliers.d.ts.map +1 -0
- package/dist/app/charts/observables/outliers.js +2 -0
- package/dist/app/charts/observables/outliers.js.map +1 -0
- package/dist/app/charts/plots/BarPlot.d.ts +87 -13
- package/dist/app/charts/plots/BarPlot.d.ts.map +1 -0
- package/dist/app/charts/plots/BarPlot.js +603 -356
- package/dist/app/charts/plots/BarPlot.js.map +1 -1
- package/dist/app/charts/plots/OutlierPlot.d.ts +123 -0
- package/dist/app/charts/plots/OutlierPlot.d.ts.map +1 -0
- package/dist/app/charts/plots/OutlierPlot.js +430 -0
- package/dist/app/charts/plots/OutlierPlot.js.map +1 -0
- package/dist/app/charts/plots/PoincarePlot.d.ts +92 -14
- package/dist/app/charts/plots/PoincarePlot.d.ts.map +1 -0
- package/dist/app/charts/plots/PoincarePlot.js +523 -364
- package/dist/app/charts/plots/PoincarePlot.js.map +1 -1
- package/dist/app/charts/plots/RasterPlot.d.ts +31 -10
- package/dist/app/charts/plots/RasterPlot.d.ts.map +1 -0
- package/dist/app/charts/plots/RasterPlot.js +198 -306
- package/dist/app/charts/plots/RasterPlot.js.map +1 -1
- package/dist/app/charts/plots/ScatterPlot.d.ts +77 -21
- package/dist/app/charts/plots/ScatterPlot.d.ts.map +1 -0
- package/dist/app/charts/plots/ScatterPlot.js +359 -302
- package/dist/app/charts/plots/ScatterPlot.js.map +1 -1
- package/dist/app/charts/plots/autoScaleYAxes.d.ts +43 -0
- package/dist/app/charts/plots/autoScaleYAxes.d.ts.map +1 -0
- package/dist/app/charts/plots/autoScaleYAxes.js +71 -0
- package/dist/app/charts/plots/autoScaleYAxes.js.map +1 -0
- package/dist/app/charts/plots/colorizedLine.d.ts +61 -0
- package/dist/app/charts/plots/colorizedLine.d.ts.map +1 -0
- package/dist/app/charts/plots/colorizedLine.js +157 -0
- package/dist/app/charts/plots/colorizedLine.js.map +1 -0
- package/dist/app/charts/plots/constants.d.ts +7 -0
- package/dist/app/charts/plots/constants.d.ts.map +1 -0
- package/dist/app/charts/plots/constants.js +11 -0
- package/dist/app/charts/plots/constants.js.map +1 -0
- package/dist/app/charts/plots/hitTesting.d.ts +88 -0
- package/dist/app/charts/plots/hitTesting.d.ts.map +1 -0
- package/dist/app/charts/plots/hitTesting.js +136 -0
- package/dist/app/charts/plots/hitTesting.js.map +1 -0
- package/dist/app/charts/plots/plot.d.ts +52 -16
- package/dist/app/charts/plots/plot.d.ts.map +1 -0
- package/dist/app/charts/plots/plot.js +108 -35
- package/dist/app/charts/plots/plot.js.map +1 -1
- package/dist/app/charts/plots/useCanvasZoomPan.d.ts +119 -0
- package/dist/app/charts/plots/useCanvasZoomPan.d.ts.map +1 -0
- package/dist/app/charts/plots/useCanvasZoomPan.js +113 -0
- package/dist/app/charts/plots/useCanvasZoomPan.js.map +1 -0
- package/dist/app/charts/plots/useStreamingTimeAxes.d.ts +103 -0
- package/dist/app/charts/plots/useStreamingTimeAxes.d.ts.map +1 -0
- package/dist/app/charts/plots/useStreamingTimeAxes.js +257 -0
- package/dist/app/charts/plots/useStreamingTimeAxes.js.map +1 -0
- package/dist/app/charts/series/baseSeries.d.ts +60 -8
- package/dist/app/charts/series/baseSeries.d.ts.map +1 -0
- package/dist/app/charts/series/baseSeries.js +53 -8
- package/dist/app/charts/series/baseSeries.js.map +1 -1
- package/dist/app/charts/series/iterateSeries.d.ts +9 -8
- package/dist/app/charts/series/iterateSeries.d.ts.map +1 -0
- package/dist/app/charts/series/iterateSeries.js +7 -7
- package/dist/app/charts/series/iterateSeries.js.map +1 -1
- package/dist/app/charts/series/ordinalSeries.d.ts +27 -13
- package/dist/app/charts/series/ordinalSeries.d.ts.map +1 -0
- package/dist/app/charts/series/ordinalSeries.js +29 -15
- package/dist/app/charts/series/ordinalSeries.js.map +1 -1
- package/dist/app/charts/series/outlierSeries.d.ts +142 -0
- package/dist/app/charts/series/outlierSeries.d.ts.map +1 -0
- package/dist/app/charts/series/outlierSeries.js +82 -0
- package/dist/app/charts/series/outlierSeries.js.map +1 -0
- package/dist/app/charts/series/timeSeries.d.ts +13 -9
- package/dist/app/charts/series/timeSeries.d.ts.map +1 -0
- package/dist/app/charts/series/timeSeries.js +6 -3
- package/dist/app/charts/series/timeSeries.js.map +1 -1
- package/dist/app/charts/series/timeSeriesChartData.d.ts +18 -10
- package/dist/app/charts/series/timeSeriesChartData.d.ts.map +1 -0
- package/dist/app/charts/series/timeSeriesChartData.js +28 -14
- package/dist/app/charts/series/timeSeriesChartData.js.map +1 -1
- package/dist/app/charts/styling/barPlotStyle.d.ts +46 -2
- package/dist/app/charts/styling/barPlotStyle.d.ts.map +1 -0
- package/dist/app/charts/styling/barPlotStyle.js +37 -3
- package/dist/app/charts/styling/barPlotStyle.js.map +1 -1
- package/dist/app/charts/styling/canvasStyle.d.ts +53 -0
- package/dist/app/charts/styling/canvasStyle.d.ts.map +1 -0
- package/dist/app/charts/styling/canvasStyle.js +71 -0
- package/dist/app/charts/styling/canvasStyle.js.map +1 -0
- package/dist/app/charts/styling/margins.d.ts +21 -2
- package/dist/app/charts/styling/margins.d.ts.map +1 -0
- package/dist/app/charts/styling/margins.js +25 -4
- package/dist/app/charts/styling/margins.js.map +1 -1
- package/dist/app/charts/styling/svgStyle.d.ts +10 -56
- package/dist/app/charts/styling/svgStyle.d.ts.map +1 -0
- package/dist/app/charts/styling/svgStyle.js +3 -78
- package/dist/app/charts/styling/svgStyle.js.map +1 -1
- package/dist/app/charts/subscriptions/viewDrivers.d.ts +124 -0
- package/dist/app/charts/subscriptions/viewDrivers.d.ts.map +1 -0
- package/dist/app/charts/subscriptions/viewDrivers.js +338 -0
- package/dist/app/charts/subscriptions/viewDrivers.js.map +1 -0
- package/dist/app/charts/tooltips/BarPlotTooltipContent.d.ts +12 -78
- package/dist/app/charts/tooltips/BarPlotTooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/BarPlotTooltipContent.js +65 -257
- package/dist/app/charts/tooltips/BarPlotTooltipContent.js.map +1 -1
- package/dist/app/charts/tooltips/DefaultOutlierTooltipContent.d.ts +9 -0
- package/dist/app/charts/tooltips/DefaultOutlierTooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/DefaultOutlierTooltipContent.js +16 -0
- package/dist/app/charts/tooltips/DefaultOutlierTooltipContent.js.map +1 -0
- package/dist/app/charts/tooltips/OutlierPlotTooltipContent.d.ts +30 -0
- package/dist/app/charts/tooltips/OutlierPlotTooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/OutlierPlotTooltipContent.js +26 -0
- package/dist/app/charts/tooltips/OutlierPlotTooltipContent.js.map +1 -0
- package/dist/app/charts/tooltips/PoincarePlotTooltipContent.d.ts +22 -72
- package/dist/app/charts/tooltips/PoincarePlotTooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/PoincarePlotTooltipContent.js +104 -171
- package/dist/app/charts/tooltips/PoincarePlotTooltipContent.js.map +1 -1
- package/dist/app/charts/tooltips/RasterPlotTooltipContent.d.ts +32 -8
- package/dist/app/charts/tooltips/RasterPlotTooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/RasterPlotTooltipContent.js +62 -115
- package/dist/app/charts/tooltips/RasterPlotTooltipContent.js.map +1 -1
- package/dist/app/charts/tooltips/ScatterPlotTooltipContent.d.ts +39 -12
- package/dist/app/charts/tooltips/ScatterPlotTooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/ScatterPlotTooltipContent.js +162 -134
- package/dist/app/charts/tooltips/ScatterPlotTooltipContent.js.map +1 -1
- package/dist/app/charts/tooltips/Tooltip.d.ts +27 -32
- package/dist/app/charts/tooltips/Tooltip.d.ts.map +1 -0
- package/dist/app/charts/tooltips/Tooltip.js +37 -81
- package/dist/app/charts/tooltips/Tooltip.js.map +1 -1
- package/dist/app/charts/tooltips/TooltipContent.d.ts +81 -0
- package/dist/app/charts/tooltips/TooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/TooltipContent.js +99 -0
- package/dist/app/charts/tooltips/TooltipContent.js.map +1 -0
- package/dist/app/charts/tooltips/tooltipUtils.d.ts +186 -36
- package/dist/app/charts/tooltips/tooltipUtils.d.ts.map +1 -0
- package/dist/app/charts/tooltips/tooltipUtils.js +277 -48
- package/dist/app/charts/tooltips/tooltipUtils.js.map +1 -1
- package/dist/app/charts/tooltips/useOutlierTooltip.d.ts +59 -0
- package/dist/app/charts/tooltips/useOutlierTooltip.d.ts.map +1 -0
- package/dist/app/charts/tooltips/useOutlierTooltip.js +16 -0
- package/dist/app/charts/tooltips/useOutlierTooltip.js.map +1 -0
- package/dist/app/charts/tooltips/useTooltipPlacement.d.ts +51 -0
- package/dist/app/charts/tooltips/useTooltipPlacement.d.ts.map +1 -0
- package/dist/app/charts/tooltips/useTooltipPlacement.js +52 -0
- package/dist/app/charts/tooltips/useTooltipPlacement.js.map +1 -0
- package/dist/app/charts/tooltips/useTooltipStyle.d.ts +11 -0
- package/dist/app/charts/tooltips/useTooltipStyle.d.ts.map +1 -0
- package/dist/app/charts/tooltips/useTooltipStyle.js +14 -0
- package/dist/app/charts/tooltips/useTooltipStyle.js.map +1 -0
- package/dist/app/charts/trackers/Tracker.d.ts +22 -6
- package/dist/app/charts/trackers/Tracker.d.ts.map +1 -0
- package/dist/app/charts/trackers/Tracker.js +36 -22
- package/dist/app/charts/trackers/Tracker.js.map +1 -1
- package/dist/app/charts/trackers/trackerUtils.d.ts +40 -18
- package/dist/app/charts/trackers/trackerUtils.d.ts.map +1 -0
- package/dist/app/charts/trackers/trackerUtils.js +213 -300
- package/dist/app/charts/trackers/trackerUtils.js.map +1 -1
- package/dist/app/charts/utils.d.ts +72 -33
- package/dist/app/charts/utils.d.ts.map +1 -0
- package/dist/app/charts/utils.js +87 -42
- package/dist/app/charts/utils.js.map +1 -1
- package/dist/index.d.ts +2 -45
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -72
- package/dist/index.js.map +1 -1
- package/package.json +87 -46
- package/src/app/charts/Chart.tsx +132 -168
- package/src/app/charts/axes/AxesState.ts +27 -29
- package/src/app/charts/axes/AxisInterval.ts +57 -32
- package/src/app/charts/axes/BaseAxisRange.ts +47 -27
- package/src/app/charts/axes/ContinuousAxis.tsx +235 -39
- package/src/app/charts/axes/ContinuousAxisRange.ts +29 -11
- package/src/app/charts/axes/EmptyAxis.tsx +52 -17
- package/src/app/charts/axes/OrdinalAxis.tsx +54 -28
- package/src/app/charts/axes/OrdinalAxisRange.ts +96 -16
- package/src/app/charts/axes/autoScale.ts +244 -0
- package/src/app/charts/axes/axes.ts +954 -735
- package/src/app/charts/d3types.ts +42 -13
- package/src/app/charts/datasources/StreamingDataSource.ts +214 -0
- package/src/app/charts/datasources/iteratesDataSource.ts +122 -0
- package/src/app/charts/datasources/ordinalDataSource.ts +205 -0
- package/src/app/charts/datasources/outlierDataSource.ts +90 -0
- package/src/app/charts/datasources/timeSeriesDataSource.ts +133 -0
- package/src/app/charts/filters/regexFilter.ts +45 -5
- package/src/app/charts/hooks/AxesProvider.tsx +301 -0
- package/src/app/charts/hooks/CanvasSurfaceProvider.tsx +117 -0
- package/src/app/charts/hooks/ChartProvider.tsx +79 -0
- package/src/app/charts/hooks/InteractionProvider.tsx +88 -0
- package/src/app/charts/hooks/PlotDimensionsProvider.tsx +109 -0
- package/src/app/charts/hooks/defaultAxesValues.ts +40 -0
- package/src/app/charts/hooks/defaultMouseValues.ts +24 -0
- package/src/app/charts/hooks/defaultPlotDimensions.ts +27 -0
- package/src/app/charts/hooks/defaultTooltipValues.tsx +23 -0
- package/src/app/charts/hooks/defaultUseChartValues.tsx +36 -0
- package/src/app/charts/hooks/useAxes.tsx +60 -228
- package/src/app/charts/hooks/useCanvasSurface.tsx +35 -0
- package/src/app/charts/hooks/useChart.tsx +47 -106
- package/src/app/charts/hooks/useDataSource.tsx +106 -0
- package/src/app/charts/hooks/useHoveredSeries.tsx +33 -0
- package/src/app/charts/hooks/useMouse.tsx +58 -82
- package/src/app/charts/hooks/usePlotDimensions.tsx +25 -89
- package/src/app/charts/hooks/useTooltip.tsx +32 -63
- package/src/app/charts/index.ts +213 -0
- package/src/app/charts/legends/Legend.tsx +198 -479
- package/src/app/charts/legends/constants.ts +37 -0
- package/src/app/charts/observables/iterates.ts +32 -12
- package/src/app/charts/observables/ordinals.ts +141 -67
- package/src/app/charts/observables/outliers.ts +20 -0
- package/src/app/charts/plots/BarPlot.tsx +784 -666
- package/src/app/charts/plots/OutlierPlot.tsx +685 -0
- package/src/app/charts/plots/PoincarePlot.tsx +707 -489
- package/src/app/charts/plots/RasterPlot.tsx +253 -445
- package/src/app/charts/plots/ScatterPlot.tsx +480 -463
- package/src/app/charts/plots/autoScaleYAxes.ts +102 -0
- package/src/app/charts/plots/colorizedLine.ts +185 -0
- package/src/app/charts/plots/constants.ts +16 -0
- package/src/app/charts/plots/hitTesting.ts +198 -0
- package/src/app/charts/plots/plot.ts +138 -44
- package/src/app/charts/plots/useCanvasZoomPan.ts +240 -0
- package/src/app/charts/plots/useStreamingTimeAxes.ts +384 -0
- package/src/app/charts/series/baseSeries.ts +81 -14
- package/src/app/charts/series/iterateSeries.ts +8 -8
- package/src/app/charts/series/ordinalSeries.ts +35 -20
- package/src/app/charts/series/outlierSeries.ts +188 -0
- package/src/app/charts/series/timeSeries.ts +14 -12
- package/src/app/charts/series/timeSeriesChartData.ts +31 -17
- package/src/app/charts/styling/barPlotStyle.ts +48 -5
- package/src/app/charts/styling/canvasStyle.ts +86 -0
- package/src/app/charts/styling/margins.ts +28 -4
- package/src/app/charts/styling/svgStyle.ts +10 -91
- package/src/app/charts/subscriptions/viewDrivers.ts +447 -0
- package/src/app/charts/tooltips/BarPlotTooltipContent.tsx +156 -380
- package/src/app/charts/tooltips/DefaultOutlierTooltipContent.tsx +40 -0
- package/src/app/charts/tooltips/OutlierPlotTooltipContent.tsx +67 -0
- package/src/app/charts/tooltips/PoincarePlotTooltipContent.tsx +229 -292
- package/src/app/charts/tooltips/RasterPlotTooltipContent.tsx +164 -217
- package/src/app/charts/tooltips/ScatterPlotTooltipContent.tsx +373 -236
- package/src/app/charts/tooltips/Tooltip.tsx +58 -124
- package/src/app/charts/tooltips/TooltipContent.tsx +177 -0
- package/src/app/charts/tooltips/tooltipUtils.ts +359 -61
- package/src/app/charts/tooltips/useOutlierTooltip.tsx +68 -0
- package/src/app/charts/tooltips/useTooltipPlacement.ts +86 -0
- package/src/app/charts/tooltips/useTooltipStyle.ts +15 -0
- package/src/app/charts/trackers/Tracker.tsx +68 -33
- package/src/app/charts/trackers/trackerUtils.ts +263 -376
- package/src/app/charts/utils.ts +90 -48
- package/src/index.ts +2 -322
- package/dist/app/charts/axes/AxesState.test.d.ts +0 -1
- package/dist/app/charts/axes/AxesState.test.js +0 -30
- package/dist/app/charts/axes/AxesState.test.js.map +0 -1
- package/dist/app/charts/axes/AxisInterval.test.d.ts +0 -1
- package/dist/app/charts/axes/AxisInterval.test.js +0 -120
- package/dist/app/charts/axes/AxisInterval.test.js.map +0 -1
- package/dist/app/charts/axes/ContinuousAxisRange.test.d.ts +0 -1
- package/dist/app/charts/axes/ContinuousAxisRange.test.js +0 -47
- package/dist/app/charts/axes/ContinuousAxisRange.test.js.map +0 -1
- package/dist/app/charts/axes/OrdinalAxisRange.test.d.ts +0 -1
- package/dist/app/charts/axes/OrdinalAxisRange.test.js +0 -48
- package/dist/app/charts/axes/OrdinalAxisRange.test.js.map +0 -1
- package/dist/app/charts/filters/regexFilter.test.d.ts +0 -1
- package/dist/app/charts/filters/regexFilter.test.js +0 -11
- package/dist/app/charts/filters/regexFilter.test.js.map +0 -1
- package/dist/app/charts/hooks/useDataObservable.d.ts +0 -72
- package/dist/app/charts/hooks/useDataObservable.js +0 -74
- package/dist/app/charts/hooks/useDataObservable.js.map +0 -1
- package/dist/app/charts/hooks/useInitialData.d.ts +0 -36
- package/dist/app/charts/hooks/useInitialData.js +0 -28
- package/dist/app/charts/hooks/useInitialData.js.map +0 -1
- package/dist/app/charts/observables/iterates.test.d.ts +0 -1
- package/dist/app/charts/observables/iterates.test.js +0 -180
- package/dist/app/charts/observables/iterates.test.js.map +0 -1
- package/dist/app/charts/observables/ordinals.test.d.ts +0 -1
- package/dist/app/charts/observables/ordinals.test.js +0 -102
- package/dist/app/charts/observables/ordinals.test.js.map +0 -1
- package/dist/app/charts/series/datumSeries.test.d.ts +0 -1
- package/dist/app/charts/series/datumSeries.test.js +0 -50
- package/dist/app/charts/series/datumSeries.test.js.map +0 -1
- package/dist/app/charts/styling/margins.test.d.ts +0 -1
- package/dist/app/charts/styling/margins.test.js +0 -19
- package/dist/app/charts/styling/margins.test.js.map +0 -1
- package/dist/app/charts/subscriptions/subscription.test.d.ts +0 -1
- package/dist/app/charts/subscriptions/subscription.test.js +0 -395
- package/dist/app/charts/subscriptions/subscription.test.js.map +0 -1
- package/dist/app/charts/subscriptions/subscriptions.d.ts +0 -100
- package/dist/app/charts/subscriptions/subscriptions.js +0 -449
- package/dist/app/charts/subscriptions/subscriptions.js.map +0 -1
- package/src/app/charts/axes/AxesState.test.ts +0 -34
- package/src/app/charts/axes/AxisInterval.test.ts +0 -143
- package/src/app/charts/axes/ContinuousAxisRange.test.ts +0 -55
- package/src/app/charts/axes/OrdinalAxisRange.test.ts +0 -55
- package/src/app/charts/filters/regexFilter.test.ts +0 -13
- package/src/app/charts/hooks/useDataObservable.tsx +0 -170
- package/src/app/charts/hooks/useInitialData.tsx +0 -64
- package/src/app/charts/observables/iterates.test.ts +0 -201
- package/src/app/charts/observables/ordinals.test.ts +0 -135
- package/src/app/charts/series/datumSeries.test.ts +0 -60
- package/src/app/charts/styling/margins.test.ts +0 -22
- package/src/app/charts/subscriptions/subscription.test.ts +0 -499
- package/src/app/charts/subscriptions/subscriptions.ts +0 -635
|
@@ -1,16 +1,45 @@
|
|
|
1
|
-
// the
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// Canvas replacement for the old SVG-selection type aliases. There's no DOM element tree to hold
|
|
2
|
+
// a d3 `Selection` over anymore, so instead every axis/plot/tracker draws directly into a shared
|
|
3
|
+
// `CanvasRenderingContext2D`, coordinated through the `CanvasContext` below.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Everything a draw-function needs to paint onto the chart's canvas, plus the API for registering
|
|
7
|
+
* and scheduling redraws. This is what gets threaded through `useChart()` in place of the old
|
|
8
|
+
* `mainG` (root SVG `<g>` selection) and `container` (root `<svg>` element).
|
|
9
|
+
*/
|
|
10
|
+
export interface CanvasContext {
|
|
11
|
+
/** unique id for the chart; mirrors the old `chartId` used to namespace SVG element ids */
|
|
12
|
+
chartId: number
|
|
13
|
+
/** the backing `<canvas>` DOM element */
|
|
14
|
+
canvas: HTMLCanvasElement
|
|
15
|
+
/** the 2D drawing context for the canvas (already scaled for devicePixelRatio) */
|
|
16
|
+
context2D: CanvasRenderingContext2D
|
|
17
|
+
/** the current device-pixel-ratio scaling applied to the context */
|
|
18
|
+
dpr: number
|
|
19
|
+
/**
|
|
20
|
+
* Registers a draw function to be invoked on every redraw. Registering under an `id` that's
|
|
21
|
+
* already in use replaces the previous draw function for that id (so components can safely
|
|
22
|
+
* re-register on every render without leaking duplicate draws).
|
|
23
|
+
* @param id A unique handle for this draw function (e.g. `axis-${chartId}-${axisId}`)
|
|
24
|
+
* @param draw The function to call, every redraw, to paint this element
|
|
25
|
+
* @param zIndex Controls draw order (lower first); defaults to 0. Use this to keep, e.g.,
|
|
26
|
+
* the tracker drawing on top of the series, which draw on top of the axes.
|
|
27
|
+
*/
|
|
28
|
+
register: (id: DrawHandle, draw: DrawFn, zIndex?: number) => void
|
|
29
|
+
/**
|
|
30
|
+
* Removes a previously registered draw function so it no longer participates when the canvas
|
|
31
|
+
* is redrawn.
|
|
32
|
+
*/
|
|
33
|
+
unregister: (id: DrawHandle) => void
|
|
34
|
+
/**
|
|
35
|
+
* Schedules the canvas to be redrawn on the next animation frame. Safe to call many times
|
|
36
|
+
* within the same frame/tick -- calls are coalesced into a single `requestAnimationFrame`.
|
|
37
|
+
*/
|
|
38
|
+
requestRedraw: () => void
|
|
39
|
+
}
|
|
10
40
|
|
|
11
|
-
|
|
12
|
-
export type
|
|
13
|
-
export type MagnifierTextSelection = Selection<SVGTextElement, any, SVGGElement, undefined>
|
|
14
|
-
|
|
15
|
-
export type TrackerSelection = Selection<SVGLineElement, Datum, null, undefined>
|
|
41
|
+
/** A function that paints something onto the shared canvas context. */
|
|
42
|
+
export type DrawFn = (cc: CanvasContext) => void
|
|
16
43
|
|
|
44
|
+
/** The id used to register/unregister a draw function with a {@link CanvasContext}. */
|
|
45
|
+
export type DrawHandle = string
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import {BehaviorSubject, Observable, Subject, Subscription} from "rxjs";
|
|
2
|
+
import type {ChartData} from "../observables/ChartData";
|
|
3
|
+
import type {BaseSeries} from "../series/baseSeries";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates the observable of chart data that a {@link StreamingDataSource} subscribes to when it
|
|
7
|
+
* starts. Handed the source's *current* series (not the original initial data), so that a source
|
|
8
|
+
* that is stopped and then started again (Pause -> Run) resumes generating from where the
|
|
9
|
+
* accumulated data left off, rather than starting over from the initial data.
|
|
10
|
+
*/
|
|
11
|
+
export type DataGenerator<CD extends ChartData, S> = (currentSeries: Array<S>) => Observable<CD>
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Owns the ingestion side of a streaming chart: the one subscription to the data generator, and
|
|
15
|
+
* the series that the incoming data accumulates into.
|
|
16
|
+
*
|
|
17
|
+
* A data source is deliberately *not* tied to any React component. The application creates it
|
|
18
|
+
* (e.g. in a store), starts and stops it (Run/Pause), and hands it to a {@link Chart}. Plots only
|
|
19
|
+
* ever *read* from it -- its `series`, and its `chartDataUpdatesObservable` notifications, which a
|
|
20
|
+
* plot subscribes to for exactly as long as it is mounted. That split is what lets data keep accumulating while a
|
|
21
|
+
* chart is unmounted (e.g. the user navigated to another page) without any subscription bound to
|
|
22
|
+
* an unmounted plot instance being kept alive, adopted, or torn down later on.
|
|
23
|
+
*
|
|
24
|
+
* Unlike earlier designs, there is never more than one subscription to the generator, and it
|
|
25
|
+
* exists only while the source is running.
|
|
26
|
+
* @template CD The type of chart data emitted by the generator
|
|
27
|
+
* @template D The type of datum held in each series
|
|
28
|
+
* @template S The type of series
|
|
29
|
+
*/
|
|
30
|
+
export interface StreamingDataSource<CD extends ChartData, D, S extends BaseSeries<D> = BaseSeries<D>> {
|
|
31
|
+
/**
|
|
32
|
+
* The live series, keyed by series name, in insertion order. Mutated in place as data
|
|
33
|
+
* arrives (for performance), so readers see new data without the map being replaced.
|
|
34
|
+
*/
|
|
35
|
+
readonly series: ReadonlyMap<string, S>
|
|
36
|
+
/**
|
|
37
|
+
* Whether the source is currently subscribed to its generator
|
|
38
|
+
*/
|
|
39
|
+
readonly running: boolean
|
|
40
|
+
/**
|
|
41
|
+
* Emits each chunk of chart data *after* it has been ingested into {@link series}. Hot: a
|
|
42
|
+
* subscriber only sees data that arrives after it subscribes (everything before that is
|
|
43
|
+
* already in {@link series}).
|
|
44
|
+
*/
|
|
45
|
+
readonly chartDataUpdatesObservable: Observable<CD>
|
|
46
|
+
/**
|
|
47
|
+
* Emits whether the source is running, starting with the current value
|
|
48
|
+
*/
|
|
49
|
+
readonly isRunningObservable: Observable<boolean>
|
|
50
|
+
/**
|
|
51
|
+
* @return The series, as an array, in insertion order
|
|
52
|
+
*/
|
|
53
|
+
seriesList(): Array<S>
|
|
54
|
+
/**
|
|
55
|
+
* @return The latest time of any datum in any series (the stream's "ground truth" time), or
|
|
56
|
+
* `-Infinity` when there is no data
|
|
57
|
+
*/
|
|
58
|
+
latestTime(): number
|
|
59
|
+
/**
|
|
60
|
+
* Subscribes to the generator (a no-op when already running)
|
|
61
|
+
*/
|
|
62
|
+
start(): void
|
|
63
|
+
/**
|
|
64
|
+
* Unsubscribes from the generator (a no-op when not running). Nothing keeps generating data
|
|
65
|
+
* in the background once this returns.
|
|
66
|
+
*/
|
|
67
|
+
stop(): void
|
|
68
|
+
/**
|
|
69
|
+
* Replaces the generator, e.g. when the data-update period changes. Only allowed while the
|
|
70
|
+
* source is stopped -- the new generator is used by the next {@link start}.
|
|
71
|
+
* @param generator The new generator
|
|
72
|
+
*/
|
|
73
|
+
setGenerator(generator: DataGenerator<CD, S>): void
|
|
74
|
+
/**
|
|
75
|
+
* Stops the source and completes its observables. A disposed source can't be started again.
|
|
76
|
+
*/
|
|
77
|
+
dispose(): void
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The lifecycle shared by every kind of data source. Subclasses only supply how a chunk of chart
|
|
82
|
+
* data is ingested into the series, and how to find the latest time in the series.
|
|
83
|
+
*/
|
|
84
|
+
export abstract class BaseStreamingDataSource<CD extends ChartData, D, S extends BaseSeries<D>>
|
|
85
|
+
implements StreamingDataSource<CD, D, S> {
|
|
86
|
+
|
|
87
|
+
protected readonly seriesMap: Map<string, S>
|
|
88
|
+
|
|
89
|
+
private generator: DataGenerator<CD, S>
|
|
90
|
+
private subscription: Subscription | undefined = undefined
|
|
91
|
+
private disposed = false
|
|
92
|
+
|
|
93
|
+
private readonly updatesSubject = new Subject<CD>()
|
|
94
|
+
private readonly runningSubject = new BehaviorSubject<boolean>(false)
|
|
95
|
+
|
|
96
|
+
readonly chartDataUpdatesObservable: Observable<CD> = this.updatesSubject.asObservable()
|
|
97
|
+
readonly isRunningObservable: Observable<boolean> = this.runningSubject.asObservable()
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @param initialData The initial series. The source takes ownership of these series and
|
|
101
|
+
* mutates them in place as data arrives.
|
|
102
|
+
* @param generator Creates the observable of chart data when the source starts
|
|
103
|
+
*/
|
|
104
|
+
protected constructor(initialData: Array<S>, generator: DataGenerator<CD, S>) {
|
|
105
|
+
this.seriesMap = new Map(initialData.map(series => [series.name, series]))
|
|
106
|
+
this.generator = generator
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The live series, keyed by series name, in insertion order (see {@link StreamingDataSource.series})
|
|
111
|
+
* @return The series map (mutated in place as data arrives)
|
|
112
|
+
*/
|
|
113
|
+
get series(): ReadonlyMap<string, S> {
|
|
114
|
+
return this.seriesMap
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Whether the source is currently subscribed to its generator
|
|
119
|
+
* @return `true` while the source is running; `false` otherwise
|
|
120
|
+
*/
|
|
121
|
+
get running(): boolean {
|
|
122
|
+
return this.runningSubject.value
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @return The series, as an array, in insertion order
|
|
127
|
+
*/
|
|
128
|
+
seriesList(): Array<S> {
|
|
129
|
+
return Array.from(this.seriesMap.values())
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Subscribes to the generator, handing it the current series, so that a restarted source
|
|
134
|
+
* resumes from the data accumulated so far. Each chunk of data the generator emits is ingested
|
|
135
|
+
* into the series, and then emitted through {@link chartDataUpdatesObservable}. When the
|
|
136
|
+
* generator fails or completes, the source stops. A no-op when the source is already running,
|
|
137
|
+
* or has been disposed.
|
|
138
|
+
*/
|
|
139
|
+
start(): void {
|
|
140
|
+
if (this.disposed || this.subscription !== undefined) return
|
|
141
|
+
|
|
142
|
+
const subscription = this.generator(this.seriesList()).subscribe({
|
|
143
|
+
next: data => {
|
|
144
|
+
this.ingest(data)
|
|
145
|
+
this.updatesSubject.next(data)
|
|
146
|
+
},
|
|
147
|
+
error: error => {
|
|
148
|
+
console.error("Streaming data source's generator failed; stopping the source", error)
|
|
149
|
+
this.markStopped()
|
|
150
|
+
},
|
|
151
|
+
complete: () => this.markStopped()
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
// the generator may have completed (or failed) synchronously during `subscribe`, in which
|
|
155
|
+
// case `markStopped` has already run and there is nothing left to hold on to
|
|
156
|
+
if (!subscription.closed) {
|
|
157
|
+
this.subscription = subscription
|
|
158
|
+
this.runningSubject.next(true)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Unsubscribes from the generator (a no-op when not running). Nothing keeps generating data
|
|
164
|
+
* in the background once this returns.
|
|
165
|
+
*/
|
|
166
|
+
stop(): void {
|
|
167
|
+
if (this.subscription === undefined) return
|
|
168
|
+
this.subscription.unsubscribe()
|
|
169
|
+
this.markStopped()
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Replaces the generator, e.g. when the data-update period changes. The new generator is used
|
|
174
|
+
* by the next {@link start}.
|
|
175
|
+
* @param generator The new generator
|
|
176
|
+
* @throws Error when the source is running (the generator can only be replaced while stopped)
|
|
177
|
+
*/
|
|
178
|
+
setGenerator(generator: DataGenerator<CD, S>): void {
|
|
179
|
+
if (this.subscription !== undefined) {
|
|
180
|
+
throw new Error("The data source's generator can only be replaced while the source is stopped")
|
|
181
|
+
}
|
|
182
|
+
this.generator = generator
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Stops the source and completes its observables. A disposed source can't be started again.
|
|
187
|
+
*/
|
|
188
|
+
dispose(): void {
|
|
189
|
+
this.stop()
|
|
190
|
+
this.disposed = true
|
|
191
|
+
this.updatesSubject.complete()
|
|
192
|
+
this.runningSubject.complete()
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* @return The latest time of any datum in any series (the stream's "ground truth" time), or
|
|
197
|
+
* `-Infinity` when there is no data
|
|
198
|
+
*/
|
|
199
|
+
abstract latestTime(): number
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Adds a chunk of chart data to the series (and applies any data-retention rules)
|
|
203
|
+
* @param data The chart data emitted by the generator
|
|
204
|
+
*/
|
|
205
|
+
protected abstract ingest(data: CD): void
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Forgets the generator subscription, and reports that the source stopped (when it was running)
|
|
209
|
+
*/
|
|
210
|
+
private markStopped(): void {
|
|
211
|
+
this.subscription = undefined
|
|
212
|
+
if (this.runningSubject.value) this.runningSubject.next(false)
|
|
213
|
+
}
|
|
214
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type {IterateChartData} from "../observables/iterates";
|
|
2
|
+
import type {IterateDatum, IterateSeries} from "../series/iterateSeries";
|
|
3
|
+
import {emptySeries} from "../series/baseSeries";
|
|
4
|
+
import {BaseStreamingDataSource, type DataGenerator} from "./StreamingDataSource";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Calculates the current time for a chunk of iterate chart data: the max over the series of the
|
|
8
|
+
* time of each series' last new point (or 0 when there are no new points). Shared by the data
|
|
9
|
+
* source (for dropping old data) and the Poincaré plot's view driver (for reporting the current
|
|
10
|
+
* time), so both agree on what "now" is.
|
|
11
|
+
* @param data The iterate chart data
|
|
12
|
+
* @return The current time
|
|
13
|
+
*/
|
|
14
|
+
export function iteratesCurrentTime(data: IterateChartData): number {
|
|
15
|
+
return Array.from(data.newPoints.values()).reduce(
|
|
16
|
+
(maxTime, points) => {
|
|
17
|
+
const seriesMaxTime = points.length > 0 ? points[points.length - 1].time : 0
|
|
18
|
+
return seriesMaxTime > maxTime ? seriesMaxTime : maxTime
|
|
19
|
+
},
|
|
20
|
+
0
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface IteratesDataSourceOptions {
|
|
25
|
+
/**
|
|
26
|
+
* The initial series, owned (and mutated in place) by the source from here on
|
|
27
|
+
*/
|
|
28
|
+
initialData: Array<IterateSeries>
|
|
29
|
+
/**
|
|
30
|
+
* Creates the observable of chart data each time the source starts
|
|
31
|
+
*/
|
|
32
|
+
generator: DataGenerator<IterateChartData, IterateSeries>
|
|
33
|
+
/**
|
|
34
|
+
* Data older than this (ms), relative to the current time, is dropped as new data arrives.
|
|
35
|
+
* Defaults to `Infinity` (never drop).
|
|
36
|
+
*/
|
|
37
|
+
dropDataAfter?: number
|
|
38
|
+
/**
|
|
39
|
+
* Called with each series' new data as it arrives
|
|
40
|
+
*/
|
|
41
|
+
onUpdateData?: (seriesName: string, data: Array<IterateDatum>) => void
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A data source for iterate charts (e.g. the Poincaré plot)
|
|
46
|
+
*/
|
|
47
|
+
export class IteratesDataSource extends BaseStreamingDataSource<IterateChartData, IterateDatum, IterateSeries> {
|
|
48
|
+
private dropDataAfter: number
|
|
49
|
+
private readonly onUpdateData: ((seriesName: string, data: Array<IterateDatum>) => void) | undefined
|
|
50
|
+
// the number of points dropped from each series so far (see `droppedCountFor`)
|
|
51
|
+
private readonly droppedCounts = new Map<string, number>()
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Creates a iterates data source (stopped: call {@link start} to start it)
|
|
55
|
+
* @param options The initial data, the generator, and the data-retention settings
|
|
56
|
+
*/
|
|
57
|
+
constructor(options: IteratesDataSourceOptions) {
|
|
58
|
+
super(options.initialData, options.generator)
|
|
59
|
+
this.dropDataAfter = options.dropDataAfter ?? Infinity
|
|
60
|
+
this.onUpdateData = options.onUpdateData
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Changes how long data is kept; takes effect as the next data arrives
|
|
65
|
+
* @param dropDataAfter Data older than this (ms) is dropped
|
|
66
|
+
*/
|
|
67
|
+
setDropDataAfter(dropDataAfter: number): void {
|
|
68
|
+
this.dropDataAfter = dropDataAfter
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @return The latest time (the `time` of the last datum) over all the series, or
|
|
73
|
+
* `-Infinity` when there is no data
|
|
74
|
+
*/
|
|
75
|
+
/**
|
|
76
|
+
* The number of points dropped (as too old) from the front of the specified series so far --
|
|
77
|
+
* so that a point's overall sequence number in its series is this plus its index in the
|
|
78
|
+
* series' data, even as old points are dropped (e.g. for colorizing the lines by point, see
|
|
79
|
+
* the `PoincarePlot`'s `lineColorSteps`)
|
|
80
|
+
* @param seriesName The name of the series
|
|
81
|
+
* @return The number of points dropped from the series (0 for an unknown series)
|
|
82
|
+
*/
|
|
83
|
+
droppedCountFor(seriesName: string): number {
|
|
84
|
+
return this.droppedCounts.get(seriesName) ?? 0
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
latestTime(): number {
|
|
88
|
+
return this.seriesList().reduce(
|
|
89
|
+
(tMax, series) => Math.max(tMax, series.last().map(datum => datum.time).getOrElse(tMax)),
|
|
90
|
+
-Infinity
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Adds each series' new points to it, and drops the points that are older than
|
|
96
|
+
* `dropDataAfter` relative to the chunk's current time (see `iteratesCurrentTime`),
|
|
97
|
+
* counting them (see {@link droppedCountFor}). New points for a series that isn't in the
|
|
98
|
+
* source are ignored. Calls `onUpdateData` with each
|
|
99
|
+
* series' new points.
|
|
100
|
+
* @param data The chunk of chart data emitted by the generator
|
|
101
|
+
*/
|
|
102
|
+
protected ingest(data: IterateChartData): void {
|
|
103
|
+
const currentTime = iteratesCurrentTime(data)
|
|
104
|
+
data.newPoints.forEach((newData, seriesName) => {
|
|
105
|
+
// note: as in the original subscription code, data for a series that isn't already in
|
|
106
|
+
// the source is accepted but not kept
|
|
107
|
+
const series = this.seriesMap.get(seriesName) || emptySeries<IterateDatum>(seriesName)
|
|
108
|
+
|
|
109
|
+
if (this.onUpdateData) this.onUpdateData(seriesName, newData)
|
|
110
|
+
|
|
111
|
+
series.data.push(...newData)
|
|
112
|
+
|
|
113
|
+
// drop data that is older than the max time-window -- guarded on series.data.length
|
|
114
|
+
let dropped = 0
|
|
115
|
+
while (series.data.length > 0 && currentTime - series.data[0].time > this.dropDataAfter) {
|
|
116
|
+
series.data.shift()
|
|
117
|
+
dropped++
|
|
118
|
+
}
|
|
119
|
+
if (dropped > 0) this.droppedCounts.set(seriesName, this.droppedCountFor(seriesName) + dropped)
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import type {BaseSeries} from "../series/baseSeries";
|
|
2
|
+
import {emptySeries} from "../series/baseSeries";
|
|
3
|
+
import {calculateOrdinalStats, type OrdinalDatum} from "../series/ordinalSeries";
|
|
4
|
+
import {
|
|
5
|
+
copyOrdinalDatumExtremum,
|
|
6
|
+
copyOrdinalValueStats,
|
|
7
|
+
copyValueStatsForSeries,
|
|
8
|
+
defaultOrdinalValueStats,
|
|
9
|
+
initialMaxValueDatum,
|
|
10
|
+
initialMinValueDatum,
|
|
11
|
+
type OrdinalChartData,
|
|
12
|
+
type OrdinalStats,
|
|
13
|
+
type OrdinalValueStats
|
|
14
|
+
} from "../observables/ordinals";
|
|
15
|
+
import {BaseStreamingDataSource, type DataGenerator} from "./StreamingDataSource";
|
|
16
|
+
|
|
17
|
+
export interface WindowedOrdinalStats extends OrdinalStats {
|
|
18
|
+
/**
|
|
19
|
+
* A map associating each series to stats about that series (e.g. map(series_name -> stats))
|
|
20
|
+
*/
|
|
21
|
+
windowedValueStatsForSeries: Map<string, OrdinalValueStats>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Calculates the ordinal stats for each of the ordinal series (generally, initial data) and
|
|
26
|
+
* returns a {@link WindowedOrdinalStats} object
|
|
27
|
+
* @param series The array of ordinal series
|
|
28
|
+
* @return A {@link WindowedOrdinalStats} object with the stats for each of the series
|
|
29
|
+
*/
|
|
30
|
+
export function initialOrdinalStats(series: Array<BaseSeries<OrdinalDatum>>): WindowedOrdinalStats {
|
|
31
|
+
const ordinalStats = calculateOrdinalStats(series)
|
|
32
|
+
return {
|
|
33
|
+
...ordinalStats,
|
|
34
|
+
windowedValueStatsForSeries: copyValueStatsForSeries(ordinalStats.valueStatsForSeries)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* First of two functions to calculate the current ordinal stats for the current time window. This
|
|
40
|
+
* function updates the windowed stats for the new data.
|
|
41
|
+
* @param newData The new data for that series
|
|
42
|
+
* @param windowedStats The current windowed ordinal value stats
|
|
43
|
+
* @return The windowed ordinal value stats updated for the new data
|
|
44
|
+
*/
|
|
45
|
+
function updatedWindowedValueStatsForNewData(newData: Array<OrdinalDatum>, windowedStats: OrdinalValueStats): OrdinalValueStats {
|
|
46
|
+
const updatedStats = copyOrdinalValueStats(windowedStats)
|
|
47
|
+
updatedStats.count += newData.length
|
|
48
|
+
const newSum = newData.reduce((total, datum) => total + datum.value, 0)
|
|
49
|
+
updatedStats.sum += newSum
|
|
50
|
+
updatedStats.sumSquared += newSum * newSum
|
|
51
|
+
updatedStats.mean = (updatedStats.count > 0) ? updatedStats.sum / updatedStats.count : NaN
|
|
52
|
+
updatedStats.min = newData.reduce((min, datum) => datum.value < min.value ? datum : min, updatedStats.min)
|
|
53
|
+
updatedStats.max = newData.reduce((max, datum) => datum.value > max.value ? datum : max, updatedStats.max)
|
|
54
|
+
return updatedStats
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Second of two functions to calculate the current ordinal stats for the current time window. This
|
|
59
|
+
* function updates the windowed stats for the dropped data (the min and max are recalculated from
|
|
60
|
+
* the data that's left)
|
|
61
|
+
* @param droppedData An array of datum that was dropped from the time window
|
|
62
|
+
* @param windowedStats The current windowed ordinal value stats
|
|
63
|
+
* @param series An array of series holding all the current data in the time-window
|
|
64
|
+
* @return The windowed ordinal value stats updated for the dropped data
|
|
65
|
+
*/
|
|
66
|
+
function updateWindowedValueStatsForDroppedData(
|
|
67
|
+
droppedData: Array<OrdinalDatum>,
|
|
68
|
+
windowedStats: OrdinalValueStats,
|
|
69
|
+
series: BaseSeries<OrdinalDatum>
|
|
70
|
+
): OrdinalValueStats {
|
|
71
|
+
const updatedStats = copyOrdinalValueStats(windowedStats)
|
|
72
|
+
updatedStats.count -= droppedData.length
|
|
73
|
+
const droppedSum = droppedData.reduce((total, datum) => total + datum.value, 0)
|
|
74
|
+
updatedStats.sum -= droppedSum
|
|
75
|
+
updatedStats.sumSquared -= droppedSum * droppedSum
|
|
76
|
+
updatedStats.mean = (updatedStats.count > 0) ? updatedStats.sum / updatedStats.count : NaN
|
|
77
|
+
updatedStats.min = series.data.reduce((min, datum) => datum.value < min.value ? datum : min, initialMinValueDatum())
|
|
78
|
+
updatedStats.max = series.data.reduce((max, datum) => datum.value > max.value ? datum : max, initialMaxValueDatum())
|
|
79
|
+
return updatedStats
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface OrdinalDataSourceOptions {
|
|
83
|
+
/**
|
|
84
|
+
* The initial series, owned (and mutated in place) by the source from here on
|
|
85
|
+
*/
|
|
86
|
+
initialData: Array<BaseSeries<OrdinalDatum>>
|
|
87
|
+
/**
|
|
88
|
+
* Creates the observable of chart data each time the source starts
|
|
89
|
+
*/
|
|
90
|
+
generator: DataGenerator<OrdinalChartData, BaseSeries<OrdinalDatum>>
|
|
91
|
+
/**
|
|
92
|
+
* Data older than this (ms), relative to the chart-wide current time, is dropped (and removed
|
|
93
|
+
* from the windowed stats) as new data arrives. Defaults to `Infinity` (never drop).
|
|
94
|
+
*/
|
|
95
|
+
dropDataAfter?: number
|
|
96
|
+
/**
|
|
97
|
+
* Called with each series' new data as it arrives
|
|
98
|
+
*/
|
|
99
|
+
onUpdateData?: (seriesName: string, data: Array<OrdinalDatum>) => void
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* A data source for ordinal charts (e.g. the bar plot). Besides the series, it keeps the lifetime
|
|
104
|
+
* stats (from the chart data) and the windowed stats (over the data currently held) for each
|
|
105
|
+
* series, so they keep accumulating while no plot is mounted.
|
|
106
|
+
*/
|
|
107
|
+
export class OrdinalDataSource extends BaseStreamingDataSource<OrdinalChartData, OrdinalDatum, BaseSeries<OrdinalDatum>> {
|
|
108
|
+
/**
|
|
109
|
+
* The lifetime and windowed stats, updated in place as data arrives
|
|
110
|
+
*/
|
|
111
|
+
readonly stats: WindowedOrdinalStats
|
|
112
|
+
|
|
113
|
+
private dropDataAfter: number
|
|
114
|
+
private readonly onUpdateData: ((seriesName: string, data: Array<OrdinalDatum>) => void) | undefined
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Creates a ordinal data source (stopped: call {@link start} to start it)
|
|
118
|
+
* @param options The initial data, the generator, and the data-retention settings
|
|
119
|
+
*/
|
|
120
|
+
constructor(options: OrdinalDataSourceOptions) {
|
|
121
|
+
super(options.initialData, options.generator)
|
|
122
|
+
this.stats = initialOrdinalStats(options.initialData)
|
|
123
|
+
this.dropDataAfter = options.dropDataAfter ?? Infinity
|
|
124
|
+
this.onUpdateData = options.onUpdateData
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Changes how long data is kept; takes effect as the next data arrives
|
|
129
|
+
* @param dropDataAfter Data older than this (ms) is dropped
|
|
130
|
+
*/
|
|
131
|
+
setDropDataAfter(dropDataAfter: number): void {
|
|
132
|
+
this.dropDataAfter = dropDataAfter
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @return The latest time (the `time` of the last datum) over all the series, or
|
|
137
|
+
* `-Infinity` when there is no data
|
|
138
|
+
*/
|
|
139
|
+
latestTime(): number {
|
|
140
|
+
return this.seriesList().reduce(
|
|
141
|
+
(tMax, series) => Math.max(tMax, series.last().map(datum => datum.time).getOrElse(tMax)),
|
|
142
|
+
-Infinity
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Adds each series' new points to it, copies the chunk's lifetime stats, updates the series'
|
|
148
|
+
* windowed stats for the new points, and then drops the points that are older than
|
|
149
|
+
* `dropDataAfter` relative to the chart-wide current time (the time of the latest datum over
|
|
150
|
+
* all series), removing them from the windowed stats too. New points for a series that isn't
|
|
151
|
+
* in the source are ignored (bar charts have a fixed set of categories). Calls `onUpdateData`
|
|
152
|
+
* with each series' new points.
|
|
153
|
+
* @param data The chunk of chart data emitted by the generator
|
|
154
|
+
*/
|
|
155
|
+
protected ingest(data: OrdinalChartData): void {
|
|
156
|
+
// the chart-wide current time (the time of the latest datum over all series). When it
|
|
157
|
+
// isn't a number, the drop comparison below is simply false, so nothing is dropped.
|
|
158
|
+
const currentTime = data.stats.maxDatum.time.time
|
|
159
|
+
|
|
160
|
+
data.newPoints.forEach((newData, name) => {
|
|
161
|
+
// note: as in the original subscription code, data for a series that isn't already in
|
|
162
|
+
// the source is accepted but not kept (bar charts have a fixed set of categories)
|
|
163
|
+
const series = this.seriesMap.get(name) || emptySeries<OrdinalDatum>(name)
|
|
164
|
+
|
|
165
|
+
if (this.onUpdateData) this.onUpdateData(name, newData)
|
|
166
|
+
|
|
167
|
+
series.data.push(...newData)
|
|
168
|
+
|
|
169
|
+
// grab the (lifetime) stats
|
|
170
|
+
this.stats.minDatum = copyOrdinalDatumExtremum(data.stats.minDatum)
|
|
171
|
+
this.stats.maxDatum = copyOrdinalDatumExtremum(data.stats.maxDatum)
|
|
172
|
+
this.stats.valueStatsForSeries = copyValueStatsForSeries(data.stats.valueStatsForSeries)
|
|
173
|
+
|
|
174
|
+
// set up for the windowed-stats
|
|
175
|
+
const lifetimeValueStats = data.stats.valueStatsForSeries.get(name) || defaultOrdinalValueStats()
|
|
176
|
+
if (!this.stats.windowedValueStatsForSeries.has(name)) {
|
|
177
|
+
this.stats.windowedValueStatsForSeries.set(name, copyOrdinalValueStats(lifetimeValueStats))
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// update the windowed-stats for the new points (the dropped points are dealt with below)
|
|
181
|
+
const windowedValueStats = updatedWindowedValueStatsForNewData(
|
|
182
|
+
newData,
|
|
183
|
+
this.stats.windowedValueStatsForSeries.get(name)!
|
|
184
|
+
)
|
|
185
|
+
this.stats.windowedValueStatsForSeries.set(name, windowedValueStats)
|
|
186
|
+
|
|
187
|
+
// drop data older than the max time-window, holding on to the dropped ones -- guarded
|
|
188
|
+
// on series.data.length, since the current time is the max across ALL series, so a
|
|
189
|
+
// single lagging series could otherwise be shifted down to empty
|
|
190
|
+
const droppedData: Array<OrdinalDatum> = []
|
|
191
|
+
while (series.data.length > 0 && currentTime - series.data[0].time > this.dropDataAfter) {
|
|
192
|
+
const dropped = series.data.shift()
|
|
193
|
+
if (dropped !== undefined) droppedData.push(dropped)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// remove the dropped data from the windowed stats
|
|
197
|
+
if (droppedData.length > 0) {
|
|
198
|
+
this.stats.windowedValueStatsForSeries.set(
|
|
199
|
+
name,
|
|
200
|
+
updateWindowedValueStatsForDroppedData(droppedData, windowedValueStats, series)
|
|
201
|
+
)
|
|
202
|
+
}
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
}
|