stream-charts 1.2.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +809 -1022
- package/changes.md +36 -0
- package/dist/app/charts/Chart.d.ts +35 -139
- package/dist/app/charts/Chart.d.ts.map +1 -0
- package/dist/app/charts/Chart.js +74 -65
- package/dist/app/charts/Chart.js.map +1 -1
- package/dist/app/charts/axes/AxesState.d.ts +26 -18
- package/dist/app/charts/axes/AxesState.d.ts.map +1 -0
- package/dist/app/charts/axes/AxesState.js +26 -24
- package/dist/app/charts/axes/AxesState.js.map +1 -1
- package/dist/app/charts/axes/AxisInterval.d.ts +44 -26
- package/dist/app/charts/axes/AxisInterval.d.ts.map +1 -0
- package/dist/app/charts/axes/AxisInterval.js +48 -29
- package/dist/app/charts/axes/AxisInterval.js.map +1 -1
- package/dist/app/charts/axes/BaseAxisRange.d.ts +46 -22
- package/dist/app/charts/axes/BaseAxisRange.d.ts.map +1 -0
- package/dist/app/charts/axes/BaseAxisRange.js +17 -12
- package/dist/app/charts/axes/BaseAxisRange.js.map +1 -1
- package/dist/app/charts/axes/ContinuousAxis.d.ts +47 -6
- package/dist/app/charts/axes/ContinuousAxis.d.ts.map +1 -0
- package/dist/app/charts/axes/ContinuousAxis.js +160 -27
- package/dist/app/charts/axes/ContinuousAxis.js.map +1 -1
- package/dist/app/charts/axes/ContinuousAxisRange.d.ts +29 -10
- package/dist/app/charts/axes/ContinuousAxisRange.d.ts.map +1 -0
- package/dist/app/charts/axes/ContinuousAxisRange.js +29 -11
- package/dist/app/charts/axes/ContinuousAxisRange.js.map +1 -1
- package/dist/app/charts/axes/EmptyAxis.d.ts +5 -2
- package/dist/app/charts/axes/EmptyAxis.d.ts.map +1 -0
- package/dist/app/charts/axes/EmptyAxis.js +30 -9
- package/dist/app/charts/axes/EmptyAxis.js.map +1 -1
- package/dist/app/charts/axes/OrdinalAxis.d.ts +5 -3
- package/dist/app/charts/axes/OrdinalAxis.d.ts.map +1 -0
- package/dist/app/charts/axes/OrdinalAxis.js +39 -16
- package/dist/app/charts/axes/OrdinalAxis.js.map +1 -1
- package/dist/app/charts/axes/OrdinalAxisRange.d.ts +76 -13
- package/dist/app/charts/axes/OrdinalAxisRange.d.ts.map +1 -0
- package/dist/app/charts/axes/OrdinalAxisRange.js +95 -16
- package/dist/app/charts/axes/OrdinalAxisRange.js.map +1 -1
- package/dist/app/charts/axes/autoScale.d.ts +111 -0
- package/dist/app/charts/axes/autoScale.d.ts.map +1 -0
- package/dist/app/charts/axes/autoScale.js +188 -0
- package/dist/app/charts/axes/autoScale.js.map +1 -0
- package/dist/app/charts/axes/axes.d.ts +273 -150
- package/dist/app/charts/axes/axes.d.ts.map +1 -0
- package/dist/app/charts/axes/axes.js +808 -583
- package/dist/app/charts/axes/axes.js.map +1 -1
- package/dist/app/charts/d3types.d.ts +40 -11
- package/dist/app/charts/d3types.d.ts.map +1 -0
- package/dist/app/charts/d3types.js +3 -0
- package/dist/app/charts/d3types.js.map +1 -1
- package/dist/app/charts/datasources/StreamingDataSource.d.ts +149 -0
- package/dist/app/charts/datasources/StreamingDataSource.d.ts.map +1 -0
- package/dist/app/charts/datasources/StreamingDataSource.js +110 -0
- package/dist/app/charts/datasources/StreamingDataSource.js.map +1 -0
- package/dist/app/charts/datasources/iteratesDataSource.d.ts +73 -0
- package/dist/app/charts/datasources/iteratesDataSource.d.ts.map +1 -0
- package/dist/app/charts/datasources/iteratesDataSource.js +87 -0
- package/dist/app/charts/datasources/iteratesDataSource.js.map +1 -0
- package/dist/app/charts/datasources/ordinalDataSource.d.ts +75 -0
- package/dist/app/charts/datasources/ordinalDataSource.d.ts.map +1 -0
- package/dist/app/charts/datasources/ordinalDataSource.js +135 -0
- package/dist/app/charts/datasources/ordinalDataSource.js.map +1 -0
- package/dist/app/charts/datasources/outlierDataSource.d.ts +53 -0
- package/dist/app/charts/datasources/outlierDataSource.d.ts.map +1 -0
- package/dist/app/charts/datasources/outlierDataSource.js +57 -0
- package/dist/app/charts/datasources/outlierDataSource.js.map +1 -0
- package/dist/app/charts/datasources/timeSeriesDataSource.d.ts +77 -0
- package/dist/app/charts/datasources/timeSeriesDataSource.d.ts.map +1 -0
- package/dist/app/charts/datasources/timeSeriesDataSource.js +85 -0
- package/dist/app/charts/datasources/timeSeriesDataSource.js.map +1 -0
- package/dist/app/charts/filters/regexFilter.d.ts +31 -4
- package/dist/app/charts/filters/regexFilter.d.ts.map +1 -0
- package/dist/app/charts/filters/regexFilter.js +38 -4
- package/dist/app/charts/filters/regexFilter.js.map +1 -1
- package/dist/app/charts/hooks/AxesProvider.d.ts +21 -0
- package/dist/app/charts/hooks/AxesProvider.d.ts.map +1 -0
- package/dist/app/charts/hooks/AxesProvider.js +213 -0
- package/dist/app/charts/hooks/AxesProvider.js.map +1 -0
- package/dist/app/charts/hooks/CanvasSurfaceProvider.d.ts +25 -0
- package/dist/app/charts/hooks/CanvasSurfaceProvider.d.ts.map +1 -0
- package/dist/app/charts/hooks/CanvasSurfaceProvider.js +76 -0
- package/dist/app/charts/hooks/CanvasSurfaceProvider.js.map +1 -0
- package/dist/app/charts/hooks/ChartProvider.d.ts +40 -0
- package/dist/app/charts/hooks/ChartProvider.d.ts.map +1 -0
- package/dist/app/charts/hooks/ChartProvider.js +33 -0
- package/dist/app/charts/hooks/ChartProvider.js.map +1 -0
- package/dist/app/charts/hooks/InteractionProvider.d.ts +23 -0
- package/dist/app/charts/hooks/InteractionProvider.d.ts.map +1 -0
- package/dist/app/charts/hooks/InteractionProvider.js +60 -0
- package/dist/app/charts/hooks/InteractionProvider.js.map +1 -0
- package/dist/app/charts/hooks/PlotDimensionsProvider.d.ts +16 -0
- package/dist/app/charts/hooks/PlotDimensionsProvider.d.ts.map +1 -0
- package/dist/app/charts/hooks/PlotDimensionsProvider.js +76 -0
- package/dist/app/charts/hooks/PlotDimensionsProvider.js.map +1 -0
- package/dist/app/charts/hooks/defaultAxesValues.d.ts +11 -0
- package/dist/app/charts/hooks/defaultAxesValues.d.ts.map +1 -0
- package/dist/app/charts/hooks/defaultAxesValues.js +36 -0
- package/dist/app/charts/hooks/defaultAxesValues.js.map +1 -0
- package/dist/app/charts/hooks/defaultMouseValues.d.ts +9 -0
- package/dist/app/charts/hooks/defaultMouseValues.d.ts.map +1 -0
- package/dist/app/charts/hooks/defaultMouseValues.js +23 -0
- package/dist/app/charts/hooks/defaultMouseValues.js.map +1 -0
- package/dist/app/charts/hooks/defaultPlotDimensions.d.ts +13 -0
- package/dist/app/charts/hooks/defaultPlotDimensions.d.ts.map +1 -0
- package/dist/app/charts/hooks/defaultPlotDimensions.js +23 -0
- package/dist/app/charts/hooks/defaultPlotDimensions.js.map +1 -0
- package/dist/app/charts/hooks/defaultTooltipValues.d.ts +9 -0
- package/dist/app/charts/hooks/defaultTooltipValues.d.ts.map +1 -0
- package/dist/app/charts/hooks/defaultTooltipValues.js +21 -0
- package/dist/app/charts/hooks/defaultTooltipValues.js.map +1 -0
- package/dist/app/charts/hooks/defaultUseChartValues.d.ts +14 -0
- package/dist/app/charts/hooks/defaultUseChartValues.d.ts.map +1 -0
- package/dist/app/charts/hooks/defaultUseChartValues.js +30 -0
- package/dist/app/charts/hooks/defaultUseChartValues.js.map +1 -0
- package/dist/app/charts/hooks/useAxes.d.ts +49 -36
- package/dist/app/charts/hooks/useAxes.d.ts.map +1 -0
- package/dist/app/charts/hooks/useAxes.js +16 -176
- package/dist/app/charts/hooks/useAxes.js.map +1 -1
- package/dist/app/charts/hooks/useCanvasSurface.d.ts +25 -0
- package/dist/app/charts/hooks/useCanvasSurface.d.ts.map +1 -0
- package/dist/app/charts/hooks/useCanvasSurface.js +18 -0
- package/dist/app/charts/hooks/useCanvasSurface.js.map +1 -0
- package/dist/app/charts/hooks/useChart.d.ts +30 -44
- package/dist/app/charts/hooks/useChart.d.ts.map +1 -0
- package/dist/app/charts/hooks/useChart.js +26 -48
- package/dist/app/charts/hooks/useChart.js.map +1 -1
- package/dist/app/charts/hooks/useDataSource.d.ts +68 -0
- package/dist/app/charts/hooks/useDataSource.d.ts.map +1 -0
- package/dist/app/charts/hooks/useDataSource.js +63 -0
- package/dist/app/charts/hooks/useDataSource.js.map +1 -0
- package/dist/app/charts/hooks/useHoveredSeries.d.ts +25 -0
- package/dist/app/charts/hooks/useHoveredSeries.d.ts.map +1 -0
- package/dist/app/charts/hooks/useHoveredSeries.js +15 -0
- package/dist/app/charts/hooks/useHoveredSeries.js.map +1 -0
- package/dist/app/charts/hooks/useMouse.d.ts +46 -22
- package/dist/app/charts/hooks/useMouse.d.ts.map +1 -0
- package/dist/app/charts/hooks/useMouse.js +12 -56
- package/dist/app/charts/hooks/useMouse.js.map +1 -1
- package/dist/app/charts/hooks/usePlotDimensions.d.ts +25 -13
- package/dist/app/charts/hooks/usePlotDimensions.d.ts.map +1 -0
- package/dist/app/charts/hooks/usePlotDimensions.js +6 -62
- package/dist/app/charts/hooks/usePlotDimensions.js.map +1 -1
- package/dist/app/charts/hooks/useTooltip.d.ts +24 -26
- package/dist/app/charts/hooks/useTooltip.d.ts.map +1 -0
- package/dist/app/charts/hooks/useTooltip.js +12 -42
- package/dist/app/charts/hooks/useTooltip.js.map +1 -1
- package/dist/app/charts/index.d.ts +66 -0
- package/dist/app/charts/index.d.ts.map +1 -0
- package/dist/app/charts/index.js +87 -0
- package/dist/app/charts/index.js.map +1 -0
- package/dist/app/charts/legends/Legend.d.ts +33 -12
- package/dist/app/charts/legends/Legend.d.ts.map +1 -0
- package/dist/app/charts/legends/Legend.js +138 -379
- package/dist/app/charts/legends/Legend.js.map +1 -1
- package/dist/app/charts/legends/constants.d.ts +19 -0
- package/dist/app/charts/legends/constants.d.ts.map +1 -0
- package/dist/app/charts/legends/constants.js +34 -0
- package/dist/app/charts/legends/constants.js.map +1 -0
- package/dist/app/charts/observables/ChartData.d.ts +1 -0
- package/dist/app/charts/observables/ChartData.d.ts.map +1 -0
- package/dist/app/charts/observables/iterates.d.ts +13 -7
- package/dist/app/charts/observables/iterates.d.ts.map +1 -0
- package/dist/app/charts/observables/iterates.js +42 -9
- package/dist/app/charts/observables/iterates.js.map +1 -1
- package/dist/app/charts/observables/ordinals.d.ts +70 -12
- package/dist/app/charts/observables/ordinals.d.ts.map +1 -0
- package/dist/app/charts/observables/ordinals.js +127 -48
- package/dist/app/charts/observables/ordinals.js.map +1 -1
- package/dist/app/charts/observables/outliers.d.ts +18 -0
- package/dist/app/charts/observables/outliers.d.ts.map +1 -0
- package/dist/app/charts/observables/outliers.js +2 -0
- package/dist/app/charts/observables/outliers.js.map +1 -0
- package/dist/app/charts/plots/BarPlot.d.ts +87 -13
- package/dist/app/charts/plots/BarPlot.d.ts.map +1 -0
- package/dist/app/charts/plots/BarPlot.js +603 -356
- package/dist/app/charts/plots/BarPlot.js.map +1 -1
- package/dist/app/charts/plots/OutlierPlot.d.ts +123 -0
- package/dist/app/charts/plots/OutlierPlot.d.ts.map +1 -0
- package/dist/app/charts/plots/OutlierPlot.js +430 -0
- package/dist/app/charts/plots/OutlierPlot.js.map +1 -0
- package/dist/app/charts/plots/PoincarePlot.d.ts +92 -14
- package/dist/app/charts/plots/PoincarePlot.d.ts.map +1 -0
- package/dist/app/charts/plots/PoincarePlot.js +523 -364
- package/dist/app/charts/plots/PoincarePlot.js.map +1 -1
- package/dist/app/charts/plots/RasterPlot.d.ts +31 -10
- package/dist/app/charts/plots/RasterPlot.d.ts.map +1 -0
- package/dist/app/charts/plots/RasterPlot.js +198 -306
- package/dist/app/charts/plots/RasterPlot.js.map +1 -1
- package/dist/app/charts/plots/ScatterPlot.d.ts +77 -21
- package/dist/app/charts/plots/ScatterPlot.d.ts.map +1 -0
- package/dist/app/charts/plots/ScatterPlot.js +359 -302
- package/dist/app/charts/plots/ScatterPlot.js.map +1 -1
- package/dist/app/charts/plots/autoScaleYAxes.d.ts +43 -0
- package/dist/app/charts/plots/autoScaleYAxes.d.ts.map +1 -0
- package/dist/app/charts/plots/autoScaleYAxes.js +71 -0
- package/dist/app/charts/plots/autoScaleYAxes.js.map +1 -0
- package/dist/app/charts/plots/colorizedLine.d.ts +61 -0
- package/dist/app/charts/plots/colorizedLine.d.ts.map +1 -0
- package/dist/app/charts/plots/colorizedLine.js +157 -0
- package/dist/app/charts/plots/colorizedLine.js.map +1 -0
- package/dist/app/charts/plots/constants.d.ts +7 -0
- package/dist/app/charts/plots/constants.d.ts.map +1 -0
- package/dist/app/charts/plots/constants.js +11 -0
- package/dist/app/charts/plots/constants.js.map +1 -0
- package/dist/app/charts/plots/hitTesting.d.ts +88 -0
- package/dist/app/charts/plots/hitTesting.d.ts.map +1 -0
- package/dist/app/charts/plots/hitTesting.js +136 -0
- package/dist/app/charts/plots/hitTesting.js.map +1 -0
- package/dist/app/charts/plots/plot.d.ts +52 -16
- package/dist/app/charts/plots/plot.d.ts.map +1 -0
- package/dist/app/charts/plots/plot.js +108 -35
- package/dist/app/charts/plots/plot.js.map +1 -1
- package/dist/app/charts/plots/useCanvasZoomPan.d.ts +119 -0
- package/dist/app/charts/plots/useCanvasZoomPan.d.ts.map +1 -0
- package/dist/app/charts/plots/useCanvasZoomPan.js +113 -0
- package/dist/app/charts/plots/useCanvasZoomPan.js.map +1 -0
- package/dist/app/charts/plots/useStreamingTimeAxes.d.ts +103 -0
- package/dist/app/charts/plots/useStreamingTimeAxes.d.ts.map +1 -0
- package/dist/app/charts/plots/useStreamingTimeAxes.js +257 -0
- package/dist/app/charts/plots/useStreamingTimeAxes.js.map +1 -0
- package/dist/app/charts/series/baseSeries.d.ts +60 -8
- package/dist/app/charts/series/baseSeries.d.ts.map +1 -0
- package/dist/app/charts/series/baseSeries.js +53 -8
- package/dist/app/charts/series/baseSeries.js.map +1 -1
- package/dist/app/charts/series/iterateSeries.d.ts +9 -8
- package/dist/app/charts/series/iterateSeries.d.ts.map +1 -0
- package/dist/app/charts/series/iterateSeries.js +7 -7
- package/dist/app/charts/series/iterateSeries.js.map +1 -1
- package/dist/app/charts/series/ordinalSeries.d.ts +27 -13
- package/dist/app/charts/series/ordinalSeries.d.ts.map +1 -0
- package/dist/app/charts/series/ordinalSeries.js +29 -15
- package/dist/app/charts/series/ordinalSeries.js.map +1 -1
- package/dist/app/charts/series/outlierSeries.d.ts +142 -0
- package/dist/app/charts/series/outlierSeries.d.ts.map +1 -0
- package/dist/app/charts/series/outlierSeries.js +82 -0
- package/dist/app/charts/series/outlierSeries.js.map +1 -0
- package/dist/app/charts/series/timeSeries.d.ts +13 -9
- package/dist/app/charts/series/timeSeries.d.ts.map +1 -0
- package/dist/app/charts/series/timeSeries.js +6 -3
- package/dist/app/charts/series/timeSeries.js.map +1 -1
- package/dist/app/charts/series/timeSeriesChartData.d.ts +18 -10
- package/dist/app/charts/series/timeSeriesChartData.d.ts.map +1 -0
- package/dist/app/charts/series/timeSeriesChartData.js +28 -14
- package/dist/app/charts/series/timeSeriesChartData.js.map +1 -1
- package/dist/app/charts/styling/barPlotStyle.d.ts +46 -2
- package/dist/app/charts/styling/barPlotStyle.d.ts.map +1 -0
- package/dist/app/charts/styling/barPlotStyle.js +37 -3
- package/dist/app/charts/styling/barPlotStyle.js.map +1 -1
- package/dist/app/charts/styling/canvasStyle.d.ts +53 -0
- package/dist/app/charts/styling/canvasStyle.d.ts.map +1 -0
- package/dist/app/charts/styling/canvasStyle.js +71 -0
- package/dist/app/charts/styling/canvasStyle.js.map +1 -0
- package/dist/app/charts/styling/margins.d.ts +21 -2
- package/dist/app/charts/styling/margins.d.ts.map +1 -0
- package/dist/app/charts/styling/margins.js +25 -4
- package/dist/app/charts/styling/margins.js.map +1 -1
- package/dist/app/charts/styling/svgStyle.d.ts +10 -56
- package/dist/app/charts/styling/svgStyle.d.ts.map +1 -0
- package/dist/app/charts/styling/svgStyle.js +3 -78
- package/dist/app/charts/styling/svgStyle.js.map +1 -1
- package/dist/app/charts/subscriptions/viewDrivers.d.ts +124 -0
- package/dist/app/charts/subscriptions/viewDrivers.d.ts.map +1 -0
- package/dist/app/charts/subscriptions/viewDrivers.js +338 -0
- package/dist/app/charts/subscriptions/viewDrivers.js.map +1 -0
- package/dist/app/charts/tooltips/BarPlotTooltipContent.d.ts +12 -78
- package/dist/app/charts/tooltips/BarPlotTooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/BarPlotTooltipContent.js +65 -257
- package/dist/app/charts/tooltips/BarPlotTooltipContent.js.map +1 -1
- package/dist/app/charts/tooltips/DefaultOutlierTooltipContent.d.ts +9 -0
- package/dist/app/charts/tooltips/DefaultOutlierTooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/DefaultOutlierTooltipContent.js +16 -0
- package/dist/app/charts/tooltips/DefaultOutlierTooltipContent.js.map +1 -0
- package/dist/app/charts/tooltips/OutlierPlotTooltipContent.d.ts +30 -0
- package/dist/app/charts/tooltips/OutlierPlotTooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/OutlierPlotTooltipContent.js +26 -0
- package/dist/app/charts/tooltips/OutlierPlotTooltipContent.js.map +1 -0
- package/dist/app/charts/tooltips/PoincarePlotTooltipContent.d.ts +22 -72
- package/dist/app/charts/tooltips/PoincarePlotTooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/PoincarePlotTooltipContent.js +104 -171
- package/dist/app/charts/tooltips/PoincarePlotTooltipContent.js.map +1 -1
- package/dist/app/charts/tooltips/RasterPlotTooltipContent.d.ts +32 -8
- package/dist/app/charts/tooltips/RasterPlotTooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/RasterPlotTooltipContent.js +62 -115
- package/dist/app/charts/tooltips/RasterPlotTooltipContent.js.map +1 -1
- package/dist/app/charts/tooltips/ScatterPlotTooltipContent.d.ts +39 -12
- package/dist/app/charts/tooltips/ScatterPlotTooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/ScatterPlotTooltipContent.js +162 -134
- package/dist/app/charts/tooltips/ScatterPlotTooltipContent.js.map +1 -1
- package/dist/app/charts/tooltips/Tooltip.d.ts +27 -32
- package/dist/app/charts/tooltips/Tooltip.d.ts.map +1 -0
- package/dist/app/charts/tooltips/Tooltip.js +37 -81
- package/dist/app/charts/tooltips/Tooltip.js.map +1 -1
- package/dist/app/charts/tooltips/TooltipContent.d.ts +81 -0
- package/dist/app/charts/tooltips/TooltipContent.d.ts.map +1 -0
- package/dist/app/charts/tooltips/TooltipContent.js +99 -0
- package/dist/app/charts/tooltips/TooltipContent.js.map +1 -0
- package/dist/app/charts/tooltips/tooltipUtils.d.ts +186 -36
- package/dist/app/charts/tooltips/tooltipUtils.d.ts.map +1 -0
- package/dist/app/charts/tooltips/tooltipUtils.js +277 -48
- package/dist/app/charts/tooltips/tooltipUtils.js.map +1 -1
- package/dist/app/charts/tooltips/useOutlierTooltip.d.ts +59 -0
- package/dist/app/charts/tooltips/useOutlierTooltip.d.ts.map +1 -0
- package/dist/app/charts/tooltips/useOutlierTooltip.js +16 -0
- package/dist/app/charts/tooltips/useOutlierTooltip.js.map +1 -0
- package/dist/app/charts/tooltips/useTooltipPlacement.d.ts +51 -0
- package/dist/app/charts/tooltips/useTooltipPlacement.d.ts.map +1 -0
- package/dist/app/charts/tooltips/useTooltipPlacement.js +52 -0
- package/dist/app/charts/tooltips/useTooltipPlacement.js.map +1 -0
- package/dist/app/charts/tooltips/useTooltipStyle.d.ts +11 -0
- package/dist/app/charts/tooltips/useTooltipStyle.d.ts.map +1 -0
- package/dist/app/charts/tooltips/useTooltipStyle.js +14 -0
- package/dist/app/charts/tooltips/useTooltipStyle.js.map +1 -0
- package/dist/app/charts/trackers/Tracker.d.ts +22 -6
- package/dist/app/charts/trackers/Tracker.d.ts.map +1 -0
- package/dist/app/charts/trackers/Tracker.js +36 -22
- package/dist/app/charts/trackers/Tracker.js.map +1 -1
- package/dist/app/charts/trackers/trackerUtils.d.ts +40 -18
- package/dist/app/charts/trackers/trackerUtils.d.ts.map +1 -0
- package/dist/app/charts/trackers/trackerUtils.js +213 -300
- package/dist/app/charts/trackers/trackerUtils.js.map +1 -1
- package/dist/app/charts/utils.d.ts +72 -33
- package/dist/app/charts/utils.d.ts.map +1 -0
- package/dist/app/charts/utils.js +87 -42
- package/dist/app/charts/utils.js.map +1 -1
- package/dist/index.d.ts +2 -45
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -72
- package/dist/index.js.map +1 -1
- package/package.json +87 -46
- package/src/app/charts/Chart.tsx +132 -168
- package/src/app/charts/axes/AxesState.ts +27 -29
- package/src/app/charts/axes/AxisInterval.ts +57 -32
- package/src/app/charts/axes/BaseAxisRange.ts +47 -27
- package/src/app/charts/axes/ContinuousAxis.tsx +235 -39
- package/src/app/charts/axes/ContinuousAxisRange.ts +29 -11
- package/src/app/charts/axes/EmptyAxis.tsx +52 -17
- package/src/app/charts/axes/OrdinalAxis.tsx +54 -28
- package/src/app/charts/axes/OrdinalAxisRange.ts +96 -16
- package/src/app/charts/axes/autoScale.ts +244 -0
- package/src/app/charts/axes/axes.ts +954 -735
- package/src/app/charts/d3types.ts +42 -13
- package/src/app/charts/datasources/StreamingDataSource.ts +214 -0
- package/src/app/charts/datasources/iteratesDataSource.ts +122 -0
- package/src/app/charts/datasources/ordinalDataSource.ts +205 -0
- package/src/app/charts/datasources/outlierDataSource.ts +90 -0
- package/src/app/charts/datasources/timeSeriesDataSource.ts +133 -0
- package/src/app/charts/filters/regexFilter.ts +45 -5
- package/src/app/charts/hooks/AxesProvider.tsx +301 -0
- package/src/app/charts/hooks/CanvasSurfaceProvider.tsx +117 -0
- package/src/app/charts/hooks/ChartProvider.tsx +79 -0
- package/src/app/charts/hooks/InteractionProvider.tsx +88 -0
- package/src/app/charts/hooks/PlotDimensionsProvider.tsx +109 -0
- package/src/app/charts/hooks/defaultAxesValues.ts +40 -0
- package/src/app/charts/hooks/defaultMouseValues.ts +24 -0
- package/src/app/charts/hooks/defaultPlotDimensions.ts +27 -0
- package/src/app/charts/hooks/defaultTooltipValues.tsx +23 -0
- package/src/app/charts/hooks/defaultUseChartValues.tsx +36 -0
- package/src/app/charts/hooks/useAxes.tsx +60 -228
- package/src/app/charts/hooks/useCanvasSurface.tsx +35 -0
- package/src/app/charts/hooks/useChart.tsx +47 -106
- package/src/app/charts/hooks/useDataSource.tsx +106 -0
- package/src/app/charts/hooks/useHoveredSeries.tsx +33 -0
- package/src/app/charts/hooks/useMouse.tsx +58 -82
- package/src/app/charts/hooks/usePlotDimensions.tsx +25 -89
- package/src/app/charts/hooks/useTooltip.tsx +32 -63
- package/src/app/charts/index.ts +213 -0
- package/src/app/charts/legends/Legend.tsx +198 -479
- package/src/app/charts/legends/constants.ts +37 -0
- package/src/app/charts/observables/iterates.ts +32 -12
- package/src/app/charts/observables/ordinals.ts +141 -67
- package/src/app/charts/observables/outliers.ts +20 -0
- package/src/app/charts/plots/BarPlot.tsx +784 -666
- package/src/app/charts/plots/OutlierPlot.tsx +685 -0
- package/src/app/charts/plots/PoincarePlot.tsx +707 -489
- package/src/app/charts/plots/RasterPlot.tsx +253 -445
- package/src/app/charts/plots/ScatterPlot.tsx +480 -463
- package/src/app/charts/plots/autoScaleYAxes.ts +102 -0
- package/src/app/charts/plots/colorizedLine.ts +185 -0
- package/src/app/charts/plots/constants.ts +16 -0
- package/src/app/charts/plots/hitTesting.ts +198 -0
- package/src/app/charts/plots/plot.ts +138 -44
- package/src/app/charts/plots/useCanvasZoomPan.ts +240 -0
- package/src/app/charts/plots/useStreamingTimeAxes.ts +384 -0
- package/src/app/charts/series/baseSeries.ts +81 -14
- package/src/app/charts/series/iterateSeries.ts +8 -8
- package/src/app/charts/series/ordinalSeries.ts +35 -20
- package/src/app/charts/series/outlierSeries.ts +188 -0
- package/src/app/charts/series/timeSeries.ts +14 -12
- package/src/app/charts/series/timeSeriesChartData.ts +31 -17
- package/src/app/charts/styling/barPlotStyle.ts +48 -5
- package/src/app/charts/styling/canvasStyle.ts +86 -0
- package/src/app/charts/styling/margins.ts +28 -4
- package/src/app/charts/styling/svgStyle.ts +10 -91
- package/src/app/charts/subscriptions/viewDrivers.ts +447 -0
- package/src/app/charts/tooltips/BarPlotTooltipContent.tsx +156 -380
- package/src/app/charts/tooltips/DefaultOutlierTooltipContent.tsx +40 -0
- package/src/app/charts/tooltips/OutlierPlotTooltipContent.tsx +67 -0
- package/src/app/charts/tooltips/PoincarePlotTooltipContent.tsx +229 -292
- package/src/app/charts/tooltips/RasterPlotTooltipContent.tsx +164 -217
- package/src/app/charts/tooltips/ScatterPlotTooltipContent.tsx +373 -236
- package/src/app/charts/tooltips/Tooltip.tsx +58 -124
- package/src/app/charts/tooltips/TooltipContent.tsx +177 -0
- package/src/app/charts/tooltips/tooltipUtils.ts +359 -61
- package/src/app/charts/tooltips/useOutlierTooltip.tsx +68 -0
- package/src/app/charts/tooltips/useTooltipPlacement.ts +86 -0
- package/src/app/charts/tooltips/useTooltipStyle.ts +15 -0
- package/src/app/charts/trackers/Tracker.tsx +68 -33
- package/src/app/charts/trackers/trackerUtils.ts +263 -376
- package/src/app/charts/utils.ts +90 -48
- package/src/index.ts +2 -322
- package/dist/app/charts/axes/AxesState.test.d.ts +0 -1
- package/dist/app/charts/axes/AxesState.test.js +0 -30
- package/dist/app/charts/axes/AxesState.test.js.map +0 -1
- package/dist/app/charts/axes/AxisInterval.test.d.ts +0 -1
- package/dist/app/charts/axes/AxisInterval.test.js +0 -120
- package/dist/app/charts/axes/AxisInterval.test.js.map +0 -1
- package/dist/app/charts/axes/ContinuousAxisRange.test.d.ts +0 -1
- package/dist/app/charts/axes/ContinuousAxisRange.test.js +0 -47
- package/dist/app/charts/axes/ContinuousAxisRange.test.js.map +0 -1
- package/dist/app/charts/axes/OrdinalAxisRange.test.d.ts +0 -1
- package/dist/app/charts/axes/OrdinalAxisRange.test.js +0 -48
- package/dist/app/charts/axes/OrdinalAxisRange.test.js.map +0 -1
- package/dist/app/charts/filters/regexFilter.test.d.ts +0 -1
- package/dist/app/charts/filters/regexFilter.test.js +0 -11
- package/dist/app/charts/filters/regexFilter.test.js.map +0 -1
- package/dist/app/charts/hooks/useDataObservable.d.ts +0 -72
- package/dist/app/charts/hooks/useDataObservable.js +0 -74
- package/dist/app/charts/hooks/useDataObservable.js.map +0 -1
- package/dist/app/charts/hooks/useInitialData.d.ts +0 -36
- package/dist/app/charts/hooks/useInitialData.js +0 -28
- package/dist/app/charts/hooks/useInitialData.js.map +0 -1
- package/dist/app/charts/observables/iterates.test.d.ts +0 -1
- package/dist/app/charts/observables/iterates.test.js +0 -180
- package/dist/app/charts/observables/iterates.test.js.map +0 -1
- package/dist/app/charts/observables/ordinals.test.d.ts +0 -1
- package/dist/app/charts/observables/ordinals.test.js +0 -102
- package/dist/app/charts/observables/ordinals.test.js.map +0 -1
- package/dist/app/charts/series/datumSeries.test.d.ts +0 -1
- package/dist/app/charts/series/datumSeries.test.js +0 -50
- package/dist/app/charts/series/datumSeries.test.js.map +0 -1
- package/dist/app/charts/styling/margins.test.d.ts +0 -1
- package/dist/app/charts/styling/margins.test.js +0 -19
- package/dist/app/charts/styling/margins.test.js.map +0 -1
- package/dist/app/charts/subscriptions/subscription.test.d.ts +0 -1
- package/dist/app/charts/subscriptions/subscription.test.js +0 -395
- package/dist/app/charts/subscriptions/subscription.test.js.map +0 -1
- package/dist/app/charts/subscriptions/subscriptions.d.ts +0 -100
- package/dist/app/charts/subscriptions/subscriptions.js +0 -449
- package/dist/app/charts/subscriptions/subscriptions.js.map +0 -1
- package/src/app/charts/axes/AxesState.test.ts +0 -34
- package/src/app/charts/axes/AxisInterval.test.ts +0 -143
- package/src/app/charts/axes/ContinuousAxisRange.test.ts +0 -55
- package/src/app/charts/axes/OrdinalAxisRange.test.ts +0 -55
- package/src/app/charts/filters/regexFilter.test.ts +0 -13
- package/src/app/charts/hooks/useDataObservable.tsx +0 -170
- package/src/app/charts/hooks/useInitialData.tsx +0 -64
- package/src/app/charts/observables/iterates.test.ts +0 -201
- package/src/app/charts/observables/ordinals.test.ts +0 -135
- package/src/app/charts/series/datumSeries.test.ts +0 -60
- package/src/app/charts/styling/margins.test.ts +0 -22
- package/src/app/charts/subscriptions/subscription.test.ts +0 -499
- package/src/app/charts/subscriptions/subscriptions.ts +0 -635
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {BaseSeries, seriesFrom} from "./baseSeries";
|
|
1
|
+
import {type BaseSeries, seriesFrom} from "./baseSeries";
|
|
2
2
|
import {
|
|
3
3
|
initialMaxTimeDatum,
|
|
4
4
|
initialMaxValueDatum, initialMinTimeDatum,
|
|
5
5
|
initialMinValueDatum,
|
|
6
|
-
OrdinalChartData,
|
|
7
|
-
OrdinalStats,
|
|
8
|
-
OrdinalValueStats
|
|
6
|
+
type OrdinalChartData,
|
|
7
|
+
type OrdinalStats,
|
|
8
|
+
type OrdinalValueStats
|
|
9
9
|
} from "../observables/ordinals";
|
|
10
|
+
import type {FastShiftArray} from "fast-shift-array";
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* An immutable datum object for series with a category and value.
|
|
@@ -22,7 +23,7 @@ export interface OrdinalDatum {
|
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
|
-
*
|
|
26
|
+
* An empty ordinal datum (`NaN` time and value, and an empty ordinal)
|
|
26
27
|
*/
|
|
27
28
|
export const emptyOrdinalDatum: OrdinalDatum = {
|
|
28
29
|
time: NaN,
|
|
@@ -30,6 +31,11 @@ export const emptyOrdinalDatum: OrdinalDatum = {
|
|
|
30
31
|
value: NaN,
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Copies an ordinal datum
|
|
36
|
+
* @param datum The datum to copy
|
|
37
|
+
* @return The copy
|
|
38
|
+
*/
|
|
33
39
|
export const copyOrdinalDatum = (datum: OrdinalDatum): OrdinalDatum => ({
|
|
34
40
|
time: datum.time,
|
|
35
41
|
ordinal: datum.ordinal,
|
|
@@ -37,11 +43,11 @@ export const copyOrdinalDatum = (datum: OrdinalDatum): OrdinalDatum => ({
|
|
|
37
43
|
})
|
|
38
44
|
|
|
39
45
|
/**
|
|
40
|
-
* Creates an
|
|
46
|
+
* Creates an ordinal datum
|
|
41
47
|
* @param time The datum time, which is mostly informational
|
|
42
48
|
* @param ordinal The category name or identifier
|
|
43
49
|
* @param value The value
|
|
44
|
-
* @return An
|
|
50
|
+
* @return An ordinal datum
|
|
45
51
|
*/
|
|
46
52
|
export const ordinalDatumOf = (time: number, ordinal: string, value: number): OrdinalDatum => ({
|
|
47
53
|
time,
|
|
@@ -51,11 +57,10 @@ export const ordinalDatumOf = (time: number, ordinal: string, value: number): Or
|
|
|
51
57
|
|
|
52
58
|
|
|
53
59
|
/**
|
|
54
|
-
* Returns whether the ordinal datum is empty. An ordinal datum is considered empty
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* @
|
|
58
|
-
* @return `true` if the iterate datum is empty; `false` otherwise
|
|
60
|
+
* Returns whether the ordinal datum is non-empty. An ordinal datum is considered empty when its
|
|
61
|
+
* time is NaN, its ordinal is blank (empty or only whitespace), or its value is NaN.
|
|
62
|
+
* @param datum The ordinal datum to test
|
|
63
|
+
* @return `true` if the ordinal datum is non-empty; `false` otherwise
|
|
59
64
|
*/
|
|
60
65
|
export const nonEmptyOrdinalDatum = (datum: OrdinalDatum): boolean =>
|
|
61
66
|
!isNaN(datum.time) && datum.ordinal.replace(/\s/g, "").length > 0 && !isNaN(datum.value)
|
|
@@ -84,15 +89,17 @@ export function ordinateSeriesFromTuples(
|
|
|
84
89
|
}
|
|
85
90
|
|
|
86
91
|
/**
|
|
87
|
-
* Creates
|
|
88
|
-
* @
|
|
89
|
-
* @
|
|
92
|
+
* Creates the ordinal chart data for the specified series: their names, the stats calculated over
|
|
93
|
+
* their data (see {@link calculateOrdinalStats}), and copies of all their data as the new points
|
|
94
|
+
* @param seriesList The series
|
|
95
|
+
* @return The ordinal chart data for the series
|
|
90
96
|
*/
|
|
91
97
|
export function initialOrdinalChartData(seriesList: Array<OrdinalSeries>): OrdinalChartData {
|
|
92
98
|
return {
|
|
93
99
|
seriesNames: new Set(seriesList.map(series => series.name)),
|
|
94
100
|
stats: calculateOrdinalStats(seriesList),
|
|
95
|
-
newPoints: new Map<string, Array<OrdinalDatum>>(seriesList.map(series => [
|
|
101
|
+
// newPoints: new Map<string, Array<OrdinalDatum>>(seriesList.map(series => [
|
|
102
|
+
newPoints: new Map<string, FastShiftArray<OrdinalDatum>>(seriesList.map(series => [
|
|
96
103
|
series.name,
|
|
97
104
|
series.data.map(datum => ({
|
|
98
105
|
time: datum.time,
|
|
@@ -103,6 +110,14 @@ export function initialOrdinalChartData(seriesList: Array<OrdinalSeries>): Ordin
|
|
|
103
110
|
}
|
|
104
111
|
}
|
|
105
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Calculates the stats of the specified series: the data with the min and max time, and with the
|
|
115
|
+
* min and max value, over all the series, and each series' value stats (its min, max, count, sum,
|
|
116
|
+
* sum of squares, and mean)
|
|
117
|
+
* @param seriesList The series
|
|
118
|
+
* @return The stats (when there's no data, the extremes are the initial ones that searches start
|
|
119
|
+
* from -- see e.g. `initialMinTimeDatum`)
|
|
120
|
+
*/
|
|
106
121
|
export function calculateOrdinalStats(seriesList: Array<OrdinalSeries>): OrdinalStats {
|
|
107
122
|
const ordinalValueStats = new Map<string, OrdinalValueStats>(seriesList.map(
|
|
108
123
|
(series: OrdinalSeries) => {
|
|
@@ -138,20 +153,20 @@ export function calculateOrdinalStats(seriesList: Array<OrdinalSeries>): Ordinal
|
|
|
138
153
|
const minTimeDatum: OrdinalDatum = seriesList.reduce(
|
|
139
154
|
(globalMin: OrdinalDatum, series: OrdinalSeries) => {
|
|
140
155
|
const seriesMin = series.data.reduce(
|
|
141
|
-
(min, datum) => datum.
|
|
156
|
+
(min, datum) => datum.time < min.time ? datum : min,
|
|
142
157
|
globalMin
|
|
143
158
|
)
|
|
144
|
-
return seriesMin.
|
|
159
|
+
return seriesMin.time < globalMin.time ? seriesMin : globalMin
|
|
145
160
|
},
|
|
146
161
|
initialMinTimeDatum()
|
|
147
162
|
)
|
|
148
163
|
const maxTimeDatum: OrdinalDatum = seriesList.reduce(
|
|
149
164
|
(globalMax: OrdinalDatum, series: OrdinalSeries) => {
|
|
150
165
|
const seriesMax = series.data.reduce(
|
|
151
|
-
(max, datum) => datum.
|
|
166
|
+
(max, datum) => datum.time > max.time ? datum : max,
|
|
152
167
|
globalMax
|
|
153
168
|
)
|
|
154
|
-
return seriesMax.
|
|
169
|
+
return seriesMax.time > globalMax.time ? seriesMax : globalMax
|
|
155
170
|
},
|
|
156
171
|
initialMaxTimeDatum()
|
|
157
172
|
)
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import type {Datum} from "./timeSeries";
|
|
2
|
+
import {type BaseSeries, seriesFrom} from "./baseSeries";
|
|
3
|
+
import {failureResult, type Result, resultFromAll, successResult} from "result-fn";
|
|
4
|
+
import type {FastShiftArray} from "fast-shift-array";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A series of {@link OutlierDatum}s, along with the measures that the data's bounds are for
|
|
8
|
+
* @template M The type of the measures that is expressed as a tuple of numbers.
|
|
9
|
+
*/
|
|
10
|
+
export interface OutlierSeries<M extends readonly number[]> extends BaseSeries<OutlierDatum<M>> {
|
|
11
|
+
/**
|
|
12
|
+
* The measures of the datum. For example, this could be a series of probabilities of
|
|
13
|
+
* the point being an outlier.
|
|
14
|
+
*/
|
|
15
|
+
readonly measures: readonly [...M]
|
|
16
|
+
/**
|
|
17
|
+
* The descriptions of the measures. For example, this could be a series of descriptions
|
|
18
|
+
* of the probabilities of the point being an outlier.
|
|
19
|
+
*/
|
|
20
|
+
readonly measureDescriptions?: {readonly [K in keyof M]: string}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The bounds of a datum.
|
|
25
|
+
*/
|
|
26
|
+
export interface OutlierBounds {
|
|
27
|
+
/**
|
|
28
|
+
* The lower bound of the datum
|
|
29
|
+
*/
|
|
30
|
+
readonly lower: number
|
|
31
|
+
/**
|
|
32
|
+
* The upper bound of the datum
|
|
33
|
+
*/
|
|
34
|
+
readonly upper: number
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A datum with an upper and lower bounds B(L, U) associated with each measure. The idea is the
|
|
39
|
+
* following. We have a datum (x, y) value. The bounds determine whether the datum is
|
|
40
|
+
* within the range associated with the measure. For example, the measure could be the
|
|
41
|
+
* 0.95 probability that the datum falls within that bound. And if the (x, y) value falls
|
|
42
|
+
* outside the bounds B(L, U), the datum could be considered an "outlier".
|
|
43
|
+
*
|
|
44
|
+
* Often we would like to have a set of measures that mean different things. For example, if
|
|
45
|
+
* the datum falls outside the bounds B1(L, U) representing the range in which we expect
|
|
46
|
+
* the datum to fall with a 0.95 probability, then we could consider the datum an "outlier". We
|
|
47
|
+
* may also want to consider the datum an "outlier" if it falls outside the bounds B2(L, U)
|
|
48
|
+
* representing the range in which we expect the datum to fall with a 0.75 probability. If the
|
|
49
|
+
* datum falls outside B2(L, U), then we could consider the datum a "possible outlier" and
|
|
50
|
+
* treat it differently from an "outlier".
|
|
51
|
+
*
|
|
52
|
+
* Note that there are constraints.
|
|
53
|
+
* 1. The cardinality of the measures and the bounds must be the same.
|
|
54
|
+
* 2. The i-th bound is associated with the i-th measure.
|
|
55
|
+
*
|
|
56
|
+
* @template M The type of the measures that is expressed as a tuple of numbers.
|
|
57
|
+
* @see OutlierBounds
|
|
58
|
+
* @see outlierBoundsFor
|
|
59
|
+
* @see outlierDatumFor
|
|
60
|
+
* @see outlierSeriesFor
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* // possible-outlier = 0.75, outlier = 0.95
|
|
64
|
+
* const Measures = [0.75, 0.95] as const;
|
|
65
|
+
* const value: Datum = datumOf(1, 10);
|
|
66
|
+
* const bounds = [
|
|
67
|
+
* outlierBoundsFor(21, 121),
|
|
68
|
+
* outlierBoundsFor(2, 52)
|
|
69
|
+
* ] as const;
|
|
70
|
+
* const datum = outlierDatumFor<typeof Measures>(value, Measures, bounds);
|
|
71
|
+
*/
|
|
72
|
+
export interface OutlierDatum<M extends readonly number[]> {
|
|
73
|
+
/**
|
|
74
|
+
* The datum with the x and y values
|
|
75
|
+
*/
|
|
76
|
+
readonly datum: Datum
|
|
77
|
+
/**
|
|
78
|
+
* The bounds of the measures. For example, if the measures are probabilities, then
|
|
79
|
+
* the bounds are a series that hold the lower and upper bounds for each probability
|
|
80
|
+
* in the measures.
|
|
81
|
+
*/
|
|
82
|
+
readonly bounds: {readonly [K in keyof M]: OutlierBounds}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Convenience function to create an outlier bounds object.
|
|
87
|
+
* @param lower The lower bound of the measure
|
|
88
|
+
* @param upper The upper bound of the measure
|
|
89
|
+
* @return An outlier bounds object
|
|
90
|
+
*/
|
|
91
|
+
export function outlierBoundsFor(lower: number, upper: number): OutlierBounds {
|
|
92
|
+
return {lower, upper}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Creates an outlier datum from the (x, y) value and the bounds associated with each measure. Because
|
|
97
|
+
* the length of the bounds-array must be the same as the length of the measures-array, this returns
|
|
98
|
+
* a {@link Result} object with the outcome of the operation.
|
|
99
|
+
* @param datum The (x, y) value
|
|
100
|
+
* @param measures The measures array where each measure is associated with a bound of the same index
|
|
101
|
+
* @param bounds The bounds array where each bound is associated with a measure of the same index
|
|
102
|
+
* @return A {@link Result} object with the outcome of the operation. If the operation is successful,
|
|
103
|
+
* then the result is an {@link OutlierDatum} object. If the operation is not successful, then
|
|
104
|
+
* the result is a `string` with the error message.
|
|
105
|
+
* @template M The type of the measures that is expressed as a tuple of numbers.
|
|
106
|
+
*/
|
|
107
|
+
export function outlierDatumFor<M extends readonly number[]>(
|
|
108
|
+
datum: Datum,
|
|
109
|
+
measures: readonly [...M],
|
|
110
|
+
bounds: {readonly [K in keyof M]: OutlierBounds},
|
|
111
|
+
): Result<OutlierDatum<M>, string> {
|
|
112
|
+
if (measures.length !== bounds.length) {
|
|
113
|
+
return failureResult(
|
|
114
|
+
`The number of measures and bounds must be the same; ` +
|
|
115
|
+
`datum: (${datum.x}, ${datum.y}); ` +
|
|
116
|
+
`measures_length: ${measures.length}; ` +
|
|
117
|
+
`bounds_length: ${bounds.length}; ` +
|
|
118
|
+
`measures: [${measures.join(", ")}]; ` +
|
|
119
|
+
`bounds: [${Object.values(bounds).map(b => `(${b.lower}, ${b.upper})`).join(", ")}]`
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
return successResult({datum, bounds})
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Creates an outlier series from the name and the array of (x, y, bounds) tuples. If any of the
|
|
127
|
+
* datum have bounds that do not have the same length as the measures, then this function will fail and
|
|
128
|
+
* return a failure result. Otherwise, it will return a success result with the outlier series.
|
|
129
|
+
* @param name The name of the series
|
|
130
|
+
* @param measures The measures that are associated with the series
|
|
131
|
+
* @param data The array of (x, y, bounds) tuples that define the series
|
|
132
|
+
* @param [measureDescriptions=undefined] The descriptions of the measures
|
|
133
|
+
* @return A {@link Result} object with the outcome of the operation. If the operation is successful,
|
|
134
|
+
* then the result is an {@link OutlierSeries} object. If the operation is not successful, then
|
|
135
|
+
* the result is an array of error messages.
|
|
136
|
+
* @template M The type of the measures that is expressed as a tuple of numbers.
|
|
137
|
+
*/
|
|
138
|
+
export function outlierSeriesFor<M extends readonly number[]>(
|
|
139
|
+
name: string,
|
|
140
|
+
measures: readonly [...M],
|
|
141
|
+
data: Array<[time: number, value: number, bounds: { readonly [K in keyof M]: OutlierBounds}]>,
|
|
142
|
+
measureDescriptions?: {readonly [K in keyof M]: string}
|
|
143
|
+
): Result<OutlierSeries<M>, Array<string>> {
|
|
144
|
+
// enrich each datum in the data array with the measures
|
|
145
|
+
const outlierData = data.map(
|
|
146
|
+
([time, value, bounds]) =>
|
|
147
|
+
outlierDatumFor({x: time, y: value}, measures, bounds)
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
// if all data has bounds-dimensions that match the measures-dimensions, then we can safely
|
|
151
|
+
// create the outlier series, otherwise we must report the errors
|
|
152
|
+
if (outlierData.filter(datum => datum.succeeded).length === data.length) {
|
|
153
|
+
// convert the Array<Result<OutlierDatum<M>, string>> to Result<Array<OutlierDatum<M>>, Array<string>>
|
|
154
|
+
return resultFromAll(outlierData)
|
|
155
|
+
.map(data => outlierSeriesFrom(name, data, measures, measureDescriptions))
|
|
156
|
+
.mapFailure(failure => [failure])
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// collect all the errors for datum whose bounds and measures dimensions did not
|
|
160
|
+
// match and report each error
|
|
161
|
+
return failureResult(outlierData
|
|
162
|
+
.filter(result => result.failed)
|
|
163
|
+
.map(result => result.error!)
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Creates an outlier series for the data and measures
|
|
169
|
+
*
|
|
170
|
+
* **Ownership warning:** `outlierData` is forwarded directly to {@link seriesFrom}, which wraps a
|
|
171
|
+
* plain array (or `FastShiftArray`) **by reference**, not a copy -- see {@link seriesFrom}'s own
|
|
172
|
+
* ownership warning for the full explanation. If you keep your own reference to `outlierData`,
|
|
173
|
+
* pass `outlierData.slice()` instead if you need an independent copy.
|
|
174
|
+
* @param name The name of the series
|
|
175
|
+
* @param outlierData The data for the series
|
|
176
|
+
* @param measures The measure defining the outlier bands
|
|
177
|
+
* @param measureDescriptions The (optional) meaning of each band
|
|
178
|
+
* @return An outlier series
|
|
179
|
+
* @template M The type of the measures that is expressed as a tuple of numbers.
|
|
180
|
+
*/
|
|
181
|
+
export function outlierSeriesFrom<M extends readonly number[]>(
|
|
182
|
+
name: string,
|
|
183
|
+
outlierData: Array<OutlierDatum<M>> | FastShiftArray<OutlierDatum<M>>,
|
|
184
|
+
measures: readonly [...M],
|
|
185
|
+
measureDescriptions?: {readonly [K in keyof M]: string}
|
|
186
|
+
): OutlierSeries<M> {
|
|
187
|
+
return {...seriesFrom(name, outlierData), measures, measureDescriptions}
|
|
188
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {BaseSeries, seriesFrom} from "./baseSeries";
|
|
1
|
+
import {type BaseSeries, seriesFrom} from "./baseSeries";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* An immutable datum object that holds
|
|
4
|
+
* An immutable datum object that holds an (x, y) value -- for a time series, a (time, value) pair
|
|
5
|
+
* (e.g. a neuron spike, or a weight)
|
|
5
6
|
*/
|
|
6
7
|
export interface Datum {
|
|
7
|
-
readonly
|
|
8
|
-
readonly
|
|
8
|
+
readonly x: number;
|
|
9
|
+
readonly y: number;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -14,10 +15,16 @@ export interface Datum {
|
|
|
14
15
|
* @param value The value
|
|
15
16
|
* @return A {@link Datum} instance with the specified (time, value)
|
|
16
17
|
*/
|
|
17
|
-
export const datumOf = (time: number, value: number): Datum => ({time, value})
|
|
18
|
+
export const datumOf = (time: number, value: number): Datum => ({x: time, y: value})
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
/**
|
|
21
|
+
* @return An empty datum (its x and y are `NaN`)
|
|
22
|
+
*/
|
|
23
|
+
export const emptyDatum = (): Datum => ({x: NaN, y: NaN})
|
|
20
24
|
|
|
25
|
+
/**
|
|
26
|
+
* A series of (time, value) data (e.g. for the scatter and raster plots)
|
|
27
|
+
*/
|
|
21
28
|
export type TimeSeries = BaseSeries<Datum>
|
|
22
29
|
|
|
23
30
|
|
|
@@ -25,16 +32,11 @@ export type TimeSeries = BaseSeries<Datum>
|
|
|
25
32
|
* Creates a series from the name and the optional array of (x, y) pairs (tuples)
|
|
26
33
|
* @param name The name of the series
|
|
27
34
|
* @param data The optional array of (x, y) pairs (tuples)
|
|
28
|
-
* @return A
|
|
35
|
+
* @return A {@link TimeSeries} that can be used by, e.g., the `ScatterPlot` and the `RasterPlot`
|
|
29
36
|
* @see seriesFrom
|
|
30
37
|
* @see emptySeries
|
|
31
38
|
*/
|
|
32
39
|
export const timeSeriesFromTuples = (name: string, data: Array<[number, number]> = []): TimeSeries =>
|
|
33
40
|
seriesFrom(name, data.map(([t, y]) => datumOf(t, y)))
|
|
34
41
|
|
|
35
|
-
export interface PixelDatum extends Datum {
|
|
36
|
-
x: number;
|
|
37
|
-
y: number;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
42
|
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {Datum, TimeSeries} from "./timeSeries";
|
|
2
|
-
import {ChartData, defaultChartData} from "../observables/ChartData";
|
|
1
|
+
import type {Datum, TimeSeries} from "./timeSeries";
|
|
2
|
+
import {type ChartData, defaultChartData} from "../observables/ChartData";
|
|
3
|
+
import {FastShiftArray} from "fast-shift-array";
|
|
4
|
+
import {DEFAULT_COMPACTING_SIZE} from "./baseSeries";
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
|
-
* The
|
|
7
|
+
* The time-series chart data produced by the rxjs observable that is pushed to a streaming chart
|
|
8
|
+
* (e.g. the scatter and raster charts): each chunk's new points, and the latest times
|
|
6
9
|
*/
|
|
7
10
|
export interface TimeSeriesChartData extends ChartData {
|
|
8
11
|
/**
|
|
@@ -28,40 +31,51 @@ export interface TimeSeriesChartData extends ChartData {
|
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
/**
|
|
31
|
-
* Creates
|
|
32
|
-
*
|
|
33
|
-
* @
|
|
34
|
+
* Creates a chart data object for the specified series whose times are all 0, and whose new
|
|
35
|
+
* points are a single (0, 0) point for each series
|
|
36
|
+
* @param series The list of series names (identifiers) to update
|
|
37
|
+
* @return The chart data object
|
|
34
38
|
*/
|
|
35
39
|
export function emptyTimeSeriesChartData(series: Array<string>): TimeSeriesChartData {
|
|
36
40
|
return {
|
|
37
41
|
...defaultChartData(),
|
|
42
|
+
seriesNames: new Set(series),
|
|
38
43
|
maxTime: 0,
|
|
39
44
|
maxTimes: new Map(series.map(name => [name, 0])),
|
|
40
|
-
newPoints: new Map<string, Array<Datum>>(series.map(name => [name, [{
|
|
45
|
+
newPoints: new Map<string, Array<Datum>>(series.map(name => [name, [{x: 0, y: 0}]]))
|
|
41
46
|
}
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
/**
|
|
45
|
-
* Creates
|
|
46
|
-
*
|
|
50
|
+
* Creates the chart data object to start a stream from, for the specified series: its new points
|
|
51
|
+
* are each series' last datum (or (0, 0), for an empty series), each series' max time is the
|
|
52
|
+
* time of its last datum (or 0), and the max time is the latest of those (or `-Infinity`, when
|
|
53
|
+
* there are no series)
|
|
54
|
+
* @param seriesList The series
|
|
47
55
|
* @param [currentTime=0] The current time
|
|
48
|
-
* @
|
|
56
|
+
* @param [compactingSize=DEFAULT_COMPACTING_SIZE] The number of shifts each new-points array
|
|
57
|
+
* accumulates before it's compacted
|
|
58
|
+
* @return The chart data object
|
|
49
59
|
*/
|
|
50
|
-
export function initialTimeSeriesChartData(
|
|
60
|
+
export function initialTimeSeriesChartData(
|
|
61
|
+
seriesList: Array<TimeSeries>,
|
|
62
|
+
currentTime: number = 0,
|
|
63
|
+
compactingSize: number = DEFAULT_COMPACTING_SIZE
|
|
64
|
+
): TimeSeriesChartData {
|
|
51
65
|
const maxTime = seriesList.reduce(
|
|
52
|
-
(tMax, series) => Math.max(tMax, series.last().map(datum => datum.
|
|
66
|
+
(tMax, series) => Math.max(tMax, series.last().map(datum => datum.x).getOrElse(-Infinity)),
|
|
53
67
|
-Infinity
|
|
54
68
|
)
|
|
55
69
|
return {
|
|
56
70
|
seriesNames: new Set(seriesList.map(series => series.name)),
|
|
57
71
|
maxTime,
|
|
58
|
-
maxTimes: new Map(seriesList.map(series => [series.name, series.last().map(datum => datum.
|
|
72
|
+
maxTimes: new Map(seriesList.map(series => [series.name, series.last().map(datum => datum.x).getOrElse(0)])),
|
|
59
73
|
newPoints: new Map<string, Array<Datum>>(seriesList.map(series => [
|
|
60
74
|
series.name,
|
|
61
|
-
[{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}]
|
|
75
|
+
FastShiftArray.fromArray([{
|
|
76
|
+
x: series.last().map(datum => datum.x).getOrElse(0),
|
|
77
|
+
y: series.last().map(datum => datum.y).getOrElse(0)
|
|
78
|
+
}], true, compactingSize)
|
|
65
79
|
])),
|
|
66
80
|
currentTime: currentTime
|
|
67
81
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {SeriesStyle} from "../axes/axes";
|
|
2
|
-
import {SvgFillStyle, SvgStrokeStyle} from "./svgStyle";
|
|
1
|
+
import type {SeriesStyle} from "../axes/axes";
|
|
2
|
+
import type {SvgFillStyle, SvgStrokeStyle} from "./svgStyle";
|
|
3
3
|
import * as d3 from "d3";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* The style of a bar series: the style of each of its bars and lines
|
|
7
|
+
*/
|
|
5
8
|
export interface BarSeriesStyle extends SeriesStyle {
|
|
6
9
|
/**
|
|
7
10
|
* The bar style for the lifetime min/max range bar. The style is for the width, fill,
|
|
@@ -27,17 +30,29 @@ export interface BarSeriesStyle extends SeriesStyle {
|
|
|
27
30
|
windowedMeanValueLine: LineStyle
|
|
28
31
|
}
|
|
29
32
|
|
|
33
|
+
/**
|
|
34
|
+
* The style of a bar: its width (as a fraction of the category's width), its fill, and its stroke
|
|
35
|
+
*/
|
|
30
36
|
export interface BarStyle {
|
|
31
37
|
widthFraction: number
|
|
32
38
|
fill: SvgFillStyle
|
|
33
39
|
stroke: SvgStrokeStyle
|
|
34
40
|
}
|
|
35
41
|
|
|
42
|
+
/**
|
|
43
|
+
* The style of a line: normally, and when highlighted
|
|
44
|
+
*/
|
|
36
45
|
export interface LineStyle {
|
|
37
46
|
regular: SvgStrokeStyle
|
|
38
47
|
highlight: SvgStrokeStyle
|
|
39
48
|
}
|
|
40
49
|
|
|
50
|
+
/**
|
|
51
|
+
* The default style for the lifetime min/max bar: 65% of the category's width, a translucent fill,
|
|
52
|
+
* and a thin stroke
|
|
53
|
+
* @param [color="#008aad"] The bar's fill and stroke color
|
|
54
|
+
* @return The bar style
|
|
55
|
+
*/
|
|
41
56
|
export function defaultMinMaxBarStyle(color: string = "#008aad"): BarStyle {
|
|
42
57
|
return {
|
|
43
58
|
widthFraction: 0.65,
|
|
@@ -53,6 +68,12 @@ export function defaultMinMaxBarStyle(color: string = "#008aad"): BarStyle {
|
|
|
53
68
|
}
|
|
54
69
|
}
|
|
55
70
|
|
|
71
|
+
/**
|
|
72
|
+
* The default style for the windowed min/max bar: 25% of the category's width (narrower than the
|
|
73
|
+
* lifetime bar, so both can be seen), filled with a slightly darker color, and no stroke
|
|
74
|
+
* @param [color="#008aad"] The color to darken for the bar's fill (used as-is when it can't be parsed)
|
|
75
|
+
* @return The bar style
|
|
76
|
+
*/
|
|
56
77
|
export function defaultWindowedMinMaxBarStyle(color: string = "#008aad"): BarStyle {
|
|
57
78
|
return {
|
|
58
79
|
widthFraction: 0.25,
|
|
@@ -68,6 +89,11 @@ export function defaultWindowedMinMaxBarStyle(color: string = "#008aad"): BarSty
|
|
|
68
89
|
}
|
|
69
90
|
}
|
|
70
91
|
|
|
92
|
+
/**
|
|
93
|
+
* The default style for the current-value line: 3 pixels wide (5 when highlighted)
|
|
94
|
+
* @param [color="#008aad"] The line's color
|
|
95
|
+
* @return The line style
|
|
96
|
+
*/
|
|
71
97
|
export function defaultValueLineStyle(color: string = "#008aad"): LineStyle {
|
|
72
98
|
return {
|
|
73
99
|
regular: {
|
|
@@ -83,6 +109,11 @@ export function defaultValueLineStyle(color: string = "#008aad"): LineStyle {
|
|
|
83
109
|
}
|
|
84
110
|
}
|
|
85
111
|
|
|
112
|
+
/**
|
|
113
|
+
* The default style for the (lifetime) mean-value line: 1 pixel wide (3 when highlighted)
|
|
114
|
+
* @param [color="#008aad"] The line's color
|
|
115
|
+
* @return The line style
|
|
116
|
+
*/
|
|
86
117
|
export function defaultMeanValueLineStyle(color: string = "#008aad"): LineStyle {
|
|
87
118
|
return {
|
|
88
119
|
regular: {
|
|
@@ -98,21 +129,33 @@ export function defaultMeanValueLineStyle(color: string = "#008aad"): LineStyle
|
|
|
98
129
|
}
|
|
99
130
|
}
|
|
100
131
|
|
|
101
|
-
|
|
132
|
+
/**
|
|
133
|
+
* The default style for the windowed mean-value line: 1 pixel wide (3 when highlighted), and red
|
|
134
|
+
* by default to set it apart from the other lines
|
|
135
|
+
* @param [color="#ad0000"] The line's color
|
|
136
|
+
* @return The line style
|
|
137
|
+
*/
|
|
138
|
+
export function defaultWindowedMeanValueLineStyle(color: string = "#ad0000"): LineStyle {
|
|
102
139
|
return {
|
|
103
140
|
regular: {
|
|
104
|
-
color:
|
|
141
|
+
color: color,
|
|
105
142
|
opacity: 0.6,
|
|
106
143
|
width: 1
|
|
107
144
|
},
|
|
108
145
|
highlight: {
|
|
109
|
-
color:
|
|
146
|
+
color: color,
|
|
110
147
|
opacity: 1,
|
|
111
148
|
width: 3
|
|
112
149
|
}
|
|
113
150
|
}
|
|
114
151
|
}
|
|
115
152
|
|
|
153
|
+
/**
|
|
154
|
+
* The default style for a bar series: all the bars and lines in the specified color (see the
|
|
155
|
+
* default styles above), except for the windowed min/max bar's darker fill
|
|
156
|
+
* @param [color="#008aad"] The series' color
|
|
157
|
+
* @return The bar series style
|
|
158
|
+
*/
|
|
116
159
|
export function defaultBarSeriesStyle(color: string = "#008aad"): BarSeriesStyle {
|
|
117
160
|
return {
|
|
118
161
|
color,
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Canvas equivalents of the stroke/fill helpers that used to live in svgStyle.ts. The old versions
|
|
2
|
+
// mutated a *persistent* SVG element's CSS style (`selection.style('stroke', ...)`), so it stuck
|
|
3
|
+
// around until changed again. Canvas has no persistent elements -- `ctx.strokeStyle`/`ctx.fillStyle`
|
|
4
|
+
// /`ctx.lineWidth` are transient 2D-context state that only affects the *next* stroke()/fill() call,
|
|
5
|
+
// so these must be (re-)applied immediately before every draw, every frame.
|
|
6
|
+
//
|
|
7
|
+
// IMPORTANT DIFFERENCE FROM SVG: canvas has a single `ctx.globalAlpha` shared between stroke and
|
|
8
|
+
// fill, unlike SVG's independent `stroke-opacity`/`fill-opacity`. If a shape needs different
|
|
9
|
+
// stroke and fill opacity in the same draw call, bake the opacity into the color string with
|
|
10
|
+
// `withAlpha(...)` instead of relying on `globalAlpha` for one of them.
|
|
11
|
+
|
|
12
|
+
import * as d3 from "d3"
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The style of a stroke (a line, or a shape's outline)
|
|
16
|
+
*/
|
|
17
|
+
export interface CanvasStrokeStyle {
|
|
18
|
+
readonly color: string
|
|
19
|
+
readonly width: number
|
|
20
|
+
readonly opacity: number
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Applies a stroke style to the canvas context. Call this immediately before `ctx.stroke()` --
|
|
25
|
+
* unlike the old SVG version, the effect is not persistent.
|
|
26
|
+
* @param context The canvas 2D context to apply the style to
|
|
27
|
+
* @param style The (partial) stroke style to apply; unset fields are left untouched on `ctx`
|
|
28
|
+
* @return `ctx`, for chaining
|
|
29
|
+
*/
|
|
30
|
+
export function applyStrokeStyle(context: CanvasRenderingContext2D, style: Partial<CanvasStrokeStyle>): CanvasRenderingContext2D {
|
|
31
|
+
if (style.color !== undefined) context.strokeStyle = style.color
|
|
32
|
+
if (style.width !== undefined) context.lineWidth = style.width
|
|
33
|
+
if (style.opacity !== undefined) context.globalAlpha = style.opacity
|
|
34
|
+
return context
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The style of a (shape's) fill
|
|
39
|
+
*/
|
|
40
|
+
export interface CanvasFillStyle {
|
|
41
|
+
readonly color: string
|
|
42
|
+
readonly opacity: number
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Applies a fill style to the canvas context. Call this immediately before `ctx.fill()`/
|
|
47
|
+
* `ctx.fillText()`/`ctx.fillRect()` -- unlike the old SVG version, the effect is not persistent.
|
|
48
|
+
* @param context The canvas 2D context to apply the style to
|
|
49
|
+
* @param style The (partial) fill style to apply; unset fields are left untouched on `ctx`
|
|
50
|
+
* @return `ctx`, for chaining
|
|
51
|
+
*/
|
|
52
|
+
export function applyFillStyle(context: CanvasRenderingContext2D, style: Partial<CanvasFillStyle>): CanvasRenderingContext2D {
|
|
53
|
+
if (style.color !== undefined) context.fillStyle = style.color
|
|
54
|
+
if (style.opacity !== undefined) context.globalAlpha = style.opacity
|
|
55
|
+
return context
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Bakes an opacity into a color string by resolving it to `rgba(...)`. Needed because canvas has
|
|
60
|
+
* a single `globalAlpha` shared between stroke and fill (see the module-level note above); when a
|
|
61
|
+
* shape needs independent stroke and fill opacity, use this to bake opacity into the color passed
|
|
62
|
+
* to `applyStrokeStyle`/`applyFillStyle` instead of setting `opacity` on both.
|
|
63
|
+
*
|
|
64
|
+
* Uses `d3.color(...)` (already the project's convention for this elsewhere -- see `Legend.tsx`,
|
|
65
|
+
* `barPlotStyle.ts`) rather than the previous approach of assigning `color` to a single
|
|
66
|
+
* module-level, lazily-created `<canvas>` context's `fillStyle` and reading back the browser's
|
|
67
|
+
* normalized value: assigning an unparseable CSS string to `fillStyle` is a silent no-op per the
|
|
68
|
+
* Canvas 2D spec, so an invalid `color` would have silently resolved to whatever the *previous,
|
|
69
|
+
* unrelated* `withAlpha` call (from any chart/tooltip/legend on the page, since the context was a
|
|
70
|
+
* single shared singleton) happened to leave `fillStyle` at -- order-dependent and effectively
|
|
71
|
+
* nondeterministic. `d3.color` instead returns `null` for unparseable input, so an invalid color
|
|
72
|
+
* falls through to the same "fall back to the original string" behavior this always had for the
|
|
73
|
+
* "no canvas 2d support" case, deterministically, with no shared state at all.
|
|
74
|
+
* @param color Any valid CSS color string (named, hex, rgb, rgba, hsl, etc)
|
|
75
|
+
* @param opacity The opacity to bake in, from 0 (transparent) to 1 (opaque)
|
|
76
|
+
* @return An `rgba(...)` string equivalent to `color` at the given `opacity`
|
|
77
|
+
*/
|
|
78
|
+
export function withAlpha(color: string, opacity: number): string {
|
|
79
|
+
const parsed = d3.color(color)
|
|
80
|
+
if (parsed === null) {
|
|
81
|
+
// unparseable color string; nothing sensible to bake an opacity into
|
|
82
|
+
return color
|
|
83
|
+
}
|
|
84
|
+
const {r, g, b} = parsed.rgb()
|
|
85
|
+
return `rgba(${r}, ${g}, ${b}, ${opacity})`
|
|
86
|
+
}
|