stream-charts 1.0.0 → 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 +758 -345
- package/changes.md +10 -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} +17 -11
- package/dist/src/app/charts/{tooltipUtils.js → tooltips/tooltipUtils.js} +52 -25
- 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
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
13
2
|
import { cloneElement, useEffect, useMemo } from "react";
|
|
14
3
|
import { defaultTooltipStyle, removeTooltip } from "./tooltipUtils";
|
|
15
4
|
import * as d3 from "d3";
|
|
16
|
-
import { useChart } from "
|
|
5
|
+
import { useChart } from "../hooks/useChart";
|
|
6
|
+
import { usePlotDimensions } from "../hooks/usePlotDimensions";
|
|
17
7
|
/**
|
|
18
8
|
* Tooltip component triggered by mouse-over-series events. When mounted, the tooltip component
|
|
19
9
|
* registers a mouse-over handler with the {@link useChart} hook using the
|
|
@@ -49,22 +39,27 @@ import { useChart } from "./hooks/useChart";
|
|
|
49
39
|
* @constructor
|
|
50
40
|
*/
|
|
51
41
|
export function Tooltip(props) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
42
|
+
const { chartId, container, tooltip, mouse } = useChart();
|
|
43
|
+
const { tooltipContentProvider, setVisibilityState, } = tooltip;
|
|
44
|
+
const { margin, plotDimensions } = usePlotDimensions();
|
|
45
|
+
const { visible, style, children } = props;
|
|
46
|
+
const { registerMouseOverHandler, unregisterMouseOverHandler, registerMouseLeaveHandler, unregisterMouseLeaveHandler } = mouse;
|
|
47
|
+
const tooltipStyle = useMemo(() => (Object.assign(Object.assign({}, defaultTooltipStyle), style)), [style]);
|
|
48
|
+
// let the tooltip context know whether the tooltip is visible
|
|
49
|
+
setVisibilityState(visible);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
const handlerId = `tooltip-${chartId}`;
|
|
57
52
|
if (visible && container) {
|
|
58
|
-
|
|
59
|
-
if (
|
|
53
|
+
const contentProvider = tooltipContentProvider();
|
|
54
|
+
if (contentProvider) {
|
|
60
55
|
// register this tooltip's mouse-over event handler with the useCharts hook
|
|
61
56
|
// so that the plots can call it when mouse-enter events are triggered (for
|
|
62
57
|
// example, a mouse-over a time-series in the plot).
|
|
63
|
-
registerMouseOverHandler(handlerId, (
|
|
58
|
+
registerMouseOverHandler(handlerId, ((seriesName, time, tooltipData, mouseCoords, providerId) => {
|
|
64
59
|
// create the rounded rectangle for the tooltip's background
|
|
65
|
-
|
|
60
|
+
const rect = d3.select(container)
|
|
66
61
|
.append('rect')
|
|
67
|
-
.attr('id',
|
|
62
|
+
.attr('id', `r${time}-${seriesName}-${chartId}`)
|
|
68
63
|
.attr('class', 'tooltip')
|
|
69
64
|
.attr('rx', tooltipStyle.borderRadius)
|
|
70
65
|
.attr('fill', tooltipStyle.backgroundColor)
|
|
@@ -72,17 +67,17 @@ export function Tooltip(props) {
|
|
|
72
67
|
.attr('stroke', tooltipStyle.borderColor)
|
|
73
68
|
.attr('stroke-width', tooltipStyle.borderWidth);
|
|
74
69
|
// call the callback to add the content
|
|
75
|
-
|
|
70
|
+
const { x, y, contentWidth, contentHeight } = contentProvider(seriesName, time, tooltipData, mouseCoords, providerId);
|
|
76
71
|
// set the position, width, and height of the tooltip rect based on the text height and width and the padding
|
|
77
|
-
rect.attr('x',
|
|
78
|
-
.attr('y',
|
|
72
|
+
rect.attr('x', () => x)
|
|
73
|
+
.attr('y', () => y)
|
|
79
74
|
.attr('width', contentWidth + tooltipStyle.paddingLeft + tooltipStyle.paddingRight)
|
|
80
75
|
.attr('height', contentHeight + tooltipStyle.paddingTop + tooltipStyle.paddingBottom);
|
|
81
76
|
}));
|
|
82
|
-
registerMouseLeaveHandler(handlerId,
|
|
77
|
+
registerMouseLeaveHandler(handlerId, () => removeTooltip());
|
|
83
78
|
}
|
|
84
79
|
}
|
|
85
|
-
return
|
|
80
|
+
return () => {
|
|
86
81
|
unregisterMouseOverHandler(handlerId);
|
|
87
82
|
unregisterMouseLeaveHandler(handlerId);
|
|
88
83
|
};
|
|
@@ -92,6 +87,6 @@ export function Tooltip(props) {
|
|
|
92
87
|
unregisterMouseOverHandler, visible, registerMouseLeaveHandler,
|
|
93
88
|
unregisterMouseLeaveHandler
|
|
94
89
|
]);
|
|
95
|
-
return _jsx(_Fragment, { children: cloneElement(children, props) }
|
|
90
|
+
return _jsx(_Fragment, { children: cloneElement(children, props) });
|
|
96
91
|
}
|
|
97
92
|
//# sourceMappingURL=Tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../../../src/app/charts/tooltips/Tooltip.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,YAAY,EAAE,SAAS,EAAE,OAAO,EAAM,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAC,mBAAmB,EAAE,aAAa,EAAe,MAAM,gBA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QACI,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc;QAC1C,wBAAwB,EAAE,sBAAsB,EAAE,YAAY;QAC9D,0BAA0B,EAAE,OAAO,EAAE,yBAAyB;QAC9D,2BAA2B;KAC9B,CACJ,CAAA;IAED,OAAO,4BAAG,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAI,CAAA;AAC/C,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Dimensions, Margin } from "
|
|
3
|
-
import {
|
|
1
|
+
import { Series } from "../plots/plot";
|
|
2
|
+
import { Dimensions, Margin } from "../styling/margins";
|
|
3
|
+
import { OrdinalStringAxis } from "../axes/axes";
|
|
4
4
|
/**
|
|
5
5
|
* Properties for rendering the tooltip. This is the style for the container
|
|
6
6
|
* of the content.
|
|
@@ -32,6 +32,7 @@ export interface TooltipStyle {
|
|
|
32
32
|
backgroundColor: string;
|
|
33
33
|
backgroundOpacity: number;
|
|
34
34
|
borderColor: string;
|
|
35
|
+
borderOpacity: number;
|
|
35
36
|
borderWidth: number;
|
|
36
37
|
borderRadius: number;
|
|
37
38
|
paddingLeft: number;
|
|
@@ -51,7 +52,7 @@ export interface TooltipDimensions {
|
|
|
51
52
|
*/
|
|
52
53
|
export declare function removeTooltip(): void;
|
|
53
54
|
/**
|
|
54
|
-
* Calculates the x-coordinate of the
|
|
55
|
+
* Calculates the x-coordinate of the upper left-hand side of the tooltip rectangle (obviously without
|
|
55
56
|
* "rounded corners"). Adjusts the x-coordinate so that tooltip is visible on the edges of the plot.
|
|
56
57
|
* @param x The current x-coordinate of the mouse
|
|
57
58
|
* @param textWidth The width of the tooltip text
|
|
@@ -62,9 +63,9 @@ export declare function removeTooltip(): void;
|
|
|
62
63
|
*/
|
|
63
64
|
export declare function tooltipX(x: number, textWidth: number, plotDimensions: Dimensions, tooltipStyle: TooltipStyle, margin: Margin): number;
|
|
64
65
|
/**
|
|
65
|
-
* Calculates the y-coordinate of the
|
|
66
|
+
* Calculates the y-coordinate of the upper-left-hand corner of the tooltip rectangle. Adjusts the y-coordinate
|
|
66
67
|
* so that the tooltip is visible on the upper edge of the plot
|
|
67
|
-
* @param y The y-coordinate of the
|
|
68
|
+
* @param y The y-coordinate of the mouse
|
|
68
69
|
* @param textHeight The height of the header and neuron ID text
|
|
69
70
|
* @param plotDimensions The dimensions of the plot
|
|
70
71
|
* @param tooltipStyle The tooltip style information
|
|
@@ -73,23 +74,28 @@ export declare function tooltipX(x: number, textWidth: number, plotDimensions: D
|
|
|
73
74
|
*/
|
|
74
75
|
export declare function tooltipY(y: number, textHeight: number, plotDimensions: Dimensions, tooltipStyle: TooltipStyle, margin: Margin): number;
|
|
75
76
|
/**
|
|
76
|
-
* Calculates the y-coordinate
|
|
77
|
-
*
|
|
77
|
+
* Calculates the y-coordinate for the upper-left-hand the tooltip rectangle. Adjusts the y-coordinate so
|
|
78
|
+
* that the tooltip is visible on the upper and lower edges of the plot
|
|
78
79
|
* @param seriesName The name of the series
|
|
79
80
|
* @param textHeight The height of the header and neuron ID text
|
|
80
81
|
* @param axis The category axis for determining the y-value of the tooltip
|
|
81
82
|
* @param tooltipStyle The tooltip style
|
|
82
83
|
* @param margin The plot margin
|
|
83
84
|
* @param categoryHeight The height (in pixels) of the category
|
|
85
|
+
* @param plotDimensions The dimensions of the plot
|
|
84
86
|
* @return The y-coordinate of the lower-left-hand corner of the tooltip rectangle
|
|
85
87
|
*/
|
|
86
|
-
export declare function categoryTooltipY(seriesName: string, textHeight: number, axis:
|
|
88
|
+
export declare function categoryTooltipY(seriesName: string, textHeight: number, axis: OrdinalStringAxis, tooltipStyle: TooltipStyle, margin: Margin, categoryHeight: number, plotDimensions: Dimensions): number;
|
|
87
89
|
/**
|
|
88
90
|
* Returns the (time, value) point that comes just before the mouse and just after the mouse
|
|
89
91
|
* @param data The time-series data
|
|
90
|
-
* @param
|
|
92
|
+
* @param value The time represented by the mouse's x-coordinate
|
|
93
|
+
* @param xFrom A function that extracts the x-value from the datum
|
|
94
|
+
* @param emptyDatum A function that returns an empty datum
|
|
95
|
+
* @template D The type of the datum in the data-series
|
|
91
96
|
* @return {[[number, number], [number, number]]} the (time, value) point that comes just before
|
|
92
97
|
* the mouse and just after the mouse. If the mouse is after the last point, then the "after" point
|
|
93
98
|
* is `[NaN, NaN]`. If the mouse is before the first point, then the "before" point is `[NaN, NaN]`.
|
|
94
99
|
*/
|
|
95
|
-
export declare function boundingPoints(data:
|
|
100
|
+
export declare function boundingPoints<D>(data: Series<D>, value: number, xFrom: (value: D) => number, emptyDatum: () => D): [D, D];
|
|
101
|
+
export declare function findPointAndNeighbors<D>(data: Series<D>, value: number, tolerance: number, xFrom: (value: D) => number, emptyDatum: () => D): [D, D, D, number];
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import * as d3 from "d3";
|
|
2
|
-
export
|
|
2
|
+
export const defaultTooltipStyle = {
|
|
3
3
|
visible: false,
|
|
4
4
|
fontSize: 12,
|
|
5
|
-
fontColor: '
|
|
5
|
+
fontColor: 'rgba(10,31,58,0.99)',
|
|
6
|
+
// fontColor: '#d2933f',
|
|
7
|
+
// fontColor: '#202020',
|
|
6
8
|
fontFamily: 'sans-serif',
|
|
7
9
|
fontWeight: 250,
|
|
8
10
|
backgroundColor: '#202020',
|
|
9
11
|
backgroundOpacity: 0.8,
|
|
10
12
|
borderColor: '#d2933f',
|
|
13
|
+
borderOpacity: 1,
|
|
11
14
|
borderWidth: 1,
|
|
12
15
|
borderRadius: 5,
|
|
13
16
|
paddingLeft: 10,
|
|
@@ -22,7 +25,7 @@ export function removeTooltip() {
|
|
|
22
25
|
d3.selectAll('.tooltip').remove();
|
|
23
26
|
}
|
|
24
27
|
/**
|
|
25
|
-
* Calculates the x-coordinate of the
|
|
28
|
+
* Calculates the x-coordinate of the upper left-hand side of the tooltip rectangle (obviously without
|
|
26
29
|
* "rounded corners"). Adjusts the x-coordinate so that tooltip is visible on the edges of the plot.
|
|
27
30
|
* @param x The current x-coordinate of the mouse
|
|
28
31
|
* @param textWidth The width of the tooltip text
|
|
@@ -32,15 +35,15 @@ export function removeTooltip() {
|
|
|
32
35
|
* @return The x-coordinate of the lower left-hand side of the tooltip rectangle
|
|
33
36
|
*/
|
|
34
37
|
export function tooltipX(x, textWidth, plotDimensions, tooltipStyle, margin) {
|
|
35
|
-
if (x
|
|
38
|
+
if (x > plotDimensions.width + margin.left - (textWidth + tooltipStyle.paddingLeft + tooltipStyle.paddingRight)) {
|
|
36
39
|
return x - textWidth - margin.right + tooltipStyle.paddingRight + tooltipStyle.paddingLeft;
|
|
37
40
|
}
|
|
38
41
|
return x + tooltipStyle.paddingLeft;
|
|
39
42
|
}
|
|
40
43
|
/**
|
|
41
|
-
* Calculates the y-coordinate of the
|
|
44
|
+
* Calculates the y-coordinate of the upper-left-hand corner of the tooltip rectangle. Adjusts the y-coordinate
|
|
42
45
|
* so that the tooltip is visible on the upper edge of the plot
|
|
43
|
-
* @param y The y-coordinate of the
|
|
46
|
+
* @param y The y-coordinate of the mouse
|
|
44
47
|
* @param textHeight The height of the header and neuron ID text
|
|
45
48
|
* @param plotDimensions The dimensions of the plot
|
|
46
49
|
* @param tooltipStyle The tooltip style information
|
|
@@ -48,22 +51,33 @@ export function tooltipX(x, textWidth, plotDimensions, tooltipStyle, margin) {
|
|
|
48
51
|
* @return The y-coordinate of the lower-left-hand corner of the tooltip rectangle
|
|
49
52
|
*/
|
|
50
53
|
export function tooltipY(y, textHeight, plotDimensions, tooltipStyle, margin) {
|
|
51
|
-
|
|
54
|
+
if (y > plotDimensions.height + margin.top - (textHeight + tooltipStyle.paddingTop + tooltipStyle.paddingBottom)) {
|
|
55
|
+
return plotDimensions.height + margin.top - (textHeight + tooltipStyle.paddingTop + tooltipStyle.paddingBottom);
|
|
56
|
+
}
|
|
57
|
+
return y + tooltipStyle.paddingTop;
|
|
52
58
|
}
|
|
53
59
|
/**
|
|
54
|
-
* Calculates the y-coordinate
|
|
55
|
-
*
|
|
60
|
+
* Calculates the y-coordinate for the upper-left-hand the tooltip rectangle. Adjusts the y-coordinate so
|
|
61
|
+
* that the tooltip is visible on the upper and lower edges of the plot
|
|
56
62
|
* @param seriesName The name of the series
|
|
57
63
|
* @param textHeight The height of the header and neuron ID text
|
|
58
64
|
* @param axis The category axis for determining the y-value of the tooltip
|
|
59
65
|
* @param tooltipStyle The tooltip style
|
|
60
66
|
* @param margin The plot margin
|
|
61
67
|
* @param categoryHeight The height (in pixels) of the category
|
|
68
|
+
* @param plotDimensions The dimensions of the plot
|
|
62
69
|
* @return The y-coordinate of the lower-left-hand corner of the tooltip rectangle
|
|
63
70
|
*/
|
|
64
|
-
export function categoryTooltipY(seriesName, textHeight, axis, tooltipStyle, margin, categoryHeight) {
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
export function categoryTooltipY(seriesName, textHeight, axis, tooltipStyle, margin, categoryHeight, plotDimensions) {
|
|
72
|
+
const y = axis.scale(seriesName) || 0;
|
|
73
|
+
const halfHeight = (tooltipStyle.paddingBottom + textHeight + tooltipStyle.paddingTop) / 2;
|
|
74
|
+
if (y < halfHeight) {
|
|
75
|
+
return margin.top;
|
|
76
|
+
}
|
|
77
|
+
if (y > plotDimensions.height + margin.top - halfHeight) {
|
|
78
|
+
return plotDimensions.height + margin.top - textHeight;
|
|
79
|
+
}
|
|
80
|
+
return y + margin.top - halfHeight + categoryHeight / 2;
|
|
67
81
|
}
|
|
68
82
|
/**
|
|
69
83
|
* Returns the index of the data point whose time is the upper boundary on the specified
|
|
@@ -72,38 +86,51 @@ export function categoryTooltipY(seriesName, textHeight, axis, tooltipStyle, mar
|
|
|
72
86
|
* the specified array, then returns -1.
|
|
73
87
|
* @param data The array of points from which to select the
|
|
74
88
|
* boundary.
|
|
75
|
-
* @param
|
|
89
|
+
* @param value The time for which to find the bounding points
|
|
90
|
+
* @param xFrom A function that extracts the x-value from the datum
|
|
91
|
+
* @template D The type of the datum in the data-series
|
|
76
92
|
* @return The index of the upper boundary.
|
|
77
93
|
*/
|
|
78
|
-
function boundingPointsIndex(data,
|
|
79
|
-
|
|
80
|
-
if (
|
|
94
|
+
function boundingPointsIndex(data, value, xFrom) {
|
|
95
|
+
const length = data.length;
|
|
96
|
+
if (value > xFrom(data[length - 1])) {
|
|
81
97
|
return length;
|
|
82
98
|
}
|
|
83
|
-
if (
|
|
99
|
+
if (value < xFrom(data[0])) {
|
|
84
100
|
return 0;
|
|
85
101
|
}
|
|
86
|
-
return data.findIndex(
|
|
87
|
-
|
|
88
|
-
return array[lowerIndex]
|
|
102
|
+
return data.findIndex((_, index, array) => {
|
|
103
|
+
const lowerIndex = Math.max(0, index - 1);
|
|
104
|
+
return xFrom(array[lowerIndex]) <= value && value <= xFrom(array[index]);
|
|
89
105
|
});
|
|
90
106
|
}
|
|
91
107
|
/**
|
|
92
108
|
* Returns the (time, value) point that comes just before the mouse and just after the mouse
|
|
93
109
|
* @param data The time-series data
|
|
94
|
-
* @param
|
|
110
|
+
* @param value The time represented by the mouse's x-coordinate
|
|
111
|
+
* @param xFrom A function that extracts the x-value from the datum
|
|
112
|
+
* @param emptyDatum A function that returns an empty datum
|
|
113
|
+
* @template D The type of the datum in the data-series
|
|
95
114
|
* @return {[[number, number], [number, number]]} the (time, value) point that comes just before
|
|
96
115
|
* the mouse and just after the mouse. If the mouse is after the last point, then the "after" point
|
|
97
116
|
* is `[NaN, NaN]`. If the mouse is before the first point, then the "before" point is `[NaN, NaN]`.
|
|
98
117
|
*/
|
|
99
|
-
export function boundingPoints(data,
|
|
100
|
-
|
|
118
|
+
export function boundingPoints(data, value, xFrom, emptyDatum) {
|
|
119
|
+
const upperIndex = boundingPointsIndex(data, value, xFrom);
|
|
101
120
|
if (upperIndex <= 0) {
|
|
102
|
-
return [
|
|
121
|
+
return [emptyDatum(), data[0]];
|
|
103
122
|
}
|
|
104
123
|
if (upperIndex >= data.length) {
|
|
105
|
-
return [data[data.length - 1],
|
|
124
|
+
return [data[data.length - 1], emptyDatum()];
|
|
106
125
|
}
|
|
107
126
|
return [data[upperIndex - 1], data[upperIndex]];
|
|
108
127
|
}
|
|
128
|
+
export function findPointAndNeighbors(data, value, tolerance, xFrom, emptyDatum) {
|
|
129
|
+
// find the index of the point
|
|
130
|
+
const index = data.findIndex((_, index, array) => Math.abs(xFrom(array[index]) - value) <= tolerance);
|
|
131
|
+
const point = index > -1 ? data[index] : emptyDatum();
|
|
132
|
+
const lower = (index > 0) ? data[index - 1] : emptyDatum();
|
|
133
|
+
const upper = (index < data.length - 1) ? data[index + 1] : emptyDatum();
|
|
134
|
+
return [lower, point, upper, index];
|
|
135
|
+
}
|
|
109
136
|
//# sourceMappingURL=tooltipUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltipUtils.js","sourceRoot":"","sources":["../../../../../src/app/charts/tooltips/tooltipUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAiDzB,MAAM,CAAC,MAAM,mBAAmB,GAAiB;IAC7C,OAAO,EAAE,KAAK;IAEd,QAAQ,EAAE,EAAE;IACZ,SAAS,EAAE,qBAAqB;IAChC,wBAAwB;IACxB,wBAAwB;IACxB,UAAU,EAAE,YAAY;IACxB,UAAU,EAAE,GAAG;IAEf,eAAe,EAAE,SAAS;IAC1B,iBAAiB,EAAE,GAAG;IAEtB,WAAW,EAAE,SAAS;IACtB,aAAa,EAAE,CAAC;IAChB,WAAW,EAAE,CAAC;IACd,YAAY,EAAE,CAAC;IAEf,WAAW,EAAE,EAAE;IACf,YAAY,EAAE,EAAE;IAChB,UAAU,EAAE,CAAC;IACb,aAAa,EAAE,EAAE;CACpB,CAAC;AASF;;GAEG;AACH,MAAM,UAAU,aAAa;IACzB,EAAE,CAAC,SAAS,CAAwB,UAAU,CAAC,CAAC,MAAM,EAAE,CAAA;AAC5D,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CAAC,CAAS,EAAE,SAAiB,EAAE,cAA0B,EAAE,YAA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Utils";
|
|
2
|
-
import { AxisLocation } from "
|
|
2
|
+
import { AxisLocation } from "../axes/axes";
|
|
3
3
|
export interface TrackerAxisInfo {
|
|
4
4
|
x: number;
|
|
5
5
|
axisLocation: AxisLocation;
|
|
6
6
|
}
|
|
7
|
-
export
|
|
7
|
+
export type TrackerAxisUpdate = Map<string, TrackerAxisInfo>;
|
|
8
8
|
export declare enum TrackerLabelLocation {
|
|
9
9
|
Nowhere = 0,
|
|
10
|
-
|
|
11
|
-
ByAxes = 2
|
|
10
|
+
ByAxis = 1
|
|
12
11
|
}
|
|
13
12
|
interface Props {
|
|
14
13
|
visible: boolean;
|
|
14
|
+
trackerAxis?: AxisLocation;
|
|
15
15
|
labelLocation?: TrackerLabelLocation;
|
|
16
|
+
labelFormatter?: (value: number) => string;
|
|
16
17
|
style?: Partial<TrackerStyle>;
|
|
17
18
|
font?: Partial<TrackerLabelFont>;
|
|
18
19
|
onTrackerUpdate?: (update: TrackerAxisUpdate) => void;
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
21
|
-
* A tracker line that displays or reports the
|
|
22
|
+
* A tracker line that displays or reports the x or y coordinates at the mouse location. The tracker
|
|
22
23
|
* handles single axes and dual axes.
|
|
23
24
|
* @param props The tracker control properties
|
|
24
25
|
* @return null component
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { noop } from "../utils";
|
|
2
|
+
import { useChart } from "../hooks/useChart";
|
|
3
|
+
import { defaultTrackerLabelFont, defaultTrackerStyle, removeTrackerControl, trackerControlInstance } from "./trackerUtils";
|
|
4
|
+
import * as d3 from "d3";
|
|
5
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
6
|
+
import { AxisLocation } from "../axes/axes";
|
|
7
|
+
import { usePlotDimensions } from "../hooks/usePlotDimensions";
|
|
8
|
+
export var TrackerLabelLocation;
|
|
9
|
+
(function (TrackerLabelLocation) {
|
|
10
|
+
TrackerLabelLocation[TrackerLabelLocation["Nowhere"] = 0] = "Nowhere";
|
|
11
|
+
TrackerLabelLocation[TrackerLabelLocation["ByAxis"] = 1] = "ByAxis";
|
|
12
|
+
})(TrackerLabelLocation || (TrackerLabelLocation = {}));
|
|
13
|
+
/**
|
|
14
|
+
* A tracker line that displays or reports the x or y coordinates at the mouse location. The tracker
|
|
15
|
+
* handles single axes and dual axes.
|
|
16
|
+
* @param props The tracker control properties
|
|
17
|
+
* @return null component
|
|
18
|
+
* @constructor
|
|
19
|
+
*/
|
|
20
|
+
export function Tracker(props) {
|
|
21
|
+
const { visible, trackerAxis = AxisLocation.Bottom, labelLocation = TrackerLabelLocation.ByAxis, labelFormatter, style, font, onTrackerUpdate = noop } = props;
|
|
22
|
+
const { chartId, container, axes, backgroundColor } = useChart();
|
|
23
|
+
const { xAxesState, yAxesState } = axes;
|
|
24
|
+
const axisState = (trackerAxis === AxisLocation.Bottom || trackerAxis === AxisLocation.Top) ?
|
|
25
|
+
xAxesState :
|
|
26
|
+
yAxesState;
|
|
27
|
+
const { plotDimensions, margin } = usePlotDimensions();
|
|
28
|
+
const trackerStyle = useMemo(() => (Object.assign(Object.assign({}, defaultTrackerStyle), style)), [style]);
|
|
29
|
+
const trackerFont = useMemo(() => (Object.assign(Object.assign({}, defaultTrackerLabelFont), font)), [font]);
|
|
30
|
+
const trackerRef = useRef(undefined);
|
|
31
|
+
const axisRef = useRef(new Map());
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const axes = new Map();
|
|
34
|
+
axisState.axes.forEach((axis, id) => axes.set(id, axis));
|
|
35
|
+
axisRef.current = axes;
|
|
36
|
+
}, [axisState]);
|
|
37
|
+
// when the container, tracker-control function, or visibility change, then we need to update the
|
|
38
|
+
// tracker control
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (container) {
|
|
41
|
+
const svg = d3.select(container);
|
|
42
|
+
if (visible && container) {
|
|
43
|
+
const trackerLabels = new Map(Array.from(axisRef.current.values()).map(axis => {
|
|
44
|
+
const formatter = labelFormatter !== null && labelFormatter !== void 0 ? labelFormatter : ((value) => labelLocation === TrackerLabelLocation.Nowhere ?
|
|
45
|
+
"" :
|
|
46
|
+
`${d3.format(",.0f")(value)}`);
|
|
47
|
+
return [axis, formatter];
|
|
48
|
+
}));
|
|
49
|
+
trackerRef.current = trackerControlInstance(chartId, container, svg, plotDimensions, margin, trackerStyle, trackerFont, trackerLabels, labelLocation, onTrackerUpdate, trackerAxis, backgroundColor);
|
|
50
|
+
}
|
|
51
|
+
// if the tracker was defined and is now no longer defined (i.e., props changed, then remove the tracker)
|
|
52
|
+
else if (!visible && trackerRef.current !== undefined) {
|
|
53
|
+
removeTrackerControl(svg, trackerAxis);
|
|
54
|
+
trackerRef.current = undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}, [backgroundColor, chartId, container, labelFormatter, labelLocation, margin, onTrackerUpdate, plotDimensions, trackerAxis, trackerFont, trackerStyle, visible]);
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=Tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tracker.js","sourceRoot":"","sources":["../../../../../src/app/charts/trackers/Tracker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EACH,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EAGzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AACjD,OAAO,EAAC,YAAY,EAAkC,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAU7D,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC5B,qEAAO,CAAA;IACP,mEAAM,CAA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AAE,cAAc,EAAE,aAAa,EAAE,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,CAAC,CACjK,CAAA;IAED,OAAO,IAAI,CAAA;AACf,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SvgSelection, TrackerSelection } from "
|
|
2
|
-
import { Dimensions, Margin } from "
|
|
3
|
-
import { ContinuousNumericAxis } from "
|
|
1
|
+
import { SvgSelection, TrackerSelection } from "../d3types";
|
|
2
|
+
import { Dimensions, Margin } from "../styling/margins";
|
|
3
|
+
import { AxisLocation, ContinuousNumericAxis } from "../axes/axes";
|
|
4
4
|
import { TrackerAxisUpdate, TrackerLabelLocation } from "./Tracker";
|
|
5
5
|
export interface TrackerLabelFont {
|
|
6
6
|
size: number;
|
|
@@ -16,7 +16,8 @@ export interface TrackerStyle {
|
|
|
16
16
|
}
|
|
17
17
|
export declare const defaultTrackerStyle: TrackerStyle;
|
|
18
18
|
/**
|
|
19
|
-
* Creates or returns the existing SVG elements for displaying a tracker line
|
|
19
|
+
* Creates or returns the existing SVG elements for displaying a tracker line that is either
|
|
20
|
+
* vertical (for x-axes) or horizontal (for y-axes).
|
|
20
21
|
* @param chartId The ID of the chart
|
|
21
22
|
* @param container The SVG container
|
|
22
23
|
* @param svg The SVG selection
|
|
@@ -26,12 +27,16 @@ export declare const defaultTrackerStyle: TrackerStyle;
|
|
|
26
27
|
* @param labelFont The font used for the axis labels
|
|
27
28
|
* @param label A function that returns the tracker label string for a given x-value
|
|
28
29
|
* @param labelStyle The location style for the tracker (i.e. on the axes, next to the mouse, none shown)
|
|
29
|
-
* @param onTrackerUpdate A callback function
|
|
30
|
+
* @param onTrackerUpdate A callback function that accepts the current tracker's axis information
|
|
31
|
+
* @param [axisLocation = AxisLocation.Bottom] The optional location of the axis for which the tracker is to
|
|
32
|
+
* be shown. Default is bottom.
|
|
33
|
+
* @param backgroundColor The background color of the tracker label
|
|
30
34
|
* @return The tracker selection
|
|
31
35
|
*/
|
|
32
|
-
export declare function trackerControlInstance(chartId: number, container: SVGSVGElement, svg: SvgSelection, plotDimensions: Dimensions, margin: Margin, style: TrackerStyle, labelFont: TrackerLabelFont, label: Map<ContinuousNumericAxis, (x: number) => string>, labelStyle: TrackerLabelLocation, onTrackerUpdate: (update: TrackerAxisUpdate) => void): TrackerSelection;
|
|
36
|
+
export declare function trackerControlInstance(chartId: number, container: SVGSVGElement, svg: SvgSelection, plotDimensions: Dimensions, margin: Margin, style: TrackerStyle, labelFont: TrackerLabelFont, label: Map<ContinuousNumericAxis, (x: number) => string>, labelStyle: TrackerLabelLocation, onTrackerUpdate: (update: TrackerAxisUpdate) => void, axisLocation: AxisLocation | undefined, backgroundColor: string): TrackerSelection;
|
|
33
37
|
/**
|
|
34
38
|
* Removes the tracker control from the chart
|
|
35
|
-
* @param svg The svg selection holding the tracker
|
|
39
|
+
* @param svg The svg selection holding the tracker control
|
|
40
|
+
* @param axisLocation The location of the axis for which the tracker is to be removed.
|
|
36
41
|
*/
|
|
37
|
-
export declare function removeTrackerControl(svg: SvgSelection): void;
|
|
42
|
+
export declare function removeTrackerControl(svg: SvgSelection, axisLocation: AxisLocation): void;
|