@perses-dev/timeseries-chart-plugin 0.12.1 → 0.13.0-beta.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.
Files changed (189) hide show
  1. package/__mf/css/async/826.85c2cbf6.css +1 -0
  2. package/__mf/font/inter-cyrillic-300-normal.432f2b21.woff +0 -0
  3. package/__mf/font/inter-cyrillic-300-normal.9da91009.woff2 +0 -0
  4. package/__mf/font/inter-cyrillic-400-normal.372704ff.woff2 +0 -0
  5. package/__mf/font/inter-cyrillic-400-normal.a6b6ef6f.woff +0 -0
  6. package/__mf/font/inter-cyrillic-500-normal.7c15bba8.woff2 +0 -0
  7. package/__mf/font/inter-cyrillic-500-normal.b9f8c929.woff +0 -0
  8. package/__mf/font/inter-cyrillic-600-normal.2f42892a.woff2 +0 -0
  9. package/__mf/font/inter-cyrillic-600-normal.c3987adc.woff +0 -0
  10. package/__mf/font/inter-cyrillic-700-normal.93eba3c3.woff +0 -0
  11. package/__mf/font/inter-cyrillic-700-normal.e9e5b2dc.woff2 +0 -0
  12. package/__mf/font/inter-cyrillic-900-normal.f285bd7a.woff2 +0 -0
  13. package/__mf/font/inter-cyrillic-900-normal.ffbd8a3a.woff +0 -0
  14. package/__mf/font/inter-cyrillic-ext-300-normal.95bb9038.woff2 +0 -0
  15. package/__mf/font/inter-cyrillic-ext-300-normal.cfc143a9.woff +0 -0
  16. package/__mf/font/inter-cyrillic-ext-400-normal.2a31c04b.woff +0 -0
  17. package/__mf/font/inter-cyrillic-ext-400-normal.f572b170.woff2 +0 -0
  18. package/__mf/font/inter-cyrillic-ext-500-normal.5a6bb1da.woff +0 -0
  19. package/__mf/font/inter-cyrillic-ext-500-normal.fe0d9b14.woff2 +0 -0
  20. package/__mf/font/inter-cyrillic-ext-600-normal.ecbdecad.woff +0 -0
  21. package/__mf/font/inter-cyrillic-ext-600-normal.f7b3c15b.woff2 +0 -0
  22. package/__mf/font/inter-cyrillic-ext-700-normal.4b4022a6.woff +0 -0
  23. package/__mf/font/inter-cyrillic-ext-700-normal.74b516d2.woff2 +0 -0
  24. package/__mf/font/inter-cyrillic-ext-900-normal.9970ddb5.woff +0 -0
  25. package/__mf/font/inter-cyrillic-ext-900-normal.a0d59adc.woff2 +0 -0
  26. package/__mf/font/inter-greek-300-normal.0d7be683.woff2 +0 -0
  27. package/__mf/font/inter-greek-300-normal.8f0b988e.woff +0 -0
  28. package/__mf/font/inter-greek-400-normal.cc58c11b.woff +0 -0
  29. package/__mf/font/inter-greek-400-normal.d7020e3c.woff2 +0 -0
  30. package/__mf/font/inter-greek-500-normal.d9a33207.woff +0 -0
  31. package/__mf/font/inter-greek-500-normal.f41f43db.woff2 +0 -0
  32. package/__mf/font/inter-greek-600-normal.4ec0c1c1.woff +0 -0
  33. package/__mf/font/inter-greek-600-normal.cc532937.woff2 +0 -0
  34. package/__mf/font/inter-greek-700-normal.5ec6c758.woff +0 -0
  35. package/__mf/font/inter-greek-700-normal.97f0eeeb.woff2 +0 -0
  36. package/__mf/font/inter-greek-900-normal.46b66369.woff2 +0 -0
  37. package/__mf/font/inter-greek-900-normal.9ae3a3c5.woff +0 -0
  38. package/__mf/font/inter-greek-ext-300-normal.10247a66.woff2 +0 -0
  39. package/__mf/font/inter-greek-ext-300-normal.4668e5cb.woff +0 -0
  40. package/__mf/font/inter-greek-ext-400-normal.4ce1df5d.woff2 +0 -0
  41. package/__mf/font/inter-greek-ext-400-normal.88ede1ea.woff +0 -0
  42. package/__mf/font/inter-greek-ext-500-normal.7a4aa726.woff +0 -0
  43. package/__mf/font/inter-greek-ext-500-normal.cbd51e2d.woff2 +0 -0
  44. package/__mf/font/inter-greek-ext-600-normal.089a95ee.woff +0 -0
  45. package/__mf/font/inter-greek-ext-600-normal.1f33d317.woff2 +0 -0
  46. package/__mf/font/inter-greek-ext-700-normal.31f1075d.woff +0 -0
  47. package/__mf/font/inter-greek-ext-700-normal.827cd618.woff2 +0 -0
  48. package/__mf/font/inter-greek-ext-900-normal.531bcee7.woff +0 -0
  49. package/__mf/font/inter-greek-ext-900-normal.8a9b36b9.woff2 +0 -0
  50. package/__mf/font/inter-latin-300-normal.15fb600d.woff2 +0 -0
  51. package/__mf/font/inter-latin-300-normal.6f95f590.woff +0 -0
  52. package/__mf/font/inter-latin-400-normal.2c7a775c.woff +0 -0
  53. package/__mf/font/inter-latin-400-normal.ef6d3f52.woff2 +0 -0
  54. package/__mf/font/inter-latin-500-normal.b7b43ace.woff2 +0 -0
  55. package/__mf/font/inter-latin-500-normal.cb4c8ceb.woff +0 -0
  56. package/__mf/font/inter-latin-600-normal.8fb1a964.woff2 +0 -0
  57. package/__mf/font/inter-latin-600-normal.ce0f5f43.woff +0 -0
  58. package/__mf/font/inter-latin-700-normal.953b7aa5.woff2 +0 -0
  59. package/__mf/font/inter-latin-700-normal.9c21d4dc.woff +0 -0
  60. package/__mf/font/inter-latin-900-normal.2a8028ec.woff2 +0 -0
  61. package/__mf/font/inter-latin-900-normal.fa252135.woff +0 -0
  62. package/__mf/font/inter-latin-ext-300-normal.167cc8c9.woff2 +0 -0
  63. package/__mf/font/inter-latin-ext-300-normal.f695be66.woff +0 -0
  64. package/__mf/font/inter-latin-ext-400-normal.32a25442.woff2 +0 -0
  65. package/__mf/font/inter-latin-ext-400-normal.4edcaace.woff +0 -0
  66. package/__mf/font/inter-latin-ext-500-normal.a19a84a6.woff +0 -0
  67. package/__mf/font/inter-latin-ext-500-normal.d9b491de.woff2 +0 -0
  68. package/__mf/font/inter-latin-ext-600-normal.38b075d8.woff2 +0 -0
  69. package/__mf/font/inter-latin-ext-600-normal.49faa47a.woff +0 -0
  70. package/__mf/font/inter-latin-ext-700-normal.93534b50.woff +0 -0
  71. package/__mf/font/inter-latin-ext-700-normal.b63daa1a.woff2 +0 -0
  72. package/__mf/font/inter-latin-ext-900-normal.0efdb307.woff +0 -0
  73. package/__mf/font/inter-latin-ext-900-normal.9c0fc2c7.woff2 +0 -0
  74. package/__mf/font/inter-vietnamese-300-normal.aad496d8.woff +0 -0
  75. package/__mf/font/inter-vietnamese-300-normal.ad9ef503.woff2 +0 -0
  76. package/__mf/font/inter-vietnamese-400-normal.a9dd2faf.woff +0 -0
  77. package/__mf/font/inter-vietnamese-400-normal.de4fc44f.woff2 +0 -0
  78. package/__mf/font/inter-vietnamese-500-normal.7c0a695f.woff2 +0 -0
  79. package/__mf/font/inter-vietnamese-500-normal.a3a73b95.woff +0 -0
  80. package/__mf/font/inter-vietnamese-600-normal.9d518599.woff2 +0 -0
  81. package/__mf/font/inter-vietnamese-600-normal.c5ce3fcb.woff +0 -0
  82. package/__mf/font/inter-vietnamese-700-normal.bc68b199.woff +0 -0
  83. package/__mf/font/inter-vietnamese-700-normal.faf12809.woff2 +0 -0
  84. package/__mf/font/inter-vietnamese-900-normal.2b782045.woff +0 -0
  85. package/__mf/font/inter-vietnamese-900-normal.e639b65a.woff2 +0 -0
  86. package/__mf/js/TimeSeriesChart.7df900ef.js +7 -0
  87. package/__mf/js/async/121.df4898d6.js +2 -0
  88. package/__mf/js/async/177.56f1be10.js +1 -0
  89. package/__mf/js/async/192.beef3a1a.js +1 -0
  90. package/__mf/js/async/2.c3740bb9.js +1 -0
  91. package/__mf/js/async/235.c24f24f7.js +1 -0
  92. package/__mf/js/async/274.d112354f.js +2 -0
  93. package/__mf/js/async/356.9f551c8a.js +1 -0
  94. package/__mf/js/async/366.084dd32e.js +24 -0
  95. package/__mf/js/async/377.7ec764e5.js +2 -0
  96. package/__mf/js/async/{544.4dd63985.js.LICENSE.txt → 377.7ec764e5.js.LICENSE.txt} +1 -1
  97. package/__mf/js/async/392.2350fb02.js +2 -0
  98. package/__mf/js/async/470.a4fd777e.js +2 -0
  99. package/__mf/js/async/491.6f81cf51.js +1 -0
  100. package/__mf/js/async/558.401fb679.js +1 -0
  101. package/__mf/js/async/587.c12780da.js +1 -0
  102. package/__mf/js/async/588.6662e16a.js +1 -0
  103. package/__mf/js/async/616.52acb1b4.js +1 -0
  104. package/__mf/js/async/702.de247ad8.js +2 -0
  105. package/__mf/js/async/71.84e486c9.js +1 -0
  106. package/__mf/js/async/721.88bf4be4.js +110 -0
  107. package/__mf/js/async/{390.ad50daba.js.LICENSE.txt → 721.88bf4be4.js.LICENSE.txt} +1 -1
  108. package/__mf/js/async/78.91de282a.js +1 -0
  109. package/__mf/js/async/826.c7b150c6.js +7 -0
  110. package/__mf/js/async/{472.fd3069f0.js.LICENSE.txt → 826.c7b150c6.js.LICENSE.txt} +19 -1
  111. package/__mf/js/async/873.9aad328a.js +1 -0
  112. package/__mf/js/async/891.18ba0e56.js +38 -0
  113. package/__mf/js/async/941.c0e2d25e.js +2 -0
  114. package/__mf/js/async/945.1a85358e.js +1 -0
  115. package/__mf/js/async/968.6de5fa7c.js +1 -0
  116. package/__mf/js/async/978.5c14e175.js +1 -0
  117. package/__mf/js/async/__federation_expose_TimeSeriesChart.0329eb0a.js +1 -0
  118. package/__mf/js/async/lib-router.1934857d.js +2 -0
  119. package/__mf/js/main.496219f9.js +7 -0
  120. package/lib/QuerySettingsEditor.d.ts.map +1 -1
  121. package/lib/QuerySettingsEditor.js +179 -167
  122. package/lib/QuerySettingsEditor.js.map +1 -1
  123. package/lib/TimeSeriesChartBase.d.ts.map +1 -1
  124. package/lib/TimeSeriesChartBase.js +12 -10
  125. package/lib/TimeSeriesChartBase.js.map +1 -1
  126. package/lib/cjs/QuerySettingsEditor.js +177 -165
  127. package/lib/cjs/TimeSeriesChartBase.js +10 -8
  128. package/lib/cjs/utils/timezone-formatter.js +48 -0
  129. package/lib/utils/timezone-formatter.d.ts +5 -0
  130. package/lib/utils/timezone-formatter.d.ts.map +1 -0
  131. package/lib/utils/timezone-formatter.js +42 -0
  132. package/lib/utils/timezone-formatter.js.map +1 -0
  133. package/mf-manifest.json +63 -52
  134. package/mf-stats.json +75 -56
  135. package/package.json +3 -3
  136. package/__mf/css/async/442.d3010b86.css +0 -1
  137. package/__mf/css/async/61.d3010b86.css +0 -1
  138. package/__mf/css/async/823.d3010b86.css +0 -1
  139. package/__mf/font/lato-all-300-normal.322bdf14.woff +0 -0
  140. package/__mf/font/lato-all-400-normal.63513b00.woff +0 -0
  141. package/__mf/font/lato-all-700-normal.bb27db94.woff +0 -0
  142. package/__mf/font/lato-all-900-normal.a27049a3.woff +0 -0
  143. package/__mf/font/lato-latin-300-normal.c5195215.woff2 +0 -0
  144. package/__mf/font/lato-latin-400-normal.b7ffde23.woff2 +0 -0
  145. package/__mf/font/lato-latin-700-normal.d5eb20bc.woff2 +0 -0
  146. package/__mf/font/lato-latin-900-normal.d884a71c.woff2 +0 -0
  147. package/__mf/font/lato-latin-ext-300-normal.abcc64a9.woff2 +0 -0
  148. package/__mf/font/lato-latin-ext-400-normal.6ebed106.woff2 +0 -0
  149. package/__mf/font/lato-latin-ext-700-normal.8697d1d5.woff2 +0 -0
  150. package/__mf/font/lato-latin-ext-900-normal.20a2b415.woff2 +0 -0
  151. package/__mf/js/TimeSeriesChart.734ed3ec.js +0 -6
  152. package/__mf/js/async/121.a742c022.js +0 -2
  153. package/__mf/js/async/177.97e14ed0.js +0 -1
  154. package/__mf/js/async/192.30450189.js +0 -1
  155. package/__mf/js/async/2.68ee9e1b.js +0 -1
  156. package/__mf/js/async/235.a53a2591.js +0 -1
  157. package/__mf/js/async/274.8e8950b6.js +0 -2
  158. package/__mf/js/async/356.dee0f34a.js +0 -1
  159. package/__mf/js/async/390.ad50daba.js +0 -110
  160. package/__mf/js/async/392.550376f0.js +0 -2
  161. package/__mf/js/async/470.4c93905a.js +0 -2
  162. package/__mf/js/async/472.fd3069f0.js +0 -7
  163. package/__mf/js/async/489.8bb61ec9.js +0 -1
  164. package/__mf/js/async/491.35fc6280.js +0 -1
  165. package/__mf/js/async/544.4dd63985.js +0 -2
  166. package/__mf/js/async/558.5a41ebcc.js +0 -1
  167. package/__mf/js/async/587.40becf9b.js +0 -1
  168. package/__mf/js/async/588.33924c3f.js +0 -1
  169. package/__mf/js/async/616.6d37f37b.js +0 -1
  170. package/__mf/js/async/634.8646a5de.js +0 -24
  171. package/__mf/js/async/702.5d93a78a.js +0 -2
  172. package/__mf/js/async/71.e481dbdb.js +0 -1
  173. package/__mf/js/async/78.362ece9d.js +0 -1
  174. package/__mf/js/async/867.12a42f78.js +0 -38
  175. package/__mf/js/async/873.11e0e15e.js +0 -1
  176. package/__mf/js/async/941.5331fb70.js +0 -2
  177. package/__mf/js/async/968.2ea36b8a.js +0 -1
  178. package/__mf/js/async/978.844227d5.js +0 -1
  179. package/__mf/js/async/__federation_expose_TimeSeriesChart.54276867.js +0 -1
  180. package/__mf/js/async/lib-router.9730f5e9.js +0 -2
  181. package/__mf/js/main.22e0e85a.js +0 -6
  182. /package/__mf/js/async/{121.a742c022.js.LICENSE.txt → 121.df4898d6.js.LICENSE.txt} +0 -0
  183. /package/__mf/js/async/{274.8e8950b6.js.LICENSE.txt → 274.d112354f.js.LICENSE.txt} +0 -0
  184. /package/__mf/js/async/{634.8646a5de.js.LICENSE.txt → 366.084dd32e.js.LICENSE.txt} +0 -0
  185. /package/__mf/js/async/{392.550376f0.js.LICENSE.txt → 392.2350fb02.js.LICENSE.txt} +0 -0
  186. /package/__mf/js/async/{470.4c93905a.js.LICENSE.txt → 470.a4fd777e.js.LICENSE.txt} +0 -0
  187. /package/__mf/js/async/{702.5d93a78a.js.LICENSE.txt → 702.de247ad8.js.LICENSE.txt} +0 -0
  188. /package/__mf/js/async/{941.5331fb70.js.LICENSE.txt → 941.c0e2d25e.js.LICENSE.txt} +0 -0
  189. /package/__mf/js/async/{lib-router.9730f5e9.js.LICENSE.txt → lib-router.1934857d.js.LICENSE.txt} +0 -0
@@ -11,17 +11,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- import { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
14
+ import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
15
15
  import { Box } from '@mui/material';
16
16
  import merge from 'lodash/merge';
17
17
  import isEqual from 'lodash/isEqual';
18
- import { toZonedTime } from 'date-fns-tz';
19
18
  import { getCommonTimeScale } from '@perses-dev/core';
20
19
  import { use } from 'echarts/core';
21
20
  import { LineChart as EChartsLineChart, BarChart as EChartsBarChart } from 'echarts/charts';
22
21
  import { GridComponent, DatasetComponent, DataZoomComponent, MarkAreaComponent, MarkLineComponent, MarkPointComponent, TitleComponent, ToolboxComponent, TooltipComponent } from 'echarts/components';
23
22
  import { CanvasRenderer } from 'echarts/renderers';
24
- import { clearHighlightedSeries, DEFAULT_PINNED_CROSSHAIR, DEFAULT_TOOLTIP_CONFIG, EChart, enableDataZoom, getClosestTimestamp, getFormattedAxis, getFormattedAxisLabel, getPointInGrid, restoreChart, TimeChartTooltip, useChartsContext, useTimeZone } from '@perses-dev/components';
23
+ import { clearHighlightedSeries, DEFAULT_PINNED_CROSSHAIR, DEFAULT_TOOLTIP_CONFIG, EChart, enableDataZoom, getClosestTimestamp, getFormattedAxis, getPointInGrid, restoreChart, TimeChartTooltip, useChartsContext, useTimeZone } from '@perses-dev/components';
24
+ import { createTimezoneAwareAxisFormatter } from './utils/timezone-formatter';
25
25
  use([
26
26
  EChartsLineChart,
27
27
  EChartsBarChart,
@@ -46,6 +46,9 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
46
46
  const [isDragging, setIsDragging] = useState(false);
47
47
  const [startX, setStartX] = useState(0);
48
48
  const { timeZone } = useTimeZone();
49
+ const getTimezoneAwareAxisFormatter = useCallback((rangeMs)=>createTimezoneAwareAxisFormatter(rangeMs, timeZone), [
50
+ timeZone
51
+ ]);
49
52
  let timeScale;
50
53
  if (timeScaleProp === undefined) {
51
54
  const commonTimeScale = getCommonTimeScale(data);
@@ -127,12 +130,11 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
127
130
  // Utilizes ECharts dataset so raw data is separate from series option style properties
128
131
  // https://apache.github.io/echarts-handbook/en/concepts/dataset/
129
132
  const dataset = [];
130
- const isLocalTimeZone = timeZone === 'local';
131
133
  data.map((d, index)=>{
132
134
  const values = d.values.map(([timestamp, value])=>{
133
135
  const val = value === null ? '-' : value; // echarts use '-' to represent null data
134
136
  return [
135
- isLocalTimeZone ? timestamp : toZonedTime(timestamp, timeZone),
137
+ timestamp,
136
138
  val
137
139
  ];
138
140
  });
@@ -156,11 +158,11 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
156
158
  series: updatedSeriesMapping,
157
159
  xAxis: {
158
160
  type: 'time',
159
- min: isLocalTimeZone ? timeScale.startMs : toZonedTime(timeScale.startMs, timeZone),
160
- max: isLocalTimeZone ? timeScale.endMs : toZonedTime(timeScale.endMs, timeZone),
161
+ min: timeScale.startMs,
162
+ max: timeScale.endMs,
161
163
  axisLabel: {
162
164
  hideOverlap: true,
163
- formatter: getFormattedAxisLabel(timeScale.rangeMs ?? 0)
165
+ formatter: getTimezoneAwareAxisFormatter(timeScale.rangeMs ?? 0)
164
166
  },
165
167
  axisPointer: {
166
168
  snap: false
@@ -209,10 +211,10 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
209
211
  noDataOption,
210
212
  __experimentalEChartsOptionsOverride,
211
213
  noDataVariant,
212
- timeZone,
213
214
  isStackedBar,
214
215
  enablePinning,
215
- pinnedCrosshair
216
+ pinnedCrosshair,
217
+ getTimezoneAwareAxisFormatter
216
218
  ]);
217
219
  // Update adjacent charts so tooltip is unpinned when current chart is clicked.
218
220
  useEffect(()=>{
@@ -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 { forwardRef, MouseEvent, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';\nimport { Box } from '@mui/material';\nimport merge from 'lodash/merge';\nimport isEqual from 'lodash/isEqual';\nimport { toZonedTime } from 'date-fns-tz';\nimport { getCommonTimeScale, TimeScale, FormatOptions, TimeSeries } from '@perses-dev/core';\nimport type {\n EChartsCoreOption,\n GridComponentOption,\n LineSeriesOption,\n YAXisComponentOption,\n TooltipComponentOption,\n} from 'echarts';\nimport { ECharts as EChartsInstance, use } from 'echarts/core';\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 { CanvasRenderer } from 'echarts/renderers';\nimport {\n ChartInstance,\n ChartInstanceFocusOpts,\n clearHighlightedSeries,\n CursorCoordinates,\n DEFAULT_PINNED_CROSSHAIR,\n DEFAULT_TOOLTIP_CONFIG,\n EChart,\n enableDataZoom,\n getClosestTimestamp,\n getFormattedAxis,\n getFormattedAxisLabel,\n getPointInGrid,\n OnEventsType,\n restoreChart,\n TimeChartSeriesMapping,\n TimeChartTooltip,\n TooltipConfig,\n useChartsContext,\n useTimeZone,\n ZoomEventData,\n} from '@perses-dev/components';\nimport { DatasetOption } from 'echarts/types/dist/shared';\n\nuse([\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 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 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 { timeZone } = useTimeZone();\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 };\n }, [onDataZoom, setTooltipPinnedCoords]);\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 const isLocalTimeZone = timeZone === 'local';\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 [isLocalTimeZone ? timestamp : toZonedTime(timestamp, timeZone), val];\n });\n dataset.push({ id: index, source: [...values], dimensions: ['time', 'value'] });\n });\n\n const updatedSeriesMapping =\n enablePinning && pinnedCrosshair !== null ? [...seriesMapping, pinnedCrosshair] : seriesMapping;\n\n const option: EChartsCoreOption = {\n dataset: dataset,\n series: updatedSeriesMapping,\n xAxis: {\n type: 'time',\n min: isLocalTimeZone ? timeScale.startMs : toZonedTime(timeScale.startMs, timeZone),\n max: isLocalTimeZone ? timeScale.endMs : toZonedTime(timeScale.endMs, timeZone),\n axisLabel: {\n hideOverlap: true,\n formatter: getFormattedAxisLabel(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 timeScale,\n yAxis,\n format,\n grid,\n noDataOption,\n __experimentalEChartsOptionsOverride,\n noDataVariant,\n timeZone,\n isStackedBar,\n enablePinning,\n pinnedCrosshair,\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 // 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 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 {showTooltip === true &&\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 <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":["forwardRef","useEffect","useImperativeHandle","useMemo","useRef","useState","Box","merge","isEqual","toZonedTime","getCommonTimeScale","use","LineChart","EChartsLineChart","BarChart","EChartsBarChart","GridComponent","DatasetComponent","DataZoomComponent","MarkAreaComponent","MarkLineComponent","MarkPointComponent","TitleComponent","ToolboxComponent","TooltipComponent","CanvasRenderer","clearHighlightedSeries","DEFAULT_PINNED_CROSSHAIR","DEFAULT_TOOLTIP_CONFIG","EChart","enableDataZoom","getClosestTimestamp","getFormattedAxis","getFormattedAxisLabel","getPointInGrid","restoreChart","TimeChartTooltip","useChartsContext","useTimeZone","TimeSeriesChartBase","TimeChart","height","data","seriesMapping","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","timeZone","undefined","commonTimeScale","today","Date","pastDate","setFullYear","getFullYear","todayMs","getTime","pastDateMs","startMs","endMs","stepMs","rangeMs","highlightSeries","name","current","dispatchAction","type","seriesId","handleEvents","datazoom","params","setTimeout","batch","xAxisStartValue","startValue","xAxisEndValue","endValue","zoomEvent","start","end","finished","noDataOption","option","length","dataset","isLocalTimeZone","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","isControlKeyPressed","ctrlKey","metaKey","preventDefault","pointInGrid","nativeEvent","offsetX","offsetY","target","HTMLCanvasElement","pinnedPos","page","x","pageX","y","pageY","client","clientX","clientY","plotCanvas","cursorX","firstTimeSeriesValues","closestTimestamp","markLine","onMouseDown","onMouseMove","deltaX","onMouseUp","onMouseLeave","onMouseEnter","hidden","containerId","tooltipPortalContainerId","wrapLabels","onUnpinClick","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,UAAU,EAAcC,SAAS,EAAEC,mBAAmB,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAC1G,SAASC,GAAG,QAAQ,gBAAgB;AACpC,OAAOC,WAAW,eAAe;AACjC,OAAOC,aAAa,iBAAiB;AACrC,SAASC,WAAW,QAAQ,cAAc;AAC1C,SAASC,kBAAkB,QAA8C,mBAAmB;AAQ5F,SAAqCC,GAAG,QAAQ,eAAe;AAC/D,SAASC,aAAaC,gBAAgB,EAAEC,YAAYC,eAAe,QAAQ,iBAAiB;AAC5F,SACEC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,iBAAiB,EACjBC,iBAAiB,EACjBC,kBAAkB,EAClBC,cAAc,EACdC,gBAAgB,EAChBC,gBAAgB,QACX,qBAAqB;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BC,UAAUlG;gBACVmG,WAAWnI;gBACXX,WAAWO,qBAAqBP,YAAYuB;;;;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 { forwardRef, MouseEvent, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';\nimport { Box } from '@mui/material';\nimport merge from 'lodash/merge';\nimport isEqual from 'lodash/isEqual';\nimport { getCommonTimeScale, TimeScale, FormatOptions, TimeSeries } from '@perses-dev/core';\nimport type {\n EChartsCoreOption,\n GridComponentOption,\n LineSeriesOption,\n YAXisComponentOption,\n TooltipComponentOption,\n} from 'echarts';\nimport { ECharts as EChartsInstance, use } from 'echarts/core';\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 { CanvasRenderer } from 'echarts/renderers';\nimport {\n ChartInstance,\n ChartInstanceFocusOpts,\n clearHighlightedSeries,\n CursorCoordinates,\n DEFAULT_PINNED_CROSSHAIR,\n DEFAULT_TOOLTIP_CONFIG,\n EChart,\n enableDataZoom,\n getClosestTimestamp,\n getFormattedAxis,\n getPointInGrid,\n OnEventsType,\n restoreChart,\n TimeChartSeriesMapping,\n TimeChartTooltip,\n TooltipConfig,\n useChartsContext,\n useTimeZone,\n ZoomEventData,\n} from '@perses-dev/components';\nimport { DatasetOption } from 'echarts/types/dist/shared';\nimport { createTimezoneAwareAxisFormatter } from './utils/timezone-formatter';\n\nuse([\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 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 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 { timeZone } = 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 };\n }, [onDataZoom, setTooltipPinnedCoords]);\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 ? [...seriesMapping, pinnedCrosshair] : seriesMapping;\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 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 // 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 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 {showTooltip === true &&\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 <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":["forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useRef","useState","Box","merge","isEqual","getCommonTimeScale","use","LineChart","EChartsLineChart","BarChart","EChartsBarChart","GridComponent","DatasetComponent","DataZoomComponent","MarkAreaComponent","MarkLineComponent","MarkPointComponent","TitleComponent","ToolboxComponent","TooltipComponent","CanvasRenderer","clearHighlightedSeries","DEFAULT_PINNED_CROSSHAIR","DEFAULT_TOOLTIP_CONFIG","EChart","enableDataZoom","getClosestTimestamp","getFormattedAxis","getPointInGrid","restoreChart","TimeChartTooltip","useChartsContext","useTimeZone","createTimezoneAwareAxisFormatter","TimeSeriesChartBase","TimeChart","height","data","seriesMapping","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","timeZone","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","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","isControlKeyPressed","ctrlKey","metaKey","preventDefault","pointInGrid","nativeEvent","offsetX","offsetY","target","HTMLCanvasElement","pinnedPos","page","x","pageX","y","pageY","client","clientX","clientY","plotCanvas","cursorX","firstTimeSeriesValues","closestTimestamp","markLine","onMouseDown","onMouseMove","deltaX","onMouseUp","onMouseLeave","onMouseEnter","hidden","containerId","tooltipPortalContainerId","wrapLabels","onUnpinClick","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,UAAU,EAAcC,WAAW,EAAEC,SAAS,EAAEC,mBAAmB,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AACvH,SAASC,GAAG,QAAQ,gBAAgB;AACpC,OAAOC,WAAW,eAAe;AACjC,OAAOC,aAAa,iBAAiB;AACrC,SAASC,kBAAkB,QAA8C,m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I,cAAc;oBACZ,0DAA0D;oBAC1DzH,uBAAuB;oBACvB,yCAAyC;oBACzCE,mBAAmB;gBACrB;;0BAGN,KAACzC;gBACCiK,IAAI;oBACFC,OAAO;oBACPtJ,QAAQ;gBACV;gBACAsE,QAAQA;gBACRiF,OAAOtI,YAAYuI,YAAY;gBAC/BC,UAAUjG;gBACVkG,WAAWnI;gBACXX,WAAWO,qBAAqBP,YAAYyB;;;;AAIpD,GAAG"}
@@ -212,19 +212,20 @@ function QuerySettingsEditor(props) {
212
212
  qs.areaOpacity = undefined;
213
213
  });
214
214
  };
215
- const addUnit = (i)=>{
215
+ const addFormat = (i)=>{
216
216
  updateQuerySettings(i, (qs)=>{
217
217
  qs.format = {
218
- unit: 'decimal'
218
+ unit: 'decimal',
219
+ shortValues: true
219
220
  };
220
221
  });
221
222
  };
222
- const removeUnit = (i)=>{
223
+ const removeFormat = (i)=>{
223
224
  updateQuerySettings(i, (qs)=>{
224
225
  qs.format = undefined;
225
226
  });
226
227
  };
227
- const handleUnitChange = (i, format)=>{
228
+ const handleFormatChange = (i, format)=>{
228
229
  updateQuerySettings(i, (qs)=>{
229
230
  qs.format = format;
230
231
  });
@@ -288,9 +289,9 @@ function QuerySettingsEditor(props) {
288
289
  onRemoveLineStyle: ()=>removeLineStyle(i),
289
290
  onAddAreaOpacity: ()=>addAreaOpacity(i),
290
291
  onRemoveAreaOpacity: ()=>removeAreaOpacity(i),
291
- onAddUnit: ()=>addUnit(i),
292
- onRemoveUnit: ()=>removeUnit(i),
293
- onUnitChange: (format)=>handleUnitChange(i, format)
292
+ onAddFormat: ()=>addFormat(i),
293
+ onRemoveFormat: ()=>removeFormat(i),
294
+ onFormatChange: (format)=>handleFormatChange(i, format)
294
295
  }, i)),
295
296
  queryCount > 0 && firstAvailableQueryIndex !== NO_INDEX_AVAILABLE && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
296
297
  variant: "contained",
@@ -304,7 +305,7 @@ function QuerySettingsEditor(props) {
304
305
  ]
305
306
  });
306
307
  }
307
- function QuerySettingsInput({ querySettings: { queryIndex, colorMode, colorValue, lineStyle, areaOpacity, format }, availableQueryIndexes, onQueryIndexChange, onColorModeChange, onColorValueChange, onLineStyleChange, onAreaOpacityChange, onDelete, inputRef, onAddColor: onAddColor, onRemoveColor: onRemoveColor, onAddLineStyle, onRemoveLineStyle, onAddAreaOpacity, onRemoveAreaOpacity, onAddUnit, onRemoveUnit, onUnitChange }) {
308
+ function QuerySettingsInput({ querySettings: { queryIndex, colorMode, colorValue, lineStyle, areaOpacity, format }, availableQueryIndexes, onQueryIndexChange, onColorModeChange, onColorValueChange, onLineStyleChange, onAreaOpacityChange, onDelete, inputRef, onAddColor: onAddColor, onRemoveColor: onRemoveColor, onAddLineStyle, onRemoveLineStyle, onAddAreaOpacity, onRemoveAreaOpacity, onAddFormat, onRemoveFormat, onFormatChange }) {
308
309
  // current query index should also be selectable
309
310
  const selectableQueryIndexes = availableQueryIndexes.concat(queryIndex).sort((a, b)=>a - b);
310
311
  // State for dropdown menu
@@ -328,9 +329,9 @@ function QuerySettingsInput({ querySettings: { queryIndex, colorMode, colorValue
328
329
  action: onAddAreaOpacity
329
330
  });
330
331
  if (format === undefined) options.push({
331
- key: 'unit',
332
- label: 'Unit',
333
- action: onAddUnit
332
+ key: 'format',
333
+ label: 'Format',
334
+ action: onAddFormat
334
335
  });
335
336
  return options;
336
337
  }, [
@@ -341,7 +342,7 @@ function QuerySettingsInput({ querySettings: { queryIndex, colorMode, colorValue
341
342
  onAddColor,
342
343
  onAddLineStyle,
343
344
  onAddAreaOpacity,
344
- onAddUnit
345
+ onAddFormat
345
346
  ]);
346
347
  const handleAddMenuClick = (event)=>{
347
348
  if (availableOptions.length === 1 && availableOptions[0]) {
@@ -359,172 +360,183 @@ function QuerySettingsInput({ querySettings: { queryIndex, colorMode, colorValue
359
360
  action();
360
361
  handleMenuClose();
361
362
  };
362
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
363
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
363
364
  sx: {
364
365
  borderBottom: '1px solid',
365
366
  borderColor: 'divider',
366
367
  borderRadius: 1,
367
- p: 2
368
+ p: 2,
369
+ display: 'flex',
370
+ flexWrap: 'nowrap',
371
+ flexDirection: 'row'
368
372
  },
369
- children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
370
- direction: "row",
371
- alignItems: "center",
372
- sx: {
373
- flexWrap: 'wrap',
374
- gap: 2
375
- },
376
- children: [
377
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
378
- select: true,
379
- inputRef: inputRef,
380
- value: queryIndex,
381
- label: "Query",
382
- onChange: onQueryIndexChange,
383
- sx: {
384
- minWidth: '75px'
385
- },
386
- children: selectableQueryIndexes.map((qi)=>/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.MenuItem, {
387
- value: qi,
388
- children: [
389
- "#",
390
- qi + 1
391
- ]
392
- }, `query-${qi}`))
393
- }),
394
- colorMode && /*#__PURE__*/ (0, _jsxruntime.jsxs)(SettingsSection, {
395
- label: "Color",
396
- onRemove: onRemoveColor,
397
- children: [
398
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TextField, {
399
- select: true,
400
- value: colorMode,
401
- onChange: onColorModeChange,
402
- size: "small",
403
- sx: {
404
- flexGrow: 1
405
- },
406
- children: [
407
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
408
- value: "fixed-single",
409
- children: "Fixed (single)"
410
- }),
411
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
412
- value: "fixed",
413
- children: "Fixed"
414
- })
415
- ]
416
- }),
417
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsColorPicker, {
418
- label: `Query n°${queryIndex + 1}`,
419
- color: colorValue || DEFAULT_COLOR_VALUE,
420
- onColorChange: onColorValueChange
421
- })
422
- ]
423
- }),
424
- lineStyle && /*#__PURE__*/ (0, _jsxruntime.jsxs)(SettingsSection, {
425
- label: "Line Style",
426
- onRemove: onRemoveLineStyle,
427
- children: [
428
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ToggleButtonGroup, {
429
- color: "primary",
430
- exclusive: true,
431
- value: lineStyle,
432
- onChange: (__, newValue)=>{
433
- if (newValue !== null) {
434
- onLineStyleChange(newValue);
435
- }
436
- },
437
- size: "small",
438
- children: Object.entries(_timeserieschartmodel.LINE_STYLE_CONFIG).map(([styleValue, config])=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ToggleButton, {
439
- value: styleValue,
440
- "aria-label": `${styleValue} line style`,
441
- children: config.label
442
- }, styleValue))
443
- }),
444
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
445
- sx: {
446
- flexGrow: 1
447
- }
448
- })
449
- ]
450
- }),
451
- areaOpacity !== undefined && /*#__PURE__*/ (0, _jsxruntime.jsxs)(SettingsSection, {
452
- label: "Opacity",
453
- onRemove: onRemoveAreaOpacity,
454
- children: [
455
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {}),
456
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Slider, {
457
- value: areaOpacity,
458
- valueLabelDisplay: "auto",
459
- step: _timeserieschartmodel.OPACITY_CONFIG.step,
460
- marks: true,
461
- min: _timeserieschartmodel.OPACITY_CONFIG.min,
462
- max: _timeserieschartmodel.OPACITY_CONFIG.max,
463
- onChange: onAreaOpacityChange,
464
- sx: {
465
- flexGrow: 1
466
- }
467
- })
468
- ]
469
- }),
470
- format !== undefined && /*#__PURE__*/ (0, _jsxruntime.jsx)(SettingsSection, {
471
- label: "Unit",
472
- onRemove: onRemoveUnit,
473
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
373
+ children: [
374
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
375
+ direction: "row",
376
+ alignItems: "center",
377
+ sx: {
378
+ flexWrap: 'wrap',
379
+ gap: 2,
380
+ flexGrow: 1
381
+ },
382
+ children: [
383
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
384
+ select: true,
385
+ inputRef: inputRef,
386
+ value: queryIndex,
387
+ label: "Query",
388
+ onChange: onQueryIndexChange,
474
389
  sx: {
475
- minWidth: '180px'
390
+ minWidth: '75px'
476
391
  },
477
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.UnitSelector, {
478
- value: format,
479
- onChange: onUnitChange
480
- })
481
- })
482
- }),
483
- availableOptions.length > 0 && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
484
- children: [
485
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
486
- onClick: handleAddMenuClick,
487
- "aria-label": "Add option",
488
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {})
489
- }),
490
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Menu, {
491
- anchorEl: anchorEl,
492
- open: Boolean(anchorEl),
493
- onClose: handleMenuClose,
494
- anchorOrigin: {
495
- vertical: 'bottom',
496
- horizontal: 'left'
392
+ children: selectableQueryIndexes.map((qi)=>/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.MenuItem, {
393
+ value: qi,
394
+ children: [
395
+ "#",
396
+ qi + 1
397
+ ]
398
+ }, `query-${qi}`))
399
+ }),
400
+ colorMode && /*#__PURE__*/ (0, _jsxruntime.jsxs)(SettingsSection, {
401
+ label: "Color",
402
+ onRemove: onRemoveColor,
403
+ children: [
404
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TextField, {
405
+ select: true,
406
+ value: colorMode,
407
+ onChange: onColorModeChange,
408
+ size: "small",
409
+ sx: {
410
+ flexGrow: 1
411
+ },
412
+ children: [
413
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
414
+ value: "fixed-single",
415
+ children: "Fixed (single)"
416
+ }),
417
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
418
+ value: "fixed",
419
+ children: "Fixed"
420
+ })
421
+ ]
422
+ }),
423
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsColorPicker, {
424
+ label: `Query n°${queryIndex + 1}`,
425
+ color: colorValue || DEFAULT_COLOR_VALUE,
426
+ onColorChange: onColorValueChange
427
+ })
428
+ ]
429
+ }),
430
+ lineStyle && /*#__PURE__*/ (0, _jsxruntime.jsxs)(SettingsSection, {
431
+ label: "Line Style",
432
+ onRemove: onRemoveLineStyle,
433
+ children: [
434
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ToggleButtonGroup, {
435
+ color: "primary",
436
+ exclusive: true,
437
+ value: lineStyle,
438
+ onChange: (__, newValue)=>{
439
+ if (newValue !== null) {
440
+ onLineStyleChange(newValue);
441
+ }
442
+ },
443
+ size: "small",
444
+ children: Object.entries(_timeserieschartmodel.LINE_STYLE_CONFIG).map(([styleValue, config])=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ToggleButton, {
445
+ value: styleValue,
446
+ "aria-label": `${styleValue} line style`,
447
+ children: config.label
448
+ }, styleValue))
449
+ }),
450
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
451
+ sx: {
452
+ flexGrow: 1
453
+ }
454
+ })
455
+ ]
456
+ }),
457
+ areaOpacity !== undefined && /*#__PURE__*/ (0, _jsxruntime.jsxs)(SettingsSection, {
458
+ label: "Opacity",
459
+ onRemove: onRemoveAreaOpacity,
460
+ children: [
461
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {}),
462
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Slider, {
463
+ value: areaOpacity,
464
+ valueLabelDisplay: "auto",
465
+ step: _timeserieschartmodel.OPACITY_CONFIG.step,
466
+ marks: true,
467
+ min: _timeserieschartmodel.OPACITY_CONFIG.min,
468
+ max: _timeserieschartmodel.OPACITY_CONFIG.max,
469
+ onChange: onAreaOpacityChange,
470
+ sx: {
471
+ flexGrow: 1
472
+ }
473
+ })
474
+ ]
475
+ }),
476
+ format !== undefined && /*#__PURE__*/ (0, _jsxruntime.jsx)(SettingsSection, {
477
+ label: "Format",
478
+ onRemove: onRemoveFormat,
479
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
480
+ sx: {
481
+ minWidth: '180px',
482
+ display: 'flex',
483
+ gap: 1,
484
+ flexDirection: 'column'
497
485
  },
498
- children: availableOptions.map((option)=>/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.MenuItem, {
499
- onClick: ()=>handleMenuItemClick(option.action),
500
- sx: {
501
- minWidth: '120px'
502
- },
503
- children: [
504
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {
505
- sx: {
506
- mr: 1,
507
- fontSize: '1rem'
508
- }
509
- }),
510
- option.label
511
- ]
512
- }, option.key))
486
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.FormatControls, {
487
+ value: format,
488
+ onChange: onFormatChange
489
+ })
513
490
  })
514
- ]
515
- }),
516
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
517
- sx: {
518
- flexGrow: 1
519
- }
520
- }),
521
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
491
+ }),
492
+ availableOptions.length > 0 && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
493
+ children: [
494
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
495
+ onClick: handleAddMenuClick,
496
+ "aria-label": "Add option",
497
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {})
498
+ }),
499
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Menu, {
500
+ anchorEl: anchorEl,
501
+ open: Boolean(anchorEl),
502
+ onClose: handleMenuClose,
503
+ anchorOrigin: {
504
+ vertical: 'bottom',
505
+ horizontal: 'left'
506
+ },
507
+ children: availableOptions.map((option)=>/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.MenuItem, {
508
+ onClick: ()=>handleMenuItemClick(option.action),
509
+ sx: {
510
+ minWidth: '120px'
511
+ },
512
+ children: [
513
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {
514
+ sx: {
515
+ mr: 1,
516
+ fontSize: '1rem'
517
+ }
518
+ }),
519
+ option.label
520
+ ]
521
+ }, option.key))
522
+ })
523
+ ]
524
+ })
525
+ ]
526
+ }),
527
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
528
+ sx: {
529
+ display: 'flex',
530
+ alignItems: 'center',
531
+ justifyContent: 'center'
532
+ },
533
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
522
534
  "aria-label": `delete settings for query n°${queryIndex + 1}`,
523
535
  onClick: onDelete,
524
536
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_DeleteOutline.default, {})
525
537
  })
526
- ]
527
- })
538
+ })
539
+ ]
528
540
  });
529
541
  }
530
542
  // Reusable section component