stream-charts 1.1.1 → 1.2.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/README.md +66 -0
- package/changes.md +8 -0
- package/dist/{src/app → app}/charts/Chart.d.ts +27 -6
- package/dist/{src/app → app}/charts/Chart.js +2 -2
- package/dist/app/charts/Chart.js.map +1 -0
- package/dist/{src/app → app}/charts/axes/AxesState.d.ts +4 -4
- package/dist/{src/app → app}/charts/axes/AxesState.js +4 -4
- package/dist/app/charts/axes/AxesState.js.map +1 -0
- package/dist/app/charts/axes/AxesState.test.js.map +1 -0
- package/dist/app/charts/axes/AxisInterval.js.map +1 -0
- package/dist/app/charts/axes/AxisInterval.test.js.map +1 -0
- package/dist/app/charts/axes/BaseAxisRange.js.map +1 -0
- package/dist/{src/app → app}/charts/axes/ContinuousAxis.d.ts +1 -3
- package/dist/{src/app → app}/charts/axes/ContinuousAxis.js +2 -3
- package/dist/app/charts/axes/ContinuousAxis.js.map +1 -0
- package/dist/app/charts/axes/ContinuousAxisRange.js.map +1 -0
- package/dist/app/charts/axes/ContinuousAxisRange.test.js.map +1 -0
- package/dist/app/charts/axes/EmptyAxis.d.ts +12 -0
- package/dist/app/charts/axes/EmptyAxis.js +70 -0
- package/dist/app/charts/axes/EmptyAxis.js.map +1 -0
- package/dist/{src/app → app}/charts/axes/OrdinalAxis.d.ts +1 -3
- package/dist/{src/app → app}/charts/axes/OrdinalAxis.js +10 -4
- package/dist/app/charts/axes/OrdinalAxis.js.map +1 -0
- package/dist/app/charts/axes/OrdinalAxisRange.js.map +1 -0
- package/dist/app/charts/axes/OrdinalAxisRange.test.js.map +1 -0
- package/dist/{src/app → app}/charts/axes/axes.d.ts +28 -0
- package/dist/{src/app → app}/charts/axes/axes.js +86 -6
- package/dist/app/charts/axes/axes.js.map +1 -0
- package/dist/{src/app → app}/charts/d3types.js.map +1 -1
- package/dist/app/charts/filters/regexFilter.js.map +1 -0
- package/dist/app/charts/filters/regexFilter.test.js.map +1 -0
- package/dist/{src/app → app}/charts/hooks/useAxes.d.ts +3 -5
- package/dist/{src/app → app}/charts/hooks/useAxes.js +0 -1
- package/dist/app/charts/hooks/useAxes.js.map +1 -0
- package/dist/{src/app → app}/charts/hooks/useChart.d.ts +9 -5
- package/dist/{src/app → app}/charts/hooks/useChart.js +4 -3
- package/dist/app/charts/hooks/useChart.js.map +1 -0
- package/dist/{src/app → app}/charts/hooks/useDataObservable.d.ts +2 -4
- package/dist/{src/app → app}/charts/hooks/useDataObservable.js +0 -2
- package/dist/app/charts/hooks/useDataObservable.js.map +1 -0
- package/dist/{src/app → app}/charts/hooks/useInitialData.d.ts +2 -4
- package/dist/{src/app → app}/charts/hooks/useInitialData.js +0 -1
- package/dist/app/charts/hooks/useInitialData.js.map +1 -0
- package/dist/{src/app → app}/charts/hooks/useMouse.d.ts +6 -2
- package/dist/{src/app → app}/charts/hooks/useMouse.js +14 -14
- package/dist/app/charts/hooks/useMouse.js.map +1 -0
- package/dist/{src/app → app}/charts/hooks/usePlotDimensions.d.ts +1 -2
- package/dist/{src/app → app}/charts/hooks/usePlotDimensions.js +0 -1
- package/dist/app/charts/hooks/usePlotDimensions.js.map +1 -0
- package/dist/{src/app → app}/charts/hooks/useTooltip.d.ts +4 -4
- package/dist/{src/app → app}/charts/hooks/useTooltip.js +0 -1
- package/dist/app/charts/hooks/useTooltip.js.map +1 -0
- package/dist/app/charts/legends/Legend.d.ts +88 -0
- package/dist/app/charts/legends/Legend.js +425 -0
- package/dist/app/charts/legends/Legend.js.map +1 -0
- package/dist/app/charts/observables/ChartData.js.map +1 -0
- package/dist/app/charts/observables/iterates.js.map +1 -0
- package/dist/app/charts/observables/iterates.test.js.map +1 -0
- package/dist/app/charts/observables/ordinals.js.map +1 -0
- package/dist/app/charts/observables/ordinals.test.js.map +1 -0
- package/dist/{src/app → app}/charts/plots/BarPlot.d.ts +10 -12
- package/dist/{src/app → app}/charts/plots/BarPlot.js +14 -15
- package/dist/app/charts/plots/BarPlot.js.map +1 -0
- package/dist/{src/app → app}/charts/plots/PoincarePlot.d.ts +1 -3
- package/dist/{src/app → app}/charts/plots/PoincarePlot.js +0 -1
- package/dist/app/charts/plots/PoincarePlot.js.map +1 -0
- package/dist/{src/app → app}/charts/plots/RasterPlot.d.ts +1 -3
- package/dist/{src/app → app}/charts/plots/RasterPlot.js +12 -7
- package/dist/app/charts/plots/RasterPlot.js.map +1 -0
- package/dist/{src/app → app}/charts/plots/ScatterPlot.d.ts +1 -3
- package/dist/{src/app → app}/charts/plots/ScatterPlot.js +7 -6
- package/dist/app/charts/plots/ScatterPlot.js.map +1 -0
- package/dist/app/charts/plots/plot.js.map +1 -0
- package/dist/app/charts/series/baseSeries.js.map +1 -0
- package/dist/app/charts/series/datumSeries.test.js.map +1 -0
- package/dist/app/charts/series/iterateSeries.js.map +1 -0
- package/dist/app/charts/series/ordinalSeries.js.map +1 -0
- package/dist/app/charts/series/timeSeries.js.map +1 -0
- package/dist/app/charts/series/timeSeriesChartData.js.map +1 -0
- package/dist/app/charts/styling/barPlotStyle.js.map +1 -0
- package/dist/app/charts/styling/margins.js.map +1 -0
- package/dist/app/charts/styling/margins.test.js.map +1 -0
- package/dist/app/charts/styling/svgStyle.js.map +1 -0
- package/dist/app/charts/subscriptions/subscription.test.js.map +1 -0
- package/dist/app/charts/subscriptions/subscriptions.js.map +1 -0
- package/dist/{src/app → app}/charts/tooltips/BarPlotTooltipContent.d.ts +1 -3
- package/dist/{src/app → app}/charts/tooltips/BarPlotTooltipContent.js +0 -1
- package/dist/app/charts/tooltips/BarPlotTooltipContent.js.map +1 -0
- package/dist/{src/app → app}/charts/tooltips/PoincarePlotTooltipContent.d.ts +1 -3
- package/dist/{src/app → app}/charts/tooltips/PoincarePlotTooltipContent.js +0 -1
- package/dist/app/charts/tooltips/PoincarePlotTooltipContent.js.map +1 -0
- package/dist/{src/app → app}/charts/tooltips/RasterPlotTooltipContent.d.ts +1 -3
- package/dist/{src/app → app}/charts/tooltips/RasterPlotTooltipContent.js +0 -1
- package/dist/app/charts/tooltips/RasterPlotTooltipContent.js.map +1 -0
- package/dist/{src/app → app}/charts/tooltips/ScatterPlotTooltipContent.d.ts +1 -3
- package/dist/{src/app → app}/charts/tooltips/ScatterPlotTooltipContent.js +3 -2
- package/dist/app/charts/tooltips/ScatterPlotTooltipContent.js.map +1 -0
- package/dist/{src/app → app}/charts/tooltips/Tooltip.d.ts +10 -11
- package/dist/{src/app → app}/charts/tooltips/Tooltip.js +12 -12
- package/dist/app/charts/tooltips/Tooltip.js.map +1 -0
- package/dist/app/charts/tooltips/tooltipUtils.js.map +1 -0
- package/dist/{src/app → app}/charts/trackers/Tracker.d.ts +1 -3
- package/dist/{src/app → app}/charts/trackers/Tracker.js +0 -1
- package/dist/app/charts/trackers/Tracker.js.map +1 -0
- package/dist/app/charts/trackers/trackerUtils.js.map +1 -0
- package/dist/app/charts/utils.js.map +1 -0
- package/dist/{src/index.d.ts → index.d.ts} +20 -24
- package/dist/{src/index.js → index.js} +19 -19
- package/dist/index.js.map +1 -0
- package/package.json +20 -8
- package/src/app/charts/Chart.tsx +29 -5
- package/src/app/charts/axes/AxesState.ts +4 -4
- package/src/app/charts/axes/ContinuousAxis.tsx +3 -4
- package/src/app/charts/axes/EmptyAxis.tsx +119 -0
- package/src/app/charts/axes/OrdinalAxis.tsx +15 -4
- package/src/app/charts/axes/axes.ts +122 -6
- package/src/app/charts/hooks/useAxes.tsx +3 -4
- package/src/app/charts/hooks/useChart.tsx +13 -5
- package/src/app/charts/hooks/useDataObservable.tsx +2 -7
- package/src/app/charts/hooks/useInitialData.tsx +2 -3
- package/src/app/charts/hooks/useMouse.tsx +16 -13
- package/src/app/charts/hooks/usePlotDimensions.tsx +1 -2
- package/src/app/charts/hooks/useTooltip.tsx +4 -5
- package/src/app/charts/legends/Legend.tsx +600 -0
- package/src/app/charts/plots/BarPlot.tsx +15 -16
- package/src/app/charts/plots/PoincarePlot.tsx +1 -2
- package/src/app/charts/plots/RasterPlot.tsx +21 -8
- package/src/app/charts/plots/ScatterPlot.tsx +9 -11
- package/src/app/charts/tooltips/BarPlotTooltipContent.tsx +1 -2
- package/src/app/charts/tooltips/PoincarePlotTooltipContent.tsx +1 -2
- package/src/app/charts/tooltips/RasterPlotTooltipContent.tsx +1 -2
- package/src/app/charts/tooltips/ScatterPlotTooltipContent.tsx +3 -2
- package/src/app/charts/tooltips/Tooltip.tsx +11 -11
- package/src/app/charts/trackers/Tracker.tsx +1 -2
- package/src/index.ts +322 -0
- package/dist/src/app/charts/Chart.js.map +0 -1
- package/dist/src/app/charts/axes/AxesState.js.map +0 -1
- package/dist/src/app/charts/axes/AxesState.test.js.map +0 -1
- package/dist/src/app/charts/axes/AxisInterval.js.map +0 -1
- package/dist/src/app/charts/axes/AxisInterval.test.js.map +0 -1
- package/dist/src/app/charts/axes/BaseAxisRange.js.map +0 -1
- package/dist/src/app/charts/axes/ContinuousAxis.js.map +0 -1
- package/dist/src/app/charts/axes/ContinuousAxisRange.js.map +0 -1
- package/dist/src/app/charts/axes/ContinuousAxisRange.test.js.map +0 -1
- package/dist/src/app/charts/axes/OrdinalAxis.js.map +0 -1
- package/dist/src/app/charts/axes/OrdinalAxisRange.js.map +0 -1
- package/dist/src/app/charts/axes/OrdinalAxisRange.test.js.map +0 -1
- package/dist/src/app/charts/axes/axes.js.map +0 -1
- package/dist/src/app/charts/filters/regexFilter.js.map +0 -1
- package/dist/src/app/charts/filters/regexFilter.test.js.map +0 -1
- package/dist/src/app/charts/hooks/useAxes.js.map +0 -1
- package/dist/src/app/charts/hooks/useChart.js.map +0 -1
- package/dist/src/app/charts/hooks/useDataObservable.js.map +0 -1
- package/dist/src/app/charts/hooks/useInitialData.js.map +0 -1
- package/dist/src/app/charts/hooks/useMouse.js.map +0 -1
- package/dist/src/app/charts/hooks/usePlotDimensions.js.map +0 -1
- package/dist/src/app/charts/hooks/useTooltip.js.map +0 -1
- package/dist/src/app/charts/observables/ChartData.js.map +0 -1
- package/dist/src/app/charts/observables/iterates.js.map +0 -1
- package/dist/src/app/charts/observables/iterates.test.js.map +0 -1
- package/dist/src/app/charts/observables/ordinals.js.map +0 -1
- package/dist/src/app/charts/observables/ordinals.test.js.map +0 -1
- package/dist/src/app/charts/plots/BarPlot.js.map +0 -1
- package/dist/src/app/charts/plots/PoincarePlot.js.map +0 -1
- package/dist/src/app/charts/plots/RasterPlot.js.map +0 -1
- package/dist/src/app/charts/plots/ScatterPlot.js.map +0 -1
- package/dist/src/app/charts/plots/plot.js.map +0 -1
- package/dist/src/app/charts/series/baseSeries.js.map +0 -1
- package/dist/src/app/charts/series/datumSeries.test.js.map +0 -1
- package/dist/src/app/charts/series/iterateSeries.js.map +0 -1
- package/dist/src/app/charts/series/ordinalSeries.js.map +0 -1
- package/dist/src/app/charts/series/timeSeries.js.map +0 -1
- package/dist/src/app/charts/series/timeSeriesChartData.js.map +0 -1
- package/dist/src/app/charts/styling/barPlotStyle.js.map +0 -1
- package/dist/src/app/charts/styling/margins.js.map +0 -1
- package/dist/src/app/charts/styling/margins.test.js.map +0 -1
- package/dist/src/app/charts/styling/svgStyle.js.map +0 -1
- package/dist/src/app/charts/subscriptions/subscription.test.js.map +0 -1
- package/dist/src/app/charts/subscriptions/subscriptions.js.map +0 -1
- package/dist/src/app/charts/tooltips/BarPlotTooltipContent.js.map +0 -1
- package/dist/src/app/charts/tooltips/PoincarePlotTooltipContent.js.map +0 -1
- package/dist/src/app/charts/tooltips/RasterPlotTooltipContent.js.map +0 -1
- package/dist/src/app/charts/tooltips/ScatterPlotTooltipContent.js.map +0 -1
- package/dist/src/app/charts/tooltips/Tooltip.js.map +0 -1
- package/dist/src/app/charts/tooltips/tooltipUtils.js.map +0 -1
- package/dist/src/app/charts/trackers/Tracker.js.map +0 -1
- package/dist/src/app/charts/trackers/trackerUtils.js.map +0 -1
- package/dist/src/app/charts/utils.js.map +0 -1
- package/dist/src/index.js.map +0 -1
- /package/dist/{src/app → app}/charts/axes/AxesState.test.d.ts +0 -0
- /package/dist/{src/app → app}/charts/axes/AxesState.test.js +0 -0
- /package/dist/{src/app → app}/charts/axes/AxisInterval.d.ts +0 -0
- /package/dist/{src/app → app}/charts/axes/AxisInterval.js +0 -0
- /package/dist/{src/app → app}/charts/axes/AxisInterval.test.d.ts +0 -0
- /package/dist/{src/app → app}/charts/axes/AxisInterval.test.js +0 -0
- /package/dist/{src/app → app}/charts/axes/BaseAxisRange.d.ts +0 -0
- /package/dist/{src/app → app}/charts/axes/BaseAxisRange.js +0 -0
- /package/dist/{src/app → app}/charts/axes/ContinuousAxisRange.d.ts +0 -0
- /package/dist/{src/app → app}/charts/axes/ContinuousAxisRange.js +0 -0
- /package/dist/{src/app → app}/charts/axes/ContinuousAxisRange.test.d.ts +0 -0
- /package/dist/{src/app → app}/charts/axes/ContinuousAxisRange.test.js +0 -0
- /package/dist/{src/app → app}/charts/axes/OrdinalAxisRange.d.ts +0 -0
- /package/dist/{src/app → app}/charts/axes/OrdinalAxisRange.js +0 -0
- /package/dist/{src/app → app}/charts/axes/OrdinalAxisRange.test.d.ts +0 -0
- /package/dist/{src/app → app}/charts/axes/OrdinalAxisRange.test.js +0 -0
- /package/dist/{src/app → app}/charts/d3types.d.ts +0 -0
- /package/dist/{src/app → app}/charts/d3types.js +0 -0
- /package/dist/{src/app → app}/charts/filters/regexFilter.d.ts +0 -0
- /package/dist/{src/app → app}/charts/filters/regexFilter.js +0 -0
- /package/dist/{src/app → app}/charts/filters/regexFilter.test.d.ts +0 -0
- /package/dist/{src/app → app}/charts/filters/regexFilter.test.js +0 -0
- /package/dist/{src/app → app}/charts/observables/ChartData.d.ts +0 -0
- /package/dist/{src/app → app}/charts/observables/ChartData.js +0 -0
- /package/dist/{src/app → app}/charts/observables/iterates.d.ts +0 -0
- /package/dist/{src/app → app}/charts/observables/iterates.js +0 -0
- /package/dist/{src/app → app}/charts/observables/iterates.test.d.ts +0 -0
- /package/dist/{src/app → app}/charts/observables/iterates.test.js +0 -0
- /package/dist/{src/app → app}/charts/observables/ordinals.d.ts +0 -0
- /package/dist/{src/app → app}/charts/observables/ordinals.js +0 -0
- /package/dist/{src/app → app}/charts/observables/ordinals.test.d.ts +0 -0
- /package/dist/{src/app → app}/charts/observables/ordinals.test.js +0 -0
- /package/dist/{src/app → app}/charts/plots/plot.d.ts +0 -0
- /package/dist/{src/app → app}/charts/plots/plot.js +0 -0
- /package/dist/{src/app → app}/charts/series/baseSeries.d.ts +0 -0
- /package/dist/{src/app → app}/charts/series/baseSeries.js +0 -0
- /package/dist/{src/app → app}/charts/series/datumSeries.test.d.ts +0 -0
- /package/dist/{src/app → app}/charts/series/datumSeries.test.js +0 -0
- /package/dist/{src/app → app}/charts/series/iterateSeries.d.ts +0 -0
- /package/dist/{src/app → app}/charts/series/iterateSeries.js +0 -0
- /package/dist/{src/app → app}/charts/series/ordinalSeries.d.ts +0 -0
- /package/dist/{src/app → app}/charts/series/ordinalSeries.js +0 -0
- /package/dist/{src/app → app}/charts/series/timeSeries.d.ts +0 -0
- /package/dist/{src/app → app}/charts/series/timeSeries.js +0 -0
- /package/dist/{src/app → app}/charts/series/timeSeriesChartData.d.ts +0 -0
- /package/dist/{src/app → app}/charts/series/timeSeriesChartData.js +0 -0
- /package/dist/{src/app → app}/charts/styling/barPlotStyle.d.ts +0 -0
- /package/dist/{src/app → app}/charts/styling/barPlotStyle.js +0 -0
- /package/dist/{src/app → app}/charts/styling/margins.d.ts +0 -0
- /package/dist/{src/app → app}/charts/styling/margins.js +0 -0
- /package/dist/{src/app → app}/charts/styling/margins.test.d.ts +0 -0
- /package/dist/{src/app → app}/charts/styling/margins.test.js +0 -0
- /package/dist/{src/app → app}/charts/styling/svgStyle.d.ts +0 -0
- /package/dist/{src/app → app}/charts/styling/svgStyle.js +0 -0
- /package/dist/{src/app → app}/charts/subscriptions/subscription.test.d.ts +0 -0
- /package/dist/{src/app → app}/charts/subscriptions/subscription.test.js +0 -0
- /package/dist/{src/app → app}/charts/subscriptions/subscriptions.d.ts +0 -0
- /package/dist/{src/app → app}/charts/subscriptions/subscriptions.js +0 -0
- /package/dist/{src/app → app}/charts/tooltips/tooltipUtils.d.ts +0 -0
- /package/dist/{src/app → app}/charts/tooltips/tooltipUtils.js +0 -0
- /package/dist/{src/app → app}/charts/trackers/trackerUtils.d.ts +0 -0
- /package/dist/{src/app → app}/charts/trackers/trackerUtils.js +0 -0
- /package/dist/{src/app → app}/charts/utils.d.ts +0 -0
- /package/dist/{src/app → app}/charts/utils.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {createContext, JSX, useContext} from "react";
|
|
1
|
+
import {createContext, JSX, MutableRefObject, useContext} from "react";
|
|
2
2
|
import {GSelection} from "../d3types";
|
|
3
3
|
import {BaseAxis, SeriesLineStyle, SeriesStyle} from "../axes/axes";
|
|
4
4
|
import {defaultAxesValues, useAxes, UseAxesValues} from "./useAxes";
|
|
@@ -18,7 +18,7 @@ export type NoTooltipMetadata = {}
|
|
|
18
18
|
* @template S The type of the series style
|
|
19
19
|
* @template TM The type of the tooltip's metadata (data about the series data)
|
|
20
20
|
*/
|
|
21
|
-
interface UseChartValues<D, S extends SeriesStyle, TM, AR extends BaseAxisRange, A extends BaseAxis> {
|
|
21
|
+
export interface UseChartValues<D, S extends SeriesStyle, TM, AR extends BaseAxisRange, A extends BaseAxis> {
|
|
22
22
|
/**
|
|
23
23
|
* Unique ID for the chart
|
|
24
24
|
*/
|
|
@@ -66,6 +66,11 @@ interface UseChartValues<D, S extends SeriesStyle, TM, AR extends BaseAxisRange,
|
|
|
66
66
|
*/
|
|
67
67
|
mouse: UseMouseValues<D, TM>
|
|
68
68
|
tooltip: UseTooltipValues<D, TM>
|
|
69
|
+
/**
|
|
70
|
+
* Ref tracking the currently-hovered series name (null when nothing is hovered).
|
|
71
|
+
* Updated by the Legend; read by plots so new path elements use the correct stroke.
|
|
72
|
+
*/
|
|
73
|
+
hoveredSeriesRef: MutableRefObject<string | null>
|
|
69
74
|
}
|
|
70
75
|
|
|
71
76
|
const defaultUseChartValues: UseChartValues<any, any, any, any, any> = {
|
|
@@ -85,12 +90,13 @@ const defaultUseChartValues: UseChartValues<any, any, any, any, any> = {
|
|
|
85
90
|
|
|
86
91
|
// internal chart-interaction event handlers
|
|
87
92
|
mouse: defaultMouseValues(),
|
|
88
|
-
tooltip: defaultTooltipValues()
|
|
93
|
+
tooltip: defaultTooltipValues(),
|
|
94
|
+
hoveredSeriesRef: { current: null },
|
|
89
95
|
}
|
|
90
96
|
|
|
91
97
|
const ChartContext = createContext<UseChartValues<any, any, any, any, any>>(defaultUseChartValues)
|
|
92
98
|
|
|
93
|
-
interface Props {
|
|
99
|
+
export interface Props {
|
|
94
100
|
chartId: number
|
|
95
101
|
container: SVGSVGElement | null
|
|
96
102
|
mainG: GSelection | null
|
|
@@ -99,6 +105,7 @@ interface Props {
|
|
|
99
105
|
svgStyle: Partial<SvgStyle>
|
|
100
106
|
seriesStyles?: Map<string, SeriesLineStyle>
|
|
101
107
|
seriesFilter?: RegExp
|
|
108
|
+
hoveredSeriesRef: MutableRefObject<string | null>
|
|
102
109
|
|
|
103
110
|
children: JSX.Element | Array<JSX.Element>
|
|
104
111
|
}
|
|
@@ -107,7 +114,6 @@ interface Props {
|
|
|
107
114
|
* The React context provider for the {@link UseChartValues}
|
|
108
115
|
* @param props The properties
|
|
109
116
|
* @return The children wrapped in this provider
|
|
110
|
-
* @constructor
|
|
111
117
|
*/
|
|
112
118
|
export default function ChartProvider(props: Props): JSX.Element {
|
|
113
119
|
const {
|
|
@@ -119,6 +125,7 @@ export default function ChartProvider(props: Props): JSX.Element {
|
|
|
119
125
|
seriesFilter = defaultUseChartValues.seriesFilter,
|
|
120
126
|
svgStyle,
|
|
121
127
|
seriesStyles = new Map<string, SeriesLineStyle>(),
|
|
128
|
+
hoveredSeriesRef,
|
|
122
129
|
} = props
|
|
123
130
|
|
|
124
131
|
const axes = useAxes()
|
|
@@ -139,6 +146,7 @@ export default function ChartProvider(props: Props): JSX.Element {
|
|
|
139
146
|
axes,
|
|
140
147
|
mouse,
|
|
141
148
|
tooltip,
|
|
149
|
+
hoveredSeriesRef,
|
|
142
150
|
}}
|
|
143
151
|
>
|
|
144
152
|
{props.children}
|
|
@@ -3,7 +3,6 @@ import {concat, from, Observable, Subscription} from "rxjs";
|
|
|
3
3
|
import {ChartData} from "../observables/ChartData";
|
|
4
4
|
import {useInitialData} from "./useInitialData";
|
|
5
5
|
import {BaseSeries} from "../series/baseSeries";
|
|
6
|
-
// import {noop} from "../utils";
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* No operation function for use when a default function is needed
|
|
@@ -12,13 +11,10 @@ const noop = () => {
|
|
|
12
11
|
/* empty on purpose */
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
// type SeriesObservable = Observable<TimeSeriesChartData> | Observable<IterateChartData>
|
|
16
|
-
// type Data = Array<Datum> | Array<IterateDatum>
|
|
17
|
-
|
|
18
14
|
/**
|
|
19
15
|
* The values exposed through the {@link useDataObservable} react hook
|
|
20
16
|
*/
|
|
21
|
-
interface UseObservableValues<CD extends ChartData, D> {
|
|
17
|
+
export interface UseObservableValues<CD extends ChartData, D> {
|
|
22
18
|
/**
|
|
23
19
|
* An observable source for chart data
|
|
24
20
|
*/
|
|
@@ -70,7 +66,7 @@ const defaultObservableValues: UseObservableValues<any, any> = {
|
|
|
70
66
|
|
|
71
67
|
const DataObservableContext = createContext<UseObservableValues<any, any>>(defaultObservableValues)
|
|
72
68
|
|
|
73
|
-
interface Props<CD extends ChartData, D> {
|
|
69
|
+
export interface Props<CD extends ChartData, D> {
|
|
74
70
|
// live data
|
|
75
71
|
seriesObservable?: Observable<CD>
|
|
76
72
|
windowingTime?: number
|
|
@@ -100,7 +96,6 @@ interface Props<CD extends ChartData, D> {
|
|
|
100
96
|
* The react context provider for the {@link UseObservableValues}
|
|
101
97
|
* @param props The properties
|
|
102
98
|
* @return The children wrapped in this provider
|
|
103
|
-
* @constructor
|
|
104
99
|
*/
|
|
105
100
|
export default function DataObservableProvider<CD extends ChartData, D>(props: Props<CD, D>): JSX.Element {
|
|
106
101
|
|
|
@@ -6,7 +6,7 @@ import {ChartData} from "../observables/ChartData";
|
|
|
6
6
|
/**
|
|
7
7
|
* The values exposed through the {@link useInitialData} react hook
|
|
8
8
|
*/
|
|
9
|
-
type UseInitialDataValues<CD extends ChartData, D> = {
|
|
9
|
+
export type UseInitialDataValues<CD extends ChartData, D> = {
|
|
10
10
|
/**
|
|
11
11
|
* An array of series representing the initial data for the chart (i.e. static data
|
|
12
12
|
* before streaming starts) where D is a datum, whose type must be the same as that
|
|
@@ -28,7 +28,7 @@ const defaultInitialDataValues: UseInitialDataValues<any, any> = {
|
|
|
28
28
|
|
|
29
29
|
const InitialDataContext = createContext<UseInitialDataValues<any, any>>(defaultInitialDataValues)
|
|
30
30
|
|
|
31
|
-
interface Props<CD extends ChartData, D> {
|
|
31
|
+
export interface Props<CD extends ChartData, D> {
|
|
32
32
|
initialData: Array<BaseSeries<D>>
|
|
33
33
|
asChartData?: (seriesList: Array<BaseSeries<D>>) => CD
|
|
34
34
|
children: JSX.Element | Array<JSX.Element>
|
|
@@ -38,7 +38,6 @@ interface Props<CD extends ChartData, D> {
|
|
|
38
38
|
* The React context provider for the {@link UseInitialDataValues}
|
|
39
39
|
* @param props The properties
|
|
40
40
|
* @return The children wrapped in this provider
|
|
41
|
-
* @constructor
|
|
42
41
|
*/
|
|
43
42
|
export default function InitialDataProvider<CD extends ChartData, D>(props: Props<CD, D>): JSX.Element {
|
|
44
43
|
const {
|
|
@@ -8,6 +8,11 @@ const noop = () => {
|
|
|
8
8
|
/* empty on purpose */
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Type representing the values exposed through the {@link useMouse} react hook.
|
|
13
|
+
* @template D The type of the data object for the series
|
|
14
|
+
* @template TM The type of the metadata object for the series
|
|
15
|
+
*/
|
|
11
16
|
export type UseMouseValues<D, TM> = {
|
|
12
17
|
/**
|
|
13
18
|
* Adds a mouse-over-series handler with the specified ID and handler function
|
|
@@ -64,7 +69,7 @@ export const defaultMouseValues = (): UseMouseValues<any, any> => ({
|
|
|
64
69
|
|
|
65
70
|
const MouseContext = createContext<UseMouseValues<any, any>>(defaultMouseValues())
|
|
66
71
|
|
|
67
|
-
type Props = {
|
|
72
|
+
export type Props = {
|
|
68
73
|
children: JSX.Element | Array<JSX.Element>
|
|
69
74
|
}
|
|
70
75
|
|
|
@@ -82,13 +87,12 @@ export default function MouseProvider<D, TM>(props: Props): JSX.Element {
|
|
|
82
87
|
},
|
|
83
88
|
unregisterMouseOverHandler: handlerId => mouseOverHandlersRef.current.delete(handlerId),
|
|
84
89
|
mouseOverHandlerFor: (handlerId, providerId) => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
+
if (mouseOverHandlersRef.current.size === 0) return undefined
|
|
91
|
+
return (seriesName: string, time: number, tooltipData: TooltipData<D, TM>, mouseCoords: [x: number, y: number]) => {
|
|
92
|
+
mouseOverHandlersRef.current.forEach(handler => {
|
|
93
|
+
handler(seriesName, time, tooltipData, mouseCoords, providerId)
|
|
94
|
+
})
|
|
90
95
|
}
|
|
91
|
-
return undefined
|
|
92
96
|
},
|
|
93
97
|
|
|
94
98
|
registerMouseLeaveHandler: (handlerId, handler) => {
|
|
@@ -97,13 +101,12 @@ export default function MouseProvider<D, TM>(props: Props): JSX.Element {
|
|
|
97
101
|
},
|
|
98
102
|
unregisterMouseLeaveHandler: handlerId => mouseLeaveHandlersRef.current.delete(handlerId),
|
|
99
103
|
mouseLeaveHandlerFor: (handlerId, providerId) => {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
104
|
+
if (mouseLeaveHandlersRef.current.size === 0) return undefined
|
|
105
|
+
return (seriesName: string) => {
|
|
106
|
+
mouseLeaveHandlersRef.current.forEach(handler => {
|
|
107
|
+
handler(seriesName, providerId)
|
|
108
|
+
})
|
|
105
109
|
}
|
|
106
|
-
return undefined
|
|
107
110
|
},
|
|
108
111
|
}}
|
|
109
112
|
>
|
|
@@ -40,7 +40,7 @@ export const defaultPlotDimensions = (): UsePlotDimensionsValues => ({
|
|
|
40
40
|
|
|
41
41
|
const PlotDimensionsContext = createContext<UsePlotDimensionsValues>(defaultPlotDimensions())
|
|
42
42
|
|
|
43
|
-
type Props = {
|
|
43
|
+
export type Props = {
|
|
44
44
|
containerDimensions: Dimensions
|
|
45
45
|
margin: Margin
|
|
46
46
|
children: JSX.Element | Array<JSX.Element>
|
|
@@ -97,7 +97,6 @@ export default function PlotDimensionsProvider(props: Props): JSX.Element {
|
|
|
97
97
|
plotDimensions: dimensions,
|
|
98
98
|
margin,
|
|
99
99
|
updateDimensions,
|
|
100
|
-
// updateDimensions: dimensions => setDimensions(dimensions),
|
|
101
100
|
registerPlotDimensionChangeHandler,
|
|
102
101
|
unregisterPlotDimensionChangeHandler
|
|
103
102
|
}}
|
|
@@ -11,6 +11,8 @@ const noop = () => {
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Base interface for tooltip data that is passed through to the tooltip content provider
|
|
14
|
+
* @template D The type of the data object for the series
|
|
15
|
+
* @template M The type of the metadata object for the series
|
|
14
16
|
*/
|
|
15
17
|
export interface TooltipData<D, M> {
|
|
16
18
|
series: Series<D>
|
|
@@ -27,10 +29,8 @@ export interface TooltipData<D, M> {
|
|
|
27
29
|
* @param mouseCoords The mouse coordinates over which the mouse is hovering
|
|
28
30
|
* @param providerId An optional ID of the tooltip content provider.
|
|
29
31
|
*/
|
|
30
|
-
type TooltipContentProvider<D, M> =
|
|
32
|
+
export type TooltipContentProvider<D, M> =
|
|
31
33
|
(seriesName: string, time: number, tooltipData: TooltipData<D, M>, mouseCoords: [x: number, y: number], providerId?: string) => TooltipDimensions
|
|
32
|
-
// type TooltipContentProvider<D, M> =
|
|
33
|
-
// (seriesName: string, time: number, tooltipData: TooltipData<D, M>, mouseCoords: [x: number, y: number]) => TooltipDimensions
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* The functions and values exposed through the {@link useTooltip} react hook
|
|
@@ -66,7 +66,7 @@ export const defaultTooltipValues = (): UseTooltipValues<any, any> => ({
|
|
|
66
66
|
|
|
67
67
|
const TooltipContext = createContext<UseTooltipValues<any, any>>(defaultTooltipValues())
|
|
68
68
|
|
|
69
|
-
type Props = {
|
|
69
|
+
export type Props = {
|
|
70
70
|
children: JSX.Element | Array<JSX.Element>
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -77,7 +77,6 @@ type Props = {
|
|
|
77
77
|
* the context or types of objects being moused over. When a tooltip content provider is registered
|
|
78
78
|
* without a provider ID, then the default provider ID is used.
|
|
79
79
|
* @param props The properties holding the children
|
|
80
|
-
* @constructor
|
|
81
80
|
* @return A JSX element containing the children
|
|
82
81
|
*/
|
|
83
82
|
export default function TooltipProvider<D, M>(props: Props): JSX.Element {
|