@perses-dev/timeseries-chart-plugin 0.14.0-beta.6 → 0.14.0-beta.8

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.
Files changed (77) hide show
  1. package/README.md +11 -0
  2. package/__mf/js/TimeSeriesChart.aa6aa96b.js +7 -0
  3. package/__mf/js/async/{1616.7cf381f0.js → 1616.2ad408f8.js} +1 -1
  4. package/__mf/js/async/2490.7e5650e7.js +2 -0
  5. package/__mf/js/async/{3068.50ed57d5.js → 3068.c95fecc7.js} +9 -9
  6. package/__mf/js/async/{5259.f3284aaa.js → 3441.65e1728a.js} +6 -6
  7. package/__mf/js/async/{392.6343c7ea.js → 392.11188127.js} +2 -2
  8. package/__mf/js/async/{4077.62433b15.js → 4077.cf1d675f.js} +1 -1
  9. package/__mf/js/async/{4121.82a6a52c.js → 4121.2a21582b.js} +2 -2
  10. package/__mf/js/async/{4134.a94fc299.js → 4134.9d3e6a8b.js} +1 -1
  11. package/__mf/js/async/{4496.b0d93933.js → 4496.eb53e477.js} +1 -1
  12. package/__mf/js/async/{4670.8e9fc9b1.js → 4670.b5dafbaa.js} +1 -1
  13. package/__mf/js/async/{5002.0d0c2f26.js → 5002.e3ab6daa.js} +1 -1
  14. package/__mf/js/async/{5071.ef93b262.js → 5071.586de8fa.js} +1 -1
  15. package/__mf/js/async/{5182.ac39e54d.js → 5182.375bbf8e.js} +2 -2
  16. package/__mf/js/async/5394.f1c40599.js +7 -0
  17. package/__mf/js/async/{5587.1f4e28c2.js → 5587.bfa64ec3.js} +1 -1
  18. package/__mf/js/async/{6274.e416bf61.js → 6274.c6a9892d.js} +2 -2
  19. package/__mf/js/async/6625.e3624f20.js +1 -0
  20. package/__mf/js/async/{7151.e70d1dc9.js → 7151.f8879976.js} +1 -1
  21. package/__mf/js/async/{7192.88142d8c.js → 7192.f5f93b5e.js} +1 -1
  22. package/__mf/js/async/{7319.4208aea7.js → 7319.3e3c9686.js} +1 -1
  23. package/__mf/js/async/{7384.fa3f2d0e.js → 7384.4be917ee.js} +1 -1
  24. package/__mf/js/async/{7633.6805cb60.js → 7633.9cb6de7a.js} +2 -2
  25. package/__mf/js/async/{7955.ab1cde16.js → 7955.877daa4d.js} +1 -1
  26. package/__mf/js/async/{7968.f59b65d1.js → 7968.cf8a4d6a.js} +1 -1
  27. package/__mf/js/async/{7978.c2017f6b.js → 7978.67c99e22.js} +1 -1
  28. package/__mf/js/async/{8356.f0faaf86.js → 8356.b7f7e7f3.js} +1 -1
  29. package/__mf/js/async/{8465.a4e88d99.js → 8465.56096f79.js} +1 -1
  30. package/__mf/js/async/{8470.c382605c.js → 8470.f137ffe2.js} +2 -2
  31. package/__mf/js/async/{8724.e0b36d16.js → 8724.0d169bb2.js} +1 -1
  32. package/__mf/js/async/{873.4fec300c.js → 873.b41b449a.js} +1 -1
  33. package/__mf/js/async/{9235.e1b40e38.js → 9235.4831e488.js} +1 -1
  34. package/__mf/js/async/{941.bdba80db.js → 941.76f11ced.js} +2 -2
  35. package/__mf/js/async/{9588.62f5ed3b.js → 9588.883e3395.js} +1 -1
  36. package/__mf/js/async/{9700.3cea5abe.js → 9700.628e2532.js} +1 -1
  37. package/__mf/js/async/__federation_expose_TimeSeriesChart.40d2d053.js +1 -0
  38. package/__mf/js/async/lib-router.4f5ed027.js +2 -0
  39. package/__mf/js/async/{lib-router.aeb226c2.js.LICENSE.txt → lib-router.4f5ed027.js.LICENSE.txt} +3 -3
  40. package/__mf/js/main.7434d87e.js +7 -0
  41. package/lib/TimeSeriesChartBase.d.ts +3 -0
  42. package/lib/TimeSeriesChartBase.d.ts.map +1 -1
  43. package/lib/TimeSeriesChartBase.js +183 -58
  44. package/lib/TimeSeriesChartBase.js.map +1 -1
  45. package/lib/TimeSeriesChartPanel.d.ts +3 -1
  46. package/lib/TimeSeriesChartPanel.d.ts.map +1 -1
  47. package/lib/TimeSeriesChartPanel.js +190 -113
  48. package/lib/TimeSeriesChartPanel.js.map +1 -1
  49. package/lib/test/mock-query-results.d.ts +2 -1
  50. package/lib/test/mock-query-results.d.ts.map +1 -1
  51. package/lib/test/mock-query-results.js +40 -0
  52. package/lib/test/mock-query-results.js.map +1 -1
  53. package/lib/utils/data-transform.d.ts +30 -3
  54. package/lib/utils/data-transform.d.ts.map +1 -1
  55. package/lib/utils/data-transform.js +41 -7
  56. package/lib/utils/data-transform.js.map +1 -1
  57. package/mf-manifest.json +45 -45
  58. package/mf-stats.json +45 -45
  59. package/package.json +5 -5
  60. package/__mf/js/TimeSeriesChart.d4c34278.js +0 -7
  61. package/__mf/js/async/702.f05e4a6a.js +0 -2
  62. package/__mf/js/async/7491.68fb6045.js +0 -1
  63. package/__mf/js/async/8391.3445b0cf.js +0 -7
  64. package/__mf/js/async/__federation_expose_TimeSeriesChart.75ec8151.js +0 -1
  65. package/__mf/js/async/lib-router.aeb226c2.js +0 -2
  66. package/__mf/js/main.d94da6a3.js +0 -7
  67. /package/__mf/css/async/{8391.85c2cbf6.css → 5394.85c2cbf6.css} +0 -0
  68. /package/__mf/js/async/{702.f05e4a6a.js.LICENSE.txt → 2490.7e5650e7.js.LICENSE.txt} +0 -0
  69. /package/__mf/js/async/{3068.50ed57d5.js.LICENSE.txt → 3068.c95fecc7.js.LICENSE.txt} +0 -0
  70. /package/__mf/js/async/{392.6343c7ea.js.LICENSE.txt → 392.11188127.js.LICENSE.txt} +0 -0
  71. /package/__mf/js/async/{4121.82a6a52c.js.LICENSE.txt → 4121.2a21582b.js.LICENSE.txt} +0 -0
  72. /package/__mf/js/async/{5182.ac39e54d.js.LICENSE.txt → 5182.375bbf8e.js.LICENSE.txt} +0 -0
  73. /package/__mf/js/async/{8391.3445b0cf.js.LICENSE.txt → 5394.f1c40599.js.LICENSE.txt} +0 -0
  74. /package/__mf/js/async/{6274.e416bf61.js.LICENSE.txt → 6274.c6a9892d.js.LICENSE.txt} +0 -0
  75. /package/__mf/js/async/{7633.6805cb60.js.LICENSE.txt → 7633.9cb6de7a.js.LICENSE.txt} +0 -0
  76. /package/__mf/js/async/{8470.c382605c.js.LICENSE.txt → 8470.f137ffe2.js.LICENSE.txt} +0 -0
  77. /package/__mf/js/async/{941.bdba80db.js.LICENSE.txt → 941.76f11ced.js.LICENSE.txt} +0 -0
@@ -12,19 +12,22 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
  import { Box } from "@mui/material";
15
- import { clearHighlightedSeries, DEFAULT_PINNED_CROSSHAIR, DEFAULT_TOOLTIP_CONFIG, EChart, enableDataZoom, getClosestTimestamp, getCommonTimeScale, getFormattedAxis, getPointInGrid, restoreChart, TimeChartTooltip, useChartsContext, useTimeZone } from "@perses-dev/components";
16
- import { LineChart as EChartsLineChart, BarChart as EChartsBarChart } from "echarts/charts";
15
+ import { clearHighlightedSeries, DEFAULT_PINNED_CROSSHAIR, DEFAULT_TOOLTIP_CONFIG, EChart, enableDataZoom, ExemplarMetadataTooltip, getClosestTimestamp, getCommonTimeScale, getFormattedAxis, getPointInGrid, restoreChart, TimeChartTooltip, useChartsContext, useTimeZone } from "@perses-dev/components";
16
+ import { LineChart as EChartsLineChart, BarChart as EChartsBarChart, ScatterChart as EChartsScatterChart } from "echarts/charts";
17
17
  import { GridComponent, DatasetComponent, DataZoomComponent, MarkAreaComponent, MarkLineComponent, MarkPointComponent, TitleComponent, ToolboxComponent, TooltipComponent } from "echarts/components";
18
18
  import { use as registerECharts } from "echarts/core";
19
19
  import { CanvasRenderer } from "echarts/renderers";
20
20
  import isEqual from "lodash/isEqual";
21
21
  import merge from "lodash/merge";
22
22
  import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
23
+ import useResizeObserver from "use-resize-observer";
23
24
  import { AnnotationTooltip, buildAnnotationSeries } from "./annotations/AnnotationTooltip.js";
25
+ import { EXEMPLAR_SERIES_ID_PREFIX, EXEMPLAR_SYMBOL_SIZE, getExemplarSeries } from "./utils/data-transform.js";
24
26
  import { createTimezoneAwareAxisFormatter } from "./utils/timezone-formatter.js";
25
27
  registerECharts([
26
28
  EChartsLineChart,
27
29
  EChartsBarChart,
30
+ EChartsScatterChart,
28
31
  GridComponent,
29
32
  DatasetComponent,
30
33
  DataZoomComponent,
@@ -36,7 +39,15 @@ registerECharts([
36
39
  TooltipComponent,
37
40
  CanvasRenderer
38
41
  ]);
39
- export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({ height, data, seriesMapping, annotations, timeScale: timeScaleProp, yAxis, format, seriesFormatMap, grid, isStackedBar = false, tooltipConfig = DEFAULT_TOOLTIP_CONFIG, noDataVariant = 'message', syncGroup, onDataZoom, onDoubleClick, __experimentalEChartsOptionsOverride }, ref) {
42
+ /**
43
+ * Maximum pixel distance from an exemplar marker center for the cursor to count as still
44
+ * hovering it (covers the full diamond bounding box, corners included).
45
+ */ const EXEMPLAR_HOVER_RADIUS = Math.SQRT2 * EXEMPLAR_SYMBOL_SIZE / 2;
46
+ const CHART_SX = {
47
+ width: '100%',
48
+ height: '100%'
49
+ };
50
+ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({ height, data, seriesMapping, exemplars, annotations, timeScale: timeScaleProp, yAxis, format, seriesFormatMap, grid, isStackedBar = false, tooltipConfig = DEFAULT_TOOLTIP_CONFIG, noDataVariant = 'message', syncGroup, onDataZoom, onDoubleClick, __experimentalEChartsOptionsOverride }, ref) {
40
51
  const { chartsTheme, enablePinning, enableSyncGrouping, lastTooltipPinnedCoords, setLastTooltipPinnedCoords } = useChartsContext();
41
52
  const isPinningEnabled = tooltipConfig.enablePinning && enablePinning;
42
53
  const chartRef = useRef();
@@ -47,33 +58,48 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
47
58
  const [startX, setStartX] = useState(0);
48
59
  const [hoveredAnnotation, setHoveredAnnotation] = useState(null);
49
60
  const [pinnedAnnotation, setPinnedAnnotation] = useState(null);
61
+ const [hoveredExemplar, setHoveredExemplar] = useState(null);
62
+ const [pinnedExemplar, setPinnedExemplar] = useState(null);
63
+ const [pinnedExemplarPos, setPinnedExemplarPos] = useState(null);
50
64
  const [pinnedAnnotationPos, setPinnedAnnotationPos] = useState(null);
51
65
  const { timeZone, formatWithUserTimeZone } = useTimeZone();
52
66
  const getTimezoneAwareAxisFormatter = useCallback((rangeMs)=>createTimezoneAwareAxisFormatter(rangeMs, timeZone), [
53
67
  timeZone
54
68
  ]);
55
- let timeScale;
56
- if (timeScaleProp === undefined) {
69
+ const timeScale = useMemo(()=>{
70
+ if (timeScaleProp) return timeScaleProp;
57
71
  const commonTimeScale = getCommonTimeScale(data);
58
- if (commonTimeScale === undefined) {
59
- // set default to past 5 years
60
- const today = new Date();
61
- const pastDate = new Date(today);
62
- pastDate.setFullYear(today.getFullYear() - 5);
63
- const todayMs = today.getTime();
64
- const pastDateMs = pastDate.getTime();
65
- timeScale = {
66
- startMs: pastDateMs,
67
- endMs: todayMs,
68
- stepMs: 1,
69
- rangeMs: todayMs - pastDateMs
70
- };
71
- } else {
72
- timeScale = commonTimeScale;
72
+ if (commonTimeScale) return commonTimeScale;
73
+ // Set the empty chart's default range to the past five years.
74
+ const today = new Date();
75
+ const pastDate = new Date(today);
76
+ pastDate.setFullYear(today.getFullYear() - 5);
77
+ const startMs = pastDate.getTime();
78
+ const endMs = today.getTime();
79
+ return {
80
+ startMs,
81
+ endMs,
82
+ stepMs: 1,
83
+ rangeMs: endMs - startMs
84
+ };
85
+ }, [
86
+ data,
87
+ timeScaleProp
88
+ ]);
89
+ // EChart resizes whenever its sx identity changes. Keep sx stable and observe
90
+ // actual container dimensions so hover/pinning never relayouts every series.
91
+ const handleResize = useCallback(({ width, height: containerHeight })=>{
92
+ const chart = chartRef.current;
93
+ if (width && containerHeight && chart && (chart.getWidth() !== width || chart.getHeight() !== containerHeight)) {
94
+ chart.resize({
95
+ width,
96
+ height: containerHeight
97
+ });
73
98
  }
74
- } else {
75
- timeScale = timeScaleProp;
76
- }
99
+ }, []);
100
+ const { ref: containerRef } = useResizeObserver({
101
+ onResize: handleResize
102
+ });
77
103
  useImperativeHandle(ref, ()=>{
78
104
  return {
79
105
  highlightSeries ({ name }) {
@@ -122,6 +148,17 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
122
148
  },
123
149
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
124
150
  mouseover: (params)=>{
151
+ if (params.componentType === 'series' && params.seriesType === 'scatter' && typeof params.seriesId === 'string' && params.seriesId.startsWith(EXEMPLAR_SERIES_ID_PREFIX)) {
152
+ if (params.data?.exemplar) {
153
+ setHoveredExemplar({
154
+ exemplar: params.data.exemplar,
155
+ seriesLabels: params.data.seriesLabels,
156
+ plottedValue: params.data?.value?.[1] ?? params.data.exemplar.value
157
+ });
158
+ return;
159
+ }
160
+ }
161
+ setHoveredExemplar(null);
125
162
  // Only markPoint (triangles under the X-axis) opens the annotation tooltip.
126
163
  // Hovering markLine or anything else keeps the regular TimeSeries tooltip visible
127
164
  // and clears any stale hovered annotation (mouseout is sometimes missed by ECharts).
@@ -136,6 +173,10 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
136
173
  },
137
174
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
138
175
  mouseout: (params)=>{
176
+ if (params.componentType === 'series' && params.seriesType === 'scatter' && typeof params.seriesId === 'string' && params.seriesId.startsWith(EXEMPLAR_SERIES_ID_PREFIX)) {
177
+ setHoveredExemplar(null);
178
+ return;
179
+ }
139
180
  if (annotations && params.componentType === 'markPoint' && params.data?.annotationIndex !== undefined && annotations) {
140
181
  // Only clear if the mouseout corresponds to the currently hovered annotation, so that
141
182
  // a quick move from one markPoint to another isn't cancelled by a late mouseout event.
@@ -148,6 +189,7 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
148
189
  // Cursor left the chart canvas — guarantee the annotation tooltip is dismissed.
149
190
  setHoveredAnnotation(null);
150
191
  }
192
+ setHoveredExemplar(null);
151
193
  }
152
194
  };
153
195
  }, [
@@ -158,40 +200,42 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
158
200
  const annotationSeries = useMemo(()=>buildAnnotationSeries(annotations), [
159
201
  annotations
160
202
  ]);
203
+ const preparedExemplarSeries = useMemo(()=>exemplars?.map(getExemplarSeries) ?? [], [
204
+ exemplars
205
+ ]);
206
+ const exemplarSeries = useMemo(()=>{
207
+ const visibleIds = new Set(seriesMapping.map((series)=>`${EXEMPLAR_SERIES_ID_PREFIX}${series.id}`));
208
+ return preparedExemplarSeries.filter((series)=>visibleIds.has(String(series.id)));
209
+ }, [
210
+ preparedExemplarSeries,
211
+ seriesMapping
212
+ ]);
161
213
  const { noDataOption } = chartsTheme;
162
- const option = useMemo(()=>{
163
- // The "chart" `noDataVariant` is only used when the `timeSeries` is an
164
- // empty array because a `null` value will throw an error.
165
- if (data === null || data.length === 0 && noDataVariant === 'message') return noDataOption;
166
- // Utilizes ECharts dataset so raw data is separate from series option style properties
167
- // https://apache.github.io/echarts-handbook/en/concepts/dataset/
168
- const dataset = [];
169
- data.map((d, index)=>{
170
- const values = d.values.map(([timestamp, value])=>{
171
- const val = value === null ? '-' : value; // echarts use '-' to represent null data
172
- return [
173
- timestamp,
174
- val
175
- ];
176
- });
177
- dataset.push({
214
+ // Reuse the dataset when pinning a crosshair or updating annotations/axes.
215
+ const dataset = useMemo(()=>data?.map((series, index)=>({
178
216
  id: index,
179
- source: [
180
- ...values
181
- ],
182
217
  dimensions: [
183
218
  'time',
184
219
  'value'
185
- ]
186
- });
187
- });
220
+ ],
221
+ // ECharts treats null as missing data; no per-point conversion/copy is needed.
222
+ source: series.values
223
+ })) ?? [], [
224
+ data
225
+ ]);
226
+ const option = useMemo(()=>{
227
+ // The "chart" `noDataVariant` is only used when the `timeSeries` is an
228
+ // empty array because a `null` value will throw an error.
229
+ if (data === null || data.length === 0 && noDataVariant === 'message') return noDataOption;
188
230
  const updatedSeriesMapping = enablePinning && pinnedCrosshair !== null ? [
189
231
  ...seriesMapping,
190
232
  pinnedCrosshair,
191
- ...annotationSeries
233
+ ...annotationSeries,
234
+ ...exemplarSeries
192
235
  ] : [
193
236
  ...seriesMapping,
194
- ...annotationSeries
237
+ ...annotationSeries,
238
+ ...exemplarSeries
195
239
  ];
196
240
  const option = {
197
241
  dataset: dataset,
@@ -243,8 +287,10 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
243
287
  return option;
244
288
  }, [
245
289
  data,
290
+ dataset,
246
291
  seriesMapping,
247
292
  annotationSeries,
293
+ exemplarSeries,
248
294
  timeScale,
249
295
  yAxis,
250
296
  format,
@@ -270,6 +316,12 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
270
316
  }
271
317
  }
272
318
  }
319
+ // A pinned exemplar tooltip is also unpinned when a tooltip is pinned in another chart,
320
+ // unless it is the one just pinned by this chart at these exact coordinates.
321
+ if (pinnedExemplarPos !== null && lastTooltipPinnedCoords !== null && !isEqual(lastTooltipPinnedCoords, pinnedExemplarPos)) {
322
+ setPinnedExemplar(null);
323
+ setPinnedExemplarPos(null);
324
+ }
273
325
  // tooltipPinnedCoords CANNOT be in dep array or tooltip pinning breaks in the current chart's onClick
274
326
  // eslint-disable-next-line react-hooks/exhaustive-deps
275
327
  }, [
@@ -277,6 +329,7 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
277
329
  seriesMapping
278
330
  ]);
279
331
  return /*#__PURE__*/ _jsxs(Box, {
332
+ ref: containerRef,
280
333
  style: {
281
334
  height
282
335
  },
@@ -285,6 +338,51 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
285
338
  // e.preventDefault(); // Prevent the default behaviour when right clicked
286
339
  // }}
287
340
  onClick: (e)=>{
341
+ // Allows user to opt-in to multi tooltip pinning when Ctrl or Cmd key held down
342
+ const isControlKeyPressed = e.ctrlKey || e.metaKey;
343
+ if (isControlKeyPressed) {
344
+ e.preventDefault();
345
+ }
346
+ // If clicking while hovering an exemplar marker, toggle the exemplar tooltip pin
347
+ // instead of pinning the TimeChartTooltip. Pinning an exemplar tooltip unpins the
348
+ // pinned TimeChartTooltip, so only one tooltip stays pinned at a time unless
349
+ // Ctrl or Cmd is held down.
350
+ if (hoveredExemplar !== null && e.target instanceof HTMLCanvasElement) {
351
+ const pinnedPos = {
352
+ page: {
353
+ x: e.pageX,
354
+ y: e.pageY
355
+ },
356
+ client: {
357
+ x: e.clientX,
358
+ y: e.clientY
359
+ },
360
+ plotCanvas: {
361
+ x: e.nativeEvent.offsetX,
362
+ y: e.nativeEvent.offsetY
363
+ },
364
+ target: e.target
365
+ };
366
+ const isUnpinClick = pinnedExemplar !== null && pinnedExemplar.exemplar === hoveredExemplar.exemplar;
367
+ // Compute the next state first and call the setters separately: updater functions
368
+ // may run more than once (e.g. StrictMode), so they must stay side-effect free.
369
+ setPinnedExemplar(isUnpinClick ? null : hoveredExemplar);
370
+ setPinnedExemplarPos(isUnpinClick ? null : pinnedPos);
371
+ if (!isUnpinClick && !isControlKeyPressed) {
372
+ // Unpin the pinned TimeChartTooltip and let adjacent charts know a tooltip is
373
+ // pinned at these coordinates, so only one tooltip is pinned at a time.
374
+ setTooltipPinnedCoords(null);
375
+ setPinnedCrosshair(null);
376
+ setLastTooltipPinnedCoords(pinnedPos);
377
+ }
378
+ return;
379
+ }
380
+ // Unpin a pinned exemplar tooltip when clicking elsewhere on the chart canvas,
381
+ // so the same click can pin the TimeChartTooltip instead. Ctrl or Cmd keeps both.
382
+ if (pinnedExemplar !== null && !isControlKeyPressed && e.target instanceof HTMLCanvasElement) {
383
+ setPinnedExemplar(null);
384
+ setPinnedExemplarPos(null);
385
+ }
288
386
  // If clicking while hovering an annotation, toggle the annotation tooltip pin
289
387
  // instead of pinning the TimeChartTooltip, so pinned TimeChartTooltip is preserved.
290
388
  if (hoveredAnnotation !== null && e.target instanceof HTMLCanvasElement) {
@@ -313,11 +411,6 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
313
411
  });
314
412
  return;
315
413
  }
316
- // Allows user to opt-in to multi tooltip pinning when Ctrl or Cmd key held down
317
- const isControlKeyPressed = e.ctrlKey || e.metaKey;
318
- if (isControlKeyPressed) {
319
- e.preventDefault();
320
- }
321
414
  // Determine where on chart canvas to plot pinned crosshair as markLine.
322
415
  const pointInGrid = getPointInGrid(e.nativeEvent.offsetX, e.nativeEvent.offsetY, chartRef.current);
323
416
  if (pointInGrid === null) {
@@ -388,6 +481,28 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
388
481
  return;
389
482
  }
390
483
  const { clientX } = e;
484
+ // ECharts does not reliably emit mouseout when the cursor moves off an exemplar marker
485
+ // onto the plain plot area, which would keep the exemplar tooltip stuck on screen and
486
+ // hide the regular TimeChartTooltip. Clear the hovered exemplar as soon as the cursor
487
+ // is no longer within its marker, so the next hover can take over.
488
+ setHoveredExemplar((current)=>{
489
+ if (current === null || chartRef.current === undefined) return current;
490
+ let markerPixel;
491
+ try {
492
+ // Use the plotted value so negated markers (negativeY) are tracked correctly.
493
+ markerPixel = chartRef.current.convertToPixel('grid', [
494
+ current.exemplar.timestamp,
495
+ current.plottedValue
496
+ ]);
497
+ } catch {
498
+ // Coordinates cannot be resolved (e.g. grid not ready yet), keep the current hover.
499
+ return current;
500
+ }
501
+ const [markerPixelX, markerPixelY] = markerPixel ?? [];
502
+ if (markerPixelX === undefined || markerPixelY === undefined) return current;
503
+ const distance = Math.hypot(e.nativeEvent.offsetX - markerPixelX, e.nativeEvent.offsetY - markerPixelY);
504
+ return distance <= EXEMPLAR_HOVER_RADIUS ? current : null;
505
+ });
391
506
  if (isDragging) {
392
507
  const deltaX = clientX - startX;
393
508
  if (deltaX > 0) {
@@ -405,8 +520,9 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
405
520
  if (tooltipPinnedCoords === null) {
406
521
  setShowTooltip(false);
407
522
  }
408
- // Defensive: clear hovered annotation in case ECharts missed a mouseout event.
523
+ // Defensive: clear hovered annotation and exemplar in case ECharts missed a mouseout event.
409
524
  setHoveredAnnotation(null);
525
+ setHoveredExemplar(null);
410
526
  if (chartRef.current !== undefined) {
411
527
  clearHighlightedSeries(chartRef.current);
412
528
  }
@@ -429,7 +545,7 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
429
545
  }
430
546
  },
431
547
  children: [
432
- showTooltip === true && (tooltipPinnedCoords !== null || hoveredAnnotation === null) && option.tooltip?.showContent === false && tooltipConfig.hidden !== true && /*#__PURE__*/ _jsx(TimeChartTooltip, {
548
+ showTooltip === true && (tooltipPinnedCoords !== null || pinnedExemplar === null && hoveredAnnotation === null && hoveredExemplar === null) && option.tooltip?.showContent === false && tooltipConfig.hidden !== true && /*#__PURE__*/ _jsx(TimeChartTooltip, {
433
549
  containerId: chartsTheme.tooltipPortalContainerId,
434
550
  chartRef: chartRef,
435
551
  data: data,
@@ -446,6 +562,18 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
446
562
  setPinnedCrosshair(null);
447
563
  }
448
564
  }),
565
+ (pinnedExemplar !== null || hoveredExemplar !== null && tooltipPinnedCoords === null) && /*#__PURE__*/ _jsx(ExemplarMetadataTooltip, {
566
+ exemplar: (pinnedExemplar ?? hoveredExemplar).exemplar,
567
+ seriesLabels: (pinnedExemplar ?? hoveredExemplar).seriesLabels,
568
+ containerId: chartsTheme.tooltipPortalContainerId,
569
+ format: format,
570
+ pinnedPos: pinnedExemplar !== null ? pinnedExemplarPos : null,
571
+ enablePinning: isPinningEnabled,
572
+ onUnpinClick: ()=>{
573
+ setPinnedExemplar(null);
574
+ setPinnedExemplarPos(null);
575
+ }
576
+ }),
449
577
  (pinnedAnnotation ?? hoveredAnnotation) && /*#__PURE__*/ _jsx(AnnotationTooltip, {
450
578
  annotation: pinnedAnnotation ?? hoveredAnnotation,
451
579
  containerId: chartsTheme.tooltipPortalContainerId,
@@ -458,10 +586,7 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
458
586
  }
459
587
  }),
460
588
  /*#__PURE__*/ _jsx(EChart, {
461
- sx: {
462
- width: '100%',
463
- height: '100%'
464
- },
589
+ sx: CHART_SX,
465
590
  option: option,
466
591
  theme: chartsTheme.echartsTheme,
467
592
  onEvents: handleEvents,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/TimeSeriesChartBase.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport type {\n ChartInstance,\n ChartInstanceFocusOpts,\n CursorCoordinates,\n FormatOptions,\n OnEventsType,\n TimeChartSeriesMapping,\n TooltipConfig,\n ZoomEventData,\n} from '@perses-dev/components';\nimport {\n clearHighlightedSeries,\n DEFAULT_PINNED_CROSSHAIR,\n DEFAULT_TOOLTIP_CONFIG,\n EChart,\n enableDataZoom,\n getClosestTimestamp,\n getCommonTimeScale,\n getFormattedAxis,\n getPointInGrid,\n restoreChart,\n TimeChartTooltip,\n useChartsContext,\n useTimeZone,\n} from '@perses-dev/components';\nimport type { TimeScale, TimeSeries } from '@perses-dev/spec';\nimport type {\n DatasetComponentOption as DatasetOption,\n EChartsCoreOption,\n GridComponentOption,\n LineSeriesOption,\n YAXisComponentOption,\n TooltipComponentOption,\n} from 'echarts';\nimport { LineChart as EChartsLineChart, BarChart as EChartsBarChart } from 'echarts/charts';\nimport {\n GridComponent,\n DatasetComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n} from 'echarts/components';\nimport type { ECharts as EChartsInstance } from 'echarts/core';\nimport { use as registerECharts } from 'echarts/core';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport isEqual from 'lodash/isEqual';\nimport merge from 'lodash/merge';\nimport type { MouseEvent } from 'react';\nimport { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';\n\nimport { AnnotationTooltip, buildAnnotationSeries } from './annotations/AnnotationTooltip';\nimport type { TimeSeriesAnnotation } from './utils/annotation';\nimport { createTimezoneAwareAxisFormatter } from './utils/timezone-formatter';\n\nregisterECharts([\n EChartsLineChart,\n EChartsBarChart,\n GridComponent,\n DatasetComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n CanvasRenderer,\n]);\n\nexport interface TimeChartProps {\n height: number;\n data: TimeSeries[];\n seriesMapping: TimeChartSeriesMapping;\n annotations?: TimeSeriesAnnotation[];\n timeScale?: TimeScale;\n yAxis?: YAXisComponentOption | YAXisComponentOption[];\n format?: FormatOptions;\n /**\n * Map of series ID to format options, used for tooltip formatting when series have different units\n */\n seriesFormatMap?: Map<string, FormatOptions>;\n grid?: GridComponentOption;\n tooltipConfig?: TooltipConfig;\n noDataVariant?: 'chart' | 'message';\n syncGroup?: string;\n isStackedBar?: boolean;\n onDataZoom?: (e: ZoomEventData) => void;\n onDoubleClick?: (e: MouseEvent) => void;\n __experimentalEChartsOptionsOverride?: (options: EChartsCoreOption) => EChartsCoreOption;\n}\n\nexport const TimeSeriesChartBase = forwardRef<ChartInstance, TimeChartProps>(function TimeChart(\n {\n height,\n data,\n seriesMapping,\n annotations,\n timeScale: timeScaleProp,\n yAxis,\n format,\n seriesFormatMap,\n grid,\n isStackedBar = false,\n tooltipConfig = DEFAULT_TOOLTIP_CONFIG,\n noDataVariant = 'message',\n syncGroup,\n onDataZoom,\n onDoubleClick,\n __experimentalEChartsOptionsOverride,\n },\n ref,\n) {\n const { chartsTheme, enablePinning, enableSyncGrouping, lastTooltipPinnedCoords, setLastTooltipPinnedCoords } =\n useChartsContext();\n const isPinningEnabled = tooltipConfig.enablePinning && enablePinning;\n const chartRef = useRef<EChartsInstance>();\n const [showTooltip, setShowTooltip] = useState<boolean>(true);\n const [tooltipPinnedCoords, setTooltipPinnedCoords] = useState<CursorCoordinates | null>(null);\n const [pinnedCrosshair, setPinnedCrosshair] = useState<LineSeriesOption | null>(null);\n const [isDragging, setIsDragging] = useState(false);\n const [startX, setStartX] = useState(0);\n const [hoveredAnnotation, setHoveredAnnotation] = useState<TimeSeriesAnnotation | null>(null);\n const [pinnedAnnotation, setPinnedAnnotation] = useState<TimeSeriesAnnotation | null>(null);\n const [pinnedAnnotationPos, setPinnedAnnotationPos] = useState<CursorCoordinates | null>(null);\n const { timeZone, formatWithUserTimeZone } = useTimeZone();\n\n const getTimezoneAwareAxisFormatter = useCallback(\n (rangeMs: number): ((value: number) => string) => createTimezoneAwareAxisFormatter(rangeMs, timeZone),\n [timeZone],\n );\n\n let timeScale: TimeScale;\n if (timeScaleProp === undefined) {\n const commonTimeScale = getCommonTimeScale(data);\n if (commonTimeScale === undefined) {\n // set default to past 5 years\n const today = new Date();\n const pastDate = new Date(today);\n pastDate.setFullYear(today.getFullYear() - 5);\n const todayMs = today.getTime();\n const pastDateMs = pastDate.getTime();\n timeScale = { startMs: pastDateMs, endMs: todayMs, stepMs: 1, rangeMs: todayMs - pastDateMs };\n } else {\n timeScale = commonTimeScale;\n }\n } else {\n timeScale = timeScaleProp;\n }\n\n useImperativeHandle(ref, () => {\n return {\n highlightSeries({ name }: ChartInstanceFocusOpts): void {\n if (!chartRef.current) {\n // when chart undef, do not highlight series when hovering over legend\n return;\n }\n\n chartRef.current.dispatchAction({ type: 'highlight', seriesId: name });\n },\n clearHighlightedSeries: (): void => {\n if (!chartRef.current) {\n // when chart undef, do not clear highlight series\n return;\n }\n clearHighlightedSeries(chartRef.current);\n },\n };\n }, []);\n\n const handleEvents: OnEventsType<LineSeriesOption['data'] | unknown> = useMemo(() => {\n return {\n datazoom: (params): void => {\n if (onDataZoom === undefined) {\n setTimeout(() => {\n // workaround so unpin happens after click event\n setTooltipPinnedCoords(null);\n }, 10);\n }\n if (onDataZoom === undefined || params.batch[0] === undefined) return;\n const xAxisStartValue = params.batch[0].startValue;\n const xAxisEndValue = params.batch[0].endValue;\n if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {\n const zoomEvent: ZoomEventData = {\n start: xAxisStartValue,\n end: xAxisEndValue,\n };\n onDataZoom(zoomEvent);\n }\n },\n finished: (): void => {\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n mouseover: (params: any): void => {\n // Only markPoint (triangles under the X-axis) opens the annotation tooltip.\n // Hovering markLine or anything else keeps the regular TimeSeries tooltip visible\n // and clears any stale hovered annotation (mouseout is sometimes missed by ECharts).\n if (annotations && params.componentType === 'markPoint' && params.data?.annotationIndex !== undefined) {\n const matchedAnnotation = annotations[params.data.annotationIndex] || null;\n if (matchedAnnotation) {\n setHoveredAnnotation(matchedAnnotation);\n return;\n }\n }\n setHoveredAnnotation(null);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n mouseout: (params: any): void => {\n if (\n annotations &&\n params.componentType === 'markPoint' &&\n params.data?.annotationIndex !== undefined &&\n annotations\n ) {\n // Only clear if the mouseout corresponds to the currently hovered annotation, so that\n // a quick move from one markPoint to another isn't cancelled by a late mouseout event.\n const leaving = annotations[params.data.annotationIndex] || null;\n setHoveredAnnotation((current) => (current === leaving ? null : current));\n }\n },\n globalout: (): void => {\n if (annotations) {\n // Cursor left the chart canvas — guarantee the annotation tooltip is dismissed.\n setHoveredAnnotation(null);\n }\n },\n };\n }, [annotations, onDataZoom]);\n\n // Generate annotation series for ECharts markArea (range), markLine (point), and markPoint (markers under X-axis)\n const annotationSeries = useMemo(() => buildAnnotationSeries(annotations), [annotations]);\n\n const { noDataOption } = chartsTheme;\n\n const option: EChartsCoreOption = useMemo(() => {\n // The \"chart\" `noDataVariant` is only used when the `timeSeries` is an\n // empty array because a `null` value will throw an error.\n if (data === null || (data.length === 0 && noDataVariant === 'message')) return noDataOption;\n\n // Utilizes ECharts dataset so raw data is separate from series option style properties\n // https://apache.github.io/echarts-handbook/en/concepts/dataset/\n const dataset: DatasetOption[] = [];\n data.map((d, index) => {\n const values = d.values.map(([timestamp, value]) => {\n const val: string | number = value === null ? '-' : value; // echarts use '-' to represent null data\n return [timestamp, val];\n });\n dataset.push({ id: index, source: [...values], dimensions: ['time', 'value'] });\n });\n\n const updatedSeriesMapping =\n enablePinning && pinnedCrosshair !== null\n ? [...seriesMapping, pinnedCrosshair, ...annotationSeries]\n : [...seriesMapping, ...annotationSeries];\n\n const option: EChartsCoreOption = {\n dataset: dataset,\n series: updatedSeriesMapping,\n xAxis: {\n type: 'time',\n min: timeScale.startMs,\n max: timeScale.endMs,\n axisLabel: {\n hideOverlap: true,\n formatter: getTimezoneAwareAxisFormatter(timeScale.rangeMs ?? 0),\n },\n axisPointer: {\n snap: false, // important so shared crosshair does not lag\n },\n },\n // If yAxis is already an array (multiple Y axes), use it directly; otherwise use getFormattedAxis\n yAxis: Array.isArray(yAxis) ? yAxis : getFormattedAxis(yAxis, format),\n animation: false,\n tooltip: {\n show: true,\n // ECharts tooltip content hidden by default since we use custom tooltip instead.\n // Stacked bar uses ECharts tooltip so subgroup data shows correctly.\n showContent: isStackedBar,\n trigger: isStackedBar ? 'item' : 'axis',\n appendToBody: isStackedBar,\n },\n // https://echarts.apache.org/en/option.html#axisPointer\n axisPointer: {\n type: 'line',\n z: 0, // ensure point symbol shows on top of dashed line\n triggerEmphasis: false, // https://github.com/apache/echarts/issues/18495\n triggerTooltip: false,\n snap: false, // xAxis.axisPointer.snap takes priority\n },\n toolbox: {\n feature: {\n dataZoom: {\n icon: null, // https://stackoverflow.com/a/67684076/17575201\n yAxisIndex: 'none',\n },\n },\n },\n grid,\n };\n\n if (__experimentalEChartsOptionsOverride) {\n return __experimentalEChartsOptionsOverride(option);\n }\n\n return option;\n }, [\n data,\n seriesMapping,\n annotationSeries,\n timeScale,\n yAxis,\n format,\n grid,\n noDataOption,\n __experimentalEChartsOptionsOverride,\n noDataVariant,\n isStackedBar,\n enablePinning,\n pinnedCrosshair,\n getTimezoneAwareAxisFormatter,\n ]);\n\n // Update adjacent charts so tooltip is unpinned when current chart is clicked.\n useEffect(() => {\n // Only allow pinning one tooltip at a time, subsequent tooltip click unpins previous.\n // Multiple tooltips can only be pinned if Ctrl or Cmd key is pressed while clicking.\n const multipleTooltipsPinned = tooltipPinnedCoords !== null && lastTooltipPinnedCoords !== null;\n if (multipleTooltipsPinned) {\n if (!isEqual(lastTooltipPinnedCoords, tooltipPinnedCoords)) {\n setTooltipPinnedCoords(null);\n if (tooltipPinnedCoords !== null && pinnedCrosshair !== null) {\n setPinnedCrosshair(null);\n }\n }\n }\n // tooltipPinnedCoords CANNOT be in dep array or tooltip pinning breaks in the current chart's onClick\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [lastTooltipPinnedCoords, seriesMapping]);\n\n return (\n <Box\n style={{ height }}\n // onContextMenu={(e) => {\n // // TODO: confirm tooltip pinning works correctly on Windows, should e.preventDefault() be added here\n // e.preventDefault(); // Prevent the default behaviour when right clicked\n // }}\n onClick={(e) => {\n // If clicking while hovering an annotation, toggle the annotation tooltip pin\n // instead of pinning the TimeChartTooltip, so pinned TimeChartTooltip is preserved.\n if (hoveredAnnotation !== null && e.target instanceof HTMLCanvasElement) {\n const pinnedPos: CursorCoordinates = {\n page: { x: e.pageX, y: e.pageY },\n client: { x: e.clientX, y: e.clientY },\n plotCanvas: { x: e.nativeEvent.offsetX, y: e.nativeEvent.offsetY },\n target: e.target,\n };\n setPinnedAnnotation((current) => {\n if (current === hoveredAnnotation) {\n setPinnedAnnotationPos(null);\n return null;\n }\n setPinnedAnnotationPos(pinnedPos);\n return hoveredAnnotation;\n });\n return;\n }\n\n // Allows user to opt-in to multi tooltip pinning when Ctrl or Cmd key held down\n const isControlKeyPressed = e.ctrlKey || e.metaKey;\n if (isControlKeyPressed) {\n e.preventDefault();\n }\n\n // Determine where on chart canvas to plot pinned crosshair as markLine.\n const pointInGrid = getPointInGrid(e.nativeEvent.offsetX, e.nativeEvent.offsetY, chartRef.current);\n if (pointInGrid === null) {\n return;\n }\n\n // Pin and unpin when clicking on chart canvas but not tooltip text.\n if (isPinningEnabled && e.target instanceof HTMLCanvasElement) {\n // Pin tooltip and update shared charts context to remember these coordinates.\n const pinnedPos: CursorCoordinates = {\n page: {\n x: e.pageX,\n y: e.pageY,\n },\n client: {\n x: e.clientX,\n y: e.clientY,\n },\n plotCanvas: {\n x: e.nativeEvent.offsetX,\n y: e.nativeEvent.offsetY,\n },\n target: e.target,\n };\n\n setTooltipPinnedCoords((current) => {\n if (current === null) {\n return pinnedPos;\n } else {\n setPinnedCrosshair(null);\n return null;\n }\n });\n\n setPinnedCrosshair((current) => {\n // Only add pinned crosshair line series when there is not one already in seriesMapping.\n if (current === null) {\n const cursorX = pointInGrid[0];\n\n // Only need to loop through first dataset source since getCommonTimeScale ensures xAxis timestamps are consistent\n const firstTimeSeriesValues = data[0]?.values;\n const closestTimestamp = getClosestTimestamp(firstTimeSeriesValues, cursorX);\n\n // Crosshair snaps to nearest timestamp since cursor may be slightly to left or right\n const pinnedCrosshair = merge({}, DEFAULT_PINNED_CROSSHAIR, {\n markLine: {\n data: [\n {\n xAxis: closestTimestamp,\n },\n ],\n },\n } as LineSeriesOption);\n return pinnedCrosshair;\n } else {\n // Clear previously set pinned crosshair\n return null;\n }\n });\n\n if (!isControlKeyPressed) {\n setLastTooltipPinnedCoords(pinnedPos);\n }\n }\n }}\n onMouseDown={(e) => {\n const { clientX } = e;\n setIsDragging(true);\n setStartX(clientX);\n }}\n onMouseMove={(e) => {\n // Allow clicking inside tooltip to copy labels.\n if (!(e.target instanceof HTMLCanvasElement)) {\n return;\n }\n const { clientX } = e;\n if (isDragging) {\n const deltaX = clientX - startX;\n if (deltaX > 0) {\n // Hide tooltip when user drags to zoom.\n setShowTooltip(false);\n }\n }\n }}\n onMouseUp={() => {\n setIsDragging(false);\n setStartX(0);\n setShowTooltip(true);\n }}\n onMouseLeave={() => {\n if (tooltipPinnedCoords === null) {\n setShowTooltip(false);\n }\n // Defensive: clear hovered annotation in case ECharts missed a mouseout event.\n setHoveredAnnotation(null);\n if (chartRef.current !== undefined) {\n clearHighlightedSeries(chartRef.current);\n }\n }}\n onMouseEnter={() => {\n setShowTooltip(true);\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n }}\n onDoubleClick={(e) => {\n setTooltipPinnedCoords(null);\n // either dispatch ECharts restore action to return to orig state or allow consumer to define behavior\n if (onDoubleClick === undefined) {\n if (chartRef.current !== undefined) {\n restoreChart(chartRef.current);\n }\n } else {\n onDoubleClick(e);\n }\n }}\n >\n {/* Allows overrides prop to hide custom tooltip and use the ECharts option.tooltip instead.\n Keep the time chart tooltip visible when pinned even if user hovers an annotation. */}\n {showTooltip === true &&\n (tooltipPinnedCoords !== null || hoveredAnnotation === null) &&\n (option.tooltip as TooltipComponentOption)?.showContent === false &&\n tooltipConfig.hidden !== true && (\n <TimeChartTooltip\n containerId={chartsTheme.tooltipPortalContainerId}\n chartRef={chartRef}\n data={data}\n seriesMapping={seriesMapping}\n wrapLabels={tooltipConfig.wrapLabels}\n enablePinning={isPinningEnabled}\n pinnedPos={tooltipPinnedCoords}\n format={format}\n seriesFormatMap={seriesFormatMap}\n onUnpinClick={() => {\n // Unpins tooltip when clicking Pin icon in TooltipHeader.\n setTooltipPinnedCoords(null);\n // Clear previously set pinned crosshair.\n setPinnedCrosshair(null);\n }}\n />\n )}\n {/* Pinned annotation takes priority over hovered. */}\n {(pinnedAnnotation ?? hoveredAnnotation) && (\n <AnnotationTooltip\n annotation={(pinnedAnnotation ?? hoveredAnnotation) as TimeSeriesAnnotation}\n containerId={chartsTheme.tooltipPortalContainerId}\n formatWithUserTimeZone={formatWithUserTimeZone}\n pinnedPos={pinnedAnnotation !== null ? pinnedAnnotationPos : null}\n enablePinning={isPinningEnabled}\n onUnpinClick={() => {\n setPinnedAnnotation(null);\n setPinnedAnnotationPos(null);\n }}\n />\n )}\n <EChart\n sx={{\n width: '100%',\n height: '100%',\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n onEvents={handleEvents}\n _instance={chartRef}\n syncGroup={enableSyncGrouping ? syncGroup : undefined}\n />\n </Box>\n );\n});\n"],"names":["Box","clearHighlightedSeries","DEFAULT_PINNED_CROSSHAIR","DEFAULT_TOOLTIP_CONFIG","EChart","enableDataZoom","getClosestTimestamp","getCommonTimeScale","getFormattedAxis","getPointInGrid","restoreChart","TimeChartTooltip","useChartsContext","useTimeZone","LineChart","EChartsLineChart","BarChart","EChartsBarChart","GridComponent","DatasetComponent","DataZoomComponent","MarkAreaComponent","MarkLineComponent","MarkPointComponent","TitleComponent","ToolboxComponent","TooltipComponent","use","registerECharts","CanvasRenderer","isEqual","merge","forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useRef","useState","AnnotationTooltip","buildAnnotationSeries","createTimezoneAwareAxisFormatter","TimeSeriesChartBase","TimeChart","height","data","seriesMapping","annotations","timeScale","timeScaleProp","yAxis","format","seriesFormatMap","grid","isStackedBar","tooltipConfig","noDataVariant","syncGroup","onDataZoom","onDoubleClick","__experimentalEChartsOptionsOverride","ref","chartsTheme","enablePinning","enableSyncGrouping","lastTooltipPinnedCoords","setLastTooltipPinnedCoords","isPinningEnabled","chartRef","showTooltip","setShowTooltip","tooltipPinnedCoords","setTooltipPinnedCoords","pinnedCrosshair","setPinnedCrosshair","isDragging","setIsDragging","startX","setStartX","hoveredAnnotation","setHoveredAnnotation","pinnedAnnotation","setPinnedAnnotation","pinnedAnnotationPos","setPinnedAnnotationPos","timeZone","formatWithUserTimeZone","getTimezoneAwareAxisFormatter","rangeMs","undefined","commonTimeScale","today","Date","pastDate","setFullYear","getFullYear","todayMs","getTime","pastDateMs","startMs","endMs","stepMs","highlightSeries","name","current","dispatchAction","type","seriesId","handleEvents","datazoom","params","setTimeout","batch","xAxisStartValue","startValue","xAxisEndValue","endValue","zoomEvent","start","end","finished","mouseover","componentType","annotationIndex","matchedAnnotation","mouseout","leaving","globalout","annotationSeries","noDataOption","option","length","dataset","map","d","index","values","timestamp","value","val","push","id","source","dimensions","updatedSeriesMapping","series","xAxis","min","max","axisLabel","hideOverlap","formatter","axisPointer","snap","Array","isArray","animation","tooltip","show","showContent","trigger","appendToBody","z","triggerEmphasis","triggerTooltip","toolbox","feature","dataZoom","icon","yAxisIndex","multipleTooltipsPinned","style","onClick","e","target","HTMLCanvasElement","pinnedPos","page","x","pageX","y","pageY","client","clientX","clientY","plotCanvas","nativeEvent","offsetX","offsetY","isControlKeyPressed","ctrlKey","metaKey","preventDefault","pointInGrid","cursorX","firstTimeSeriesValues","closestTimestamp","markLine","onMouseDown","onMouseMove","deltaX","onMouseUp","onMouseLeave","onMouseEnter","hidden","containerId","tooltipPortalContainerId","wrapLabels","onUnpinClick","annotation","sx","width","theme","echartsTheme","onEvents","_instance"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,GAAG,QAAQ,gBAAgB;AAWpC,SACEC,sBAAsB,EACtBC,wBAAwB,EACxBC,sBAAsB,EACtBC,MAAM,EACNC,cAAc,EACdC,mBAAmB,EACnBC,kBAAkB,EAClBC,gBAAgB,EAChBC,cAAc,EACdC,YAAY,EACZC,gBAAgB,EAChBC,gBAAgB,EAChBC,WAAW,QACN,yBAAyB;AAUhC,SAASC,aAAaC,gBAAgB,EAAEC,YAAYC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Aa0D,SAASoC,OAAO;gBAC/B;YACF,OAAO;gBACL7C,cAAckH;YAChB;QACF;;YAICxG,gBAAgB,QACdE,CAAAA,wBAAwB,QAAQQ,sBAAsB,IAAG,KAC1D,AAACmD,OAAO2B,OAAO,EAA6BE,gBAAgB,SAC5DxG,cAAcqJ,MAAM,KAAK,sBACvB,KAACjM;gBACCkM,aAAa/I,YAAYgJ,wBAAwB;gBACjD1I,UAAUA;gBACVvB,MAAMA;gBACNC,eAAeA;gBACfiK,YAAYxJ,cAAcwJ,UAAU;gBACpChJ,eAAeI;gBACf6G,WAAWzG;gBACXpB,QAAQA;gBACRC,iBAAiBA;gBACjB4J,cAAc;oBACZ,0DAA0D;oBAC1DxI,uBAAuB;oBACvB,yCAAyC;oBACzCE,mBAAmB;gBACrB;;YAIJO,CAAAA,oBAAoBF,iBAAgB,mBACpC,KAACxC;gBACC0K,YAAahI,oBAAoBF;gBACjC8H,aAAa/I,YAAYgJ,wBAAwB;gBACjDxH,wBAAwBA;gBACxB0F,WAAW/F,qBAAqB,OAAOE,sBAAsB;gBAC7DpB,eAAeI;gBACf6I,cAAc;oBACZ9H,oBAAoB;oBACpBE,uBAAuB;gBACzB;;0BAGJ,KAAChF;gBACC8M,IAAI;oBACFC,OAAO;oBACPvK,QAAQ;gBACV;gBACAsF,QAAQA;gBACRkF,OAAOtJ,YAAYuJ,YAAY;gBAC/BC,UAAU1G;gBACV2G,WAAWnJ;gBACXX,WAAWO,qBAAqBP,YAAYgC;;;;AAIpD,GAAG"}
1
+ {"version":3,"sources":["../../src/TimeSeriesChartBase.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport type {\n ChartInstance,\n ChartInstanceFocusOpts,\n CursorCoordinates,\n FormatOptions,\n OnEventsType,\n TimeChartSeriesMapping,\n TooltipConfig,\n ZoomEventData,\n} from '@perses-dev/components';\nimport {\n clearHighlightedSeries,\n DEFAULT_PINNED_CROSSHAIR,\n DEFAULT_TOOLTIP_CONFIG,\n EChart,\n enableDataZoom,\n ExemplarMetadataTooltip,\n getClosestTimestamp,\n getCommonTimeScale,\n getFormattedAxis,\n getPointInGrid,\n restoreChart,\n TimeChartTooltip,\n useChartsContext,\n useTimeZone,\n} from '@perses-dev/components';\nimport type { Exemplar, Labels, TimeScale, TimeSeries } from '@perses-dev/spec';\nimport type {\n DatasetComponentOption as DatasetOption,\n EChartsCoreOption,\n GridComponentOption,\n LineSeriesOption,\n YAXisComponentOption,\n TooltipComponentOption,\n} from 'echarts';\nimport {\n LineChart as EChartsLineChart,\n BarChart as EChartsBarChart,\n ScatterChart as EChartsScatterChart,\n} from 'echarts/charts';\nimport {\n GridComponent,\n DatasetComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n} from 'echarts/components';\nimport type { ECharts as EChartsInstance } from 'echarts/core';\nimport { use as registerECharts } from 'echarts/core';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport isEqual from 'lodash/isEqual';\nimport merge from 'lodash/merge';\nimport type { MouseEvent } from 'react';\nimport { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';\nimport useResizeObserver from 'use-resize-observer';\n\nimport { AnnotationTooltip, buildAnnotationSeries } from './annotations/AnnotationTooltip';\nimport type { TimeSeriesAnnotation } from './utils/annotation';\nimport type { ExemplarChartData } from './utils/data-transform';\nimport { EXEMPLAR_SERIES_ID_PREFIX, EXEMPLAR_SYMBOL_SIZE, getExemplarSeries } from './utils/data-transform';\nimport { createTimezoneAwareAxisFormatter } from './utils/timezone-formatter';\n\nregisterECharts([\n EChartsLineChart,\n EChartsBarChart,\n EChartsScatterChart,\n GridComponent,\n DatasetComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n CanvasRenderer,\n]);\n\ninterface HoveredExemplar {\n exemplar: Exemplar;\n seriesLabels?: Labels;\n /**\n * The Y value actually plotted for the marker. Differs from `exemplar.value` when the\n * matching series is rendered with the negativeY transform (value negated for display).\n */\n plottedValue: number;\n}\n\n/**\n * Maximum pixel distance from an exemplar marker center for the cursor to count as still\n * hovering it (covers the full diamond bounding box, corners included).\n */\nconst EXEMPLAR_HOVER_RADIUS = (Math.SQRT2 * EXEMPLAR_SYMBOL_SIZE) / 2;\n\nconst CHART_SX = { width: '100%', height: '100%' };\n\nexport interface TimeChartProps {\n height: number;\n data: TimeSeries[];\n seriesMapping: TimeChartSeriesMapping;\n /** All exemplar groups; only groups matching a visible series are rendered. */\n exemplars?: ExemplarChartData[];\n annotations?: TimeSeriesAnnotation[];\n timeScale?: TimeScale;\n yAxis?: YAXisComponentOption | YAXisComponentOption[];\n format?: FormatOptions;\n /**\n * Map of series ID to format options, used for tooltip formatting when series have different units\n */\n seriesFormatMap?: Map<string, FormatOptions>;\n grid?: GridComponentOption;\n tooltipConfig?: TooltipConfig;\n noDataVariant?: 'chart' | 'message';\n syncGroup?: string;\n isStackedBar?: boolean;\n onDataZoom?: (e: ZoomEventData) => void;\n onDoubleClick?: (e: MouseEvent) => void;\n __experimentalEChartsOptionsOverride?: (options: EChartsCoreOption) => EChartsCoreOption;\n}\n\nexport const TimeSeriesChartBase = forwardRef<ChartInstance, TimeChartProps>(function TimeChart(\n {\n height,\n data,\n seriesMapping,\n exemplars,\n annotations,\n timeScale: timeScaleProp,\n yAxis,\n format,\n seriesFormatMap,\n grid,\n isStackedBar = false,\n tooltipConfig = DEFAULT_TOOLTIP_CONFIG,\n noDataVariant = 'message',\n syncGroup,\n onDataZoom,\n onDoubleClick,\n __experimentalEChartsOptionsOverride,\n },\n ref,\n) {\n const { chartsTheme, enablePinning, enableSyncGrouping, lastTooltipPinnedCoords, setLastTooltipPinnedCoords } =\n useChartsContext();\n const isPinningEnabled = tooltipConfig.enablePinning && enablePinning;\n const chartRef = useRef<EChartsInstance>();\n const [showTooltip, setShowTooltip] = useState<boolean>(true);\n const [tooltipPinnedCoords, setTooltipPinnedCoords] = useState<CursorCoordinates | null>(null);\n const [pinnedCrosshair, setPinnedCrosshair] = useState<LineSeriesOption | null>(null);\n const [isDragging, setIsDragging] = useState(false);\n const [startX, setStartX] = useState(0);\n const [hoveredAnnotation, setHoveredAnnotation] = useState<TimeSeriesAnnotation | null>(null);\n const [pinnedAnnotation, setPinnedAnnotation] = useState<TimeSeriesAnnotation | null>(null);\n const [hoveredExemplar, setHoveredExemplar] = useState<HoveredExemplar | null>(null);\n const [pinnedExemplar, setPinnedExemplar] = useState<HoveredExemplar | null>(null);\n const [pinnedExemplarPos, setPinnedExemplarPos] = useState<CursorCoordinates | null>(null);\n const [pinnedAnnotationPos, setPinnedAnnotationPos] = useState<CursorCoordinates | null>(null);\n const { timeZone, formatWithUserTimeZone } = useTimeZone();\n\n const getTimezoneAwareAxisFormatter = useCallback(\n (rangeMs: number): ((value: number) => string) => createTimezoneAwareAxisFormatter(rangeMs, timeZone),\n [timeZone],\n );\n\n const timeScale = useMemo((): TimeScale => {\n if (timeScaleProp) return timeScaleProp;\n const commonTimeScale = getCommonTimeScale(data);\n if (commonTimeScale) return commonTimeScale;\n // Set the empty chart's default range to the past five years.\n const today = new Date();\n const pastDate = new Date(today);\n pastDate.setFullYear(today.getFullYear() - 5);\n const startMs = pastDate.getTime();\n const endMs = today.getTime();\n return { startMs, endMs, stepMs: 1, rangeMs: endMs - startMs };\n }, [data, timeScaleProp]);\n\n // EChart resizes whenever its sx identity changes. Keep sx stable and observe\n // actual container dimensions so hover/pinning never relayouts every series.\n const handleResize = useCallback(({ width, height: containerHeight }: { width?: number; height?: number }): void => {\n const chart = chartRef.current;\n if (width && containerHeight && chart && (chart.getWidth() !== width || chart.getHeight() !== containerHeight)) {\n chart.resize({ width, height: containerHeight });\n }\n }, []);\n const { ref: containerRef } = useResizeObserver<HTMLDivElement>({ onResize: handleResize });\n\n useImperativeHandle(ref, () => {\n return {\n highlightSeries({ name }: ChartInstanceFocusOpts): void {\n if (!chartRef.current) {\n // when chart undef, do not highlight series when hovering over legend\n return;\n }\n\n chartRef.current.dispatchAction({ type: 'highlight', seriesId: name });\n },\n clearHighlightedSeries: (): void => {\n if (!chartRef.current) {\n // when chart undef, do not clear highlight series\n return;\n }\n clearHighlightedSeries(chartRef.current);\n },\n };\n }, []);\n\n const handleEvents: OnEventsType<LineSeriesOption['data'] | unknown> = useMemo(() => {\n return {\n datazoom: (params): void => {\n if (onDataZoom === undefined) {\n setTimeout(() => {\n // workaround so unpin happens after click event\n setTooltipPinnedCoords(null);\n }, 10);\n }\n if (onDataZoom === undefined || params.batch[0] === undefined) return;\n const xAxisStartValue = params.batch[0].startValue;\n const xAxisEndValue = params.batch[0].endValue;\n if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {\n const zoomEvent: ZoomEventData = {\n start: xAxisStartValue,\n end: xAxisEndValue,\n };\n onDataZoom(zoomEvent);\n }\n },\n finished: (): void => {\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n mouseover: (params: any): void => {\n if (\n params.componentType === 'series' &&\n params.seriesType === 'scatter' &&\n typeof params.seriesId === 'string' &&\n params.seriesId.startsWith(EXEMPLAR_SERIES_ID_PREFIX)\n ) {\n if (params.data?.exemplar) {\n setHoveredExemplar({\n exemplar: params.data.exemplar,\n seriesLabels: params.data.seriesLabels,\n plottedValue: params.data?.value?.[1] ?? params.data.exemplar.value,\n });\n return;\n }\n }\n setHoveredExemplar(null);\n // Only markPoint (triangles under the X-axis) opens the annotation tooltip.\n // Hovering markLine or anything else keeps the regular TimeSeries tooltip visible\n // and clears any stale hovered annotation (mouseout is sometimes missed by ECharts).\n if (annotations && params.componentType === 'markPoint' && params.data?.annotationIndex !== undefined) {\n const matchedAnnotation = annotations[params.data.annotationIndex] || null;\n if (matchedAnnotation) {\n setHoveredAnnotation(matchedAnnotation);\n return;\n }\n }\n setHoveredAnnotation(null);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n mouseout: (params: any): void => {\n if (\n params.componentType === 'series' &&\n params.seriesType === 'scatter' &&\n typeof params.seriesId === 'string' &&\n params.seriesId.startsWith(EXEMPLAR_SERIES_ID_PREFIX)\n ) {\n setHoveredExemplar(null);\n return;\n }\n if (\n annotations &&\n params.componentType === 'markPoint' &&\n params.data?.annotationIndex !== undefined &&\n annotations\n ) {\n // Only clear if the mouseout corresponds to the currently hovered annotation, so that\n // a quick move from one markPoint to another isn't cancelled by a late mouseout event.\n const leaving = annotations[params.data.annotationIndex] || null;\n setHoveredAnnotation((current) => (current === leaving ? null : current));\n }\n },\n globalout: (): void => {\n if (annotations) {\n // Cursor left the chart canvas — guarantee the annotation tooltip is dismissed.\n setHoveredAnnotation(null);\n }\n setHoveredExemplar(null);\n },\n };\n }, [annotations, onDataZoom]);\n\n // Generate annotation series for ECharts markArea (range), markLine (point), and markPoint (markers under X-axis)\n const annotationSeries = useMemo(() => buildAnnotationSeries(annotations), [annotations]);\n\n const preparedExemplarSeries = useMemo(() => exemplars?.map(getExemplarSeries) ?? [], [exemplars]);\n const exemplarSeries = useMemo(() => {\n const visibleIds = new Set(seriesMapping.map((series) => `${EXEMPLAR_SERIES_ID_PREFIX}${series.id}`));\n return preparedExemplarSeries.filter((series) => visibleIds.has(String(series.id)));\n }, [preparedExemplarSeries, seriesMapping]);\n\n const { noDataOption } = chartsTheme;\n\n // Reuse the dataset when pinning a crosshair or updating annotations/axes.\n const dataset = useMemo<DatasetOption[]>(\n () =>\n data?.map((series, index) => ({\n id: index,\n dimensions: ['time', 'value'],\n // ECharts treats null as missing data; no per-point conversion/copy is needed.\n source: series.values,\n })) ?? [],\n [data],\n );\n\n const option: EChartsCoreOption = useMemo(() => {\n // The \"chart\" `noDataVariant` is only used when the `timeSeries` is an\n // empty array because a `null` value will throw an error.\n if (data === null || (data.length === 0 && noDataVariant === 'message')) return noDataOption;\n\n const updatedSeriesMapping =\n enablePinning && pinnedCrosshair !== null\n ? [...seriesMapping, pinnedCrosshair, ...annotationSeries, ...exemplarSeries]\n : [...seriesMapping, ...annotationSeries, ...exemplarSeries];\n\n const option: EChartsCoreOption = {\n dataset: dataset,\n series: updatedSeriesMapping,\n xAxis: {\n type: 'time',\n min: timeScale.startMs,\n max: timeScale.endMs,\n axisLabel: {\n hideOverlap: true,\n formatter: getTimezoneAwareAxisFormatter(timeScale.rangeMs ?? 0),\n },\n axisPointer: {\n snap: false, // important so shared crosshair does not lag\n },\n },\n // If yAxis is already an array (multiple Y axes), use it directly; otherwise use getFormattedAxis\n yAxis: Array.isArray(yAxis) ? yAxis : getFormattedAxis(yAxis, format),\n animation: false,\n tooltip: {\n show: true,\n // ECharts tooltip content hidden by default since we use custom tooltip instead.\n // Stacked bar uses ECharts tooltip so subgroup data shows correctly.\n showContent: isStackedBar,\n trigger: isStackedBar ? 'item' : 'axis',\n appendToBody: isStackedBar,\n },\n // https://echarts.apache.org/en/option.html#axisPointer\n axisPointer: {\n type: 'line',\n z: 0, // ensure point symbol shows on top of dashed line\n triggerEmphasis: false, // https://github.com/apache/echarts/issues/18495\n triggerTooltip: false,\n snap: false, // xAxis.axisPointer.snap takes priority\n },\n toolbox: {\n feature: {\n dataZoom: {\n icon: null, // https://stackoverflow.com/a/67684076/17575201\n yAxisIndex: 'none',\n },\n },\n },\n grid,\n };\n\n if (__experimentalEChartsOptionsOverride) {\n return __experimentalEChartsOptionsOverride(option);\n }\n\n return option;\n }, [\n data,\n dataset,\n seriesMapping,\n annotationSeries,\n exemplarSeries,\n timeScale,\n yAxis,\n format,\n grid,\n noDataOption,\n __experimentalEChartsOptionsOverride,\n noDataVariant,\n isStackedBar,\n enablePinning,\n pinnedCrosshair,\n getTimezoneAwareAxisFormatter,\n ]);\n\n // Update adjacent charts so tooltip is unpinned when current chart is clicked.\n useEffect(() => {\n // Only allow pinning one tooltip at a time, subsequent tooltip click unpins previous.\n // Multiple tooltips can only be pinned if Ctrl or Cmd key is pressed while clicking.\n const multipleTooltipsPinned = tooltipPinnedCoords !== null && lastTooltipPinnedCoords !== null;\n if (multipleTooltipsPinned) {\n if (!isEqual(lastTooltipPinnedCoords, tooltipPinnedCoords)) {\n setTooltipPinnedCoords(null);\n if (tooltipPinnedCoords !== null && pinnedCrosshair !== null) {\n setPinnedCrosshair(null);\n }\n }\n }\n // A pinned exemplar tooltip is also unpinned when a tooltip is pinned in another chart,\n // unless it is the one just pinned by this chart at these exact coordinates.\n if (\n pinnedExemplarPos !== null &&\n lastTooltipPinnedCoords !== null &&\n !isEqual(lastTooltipPinnedCoords, pinnedExemplarPos)\n ) {\n setPinnedExemplar(null);\n setPinnedExemplarPos(null);\n }\n // tooltipPinnedCoords CANNOT be in dep array or tooltip pinning breaks in the current chart's onClick\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [lastTooltipPinnedCoords, seriesMapping]);\n\n return (\n <Box\n ref={containerRef}\n style={{ height }}\n // onContextMenu={(e) => {\n // // TODO: confirm tooltip pinning works correctly on Windows, should e.preventDefault() be added here\n // e.preventDefault(); // Prevent the default behaviour when right clicked\n // }}\n onClick={(e) => {\n // Allows user to opt-in to multi tooltip pinning when Ctrl or Cmd key held down\n const isControlKeyPressed = e.ctrlKey || e.metaKey;\n if (isControlKeyPressed) {\n e.preventDefault();\n }\n\n // If clicking while hovering an exemplar marker, toggle the exemplar tooltip pin\n // instead of pinning the TimeChartTooltip. Pinning an exemplar tooltip unpins the\n // pinned TimeChartTooltip, so only one tooltip stays pinned at a time unless\n // Ctrl or Cmd is held down.\n if (hoveredExemplar !== null && e.target instanceof HTMLCanvasElement) {\n const pinnedPos: CursorCoordinates = {\n page: { x: e.pageX, y: e.pageY },\n client: { x: e.clientX, y: e.clientY },\n plotCanvas: { x: e.nativeEvent.offsetX, y: e.nativeEvent.offsetY },\n target: e.target,\n };\n const isUnpinClick = pinnedExemplar !== null && pinnedExemplar.exemplar === hoveredExemplar.exemplar;\n // Compute the next state first and call the setters separately: updater functions\n // may run more than once (e.g. StrictMode), so they must stay side-effect free.\n setPinnedExemplar(isUnpinClick ? null : hoveredExemplar);\n setPinnedExemplarPos(isUnpinClick ? null : pinnedPos);\n if (!isUnpinClick && !isControlKeyPressed) {\n // Unpin the pinned TimeChartTooltip and let adjacent charts know a tooltip is\n // pinned at these coordinates, so only one tooltip is pinned at a time.\n setTooltipPinnedCoords(null);\n setPinnedCrosshair(null);\n setLastTooltipPinnedCoords(pinnedPos);\n }\n return;\n }\n\n // Unpin a pinned exemplar tooltip when clicking elsewhere on the chart canvas,\n // so the same click can pin the TimeChartTooltip instead. Ctrl or Cmd keeps both.\n if (pinnedExemplar !== null && !isControlKeyPressed && e.target instanceof HTMLCanvasElement) {\n setPinnedExemplar(null);\n setPinnedExemplarPos(null);\n }\n\n // If clicking while hovering an annotation, toggle the annotation tooltip pin\n // instead of pinning the TimeChartTooltip, so pinned TimeChartTooltip is preserved.\n if (hoveredAnnotation !== null && e.target instanceof HTMLCanvasElement) {\n const pinnedPos: CursorCoordinates = {\n page: { x: e.pageX, y: e.pageY },\n client: { x: e.clientX, y: e.clientY },\n plotCanvas: { x: e.nativeEvent.offsetX, y: e.nativeEvent.offsetY },\n target: e.target,\n };\n setPinnedAnnotation((current) => {\n if (current === hoveredAnnotation) {\n setPinnedAnnotationPos(null);\n return null;\n }\n setPinnedAnnotationPos(pinnedPos);\n return hoveredAnnotation;\n });\n return;\n }\n\n // Determine where on chart canvas to plot pinned crosshair as markLine.\n const pointInGrid = getPointInGrid(e.nativeEvent.offsetX, e.nativeEvent.offsetY, chartRef.current);\n if (pointInGrid === null) {\n return;\n }\n\n // Pin and unpin when clicking on chart canvas but not tooltip text.\n if (isPinningEnabled && e.target instanceof HTMLCanvasElement) {\n // Pin tooltip and update shared charts context to remember these coordinates.\n const pinnedPos: CursorCoordinates = {\n page: {\n x: e.pageX,\n y: e.pageY,\n },\n client: {\n x: e.clientX,\n y: e.clientY,\n },\n plotCanvas: {\n x: e.nativeEvent.offsetX,\n y: e.nativeEvent.offsetY,\n },\n target: e.target,\n };\n\n setTooltipPinnedCoords((current) => {\n if (current === null) {\n return pinnedPos;\n } else {\n setPinnedCrosshair(null);\n return null;\n }\n });\n\n setPinnedCrosshair((current) => {\n // Only add pinned crosshair line series when there is not one already in seriesMapping.\n if (current === null) {\n const cursorX = pointInGrid[0];\n\n // Only need to loop through first dataset source since getCommonTimeScale ensures xAxis timestamps are consistent\n const firstTimeSeriesValues = data[0]?.values;\n const closestTimestamp = getClosestTimestamp(firstTimeSeriesValues, cursorX);\n\n // Crosshair snaps to nearest timestamp since cursor may be slightly to left or right\n const pinnedCrosshair = merge({}, DEFAULT_PINNED_CROSSHAIR, {\n markLine: {\n data: [\n {\n xAxis: closestTimestamp,\n },\n ],\n },\n } as LineSeriesOption);\n return pinnedCrosshair;\n } else {\n // Clear previously set pinned crosshair\n return null;\n }\n });\n\n if (!isControlKeyPressed) {\n setLastTooltipPinnedCoords(pinnedPos);\n }\n }\n }}\n onMouseDown={(e) => {\n const { clientX } = e;\n setIsDragging(true);\n setStartX(clientX);\n }}\n onMouseMove={(e) => {\n // Allow clicking inside tooltip to copy labels.\n if (!(e.target instanceof HTMLCanvasElement)) {\n return;\n }\n const { clientX } = e;\n // ECharts does not reliably emit mouseout when the cursor moves off an exemplar marker\n // onto the plain plot area, which would keep the exemplar tooltip stuck on screen and\n // hide the regular TimeChartTooltip. Clear the hovered exemplar as soon as the cursor\n // is no longer within its marker, so the next hover can take over.\n setHoveredExemplar((current) => {\n if (current === null || chartRef.current === undefined) return current;\n let markerPixel: number[] | undefined;\n try {\n // Use the plotted value so negated markers (negativeY) are tracked correctly.\n markerPixel = chartRef.current.convertToPixel('grid', [current.exemplar.timestamp, current.plottedValue]);\n } catch {\n // Coordinates cannot be resolved (e.g. grid not ready yet), keep the current hover.\n return current;\n }\n const [markerPixelX, markerPixelY] = markerPixel ?? [];\n if (markerPixelX === undefined || markerPixelY === undefined) return current;\n const distance = Math.hypot(e.nativeEvent.offsetX - markerPixelX, e.nativeEvent.offsetY - markerPixelY);\n return distance <= EXEMPLAR_HOVER_RADIUS ? current : null;\n });\n if (isDragging) {\n const deltaX = clientX - startX;\n if (deltaX > 0) {\n // Hide tooltip when user drags to zoom.\n setShowTooltip(false);\n }\n }\n }}\n onMouseUp={() => {\n setIsDragging(false);\n setStartX(0);\n setShowTooltip(true);\n }}\n onMouseLeave={() => {\n if (tooltipPinnedCoords === null) {\n setShowTooltip(false);\n }\n // Defensive: clear hovered annotation and exemplar in case ECharts missed a mouseout event.\n setHoveredAnnotation(null);\n setHoveredExemplar(null);\n if (chartRef.current !== undefined) {\n clearHighlightedSeries(chartRef.current);\n }\n }}\n onMouseEnter={() => {\n setShowTooltip(true);\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n }}\n onDoubleClick={(e) => {\n setTooltipPinnedCoords(null);\n // either dispatch ECharts restore action to return to orig state or allow consumer to define behavior\n if (onDoubleClick === undefined) {\n if (chartRef.current !== undefined) {\n restoreChart(chartRef.current);\n }\n } else {\n onDoubleClick(e);\n }\n }}\n >\n {/* Allows overrides prop to hide custom tooltip and use the ECharts option.tooltip instead.\n Keep the time chart tooltip visible when pinned even if user hovers an annotation or exemplar,\n but do not show the mouse-following tooltip on top of a pinned exemplar tooltip. */}\n {showTooltip === true &&\n (tooltipPinnedCoords !== null ||\n (pinnedExemplar === null && hoveredAnnotation === null && hoveredExemplar === null)) &&\n (option.tooltip as TooltipComponentOption)?.showContent === false &&\n tooltipConfig.hidden !== true && (\n <TimeChartTooltip\n containerId={chartsTheme.tooltipPortalContainerId}\n chartRef={chartRef}\n data={data}\n seriesMapping={seriesMapping}\n wrapLabels={tooltipConfig.wrapLabels}\n enablePinning={isPinningEnabled}\n pinnedPos={tooltipPinnedCoords}\n format={format}\n seriesFormatMap={seriesFormatMap}\n onUnpinClick={() => {\n // Unpins tooltip when clicking Pin icon in TooltipHeader.\n setTooltipPinnedCoords(null);\n // Clear previously set pinned crosshair.\n setPinnedCrosshair(null);\n }}\n />\n )}\n {/* Pinned exemplar takes priority over hovered. While a TimeChartTooltip is pinned, the\n mouse-following exemplar tooltip is not rendered so it does not appear on top of it. */}\n {(pinnedExemplar !== null || (hoveredExemplar !== null && tooltipPinnedCoords === null)) && (\n <ExemplarMetadataTooltip\n exemplar={(pinnedExemplar ?? hoveredExemplar)!.exemplar}\n seriesLabels={(pinnedExemplar ?? hoveredExemplar)!.seriesLabels}\n containerId={chartsTheme.tooltipPortalContainerId}\n format={format}\n pinnedPos={pinnedExemplar !== null ? pinnedExemplarPos : null}\n enablePinning={isPinningEnabled}\n onUnpinClick={() => {\n setPinnedExemplar(null);\n setPinnedExemplarPos(null);\n }}\n />\n )}\n {/* Pinned annotation takes priority over hovered. */}\n {(pinnedAnnotation ?? hoveredAnnotation) && (\n <AnnotationTooltip\n annotation={(pinnedAnnotation ?? hoveredAnnotation) as TimeSeriesAnnotation}\n containerId={chartsTheme.tooltipPortalContainerId}\n formatWithUserTimeZone={formatWithUserTimeZone}\n pinnedPos={pinnedAnnotation !== null ? pinnedAnnotationPos : null}\n enablePinning={isPinningEnabled}\n onUnpinClick={() => {\n setPinnedAnnotation(null);\n setPinnedAnnotationPos(null);\n }}\n />\n )}\n <EChart\n sx={CHART_SX}\n option={option}\n theme={chartsTheme.echartsTheme}\n onEvents={handleEvents}\n _instance={chartRef}\n syncGroup={enableSyncGrouping ? syncGroup : undefined}\n />\n </Box>\n );\n});\n"],"names":["Box","clearHighlightedSeries","DEFAULT_PINNED_CROSSHAIR","DEFAULT_TOOLTIP_CONFIG","EChart","enableDataZoom","ExemplarMetadataTooltip","getClosestTimestamp","getCommonTimeScale","getFormattedAxis","getPointInGrid","restoreChart","TimeChartTooltip","useChartsContext","useTimeZone","LineChart","EChartsLineChart","BarChart","EChartsBarChart","ScatterChart","EChartsScatterChart","GridComponent","DatasetComponent","DataZoomComponent","MarkAreaComponent","MarkLineComponent","MarkPointComponent","TitleComponent","ToolboxComponent","TooltipComponent","use","registerECharts","CanvasRenderer","isEqual","merge","forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useRef","useState","useResizeObserver","AnnotationTooltip","buildAnnotationSeries","EXEMPLAR_SERIES_ID_PREFIX","EXEMPLAR_SYMBOL_SIZE","getExemplarSeries","createTimezoneAwareAxisFormatter","EXEMPLAR_HOVER_RADIUS","Math","SQRT2","CHART_SX","width","height","TimeSeriesChartBase","TimeChart","data","seriesMapping","exemplars","annotations","timeScale","timeScaleProp","yAxis","format","seriesFormatMap","grid","isStackedBar","tooltipConfig","noDataVariant","syncGroup","onDataZoom","onDoubleClick","__experimentalEChartsOptionsOverride","ref","chartsTheme","enablePinning","enableSyncGrouping","lastTooltipPinnedCoords","setLastTooltipPinnedCoords","isPinningEnabled","chartRef","showTooltip","setShowTooltip","tooltipPinnedCoords","setTooltipPinnedCoords","pinnedCrosshair","setPinnedCrosshair","isDragging","setIsDragging","startX","setStartX","hoveredAnnotation","setHoveredAnnotation","pinnedAnnotation","setPinnedAnnotation","hoveredExemplar","setHoveredExemplar","pinnedExemplar","setPinnedExemplar","pinnedExemplarPos","setPinnedExemplarPos","pinnedAnnotationPos","setPinnedAnnotationPos","timeZone","formatWithUserTimeZone","getTimezoneAwareAxisFormatter","rangeMs","commonTimeScale","today","Date","pastDate","setFullYear","getFullYear","startMs","getTime","endMs","stepMs","handleResize","containerHeight","chart","current","getWidth","getHeight","resize","containerRef","onResize","highlightSeries","name","dispatchAction","type","seriesId","handleEvents","datazoom","params","undefined","setTimeout","batch","xAxisStartValue","startValue","xAxisEndValue","endValue","zoomEvent","start","end","finished","mouseover","componentType","seriesType","startsWith","exemplar","seriesLabels","plottedValue","value","annotationIndex","matchedAnnotation","mouseout","leaving","globalout","annotationSeries","preparedExemplarSeries","map","exemplarSeries","visibleIds","Set","series","id","filter","has","String","noDataOption","dataset","index","dimensions","source","values","option","length","updatedSeriesMapping","xAxis","min","max","axisLabel","hideOverlap","formatter","axisPointer","snap","Array","isArray","animation","tooltip","show","showContent","trigger","appendToBody","z","triggerEmphasis","triggerTooltip","toolbox","feature","dataZoom","icon","yAxisIndex","multipleTooltipsPinned","style","onClick","e","isControlKeyPressed","ctrlKey","metaKey","preventDefault","target","HTMLCanvasElement","pinnedPos","page","x","pageX","y","pageY","client","clientX","clientY","plotCanvas","nativeEvent","offsetX","offsetY","isUnpinClick","pointInGrid","cursorX","firstTimeSeriesValues","closestTimestamp","markLine","onMouseDown","onMouseMove","markerPixel","convertToPixel","timestamp","markerPixelX","markerPixelY","distance","hypot","deltaX","onMouseUp","onMouseLeave","onMouseEnter","hidden","containerId","tooltipPortalContainerId","wrapLabels","onUnpinClick","annotation","sx","theme","echartsTheme","onEvents","_instance"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,GAAG,QAAQ,gBAAgB;AAWpC,SACEC,sBAAsB,EACtBC,wBAAwB,EACxBC,sBAAsB,EACtBC,MAAM,EACNC,cAAc,EACdC,uBAAuB,EACvBC,mBAAmB,EACnBC,kBAAkB,EAClBC,gBAAgB,EAChBC,cAAc,EACdC,YAAY,EACZC,gBAAgB,EAChBC,gBAAgB,EAChBC,WAAW,QACN,yBAAyB;AAUhC,SACEC,aAAaC,gBAAgB,EAC7BC,YAAYC,eAAe,EAC3BC,gBAAgBC,mBAAmB,QAC9B,iBAAiB;AACxB,SACEC,aAAa,EACbC,gBAAgB,EA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gBACpC5K,eAAeI;gBACfqI,WAAWjI;gBACXpB,QAAQA;gBACRC,iBAAiBA;gBACjBwL,cAAc;oBACZ,0DAA0D;oBAC1DpK,uBAAuB;oBACvB,yCAAyC;oBACzCE,mBAAmB;gBACrB;;YAKJW,CAAAA,mBAAmB,QAASF,oBAAoB,QAAQZ,wBAAwB,IAAI,mBACpF,KAAC9E;gBACCgJ,UAAU,AAACpD,CAAAA,kBAAkBF,eAAc,EAAIsD,QAAQ;gBACvDC,cAAc,AAACrD,CAAAA,kBAAkBF,eAAc,EAAIuD,YAAY;gBAC/D+F,aAAa3K,YAAY4K,wBAAwB;gBACjDvL,QAAQA;gBACRqJ,WAAWnH,mBAAmB,OAAOE,oBAAoB;gBACzDxB,eAAeI;gBACfyK,cAAc;oBACZtJ,kBAAkB;oBAClBE,qBAAqB;gBACvB;;YAIFP,CAAAA,oBAAoBF,iBAAgB,mBACpC,KAACjD;gBACC+M,YAAa5J,oBAAoBF;gBACjC0J,aAAa3K,YAAY4K,wBAAwB;gBACjD9I,wBAAwBA;gBACxB4G,WAAWvH,qBAAqB,OAAOQ,sBAAsB;gBAC7D1B,eAAeI;gBACfyK,cAAc;oBACZ1J,oBAAoB;oBACpBQ,uBAAuB;gBACzB;;0BAGJ,KAACnG;gBACCuP,IAAIvM;gBACJ4H,QAAQA;gBACR4E,OAAOjL,YAAYkL,YAAY;gBAC/BC,UAAU1H;gBACV2H,WAAW9K;gBACXX,WAAWO,qBAAqBP,YAAYiE;;;;AAIpD,GAAG"}
@@ -3,5 +3,7 @@ import type { TimeSeriesData } from '@perses-dev/spec';
3
3
  import type { ReactElement } from 'react';
4
4
  import type { TimeSeriesChartOptions } from './time-series-chart-model';
5
5
  export type TimeSeriesChartProps = PanelProps<TimeSeriesChartOptions, TimeSeriesData>;
6
- export declare function TimeSeriesChartPanel(props: TimeSeriesChartProps): ReactElement | null;
6
+ declare function TimeSeriesChartPanelComponent(props: TimeSeriesChartProps): ReactElement | null;
7
+ export declare const TimeSeriesChartPanel: import("react").MemoExoticComponent<typeof TimeSeriesChartPanelComponent>;
8
+ export {};
7
9
  //# sourceMappingURL=TimeSeriesChartPanel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TimeSeriesChartPanel.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesChartPanel.tsx"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAE,UAAU,EAAmB,MAAM,2BAA2B,CAAC;AAQ7E,OAAO,KAAK,EAAc,cAAc,EAAwB,MAAM,kBAAkB,CAAC;AAGzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAE,sBAAsB,EAAwB,MAAM,2BAA2B,CAAC;AAc9F,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,sBAAsB,EAAE,cAAc,CAAC,CAAC;AAWtF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,GAAG,IAAI,CA+crF"}
1
+ {"version":3,"file":"TimeSeriesChartPanel.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesChartPanel.tsx"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAE,UAAU,EAAmB,MAAM,2BAA2B,CAAC;AAQ7E,OAAO,KAAK,EAAsB,cAAc,EAAwB,MAAM,kBAAkB,CAAC;AAGjG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAexE,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,sBAAsB,EAAE,cAAc,CAAC,CAAC;AAuBtF,iBAAS,6BAA6B,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,GAAG,IAAI,CAufvF;AAKD,eAAO,MAAM,oBAAoB,2EAYhC,CAAC"}