@perses-dev/components 0.0.0-snapshot-profile-89b306f → 0.0.0-snapshot-panel-actions-520389b

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 (57) hide show
  1. package/README.md +1 -5
  2. package/dist/EChart/EChart.d.ts.map +1 -1
  3. package/dist/EChart/EChart.js +9 -4
  4. package/dist/EChart/EChart.js.map +1 -1
  5. package/dist/TimeSeriesTooltip/index.d.ts +0 -1
  6. package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
  7. package/dist/TimeSeriesTooltip/index.js +0 -1
  8. package/dist/TimeSeriesTooltip/index.js.map +1 -1
  9. package/dist/cjs/EChart/EChart.js +7 -2
  10. package/dist/cjs/TimeSeriesTooltip/index.js +0 -1
  11. package/dist/cjs/index.js +0 -2
  12. package/dist/cjs/utils/axis.js +3 -18
  13. package/dist/cjs/utils/format.js +0 -21
  14. package/dist/index.d.ts +0 -2
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +0 -2
  17. package/dist/index.js.map +1 -1
  18. package/dist/model/graph.d.ts +0 -1
  19. package/dist/model/graph.d.ts.map +1 -1
  20. package/dist/model/graph.js.map +1 -1
  21. package/dist/utils/axis.d.ts +0 -4
  22. package/dist/utils/axis.d.ts.map +1 -1
  23. package/dist/utils/axis.js +0 -9
  24. package/dist/utils/axis.js.map +1 -1
  25. package/dist/utils/chart-actions.d.ts +0 -2
  26. package/dist/utils/chart-actions.d.ts.map +1 -1
  27. package/dist/utils/chart-actions.js.map +1 -1
  28. package/dist/utils/format.d.ts +0 -1
  29. package/dist/utils/format.d.ts.map +1 -1
  30. package/dist/utils/format.js +0 -20
  31. package/dist/utils/format.js.map +1 -1
  32. package/package.json +4 -7
  33. package/dist/LineChart/LineChart.d.ts +0 -22
  34. package/dist/LineChart/LineChart.d.ts.map +0 -1
  35. package/dist/LineChart/LineChart.js +0 -266
  36. package/dist/LineChart/LineChart.js.map +0 -1
  37. package/dist/LineChart/index.d.ts +0 -2
  38. package/dist/LineChart/index.d.ts.map +0 -1
  39. package/dist/LineChart/index.js +0 -15
  40. package/dist/LineChart/index.js.map +0 -1
  41. package/dist/TimeChart/TimeChart.d.ts +0 -24
  42. package/dist/TimeChart/TimeChart.d.ts.map +0 -1
  43. package/dist/TimeChart/TimeChart.js +0 -394
  44. package/dist/TimeChart/TimeChart.js.map +0 -1
  45. package/dist/TimeChart/index.d.ts +0 -2
  46. package/dist/TimeChart/index.d.ts.map +0 -1
  47. package/dist/TimeChart/index.js +0 -15
  48. package/dist/TimeChart/index.js.map +0 -1
  49. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts +0 -21
  50. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +0 -1
  51. package/dist/TimeSeriesTooltip/LineChartTooltip.js +0 -101
  52. package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +0 -1
  53. package/dist/cjs/LineChart/LineChart.js +0 -274
  54. package/dist/cjs/LineChart/index.js +0 -30
  55. package/dist/cjs/TimeChart/TimeChart.js +0 -407
  56. package/dist/cjs/TimeChart/index.js +0 -30
  57. package/dist/cjs/TimeSeriesTooltip/LineChartTooltip.js +0 -114
@@ -1,274 +0,0 @@
1
- // Copyright 2023 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, "LineChart", {
18
- enumerable: true,
19
- get: function() {
20
- return LineChart;
21
- }
22
- });
23
- const _jsxruntime = require("react/jsx-runtime");
24
- const _react = require("react");
25
- const _material = require("@mui/material");
26
- const _core = require("echarts/core");
27
- const _charts = require("echarts/charts");
28
- const _components = require("echarts/components");
29
- const _renderers = require("echarts/renderers");
30
- const _EChart = require("../EChart");
31
- const _context = require("../context");
32
- const _TimeSeriesTooltip = require("../TimeSeriesTooltip");
33
- const _utils = require("../utils");
34
- (0, _core.use)([
35
- _charts.LineChart,
36
- _components.GridComponent,
37
- _components.DataZoomComponent,
38
- _components.MarkAreaComponent,
39
- _components.MarkLineComponent,
40
- _components.MarkPointComponent,
41
- _components.TitleComponent,
42
- _components.ToolboxComponent,
43
- _components.TooltipComponent,
44
- _components.LegendComponent,
45
- _renderers.CanvasRenderer
46
- ]);
47
- const LineChart = /*#__PURE__*/ (0, _react.forwardRef)(function LineChart({ height, data, yAxis, format, grid, legend, tooltipConfig = _TimeSeriesTooltip.DEFAULT_TOOLTIP_CONFIG, noDataVariant = 'message', syncGroup, onDataZoom, onDoubleClick, __experimentalEChartsOptionsOverride }, ref) {
48
- const chartsTheme = (0, _context.useChartsTheme)();
49
- const chartRef = (0, _react.useRef)();
50
- const [showTooltip, setShowTooltip] = (0, _react.useState)(true);
51
- const [tooltipPinnedCoords, setTooltipPinnedCoords] = (0, _react.useState)(null);
52
- const { timeZone } = (0, _context.useTimeZone)();
53
- const [isDragging, setIsDragging] = (0, _react.useState)(false);
54
- const [startX, setStartX] = (0, _react.useState)(0);
55
- (0, _react.useImperativeHandle)(ref, ()=>{
56
- return {
57
- highlightSeries ({ id }) {
58
- if (!chartRef.current) {
59
- // when chart undef, do not highlight series when hovering over legend
60
- return;
61
- }
62
- chartRef.current.dispatchAction({
63
- type: 'highlight',
64
- seriesId: id
65
- });
66
- },
67
- clearHighlightedSeries: ()=>{
68
- if (!chartRef.current) {
69
- // when chart undef, do not clear highlight series
70
- return;
71
- }
72
- (0, _utils.clearHighlightedSeries)(chartRef.current);
73
- }
74
- };
75
- }, []);
76
- const handleEvents = (0, _react.useMemo)(()=>{
77
- return {
78
- datazoom: (params)=>{
79
- if (onDataZoom === undefined) {
80
- setTimeout(()=>{
81
- // workaround so unpin happens after click event
82
- setTooltipPinnedCoords(null);
83
- }, 10);
84
- }
85
- if (onDataZoom === undefined || params.batch[0] === undefined) return;
86
- const startIndex = params.batch[0].startValue ?? 0;
87
- const endIndex = params.batch[0].endValue ?? data.xAxis.length - 1;
88
- const xAxisStartValue = data.xAxis[startIndex];
89
- const xAxisEndValue = data.xAxis[endIndex];
90
- if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {
91
- const zoomEvent = {
92
- start: xAxisStartValue,
93
- end: xAxisEndValue,
94
- startIndex,
95
- endIndex
96
- };
97
- onDataZoom(zoomEvent);
98
- }
99
- }
100
- };
101
- }, [
102
- data,
103
- onDataZoom,
104
- setTooltipPinnedCoords
105
- ]);
106
- if (chartRef.current !== undefined) {
107
- (0, _utils.enableDataZoom)(chartRef.current);
108
- }
109
- const { noDataOption } = chartsTheme;
110
- const option = (0, _react.useMemo)(()=>{
111
- if (data.timeSeries === undefined) return {};
112
- // The "chart" `noDataVariant` is only used when the `timeSeries` is an
113
- // empty array because a `null` value will throw an error.
114
- if (data.timeSeries === null || data.timeSeries.length === 0 && noDataVariant === 'message') return noDataOption;
115
- const rangeMs = data.rangeMs ?? (0, _utils.getDateRange)(data.xAxis);
116
- const option = {
117
- series: data.timeSeries,
118
- xAxis: {
119
- type: 'category',
120
- data: data.xAxis,
121
- max: data.xAxisMax,
122
- axisLabel: {
123
- formatter: (value)=>{
124
- return (0, _utils.getFormattedDate)(value, rangeMs, timeZone);
125
- }
126
- }
127
- },
128
- yAxis: (0, _utils.getFormattedAxis)(yAxis, format),
129
- animation: false,
130
- tooltip: {
131
- show: true,
132
- trigger: 'axis',
133
- showContent: false
134
- },
135
- // https://echarts.apache.org/en/option.html#axisPointer
136
- axisPointer: {
137
- type: 'line',
138
- z: 0,
139
- triggerEmphasis: false,
140
- triggerTooltip: false,
141
- snap: true
142
- },
143
- toolbox: {
144
- feature: {
145
- dataZoom: {
146
- icon: null,
147
- yAxisIndex: 'none'
148
- }
149
- }
150
- },
151
- grid,
152
- legend
153
- };
154
- if (__experimentalEChartsOptionsOverride) {
155
- return __experimentalEChartsOptionsOverride(option);
156
- }
157
- return option;
158
- }, [
159
- data,
160
- yAxis,
161
- format,
162
- grid,
163
- legend,
164
- noDataOption,
165
- timeZone,
166
- __experimentalEChartsOptionsOverride,
167
- noDataVariant
168
- ]);
169
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
170
- style: {
171
- height
172
- },
173
- onClick: (e)=>{
174
- // Pin and unpin when clicking on chart canvas but not tooltip text.
175
- if (tooltipConfig.enablePinning && e.target instanceof HTMLCanvasElement) {
176
- setTooltipPinnedCoords((current)=>{
177
- if (current === null) {
178
- return {
179
- page: {
180
- x: e.pageX,
181
- y: e.pageY
182
- },
183
- client: {
184
- x: e.clientX,
185
- y: e.clientY
186
- },
187
- plotCanvas: {
188
- x: e.nativeEvent.offsetX,
189
- y: e.nativeEvent.offsetY
190
- },
191
- target: e.target
192
- };
193
- } else {
194
- return null;
195
- }
196
- });
197
- }
198
- },
199
- onMouseDown: (e)=>{
200
- const { clientX } = e;
201
- setIsDragging(true);
202
- setStartX(clientX);
203
- },
204
- onMouseMove: (e)=>{
205
- // Allow clicking inside tooltip to copy labels.
206
- if (!(e.target instanceof HTMLCanvasElement)) {
207
- return;
208
- }
209
- const { clientX } = e;
210
- if (isDragging) {
211
- const deltaX = clientX - startX;
212
- if (deltaX > 0) {
213
- // Hide tooltip when user drags to zoom.
214
- setShowTooltip(false);
215
- }
216
- }
217
- },
218
- onMouseUp: ()=>{
219
- setIsDragging(false);
220
- setStartX(0);
221
- setShowTooltip(true);
222
- },
223
- onMouseLeave: ()=>{
224
- if (tooltipPinnedCoords === null) {
225
- setShowTooltip(false);
226
- }
227
- if (chartRef.current !== undefined) {
228
- (0, _utils.clearHighlightedSeries)(chartRef.current);
229
- }
230
- },
231
- onMouseEnter: ()=>{
232
- setShowTooltip(true);
233
- if (chartRef.current !== undefined) {
234
- (0, _utils.enableDataZoom)(chartRef.current);
235
- }
236
- },
237
- onDoubleClick: (e)=>{
238
- setTooltipPinnedCoords(null);
239
- // either dispatch ECharts restore action to return to orig state or allow consumer to define behavior
240
- if (onDoubleClick === undefined) {
241
- if (chartRef.current !== undefined) {
242
- (0, _utils.restoreChart)(chartRef.current);
243
- }
244
- } else {
245
- onDoubleClick(e);
246
- }
247
- },
248
- children: [
249
- showTooltip === true && option.tooltip?.showContent === false && tooltipConfig.hidden !== true && /*#__PURE__*/ (0, _jsxruntime.jsx)(_TimeSeriesTooltip.LineChartTooltip, {
250
- chartRef: chartRef,
251
- chartData: data,
252
- wrapLabels: tooltipConfig.wrapLabels,
253
- enablePinning: tooltipConfig.enablePinning,
254
- pinnedPos: tooltipPinnedCoords,
255
- format: format,
256
- onUnpinClick: ()=>{
257
- setTooltipPinnedCoords(null);
258
- },
259
- containerId: chartsTheme.tooltipPortalContainerId
260
- }),
261
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_EChart.EChart, {
262
- sx: {
263
- width: '100%',
264
- height: '100%'
265
- },
266
- option: option,
267
- theme: chartsTheme.echartsTheme,
268
- onEvents: handleEvents,
269
- _instance: chartRef,
270
- syncGroup: syncGroup
271
- })
272
- ]
273
- });
274
- });
@@ -1,30 +0,0 @@
1
- // Copyright 2023 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
- _export_star(require("./LineChart"), exports);
18
- function _export_star(from, to) {
19
- Object.keys(from).forEach(function(k) {
20
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
21
- Object.defineProperty(to, k, {
22
- enumerable: true,
23
- get: function() {
24
- return from[k];
25
- }
26
- });
27
- }
28
- });
29
- return from;
30
- }