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,67 @@
|
|
|
1
|
+
import type {JSX, ReactElement} from "react"
|
|
2
|
+
import type {TooltipStyle} from "./tooltipUtils"
|
|
3
|
+
import {TooltipContent} from "./TooltipContent"
|
|
4
|
+
import type {OutlierBandTooltipMetadata} from "../plots/OutlierPlot"
|
|
5
|
+
import type {OutlierDatum} from "../series/outlierSeries"
|
|
6
|
+
import {DefaultOutlierTooltipContent} from "./DefaultOutlierTooltipContent"
|
|
7
|
+
import {type OutlierTooltipContentFormatters, type OutlierTooltipData, UseOutlierTooltip} from "./useOutlierTooltip"
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The properties of the {@link OutlierPlotTooltipContent}: its style, its (optional) custom
|
|
11
|
+
* content, and the formatters for the content
|
|
12
|
+
*/
|
|
13
|
+
export type Props = {
|
|
14
|
+
/**
|
|
15
|
+
* Overrides of the style of the enclosing {@link Tooltip}
|
|
16
|
+
*/
|
|
17
|
+
style?: Partial<TooltipStyle>
|
|
18
|
+
/**
|
|
19
|
+
* Custom tooltip content, which gets what the tooltip shows, and the formatters, from
|
|
20
|
+
* {@link useOutlierTooltip}. Defaults to {@link DefaultOutlierTooltipContent}.
|
|
21
|
+
*/
|
|
22
|
+
children?: JSX.Element | Array<JSX.Element>
|
|
23
|
+
} & OutlierTooltipContentFormatters
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The tooltip content for an {@link OutlierPlot}: when the mouse is over a band, or an outlier,
|
|
27
|
+
* shows the series' name, the outlier (if any), the band, the probabilities of a point being in
|
|
28
|
+
* and outside the band, and the number of points in the band. Put it inside a {@link Tooltip}.
|
|
29
|
+
*
|
|
30
|
+
* To lay the content out yourself, put your own component inside this one: it gets what the
|
|
31
|
+
* tooltip shows, its style, and the formatters, from {@link useOutlierTooltip}.
|
|
32
|
+
* @param props The style, the formatters, and the (optional) custom content
|
|
33
|
+
* @return The tooltip's box (a portal), or `null` when no band or outlier is hovered
|
|
34
|
+
*/
|
|
35
|
+
export function OutlierPlotTooltipContent(props: Props): ReactElement | null {
|
|
36
|
+
const {
|
|
37
|
+
style,
|
|
38
|
+
children,
|
|
39
|
+
datumFormatter = (x: number, y: number) => `(${x}, ${y})`,
|
|
40
|
+
bandFormatter = (lower: number, upper: number) => `Band: ${lower} ⭢ ${upper}`,
|
|
41
|
+
measureFormatter = (innerProb: number, outerProb: number) => `Points have a ${(innerProb * 100).toFixed(1)}% probability of being in this band, and a ${(outerProb * 100).toFixed(1)}% probability of being outside this band`,
|
|
42
|
+
} = props
|
|
43
|
+
|
|
44
|
+
// (a description given as lines is shown one per line)
|
|
45
|
+
const measureDescription = (innerProb: number, outerProb: number): string | JSX.Element => {
|
|
46
|
+
const description = measureFormatter(innerProb, outerProb)
|
|
47
|
+
return Array.isArray(description) ?
|
|
48
|
+
<>{description.map((line, index) => <div key={index}>{line}</div>)}</> :
|
|
49
|
+
description
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<TooltipContent<OutlierDatum<readonly number[]>, OutlierBandTooltipMetadata, OutlierTooltipData>
|
|
54
|
+
style={style}
|
|
55
|
+
boxStyle={{lineHeight: 1.6}}
|
|
56
|
+
capture={(seriesName, _time, {metadata}) => ({...metadata, seriesName})}
|
|
57
|
+
>
|
|
58
|
+
{(tooltipContent, tooltipStyle) =>
|
|
59
|
+
<UseOutlierTooltip.Provider
|
|
60
|
+
value={{tooltipContent, tooltipStyle, datumFormatter, bandFormatter, measureFormatter: measureDescription}}
|
|
61
|
+
>
|
|
62
|
+
{children ?? <DefaultOutlierTooltipContent/>}
|
|
63
|
+
</UseOutlierTooltip.Provider>
|
|
64
|
+
}
|
|
65
|
+
</TooltipContent>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
@@ -1,101 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from "svg-table";
|
|
10
|
-
import {
|
|
11
|
-
defaultTooltipStyle,
|
|
12
|
-
findPointAndNeighbors,
|
|
13
|
-
TooltipDimensions,
|
|
14
|
-
TooltipStyle,
|
|
15
|
-
tooltipX,
|
|
16
|
-
tooltipY
|
|
17
|
-
} from "./tooltipUtils";
|
|
18
|
-
import {formatTime, formatTimeChange, formatValue, formatValueChange} from "../utils";
|
|
19
|
-
import {useEffect, useMemo} from "react";
|
|
20
|
-
import {NoTooltipMetadata, useChart} from "../hooks/useChart";
|
|
21
|
-
import {usePlotDimensions} from "../hooks/usePlotDimensions";
|
|
22
|
-
import {emptyIterateDatum, IterateDatum} from "../series/iterateSeries";
|
|
23
|
-
import {ContinuousNumericAxis, SeriesLineStyle} from "../axes/axes";
|
|
24
|
-
import {TooltipData} from "../hooks/useTooltip";
|
|
25
|
-
import {DataFrame} from "data-frame-ts";
|
|
26
|
-
import {Dimensions} from "../styling/margins";
|
|
27
|
-
import {Background, Border, BorderElement, Dimension} from "svg-table/stylings";
|
|
28
|
-
import {ContinuousAxisRange} from "../axes/ContinuousAxisRange";
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
# Want to write your own tooltip-content component?
|
|
32
|
-
|
|
33
|
-
Here's how to write your own tooltip-content component.
|
|
34
|
-
|
|
35
|
-
To create your own tooltip content `<MyTooltipContent/>` you must do the following:
|
|
36
|
-
1. Create a react component for your tooltip content (see for example, {@link PoincarePlotTooltipContent}
|
|
37
|
-
as a reference.
|
|
38
|
-
2. Use the {@link useChart} hook to get the {@link registerTooltipContentProvider} registration function.
|
|
39
|
-
3. When your tooltip content component (`<MyTooltipContent/>`) mounts, use the {@link registerTooltipContentProvider}
|
|
40
|
-
function to register your tooltip content provider.
|
|
41
|
-
4. When the chart dimensions, margin, container, etc, change, register your tooltip content provider
|
|
42
|
-
again (you can register as many times as you like because it only uses the last content provider
|
|
43
|
-
registered).
|
|
44
|
-
|
|
45
|
-
That's it! A few more details are below.
|
|
46
|
-
|
|
47
|
-
The {@link registerTooltipContentProvider} function from the {@link useChart} hook allows you to register
|
|
48
|
-
one tooltip content provider. A second call to this function will cause the {@link useChart} hook to drop
|
|
49
|
-
the first one in favor of the second one.
|
|
50
|
-
|
|
51
|
-
The {@link registerTooltipContentProvider} function from the {@link useChart} hook accepts a higher-order
|
|
52
|
-
function that allowing a closure on content/chart-specific data. Specifically, you must hand the
|
|
53
|
-
{@link registerTooltipContentProvider} a function of the form:
|
|
54
|
-
|
|
55
|
-
`(seriesName: string, time: number, series: TimeSeries, mouseCoords: [x: number, y: number]) => TooltipDimensions`
|
|
56
|
-
|
|
57
|
-
Your function to add that actual content will be what this function calls whenever d3 fires a mouse-over
|
|
58
|
-
event on one you the time-series in the chart.
|
|
59
|
-
|
|
60
|
-
The code snippet below is from the `useEffect` call in the {@link PoincarePlotTooltipContent}.
|
|
61
|
-
Note that the first four arguments to the {@link addTooltipContent} function are those provided by the {@link useChart} hook
|
|
62
|
-
when a d3 mouse-over event occurs on one of your series. The additional six arguments are from the closure formed
|
|
63
|
-
on the variables in your component. The `chartId`, `container`, `margin`, and `plotDimensions` are from the
|
|
64
|
-
{@link useChart} hook called by the {@link PoincarePlotTooltipContent} component. The last two
|
|
65
|
-
arguments, `defaultTooltipStyle` and `options` are specific to the {@link PoincarePlotTooltipContent}.
|
|
66
|
-
For example, the `options` property is set by the caller of the {@link PoincarePlotTooltipContent}
|
|
67
|
-
component.
|
|
68
|
-
|
|
69
|
-
```ts
|
|
70
|
-
// register the tooltip content provider function with the chart hook (useChart) so that
|
|
71
|
-
// it is visible to all children of the Chart (i.e. the <Tooltip>).
|
|
72
|
-
registerTooltipContentProvider(
|
|
73
|
-
(seriesName: string, time: number, series: TimeSeries, mouseCoords: [x: number, y: number]) =>
|
|
74
|
-
addTooltipContent(
|
|
75
|
-
seriesName, time, series, mouseCoords,
|
|
76
|
-
chartId, container, margin, plotDimensions,
|
|
77
|
-
defaultTooltipStyle, options
|
|
78
|
-
)
|
|
79
|
-
)
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
This pattern allows you to supplement that `useChart` mouse-over callback with information specific to your component.
|
|
83
|
-
|
|
84
|
-
*/
|
|
1
|
+
import type {CSSProperties, ReactElement} from "react";
|
|
2
|
+
import {useLayoutEffect, useState, useRef} from "react";
|
|
3
|
+
import {findPointAndNeighbors, sparklineFor, type TooltipStyle} from "./tooltipUtils";
|
|
4
|
+
import {TooltipContent} from "./TooltipContent";
|
|
5
|
+
import {formatTime, formatValue} from "../utils";
|
|
6
|
+
import type {NoTooltipMetadata} from "../hooks/useChart";
|
|
7
|
+
import {emptyIterateDatum, type IterateDatum} from "../series/iterateSeries";
|
|
8
|
+
import type {TooltipData} from "../hooks/useTooltip";
|
|
85
9
|
|
|
86
10
|
/**
|
|
87
11
|
* Properties for rendering the tooltip content. The properties are applied as
|
|
88
12
|
* shown below.
|
|
89
13
|
* ```
|
|
90
14
|
* series name
|
|
91
|
-
*
|
|
92
|
-
* xLabel xValueFormatter xValueFormatter
|
|
93
|
-
* yLabel yValueFormatter yValueFormatter
|
|
15
|
+
* f[n-1](x) f[n](x) f[n+1](x)
|
|
16
|
+
* xLabel xValueFormatter xValueFormatter xValueFormatter
|
|
17
|
+
* yLabel yValueFormatter yValueFormatter yValueFormatter
|
|
94
18
|
* ```
|
|
19
|
+
* The column headers are always the `f[i](x)` form, built from the hovered point's index: the
|
|
20
|
+
* `nMinusLagHeader`, `nHeader`, and `nPlusLagHeader` properties, and the `xChangeFormatter` and
|
|
21
|
+
* `yChangeFormatter` properties, are accepted, but not (yet) used.
|
|
95
22
|
*/
|
|
96
23
|
export interface Props {
|
|
97
24
|
// label for the x-values (x-value row header)
|
|
98
25
|
xLabel: string
|
|
26
|
+
// label for the y-values (y-value row header)
|
|
99
27
|
yLabel: string
|
|
100
28
|
nMinusLagHeader?: string
|
|
101
29
|
nHeader?: string
|
|
@@ -108,244 +36,253 @@ export interface Props {
|
|
|
108
36
|
}
|
|
109
37
|
|
|
110
38
|
/**
|
|
111
|
-
*
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
39
|
+
* The data needed to render the tooltip's content, captured when the mouse moves over an element
|
|
40
|
+
*/
|
|
41
|
+
interface PoincareTooltipContent {
|
|
42
|
+
seriesName: string
|
|
43
|
+
prevHeader: string
|
|
44
|
+
currentHeader: string
|
|
45
|
+
nextHeader: string
|
|
46
|
+
xLabel: string
|
|
47
|
+
xPrev: string
|
|
48
|
+
xCurrent: string
|
|
49
|
+
xNext: string
|
|
50
|
+
yLabel: string
|
|
51
|
+
yPrev: string
|
|
52
|
+
yCurrent: string
|
|
53
|
+
yNext: string
|
|
54
|
+
// the series' values (each point's `f[n+1](x)`) over time, around the hovered point (see
|
|
55
|
+
// `SPARKLINE_POINTS`), for the sparkline -- which is drawn once the tooltip's width is known
|
|
56
|
+
sparklineValues: Array<{ time: number, value: number }>
|
|
57
|
+
// the hovered point's time (marked on the sparkline)
|
|
58
|
+
hoveredTime: number
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// the height of the tooltip's sparkline (of the series' values over time); it's as wide as the
|
|
62
|
+
// tooltip's content (at least this wide)
|
|
63
|
+
const SPARKLINE_HEIGHT = 36
|
|
64
|
+
const MIN_SPARKLINE_WIDTH = 120
|
|
65
|
+
// the number of points (around the hovered point) the sparkline shows
|
|
66
|
+
const SPARKLINE_POINTS = 60
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Adds tooltip content as a table. The columns of the table are the previous, current, and next
|
|
70
|
+
* iterate (relative to the hovered point). The rows of the table are the time values for the
|
|
71
|
+
* first row, and the iterate values (each point's `f[n+1](x)`) for the second row. Below the
|
|
72
|
+
* table, as wide as it, a sparkline of the series' values over time -- the 60 points around the
|
|
73
|
+
* hovered point -- with the hovered point marked.
|
|
115
74
|
* ```
|
|
116
75
|
* series name
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* value
|
|
76
|
+
* f[n-1](x) f[n](x) f[n+1](x)
|
|
77
|
+
* t (ms) t_p t_c t_n
|
|
78
|
+
* value v_p v_c v_n
|
|
79
|
+
* value over time
|
|
80
|
+
* sparkline
|
|
120
81
|
* ```
|
|
121
82
|
*
|
|
122
|
-
*
|
|
123
|
-
* event on a series. The content provider is returns the {@link addTooltipContent} function
|
|
124
|
-
* when called. And when called the {@link addTooltipContent} function adds the actual tooltip
|
|
125
|
-
* content to the SVG element.
|
|
83
|
+
* Built on {@link TooltipContent}; put it inside a {@link Tooltip}.
|
|
126
84
|
* @param props The properties describing the tooltip content
|
|
127
|
-
* @return null
|
|
85
|
+
* @return The tooltip's portal, or `null` when nothing is being hovered
|
|
128
86
|
*/
|
|
129
|
-
export function PoincarePlotTooltipContent(props: Props): null {
|
|
130
|
-
const {
|
|
131
|
-
chartId,
|
|
132
|
-
container,
|
|
133
|
-
tooltip
|
|
134
|
-
} = useChart<IterateDatum, SeriesLineStyle, NoTooltipMetadata, ContinuousAxisRange, ContinuousNumericAxis>()
|
|
135
|
-
|
|
136
|
-
const {registerTooltipContentProvider} = tooltip
|
|
137
|
-
|
|
138
|
-
const {
|
|
139
|
-
margin,
|
|
140
|
-
plotDimensions,
|
|
141
|
-
} = usePlotDimensions()
|
|
142
|
-
|
|
87
|
+
export function PoincarePlotTooltipContent(props: Props): ReactElement | null {
|
|
143
88
|
const {
|
|
144
89
|
xLabel,
|
|
145
90
|
yLabel,
|
|
146
|
-
nMinusLagHeader
|
|
147
|
-
|
|
148
|
-
nPlusLagHeader = ' f[n+1](x)',
|
|
91
|
+
// (the `nMinusLagHeader`, `nHeader`, and `nPlusLagHeader` properties aren't used: the
|
|
92
|
+
// column headers are always the `f[i](x)` form, built from the point's index)
|
|
149
93
|
xValueFormatter = formatTime,
|
|
150
94
|
yValueFormatter = formatValue,
|
|
151
|
-
xChangeFormatter = formatTimeChange,
|
|
152
|
-
yChangeFormatter = formatValueChange,
|
|
153
95
|
style,
|
|
154
96
|
} = props
|
|
155
97
|
|
|
156
|
-
|
|
98
|
+
return (
|
|
99
|
+
<TooltipContent<IterateDatum, NoTooltipMetadata, PoincareTooltipContent>
|
|
100
|
+
style={style}
|
|
101
|
+
capture={(seriesName, time, tooltipData) =>
|
|
102
|
+
captureTooltipContent(seriesName, time, tooltipData, {xLabel, yLabel, xValueFormatter, yValueFormatter})
|
|
103
|
+
}
|
|
104
|
+
>
|
|
105
|
+
{(tooltipContent, tooltipStyle) =>
|
|
106
|
+
// (a fresh body for each point, so its sparkline starts out narrower than the
|
|
107
|
+
// tooltip, and the tooltip's size is right when it's placed)
|
|
108
|
+
<PoincareTooltipBody key={tooltipContent.hoveredTime} tooltipContent={tooltipContent} tooltipStyle={tooltipStyle}/>
|
|
109
|
+
}
|
|
110
|
+
</TooltipContent>
|
|
111
|
+
)
|
|
112
|
+
}
|
|
157
113
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
114
|
+
/**
|
|
115
|
+
* The Poincaré tooltip's content: the series' name, the table of the hovered iterate and its
|
|
116
|
+
* neighbors, and, as wide as the table (or the name, when that's wider), the sparkline of the
|
|
117
|
+
* series' values around the hovered point
|
|
118
|
+
* @param props The captured content, and the tooltip's style
|
|
119
|
+
* @return The tooltip's content
|
|
120
|
+
*/
|
|
121
|
+
function PoincareTooltipBody(props: {tooltipContent: PoincareTooltipContent, tooltipStyle: TooltipStyle}): ReactElement {
|
|
122
|
+
const {tooltipContent, tooltipStyle} = props
|
|
123
|
+
|
|
124
|
+
// the sparkline is as wide as the tooltip's content: its table, or its title when that's wider.
|
|
125
|
+
// Both are measured at their natural widths (rather than the sparkline-stretched width of the
|
|
126
|
+
// tooltip itself), before the tooltip is painted.
|
|
127
|
+
const titleRef = useRef<HTMLDivElement>(null)
|
|
128
|
+
const tableRef = useRef<HTMLTableElement>(null)
|
|
129
|
+
const [sparklineWidth, setSparklineWidth] = useState<number>(MIN_SPARKLINE_WIDTH)
|
|
130
|
+
useLayoutEffect(
|
|
168
131
|
() => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
seriesName, time, tooltipData, mouseCoords,
|
|
176
|
-
chartId, container, margin, plotDimensions, tooltipStyle,
|
|
177
|
-
)
|
|
178
|
-
)
|
|
179
|
-
}
|
|
132
|
+
const contentWidth = Math.max(
|
|
133
|
+
MIN_SPARKLINE_WIDTH,
|
|
134
|
+
tableRef.current?.offsetWidth ?? 0,
|
|
135
|
+
titleRef.current?.offsetWidth ?? 0
|
|
136
|
+
)
|
|
137
|
+
if (contentWidth !== sparklineWidth) setSparklineWidth(contentWidth)
|
|
180
138
|
},
|
|
181
|
-
[
|
|
182
|
-
chartId, container, margin, plotDimensions, registerTooltipContentProvider,
|
|
183
|
-
xLabel, xChangeFormatter, xValueFormatter,
|
|
184
|
-
yLabel, yChangeFormatter, yValueFormatter,
|
|
185
|
-
nMinusLagHeader, nHeader, nPlusLagHeader,
|
|
186
|
-
tooltipStyle
|
|
187
|
-
]
|
|
139
|
+
[tooltipContent, sparklineWidth]
|
|
188
140
|
)
|
|
189
141
|
|
|
190
|
-
|
|
191
|
-
}
|
|
142
|
+
const cellStyle: CSSProperties = {padding: '1px 8px', textAlign: 'right', border: 'none'}
|
|
143
|
+
const rowLabelStyle: CSSProperties = {...cellStyle, textAlign: 'left', paddingLeft: 0}
|
|
144
|
+
const headerCellStyle: CSSProperties = {...cellStyle, fontWeight: tooltipStyle.fontWeight + 550}
|
|
145
|
+
// the "current" (middle) column stands out
|
|
146
|
+
const currentColumnStyle: CSSProperties = {...cellStyle, fontWeight: tooltipStyle.fontWeight + 300}
|
|
192
147
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
148
|
+
// the series' values around the hovered point, over time, with the hovered point marked (when
|
|
149
|
+
// there are enough values to draw)
|
|
150
|
+
const sparkline = sparklineFor(
|
|
151
|
+
tooltipContent.sparklineValues, sparklineWidth, SPARKLINE_HEIGHT, 2, undefined, tooltipContent.hoveredTime
|
|
152
|
+
)
|
|
198
153
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
154
|
+
return <>
|
|
155
|
+
<div
|
|
156
|
+
ref={titleRef}
|
|
157
|
+
style={{fontSize: tooltipStyle.fontSize, fontWeight: tooltipStyle.fontWeight, marginBottom: 4, width: 'fit-content'}}
|
|
158
|
+
>
|
|
159
|
+
{tooltipContent.seriesName}
|
|
160
|
+
</div>
|
|
161
|
+
{/* (at its natural width, rather than the app's default full-width tables, so that it
|
|
162
|
+
can be measured for the sparkline's width) */}
|
|
163
|
+
<table ref={tableRef} style={{fontSize: tooltipStyle.fontSize, borderCollapse: 'collapse', border: 'none', width: 'auto'}}>
|
|
164
|
+
<thead>
|
|
165
|
+
<tr>
|
|
166
|
+
<td style={rowLabelStyle}/>
|
|
167
|
+
<td style={headerCellStyle}>{tooltipContent.prevHeader}</td>
|
|
168
|
+
<td style={{...headerCellStyle, ...currentColumnStyle}}>{tooltipContent.currentHeader}</td>
|
|
169
|
+
<td style={headerCellStyle}>{tooltipContent.nextHeader}</td>
|
|
170
|
+
</tr>
|
|
171
|
+
</thead>
|
|
172
|
+
<tbody>
|
|
173
|
+
<tr>
|
|
174
|
+
<td style={rowLabelStyle}>{tooltipContent.xLabel}</td>
|
|
175
|
+
<td style={cellStyle}>{tooltipContent.xPrev}</td>
|
|
176
|
+
<td style={currentColumnStyle}>{tooltipContent.xCurrent}</td>
|
|
177
|
+
<td style={cellStyle}>{tooltipContent.xNext}</td>
|
|
178
|
+
</tr>
|
|
179
|
+
<tr>
|
|
180
|
+
<td style={rowLabelStyle}>{tooltipContent.yLabel}</td>
|
|
181
|
+
<td style={cellStyle}>{tooltipContent.yPrev}</td>
|
|
182
|
+
<td style={currentColumnStyle}>{tooltipContent.yCurrent}</td>
|
|
183
|
+
<td style={cellStyle}>{tooltipContent.yNext}</td>
|
|
184
|
+
</tr>
|
|
185
|
+
</tbody>
|
|
186
|
+
</table>
|
|
187
|
+
{/* the series' values over time, with the hovered point marked (the dot) */}
|
|
188
|
+
{sparkline !== undefined && <>
|
|
189
|
+
<div style={{fontSize: tooltipStyle.fontSize, marginTop: 8}}>
|
|
190
|
+
{tooltipContent.yLabel} over time
|
|
191
|
+
</div>
|
|
192
|
+
<svg
|
|
193
|
+
width={sparklineWidth}
|
|
194
|
+
height={SPARKLINE_HEIGHT}
|
|
195
|
+
style={{display: 'block', marginTop: 4}}
|
|
196
|
+
aria-hidden="true"
|
|
197
|
+
>
|
|
198
|
+
<path
|
|
199
|
+
d={sparkline.path}
|
|
200
|
+
fill="none"
|
|
201
|
+
stroke={tooltipStyle.fontColor}
|
|
202
|
+
strokeWidth={1}
|
|
203
|
+
strokeLinejoin="round"
|
|
204
|
+
strokeLinecap="round"
|
|
205
|
+
/>
|
|
206
|
+
{sparkline.mark !== undefined &&
|
|
207
|
+
<circle
|
|
208
|
+
cx={sparkline.mark[0]}
|
|
209
|
+
cy={sparkline.mark[1]}
|
|
210
|
+
r={2.5}
|
|
211
|
+
fill={tooltipStyle.fontColor}
|
|
212
|
+
/>
|
|
213
|
+
}
|
|
214
|
+
</svg>
|
|
215
|
+
</>}
|
|
216
|
+
</>
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// the row labels and value formatters for the tooltip's table
|
|
220
|
+
interface CaptureOptions {
|
|
221
|
+
xLabel: string
|
|
222
|
+
yLabel: string
|
|
223
|
+
xValueFormatter: (value: number) => string
|
|
224
|
+
yValueFormatter: (value: number) => string
|
|
203
225
|
}
|
|
204
226
|
|
|
205
227
|
/**
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
228
|
+
* Captures the data needed to render the tooltip's content: the table (the hovered point, the
|
|
229
|
+
* first point within 0.1 of the plot's time, and its neighbors), and the series' values around
|
|
230
|
+
* the hovered point, over time, for the sparkline
|
|
231
|
+
* @param seriesName The name of the series
|
|
232
|
+
* @param time The time of the hovered point
|
|
209
233
|
* @param tooltipData The series data and metadata
|
|
210
|
-
* @param
|
|
211
|
-
* @
|
|
212
|
-
* @param container The plot container (SVGSVGElement)
|
|
213
|
-
* @param margin The plot margins
|
|
214
|
-
* @param tooltipStyle The style properties for the tooltip
|
|
215
|
-
* @param plotDimensions The dimensions of the plot
|
|
216
|
-
* @return The width and text height of the tooltip content
|
|
234
|
+
* @param options Header labels and value formatters
|
|
235
|
+
* @return The tooltip's content
|
|
217
236
|
*/
|
|
218
|
-
function
|
|
237
|
+
function captureTooltipContent(
|
|
219
238
|
seriesName: string,
|
|
220
239
|
time: number,
|
|
221
240
|
tooltipData: TooltipData<IterateDatum, NoTooltipMetadata>,
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
container: SVGSVGElement,
|
|
225
|
-
margin: Margin,
|
|
226
|
-
plotDimensions: Dimensions,
|
|
227
|
-
tooltipStyle: TooltipStyle
|
|
228
|
-
): TooltipDimensions {
|
|
229
|
-
const [x, y] = mouseCoords
|
|
241
|
+
options: CaptureOptions,
|
|
242
|
+
): PoincareTooltipContent {
|
|
230
243
|
const {series} = tooltipData
|
|
231
244
|
const [lower, point, upper, index] = findPointAndNeighbors(
|
|
232
245
|
series, time, 0.1, value => value.time, () => emptyIterateDatum
|
|
233
246
|
)
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
const font: TableFont = {
|
|
255
|
-
size: tooltipStyle.fontSize,
|
|
256
|
-
family: tooltipStyle.fontFamily,
|
|
257
|
-
color: tooltipStyle.fontColor,
|
|
258
|
-
weight: tooltipStyle.fontWeight
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
const padding: Padding = {
|
|
262
|
-
top: tooltipStyle.paddingTop,
|
|
263
|
-
bottom: tooltipStyle.paddingBottom,
|
|
264
|
-
right: tooltipStyle.paddingRight,
|
|
265
|
-
left: tooltipStyle.paddingLeft
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
const currentIterateStyle: CellStyle = {
|
|
269
|
-
border,
|
|
270
|
-
dimension,
|
|
271
|
-
background,
|
|
272
|
-
font: {...font, weight: 550},
|
|
273
|
-
padding,
|
|
274
|
-
alignText: 'right',
|
|
275
|
-
verticalAlignText: 'middle'
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
return DataFrame
|
|
279
|
-
.from<number | string>([
|
|
280
|
-
[lower.time, point.time, upper.time],
|
|
281
|
-
[lower.iterateN_1, point.iterateN_1, upper.iterateN_1]
|
|
282
|
-
])
|
|
283
|
-
// create the table data that has the column headers
|
|
284
|
-
.flatMap(df => TableData
|
|
285
|
-
.fromDataFrame(df)
|
|
286
|
-
.withColumnHeader([
|
|
287
|
-
index > 0 ? `f[${index - 1}](x)` : '- n/a -',
|
|
288
|
-
`f[${index}](x)`,
|
|
289
|
-
index < series.length - 1 ? `f[${index + 1}](x)` : '- n/a -'
|
|
290
|
-
])
|
|
291
|
-
.flatMap(td => td.withRowHeader(['t (ms)', 'value']))
|
|
292
|
-
)
|
|
293
|
-
// add the dat formatters for the (x, y) values of the iterates
|
|
294
|
-
.flatMap(tableData => TableFormatter.fromTableData(tableData)
|
|
295
|
-
.addRowFormatter(1, value => formatTime(value as number, ""))
|
|
296
|
-
.flatMap(tf => tf.addRowFormatter(2, value => formatValue(value as number)))
|
|
297
|
-
.flatMap(tf => tf.formatTable())
|
|
298
|
-
)
|
|
299
|
-
.map(tableData => TableStyler.fromTableData(tableData)
|
|
300
|
-
.withTableFont(font)
|
|
301
|
-
.withPadding(padding)
|
|
302
|
-
.withColumnHeaderStyle({
|
|
303
|
-
font: {...font, weight: 650},
|
|
304
|
-
padding: {top: 0, bottom: 10},
|
|
305
|
-
dimension: {...dimension, maxHeight: 70},
|
|
306
|
-
alignText: 'center',
|
|
307
|
-
})
|
|
308
|
-
.withRowHeaderStyle({
|
|
309
|
-
font: {...font, weight: 650},
|
|
310
|
-
padding: {left: 0, right: 10},
|
|
311
|
-
dimension: dimension,
|
|
312
|
-
alignText: 'center',
|
|
313
|
-
})
|
|
314
|
-
.withColumnStyles([], {
|
|
315
|
-
padding: {left: 10, right: 10},
|
|
316
|
-
alignText: 'right',
|
|
317
|
-
})
|
|
318
|
-
.withCellStyle(1, 2, currentIterateStyle)
|
|
319
|
-
.withCellStyle(2, 2, currentIterateStyle)
|
|
320
|
-
.withRowStyles([], {
|
|
321
|
-
font,
|
|
322
|
-
dimension: {...dimension, maxHeight: 20},
|
|
323
|
-
padding: {top: 0, bottom: 0}}
|
|
324
|
-
)
|
|
325
|
-
.styleTable()
|
|
326
|
-
)
|
|
327
|
-
.flatMap(styledTable =>
|
|
328
|
-
createTable(styledTable, container, `t${time}-${seriesName}-header-${chartId}`, tooltipCoordinates)
|
|
329
|
-
)
|
|
330
|
-
.map(renderingInfo => {
|
|
331
|
-
const {tableX: x, tableY: y, tableWidth: contentWidth, tableHeight: contentHeight} = renderingInfo
|
|
332
|
-
return {x, y, contentWidth, contentHeight}
|
|
333
|
-
})
|
|
334
|
-
.getOrThrow()
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Calculates the coordinates of the tooltip based on the width and height of the SVG
|
|
338
|
-
* table. This is needed because the tooltip needs to be adjusted relative mouse location
|
|
339
|
-
* when the mouse coordinates are too close to an edge.
|
|
340
|
-
* @param width The SVG table width
|
|
341
|
-
* @param height The SVG table height
|
|
342
|
-
* @return The updated tooltip coordinates
|
|
343
|
-
*/
|
|
344
|
-
function tooltipCoordinates(width: number, height: number): [x: number, y: number] {
|
|
345
|
-
return [
|
|
346
|
-
tooltipX(x, width, plotDimensions, tooltipStyle, margin),
|
|
347
|
-
tooltipY(y, height, plotDimensions, tooltipStyle, margin)
|
|
348
|
-
]
|
|
247
|
+
const {xLabel, yLabel, xValueFormatter, yValueFormatter} = options
|
|
248
|
+
|
|
249
|
+
return {
|
|
250
|
+
seriesName,
|
|
251
|
+
// (the headers are always the f[i](x) form, built from the point's index)
|
|
252
|
+
prevHeader: index > 0 ? `f[${index - 1}](x)` : '- n/a -',
|
|
253
|
+
currentHeader: `f[${index}](x)`,
|
|
254
|
+
nextHeader: index < series.length - 1 ? `f[${index + 1}](x)` : '- n/a -',
|
|
255
|
+
xLabel,
|
|
256
|
+
xPrev: xValueFormatter(lower.time),
|
|
257
|
+
xCurrent: xValueFormatter(point.time),
|
|
258
|
+
xNext: xValueFormatter(upper.time),
|
|
259
|
+
yLabel,
|
|
260
|
+
yPrev: yValueFormatter(lower.iterateN_1),
|
|
261
|
+
yCurrent: yValueFormatter(point.iterateN_1),
|
|
262
|
+
yNext: yValueFormatter(upper.iterateN_1),
|
|
263
|
+
sparklineValues: valuesAround(series, index, SPARKLINE_POINTS),
|
|
264
|
+
hoveredTime: point.time,
|
|
349
265
|
}
|
|
266
|
+
}
|
|
350
267
|
|
|
268
|
+
/**
|
|
269
|
+
* The values (each point's `f[n+1](x)`) of (at most) the specified number of points around the
|
|
270
|
+
* hovered point, over time: centered on the hovered point, or shifted to stay within the series
|
|
271
|
+
* when the hovered point is near its start or end
|
|
272
|
+
* @param series The series' iterates, ordered by time
|
|
273
|
+
* @param index The index of the hovered point (or -1, when it wasn't found)
|
|
274
|
+
* @param count The (largest) number of points
|
|
275
|
+
* @return The points' times and values, in order
|
|
276
|
+
*/
|
|
277
|
+
function valuesAround(
|
|
278
|
+
series: { length: number, [index: number]: IterateDatum },
|
|
279
|
+
index: number,
|
|
280
|
+
count: number
|
|
281
|
+
): Array<{ time: number, value: number }> {
|
|
282
|
+
if (index < 0) return []
|
|
283
|
+
const start = Math.max(0, Math.min(index - Math.floor(count / 2), series.length - count))
|
|
284
|
+
const end = Math.min(series.length, start + count)
|
|
285
|
+
const values: Array<{ time: number, value: number }> = []
|
|
286
|
+
for (let i = start; i < end; i++) values.push({time: series[i].time, value: series[i].iterateN_1})
|
|
287
|
+
return values
|
|
351
288
|
}
|