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
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import {createContext, useCallback, useContext, useSyncExternalStore} from "react";
|
|
2
|
+
import type {ChartData} from "../observables/ChartData";
|
|
3
|
+
import type {BaseSeries} from "../series/baseSeries";
|
|
4
|
+
import type {StreamingDataSource} from "../datasources/StreamingDataSource";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The chart's data: its data source, the series the source held when it was handed to the chart,
|
|
8
|
+
* and the chart's streaming settings and callbacks
|
|
9
|
+
* @template CD The type of the chart data
|
|
10
|
+
* @template D The type of datum held in each series
|
|
11
|
+
* @template S The type of series
|
|
12
|
+
*/
|
|
13
|
+
export interface ChartDataValues<CD extends ChartData, D, S extends BaseSeries<D> = BaseSeries<D>> {
|
|
14
|
+
/**
|
|
15
|
+
* The data source handed to the chart (its `dataSource` prop)
|
|
16
|
+
*/
|
|
17
|
+
dataSource: StreamingDataSource<CD, D, S>
|
|
18
|
+
/**
|
|
19
|
+
* The series the data source held when it was handed to the chart (a new data source means
|
|
20
|
+
* new initial data, so plots keyed on it reset)
|
|
21
|
+
*/
|
|
22
|
+
initialData: Array<S>
|
|
23
|
+
/**
|
|
24
|
+
* The time (ms) over which incoming data is batched before the plot redraws
|
|
25
|
+
*/
|
|
26
|
+
windowingTime: number
|
|
27
|
+
/**
|
|
28
|
+
* The period (ms) at which the data source's generator emits new data, when known. When
|
|
29
|
+
* provided, batching switches from wall-clock-based to a fixed tick count derived from
|
|
30
|
+
* `windowingTime / dataUpdatePeriod` (see the view drivers in `subscriptions/viewDrivers.ts`).
|
|
31
|
+
*/
|
|
32
|
+
dataUpdatePeriod?: number
|
|
33
|
+
/**
|
|
34
|
+
* Called when the chart time is updated (e.g. by plots whose axes aren't time)
|
|
35
|
+
* @param time The new chart time
|
|
36
|
+
*/
|
|
37
|
+
onUpdateChartTime: (time: number) => void
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// the context is generic over the same type parameters as `ChartDataValues`, but a context object
|
|
41
|
+
// can't itself carry unbound generics -- the hooks below cast it back to the caller's concrete
|
|
42
|
+
// types, which is safe because `<Chart/>` is what actually supplies the value
|
|
43
|
+
export const ChartDataContext = createContext<unknown>(undefined)
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @return The chart's data, and its streaming settings
|
|
47
|
+
* @throws Error when used outside a `<Chart>`
|
|
48
|
+
*/
|
|
49
|
+
function useChartData<CD extends ChartData, D, S extends BaseSeries<D>>(): ChartDataValues<CD, D, S> {
|
|
50
|
+
const context = useContext(ChartDataContext)
|
|
51
|
+
if (context === undefined) {
|
|
52
|
+
throw new Error("The chart's data can only be used within a <Chart/>")
|
|
53
|
+
}
|
|
54
|
+
return context as ChartDataValues<CD, D, S>
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @return The {@link StreamingDataSource} handed to the enclosing {@link Chart} through its
|
|
59
|
+
* `dataSource` prop (`undefined` only outside of a chart)
|
|
60
|
+
* @template CD The type of the chart data
|
|
61
|
+
* @template D The type of datum held in each series
|
|
62
|
+
* @template S The type of series
|
|
63
|
+
*/
|
|
64
|
+
export function useDataSource<CD extends ChartData, D, S extends BaseSeries<D> = BaseSeries<D>>(): StreamingDataSource<CD, D, S> | undefined {
|
|
65
|
+
return (useContext(ChartDataContext) as ChartDataValues<CD, D, S> | undefined)?.dataSource
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @return The series the chart's data source held when it was handed to the chart (for
|
|
70
|
+
* components that need the set of series up front, e.g. the legend, or a plot resetting itself
|
|
71
|
+
* for new data)
|
|
72
|
+
* @throws Error when used outside a `<Chart>`
|
|
73
|
+
* @template D The type of the datum held in each series
|
|
74
|
+
*/
|
|
75
|
+
export function useInitialData<D>(): {initialData: Array<BaseSeries<D>>} {
|
|
76
|
+
const {initialData} = useChartData<ChartData, D, BaseSeries<D>>()
|
|
77
|
+
return {initialData}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @return The chart's streaming settings (how updates are batched for rendering) and callbacks
|
|
82
|
+
* @throws Error when used outside a `<Chart>`
|
|
83
|
+
*/
|
|
84
|
+
export function useStreamingSettings(): Pick<ChartDataValues<ChartData, unknown>, 'windowingTime' | 'dataUpdatePeriod' | 'onUpdateChartTime'> {
|
|
85
|
+
const {windowingTime, dataUpdatePeriod, onUpdateChartTime} = useChartData<ChartData, unknown, BaseSeries<unknown>>()
|
|
86
|
+
return {windowingTime, dataUpdatePeriod, onUpdateChartTime}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Subscribes the calling component to the data source's running state, so it re-renders when the
|
|
91
|
+
* source starts or stops (e.g. to switch the zoom pivot, or hide markers while running).
|
|
92
|
+
* @param dataSource The data source, or `undefined` (in which case this is always `false`)
|
|
93
|
+
* @return Whether the data source is currently running
|
|
94
|
+
*/
|
|
95
|
+
export function useDataSourceRunning<CD extends ChartData, D>(dataSource: StreamingDataSource<CD, D> | undefined): boolean {
|
|
96
|
+
const subscribe = useCallback(
|
|
97
|
+
(onChange: () => void): (() => void) => {
|
|
98
|
+
if (dataSource === undefined) return () => {
|
|
99
|
+
}
|
|
100
|
+
const subscription = dataSource.isRunningObservable.subscribe(() => onChange())
|
|
101
|
+
return () => subscription.unsubscribe()
|
|
102
|
+
},
|
|
103
|
+
[dataSource]
|
|
104
|
+
)
|
|
105
|
+
return useSyncExternalStore(subscribe, () => dataSource?.running ?? false)
|
|
106
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {createContext, type Dispatch, type SetStateAction, useContext} from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The series the mouse is over (in a plot, or in the legend), which the plots and the legend
|
|
5
|
+
* highlight
|
|
6
|
+
*/
|
|
7
|
+
export interface HoveredSeriesValues {
|
|
8
|
+
/**
|
|
9
|
+
* The name of the hovered series, or `null` when no series is hovered
|
|
10
|
+
*/
|
|
11
|
+
hoveredSeriesName: string | null
|
|
12
|
+
/**
|
|
13
|
+
* Sets (or, with `null`, clears) the hovered series -- e.g. when the mouse is over the series'
|
|
14
|
+
* entry in the legend. (A plot's own mouse-over and mouse-leave set it, through the chart's
|
|
15
|
+
* mouse handlers -- see `useMouse`.)
|
|
16
|
+
*/
|
|
17
|
+
setHoveredSeriesName: Dispatch<SetStateAction<string | null>>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const HoveredSeriesContext = createContext<HoveredSeriesValues>({
|
|
21
|
+
hoveredSeriesName: null,
|
|
22
|
+
setHoveredSeriesName: () => {
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* React hook for the series the mouse is over. Kept apart from {@link useChart}, so that only the
|
|
28
|
+
* components that show the hover (the plots and the legend) re-render when it changes.
|
|
29
|
+
* @return The hovered series' name, and its setter
|
|
30
|
+
*/
|
|
31
|
+
export function useHoveredSeries(): HoveredSeriesValues {
|
|
32
|
+
return useContext(HoveredSeriesContext)
|
|
33
|
+
}
|
|
@@ -1,25 +1,42 @@
|
|
|
1
|
-
import {createContext,
|
|
2
|
-
import {TooltipData} from "./useTooltip";
|
|
1
|
+
import {createContext, useContext} from "react";
|
|
2
|
+
import type {TooltipData} from "./useTooltip";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Called when the mouse moves over a series (e.g. to show the tooltip)
|
|
6
|
+
* @param seriesName The name of the series under the mouse
|
|
7
|
+
* @param time The time (x-value) under the mouse
|
|
8
|
+
* @param tooltipData The data for the tooltip (the series, and the plot's metadata about it)
|
|
9
|
+
* @param mouseCoords The mouse coordinates
|
|
10
|
+
* @param [providerId] The ID of the tooltip content provider to use (e.g. for a plot whose
|
|
11
|
+
* elements have different tooltips)
|
|
6
12
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
13
|
+
export type TooltipMouseOverHandlerFn<D, TM> = (
|
|
14
|
+
seriesName: string,
|
|
15
|
+
time: number,
|
|
16
|
+
tooltipData: TooltipData<D, TM>,
|
|
17
|
+
mouseCoords: [x: number, y: number],
|
|
18
|
+
providerId?: string
|
|
19
|
+
) => void
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Called when the mouse leaves a series (e.g. to hide the tooltip)
|
|
23
|
+
* @param seriesName The name of the series the mouse left
|
|
24
|
+
*/
|
|
25
|
+
export type TooltipMouseLeaveHandlerFn = (seriesName: string) => void
|
|
10
26
|
|
|
11
27
|
/**
|
|
12
|
-
* Type representing the values exposed through the
|
|
28
|
+
* Type representing the values exposed through the `useMouse` react hook.
|
|
13
29
|
* @template D The type of the data object for the series
|
|
14
30
|
* @template TM The type of the metadata object for the series
|
|
15
31
|
*/
|
|
16
32
|
export type UseMouseValues<D, TM> = {
|
|
17
33
|
/**
|
|
18
|
-
* Adds a mouse-over-series handler with the specified ID and handler function
|
|
34
|
+
* Adds a mouse-over-series handler with the specified ID and handler function (replacing any
|
|
35
|
+
* handler already registered with that ID)
|
|
19
36
|
* @param handlerId The handler ID
|
|
20
37
|
* @param handler The handler function called when a mouse-over-series event occurs.
|
|
21
|
-
* The handler function is handed the series name, the time (x-value), the
|
|
22
|
-
* series
|
|
38
|
+
* The handler function is handed the series name, the time (x-value), the tooltip data (the
|
|
39
|
+
* series and its metadata), and the mouse coordinates.
|
|
23
40
|
* @return The handler ID.
|
|
24
41
|
*/
|
|
25
42
|
registerMouseOverHandler: (
|
|
@@ -32,97 +49,56 @@ export type UseMouseValues<D, TM> = {
|
|
|
32
49
|
*/
|
|
33
50
|
unregisterMouseOverHandler: (handlerId: string) => void
|
|
34
51
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
52
|
+
* Retrieves the mouse-over-series handler a plot calls when the mouse is over one of its
|
|
53
|
+
* series: it sets the hovered series (see {@link useHoveredSeries}), and calls *every*
|
|
54
|
+
* registered mouse-over-series handler, handing each the specified provider ID. (The
|
|
55
|
+
* `handlerId` is accepted, but unused.)
|
|
56
|
+
* @param handlerId The ID of the handler (unused)
|
|
57
|
+
* @param [providerId] The ID of the tooltip content provider handed to the handlers
|
|
58
|
+
* @return The mouse-over-series handler
|
|
38
59
|
*/
|
|
39
|
-
mouseOverHandlerFor: (handlerId: string, providerId?: string) =>
|
|
40
|
-
((seriesName: string, time: number, tooltipData: TooltipData<D, TM>, mouseCoords: [x: number, y: number], providerId?: string) => void) | undefined
|
|
60
|
+
mouseOverHandlerFor: (handlerId: string, providerId?: string) => TooltipMouseOverHandlerFn<D, TM>
|
|
41
61
|
/**
|
|
42
|
-
* Adds a mouse-leave-series handler with the specified ID and handler function
|
|
62
|
+
* Adds a mouse-leave-series handler with the specified ID and handler function (replacing any
|
|
63
|
+
* handler already registered with that ID)
|
|
43
64
|
* @param handlerId The handler ID
|
|
44
65
|
* @param handler The handler function called when a mouse-leave-series event occurs
|
|
45
66
|
* @return The handler ID
|
|
46
67
|
*/
|
|
47
|
-
registerMouseLeaveHandler: (handlerId: string, handler:
|
|
68
|
+
registerMouseLeaveHandler: (handlerId: string, handler: TooltipMouseLeaveHandlerFn) => string
|
|
48
69
|
/**
|
|
49
70
|
* Removes the mouse-leave-series handler with the specified ID
|
|
50
71
|
* @param handlerId The ID of the handler to remove
|
|
51
72
|
*/
|
|
52
73
|
unregisterMouseLeaveHandler: (handlerId: string) => void
|
|
53
74
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
75
|
+
* Retrieves the mouse-leave-series handler a plot calls when the mouse leaves one of its
|
|
76
|
+
* series: it clears the hovered series, and calls *every* registered mouse-leave-series
|
|
77
|
+
* handler, handing each the specified provider ID. (The `handlerId` is accepted, but unused.)
|
|
78
|
+
* @param handlerId The ID of the handler (unused)
|
|
79
|
+
* @param [providerId] The ID of the tooltip content provider handed to the handlers
|
|
80
|
+
* @return The mouse-leave-series handler
|
|
57
81
|
*/
|
|
58
|
-
mouseLeaveHandlerFor: (handlerId: string, providerId?: string) => ((seriesName: string, providerId?: string) => void)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export const defaultMouseValues = (): UseMouseValues<any, any> => ({
|
|
62
|
-
registerMouseOverHandler: () => '',
|
|
63
|
-
unregisterMouseOverHandler: noop,
|
|
64
|
-
mouseOverHandlerFor: () => undefined,
|
|
65
|
-
registerMouseLeaveHandler: () => '',
|
|
66
|
-
unregisterMouseLeaveHandler: noop,
|
|
67
|
-
mouseLeaveHandlerFor: () => undefined,
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
const MouseContext = createContext<UseMouseValues<any, any>>(defaultMouseValues())
|
|
71
|
-
|
|
72
|
-
export type Props = {
|
|
73
|
-
children: JSX.Element | Array<JSX.Element>
|
|
82
|
+
mouseLeaveHandlerFor: (handlerId: string, providerId?: string) => ((seriesName: string, providerId?: string) => void)
|
|
74
83
|
}
|
|
75
84
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const mouseLeaveHandlersRef = useRef<Map<string, (seriesName: string, providerId?: string) => void>>(new Map())
|
|
81
|
-
|
|
82
|
-
return <MouseContext.Provider
|
|
83
|
-
value={{
|
|
84
|
-
registerMouseOverHandler: (handlerId, handler) => {
|
|
85
|
-
mouseOverHandlersRef.current.set(handlerId, handler)
|
|
86
|
-
return handlerId
|
|
87
|
-
},
|
|
88
|
-
unregisterMouseOverHandler: handlerId => mouseOverHandlersRef.current.delete(handlerId),
|
|
89
|
-
mouseOverHandlerFor: (handlerId, providerId) => {
|
|
90
|
-
if (mouseOverHandlersRef.current.size === 0) return undefined
|
|
91
|
-
return (seriesName: string, time: number, tooltipData: TooltipData<D, TM>, mouseCoords: [x: number, y: number]) => {
|
|
92
|
-
mouseOverHandlersRef.current.forEach(handler => {
|
|
93
|
-
handler(seriesName, time, tooltipData, mouseCoords, providerId)
|
|
94
|
-
})
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
registerMouseLeaveHandler: (handlerId, handler) => {
|
|
99
|
-
mouseLeaveHandlersRef.current.set(handlerId, handler)
|
|
100
|
-
return handlerId
|
|
101
|
-
},
|
|
102
|
-
unregisterMouseLeaveHandler: handlerId => mouseLeaveHandlersRef.current.delete(handlerId),
|
|
103
|
-
mouseLeaveHandlerFor: (handlerId, providerId) => {
|
|
104
|
-
if (mouseLeaveHandlersRef.current.size === 0) return undefined
|
|
105
|
-
return (seriesName: string) => {
|
|
106
|
-
mouseLeaveHandlersRef.current.forEach(handler => {
|
|
107
|
-
handler(seriesName, providerId)
|
|
108
|
-
})
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
}}
|
|
112
|
-
>
|
|
113
|
-
{children}
|
|
114
|
-
</MouseContext.Provider>
|
|
115
|
-
}
|
|
85
|
+
// the context is generic over the same type parameters as `UseMouseValues`, but a context
|
|
86
|
+
// object can't itself carry unbound generics -- `useMouse` below casts it back to the caller's
|
|
87
|
+
// concrete types, which is safe because `<InteractionProvider/>` is what actually supplies the value
|
|
88
|
+
export const MouseContext = createContext<unknown>(undefined)
|
|
116
89
|
|
|
117
90
|
/**
|
|
118
|
-
* React hook
|
|
91
|
+
* React hook for registering, and retrieving, the chart's mouse-over-series and
|
|
92
|
+
* mouse-leave-series handlers. Must be used within a `<Chart>`.
|
|
119
93
|
* @return The {@link UseMouseValues} held in the React context.
|
|
94
|
+
* @throws Error when used outside a `<Chart>`
|
|
95
|
+
* @template D The type of the data object for the series
|
|
96
|
+
* @template TM The type of the metadata object for the series
|
|
120
97
|
*/
|
|
121
98
|
export function useMouse<D, TM>(): UseMouseValues<D, TM> {
|
|
122
|
-
const context = useContext
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
throw new Error("useMouse can only be used when the parent is a <MouseProvider/>")
|
|
99
|
+
const context = useContext(MouseContext)
|
|
100
|
+
if (context === undefined) {
|
|
101
|
+
throw new Error("useMouse can only be used within a <Chart/>")
|
|
126
102
|
}
|
|
127
|
-
return context
|
|
103
|
+
return context as UseMouseValues<D, TM>
|
|
128
104
|
}
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import {Dimensions,
|
|
2
|
-
import {createContext,
|
|
1
|
+
import {type Dimensions, type Margin} from "../styling/margins";
|
|
2
|
+
import {createContext, useContext} from "react";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Called when the plot's dimensions change
|
|
6
|
+
* @param previousDimensions The plot's dimensions before the change
|
|
7
|
+
* @param newDimensions The plot's new dimensions
|
|
6
8
|
*/
|
|
7
|
-
const noop = () => {
|
|
8
|
-
/* empty on purpose */
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const defaultMargin: Margin = {top: 30, right: 20, bottom: 30, left: 50}
|
|
12
|
-
|
|
13
9
|
export type PlotDimensionChangeHandler = (previousDimensions: Dimensions, newDimensions: Dimensions) => void
|
|
14
10
|
|
|
11
|
+
/**
|
|
12
|
+
* The values exposed through the {@link usePlotDimensions} react hook
|
|
13
|
+
*/
|
|
15
14
|
export type UsePlotDimensionsValues = {
|
|
16
15
|
/**
|
|
17
|
-
* The width and height (in pixels) of
|
|
16
|
+
* The width and height (in pixels) of the plot area (the chart without its margins)
|
|
18
17
|
*/
|
|
19
18
|
plotDimensions: Dimensions
|
|
20
19
|
/**
|
|
21
|
-
* The
|
|
20
|
+
* The margins between the edges of the chart and the plot area (where the axes are drawn)
|
|
22
21
|
*/
|
|
23
22
|
margin: Margin
|
|
24
23
|
/**
|
|
@@ -26,93 +25,30 @@ export type UsePlotDimensionsValues = {
|
|
|
26
25
|
* @param dimensions the new dimensions of the plot
|
|
27
26
|
*/
|
|
28
27
|
updateDimensions: (dimensions: Dimensions) => void
|
|
28
|
+
/**
|
|
29
|
+
* Registers a handler that's called whenever the plot dimensions change
|
|
30
|
+
* @param handler The handler
|
|
31
|
+
* @return The handler's ID (for unregistering it)
|
|
32
|
+
*/
|
|
29
33
|
registerPlotDimensionChangeHandler: (handler: PlotDimensionChangeHandler) => string
|
|
34
|
+
/**
|
|
35
|
+
* Unregisters the plot-dimension change handler with the specified ID
|
|
36
|
+
* @param handlerId The handler's ID (from {@link registerPlotDimensionChangeHandler})
|
|
37
|
+
*/
|
|
30
38
|
unregisterPlotDimensionChangeHandler: (handlerId: string) => void
|
|
31
39
|
}
|
|
32
40
|
|
|
33
|
-
export const
|
|
34
|
-
plotDimensions: {width: 0, height: 0},
|
|
35
|
-
margin: defaultMargin,
|
|
36
|
-
updateDimensions: noop,
|
|
37
|
-
registerPlotDimensionChangeHandler: () => "",
|
|
38
|
-
unregisterPlotDimensionChangeHandler: noop
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
const PlotDimensionsContext = createContext<UsePlotDimensionsValues>(defaultPlotDimensions())
|
|
42
|
-
|
|
43
|
-
export type Props = {
|
|
44
|
-
containerDimensions: Dimensions
|
|
45
|
-
margin: Margin
|
|
46
|
-
children: JSX.Element | Array<JSX.Element>
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export default function PlotDimensionsProvider(props: Props): JSX.Element {
|
|
50
|
-
const {
|
|
51
|
-
containerDimensions,
|
|
52
|
-
margin,
|
|
53
|
-
children
|
|
54
|
-
} = props
|
|
55
|
-
|
|
56
|
-
const [dimensions, setDimensions] = useState<Dimensions>(defaultPlotDimensions().plotDimensions)
|
|
57
|
-
const plotDimensionChangeHandersRef = useRef<Map<string, PlotDimensionChangeHandler>>(new Map())
|
|
58
|
-
|
|
59
|
-
// update the plot dimensions when the container size or margin change
|
|
60
|
-
useEffect(
|
|
61
|
-
() => {
|
|
62
|
-
const newDimensions = plotDimensionsFrom(containerDimensions.width, containerDimensions.height, margin)
|
|
63
|
-
setDimensions(prevDimensions => {
|
|
64
|
-
if (dimensionsNotEqual(prevDimensions, newDimensions)) {
|
|
65
|
-
for(const handler of plotDimensionChangeHandersRef.current.values()) {
|
|
66
|
-
handler(prevDimensions, newDimensions)
|
|
67
|
-
}
|
|
68
|
-
return newDimensions
|
|
69
|
-
}
|
|
70
|
-
return prevDimensions
|
|
71
|
-
})
|
|
72
|
-
},
|
|
73
|
-
[containerDimensions, margin]
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
function updateDimensions(newDimensions: Dimensions) {
|
|
77
|
-
setDimensions(prevState => {
|
|
78
|
-
for(const handler of plotDimensionChangeHandersRef.current.values()) {
|
|
79
|
-
handler(prevState, newDimensions)
|
|
80
|
-
}
|
|
81
|
-
return newDimensions
|
|
82
|
-
})
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function registerPlotDimensionChangeHandler(handler: PlotDimensionChangeHandler) {
|
|
86
|
-
const handlerId = crypto.randomUUID()
|
|
87
|
-
plotDimensionChangeHandersRef.current.set(handlerId, handler)
|
|
88
|
-
return handlerId
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function unregisterPlotDimensionChangeHandler(handlerId: string): boolean {
|
|
92
|
-
return plotDimensionChangeHandersRef.current.delete(handlerId)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return <PlotDimensionsContext.Provider
|
|
96
|
-
value={{
|
|
97
|
-
plotDimensions: dimensions,
|
|
98
|
-
margin,
|
|
99
|
-
updateDimensions,
|
|
100
|
-
registerPlotDimensionChangeHandler,
|
|
101
|
-
unregisterPlotDimensionChangeHandler
|
|
102
|
-
}}
|
|
103
|
-
>
|
|
104
|
-
{children}
|
|
105
|
-
</PlotDimensionsContext.Provider>
|
|
106
|
-
}
|
|
41
|
+
export const PlotDimensionsContext = createContext<UsePlotDimensionsValues | undefined>(undefined)
|
|
107
42
|
|
|
108
43
|
/**
|
|
109
|
-
* React hook
|
|
44
|
+
* React hook for the plot's dimensions and margins. Must be used within a
|
|
45
|
+
* `PlotDimensionsProvider` (i.e. within a `<Chart>`).
|
|
110
46
|
* @return The {@link UsePlotDimensionsValues} held in the React context.
|
|
47
|
+
* @throws Error when used outside a `<PlotDimensionsProvider>`
|
|
111
48
|
*/
|
|
112
49
|
export function usePlotDimensions(): UsePlotDimensionsValues {
|
|
113
|
-
const context = useContext
|
|
114
|
-
|
|
115
|
-
if (plotDimensions === undefined || plotDimensions === null) {
|
|
50
|
+
const context = useContext(PlotDimensionsContext)
|
|
51
|
+
if (context === undefined) {
|
|
116
52
|
throw new Error("usePlotDimensions can only be used when the parent is a <PlotDimensionsProvider/>")
|
|
117
53
|
}
|
|
118
54
|
return context
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import {Series} from "../plots/plot";
|
|
2
|
-
import {
|
|
3
|
-
import {createContext, JSX, useContext, useRef} from "react";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* No operation function for use when a default function is needed
|
|
7
|
-
*/
|
|
8
|
-
const noop = () => {
|
|
9
|
-
/* empty on purpose */
|
|
10
|
-
}
|
|
1
|
+
import type {Series} from "../plots/plot";
|
|
2
|
+
import {createContext, useContext} from "react";
|
|
11
3
|
|
|
12
4
|
/**
|
|
13
5
|
* Base interface for tooltip data that is passed through to the tooltip content provider
|
|
@@ -20,20 +12,23 @@ export interface TooltipData<D, M> {
|
|
|
20
12
|
}
|
|
21
13
|
|
|
22
14
|
/**
|
|
23
|
-
* A
|
|
24
|
-
*
|
|
25
|
-
* @return The tooltip content, or `undefined` if no tooltip content is available.
|
|
15
|
+
* A function that provides (shows) the tooltip content for the element under the mouse (see
|
|
16
|
+
* {@link TooltipContent}, which registers one)
|
|
26
17
|
* @param seriesName The name of the series for which the tooltip content is being provided
|
|
27
18
|
* @param time The time (x-value) for which the tooltip content is being provided
|
|
28
19
|
* @param tooltipData The tooltip data
|
|
29
20
|
* @param mouseCoords The mouse coordinates over which the mouse is hovering
|
|
30
21
|
* @param providerId An optional ID of the tooltip content provider.
|
|
22
|
+
* @template D The type of the data object for the series
|
|
23
|
+
* @template M The type of the metadata object for the series
|
|
31
24
|
*/
|
|
32
25
|
export type TooltipContentProvider<D, M> =
|
|
33
|
-
(seriesName: string, time: number, tooltipData: TooltipData<D, M>, mouseCoords: [x: number, y: number], providerId?: string) =>
|
|
26
|
+
(seriesName: string, time: number, tooltipData: TooltipData<D, M>, mouseCoords: [x: number, y: number], providerId?: string) => void
|
|
34
27
|
|
|
35
28
|
/**
|
|
36
|
-
* The functions and values exposed through the
|
|
29
|
+
* The functions and values exposed through the `useTooltip` react hook
|
|
30
|
+
* @template D The type of the data object for the series
|
|
31
|
+
* @template M The type of the metadata object for the series
|
|
37
32
|
*/
|
|
38
33
|
export type UseTooltipValues<D, M> = {
|
|
39
34
|
/**
|
|
@@ -50,62 +45,36 @@ export type UseTooltipValues<D, M> = {
|
|
|
50
45
|
*/
|
|
51
46
|
tooltipContentProvider: () => (TooltipContentProvider<D, M> | undefined)
|
|
52
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Callback that sets the visibility state of the tooltip. This is used to control whether the tooltip is
|
|
50
|
+
* visible or not.
|
|
51
|
+
* @param visible Whether the tooltip should be visible or not.
|
|
52
|
+
*/
|
|
53
53
|
setVisibilityState: (visible: boolean) => void
|
|
54
|
-
visibilityState: boolean
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* The default values for the {@link UseTooltipValues}
|
|
59
|
-
*/
|
|
60
|
-
export const defaultTooltipValues = (): UseTooltipValues<any, any> => ({
|
|
61
|
-
registerTooltipContentProvider: noop,
|
|
62
|
-
tooltipContentProvider: () => undefined,
|
|
63
|
-
setVisibilityState: noop,
|
|
64
|
-
visibilityState: false,
|
|
65
|
-
})
|
|
66
54
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
55
|
+
/**
|
|
56
|
+
* @return Whether the tooltip is currently visible or not.
|
|
57
|
+
*/
|
|
58
|
+
visibilityState: boolean
|
|
71
59
|
}
|
|
72
60
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
* the context or types of objects being moused over. When a tooltip content provider is registered
|
|
78
|
-
* without a provider ID, then the default provider ID is used.
|
|
79
|
-
* @param props The properties holding the children
|
|
80
|
-
* @return A JSX element containing the children
|
|
81
|
-
*/
|
|
82
|
-
export default function TooltipProvider<D, M>(props: Props): JSX.Element {
|
|
83
|
-
const {children} = props
|
|
84
|
-
|
|
85
|
-
const tooltipContentProviderRef = useRef<TooltipContentProvider<D, M>>(undefined)
|
|
86
|
-
const visibilityStateRef = useRef<boolean>(false)
|
|
87
|
-
|
|
88
|
-
return <TooltipContext.Provider
|
|
89
|
-
value={{
|
|
90
|
-
registerTooltipContentProvider: provider => tooltipContentProviderRef.current = provider,
|
|
91
|
-
tooltipContentProvider: () => tooltipContentProviderRef.current,
|
|
92
|
-
setVisibilityState: (visible: boolean) => visibilityStateRef.current = visible,
|
|
93
|
-
visibilityState: visibilityStateRef.current
|
|
94
|
-
}}
|
|
95
|
-
>
|
|
96
|
-
{children}
|
|
97
|
-
</TooltipContext.Provider>
|
|
98
|
-
}
|
|
61
|
+
// the context is generic over the same type parameters as `UseTooltipValues`, but a context
|
|
62
|
+
// object can't itself carry unbound generics -- `useTooltip` below casts it back to the caller's
|
|
63
|
+
// concrete types, which is safe because `<InteractionProvider/>` is what actually supplies the value
|
|
64
|
+
export const TooltipContext = createContext<unknown>(undefined)
|
|
99
65
|
|
|
100
66
|
/**
|
|
101
|
-
* React hook
|
|
67
|
+
* React hook for registering, and retrieving, the chart's tooltip content provider, and for the
|
|
68
|
+
* tooltip's visibility. Must be used within a `<Chart>`.
|
|
102
69
|
* @return The {@link UseTooltipValues} held in the React context.
|
|
70
|
+
* @throws Error when used outside a `<Chart>`
|
|
71
|
+
* @template D The type of the data object for the series
|
|
72
|
+
* @template M The type of the metadata object for the series
|
|
103
73
|
*/
|
|
104
74
|
export function useTooltip<D, M>(): UseTooltipValues<D, M> {
|
|
105
|
-
const context = useContext
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
throw new Error("useTooltip can only be used when the parent is a <TooltipProvider/>")
|
|
75
|
+
const context = useContext(TooltipContext)
|
|
76
|
+
if (context === undefined) {
|
|
77
|
+
throw new Error("useTooltip can only be used within a <Chart/>")
|
|
109
78
|
}
|
|
110
|
-
return context
|
|
79
|
+
return context as UseTooltipValues<D, M>
|
|
111
80
|
}
|