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,22 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { clipToArea } from "./plot";
|
|
2
|
+
import { useStreamingTimeAxes } from "./useStreamingTimeAxes";
|
|
3
|
+
import { useHoveredSeries } from "../hooks/useHoveredSeries";
|
|
3
4
|
import { noop } from "../utils";
|
|
4
5
|
import { useChart } from "../hooks/useChart";
|
|
5
|
-
import { useCallback, useEffect,
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
7
|
+
import { AxisType, checkAxisType, defaultLineStyle } from "../axes/axes";
|
|
8
|
+
import { seriesAt, canvasLocalPoint } from "./hitTesting";
|
|
9
|
+
import { timeSeriesAxisTimes } from "../subscriptions/viewDrivers";
|
|
10
|
+
import { useDataSource, useDataSourceRunning, useInitialData } from "../hooks/useDataSource";
|
|
9
11
|
import { usePlotDimensions } from "../hooks/usePlotDimensions";
|
|
10
|
-
import {
|
|
11
|
-
import { Optional } from "result-fn";
|
|
12
|
-
import { ContinuousAxisRange } from "../axes/ContinuousAxisRange";
|
|
12
|
+
import { FastShiftArray } from "fast-shift-array";
|
|
13
13
|
/**
|
|
14
|
-
* Renders a streaming neuron raster plot for the series
|
|
15
|
-
*
|
|
14
|
+
* Renders a streaming neuron raster plot for the series held by the {@link StreamingDataSource}
|
|
15
|
+
* handed to the {@link Chart} (its `dataSource` prop). This component uses the {@link useChart}
|
|
16
16
|
* hook, and therefore must be a child of the {@link Chart} in order to be plugged in to the
|
|
17
17
|
* chart ecosystem (axes, tracker, tooltip).
|
|
18
18
|
*
|
|
19
|
+
* The plot never subscribes to the data stream itself -- see {@link ScatterPlot} for how the
|
|
20
|
+
* application-owned data source and this plot's mount-scoped view driver divide the work.
|
|
21
|
+
*
|
|
22
|
+
* Internally, this no longer creates/updates SVG `<line>` elements. Instead, it registers a single
|
|
23
|
+
* draw function with the chart's {@link CanvasContext} that redraws every series' spikes from
|
|
24
|
+
* scratch each time the canvas repaints. Mouse hover (for the tooltip) is handled by hit-testing
|
|
25
|
+
* the mouse position against the last-drawn spike geometry -- as *disjoint* segments, since unlike
|
|
26
|
+
* a scatter series, consecutive spikes are not connected by a line (see `hitTesting.ts`). When
|
|
27
|
+
* the data source is paused, hovering over a spike shows the tooltip (when there's one).
|
|
28
|
+
*
|
|
19
29
|
* @param props The properties associated with the raster plot
|
|
30
|
+
* @return `null` (the plot draws onto the chart's canvas)
|
|
20
31
|
* @example
|
|
21
32
|
<RasterPlot
|
|
22
33
|
axisAssignments={new Map([
|
|
@@ -24,92 +35,50 @@ import { ContinuousAxisRange } from "../axes/ContinuousAxisRange";
|
|
|
24
35
|
['neuron2', assignAxes("x-axis-2", "y-axis-2")],
|
|
25
36
|
])}
|
|
26
37
|
spikeMargin={1}
|
|
27
|
-
dropDataAfter={5000}
|
|
28
38
|
panEnabled={true}
|
|
29
39
|
zoomEnabled={true}
|
|
30
40
|
zoomKeyModifiersRequired={true}
|
|
31
41
|
/>
|
|
32
42
|
*/
|
|
33
43
|
export function RasterPlot(props) {
|
|
34
|
-
|
|
35
|
-
const {
|
|
44
|
+
var _a;
|
|
45
|
+
const { chartId, canvasContext, axes, seriesStyles, seriesFilter, mouse, } = useChart();
|
|
46
|
+
const { hoveredSeriesName } = useHoveredSeries();
|
|
47
|
+
const { xAxesState, yAxesState, setAxisAssignments, } = axes;
|
|
36
48
|
const { mouseOverHandlerFor, mouseLeaveHandlerFor } = mouse;
|
|
37
49
|
const { plotDimensions, margin } = usePlotDimensions();
|
|
38
|
-
|
|
50
|
+
// the application-owned source of the data, and whether it's running (streaming)
|
|
51
|
+
const dataSource = useDataSource();
|
|
52
|
+
const running = useDataSourceRunning(dataSource);
|
|
39
53
|
const { initialData } = useInitialData();
|
|
40
|
-
const { axisAssignments = new Map(),
|
|
54
|
+
const { axisAssignments = new Map(), panEnabled = false, zoomEnabled = false, zoomKeyModifiersRequired = true, withCadenceOf, spikeMargin = 2, highlightAxesOnMouseOver = false, onZoomReset = noop, } = props;
|
|
41
55
|
// why do "dataRef" and "seriesRef" both hold on to the same underlying data? for performance.
|
|
42
56
|
//
|
|
43
57
|
// the "dataRef" and "seriesRef" both point to the same underlying data, a collection
|
|
44
|
-
// of series
|
|
45
|
-
// are the
|
|
58
|
+
// of series (held, and updated as new data is streamed in, by the data source). The series in
|
|
59
|
+
// "dataRef" are read by the canvas draw function, and the "seriesRef" map is for looking a
|
|
60
|
+
// series up by its name.
|
|
46
61
|
//
|
|
47
62
|
// the "dataRef" object holds on to a copy of the initial data (which is an array of
|
|
48
|
-
// time-series, e.i. an array of BaseSeries<
|
|
63
|
+
// time-series, e.i. an array of BaseSeries<Datum> objects). The slice just creates a copy of
|
|
49
64
|
// the array, but the references to the BaseSeries objects are the same and still point to the same
|
|
50
65
|
// data as the "initialData" array.
|
|
51
66
|
//
|
|
52
|
-
// the "seriesRef" object is a reference to a map (series_name -> BaseSeries<
|
|
53
|
-
//
|
|
67
|
+
// the "seriesRef" object is a reference to a map (series_name -> BaseSeries<Datum>), used to find
|
|
68
|
+
// the series under the mouse (for the tooltip).
|
|
54
69
|
//
|
|
55
|
-
// the series in the "dataRef" object are the ones
|
|
56
|
-
//
|
|
70
|
+
// the series in the "dataRef" object are the ones read by the next redraw, so as these are
|
|
71
|
+
// updated, the next canvas repaint picks up the new data.
|
|
57
72
|
const dataRef = useRef(initialData.slice());
|
|
58
73
|
const seriesRef = useRef(new Map(initialData.map(series => [series.name, series])));
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// set the axis assignments needed if a tooltip is being used
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
setAxisAssignments(axisAssignments);
|
|
70
|
-
}, [axisAssignments, setAxisAssignments]);
|
|
71
|
-
// calculates the distinct series IDs that cover all the series in the plot
|
|
72
|
-
const axesForSeries = useMemo(() => axesForSeriesGen(initialData, axisAssignments, xAxesState), [initialData, axisAssignments, xAxesState]);
|
|
73
|
-
// updates the timing using the onUpdateTime and updatePlot references. This and the references
|
|
74
|
-
// defined above allow the axes' times to be update properly by avoid stale reference to these
|
|
75
|
-
// functions.
|
|
76
|
-
const updateTimingAndPlot = useCallback((ranges) => {
|
|
77
|
-
if (mainG !== null) {
|
|
78
|
-
onUpdateTimeRef.current(ranges);
|
|
79
|
-
updatePlotRef.current(ranges, mainG);
|
|
80
|
-
if (onUpdateAxesInterval) {
|
|
81
|
-
setTimeout(() => {
|
|
82
|
-
const times = new Map();
|
|
83
|
-
ranges.forEach((range, name) => times.set(name, range.current));
|
|
84
|
-
onUpdateAxesInterval(times);
|
|
85
|
-
}, 0);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}, [mainG, onUpdateAxesInterval]);
|
|
89
|
-
// todo find better way
|
|
90
|
-
// when the initial data changes, then reset the plot. note that the initial data doesn't change
|
|
91
|
-
// during the normal course of updates from the observable, only when the plot is restarted.
|
|
92
|
-
useEffect(() => {
|
|
93
|
-
dataRef.current = initialData.slice();
|
|
94
|
-
seriesRef.current = new Map(initialData.map(series => [series.name, series]));
|
|
95
|
-
currentTimeRef.current = new Map(Array.from(xAxesState.axes.keys()).map(id => [id, 0]));
|
|
96
|
-
updateTimingAndPlot(new Map(Array.from(continuousAxisRanges(xAxesState.axes).entries())
|
|
97
|
-
.map(([id, range]) => {
|
|
98
|
-
// grab the current range, then calculate the minimum time from the initial data, and
|
|
99
|
-
// set that as the start, and then add the range to it for the end time
|
|
100
|
-
const [start, end] = range.original.asTuple();
|
|
101
|
-
const minTime = initialData
|
|
102
|
-
.filter(srs => { var _a; return ((_a = axisAssignments.get(srs.name)) === null || _a === void 0 ? void 0 : _a.xAxis) === id; })
|
|
103
|
-
.reduce((tMin, series) => Math.min(tMin, !series.isEmpty() ? series.data[0].time : tMin), Infinity);
|
|
104
|
-
const startTime = minTime === Infinity ? 0 : minTime;
|
|
105
|
-
return [id, ContinuousAxisRange.from(startTime, startTime + end - start)];
|
|
106
|
-
})));
|
|
107
|
-
},
|
|
108
|
-
// ** not happy about this **
|
|
109
|
-
// only want this effect to run when the initial data is changed, which mean all the
|
|
110
|
-
// other dependencies are recalculated anyway.
|
|
111
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
112
|
-
[initialData]);
|
|
74
|
+
// the last-drawn geometry for each series' spikes, in canvas coordinates, used for
|
|
75
|
+
// hit-testing mouse hover on `mousemove` (see the effect below that wires up the listener)
|
|
76
|
+
const geometryRef = useRef(new Map());
|
|
77
|
+
// the name of the series the mouse was over on the previous `mousemove`, so we know when to
|
|
78
|
+
// fire a "leave" for the old series before firing an "over" for the new one
|
|
79
|
+
const lastHoveredRef = useRef(undefined);
|
|
80
|
+
// tooltips are only shown while the data source is paused (and not while panning)
|
|
81
|
+
const allowTooltipRef = useRef(!((_a = dataSource === null || dataSource === void 0 ? void 0 : dataSource.running) !== null && _a !== void 0 ? _a : false));
|
|
113
82
|
/**
|
|
114
83
|
* Calculates the upper and lower y-coordinate for the spike line
|
|
115
84
|
* @param categorySize The size of the category (i.e. plot_height / num_series)
|
|
@@ -130,227 +99,159 @@ export function RasterPlot(props) {
|
|
|
130
99
|
};
|
|
131
100
|
}
|
|
132
101
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
* @param transform The d3 zoom transformation information
|
|
144
|
-
* @param x The x-position of the mouse when the scroll wheel or gesture is used
|
|
145
|
-
* @param plotDimensions The dimensions of the plot
|
|
146
|
-
* @param series An array of series names
|
|
147
|
-
* @param ranges A map holding the axis ID and its associated time-range
|
|
102
|
+
* (Re-)registers this plot's draw function with the canvas context and requests a redraw.
|
|
103
|
+
* Replaces the old version, which directly mutated SVG `<line>` elements bound via d3's
|
|
104
|
+
* enter/update/exit join. Canvas has no persistent elements to join against, so the draw
|
|
105
|
+
* function just redraws every spike from current data/scale state each time it's invoked.
|
|
106
|
+
*
|
|
107
|
+
* Pan/zoom behavior setup lives in a separate effect (see below), not here -- this function
|
|
108
|
+
* runs on every data tick (each `windowingTime` interval), and recreating/reattaching a
|
|
109
|
+
* `d3.drag()`/`d3.zoom()` behavior that often is pure overhead unrelated to drawing the new
|
|
110
|
+
* data.
|
|
111
|
+
* @param cc The canvas context to register the draw function with
|
|
148
112
|
*/
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
// select the svg element bind the data to them
|
|
157
|
-
const svg = d3.select(container);
|
|
158
|
-
// set up panning
|
|
159
|
-
if (panEnabled) {
|
|
160
|
-
const drag = d3.drag()
|
|
161
|
-
.on("start", () => {
|
|
162
|
-
d3.select(container).style("cursor", "move");
|
|
163
|
-
allowTooltipRef.current = false;
|
|
164
|
-
})
|
|
165
|
-
.on("drag", (event) => {
|
|
166
|
-
onPan(event.dx, plotDimensions, timeRanges);
|
|
167
|
-
// need to update the plot with the new time-ranges
|
|
168
|
-
updatePlotRef.current(timeRanges, mainGElem);
|
|
169
|
-
})
|
|
170
|
-
.on("end", () => {
|
|
171
|
-
d3.select(container).style("cursor", "auto");
|
|
172
|
-
allowTooltipRef.current = isSubscriptionClosed();
|
|
173
|
-
});
|
|
174
|
-
svg.call(drag);
|
|
175
|
-
}
|
|
176
|
-
// set up for zooming
|
|
177
|
-
if (zoomEnabled) {
|
|
178
|
-
const zoom = d3.zoom()
|
|
179
|
-
.filter((event) => !zoomKeyModifiersRequired || event.shiftKey || event.ctrlKey)
|
|
180
|
-
.scaleExtent([0, 10])
|
|
181
|
-
.translateExtent([[margin.left, margin.top], [plotDimensions.width, plotDimensions.height]])
|
|
182
|
-
.on("zoom", (event) => {
|
|
183
|
-
onZoom(event.transform, event.sourceEvent.offsetX - margin.left, plotDimensions, timeRanges);
|
|
184
|
-
updatePlotRef.current(timeRanges, mainGElem);
|
|
185
|
-
});
|
|
186
|
-
svg.call(zoom);
|
|
187
|
-
}
|
|
113
|
+
const updatePlot = useCallback((cc) => {
|
|
114
|
+
const draw = (context) => {
|
|
115
|
+
const { context2D } = context;
|
|
116
|
+
context2D.save();
|
|
117
|
+
clipToArea(context, plotDimensions, { x: margin.left, y: margin.top });
|
|
118
|
+
context2D.translate(margin.left, margin.top);
|
|
119
|
+
const newGeometry = new Map();
|
|
188
120
|
// enter, update, delete the raster data
|
|
189
121
|
dataRef.current.forEach(series => {
|
|
190
122
|
const [xAxis, yAxis] = axesFor(series.name, axisAssignments, axisId => xAxesState.axisFor(axisId).getOrUndefined(), axisId => yAxesState.axisFor(axisId).getOrUndefined());
|
|
123
|
+
if (xAxis === undefined || yAxis === undefined)
|
|
124
|
+
return;
|
|
191
125
|
// grab the series styles, or the defaults if none exist
|
|
192
|
-
const { color, lineWidth, highlightColor, highlightWidth, margin: spikeLineMargin = spikeMargin } = seriesStyles.get(series.name) ||
|
|
193
|
-
|
|
194
|
-
|
|
126
|
+
const { color: seriesColor, lineWidth, highlightColor, highlightWidth, margin: spikeLineMargin = spikeMargin } = seriesStyles.get(series.name) || {
|
|
127
|
+
...defaultLineStyle(),
|
|
128
|
+
highlightColor: defaultLineStyle().color
|
|
129
|
+
};
|
|
130
|
+
const isHovered = hoveredSeriesName === series.name;
|
|
131
|
+
const strokeColor = isHovered ? highlightColor : seriesColor;
|
|
195
132
|
const strokeWidth = isHovered ? (highlightWidth || lineWidth) : lineWidth;
|
|
196
133
|
// only show the data for which the regex filter matches
|
|
197
|
-
const plotData = (series.name.match(seriesFilter)) ? series.data :
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
.selectAll('line')
|
|
201
|
-
.data(plotData);
|
|
202
|
-
//
|
|
203
|
-
// enter new elements
|
|
134
|
+
const plotData = (series.name.match(seriesFilter)) ? series.data : FastShiftArray.empty();
|
|
135
|
+
// grab the functions that are used to determine the lower and upper coordinates of
|
|
136
|
+
// the raster line (y1, y2) and then calculate the values (y1, y2) using those functions
|
|
204
137
|
const { yUpper, yLower } = yCoordsFn(yAxis.scale.bandwidth(), lineWidth, spikeLineMargin);
|
|
205
|
-
// grab the value (index) associated with the series name (this is a category axis)
|
|
206
138
|
const y = yAxis.scale(series.name) || 0;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
.
|
|
215
|
-
.
|
|
216
|
-
.
|
|
217
|
-
.
|
|
218
|
-
.
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
.attr('x1', datum => datum.x)
|
|
226
|
-
.attr('x2', datum => datum.x)
|
|
227
|
-
.attr('y1', _ => yUpper(y))
|
|
228
|
-
.attr('y2', _ => yLower(y))
|
|
229
|
-
.attr('stroke', strokeColor)
|
|
230
|
-
.attr('stroke-width', strokeWidth);
|
|
231
|
-
// exit old elements
|
|
232
|
-
seriesContainer.exit().remove();
|
|
139
|
+
const y1 = yUpper(y);
|
|
140
|
+
const y2 = yLower(y);
|
|
141
|
+
context2D.strokeStyle = strokeColor;
|
|
142
|
+
context2D.lineWidth = strokeWidth;
|
|
143
|
+
const segments = [];
|
|
144
|
+
for (let i = 0; i < plotData.length; i++) {
|
|
145
|
+
const x = xAxis.scale(plotData[i].x);
|
|
146
|
+
context2D.beginPath();
|
|
147
|
+
context2D.moveTo(x, y1);
|
|
148
|
+
context2D.lineTo(x, y2);
|
|
149
|
+
context2D.stroke();
|
|
150
|
+
segments.push([[x + margin.left, y1 + margin.top], [x + margin.left, y2 + margin.top]]);
|
|
151
|
+
}
|
|
152
|
+
newGeometry.set(series.name, {
|
|
153
|
+
points: [],
|
|
154
|
+
segments,
|
|
155
|
+
hitRadius: Math.max(4, strokeWidth)
|
|
156
|
+
});
|
|
233
157
|
});
|
|
234
|
-
|
|
158
|
+
geometryRef.current = newGeometry;
|
|
159
|
+
context2D.restore();
|
|
160
|
+
};
|
|
161
|
+
cc.register(`raster-plot-${chartId}`, draw, 10);
|
|
162
|
+
cc.requestRedraw();
|
|
235
163
|
}, [
|
|
236
|
-
axisAssignments, chartId,
|
|
237
|
-
|
|
238
|
-
panEnabled,
|
|
239
|
-
plotDimensions,
|
|
240
|
-
seriesFilter, seriesStyles,
|
|
241
|
-
xAxesState, yAxesState,
|
|
242
|
-
zoomEnabled, zoomKeyModifiersRequired,
|
|
243
|
-
spikeMargin,
|
|
244
|
-
hoveredSeriesRef
|
|
164
|
+
axisAssignments, chartId, plotDimensions, seriesFilter, seriesStyles, xAxesState, yAxesState,
|
|
165
|
+
spikeMargin, hoveredSeriesName, margin.left, margin.top
|
|
245
166
|
]);
|
|
246
|
-
//
|
|
247
|
-
//
|
|
248
|
-
|
|
249
|
-
|
|
167
|
+
// the time axes: their ranges, the view driver, panning and zooming, highlighting, and
|
|
168
|
+
// reporting the axes' intervals -- see `useStreamingTimeAxes`
|
|
169
|
+
useStreamingTimeAxes({
|
|
170
|
+
canvasContext,
|
|
171
|
+
dataSource,
|
|
172
|
+
running,
|
|
173
|
+
initialData,
|
|
174
|
+
timeOf: datum => datum.x,
|
|
175
|
+
axisTimesFor: timeSeriesAxisTimes(axisAssignments, xAxesState),
|
|
176
|
+
axisAssignments,
|
|
177
|
+
updatePlot,
|
|
178
|
+
onDataReset: () => {
|
|
179
|
+
dataRef.current = initialData.slice();
|
|
180
|
+
seriesRef.current = new Map(initialData.map(series => [series.name, series]));
|
|
181
|
+
},
|
|
182
|
+
allowTooltipRef,
|
|
183
|
+
panEnabled,
|
|
184
|
+
zoomEnabled,
|
|
185
|
+
zoomKeyModifiersRequired,
|
|
186
|
+
onZoomReset,
|
|
187
|
+
withCadenceOf,
|
|
188
|
+
highlightAxesOnMouseOver,
|
|
189
|
+
});
|
|
190
|
+
// the series' axis assignments, for the chart (e.g. the tooltip looks up a spike's row's axis)
|
|
191
|
+
useEffect(() => {
|
|
192
|
+
setAxisAssignments(axisAssignments);
|
|
193
|
+
}, [axisAssignments, setAxisAssignments]);
|
|
194
|
+
// wires up a single mousemove/mouseleave listener on the shared canvas to replace the old
|
|
195
|
+
// per-element SVG mouseover/mouseleave handlers. Hit-tests the mouse position against the
|
|
196
|
+
// last-drawn spike geometry (see `geometryRef`, populated by the draw function above).
|
|
250
197
|
useEffect(() => {
|
|
251
|
-
if (
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
.attr('id', series => `${series.name}-${chartId}-raster`)
|
|
263
|
-
.attr('transform', `translate(${margin.left}, ${margin.top})`);
|
|
198
|
+
if (!canvasContext)
|
|
199
|
+
return;
|
|
200
|
+
const canvas = canvasContext.canvas;
|
|
201
|
+
const handleMove = (event) => {
|
|
202
|
+
if (!allowTooltipRef.current)
|
|
203
|
+
return;
|
|
204
|
+
const [x, y] = canvasLocalPoint(event, canvas);
|
|
205
|
+
const hit = seriesAt(x, y, geometryRef.current);
|
|
206
|
+
if ((hit === null || hit === void 0 ? void 0 : hit.name) === lastHoveredRef.current && hit !== undefined) {
|
|
207
|
+
// still hovering the same series -- no enter/leave to fire, but the specific
|
|
208
|
+
// spike may have changed, so fall through and re-report below
|
|
264
209
|
}
|
|
265
|
-
else {
|
|
266
|
-
|
|
267
|
-
.selectAll('g')
|
|
268
|
-
.attr("clip-path", `url(#${clipPathId})`);
|
|
210
|
+
else if (lastHoveredRef.current !== undefined) {
|
|
211
|
+
handleMouseLeaveSeries(lastHoveredRef.current, mouseLeaveHandlerFor(`tooltip-${chartId}`));
|
|
269
212
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
onUpdateTimeRef.current = updateAxisRanges;
|
|
278
|
-
}, [updateAxisRanges]);
|
|
279
|
-
// memoized function for subscribing to the chart-data observable
|
|
280
|
-
const subscribe = useCallback(() => {
|
|
281
|
-
if (seriesObservable === undefined || mainG === null)
|
|
282
|
-
return undefined;
|
|
283
|
-
if (withCadenceOf !== undefined) {
|
|
284
|
-
return subscriptionTimeSeriesWithCadenceFor(seriesObservable, onSubscribe, windowingTime, axisAssignments, xAxesState, onUpdateData, dropDataAfter, updateTimingAndPlot,
|
|
285
|
-
// as new data flows into the subscription, the subscription
|
|
286
|
-
// updates this map directly (for performance)
|
|
287
|
-
seriesRef.current, (axisId, end) => currentTimeRef.current.set(axisId, end), withCadenceOf);
|
|
288
|
-
}
|
|
289
|
-
return subscriptionTimeSeriesFor(seriesObservable, onSubscribe, windowingTime, axisAssignments, xAxesState, onUpdateData, dropDataAfter, updateTimingAndPlot,
|
|
290
|
-
// as new data flows into the subscription, the subscription
|
|
291
|
-
// updates this map directly (for performance)
|
|
292
|
-
seriesRef.current, (axisId, end) => currentTimeRef.current.set(axisId, end));
|
|
293
|
-
}, [
|
|
294
|
-
axisAssignments, dropDataAfter, mainG,
|
|
295
|
-
onSubscribe, onUpdateData,
|
|
296
|
-
seriesObservable, updateTimingAndPlot, windowingTime, xAxesState,
|
|
297
|
-
withCadenceOf
|
|
298
|
-
]);
|
|
299
|
-
const timeRangesRef = useRef(new Map());
|
|
300
|
-
useEffect(() => {
|
|
301
|
-
if (container && mainG) {
|
|
302
|
-
// so this gets a bit complicated. the time-ranges need to be updated whenever the time-ranges
|
|
303
|
-
// change. for example, as data is streamed in, the times change, and then we need to update the
|
|
304
|
-
// time-range. however, we want to keep the time-ranges to reflect their original scale so that
|
|
305
|
-
// we can zoom properly (so the updates can't fuck with the scale). At the same time, when the
|
|
306
|
-
// interpolation changes, then the update plot changes, and the time-ranges must maintain their
|
|
307
|
-
// original scale as well.
|
|
308
|
-
if (timeRangesRef.current.size === 0) {
|
|
309
|
-
// when no time-ranges have yet been created, then create them and hold on to a mutable
|
|
310
|
-
// reference to them
|
|
311
|
-
timeRangesRef.current = continuousAxisRanges(xAxesState.axes);
|
|
213
|
+
if (hit !== undefined) {
|
|
214
|
+
const series = seriesRef.current.get(hit.name);
|
|
215
|
+
const selectedDatum = series === null || series === void 0 ? void 0 : series.data[hit.index];
|
|
216
|
+
const xAxis = axesFor(hit.name, axisAssignments, axisId => xAxesState.axisFor(axisId).getOrUndefined(), axisId => yAxesState.axisFor(axisId).getOrUndefined())[0];
|
|
217
|
+
if (series !== undefined && selectedDatum !== undefined && xAxis !== undefined) {
|
|
218
|
+
handleMouseOverSeries(xAxis, hit.name, selectedDatum, series.data, [x, y], margin, mouseOverHandlerFor(`tooltip-${chartId}`));
|
|
219
|
+
}
|
|
312
220
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
const [start, end] = Optional.ofNullable(intervals.get(id))
|
|
320
|
-
.map(interval => interval.asTuple())
|
|
321
|
-
.getOrThrow(() => new Error(`Unable to retrieve interval for axis; axis_id: ${id}`));
|
|
322
|
-
// .getOrElse([NaN, NaN])
|
|
323
|
-
if (!isNaN(start) && !isNaN(end)) {
|
|
324
|
-
// update the reference map with the new (start, end) portion of the range,
|
|
325
|
-
// while keeping the original scale intact
|
|
326
|
-
rangesMap.set(id, range.update(start, end));
|
|
327
|
-
}
|
|
328
|
-
});
|
|
221
|
+
lastHoveredRef.current = hit === null || hit === void 0 ? void 0 : hit.name;
|
|
222
|
+
};
|
|
223
|
+
const handleLeaveCanvas = () => {
|
|
224
|
+
if (lastHoveredRef.current !== undefined) {
|
|
225
|
+
handleMouseLeaveSeries(lastHoveredRef.current, mouseLeaveHandlerFor(`tooltip-${chartId}`));
|
|
226
|
+
lastHoveredRef.current = undefined;
|
|
329
227
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
228
|
+
};
|
|
229
|
+
canvas.addEventListener('mousemove', handleMove);
|
|
230
|
+
canvas.addEventListener('mouseleave', handleLeaveCanvas);
|
|
231
|
+
return () => {
|
|
232
|
+
canvas.removeEventListener('mousemove', handleMove);
|
|
233
|
+
canvas.removeEventListener('mouseleave', handleLeaveCanvas);
|
|
234
|
+
};
|
|
235
|
+
}, [canvasContext, chartId, margin, axisAssignments, xAxesState, yAxesState, mouseOverHandlerFor, mouseLeaveHandlerFor]);
|
|
236
|
+
// this plot needs a data source (see the `Chart`'s `dataSource` prop)
|
|
337
237
|
useEffect(() => {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
subscriptionRef.current = subscribe();
|
|
341
|
-
allowTooltipRef.current = false;
|
|
342
|
-
}
|
|
343
|
-
else if (!shouldSubscribe && subscriptionRef.current !== undefined) {
|
|
344
|
-
(_a = subscriptionRef.current) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
345
|
-
subscriptionRef.current = undefined;
|
|
346
|
-
allowTooltipRef.current = true;
|
|
238
|
+
if (dataSource === undefined) {
|
|
239
|
+
console.error("RasterPlot requires a data source; set the enclosing Chart's `dataSource` prop");
|
|
347
240
|
}
|
|
348
|
-
}, [
|
|
241
|
+
}, [dataSource]);
|
|
242
|
+
// unregister this plot's draw function on unmount
|
|
243
|
+
useEffect(() => {
|
|
244
|
+
return () => {
|
|
245
|
+
if (canvasContext) {
|
|
246
|
+
canvasContext.unregister(`raster-plot-${chartId}`);
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
}, [canvasContext, chartId]);
|
|
349
250
|
return null;
|
|
350
251
|
}
|
|
351
252
|
/**
|
|
352
|
-
* Attempts to locate the x- and y-axes for the specified series. If
|
|
353
|
-
*
|
|
253
|
+
* Attempts to locate the x- and y-axes for the specified series. If the series has no axis
|
|
254
|
+
* assignment, then uses the default (first) x- and y-axes.
|
|
354
255
|
* @param seriesName Name of the series for which to retrieve the axis
|
|
355
256
|
* @param axisAssignments A map holding the series name and the associated x- and y-axes assigned
|
|
356
257
|
* to that series. Note that the series in the axis-assignment map is merely a subset of the set
|
|
@@ -358,63 +259,54 @@ export function RasterPlot(props) {
|
|
|
358
259
|
* @param xAxisFor The function that accepts an axis ID and returns the corresponding x-axis
|
|
359
260
|
* @param yAxisFor The function that accepts an axis ID and returns the corresponding y-axis
|
|
360
261
|
* @return A 2d tuple holding the linear x-axis as its first element and the category y-axis as
|
|
361
|
-
* the second element.
|
|
262
|
+
* the second element (either is actually `undefined` when it isn't found, despite the type).
|
|
263
|
+
* @throws Error when the x-axis isn't a continuous numeric axis, or the y-axis isn't a category axis
|
|
362
264
|
*/
|
|
363
265
|
function axesFor(seriesName, axisAssignments, xAxisFor, yAxisFor) {
|
|
364
266
|
const axes = axisAssignments.get(seriesName);
|
|
365
267
|
const xAxis = xAxisFor((axes === null || axes === void 0 ? void 0 : axes.xAxis) || "");
|
|
268
|
+
checkAxisType("RasterPlot", "x", xAxis, AxisType.ContinuousNumeric);
|
|
366
269
|
const xAxisLinear = xAxis;
|
|
367
|
-
if (xAxis && !xAxisLinear) {
|
|
368
|
-
throw Error("Raster plot requires that x-axis be of type LinearAxis");
|
|
369
|
-
}
|
|
370
270
|
const yAxis = yAxisFor((axes === null || axes === void 0 ? void 0 : axes.yAxis) || "");
|
|
271
|
+
checkAxisType("RasterPlot", "y", yAxis, AxisType.OrdinalString);
|
|
371
272
|
const yAxisCategory = yAxis;
|
|
372
|
-
if (yAxis && !yAxisCategory) {
|
|
373
|
-
throw Error("Raster plot requires that y-axis be of type CategoryAxis");
|
|
374
|
-
}
|
|
375
273
|
return [xAxisLinear, yAxisCategory];
|
|
376
274
|
}
|
|
377
275
|
/**
|
|
378
|
-
*
|
|
379
|
-
*
|
|
276
|
+
* Reports a tooltip showing the neuron, spike time, and the spike's value when the mouse hovers over a spike.
|
|
277
|
+
* Replaces the old version, which mutated the hovered SVG `<line>`'s stroke directly; highlighting is now
|
|
278
|
+
* handled by the draw function reading `hoveredSeriesName` from chart state rather than by touching an
|
|
279
|
+
* element here.
|
|
380
280
|
* @param xAxis The x-axis
|
|
381
281
|
* @param seriesName The name of the series (i.e. the neuron ID)
|
|
382
282
|
* @param selectedDatum The selected datum
|
|
383
|
-
* @param
|
|
283
|
+
* @param spikes All the series' spikes that the chart holds (for the tooltip's statistics)
|
|
284
|
+
* @param mouseCoords The `[x, y]` position of the mouse, in canvas coordinates
|
|
384
285
|
* @param margin The plot margin
|
|
385
|
-
* @param seriesStyles The series style information (needed for (un)highlighting)
|
|
386
|
-
* @param allowTooltip When set to `false` won't show tooltip, even if it is visible (used by pan)
|
|
387
286
|
* @param mouseOverHandlerFor The handler for the mouse over (registered by the <Tooltip/>)
|
|
388
287
|
*/
|
|
389
|
-
function handleMouseOverSeries(
|
|
288
|
+
function handleMouseOverSeries(xAxis, seriesName, selectedDatum, spikes, mouseCoords, margin, mouseOverHandlerFor) {
|
|
390
289
|
// grab the time needed for the tooltip ID
|
|
391
|
-
const [x
|
|
290
|
+
const [x] = mouseCoords;
|
|
392
291
|
const time = Math.round(xAxis.scale.invert(x - margin.left));
|
|
393
|
-
|
|
394
|
-
// Use d3 to select element, change color and size
|
|
395
|
-
d3.select(event.currentTarget)
|
|
396
|
-
.attr('stroke', highlightColor)
|
|
397
|
-
.attr('stroke-width', highlightWidth);
|
|
398
|
-
if (mouseOverHandlerFor && allowTooltip) {
|
|
292
|
+
if (mouseOverHandlerFor) {
|
|
399
293
|
// the contract for the mouse over handler is for a time-series, but here we only
|
|
400
294
|
// need one point, the selected datum, and so we convert it into an array of point
|
|
401
295
|
// (i.e. a time-series). The category tooltip is (and custom ones, must) be
|
|
402
|
-
// written to expect only the selected point
|
|
403
|
-
|
|
296
|
+
// written to expect only the selected point. All the series' spikes (that the chart
|
|
297
|
+
// holds) come along in the metadata, for the tooltip's statistics
|
|
298
|
+
mouseOverHandlerFor(seriesName, time, { series: [selectedDatum], metadata: { spikes } }, mouseCoords);
|
|
404
299
|
}
|
|
405
300
|
}
|
|
406
301
|
/**
|
|
407
|
-
*
|
|
302
|
+
* Calls the mouse-leave-series handler registered for this series. Replaces the old version, which
|
|
303
|
+
* also reset the hovered SVG element's stroke color/width directly; that reset is now implicit --
|
|
304
|
+
* once `hoveredSeriesName` is cleared, the next redraw simply paints the spikes in their normal
|
|
305
|
+
* (non-highlighted) style.
|
|
408
306
|
* @param seriesName The name of the series (i.e. the neuron ID)
|
|
409
|
-
* @param segment The SVG line element representing the spike, over which the mouse is hovering.
|
|
410
|
-
* @param seriesStyles The styles for the series (for (un)highlighting)
|
|
411
307
|
* @param mouseLeaverHandlerFor Registered handler for the series when the mouse leaves
|
|
412
308
|
*/
|
|
413
|
-
function handleMouseLeaveSeries(seriesName,
|
|
414
|
-
const { color, lineWidth } = seriesStyles.get(seriesName) || defaultLineStyle();
|
|
415
|
-
d3.select(segment)
|
|
416
|
-
.attr('stroke', color)
|
|
417
|
-
.attr('stroke-width', lineWidth);
|
|
309
|
+
function handleMouseLeaveSeries(seriesName, mouseLeaverHandlerFor) {
|
|
418
310
|
if (mouseLeaverHandlerFor) {
|
|
419
311
|
mouseLeaverHandlerFor(seriesName);
|
|
420
312
|
}
|