@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/components",
3
- "version": "0.0.0-snapshot-profile-89b306f",
3
+ "version": "0.0.0-snapshot-panel-actions-520389b",
4
4
  "description": "Common UI components used across Perses features",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -14,9 +14,6 @@
14
14
  "module": "dist/index.js",
15
15
  "main": "dist/cjs/index.js",
16
16
  "types": "dist/index.d.ts",
17
- "sideEffects": [
18
- "./dist/LineChart/LineChart.js"
19
- ],
20
17
  "scripts": {
21
18
  "clean": "rimraf dist/",
22
19
  "build": "concurrently \"npm:build:*\"",
@@ -36,12 +33,13 @@
36
33
  "@codemirror/lang-json": "^6.0.1",
37
34
  "@fontsource/lato": "^4.5.10",
38
35
  "@mui/x-date-pickers": "^7.23.1",
39
- "@perses-dev/core": "0.0.0-snapshot-profile-89b306f",
36
+ "@perses-dev/core": "0.0.0-snapshot-panel-actions-520389b",
40
37
  "@tanstack/react-table": "^8.20.5",
41
38
  "@uiw/react-codemirror": "^4.19.1",
42
39
  "date-fns": "^4.1.0",
43
40
  "date-fns-tz": "^3.2.0",
44
41
  "echarts": "5.5.0",
42
+ "immer": "^10.1.1",
45
43
  "lodash": "^4.17.21",
46
44
  "mathjs": "^10.6.4",
47
45
  "mdi-material-ui": "^7.9.2",
@@ -49,8 +47,7 @@
49
47
  "react-colorful": "^5.6.1",
50
48
  "react-error-boundary": "^3.1.4",
51
49
  "react-hook-form": "^7.51.3",
52
- "react-virtuoso": "^4.12.2",
53
- "zod": "^3.21.4"
50
+ "react-virtuoso": "^4.12.2"
54
51
  },
55
52
  "peerDependencies": {
56
53
  "@mui/material": "^6.1.10",
@@ -1,22 +0,0 @@
1
- import { MouseEvent } from 'react';
2
- import { FormatOptions } from '@perses-dev/core';
3
- import type { EChartsCoreOption, GridComponentOption, LegendComponentOption, YAXisComponentOption } from 'echarts';
4
- import { EChartsDataFormat, ChartInstance } from '../model';
5
- import { TooltipConfig } from '../TimeSeriesTooltip';
6
- import { ZoomEventData } from '../utils';
7
- export interface LineChartProps {
8
- height: number;
9
- data: EChartsDataFormat;
10
- yAxis?: YAXisComponentOption;
11
- format?: FormatOptions;
12
- grid?: GridComponentOption;
13
- legend?: LegendComponentOption;
14
- tooltipConfig?: TooltipConfig;
15
- noDataVariant?: 'chart' | 'message';
16
- syncGroup?: string;
17
- onDataZoom?: (e: ZoomEventData) => void;
18
- onDoubleClick?: (e: MouseEvent) => void;
19
- __experimentalEChartsOptionsOverride?: (options: EChartsCoreOption) => EChartsCoreOption;
20
- }
21
- export declare const LineChart: import("react").ForwardRefExoticComponent<LineChartProps & import("react").RefAttributes<ChartInstance>>;
22
- //# sourceMappingURL=LineChart.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../src/LineChart/LineChart.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAc,UAAU,EAAkD,MAAM,OAAO,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EAEnB,qBAAqB,EACrB,oBAAoB,EAErB,MAAM,SAAS,CAAC;AAgBjB,OAAO,EAAE,iBAAiB,EAA0B,aAAa,EAAE,MAAM,UAAU,CAAC;AAEpF,OAAO,EAAuC,aAAa,EAA0B,MAAM,sBAAsB,CAAC;AAClH,OAAO,EAOL,aAAa,EACd,MAAM,UAAU,CAAC;AAgBlB,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACxC,oCAAoC,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,iBAAiB,CAAC;CAC1F;AAED,eAAO,MAAM,SAAS,0GAmPpB,CAAC"}
@@ -1,266 +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
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- import { forwardRef, useImperativeHandle, useMemo, useRef, useState } from 'react';
15
- import { Box } from '@mui/material';
16
- import { use } from 'echarts/core';
17
- import { LineChart as EChartsLineChart } from 'echarts/charts';
18
- import { GridComponent, DataZoomComponent, MarkAreaComponent, MarkLineComponent, MarkPointComponent, TitleComponent, ToolboxComponent, TooltipComponent, LegendComponent } from 'echarts/components';
19
- import { CanvasRenderer } from 'echarts/renderers';
20
- import { EChart } from '../EChart';
21
- import { useChartsTheme, useTimeZone } from '../context';
22
- import { LineChartTooltip, DEFAULT_TOOLTIP_CONFIG } from '../TimeSeriesTooltip';
23
- import { clearHighlightedSeries, enableDataZoom, getDateRange, getFormattedDate, getFormattedAxis, restoreChart } from '../utils';
24
- use([
25
- EChartsLineChart,
26
- GridComponent,
27
- DataZoomComponent,
28
- MarkAreaComponent,
29
- MarkLineComponent,
30
- MarkPointComponent,
31
- TitleComponent,
32
- ToolboxComponent,
33
- TooltipComponent,
34
- LegendComponent,
35
- CanvasRenderer
36
- ]);
37
- export const LineChart = /*#__PURE__*/ forwardRef(function LineChart({ height, data, yAxis, format, grid, legend, tooltipConfig = DEFAULT_TOOLTIP_CONFIG, noDataVariant = 'message', syncGroup, onDataZoom, onDoubleClick, __experimentalEChartsOptionsOverride }, ref) {
38
- const chartsTheme = useChartsTheme();
39
- const chartRef = useRef();
40
- const [showTooltip, setShowTooltip] = useState(true);
41
- const [tooltipPinnedCoords, setTooltipPinnedCoords] = useState(null);
42
- const { timeZone } = useTimeZone();
43
- const [isDragging, setIsDragging] = useState(false);
44
- const [startX, setStartX] = useState(0);
45
- useImperativeHandle(ref, ()=>{
46
- return {
47
- highlightSeries ({ id }) {
48
- if (!chartRef.current) {
49
- // when chart undef, do not highlight series when hovering over legend
50
- return;
51
- }
52
- chartRef.current.dispatchAction({
53
- type: 'highlight',
54
- seriesId: id
55
- });
56
- },
57
- clearHighlightedSeries: ()=>{
58
- if (!chartRef.current) {
59
- // when chart undef, do not clear highlight series
60
- return;
61
- }
62
- clearHighlightedSeries(chartRef.current);
63
- }
64
- };
65
- }, []);
66
- const handleEvents = useMemo(()=>{
67
- return {
68
- datazoom: (params)=>{
69
- if (onDataZoom === undefined) {
70
- setTimeout(()=>{
71
- // workaround so unpin happens after click event
72
- setTooltipPinnedCoords(null);
73
- }, 10);
74
- }
75
- if (onDataZoom === undefined || params.batch[0] === undefined) return;
76
- const startIndex = params.batch[0].startValue ?? 0;
77
- const endIndex = params.batch[0].endValue ?? data.xAxis.length - 1;
78
- const xAxisStartValue = data.xAxis[startIndex];
79
- const xAxisEndValue = data.xAxis[endIndex];
80
- if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {
81
- const zoomEvent = {
82
- start: xAxisStartValue,
83
- end: xAxisEndValue,
84
- startIndex,
85
- endIndex
86
- };
87
- onDataZoom(zoomEvent);
88
- }
89
- }
90
- };
91
- }, [
92
- data,
93
- onDataZoom,
94
- setTooltipPinnedCoords
95
- ]);
96
- if (chartRef.current !== undefined) {
97
- enableDataZoom(chartRef.current);
98
- }
99
- const { noDataOption } = chartsTheme;
100
- const option = useMemo(()=>{
101
- if (data.timeSeries === undefined) return {};
102
- // The "chart" `noDataVariant` is only used when the `timeSeries` is an
103
- // empty array because a `null` value will throw an error.
104
- if (data.timeSeries === null || data.timeSeries.length === 0 && noDataVariant === 'message') return noDataOption;
105
- const rangeMs = data.rangeMs ?? getDateRange(data.xAxis);
106
- const option = {
107
- series: data.timeSeries,
108
- xAxis: {
109
- type: 'category',
110
- data: data.xAxis,
111
- max: data.xAxisMax,
112
- axisLabel: {
113
- formatter: (value)=>{
114
- return getFormattedDate(value, rangeMs, timeZone);
115
- }
116
- }
117
- },
118
- yAxis: getFormattedAxis(yAxis, format),
119
- animation: false,
120
- tooltip: {
121
- show: true,
122
- trigger: 'axis',
123
- showContent: false
124
- },
125
- // https://echarts.apache.org/en/option.html#axisPointer
126
- axisPointer: {
127
- type: 'line',
128
- z: 0,
129
- triggerEmphasis: false,
130
- triggerTooltip: false,
131
- snap: true
132
- },
133
- toolbox: {
134
- feature: {
135
- dataZoom: {
136
- icon: null,
137
- yAxisIndex: 'none'
138
- }
139
- }
140
- },
141
- grid,
142
- legend
143
- };
144
- if (__experimentalEChartsOptionsOverride) {
145
- return __experimentalEChartsOptionsOverride(option);
146
- }
147
- return option;
148
- }, [
149
- data,
150
- yAxis,
151
- format,
152
- grid,
153
- legend,
154
- noDataOption,
155
- timeZone,
156
- __experimentalEChartsOptionsOverride,
157
- noDataVariant
158
- ]);
159
- return /*#__PURE__*/ _jsxs(Box, {
160
- style: {
161
- height
162
- },
163
- onClick: (e)=>{
164
- // Pin and unpin when clicking on chart canvas but not tooltip text.
165
- if (tooltipConfig.enablePinning && e.target instanceof HTMLCanvasElement) {
166
- setTooltipPinnedCoords((current)=>{
167
- if (current === null) {
168
- return {
169
- page: {
170
- x: e.pageX,
171
- y: e.pageY
172
- },
173
- client: {
174
- x: e.clientX,
175
- y: e.clientY
176
- },
177
- plotCanvas: {
178
- x: e.nativeEvent.offsetX,
179
- y: e.nativeEvent.offsetY
180
- },
181
- target: e.target
182
- };
183
- } else {
184
- return null;
185
- }
186
- });
187
- }
188
- },
189
- onMouseDown: (e)=>{
190
- const { clientX } = e;
191
- setIsDragging(true);
192
- setStartX(clientX);
193
- },
194
- onMouseMove: (e)=>{
195
- // Allow clicking inside tooltip to copy labels.
196
- if (!(e.target instanceof HTMLCanvasElement)) {
197
- return;
198
- }
199
- const { clientX } = e;
200
- if (isDragging) {
201
- const deltaX = clientX - startX;
202
- if (deltaX > 0) {
203
- // Hide tooltip when user drags to zoom.
204
- setShowTooltip(false);
205
- }
206
- }
207
- },
208
- onMouseUp: ()=>{
209
- setIsDragging(false);
210
- setStartX(0);
211
- setShowTooltip(true);
212
- },
213
- onMouseLeave: ()=>{
214
- if (tooltipPinnedCoords === null) {
215
- setShowTooltip(false);
216
- }
217
- if (chartRef.current !== undefined) {
218
- clearHighlightedSeries(chartRef.current);
219
- }
220
- },
221
- onMouseEnter: ()=>{
222
- setShowTooltip(true);
223
- if (chartRef.current !== undefined) {
224
- enableDataZoom(chartRef.current);
225
- }
226
- },
227
- onDoubleClick: (e)=>{
228
- setTooltipPinnedCoords(null);
229
- // either dispatch ECharts restore action to return to orig state or allow consumer to define behavior
230
- if (onDoubleClick === undefined) {
231
- if (chartRef.current !== undefined) {
232
- restoreChart(chartRef.current);
233
- }
234
- } else {
235
- onDoubleClick(e);
236
- }
237
- },
238
- children: [
239
- showTooltip === true && option.tooltip?.showContent === false && tooltipConfig.hidden !== true && /*#__PURE__*/ _jsx(LineChartTooltip, {
240
- chartRef: chartRef,
241
- chartData: data,
242
- wrapLabels: tooltipConfig.wrapLabels,
243
- enablePinning: tooltipConfig.enablePinning,
244
- pinnedPos: tooltipPinnedCoords,
245
- format: format,
246
- onUnpinClick: ()=>{
247
- setTooltipPinnedCoords(null);
248
- },
249
- containerId: chartsTheme.tooltipPortalContainerId
250
- }),
251
- /*#__PURE__*/ _jsx(EChart, {
252
- sx: {
253
- width: '100%',
254
- height: '100%'
255
- },
256
- option: option,
257
- theme: chartsTheme.echartsTheme,
258
- onEvents: handleEvents,
259
- _instance: chartRef,
260
- syncGroup: syncGroup
261
- })
262
- ]
263
- });
264
- });
265
-
266
- //# sourceMappingURL=LineChart.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/LineChart/LineChart.tsx"],"sourcesContent":["// Copyright 2023 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, useImperativeHandle, useMemo, useRef, useState } from 'react';\nimport { FormatOptions } from '@perses-dev/core';\nimport { Box } from '@mui/material';\nimport type {\n EChartsCoreOption,\n GridComponentOption,\n LineSeriesOption,\n LegendComponentOption,\n YAXisComponentOption,\n TooltipComponentOption,\n} from 'echarts';\nimport { ECharts as EChartsInstance, use } from 'echarts/core';\nimport { LineChart as EChartsLineChart } from 'echarts/charts';\nimport {\n GridComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n LegendComponent,\n} from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { EChart, OnEventsType } from '../EChart';\nimport { EChartsDataFormat, ChartInstanceFocusOpts, ChartInstance } from '../model';\nimport { useChartsTheme, useTimeZone } from '../context';\nimport { CursorCoordinates, LineChartTooltip, TooltipConfig, DEFAULT_TOOLTIP_CONFIG } from '../TimeSeriesTooltip';\nimport {\n clearHighlightedSeries,\n enableDataZoom,\n getDateRange,\n getFormattedDate,\n getFormattedAxis,\n restoreChart,\n ZoomEventData,\n} from '../utils';\n\nuse([\n EChartsLineChart,\n GridComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n LegendComponent,\n CanvasRenderer,\n]);\n\nexport interface LineChartProps {\n height: number;\n data: EChartsDataFormat;\n yAxis?: YAXisComponentOption;\n format?: FormatOptions;\n grid?: GridComponentOption;\n legend?: LegendComponentOption;\n tooltipConfig?: TooltipConfig;\n noDataVariant?: 'chart' | 'message';\n syncGroup?: string;\n onDataZoom?: (e: ZoomEventData) => void;\n onDoubleClick?: (e: MouseEvent) => void;\n __experimentalEChartsOptionsOverride?: (options: EChartsCoreOption) => EChartsCoreOption;\n}\n\nexport const LineChart = forwardRef<ChartInstance, LineChartProps>(function LineChart(\n {\n height,\n data,\n yAxis,\n format,\n grid,\n legend,\n tooltipConfig = DEFAULT_TOOLTIP_CONFIG,\n noDataVariant = 'message',\n syncGroup,\n onDataZoom,\n onDoubleClick,\n __experimentalEChartsOptionsOverride,\n },\n ref\n) {\n const chartsTheme = useChartsTheme();\n const chartRef = useRef<EChartsInstance>();\n const [showTooltip, setShowTooltip] = useState<boolean>(true);\n const [tooltipPinnedCoords, setTooltipPinnedCoords] = useState<CursorCoordinates | null>(null);\n const { timeZone } = useTimeZone();\n\n const [isDragging, setIsDragging] = useState(false);\n const [startX, setStartX] = useState(0);\n\n useImperativeHandle(ref, () => {\n return {\n highlightSeries({ id }: 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: id });\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 startIndex = params.batch[0].startValue ?? 0;\n const endIndex = params.batch[0].endValue ?? data.xAxis.length - 1;\n const xAxisStartValue = data.xAxis[startIndex];\n const xAxisEndValue = data.xAxis[endIndex];\n\n if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {\n const zoomEvent: ZoomEventData = {\n start: xAxisStartValue,\n end: xAxisEndValue,\n startIndex,\n endIndex,\n };\n onDataZoom(zoomEvent);\n }\n },\n };\n }, [data, onDataZoom, setTooltipPinnedCoords]);\n\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n\n const { noDataOption } = chartsTheme;\n\n const option: EChartsCoreOption = useMemo(() => {\n if (data.timeSeries === undefined) return {};\n\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.timeSeries === null || (data.timeSeries.length === 0 && noDataVariant === 'message')) return noDataOption;\n\n const rangeMs = data.rangeMs ?? getDateRange(data.xAxis);\n\n const option: EChartsCoreOption = {\n series: data.timeSeries,\n xAxis: {\n type: 'category',\n data: data.xAxis,\n max: data.xAxisMax,\n axisLabel: {\n formatter: (value: number) => {\n return getFormattedDate(value, rangeMs, timeZone);\n },\n },\n },\n yAxis: getFormattedAxis(yAxis, format),\n animation: false,\n tooltip: {\n show: true,\n trigger: 'axis',\n showContent: false, // echarts tooltip content hidden since we use custom tooltip instead\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: true,\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 legend,\n };\n\n if (__experimentalEChartsOptionsOverride) {\n return __experimentalEChartsOptionsOverride(option);\n }\n return option;\n }, [data, yAxis, format, grid, legend, noDataOption, timeZone, __experimentalEChartsOptionsOverride, noDataVariant]);\n\n return (\n <Box\n style={{ height }}\n onClick={(e) => {\n // Pin and unpin when clicking on chart canvas but not tooltip text.\n if (tooltipConfig.enablePinning && e.target instanceof HTMLCanvasElement) {\n setTooltipPinnedCoords((current) => {\n if (current === null) {\n return {\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 } else {\n return null;\n }\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 <LineChartTooltip\n chartRef={chartRef}\n chartData={data}\n wrapLabels={tooltipConfig.wrapLabels}\n enablePinning={tooltipConfig.enablePinning}\n pinnedPos={tooltipPinnedCoords}\n format={format}\n onUnpinClick={() => {\n setTooltipPinnedCoords(null);\n }}\n containerId={chartsTheme.tooltipPortalContainerId}\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={syncGroup}\n />\n </Box>\n );\n});\n"],"names":["forwardRef","useImperativeHandle","useMemo","useRef","useState","Box","use","LineChart","EChartsLineChart","GridComponent","DataZoomComponent","MarkAreaComponent","MarkLineComponent","MarkPointComponent","TitleComponent","ToolboxComponent","TooltipComponent","LegendComponent","CanvasRenderer","EChart","useChartsTheme","useTimeZone","LineChartTooltip","DEFAULT_TOOLTIP_CONFIG","clearHighlightedSeries","enableDataZoom","getDateRange","getFormattedDate","getFormattedAxis","restoreChart","height","data","yAxis","format","grid","legend","tooltipConfig","noDataVariant","syncGroup","onDataZoom","onDoubleClick","__experimentalEChartsOptionsOverride","ref","chartsTheme","chartRef","showTooltip","setShowTooltip","tooltipPinnedCoords","setTooltipPinnedCoords","timeZone","isDragging","setIsDragging","startX","setStartX","highlightSeries","id","current","dispatchAction","type","seriesId","handleEvents","datazoom","params","undefined","setTimeout","batch","startIndex","startValue","endIndex","endValue","xAxis","length","xAxisStartValue","xAxisEndValue","zoomEvent","start","end","noDataOption","option","timeSeries","rangeMs","series","max","xAxisMax","axisLabel","formatter","value","animation","tooltip","show","trigger","showContent","axisPointer","z","triggerEmphasis","triggerTooltip","snap","toolbox","feature","dataZoom","icon","yAxisIndex","style","onClick","e","enablePinning","target","HTMLCanvasElement","page","x","pageX","y","pageY","client","clientX","clientY","plotCanvas","nativeEvent","offsetX","offsetY","onMouseDown","onMouseMove","deltaX","onMouseUp","onMouseLeave","onMouseEnter","hidden","chartData","wrapLabels","pinnedPos","onUnpinClick","containerId","tooltipPortalContainerId","sx","width","theme","echartsTheme","onEvents","_instance"],"mappings":"AAAA,oCAAoC;AACpC,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,mBAAmB,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAE/F,SAASC,GAAG,QAAQ,gBAAgB;AASpC,SAAqCC,GAAG,QAAQ,eAAe;AAC/D,SAASC,aAAaC,gBAAgB,QAAQ,iBAAiB;AAC/D,SACEC,aAAa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O;oBACPxG,QAAQ;gBACV;gBACAgD,QAAQA;gBACRyD,OAAO5F,YAAY6F,YAAY;gBAC/BC,UAAU7E;gBACV8E,WAAW9F;gBACXN,WAAWA;;;;AAInB,GAAG"}
@@ -1,2 +0,0 @@
1
- export * from './LineChart';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/LineChart/index.ts"],"names":[],"mappings":"AAaA,cAAc,aAAa,CAAC"}
@@ -1,15 +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
- export * from './LineChart';
14
-
15
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/LineChart/index.ts"],"sourcesContent":["// Copyright 2023 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\nexport * from './LineChart';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,cAAc"}
@@ -1,24 +0,0 @@
1
- import { MouseEvent } from 'react';
2
- import { TimeScale, FormatOptions, TimeSeries } from '@perses-dev/core';
3
- import type { EChartsCoreOption, GridComponentOption, YAXisComponentOption } from 'echarts';
4
- import { ChartInstance, TimeChartSeriesMapping } from '../model';
5
- import { ZoomEventData } from '../utils';
6
- import { TooltipConfig } from '../TimeSeriesTooltip';
7
- export interface TimeChartProps {
8
- height: number;
9
- data: TimeSeries[];
10
- seriesMapping: TimeChartSeriesMapping;
11
- timeScale?: TimeScale;
12
- yAxis?: YAXisComponentOption;
13
- format?: FormatOptions;
14
- grid?: GridComponentOption;
15
- tooltipConfig?: TooltipConfig;
16
- noDataVariant?: 'chart' | 'message';
17
- syncGroup?: string;
18
- isStackedBar?: boolean;
19
- onDataZoom?: (e: ZoomEventData) => void;
20
- onDoubleClick?: (e: MouseEvent) => void;
21
- __experimentalEChartsOptionsOverride?: (options: EChartsCoreOption) => EChartsCoreOption;
22
- }
23
- export declare const TimeChart: import("react").ForwardRefExoticComponent<TimeChartProps & import("react").RefAttributes<ChartInstance>>;
24
- //# sourceMappingURL=TimeChart.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TimeChart.d.ts","sourceRoot":"","sources":["../../src/TimeChart/TimeChart.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAc,UAAU,EAA6D,MAAM,OAAO,CAAC;AAM1G,OAAO,EAAsB,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EAEnB,oBAAoB,EAErB,MAAM,SAAS,CAAC;AAgBjB,OAAO,EAA0B,aAAa,EAAE,sBAAsB,EAA4B,MAAM,UAAU,CAAC;AAEnH,OAAO,EAQL,aAAa,EACd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAuC,aAAa,EAA0B,MAAM,sBAAsB,CAAC;AAkBlH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,aAAa,EAAE,sBAAsB,CAAC;IACtC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACxC,oCAAoC,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,iBAAiB,CAAC;CAC1F;AAED,eAAO,MAAM,SAAS,0GA0WpB,CAAC"}