stream-charts 1.0.1 → 1.1.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 +756 -343
- package/changes.md +7 -0
- package/dist/src/app/charts/Chart.d.ts +116 -87
- package/dist/src/app/charts/Chart.js +96 -101
- package/dist/src/app/charts/Chart.js.map +1 -1
- package/dist/src/app/charts/axes/AxesState.d.ts +64 -0
- package/dist/src/app/charts/axes/AxesState.js +97 -0
- package/dist/src/app/charts/axes/AxesState.js.map +1 -0
- package/dist/src/app/charts/axes/AxesState.test.js +30 -0
- package/dist/src/app/charts/axes/AxesState.test.js.map +1 -0
- package/dist/src/app/charts/axes/AxisInterval.d.ts +92 -0
- package/dist/src/app/charts/axes/AxisInterval.js +126 -0
- package/dist/src/app/charts/axes/AxisInterval.js.map +1 -0
- package/dist/src/app/charts/axes/AxisInterval.test.js +120 -0
- package/dist/src/app/charts/axes/AxisInterval.test.js.map +1 -0
- package/dist/src/app/charts/axes/BaseAxisRange.d.ts +83 -0
- package/dist/src/app/charts/axes/BaseAxisRange.js +58 -0
- package/dist/src/app/charts/axes/BaseAxisRange.js.map +1 -0
- package/dist/src/app/charts/axes/ContinuousAxis.d.ts +22 -0
- package/dist/src/app/charts/axes/ContinuousAxis.js +96 -0
- package/dist/src/app/charts/axes/ContinuousAxis.js.map +1 -0
- package/dist/src/app/charts/axes/ContinuousAxisRange.d.ts +59 -0
- package/dist/src/app/charts/axes/ContinuousAxisRange.js +84 -0
- package/dist/src/app/charts/axes/ContinuousAxisRange.js.map +1 -0
- package/dist/src/app/charts/axes/ContinuousAxisRange.test.js +47 -0
- package/dist/src/app/charts/axes/ContinuousAxisRange.test.js.map +1 -0
- package/dist/src/app/charts/axes/OrdinalAxis.d.ts +23 -0
- package/dist/src/app/charts/axes/OrdinalAxis.js +124 -0
- package/dist/src/app/charts/axes/OrdinalAxis.js.map +1 -0
- package/dist/src/app/charts/axes/OrdinalAxisRange.d.ts +69 -0
- package/dist/src/app/charts/axes/OrdinalAxisRange.js +100 -0
- package/dist/src/app/charts/axes/OrdinalAxisRange.js.map +1 -0
- package/dist/src/app/charts/axes/OrdinalAxisRange.test.js +48 -0
- package/dist/src/app/charts/axes/OrdinalAxisRange.test.js.map +1 -0
- package/dist/src/app/charts/axes/axes.d.ts +391 -0
- package/dist/src/app/charts/axes/axes.js +1046 -0
- package/dist/src/app/charts/axes/axes.js.map +1 -0
- package/dist/src/app/charts/d3types.d.ts +10 -10
- package/dist/src/app/charts/filters/regexFilter.d.ts +9 -0
- package/dist/src/app/charts/filters/regexFilter.js +18 -0
- package/dist/src/app/charts/filters/regexFilter.js.map +1 -0
- package/dist/src/app/charts/filters/regexFilter.test.d.ts +1 -0
- package/dist/src/app/charts/filters/regexFilter.test.js +11 -0
- package/dist/src/app/charts/filters/regexFilter.test.js.map +1 -0
- package/dist/src/app/charts/hooks/useAxes.d.ts +144 -0
- package/dist/src/app/charts/hooks/useAxes.js +187 -0
- package/dist/src/app/charts/hooks/useAxes.js.map +1 -0
- package/dist/src/app/charts/hooks/useChart.d.ts +30 -201
- package/dist/src/app/charts/hooks/useChart.js +33 -134
- package/dist/src/app/charts/hooks/useChart.js.map +1 -1
- package/dist/src/app/charts/hooks/useDataObservable.d.ts +74 -0
- package/dist/src/app/charts/hooks/useDataObservable.js +76 -0
- package/dist/src/app/charts/hooks/useDataObservable.js.map +1 -0
- package/dist/src/app/charts/hooks/useInitialData.d.ts +38 -0
- package/dist/src/app/charts/hooks/useInitialData.js +29 -0
- package/dist/src/app/charts/hooks/useInitialData.js.map +1 -0
- package/dist/src/app/charts/hooks/useMouse.d.ts +53 -0
- package/dist/src/app/charts/hooks/useMouse.js +65 -0
- package/dist/src/app/charts/hooks/useMouse.js.map +1 -0
- package/dist/src/app/charts/hooks/usePlotDimensions.d.ts +34 -0
- package/dist/src/app/charts/hooks/usePlotDimensions.js +73 -0
- package/dist/src/app/charts/hooks/usePlotDimensions.js.map +1 -0
- package/dist/src/app/charts/hooks/useTooltip.d.ts +64 -0
- package/dist/src/app/charts/hooks/useTooltip.js +52 -0
- package/dist/src/app/charts/hooks/useTooltip.js.map +1 -0
- package/dist/src/app/charts/observables/ChartData.d.ts +23 -0
- package/dist/src/app/charts/observables/ChartData.js +20 -0
- package/dist/src/app/charts/observables/ChartData.js.map +1 -0
- package/dist/src/app/charts/observables/iterates.d.ts +52 -0
- package/dist/src/app/charts/observables/iterates.js +121 -0
- package/dist/src/app/charts/observables/iterates.js.map +1 -0
- package/dist/src/app/charts/observables/iterates.test.d.ts +1 -0
- package/dist/src/app/charts/observables/iterates.test.js +180 -0
- package/dist/src/app/charts/observables/iterates.test.js.map +1 -0
- package/dist/src/app/charts/observables/ordinals.d.ts +75 -0
- package/dist/src/app/charts/observables/ordinals.js +141 -0
- package/dist/src/app/charts/observables/ordinals.js.map +1 -0
- package/dist/src/app/charts/observables/ordinals.test.d.ts +1 -0
- package/dist/src/app/charts/observables/ordinals.test.js +102 -0
- package/dist/src/app/charts/observables/ordinals.test.js.map +1 -0
- package/dist/src/app/charts/plots/BarPlot.d.ts +81 -0
- package/dist/src/app/charts/plots/BarPlot.js +557 -0
- package/dist/src/app/charts/plots/BarPlot.js.map +1 -0
- package/dist/src/app/charts/plots/PoincarePlot.d.ts +78 -0
- package/dist/src/app/charts/plots/PoincarePlot.js +504 -0
- package/dist/src/app/charts/plots/PoincarePlot.js.map +1 -0
- package/dist/src/app/charts/{RasterPlot.d.ts → plots/RasterPlot.d.ts} +1 -1
- package/dist/src/app/charts/{RasterPlot.js → plots/RasterPlot.js} +152 -133
- package/dist/src/app/charts/plots/RasterPlot.js.map +1 -0
- package/dist/src/app/charts/{ScatterPlot.d.ts → plots/ScatterPlot.d.ts} +10 -8
- package/dist/src/app/charts/plots/ScatterPlot.js +379 -0
- package/dist/src/app/charts/plots/ScatterPlot.js.map +1 -0
- package/dist/src/app/charts/{plot.d.ts → plots/plot.d.ts} +12 -14
- package/dist/src/app/charts/{plot.js → plots/plot.js} +19 -17
- package/dist/src/app/charts/plots/plot.js.map +1 -0
- package/dist/src/app/charts/series/baseSeries.d.ts +38 -0
- package/dist/src/app/charts/series/baseSeries.js +36 -0
- package/dist/src/app/charts/series/baseSeries.js.map +1 -0
- package/dist/src/app/charts/series/datumSeries.test.d.ts +1 -0
- package/dist/src/app/charts/series/datumSeries.test.js +50 -0
- package/dist/src/app/charts/series/datumSeries.test.js.map +1 -0
- package/dist/src/app/charts/series/iterateSeries.d.ts +42 -0
- package/dist/src/app/charts/series/iterateSeries.js +34 -0
- package/dist/src/app/charts/series/iterateSeries.js.map +1 -0
- package/dist/src/app/charts/series/ordinalSeries.d.ts +54 -0
- package/dist/src/app/charts/series/ordinalSeries.js +98 -0
- package/dist/src/app/charts/series/ordinalSeries.js.map +1 -0
- package/dist/src/app/charts/series/timeSeries.d.ts +30 -0
- package/dist/src/app/charts/series/timeSeries.js +19 -0
- package/dist/src/app/charts/series/timeSeries.js.map +1 -0
- package/dist/src/app/charts/{chartData.d.ts → series/timeSeriesChartData.d.ts} +11 -6
- package/dist/src/app/charts/series/timeSeriesChartData.js +32 -0
- package/dist/src/app/charts/series/timeSeriesChartData.js.map +1 -0
- package/dist/src/app/charts/styling/barPlotStyle.d.ts +41 -0
- package/dist/src/app/charts/styling/barPlotStyle.js +84 -0
- package/dist/src/app/charts/styling/barPlotStyle.js.map +1 -0
- package/dist/src/app/charts/{margins.d.ts → styling/margins.d.ts} +7 -5
- package/dist/src/app/charts/{margins.js → styling/margins.js} +19 -9
- package/dist/src/app/charts/styling/margins.js.map +1 -0
- package/dist/src/app/charts/styling/margins.test.d.ts +1 -0
- package/dist/src/app/charts/styling/margins.test.js +19 -0
- package/dist/src/app/charts/styling/margins.test.js.map +1 -0
- package/dist/src/app/charts/styling/svgStyle.d.ts +76 -0
- package/dist/src/app/charts/styling/svgStyle.js +84 -0
- package/dist/src/app/charts/styling/svgStyle.js.map +1 -0
- package/dist/src/app/charts/subscriptions/subscription.test.d.ts +1 -0
- package/dist/src/app/charts/subscriptions/subscription.test.js +395 -0
- package/dist/src/app/charts/subscriptions/subscription.test.js.map +1 -0
- package/dist/src/app/charts/subscriptions/subscriptions.d.ts +100 -0
- package/dist/src/app/charts/subscriptions/subscriptions.js +449 -0
- package/dist/src/app/charts/subscriptions/subscriptions.js.map +1 -0
- package/dist/src/app/charts/tooltips/BarPlotTooltipContent.d.ts +90 -0
- package/dist/src/app/charts/tooltips/BarPlotTooltipContent.js +302 -0
- package/dist/src/app/charts/tooltips/BarPlotTooltipContent.js.map +1 -0
- package/dist/src/app/charts/tooltips/PoincarePlotTooltipContent.d.ts +100 -0
- package/dist/src/app/charts/tooltips/PoincarePlotTooltipContent.js +190 -0
- package/dist/src/app/charts/tooltips/PoincarePlotTooltipContent.js.map +1 -0
- package/dist/src/app/charts/{RasterPlotTooltipContent.js → tooltips/RasterPlotTooltipContent.js} +40 -44
- package/dist/src/app/charts/tooltips/RasterPlotTooltipContent.js.map +1 -0
- package/dist/src/app/charts/tooltips/ScatterPlotTooltipContent.js +154 -0
- package/dist/src/app/charts/tooltips/ScatterPlotTooltipContent.js.map +1 -0
- package/dist/src/app/charts/{Tooltip.d.ts → tooltips/Tooltip.d.ts} +4 -2
- package/dist/src/app/charts/{Tooltip.js → tooltips/Tooltip.js} +23 -28
- package/dist/src/app/charts/tooltips/Tooltip.js.map +1 -0
- package/dist/src/app/charts/{tooltipUtils.d.ts → tooltips/tooltipUtils.d.ts} +11 -6
- package/dist/src/app/charts/{tooltipUtils.js → tooltips/tooltipUtils.js} +33 -17
- package/dist/src/app/charts/tooltips/tooltipUtils.js.map +1 -0
- package/dist/src/app/charts/{Tracker.d.ts → trackers/Tracker.d.ts} +6 -5
- package/dist/src/app/charts/trackers/Tracker.js +60 -0
- package/dist/src/app/charts/trackers/Tracker.js.map +1 -0
- package/dist/src/app/charts/{trackerUtils.d.ts → trackers/trackerUtils.d.ts} +13 -8
- package/dist/src/app/charts/trackers/trackerUtils.js +359 -0
- package/dist/src/app/charts/trackers/trackerUtils.js.map +1 -0
- package/dist/src/app/charts/utils.d.ts +22 -32
- package/dist/src/app/charts/utils.js +36 -37
- package/dist/src/app/charts/utils.js.map +1 -1
- package/dist/src/index.d.ts +48 -15
- package/dist/src/index.js +71 -15
- package/dist/src/index.js.map +1 -1
- package/package.json +30 -20
- package/src/app/charts/Chart.tsx +334 -0
- package/src/app/charts/axes/AxesState.test.ts +34 -0
- package/src/app/charts/axes/AxesState.ts +112 -0
- package/src/app/charts/axes/AxisInterval.test.ts +143 -0
- package/src/app/charts/axes/AxisInterval.ts +139 -0
- package/src/app/charts/axes/BaseAxisRange.ts +113 -0
- package/src/app/charts/axes/ContinuousAxis.tsx +192 -0
- package/src/app/charts/axes/ContinuousAxisRange.test.ts +55 -0
- package/src/app/charts/axes/ContinuousAxisRange.ts +96 -0
- package/src/app/charts/axes/OrdinalAxis.tsx +223 -0
- package/src/app/charts/axes/OrdinalAxisRange.test.ts +55 -0
- package/src/app/charts/axes/OrdinalAxisRange.ts +112 -0
- package/src/app/charts/axes/axes.ts +1569 -0
- package/src/app/charts/d3types.ts +16 -0
- package/src/app/charts/filters/regexFilter.test.ts +13 -0
- package/src/app/charts/filters/regexFilter.ts +17 -0
- package/src/app/charts/hooks/useAxes.tsx +341 -0
- package/src/app/charts/hooks/useChart.tsx +159 -0
- package/src/app/charts/hooks/useDataObservable.tsx +175 -0
- package/src/app/charts/hooks/useInitialData.tsx +65 -0
- package/src/app/charts/hooks/useMouse.tsx +125 -0
- package/src/app/charts/hooks/usePlotDimensions.tsx +120 -0
- package/src/app/charts/hooks/useTooltip.tsx +112 -0
- package/src/app/charts/observables/ChartData.ts +31 -0
- package/src/app/charts/observables/iterates.test.ts +201 -0
- package/src/app/charts/observables/iterates.ts +203 -0
- package/src/app/charts/observables/ordinals.test.ts +135 -0
- package/src/app/charts/observables/ordinals.ts +248 -0
- package/src/app/charts/plots/BarPlot.tsx +1088 -0
- package/src/app/charts/plots/PoincarePlot.tsx +832 -0
- package/src/app/charts/plots/RasterPlot.tsx +676 -0
- package/src/app/charts/plots/ScatterPlot.tsx +653 -0
- package/src/app/charts/plots/plot.ts +75 -0
- package/src/app/charts/series/baseSeries.ts +52 -0
- package/src/app/charts/series/datumSeries.test.ts +60 -0
- package/src/app/charts/series/iterateSeries.ts +56 -0
- package/src/app/charts/series/ordinalSeries.ts +164 -0
- package/src/app/charts/series/timeSeries.ts +40 -0
- package/src/app/charts/series/timeSeriesChartData.ts +68 -0
- package/src/app/charts/styling/barPlotStyle.ts +126 -0
- package/src/app/charts/styling/margins.test.ts +22 -0
- package/src/app/charts/styling/margins.ts +58 -0
- package/src/app/charts/styling/svgStyle.ts +118 -0
- package/src/app/charts/subscriptions/subscription.test.ts +499 -0
- package/src/app/charts/subscriptions/subscriptions.ts +635 -0
- package/src/app/charts/tooltips/BarPlotTooltipContent.tsx +440 -0
- package/src/app/charts/tooltips/PoincarePlotTooltipContent.tsx +352 -0
- package/src/app/charts/tooltips/RasterPlotTooltipContent.tsx +274 -0
- package/src/app/charts/tooltips/ScatterPlotTooltipContent.tsx +319 -0
- package/src/app/charts/tooltips/Tooltip.tsx +148 -0
- package/src/app/charts/tooltips/tooltipUtils.ts +216 -0
- package/src/app/charts/trackers/Tracker.tsx +129 -0
- package/src/app/charts/trackers/trackerUtils.ts +494 -0
- package/src/app/charts/utils.ts +109 -0
- package/dist/src/app/charts/CategoryAxis.d.ts +0 -20
- package/dist/src/app/charts/CategoryAxis.js +0 -112
- package/dist/src/app/charts/CategoryAxis.js.map +0 -1
- package/dist/src/app/charts/ContinuousAxis.d.ts +0 -16
- package/dist/src/app/charts/ContinuousAxis.js +0 -186
- package/dist/src/app/charts/ContinuousAxis.js.map +0 -1
- package/dist/src/app/charts/RasterPlot.js.map +0 -1
- package/dist/src/app/charts/RasterPlotTooltipContent.js.map +0 -1
- package/dist/src/app/charts/ScatterPlot.js +0 -351
- package/dist/src/app/charts/ScatterPlot.js.map +0 -1
- package/dist/src/app/charts/ScatterPlotTooltipContent.js +0 -163
- package/dist/src/app/charts/ScatterPlotTooltipContent.js.map +0 -1
- package/dist/src/app/charts/Tooltip.js.map +0 -1
- package/dist/src/app/charts/Tracker.js +0 -65
- package/dist/src/app/charts/Tracker.js.map +0 -1
- package/dist/src/app/charts/axes.d.ts +0 -132
- package/dist/src/app/charts/axes.js +0 -265
- package/dist/src/app/charts/axes.js.map +0 -1
- package/dist/src/app/charts/chartData.js +0 -32
- package/dist/src/app/charts/chartData.js.map +0 -1
- package/dist/src/app/charts/continuousAxisRangeFor.d.ts +0 -20
- package/dist/src/app/charts/continuousAxisRangeFor.js +0 -68
- package/dist/src/app/charts/continuousAxisRangeFor.js.map +0 -1
- package/dist/src/app/charts/datumSeries.d.ts +0 -59
- package/dist/src/app/charts/datumSeries.js +0 -55
- package/dist/src/app/charts/datumSeries.js.map +0 -1
- package/dist/src/app/charts/datumSeries.test.js +0 -50
- package/dist/src/app/charts/datumSeries.test.js.map +0 -1
- package/dist/src/app/charts/hooks/AxesState.d.ts +0 -37
- package/dist/src/app/charts/hooks/AxesState.js +0 -44
- package/dist/src/app/charts/hooks/AxesState.js.map +0 -1
- package/dist/src/app/charts/margins.js.map +0 -1
- package/dist/src/app/charts/margins.test.js +0 -14
- package/dist/src/app/charts/margins.test.js.map +0 -1
- package/dist/src/app/charts/plot.js.map +0 -1
- package/dist/src/app/charts/regexFilter.d.ts +0 -9
- package/dist/src/app/charts/regexFilter.js +0 -17
- package/dist/src/app/charts/regexFilter.js.map +0 -1
- package/dist/src/app/charts/regexFilter.test.js +0 -11
- package/dist/src/app/charts/regexFilter.test.js.map +0 -1
- package/dist/src/app/charts/subscriptions.d.ts +0 -43
- package/dist/src/app/charts/subscriptions.js +0 -213
- package/dist/src/app/charts/subscriptions.js.map +0 -1
- package/dist/src/app/charts/svgStyle.d.ts +0 -27
- package/dist/src/app/charts/svgStyle.js +0 -32
- package/dist/src/app/charts/svgStyle.js.map +0 -1
- package/dist/src/app/charts/timeRange.test.js +0 -54
- package/dist/src/app/charts/timeRange.test.js.map +0 -1
- package/dist/src/app/charts/tooltipUtils.js.map +0 -1
- package/dist/src/app/charts/trackerUtils.js +0 -130
- package/dist/src/app/charts/trackerUtils.js.map +0 -1
- /package/dist/src/app/charts/{datumSeries.test.d.ts → axes/AxesState.test.d.ts} +0 -0
- /package/dist/src/app/charts/{margins.test.d.ts → axes/AxisInterval.test.d.ts} +0 -0
- /package/dist/src/app/charts/{regexFilter.test.d.ts → axes/ContinuousAxisRange.test.d.ts} +0 -0
- /package/dist/src/app/charts/{timeRange.test.d.ts → axes/OrdinalAxisRange.test.d.ts} +0 -0
- /package/dist/src/app/charts/{RasterPlotTooltipContent.d.ts → tooltips/RasterPlotTooltipContent.d.ts} +0 -0
- /package/dist/src/app/charts/{ScatterPlotTooltipContent.d.ts → tooltips/ScatterPlotTooltipContent.d.ts} +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { JSX } from "react";
|
|
2
|
+
import { BaseSeries } from "../series/baseSeries";
|
|
3
|
+
import { ChartData } from "../observables/ChartData";
|
|
4
|
+
/**
|
|
5
|
+
* The values exposed through the {@link useInitialData} react hook
|
|
6
|
+
*/
|
|
7
|
+
type UseInitialDataValues<CD extends ChartData, D> = {
|
|
8
|
+
/**
|
|
9
|
+
* An array of series representing the initial data for the chart (i.e. static data
|
|
10
|
+
* before streaming starts) where D is a datum, whose type must be the same as that
|
|
11
|
+
* used for the Observable on the chart data
|
|
12
|
+
*/
|
|
13
|
+
initialData: Array<BaseSeries<D>>;
|
|
14
|
+
/**
|
|
15
|
+
* Function that takes an array of series (which has elements of type D) and converts
|
|
16
|
+
* it into a chart data type, CD
|
|
17
|
+
* @param seriesList
|
|
18
|
+
*/
|
|
19
|
+
asChartData?: (seriesList: Array<BaseSeries<D>>) => CD;
|
|
20
|
+
};
|
|
21
|
+
interface Props<CD extends ChartData, D> {
|
|
22
|
+
initialData: Array<BaseSeries<D>>;
|
|
23
|
+
asChartData?: (seriesList: Array<BaseSeries<D>>) => CD;
|
|
24
|
+
children: JSX.Element | Array<JSX.Element>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The React context provider for the {@link UseInitialDataValues}
|
|
28
|
+
* @param props The properties
|
|
29
|
+
* @return The children wrapped in this provider
|
|
30
|
+
* @constructor
|
|
31
|
+
*/
|
|
32
|
+
export default function InitialDataProvider<CD extends ChartData, D>(props: Props<CD, D>): JSX.Element;
|
|
33
|
+
/**
|
|
34
|
+
* React hook that sets up the React context for the initial data values.
|
|
35
|
+
* @return The {@link UseInitialDataValues} held in the React context.
|
|
36
|
+
*/
|
|
37
|
+
export declare function useInitialData<CD extends ChartData, D>(): UseInitialDataValues<CD, D>;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
const defaultInitialDataValues = {
|
|
4
|
+
initialData: new Array()
|
|
5
|
+
};
|
|
6
|
+
const InitialDataContext = createContext(defaultInitialDataValues);
|
|
7
|
+
/**
|
|
8
|
+
* The React context provider for the {@link UseInitialDataValues}
|
|
9
|
+
* @param props The properties
|
|
10
|
+
* @return The children wrapped in this provider
|
|
11
|
+
* @constructor
|
|
12
|
+
*/
|
|
13
|
+
export default function InitialDataProvider(props) {
|
|
14
|
+
const { initialData, asChartData } = props;
|
|
15
|
+
return _jsx(InitialDataContext.Provider, { value: { initialData, asChartData }, children: props.children });
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* React hook that sets up the React context for the initial data values.
|
|
19
|
+
* @return The {@link UseInitialDataValues} held in the React context.
|
|
20
|
+
*/
|
|
21
|
+
export function useInitialData() {
|
|
22
|
+
const context = useContext(InitialDataContext);
|
|
23
|
+
const { initialData } = context;
|
|
24
|
+
if (initialData === undefined) {
|
|
25
|
+
throw new Error("useInitialData can only be used when the parent is a <InitialDataProvider/>");
|
|
26
|
+
}
|
|
27
|
+
return context;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=useInitialData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInitialData.js","sourceRoot":"","sources":["../../../../../src/app/charts/hooks/useInitialData.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,aAAa,EAAO,UAAU,EAAC,MAAM,OAAO,CAAC;AAwBrD,MAAM,wBAAwB,GAAmC;IAC7D,WAAW,EAAE,IAAI,KAAK,EAAmB;CAC5C,CAAA;AAED,MAAM,kBAAkB,GAAG,aAAa,CAAiC,wBAAwB,CAAC,CAAA;AAQlG;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAA0B,KAAmB;IACpF,MAAM,EACF,WAAW,EACX,WAAW,EACd,GAAG,KAAK,CAAA;IAET,OAAO,KAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAC,WAAW,EAAE,WAAW,EAAC,YAChE,KAAK,CAAC,QAAQ,GACW,CAAA;AAClC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC1B,MAAM,OAAO,GAAG,UAAU,CAA8B,kBAAkB,CAAC,CAAA;IAC3E,MAAM,EAAC,WAAW,EAAC,GAAG,OAAO,CAAA;IAC7B,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAA;IAClG,CAAC;IACD,OAAO,OAAO,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { JSX } from "react";
|
|
2
|
+
import { TooltipData } from "./useTooltip";
|
|
3
|
+
export type UseMouseValues<D, TM> = {
|
|
4
|
+
/**
|
|
5
|
+
* Adds a mouse-over-series handler with the specified ID and handler function
|
|
6
|
+
* @param handlerId The handler ID
|
|
7
|
+
* @param handler The handler function called when a mouse-over-series event occurs.
|
|
8
|
+
* The handler function is handed the series name, the time (x-value), the actual
|
|
9
|
+
* series, and the mouse coordinates over which the mouse has moved over.
|
|
10
|
+
* @return The handler ID.
|
|
11
|
+
*/
|
|
12
|
+
registerMouseOverHandler: (handlerId: string, handler: (seriesName: string, time: number, tooltipData: TooltipData<D, TM>, mouseCoords: [x: number, y: number]) => void) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Removes the mouse-over-series handler with the specified ID
|
|
15
|
+
* @param handlerId The ID of the handler to remove
|
|
16
|
+
*/
|
|
17
|
+
unregisterMouseOverHandler: (handlerId: string) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Attempts to retrieve the mouse-over-series handler for the specified ID
|
|
20
|
+
* @param handlerId The ID of the handler
|
|
21
|
+
* @return The mouse-over-series handler for the ID, or `undefined` if not found
|
|
22
|
+
*/
|
|
23
|
+
mouseOverHandlerFor: (handlerId: string, providerId?: string) => ((seriesName: string, time: number, tooltipData: TooltipData<D, TM>, mouseCoords: [x: number, y: number], providerId?: string) => void) | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Adds a mouse-leave-series handler with the specified ID and handler function
|
|
26
|
+
* @param handlerId The handler ID
|
|
27
|
+
* @param handler The handler function called when a mouse-leave-series event occurs
|
|
28
|
+
* @return The handler ID
|
|
29
|
+
*/
|
|
30
|
+
registerMouseLeaveHandler: (handlerId: string, handler: (seriesName: string) => void) => string;
|
|
31
|
+
/**
|
|
32
|
+
* Removes the mouse-leave-series handler with the specified ID
|
|
33
|
+
* @param handlerId The ID of the handler to remove
|
|
34
|
+
*/
|
|
35
|
+
unregisterMouseLeaveHandler: (handlerId: string) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Attempts to retrieve the mouse-leave-series handler for the specified ID
|
|
38
|
+
* @param handlerId The ID of the handler
|
|
39
|
+
* @return The mouse-leave-series handler for the ID, or `undefined` if not found
|
|
40
|
+
*/
|
|
41
|
+
mouseLeaveHandlerFor: (handlerId: string, providerId?: string) => ((seriesName: string, providerId?: string) => void) | undefined;
|
|
42
|
+
};
|
|
43
|
+
export declare const defaultMouseValues: () => UseMouseValues<any, any>;
|
|
44
|
+
type Props = {
|
|
45
|
+
children: JSX.Element | Array<JSX.Element>;
|
|
46
|
+
};
|
|
47
|
+
export default function MouseProvider<D, TM>(props: Props): JSX.Element;
|
|
48
|
+
/**
|
|
49
|
+
* React hook that sets up the React context for the mouse values.
|
|
50
|
+
* @return The {@link UseMouseValues} held in the React context.
|
|
51
|
+
*/
|
|
52
|
+
export declare function useMouse<D, TM>(): UseMouseValues<D, TM>;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useRef } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* No operation function for use when a default function is needed
|
|
5
|
+
*/
|
|
6
|
+
const noop = () => {
|
|
7
|
+
/* empty on purpose */
|
|
8
|
+
};
|
|
9
|
+
export const defaultMouseValues = () => ({
|
|
10
|
+
registerMouseOverHandler: () => '',
|
|
11
|
+
unregisterMouseOverHandler: noop,
|
|
12
|
+
mouseOverHandlerFor: () => undefined,
|
|
13
|
+
registerMouseLeaveHandler: () => '',
|
|
14
|
+
unregisterMouseLeaveHandler: noop,
|
|
15
|
+
mouseLeaveHandlerFor: () => undefined,
|
|
16
|
+
});
|
|
17
|
+
const MouseContext = createContext(defaultMouseValues());
|
|
18
|
+
export default function MouseProvider(props) {
|
|
19
|
+
const { children } = props;
|
|
20
|
+
const mouseOverHandlersRef = useRef(new Map());
|
|
21
|
+
const mouseLeaveHandlersRef = useRef(new Map());
|
|
22
|
+
return _jsx(MouseContext.Provider, { value: {
|
|
23
|
+
registerMouseOverHandler: (handlerId, handler) => {
|
|
24
|
+
mouseOverHandlersRef.current.set(handlerId, handler);
|
|
25
|
+
return handlerId;
|
|
26
|
+
},
|
|
27
|
+
unregisterMouseOverHandler: handlerId => mouseOverHandlersRef.current.delete(handlerId),
|
|
28
|
+
mouseOverHandlerFor: (handlerId, providerId) => {
|
|
29
|
+
const handlerHoc = mouseOverHandlersRef.current.get(handlerId);
|
|
30
|
+
if (handlerHoc !== undefined) {
|
|
31
|
+
return (seriesName, time, tooltipData, mouseCoords) => {
|
|
32
|
+
handlerHoc(seriesName, time, tooltipData, mouseCoords, providerId);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return undefined;
|
|
36
|
+
},
|
|
37
|
+
registerMouseLeaveHandler: (handlerId, handler) => {
|
|
38
|
+
mouseLeaveHandlersRef.current.set(handlerId, handler);
|
|
39
|
+
return handlerId;
|
|
40
|
+
},
|
|
41
|
+
unregisterMouseLeaveHandler: handlerId => mouseLeaveHandlersRef.current.delete(handlerId),
|
|
42
|
+
mouseLeaveHandlerFor: (handlerId, providerId) => {
|
|
43
|
+
const handlerHoc = mouseLeaveHandlersRef.current.get(handlerId);
|
|
44
|
+
if (handlerHoc !== undefined) {
|
|
45
|
+
return (seriesName) => {
|
|
46
|
+
handlerHoc(seriesName, providerId);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
},
|
|
51
|
+
}, children: children });
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* React hook that sets up the React context for the mouse values.
|
|
55
|
+
* @return The {@link UseMouseValues} held in the React context.
|
|
56
|
+
*/
|
|
57
|
+
export function useMouse() {
|
|
58
|
+
const context = useContext(MouseContext);
|
|
59
|
+
const { mouseOverHandlerFor } = context;
|
|
60
|
+
if (mouseOverHandlerFor === undefined || mouseOverHandlerFor === null) {
|
|
61
|
+
throw new Error("useMouse can only be used when the parent is a <MouseProvider/>");
|
|
62
|
+
}
|
|
63
|
+
return context;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=useMouse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMouse.js","sourceRoot":"","sources":["../../../../../src/app/charts/hooks/useMouse.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,aAAa,EAAO,UAAU,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AA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
|
2
|
+
import { JSX } from "react";
|
|
3
|
+
export declare const defaultMargin: Margin;
|
|
4
|
+
export type PlotDimensionChangeHandler = (previousDimensions: Dimensions, newDimensions: Dimensions) => void;
|
|
5
|
+
export type UsePlotDimensionsValues = {
|
|
6
|
+
/**
|
|
7
|
+
* The width and height (in pixels) of this chart
|
|
8
|
+
*/
|
|
9
|
+
plotDimensions: Dimensions;
|
|
10
|
+
/**
|
|
11
|
+
* The plot margins for the border of main G
|
|
12
|
+
*/
|
|
13
|
+
margin: Margin;
|
|
14
|
+
/**
|
|
15
|
+
* Update the plot dimensions (for example, on a window resize)
|
|
16
|
+
* @param dimensions the new dimensions of the plot
|
|
17
|
+
*/
|
|
18
|
+
updateDimensions: (dimensions: Dimensions) => void;
|
|
19
|
+
registerPlotDimensionChangeHandler: (handler: PlotDimensionChangeHandler) => string;
|
|
20
|
+
unregisterPlotDimensionChangeHandler: (handlerId: string) => void;
|
|
21
|
+
};
|
|
22
|
+
export declare const defaultPlotDimensions: () => UsePlotDimensionsValues;
|
|
23
|
+
type Props = {
|
|
24
|
+
containerDimensions: Dimensions;
|
|
25
|
+
margin: Margin;
|
|
26
|
+
children: JSX.Element | Array<JSX.Element>;
|
|
27
|
+
};
|
|
28
|
+
export default function PlotDimensionsProvider(props: Props): JSX.Element;
|
|
29
|
+
/**
|
|
30
|
+
* React hook that sets up the React context for the plot-dimension values.
|
|
31
|
+
* @return The {@link UsePlotDimensionsValues} held in the React context.
|
|
32
|
+
*/
|
|
33
|
+
export declare function usePlotDimensions(): UsePlotDimensionsValues;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { dimensionsNotEqual, plotDimensionsFrom } from "../styling/margins";
|
|
3
|
+
import { createContext, useContext, useEffect, useRef, useState } from "react";
|
|
4
|
+
/**
|
|
5
|
+
* No operation function for use when a default function is needed
|
|
6
|
+
*/
|
|
7
|
+
const noop = () => {
|
|
8
|
+
/* empty on purpose */
|
|
9
|
+
};
|
|
10
|
+
export const defaultMargin = { top: 30, right: 20, bottom: 30, left: 50 };
|
|
11
|
+
export const defaultPlotDimensions = () => ({
|
|
12
|
+
plotDimensions: { width: 0, height: 0 },
|
|
13
|
+
margin: defaultMargin,
|
|
14
|
+
updateDimensions: noop,
|
|
15
|
+
registerPlotDimensionChangeHandler: () => "",
|
|
16
|
+
unregisterPlotDimensionChangeHandler: noop
|
|
17
|
+
});
|
|
18
|
+
const PlotDimensionsContext = createContext(defaultPlotDimensions());
|
|
19
|
+
export default function PlotDimensionsProvider(props) {
|
|
20
|
+
const { containerDimensions, margin, children } = props;
|
|
21
|
+
const [dimensions, setDimensions] = useState(defaultPlotDimensions().plotDimensions);
|
|
22
|
+
const plotDimensionChangeHandersRef = useRef(new Map());
|
|
23
|
+
// update the plot dimensions when the container size or margin change
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const newDimensions = plotDimensionsFrom(containerDimensions.width, containerDimensions.height, margin);
|
|
26
|
+
setDimensions(prevDimensions => {
|
|
27
|
+
if (dimensionsNotEqual(prevDimensions, newDimensions)) {
|
|
28
|
+
for (const handler of plotDimensionChangeHandersRef.current.values()) {
|
|
29
|
+
handler(prevDimensions, newDimensions);
|
|
30
|
+
}
|
|
31
|
+
return newDimensions;
|
|
32
|
+
}
|
|
33
|
+
return prevDimensions;
|
|
34
|
+
});
|
|
35
|
+
}, [containerDimensions, margin]);
|
|
36
|
+
function updateDimensions(newDimensions) {
|
|
37
|
+
setDimensions(prevState => {
|
|
38
|
+
for (const handler of plotDimensionChangeHandersRef.current.values()) {
|
|
39
|
+
handler(prevState, newDimensions);
|
|
40
|
+
}
|
|
41
|
+
return newDimensions;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function registerPlotDimensionChangeHandler(handler) {
|
|
45
|
+
const handlerId = crypto.randomUUID();
|
|
46
|
+
plotDimensionChangeHandersRef.current.set(handlerId, handler);
|
|
47
|
+
return handlerId;
|
|
48
|
+
}
|
|
49
|
+
function unregisterPlotDimensionChangeHandler(handlerId) {
|
|
50
|
+
return plotDimensionChangeHandersRef.current.delete(handlerId);
|
|
51
|
+
}
|
|
52
|
+
return _jsx(PlotDimensionsContext.Provider, { value: {
|
|
53
|
+
plotDimensions: dimensions,
|
|
54
|
+
margin,
|
|
55
|
+
updateDimensions,
|
|
56
|
+
// updateDimensions: dimensions => setDimensions(dimensions),
|
|
57
|
+
registerPlotDimensionChangeHandler,
|
|
58
|
+
unregisterPlotDimensionChangeHandler
|
|
59
|
+
}, children: children });
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* React hook that sets up the React context for the plot-dimension values.
|
|
63
|
+
* @return The {@link UsePlotDimensionsValues} held in the React context.
|
|
64
|
+
*/
|
|
65
|
+
export function usePlotDimensions() {
|
|
66
|
+
const context = useContext(PlotDimensionsContext);
|
|
67
|
+
const { plotDimensions } = context;
|
|
68
|
+
if (plotDimensions === undefined || plotDimensions === null) {
|
|
69
|
+
throw new Error("usePlotDimensions can only be used when the parent is a <PlotDimensionsProvider/>");
|
|
70
|
+
}
|
|
71
|
+
return context;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=usePlotDimensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePlotDimensions.js","sourceRoot":"","sources":["../../../../../src/app/charts/hooks/usePlotDimensions.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,kBAAkB,EAAU,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAC9F,OAAO,EAAC,aAAa,EAAO,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAElF;;GAEG;AACH,MAAM,IAAI,GAAG,GAAG,EAAE;IACd,sBAAsB;AAC1B,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAW,EAAC,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM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AED,SAAS,gBAAgB,CAAC,aAAyB;QAC/C,aAAa,CAAC,SAAS,CAAC,EAAE;YACtB,KAAI,MAAM,OAAO,IAAI,6BAA6B,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;gBAClE,OAAO,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;YACrC,CAAC;YACD,OAAO,aAAa,CAAA;QACxB,CAAC,CAAC,CAAA;IACN,CAAC;IAED,SAAS,kCAAkC,CAAC,OAAmC;QAC3E,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,EAAE,CAAA;QACrC,6BAA6B,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;QAC7D,OAAO,SAAS,CAAA;IACpB,CAAC;IAED,SAAS,oCAAoC,CAAC,SAAiB;QAC3D,OAAO,6BAA6B,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;IAClE,CAAC;IAED,OAAO,KAAC,qBAAqB,CAAC,QAAQ,IAClC,KAAK,EAAE;YACH,cAAc,EAAE,UAAU;YAC1B,MAAM;YACN,gBAAgB;YAChB,6DAA6D;YAC7D,kCAAkC;YAClC,oCAAoC;SACvC,YAEA,QAAQ,GACoB,CAAA;AACrC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB;IAC7B,MAAM,OAAO,GAAG,UAAU,CAA0B,qBAAqB,CAAC,CAAA;IAC1E,MAAM,EAAC,cAAc,EAAC,GAAG,OAAO,CAAA;IAChC,IAAI,cAAc,KAAK,SAAS,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,mFAAmF,CAAC,CAAA;IACxG,CAAC;IACD,OAAO,OAAO,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Series } from "../plots/plot";
|
|
2
|
+
import { TooltipDimensions } from "../tooltips/tooltipUtils";
|
|
3
|
+
import { JSX } from "react";
|
|
4
|
+
/**
|
|
5
|
+
* Base interface for tooltip data that is passed through to the tooltip content provider
|
|
6
|
+
*/
|
|
7
|
+
export interface TooltipData<D, M> {
|
|
8
|
+
series: Series<D>;
|
|
9
|
+
metadata: M;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A higher-order function that returns a function that provides the tooltip content or
|
|
13
|
+
* `undefined` if no tooltip content is available.
|
|
14
|
+
* @return The tooltip content, or `undefined` if no tooltip content is available.
|
|
15
|
+
* @param seriesName The name of the series for which the tooltip content is being provided
|
|
16
|
+
* @param time The time (x-value) for which the tooltip content is being provided
|
|
17
|
+
* @param tooltipData The tooltip data
|
|
18
|
+
* @param mouseCoords The mouse coordinates over which the mouse is hovering
|
|
19
|
+
* @param providerId An optional ID of the tooltip content provider.
|
|
20
|
+
*/
|
|
21
|
+
type TooltipContentProvider<D, M> = (seriesName: string, time: number, tooltipData: TooltipData<D, M>, mouseCoords: [x: number, y: number], providerId?: string) => TooltipDimensions;
|
|
22
|
+
/**
|
|
23
|
+
* The functions and values exposed through the {@link useTooltip} react hook
|
|
24
|
+
*/
|
|
25
|
+
export type UseTooltipValues<D, M> = {
|
|
26
|
+
/**
|
|
27
|
+
* Registers the provider of the tooltip content (generally the plot will register this).
|
|
28
|
+
* When this function is called again, overwrites the previously registered provider with the
|
|
29
|
+
* one specified. This function can be called repeatedly.
|
|
30
|
+
* @param provider The function that provides the content when called.
|
|
31
|
+
*/
|
|
32
|
+
registerTooltipContentProvider: (provider: TooltipContentProvider<D, M>) => void;
|
|
33
|
+
/**
|
|
34
|
+
* @return The registered function that provides the tooltip content. If no function has been
|
|
35
|
+
* registered, then returns `undefined`.
|
|
36
|
+
*/
|
|
37
|
+
tooltipContentProvider: () => (TooltipContentProvider<D, M> | undefined);
|
|
38
|
+
setVisibilityState: (visible: boolean) => void;
|
|
39
|
+
visibilityState: boolean;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The default values for the {@link UseTooltipValues}
|
|
43
|
+
*/
|
|
44
|
+
export declare const defaultTooltipValues: () => UseTooltipValues<any, any>;
|
|
45
|
+
type Props = {
|
|
46
|
+
children: JSX.Element | Array<JSX.Element>;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* The tooltip context provider allows registering and retrieving tooltip content providers. When
|
|
50
|
+
* a tooltip content provider is registered with a provider ID, then it must be retrieved with that
|
|
51
|
+
* same provider ID. This allows a chart to have multiple tooltip content providers, depending on
|
|
52
|
+
* the context or types of objects being moused over. When a tooltip content provider is registered
|
|
53
|
+
* without a provider ID, then the default provider ID is used.
|
|
54
|
+
* @param props The properties holding the children
|
|
55
|
+
* @constructor
|
|
56
|
+
* @return A JSX element containing the children
|
|
57
|
+
*/
|
|
58
|
+
export default function TooltipProvider<D, M>(props: Props): JSX.Element;
|
|
59
|
+
/**
|
|
60
|
+
* React hook that sets up the React context for the mouse values.
|
|
61
|
+
* @return The {@link UseTooltipValues} held in the React context.
|
|
62
|
+
*/
|
|
63
|
+
export declare function useTooltip<D, M>(): UseTooltipValues<D, M>;
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useRef } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* No operation function for use when a default function is needed
|
|
5
|
+
*/
|
|
6
|
+
const noop = () => {
|
|
7
|
+
/* empty on purpose */
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The default values for the {@link UseTooltipValues}
|
|
11
|
+
*/
|
|
12
|
+
export const defaultTooltipValues = () => ({
|
|
13
|
+
registerTooltipContentProvider: noop,
|
|
14
|
+
tooltipContentProvider: () => undefined,
|
|
15
|
+
setVisibilityState: noop,
|
|
16
|
+
visibilityState: false,
|
|
17
|
+
});
|
|
18
|
+
const TooltipContext = createContext(defaultTooltipValues());
|
|
19
|
+
/**
|
|
20
|
+
* The tooltip context provider allows registering and retrieving tooltip content providers. When
|
|
21
|
+
* a tooltip content provider is registered with a provider ID, then it must be retrieved with that
|
|
22
|
+
* same provider ID. This allows a chart to have multiple tooltip content providers, depending on
|
|
23
|
+
* the context or types of objects being moused over. When a tooltip content provider is registered
|
|
24
|
+
* without a provider ID, then the default provider ID is used.
|
|
25
|
+
* @param props The properties holding the children
|
|
26
|
+
* @constructor
|
|
27
|
+
* @return A JSX element containing the children
|
|
28
|
+
*/
|
|
29
|
+
export default function TooltipProvider(props) {
|
|
30
|
+
const { children } = props;
|
|
31
|
+
const tooltipContentProviderRef = useRef(undefined);
|
|
32
|
+
const visibilityStateRef = useRef(false);
|
|
33
|
+
return _jsx(TooltipContext.Provider, { value: {
|
|
34
|
+
registerTooltipContentProvider: provider => tooltipContentProviderRef.current = provider,
|
|
35
|
+
tooltipContentProvider: () => tooltipContentProviderRef.current,
|
|
36
|
+
setVisibilityState: (visible) => visibilityStateRef.current = visible,
|
|
37
|
+
visibilityState: visibilityStateRef.current
|
|
38
|
+
}, children: children });
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* React hook that sets up the React context for the mouse values.
|
|
42
|
+
* @return The {@link UseTooltipValues} held in the React context.
|
|
43
|
+
*/
|
|
44
|
+
export function useTooltip() {
|
|
45
|
+
const context = useContext(TooltipContext);
|
|
46
|
+
const { registerTooltipContentProvider } = context;
|
|
47
|
+
if (registerTooltipContentProvider === undefined || registerTooltipContentProvider === null) {
|
|
48
|
+
throw new Error("useTooltip can only be used when the parent is a <TooltipProvider/>");
|
|
49
|
+
}
|
|
50
|
+
return context;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=useTooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTooltip.js","sourceRoot":"","sources":["../../../../../src/app/charts/hooks/useTooltip.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAC,aAAa,EAAO,UAAU,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAE7D;;GAEG;AACH,MAAM,IAAI,GAAG,GAAG,E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|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intended base interface for chart data. All chart data need to hold
|
|
3
|
+
* a {@link Set} of series names.
|
|
4
|
+
* @see TimeSeriesChartData
|
|
5
|
+
* @see IterateChartData
|
|
6
|
+
* @see OrdinalChartData
|
|
7
|
+
*/
|
|
8
|
+
export interface ChartData {
|
|
9
|
+
seriesNames: Set<string>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @return A default {@link ChartData} object with an empty set of series
|
|
13
|
+
* names
|
|
14
|
+
*/
|
|
15
|
+
export declare function defaultChartData(): ChartData;
|
|
16
|
+
/**
|
|
17
|
+
* Creates and returns a deep copy of the {@link ChartData}
|
|
18
|
+
* @param data The chart data to copy
|
|
19
|
+
* @return A deep copy of the chart data
|
|
20
|
+
*/
|
|
21
|
+
export declare function copyChartData(data: ChartData): {
|
|
22
|
+
seriesNames: Set<string>;
|
|
23
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @return A default {@link ChartData} object with an empty set of series
|
|
3
|
+
* names
|
|
4
|
+
*/
|
|
5
|
+
export function defaultChartData() {
|
|
6
|
+
return {
|
|
7
|
+
seriesNames: new Set()
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Creates and returns a deep copy of the {@link ChartData}
|
|
12
|
+
* @param data The chart data to copy
|
|
13
|
+
* @return A deep copy of the chart data
|
|
14
|
+
*/
|
|
15
|
+
export function copyChartData(data) {
|
|
16
|
+
return {
|
|
17
|
+
seriesNames: new Set(data.seriesNames.values()),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=ChartData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartData.js","sourceRoot":"","sources":["../../../../../src/app/charts/observables/ChartData.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC5B,OAAO;QACH,WAAW,EAAE,IAAI,GAAG,EAAU;KACjC,CAAA;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,IAAe;IACzC,OAAO;QACH,WAAW,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;KAClD,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for plotting function iterates. For example suppose that f[1](x) = f(x), f[2](x) = f(f(x)),
|
|
3
|
+
* f[3](x) = f(f(f(x))), and f[m](x) = f(f(f....(x))), where the function is applied m times. Given this,
|
|
4
|
+
* then an iterate (Poincare) plot shows points (f[m](x), f[m+1](x)), which is a 1-iterate. Plots of
|
|
5
|
+
* points (f[m](x), f[m+n](x)) are n-iterates.
|
|
6
|
+
*
|
|
7
|
+
* 1. Convert series to chart data observable in the usual way
|
|
8
|
+
* 2. Accepts that chart-data observable and converts that observable to an iterate-chart-data observable
|
|
9
|
+
*/
|
|
10
|
+
import { Observable } from "rxjs";
|
|
11
|
+
import { TimeSeriesChartData } from "../series/timeSeriesChartData";
|
|
12
|
+
import { IterateDatum } from "../series/iterateSeries";
|
|
13
|
+
import { ChartData } from "./ChartData";
|
|
14
|
+
export interface IterateChartData extends ChartData {
|
|
15
|
+
/**
|
|
16
|
+
* The min values for (time, iterate n, and iterate n+1) for the data in the newPoints map
|
|
17
|
+
*/
|
|
18
|
+
minIterate: IterateDatum;
|
|
19
|
+
/**
|
|
20
|
+
* The max values for (time, iterate n, and iterate n+1) for the data in the newPoints map
|
|
21
|
+
*/
|
|
22
|
+
maxIterate: IterateDatum;
|
|
23
|
+
/**
|
|
24
|
+
* Holds the association of the series name to the current min time for that series
|
|
25
|
+
*/
|
|
26
|
+
minIterates: Map<string, IterateDatum>;
|
|
27
|
+
/**
|
|
28
|
+
* Holds the association of the series name to the current max time for that series
|
|
29
|
+
*/
|
|
30
|
+
maxIterates: Map<string, IterateDatum>;
|
|
31
|
+
/**
|
|
32
|
+
* Map holding the name of the series (the time-series identifier) and the associated
|
|
33
|
+
* data points for that time-series (`map(series_name -> array(datum))`)
|
|
34
|
+
*/
|
|
35
|
+
newPoints: Map<string, Array<IterateDatum>>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Makes a deep copy of the iterate chart data
|
|
39
|
+
* @param data The iterate chart data to copy
|
|
40
|
+
*/
|
|
41
|
+
export declare const copyIterateDataFrom: (data: IterateChartData) => IterateChartData;
|
|
42
|
+
/**
|
|
43
|
+
* Accepts a {@link TimeSeriesChartData} observable and converts it to an observable of {@link IterateChartData}
|
|
44
|
+
* for the specified n-iterate. suppose that `f[0](x) = x`, `f[1](x) = f(x)`, `f[2](x) = f(f(x))`,
|
|
45
|
+
* `f[3](x) = f(f(f(x)))`, and `f[m](x) = f(f(f....(x)))`, where the function is applied `m` times. Given this,
|
|
46
|
+
* then an iterate (Poincare) plot shows points `(f[m](x), f[m+1](x))`, which is a 1-iterate. Plots of
|
|
47
|
+
* points `(f[m](x), f[m+n](x))` are n-iterates.
|
|
48
|
+
* @param dataObservable The observable over {@link TimeSeriesChartData}
|
|
49
|
+
* @param [n=1] The iterate distance
|
|
50
|
+
* @return An over {@link IterateChartData} holding the n-iterate for the incoming chart data
|
|
51
|
+
*/
|
|
52
|
+
export declare function iteratesObservable(dataObservable: Observable<TimeSeriesChartData>, n?: number): Observable<IterateChartData>;
|