@perses-dev/timeseries-chart-plugin 0.13.0 → 0.14.0-beta.2

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 (172) hide show
  1. package/__mf/js/TimeSeriesChart.b9caac04.js +7 -0
  2. package/__mf/js/async/121.fde1320e.js +2 -0
  3. package/__mf/js/async/{527.f97d1b86.js → 182.9e1e293f.js} +9 -9
  4. package/__mf/js/async/192.66c6659d.js +1 -0
  5. package/__mf/js/async/2.166bda4f.js +1 -0
  6. package/__mf/js/async/235.76fd7af2.js +1 -0
  7. package/__mf/js/async/274.e4ed32f7.js +2 -0
  8. package/__mf/js/async/319.8e262f9c.js +1 -0
  9. package/__mf/js/async/356.52455d93.js +1 -0
  10. package/__mf/js/async/384.f40367cc.js +1 -0
  11. package/__mf/js/async/392.8cb3dcaa.js +2 -0
  12. package/__mf/js/async/463.f5dc7759.js +7 -0
  13. package/__mf/js/async/{694.0fb9ee5a.js.LICENSE.txt → 463.f5dc7759.js.LICENSE.txt} +41 -1
  14. package/__mf/js/async/465.add3260a.js +1 -0
  15. package/__mf/js/async/470.beedcbcc.js +2 -0
  16. package/__mf/js/async/522.806db24f.js +22 -0
  17. package/__mf/js/async/525.8b92c616.js +37 -0
  18. package/__mf/js/async/587.828c454a.js +1 -0
  19. package/__mf/js/async/597.0c5bd6dd.js +2 -0
  20. package/__mf/js/async/612.b2f31132.js +3 -0
  21. package/__mf/js/async/616.804d525d.js +1 -0
  22. package/__mf/js/async/663.892b9ad5.js +1 -0
  23. package/__mf/js/async/700.25c7e5dd.js +1 -0
  24. package/__mf/js/async/724.f74ffa12.js +1 -0
  25. package/__mf/js/async/730.058dea58.js +2 -0
  26. package/__mf/js/async/865.cb917066.js +2 -0
  27. package/__mf/js/async/941.3bb54150.js +2 -0
  28. package/__mf/js/async/955.52ca0671.js +1 -0
  29. package/__mf/js/async/968.2dd830b3.js +1 -0
  30. package/__mf/js/async/__federation_expose_TimeSeriesChart.4ddb01e0.js +1 -0
  31. package/__mf/js/async/lib-router.ecb51f08.js +2 -0
  32. package/__mf/js/main.f55169be.js +7 -0
  33. package/lib/GeneralSettingsEditor.d.ts +2 -2
  34. package/lib/GeneralSettingsEditor.d.ts.map +1 -1
  35. package/lib/GeneralSettingsEditor.js +7 -7
  36. package/lib/GeneralSettingsEditor.js.map +1 -1
  37. package/lib/QuerySettingsEditor.d.ts +2 -2
  38. package/lib/QuerySettingsEditor.d.ts.map +1 -1
  39. package/lib/QuerySettingsEditor.js +11 -11
  40. package/lib/QuerySettingsEditor.js.map +1 -1
  41. package/lib/TimeSeriesChart.d.ts +3 -3
  42. package/lib/TimeSeriesChart.d.ts.map +1 -1
  43. package/lib/TimeSeriesChart.js +6 -5
  44. package/lib/TimeSeriesChart.js.map +1 -1
  45. package/lib/TimeSeriesChartBase.d.ts +4 -4
  46. package/lib/TimeSeriesChartBase.d.ts.map +1 -1
  47. package/lib/TimeSeriesChartBase.js +12 -12
  48. package/lib/TimeSeriesChartBase.js.map +1 -1
  49. package/lib/TimeSeriesChartPanel.d.ts +4 -4
  50. package/lib/TimeSeriesChartPanel.d.ts.map +1 -1
  51. package/lib/TimeSeriesChartPanel.js +12 -12
  52. package/lib/TimeSeriesChartPanel.js.map +1 -1
  53. package/lib/TimeSeriesExportAction.d.ts +1 -1
  54. package/lib/TimeSeriesExportAction.d.ts.map +1 -1
  55. package/lib/TimeSeriesExportAction.js +5 -5
  56. package/lib/TimeSeriesExportAction.js.map +1 -1
  57. package/lib/VisualOptionsEditor.d.ts +2 -2
  58. package/lib/VisualOptionsEditor.d.ts.map +1 -1
  59. package/lib/VisualOptionsEditor.js +4 -4
  60. package/lib/VisualOptionsEditor.js.map +1 -1
  61. package/lib/YAxisOptionsEditor.d.ts +2 -2
  62. package/lib/YAxisOptionsEditor.d.ts.map +1 -1
  63. package/lib/YAxisOptionsEditor.js +3 -3
  64. package/lib/YAxisOptionsEditor.js.map +1 -1
  65. package/lib/annotations/AnnotationTooltip.d.ts +2 -2
  66. package/lib/annotations/AnnotationTooltip.d.ts.map +1 -1
  67. package/lib/annotations/AnnotationTooltip.js +6 -6
  68. package/lib/annotations/AnnotationTooltip.js.map +1 -1
  69. package/lib/bootstrap.js +2 -2
  70. package/lib/getPluginModule.d.ts +1 -1
  71. package/lib/getPluginModule.d.ts.map +1 -1
  72. package/lib/getPluginModule.js +3 -1
  73. package/lib/getPluginModule.js.map +1 -1
  74. package/lib/index-federation.js +1 -1
  75. package/lib/index.js +9 -9
  76. package/lib/index.js.map +1 -1
  77. package/lib/setup-tests.d.ts +1 -1
  78. package/lib/setup-tests.d.ts.map +1 -1
  79. package/lib/setup-tests.js +2 -2
  80. package/lib/setup-tests.js.map +1 -1
  81. package/lib/test/mock-query-results.d.ts +1 -1
  82. package/lib/test/mock-query-results.d.ts.map +1 -1
  83. package/lib/test/mock-query-results.js.map +1 -1
  84. package/lib/time-series-chart-model.d.ts +3 -3
  85. package/lib/time-series-chart-model.d.ts.map +1 -1
  86. package/lib/time-series-chart-model.js.map +1 -1
  87. package/lib/utils/annotation.d.ts +2 -2
  88. package/lib/utils/annotation.d.ts.map +1 -1
  89. package/lib/utils/annotation.js.map +1 -1
  90. package/lib/utils/data-transform.d.ts +5 -5
  91. package/lib/utils/data-transform.d.ts.map +1 -1
  92. package/lib/utils/data-transform.js +3 -3
  93. package/lib/utils/data-transform.js.map +1 -1
  94. package/lib/utils/palette-gen.d.ts +1 -1
  95. package/lib/utils/palette-gen.d.ts.map +1 -1
  96. package/lib/utils/palette-gen.js +1 -1
  97. package/lib/utils/palette-gen.js.map +1 -1
  98. package/lib/utils/palette.js +1 -1
  99. package/lib/utils/palette.js.map +1 -1
  100. package/lib/utils/timezone-formatter.js +1 -1
  101. package/mf-manifest.json +37 -81
  102. package/mf-stats.json +39 -91
  103. package/package.json +11 -11
  104. package/__mf/js/TimeSeriesChart.42841bce.js +0 -7
  105. package/__mf/js/async/121.c3c0e54f.js +0 -2
  106. package/__mf/js/async/177.2fef2962.js +0 -1
  107. package/__mf/js/async/187.f5e8932b.js +0 -1
  108. package/__mf/js/async/192.c3dd56d5.js +0 -1
  109. package/__mf/js/async/2.60fa4a40.js +0 -1
  110. package/__mf/js/async/208.b9f374ad.js +0 -7
  111. package/__mf/js/async/208.b9f374ad.js.LICENSE.txt +0 -39
  112. package/__mf/js/async/235.d23c8ef0.js +0 -1
  113. package/__mf/js/async/274.72dfa9c8.js +0 -2
  114. package/__mf/js/async/356.8170c96d.js +0 -1
  115. package/__mf/js/async/392.b9ba5bf2.js +0 -2
  116. package/__mf/js/async/470.e09f33b7.js +0 -2
  117. package/__mf/js/async/491.85194549.js +0 -1
  118. package/__mf/js/async/518.2ac1df43.js +0 -38
  119. package/__mf/js/async/52.0d78de2b.js +0 -1
  120. package/__mf/js/async/546.5fecffa4.js +0 -3
  121. package/__mf/js/async/568.45da2c30.js +0 -1
  122. package/__mf/js/async/587.c9460696.js +0 -1
  123. package/__mf/js/async/588.0a1aa144.js +0 -1
  124. package/__mf/js/async/603.3b771310.js +0 -2
  125. package/__mf/js/async/616.79484ac8.js +0 -1
  126. package/__mf/js/async/655.2f794f77.js +0 -1
  127. package/__mf/js/async/694.0fb9ee5a.js +0 -2
  128. package/__mf/js/async/702.785cd635.js +0 -2
  129. package/__mf/js/async/71.8c6cf914.js +0 -1
  130. package/__mf/js/async/724.c45dcf5b.js +0 -1
  131. package/__mf/js/async/873.04a201bf.js +0 -1
  132. package/__mf/js/async/941.b89f8595.js +0 -2
  133. package/__mf/js/async/955.176fe200.js +0 -1
  134. package/__mf/js/async/968.2a9fb1a0.js +0 -1
  135. package/__mf/js/async/978.a9865b23.js +0 -1
  136. package/__mf/js/async/984.83bd5c6d.js +0 -22
  137. package/__mf/js/async/__federation_expose_TimeSeriesChart.0ab11cd4.js +0 -1
  138. package/__mf/js/async/lib-router.319c02cd.js +0 -2
  139. package/__mf/js/main.691eecd6.js +0 -7
  140. package/lib/cjs/GeneralSettingsEditor.js +0 -103
  141. package/lib/cjs/QuerySettingsEditor.js +0 -666
  142. package/lib/cjs/TimeSeriesChart.js +0 -50
  143. package/lib/cjs/TimeSeriesChartBase.js +0 -488
  144. package/lib/cjs/TimeSeriesChartPanel.js +0 -456
  145. package/lib/cjs/TimeSeriesExportAction.js +0 -124
  146. package/lib/cjs/VisualOptionsEditor.js +0 -161
  147. package/lib/cjs/YAxisOptionsEditor.js +0 -118
  148. package/lib/cjs/annotations/AnnotationTooltip.js +0 -370
  149. package/lib/cjs/bootstrap.js +0 -26
  150. package/lib/cjs/env.d.js +0 -14
  151. package/lib/cjs/getPluginModule.js +0 -39
  152. package/lib/cjs/index-federation.js +0 -55
  153. package/lib/cjs/index.js +0 -44
  154. package/lib/cjs/setup-tests.js +0 -19
  155. package/lib/cjs/test/mock-query-results.js +0 -403
  156. package/lib/cjs/time-series-chart-model.js +0 -225
  157. package/lib/cjs/utils/annotation.js +0 -37
  158. package/lib/cjs/utils/data-transform.js +0 -243
  159. package/lib/cjs/utils/palette-gen.js +0 -75
  160. package/lib/cjs/utils/palette.js +0 -83
  161. package/lib/cjs/utils/timezone-formatter.js +0 -48
  162. /package/__mf/css/async/{208.85c2cbf6.css → 463.85c2cbf6.css} +0 -0
  163. /package/__mf/js/async/{121.c3c0e54f.js.LICENSE.txt → 121.fde1320e.js.LICENSE.txt} +0 -0
  164. /package/__mf/js/async/{527.f97d1b86.js.LICENSE.txt → 182.9e1e293f.js.LICENSE.txt} +0 -0
  165. /package/__mf/js/async/{274.72dfa9c8.js.LICENSE.txt → 274.e4ed32f7.js.LICENSE.txt} +0 -0
  166. /package/__mf/js/async/{392.b9ba5bf2.js.LICENSE.txt → 392.8cb3dcaa.js.LICENSE.txt} +0 -0
  167. /package/__mf/js/async/{470.e09f33b7.js.LICENSE.txt → 470.beedcbcc.js.LICENSE.txt} +0 -0
  168. /package/__mf/js/async/{984.83bd5c6d.js.LICENSE.txt → 522.806db24f.js.LICENSE.txt} +0 -0
  169. /package/__mf/js/async/{603.3b771310.js.LICENSE.txt → 597.0c5bd6dd.js.LICENSE.txt} +0 -0
  170. /package/__mf/js/async/{702.785cd635.js.LICENSE.txt → 865.cb917066.js.LICENSE.txt} +0 -0
  171. /package/__mf/js/async/{941.b89f8595.js.LICENSE.txt → 941.3bb54150.js.LICENSE.txt} +0 -0
  172. /package/__mf/js/async/{lib-router.319c02cd.js.LICENSE.txt → lib-router.ecb51f08.js.LICENSE.txt} +0 -0
@@ -1,50 +0,0 @@
1
- // Copyright The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- Object.defineProperty(exports, "TimeSeriesChart", {
18
- enumerable: true,
19
- get: function() {
20
- return TimeSeriesChart;
21
- }
22
- });
23
- const _timeserieschartmodel = require("./time-series-chart-model");
24
- const _GeneralSettingsEditor = require("./GeneralSettingsEditor");
25
- const _QuerySettingsEditor = require("./QuerySettingsEditor");
26
- const _TimeSeriesChartPanel = require("./TimeSeriesChartPanel");
27
- const _TimeSeriesExportAction = require("./TimeSeriesExportAction");
28
- const TimeSeriesChart = {
29
- PanelComponent: _TimeSeriesChartPanel.TimeSeriesChartPanel,
30
- supportedQueryTypes: [
31
- 'TimeSeriesQuery'
32
- ],
33
- panelOptionsEditorComponents: [
34
- {
35
- label: 'General Settings',
36
- content: _GeneralSettingsEditor.TimeSeriesChartGeneralSettings
37
- },
38
- {
39
- label: 'Query Settings',
40
- content: _QuerySettingsEditor.QuerySettingsEditor
41
- }
42
- ],
43
- createInitialOptions: _timeserieschartmodel.createInitialTimeSeriesChartOptions,
44
- actions: [
45
- {
46
- component: _TimeSeriesExportAction.TimeSeriesExportAction,
47
- location: 'header'
48
- }
49
- ]
50
- };
@@ -1,488 +0,0 @@
1
- // Copyright The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- Object.defineProperty(exports, "TimeSeriesChartBase", {
18
- enumerable: true,
19
- get: function() {
20
- return TimeSeriesChartBase;
21
- }
22
- });
23
- const _jsxruntime = require("react/jsx-runtime");
24
- const _react = require("react");
25
- const _material = require("@mui/material");
26
- const _merge = /*#__PURE__*/ _interop_require_default(require("lodash/merge"));
27
- const _isEqual = /*#__PURE__*/ _interop_require_default(require("lodash/isEqual"));
28
- const _core = require("echarts/core");
29
- const _charts = require("echarts/charts");
30
- const _components = require("echarts/components");
31
- const _renderers = require("echarts/renderers");
32
- const _components1 = require("@perses-dev/components");
33
- const _timezoneformatter = require("./utils/timezone-formatter");
34
- const _AnnotationTooltip = require("./annotations/AnnotationTooltip");
35
- function _interop_require_default(obj) {
36
- return obj && obj.__esModule ? obj : {
37
- default: obj
38
- };
39
- }
40
- (0, _core.use)([
41
- _charts.LineChart,
42
- _charts.BarChart,
43
- _components.GridComponent,
44
- _components.DatasetComponent,
45
- _components.DataZoomComponent,
46
- _components.MarkAreaComponent,
47
- _components.MarkLineComponent,
48
- _components.MarkPointComponent,
49
- _components.TitleComponent,
50
- _components.ToolboxComponent,
51
- _components.TooltipComponent,
52
- _renderers.CanvasRenderer
53
- ]);
54
- const TimeSeriesChartBase = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ height, data, seriesMapping, annotations, timeScale: timeScaleProp, yAxis, format, seriesFormatMap, grid, isStackedBar = false, tooltipConfig = _components1.DEFAULT_TOOLTIP_CONFIG, noDataVariant = 'message', syncGroup, onDataZoom, onDoubleClick, __experimentalEChartsOptionsOverride }, ref) {
55
- const { chartsTheme, enablePinning, enableSyncGrouping, lastTooltipPinnedCoords, setLastTooltipPinnedCoords } = (0, _components1.useChartsContext)();
56
- const isPinningEnabled = tooltipConfig.enablePinning && enablePinning;
57
- const chartRef = (0, _react.useRef)();
58
- const [showTooltip, setShowTooltip] = (0, _react.useState)(true);
59
- const [tooltipPinnedCoords, setTooltipPinnedCoords] = (0, _react.useState)(null);
60
- const [pinnedCrosshair, setPinnedCrosshair] = (0, _react.useState)(null);
61
- const [isDragging, setIsDragging] = (0, _react.useState)(false);
62
- const [startX, setStartX] = (0, _react.useState)(0);
63
- const [hoveredAnnotation, setHoveredAnnotation] = (0, _react.useState)(null);
64
- const [pinnedAnnotation, setPinnedAnnotation] = (0, _react.useState)(null);
65
- const [pinnedAnnotationPos, setPinnedAnnotationPos] = (0, _react.useState)(null);
66
- const { timeZone, formatWithUserTimeZone } = (0, _components1.useTimeZone)();
67
- const getTimezoneAwareAxisFormatter = (0, _react.useCallback)((rangeMs)=>(0, _timezoneformatter.createTimezoneAwareAxisFormatter)(rangeMs, timeZone), [
68
- timeZone
69
- ]);
70
- let timeScale;
71
- if (timeScaleProp === undefined) {
72
- const commonTimeScale = (0, _components1.getCommonTimeScale)(data);
73
- if (commonTimeScale === undefined) {
74
- // set default to past 5 years
75
- const today = new Date();
76
- const pastDate = new Date(today);
77
- pastDate.setFullYear(today.getFullYear() - 5);
78
- const todayMs = today.getTime();
79
- const pastDateMs = pastDate.getTime();
80
- timeScale = {
81
- startMs: pastDateMs,
82
- endMs: todayMs,
83
- stepMs: 1,
84
- rangeMs: todayMs - pastDateMs
85
- };
86
- } else {
87
- timeScale = commonTimeScale;
88
- }
89
- } else {
90
- timeScale = timeScaleProp;
91
- }
92
- (0, _react.useImperativeHandle)(ref, ()=>{
93
- return {
94
- highlightSeries ({ name }) {
95
- if (!chartRef.current) {
96
- // when chart undef, do not highlight series when hovering over legend
97
- return;
98
- }
99
- chartRef.current.dispatchAction({
100
- type: 'highlight',
101
- seriesId: name
102
- });
103
- },
104
- clearHighlightedSeries: ()=>{
105
- if (!chartRef.current) {
106
- // when chart undef, do not clear highlight series
107
- return;
108
- }
109
- (0, _components1.clearHighlightedSeries)(chartRef.current);
110
- }
111
- };
112
- }, []);
113
- const handleEvents = (0, _react.useMemo)(()=>{
114
- return {
115
- datazoom: (params)=>{
116
- if (onDataZoom === undefined) {
117
- setTimeout(()=>{
118
- // workaround so unpin happens after click event
119
- setTooltipPinnedCoords(null);
120
- }, 10);
121
- }
122
- if (onDataZoom === undefined || params.batch[0] === undefined) return;
123
- const xAxisStartValue = params.batch[0].startValue;
124
- const xAxisEndValue = params.batch[0].endValue;
125
- if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {
126
- const zoomEvent = {
127
- start: xAxisStartValue,
128
- end: xAxisEndValue
129
- };
130
- onDataZoom(zoomEvent);
131
- }
132
- },
133
- finished: ()=>{
134
- if (chartRef.current !== undefined) {
135
- (0, _components1.enableDataZoom)(chartRef.current);
136
- }
137
- },
138
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
139
- mouseover: (params)=>{
140
- // Only markPoint (triangles under the X-axis) opens the annotation tooltip.
141
- // Hovering markLine or anything else keeps the regular TimeSeries tooltip visible
142
- // and clears any stale hovered annotation (mouseout is sometimes missed by ECharts).
143
- if (annotations && params.componentType === 'markPoint' && params.data?.annotationIndex !== undefined) {
144
- const matchedAnnotation = annotations[params.data.annotationIndex] || null;
145
- if (matchedAnnotation) {
146
- setHoveredAnnotation(matchedAnnotation);
147
- return;
148
- }
149
- }
150
- setHoveredAnnotation(null);
151
- },
152
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
153
- mouseout: (params)=>{
154
- if (annotations && params.componentType === 'markPoint' && params.data?.annotationIndex !== undefined && annotations) {
155
- // Only clear if the mouseout corresponds to the currently hovered annotation, so that
156
- // a quick move from one markPoint to another isn't cancelled by a late mouseout event.
157
- const leaving = annotations[params.data.annotationIndex] || null;
158
- setHoveredAnnotation((current)=>current === leaving ? null : current);
159
- }
160
- },
161
- globalout: ()=>{
162
- if (annotations) {
163
- // Cursor left the chart canvas — guarantee the annotation tooltip is dismissed.
164
- setHoveredAnnotation(null);
165
- }
166
- }
167
- };
168
- }, [
169
- annotations,
170
- onDataZoom
171
- ]);
172
- // Generate annotation series for ECharts markArea (range), markLine (point), and markPoint (markers under X-axis)
173
- const annotationSeries = (0, _react.useMemo)(()=>(0, _AnnotationTooltip.buildAnnotationSeries)(annotations), [
174
- annotations
175
- ]);
176
- const { noDataOption } = chartsTheme;
177
- const option = (0, _react.useMemo)(()=>{
178
- // The "chart" `noDataVariant` is only used when the `timeSeries` is an
179
- // empty array because a `null` value will throw an error.
180
- if (data === null || data.length === 0 && noDataVariant === 'message') return noDataOption;
181
- // Utilizes ECharts dataset so raw data is separate from series option style properties
182
- // https://apache.github.io/echarts-handbook/en/concepts/dataset/
183
- const dataset = [];
184
- data.map((d, index)=>{
185
- const values = d.values.map(([timestamp, value])=>{
186
- const val = value === null ? '-' : value; // echarts use '-' to represent null data
187
- return [
188
- timestamp,
189
- val
190
- ];
191
- });
192
- dataset.push({
193
- id: index,
194
- source: [
195
- ...values
196
- ],
197
- dimensions: [
198
- 'time',
199
- 'value'
200
- ]
201
- });
202
- });
203
- const updatedSeriesMapping = enablePinning && pinnedCrosshair !== null ? [
204
- ...seriesMapping,
205
- pinnedCrosshair,
206
- ...annotationSeries
207
- ] : [
208
- ...seriesMapping,
209
- ...annotationSeries
210
- ];
211
- const option = {
212
- dataset: dataset,
213
- series: updatedSeriesMapping,
214
- xAxis: {
215
- type: 'time',
216
- min: timeScale.startMs,
217
- max: timeScale.endMs,
218
- axisLabel: {
219
- hideOverlap: true,
220
- formatter: getTimezoneAwareAxisFormatter(timeScale.rangeMs ?? 0)
221
- },
222
- axisPointer: {
223
- snap: false
224
- }
225
- },
226
- // If yAxis is already an array (multiple Y axes), use it directly; otherwise use getFormattedAxis
227
- yAxis: Array.isArray(yAxis) ? yAxis : (0, _components1.getFormattedAxis)(yAxis, format),
228
- animation: false,
229
- tooltip: {
230
- show: true,
231
- // ECharts tooltip content hidden by default since we use custom tooltip instead.
232
- // Stacked bar uses ECharts tooltip so subgroup data shows correctly.
233
- showContent: isStackedBar,
234
- trigger: isStackedBar ? 'item' : 'axis',
235
- appendToBody: isStackedBar
236
- },
237
- // https://echarts.apache.org/en/option.html#axisPointer
238
- axisPointer: {
239
- type: 'line',
240
- z: 0,
241
- triggerEmphasis: false,
242
- triggerTooltip: false,
243
- snap: false
244
- },
245
- toolbox: {
246
- feature: {
247
- dataZoom: {
248
- icon: null,
249
- yAxisIndex: 'none'
250
- }
251
- }
252
- },
253
- grid
254
- };
255
- if (__experimentalEChartsOptionsOverride) {
256
- return __experimentalEChartsOptionsOverride(option);
257
- }
258
- return option;
259
- }, [
260
- data,
261
- seriesMapping,
262
- annotationSeries,
263
- timeScale,
264
- yAxis,
265
- format,
266
- grid,
267
- noDataOption,
268
- __experimentalEChartsOptionsOverride,
269
- noDataVariant,
270
- isStackedBar,
271
- enablePinning,
272
- pinnedCrosshair,
273
- getTimezoneAwareAxisFormatter
274
- ]);
275
- // Update adjacent charts so tooltip is unpinned when current chart is clicked.
276
- (0, _react.useEffect)(()=>{
277
- // Only allow pinning one tooltip at a time, subsequent tooltip click unpins previous.
278
- // Multiple tooltips can only be pinned if Ctrl or Cmd key is pressed while clicking.
279
- const multipleTooltipsPinned = tooltipPinnedCoords !== null && lastTooltipPinnedCoords !== null;
280
- if (multipleTooltipsPinned) {
281
- if (!(0, _isEqual.default)(lastTooltipPinnedCoords, tooltipPinnedCoords)) {
282
- setTooltipPinnedCoords(null);
283
- if (tooltipPinnedCoords !== null && pinnedCrosshair !== null) {
284
- setPinnedCrosshair(null);
285
- }
286
- }
287
- }
288
- // tooltipPinnedCoords CANNOT be in dep array or tooltip pinning breaks in the current chart's onClick
289
- // eslint-disable-next-line react-hooks/exhaustive-deps
290
- }, [
291
- lastTooltipPinnedCoords,
292
- seriesMapping
293
- ]);
294
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
295
- style: {
296
- height
297
- },
298
- // onContextMenu={(e) => {
299
- // // TODO: confirm tooltip pinning works correctly on Windows, should e.preventDefault() be added here
300
- // e.preventDefault(); // Prevent the default behaviour when right clicked
301
- // }}
302
- onClick: (e)=>{
303
- // If clicking while hovering an annotation, toggle the annotation tooltip pin
304
- // instead of pinning the TimeChartTooltip, so pinned TimeChartTooltip is preserved.
305
- if (hoveredAnnotation !== null && e.target instanceof HTMLCanvasElement) {
306
- const pinnedPos = {
307
- page: {
308
- x: e.pageX,
309
- y: e.pageY
310
- },
311
- client: {
312
- x: e.clientX,
313
- y: e.clientY
314
- },
315
- plotCanvas: {
316
- x: e.nativeEvent.offsetX,
317
- y: e.nativeEvent.offsetY
318
- },
319
- target: e.target
320
- };
321
- setPinnedAnnotation((current)=>{
322
- if (current === hoveredAnnotation) {
323
- setPinnedAnnotationPos(null);
324
- return null;
325
- }
326
- setPinnedAnnotationPos(pinnedPos);
327
- return hoveredAnnotation;
328
- });
329
- return;
330
- }
331
- // Allows user to opt-in to multi tooltip pinning when Ctrl or Cmd key held down
332
- const isControlKeyPressed = e.ctrlKey || e.metaKey;
333
- if (isControlKeyPressed) {
334
- e.preventDefault();
335
- }
336
- // Determine where on chart canvas to plot pinned crosshair as markLine.
337
- const pointInGrid = (0, _components1.getPointInGrid)(e.nativeEvent.offsetX, e.nativeEvent.offsetY, chartRef.current);
338
- if (pointInGrid === null) {
339
- return;
340
- }
341
- // Pin and unpin when clicking on chart canvas but not tooltip text.
342
- if (isPinningEnabled && e.target instanceof HTMLCanvasElement) {
343
- // Pin tooltip and update shared charts context to remember these coordinates.
344
- const pinnedPos = {
345
- page: {
346
- x: e.pageX,
347
- y: e.pageY
348
- },
349
- client: {
350
- x: e.clientX,
351
- y: e.clientY
352
- },
353
- plotCanvas: {
354
- x: e.nativeEvent.offsetX,
355
- y: e.nativeEvent.offsetY
356
- },
357
- target: e.target
358
- };
359
- setTooltipPinnedCoords((current)=>{
360
- if (current === null) {
361
- return pinnedPos;
362
- } else {
363
- setPinnedCrosshair(null);
364
- return null;
365
- }
366
- });
367
- setPinnedCrosshair((current)=>{
368
- // Only add pinned crosshair line series when there is not one already in seriesMapping.
369
- if (current === null) {
370
- const cursorX = pointInGrid[0];
371
- // Only need to loop through first dataset source since getCommonTimeScale ensures xAxis timestamps are consistent
372
- const firstTimeSeriesValues = data[0]?.values;
373
- const closestTimestamp = (0, _components1.getClosestTimestamp)(firstTimeSeriesValues, cursorX);
374
- // Crosshair snaps to nearest timestamp since cursor may be slightly to left or right
375
- const pinnedCrosshair = (0, _merge.default)({}, _components1.DEFAULT_PINNED_CROSSHAIR, {
376
- markLine: {
377
- data: [
378
- {
379
- xAxis: closestTimestamp
380
- }
381
- ]
382
- }
383
- });
384
- return pinnedCrosshair;
385
- } else {
386
- // Clear previously set pinned crosshair
387
- return null;
388
- }
389
- });
390
- if (!isControlKeyPressed) {
391
- setLastTooltipPinnedCoords(pinnedPos);
392
- }
393
- }
394
- },
395
- onMouseDown: (e)=>{
396
- const { clientX } = e;
397
- setIsDragging(true);
398
- setStartX(clientX);
399
- },
400
- onMouseMove: (e)=>{
401
- // Allow clicking inside tooltip to copy labels.
402
- if (!(e.target instanceof HTMLCanvasElement)) {
403
- return;
404
- }
405
- const { clientX } = e;
406
- if (isDragging) {
407
- const deltaX = clientX - startX;
408
- if (deltaX > 0) {
409
- // Hide tooltip when user drags to zoom.
410
- setShowTooltip(false);
411
- }
412
- }
413
- },
414
- onMouseUp: ()=>{
415
- setIsDragging(false);
416
- setStartX(0);
417
- setShowTooltip(true);
418
- },
419
- onMouseLeave: ()=>{
420
- if (tooltipPinnedCoords === null) {
421
- setShowTooltip(false);
422
- }
423
- // Defensive: clear hovered annotation in case ECharts missed a mouseout event.
424
- setHoveredAnnotation(null);
425
- if (chartRef.current !== undefined) {
426
- (0, _components1.clearHighlightedSeries)(chartRef.current);
427
- }
428
- },
429
- onMouseEnter: ()=>{
430
- setShowTooltip(true);
431
- if (chartRef.current !== undefined) {
432
- (0, _components1.enableDataZoom)(chartRef.current);
433
- }
434
- },
435
- onDoubleClick: (e)=>{
436
- setTooltipPinnedCoords(null);
437
- // either dispatch ECharts restore action to return to orig state or allow consumer to define behavior
438
- if (onDoubleClick === undefined) {
439
- if (chartRef.current !== undefined) {
440
- (0, _components1.restoreChart)(chartRef.current);
441
- }
442
- } else {
443
- onDoubleClick(e);
444
- }
445
- },
446
- children: [
447
- showTooltip === true && (tooltipPinnedCoords !== null || hoveredAnnotation === null) && option.tooltip?.showContent === false && tooltipConfig.hidden !== true && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components1.TimeChartTooltip, {
448
- containerId: chartsTheme.tooltipPortalContainerId,
449
- chartRef: chartRef,
450
- data: data,
451
- seriesMapping: seriesMapping,
452
- wrapLabels: tooltipConfig.wrapLabels,
453
- enablePinning: isPinningEnabled,
454
- pinnedPos: tooltipPinnedCoords,
455
- format: format,
456
- seriesFormatMap: seriesFormatMap,
457
- onUnpinClick: ()=>{
458
- // Unpins tooltip when clicking Pin icon in TooltipHeader.
459
- setTooltipPinnedCoords(null);
460
- // Clear previously set pinned crosshair.
461
- setPinnedCrosshair(null);
462
- }
463
- }),
464
- (pinnedAnnotation ?? hoveredAnnotation) && /*#__PURE__*/ (0, _jsxruntime.jsx)(_AnnotationTooltip.AnnotationTooltip, {
465
- annotation: pinnedAnnotation ?? hoveredAnnotation,
466
- containerId: chartsTheme.tooltipPortalContainerId,
467
- formatWithUserTimeZone: formatWithUserTimeZone,
468
- pinnedPos: pinnedAnnotation !== null ? pinnedAnnotationPos : null,
469
- enablePinning: isPinningEnabled,
470
- onUnpinClick: ()=>{
471
- setPinnedAnnotation(null);
472
- setPinnedAnnotationPos(null);
473
- }
474
- }),
475
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components1.EChart, {
476
- sx: {
477
- width: '100%',
478
- height: '100%'
479
- },
480
- option: option,
481
- theme: chartsTheme.echartsTheme,
482
- onEvents: handleEvents,
483
- _instance: chartRef,
484
- syncGroup: enableSyncGrouping ? syncGroup : undefined
485
- })
486
- ]
487
- });
488
- });