@perses-dev/components 0.51.0-beta.1 → 0.51.0-rc.1
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.
- package/README.md +1 -8
- package/dist/EChart/EChart.d.ts +3 -2
- package/dist/EChart/EChart.d.ts.map +1 -1
- package/dist/EChart/EChart.js +19 -7
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/JSONEditor.d.ts.map +1 -1
- package/dist/JSONEditor.js +5 -6
- package/dist/JSONEditor.js.map +1 -1
- package/dist/Table/Table.d.ts +1 -1
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +14 -4
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableFoot.d.ts +4 -0
- package/dist/Table/TableFoot.d.ts.map +1 -0
- package/dist/{BarChart/index.js → Table/TableFoot.js} +11 -3
- package/dist/Table/TableFoot.js.map +1 -0
- package/dist/Table/VirtualizedTable.d.ts +3 -2
- package/dist/Table/VirtualizedTable.d.ts.map +1 -1
- package/dist/Table/VirtualizedTable.js +31 -2
- package/dist/Table/VirtualizedTable.js.map +1 -1
- package/dist/Table/model/table-model.d.ts +10 -1
- package/dist/Table/model/table-model.d.ts.map +1 -1
- package/dist/Table/model/table-model.js.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.d.ts +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js +2 -5
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/index.d.ts +0 -1
- package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/index.js +0 -1
- package/dist/TimeSeriesTooltip/index.js.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts +1 -8
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.js +6 -16
- package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
- package/dist/TimeSeriesTooltip/utils.d.ts +1 -1
- package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/utils.js +27 -23
- package/dist/TimeSeriesTooltip/utils.js.map +1 -1
- package/dist/cjs/EChart/EChart.js +17 -5
- package/dist/cjs/JSONEditor.js +4 -5
- package/dist/cjs/Table/Table.js +13 -3
- package/dist/cjs/{StatChart/utils/formatStatChartValue.js → Table/TableFoot.js} +12 -15
- package/dist/cjs/Table/VirtualizedTable.js +30 -1
- package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +1 -4
- package/dist/cjs/TimeSeriesTooltip/index.js +0 -1
- package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +6 -25
- package/dist/cjs/TimeSeriesTooltip/utils.js +26 -22
- package/dist/cjs/context/ChartsProvider.js +3 -1
- package/dist/cjs/index.js +0 -7
- package/dist/cjs/test-utils/theme.js +1 -0
- package/dist/cjs/utils/axis.js +3 -18
- package/dist/cjs/utils/format.js +0 -21
- package/dist/context/ChartsProvider.d.ts +2 -0
- package/dist/context/ChartsProvider.d.ts.map +1 -1
- package/dist/context/ChartsProvider.js +3 -1
- package/dist/context/ChartsProvider.js.map +1 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -7
- package/dist/index.js.map +1 -1
- package/dist/model/graph.d.ts +0 -1
- package/dist/model/graph.d.ts.map +1 -1
- package/dist/model/graph.js.map +1 -1
- package/dist/test-utils/theme.d.ts.map +1 -1
- package/dist/test-utils/theme.js +1 -0
- package/dist/test-utils/theme.js.map +1 -1
- package/dist/utils/axis.d.ts +0 -4
- package/dist/utils/axis.d.ts.map +1 -1
- package/dist/utils/axis.js +0 -9
- package/dist/utils/axis.js.map +1 -1
- package/dist/utils/chart-actions.d.ts +0 -2
- package/dist/utils/chart-actions.d.ts.map +1 -1
- package/dist/utils/chart-actions.js.map +1 -1
- package/dist/utils/format.d.ts +0 -1
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +0 -20
- package/dist/utils/format.js.map +1 -1
- package/package.json +2 -7
- package/dist/BarChart/BarChart.d.ts +0 -16
- package/dist/BarChart/BarChart.d.ts.map +0 -1
- package/dist/BarChart/BarChart.js +0 -134
- package/dist/BarChart/BarChart.js.map +0 -1
- package/dist/BarChart/index.d.ts +0 -2
- package/dist/BarChart/index.d.ts.map +0 -1
- package/dist/BarChart/index.js.map +0 -1
- package/dist/GaugeChart/GaugeChart.d.ts +0 -23
- package/dist/GaugeChart/GaugeChart.d.ts.map +0 -1
- package/dist/GaugeChart/GaugeChart.js +0 -214
- package/dist/GaugeChart/GaugeChart.js.map +0 -1
- package/dist/GaugeChart/index.d.ts +0 -2
- package/dist/GaugeChart/index.d.ts.map +0 -1
- package/dist/GaugeChart/index.js +0 -15
- package/dist/GaugeChart/index.js.map +0 -1
- package/dist/LineChart/LineChart.d.ts +0 -22
- package/dist/LineChart/LineChart.d.ts.map +0 -1
- package/dist/LineChart/LineChart.js +0 -266
- package/dist/LineChart/LineChart.js.map +0 -1
- package/dist/LineChart/index.d.ts +0 -2
- package/dist/LineChart/index.d.ts.map +0 -1
- package/dist/LineChart/index.js +0 -15
- package/dist/LineChart/index.js.map +0 -1
- package/dist/PieChart/PieChart.d.ts +0 -14
- package/dist/PieChart/PieChart.d.ts.map +0 -1
- package/dist/PieChart/PieChart.js +0 -92
- package/dist/PieChart/PieChart.js.map +0 -1
- package/dist/PieChart/index.d.ts +0 -2
- package/dist/PieChart/index.d.ts.map +0 -1
- package/dist/PieChart/index.js +0 -15
- package/dist/PieChart/index.js.map +0 -1
- package/dist/StatChart/StatChart.d.ts +0 -21
- package/dist/StatChart/StatChart.d.ts.map +0 -1
- package/dist/StatChart/StatChart.js +0 -185
- package/dist/StatChart/StatChart.js.map +0 -1
- package/dist/StatChart/calculateFontSize.d.ts +0 -16
- package/dist/StatChart/calculateFontSize.d.ts.map +0 -1
- package/dist/StatChart/calculateFontSize.js +0 -49
- package/dist/StatChart/calculateFontSize.js.map +0 -1
- package/dist/StatChart/index.d.ts +0 -2
- package/dist/StatChart/index.d.ts.map +0 -1
- package/dist/StatChart/index.js +0 -15
- package/dist/StatChart/index.js.map +0 -1
- package/dist/StatChart/utils/formatStatChartValue.d.ts +0 -3
- package/dist/StatChart/utils/formatStatChartValue.d.ts.map +0 -1
- package/dist/StatChart/utils/formatStatChartValue.js +0 -26
- package/dist/StatChart/utils/formatStatChartValue.js.map +0 -1
- package/dist/StatusHistoryChart/StatusHistoryChart.d.ts +0 -27
- package/dist/StatusHistoryChart/StatusHistoryChart.d.ts.map +0 -1
- package/dist/StatusHistoryChart/StatusHistoryChart.js +0 -132
- package/dist/StatusHistoryChart/StatusHistoryChart.js.map +0 -1
- package/dist/StatusHistoryChart/StatusHistoryTooltip.d.ts +0 -13
- package/dist/StatusHistoryChart/StatusHistoryTooltip.d.ts.map +0 -1
- package/dist/StatusHistoryChart/StatusHistoryTooltip.js +0 -47
- package/dist/StatusHistoryChart/StatusHistoryTooltip.js.map +0 -1
- package/dist/StatusHistoryChart/get-formatted-axis-label.d.ts +0 -2
- package/dist/StatusHistoryChart/get-formatted-axis-label.d.ts.map +0 -1
- package/dist/StatusHistoryChart/get-formatted-axis-label.js +0 -41
- package/dist/StatusHistoryChart/get-formatted-axis-label.js.map +0 -1
- package/dist/StatusHistoryChart/index.d.ts +0 -3
- package/dist/StatusHistoryChart/index.d.ts.map +0 -1
- package/dist/StatusHistoryChart/index.js +0 -16
- package/dist/StatusHistoryChart/index.js.map +0 -1
- package/dist/StatusHistoryChart/utils/get-color.d.ts +0 -6
- package/dist/StatusHistoryChart/utils/get-color.d.ts.map +0 -1
- package/dist/StatusHistoryChart/utils/get-color.js +0 -100
- package/dist/StatusHistoryChart/utils/get-color.js.map +0 -1
- package/dist/StatusHistoryChart/utils/get-tooltip-position.d.ts +0 -3
- package/dist/StatusHistoryChart/utils/get-tooltip-position.d.ts.map +0 -1
- package/dist/StatusHistoryChart/utils/get-tooltip-position.js +0 -27
- package/dist/StatusHistoryChart/utils/get-tooltip-position.js.map +0 -1
- package/dist/TimeChart/TimeChart.d.ts +0 -24
- package/dist/TimeChart/TimeChart.d.ts.map +0 -1
- package/dist/TimeChart/TimeChart.js +0 -394
- package/dist/TimeChart/TimeChart.js.map +0 -1
- package/dist/TimeChart/index.d.ts +0 -2
- package/dist/TimeChart/index.d.ts.map +0 -1
- package/dist/TimeChart/index.js +0 -15
- package/dist/TimeChart/index.js.map +0 -1
- package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts +0 -21
- package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +0 -1
- package/dist/TimeSeriesTooltip/LineChartTooltip.js +0 -104
- package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +0 -1
- package/dist/cjs/BarChart/BarChart.js +0 -142
- package/dist/cjs/BarChart/index.js +0 -30
- package/dist/cjs/GaugeChart/GaugeChart.js +0 -227
- package/dist/cjs/GaugeChart/index.js +0 -30
- package/dist/cjs/LineChart/LineChart.js +0 -274
- package/dist/cjs/LineChart/index.js +0 -30
- package/dist/cjs/PieChart/PieChart.js +0 -100
- package/dist/cjs/PieChart/index.js +0 -30
- package/dist/cjs/StatChart/StatChart.js +0 -198
- package/dist/cjs/StatChart/calculateFontSize.js +0 -55
- package/dist/cjs/StatChart/index.js +0 -30
- package/dist/cjs/StatusHistoryChart/StatusHistoryChart.js +0 -140
- package/dist/cjs/StatusHistoryChart/StatusHistoryTooltip.js +0 -55
- package/dist/cjs/StatusHistoryChart/get-formatted-axis-label.js +0 -48
- package/dist/cjs/StatusHistoryChart/index.js +0 -31
- package/dist/cjs/StatusHistoryChart/utils/get-color.js +0 -125
- package/dist/cjs/StatusHistoryChart/utils/get-tooltip-position.js +0 -35
- package/dist/cjs/TimeChart/TimeChart.js +0 -407
- package/dist/cjs/TimeChart/index.js +0 -30
- package/dist/cjs/TimeSeriesTooltip/LineChartTooltip.js +0 -117
|
@@ -1,407 +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, "TimeChart", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function() {
|
|
20
|
-
return TimeChart;
|
|
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 _datefnstz = require("date-fns-tz");
|
|
29
|
-
const _core = require("@perses-dev/core");
|
|
30
|
-
const _core1 = require("echarts/core");
|
|
31
|
-
const _charts = require("echarts/charts");
|
|
32
|
-
const _components = require("echarts/components");
|
|
33
|
-
const _renderers = require("echarts/renderers");
|
|
34
|
-
const _EChart = require("../EChart");
|
|
35
|
-
const _model = require("../model");
|
|
36
|
-
const _ChartsProvider = require("../context/ChartsProvider");
|
|
37
|
-
const _utils = require("../utils");
|
|
38
|
-
const _TimeSeriesTooltip = require("../TimeSeriesTooltip");
|
|
39
|
-
const _TimeZoneProvider = require("../context/TimeZoneProvider");
|
|
40
|
-
function _interop_require_default(obj) {
|
|
41
|
-
return obj && obj.__esModule ? obj : {
|
|
42
|
-
default: obj
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
(0, _core1.use)([
|
|
46
|
-
_charts.LineChart,
|
|
47
|
-
_charts.BarChart,
|
|
48
|
-
_components.GridComponent,
|
|
49
|
-
_components.DatasetComponent,
|
|
50
|
-
_components.DataZoomComponent,
|
|
51
|
-
_components.MarkAreaComponent,
|
|
52
|
-
_components.MarkLineComponent,
|
|
53
|
-
_components.MarkPointComponent,
|
|
54
|
-
_components.TitleComponent,
|
|
55
|
-
_components.ToolboxComponent,
|
|
56
|
-
_components.TooltipComponent,
|
|
57
|
-
_renderers.CanvasRenderer
|
|
58
|
-
]);
|
|
59
|
-
const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ height, data, seriesMapping, timeScale: timeScaleProp, yAxis, format, grid, isStackedBar = false, tooltipConfig = _TimeSeriesTooltip.DEFAULT_TOOLTIP_CONFIG, noDataVariant = 'message', syncGroup, onDataZoom, onDoubleClick, __experimentalEChartsOptionsOverride }, ref) {
|
|
60
|
-
const { chartsTheme, enablePinning, lastTooltipPinnedCoords, setLastTooltipPinnedCoords } = (0, _ChartsProvider.useChartsContext)();
|
|
61
|
-
const isPinningEnabled = tooltipConfig.enablePinning && enablePinning;
|
|
62
|
-
const chartRef = (0, _react.useRef)();
|
|
63
|
-
const [showTooltip, setShowTooltip] = (0, _react.useState)(true);
|
|
64
|
-
const [tooltipPinnedCoords, setTooltipPinnedCoords] = (0, _react.useState)(null);
|
|
65
|
-
const [pinnedCrosshair, setPinnedCrosshair] = (0, _react.useState)(null);
|
|
66
|
-
const [isDragging, setIsDragging] = (0, _react.useState)(false);
|
|
67
|
-
const [startX, setStartX] = (0, _react.useState)(0);
|
|
68
|
-
const { timeZone } = (0, _TimeZoneProvider.useTimeZone)();
|
|
69
|
-
let timeScale;
|
|
70
|
-
if (timeScaleProp === undefined) {
|
|
71
|
-
const commonTimeScale = (0, _core.getCommonTimeScale)(data);
|
|
72
|
-
if (commonTimeScale === undefined) {
|
|
73
|
-
// set default to past 5 years
|
|
74
|
-
const today = new Date();
|
|
75
|
-
const pastDate = new Date(today);
|
|
76
|
-
pastDate.setFullYear(today.getFullYear() - 5);
|
|
77
|
-
const todayMs = today.getTime();
|
|
78
|
-
const pastDateMs = pastDate.getTime();
|
|
79
|
-
timeScale = {
|
|
80
|
-
startMs: pastDateMs,
|
|
81
|
-
endMs: todayMs,
|
|
82
|
-
stepMs: 1,
|
|
83
|
-
rangeMs: todayMs - pastDateMs
|
|
84
|
-
};
|
|
85
|
-
} else {
|
|
86
|
-
timeScale = commonTimeScale;
|
|
87
|
-
}
|
|
88
|
-
} else {
|
|
89
|
-
timeScale = timeScaleProp;
|
|
90
|
-
}
|
|
91
|
-
(0, _react.useImperativeHandle)(ref, ()=>{
|
|
92
|
-
return {
|
|
93
|
-
highlightSeries ({ name }) {
|
|
94
|
-
if (!chartRef.current) {
|
|
95
|
-
// when chart undef, do not highlight series when hovering over legend
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
chartRef.current.dispatchAction({
|
|
99
|
-
type: 'highlight',
|
|
100
|
-
seriesId: name
|
|
101
|
-
});
|
|
102
|
-
},
|
|
103
|
-
clearHighlightedSeries: ()=>{
|
|
104
|
-
if (!chartRef.current) {
|
|
105
|
-
// when chart undef, do not clear highlight series
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
(0, _utils.clearHighlightedSeries)(chartRef.current);
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
}, []);
|
|
112
|
-
const handleEvents = (0, _react.useMemo)(()=>{
|
|
113
|
-
return {
|
|
114
|
-
datazoom: (params)=>{
|
|
115
|
-
if (onDataZoom === undefined) {
|
|
116
|
-
setTimeout(()=>{
|
|
117
|
-
// workaround so unpin happens after click event
|
|
118
|
-
setTooltipPinnedCoords(null);
|
|
119
|
-
}, 10);
|
|
120
|
-
}
|
|
121
|
-
if (onDataZoom === undefined || params.batch[0] === undefined) return;
|
|
122
|
-
const xAxisStartValue = params.batch[0].startValue;
|
|
123
|
-
const xAxisEndValue = params.batch[0].endValue;
|
|
124
|
-
if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {
|
|
125
|
-
const zoomEvent = {
|
|
126
|
-
start: xAxisStartValue,
|
|
127
|
-
end: xAxisEndValue
|
|
128
|
-
};
|
|
129
|
-
onDataZoom(zoomEvent);
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
finished: ()=>{
|
|
133
|
-
if (chartRef.current !== undefined) {
|
|
134
|
-
(0, _utils.enableDataZoom)(chartRef.current);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
}, [
|
|
139
|
-
onDataZoom,
|
|
140
|
-
setTooltipPinnedCoords
|
|
141
|
-
]);
|
|
142
|
-
const { noDataOption } = chartsTheme;
|
|
143
|
-
const option = (0, _react.useMemo)(()=>{
|
|
144
|
-
// The "chart" `noDataVariant` is only used when the `timeSeries` is an
|
|
145
|
-
// empty array because a `null` value will throw an error.
|
|
146
|
-
if (data === null || data.length === 0 && noDataVariant === 'message') return noDataOption;
|
|
147
|
-
// Utilizes ECharts dataset so raw data is separate from series option style properties
|
|
148
|
-
// https://apache.github.io/echarts-handbook/en/concepts/dataset/
|
|
149
|
-
const dataset = [];
|
|
150
|
-
const isLocalTimeZone = timeZone === 'local';
|
|
151
|
-
data.map((d, index)=>{
|
|
152
|
-
const values = d.values.map(([timestamp, value])=>{
|
|
153
|
-
const val = value === null ? '-' : value; // echarts use '-' to represent null data
|
|
154
|
-
return [
|
|
155
|
-
isLocalTimeZone ? timestamp : (0, _datefnstz.toZonedTime)(timestamp, timeZone),
|
|
156
|
-
val
|
|
157
|
-
];
|
|
158
|
-
});
|
|
159
|
-
dataset.push({
|
|
160
|
-
id: index,
|
|
161
|
-
source: [
|
|
162
|
-
...values
|
|
163
|
-
],
|
|
164
|
-
dimensions: [
|
|
165
|
-
'time',
|
|
166
|
-
'value'
|
|
167
|
-
]
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
const updatedSeriesMapping = enablePinning && pinnedCrosshair !== null ? [
|
|
171
|
-
...seriesMapping,
|
|
172
|
-
pinnedCrosshair
|
|
173
|
-
] : seriesMapping;
|
|
174
|
-
const option = {
|
|
175
|
-
dataset: dataset,
|
|
176
|
-
series: updatedSeriesMapping,
|
|
177
|
-
xAxis: {
|
|
178
|
-
type: 'time',
|
|
179
|
-
min: isLocalTimeZone ? timeScale.startMs : (0, _datefnstz.toZonedTime)(timeScale.startMs, timeZone),
|
|
180
|
-
max: isLocalTimeZone ? timeScale.endMs : (0, _datefnstz.toZonedTime)(timeScale.endMs, timeZone),
|
|
181
|
-
axisLabel: {
|
|
182
|
-
hideOverlap: true,
|
|
183
|
-
formatter: (0, _utils.getFormattedAxisLabel)(timeScale.rangeMs ?? 0)
|
|
184
|
-
},
|
|
185
|
-
axisPointer: {
|
|
186
|
-
snap: false
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
yAxis: (0, _utils.getFormattedAxis)(yAxis, format),
|
|
190
|
-
animation: false,
|
|
191
|
-
tooltip: {
|
|
192
|
-
show: true,
|
|
193
|
-
// ECharts tooltip content hidden by default since we use custom tooltip instead.
|
|
194
|
-
// Stacked bar uses ECharts tooltip so subgroup data shows correctly.
|
|
195
|
-
showContent: isStackedBar,
|
|
196
|
-
trigger: isStackedBar ? 'item' : 'axis',
|
|
197
|
-
appendToBody: isStackedBar
|
|
198
|
-
},
|
|
199
|
-
// https://echarts.apache.org/en/option.html#axisPointer
|
|
200
|
-
axisPointer: {
|
|
201
|
-
type: 'line',
|
|
202
|
-
z: 0,
|
|
203
|
-
triggerEmphasis: false,
|
|
204
|
-
triggerTooltip: false,
|
|
205
|
-
snap: false
|
|
206
|
-
},
|
|
207
|
-
toolbox: {
|
|
208
|
-
feature: {
|
|
209
|
-
dataZoom: {
|
|
210
|
-
icon: null,
|
|
211
|
-
yAxisIndex: 'none'
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
},
|
|
215
|
-
grid
|
|
216
|
-
};
|
|
217
|
-
if (__experimentalEChartsOptionsOverride) {
|
|
218
|
-
return __experimentalEChartsOptionsOverride(option);
|
|
219
|
-
}
|
|
220
|
-
return option;
|
|
221
|
-
}, [
|
|
222
|
-
data,
|
|
223
|
-
seriesMapping,
|
|
224
|
-
timeScale,
|
|
225
|
-
yAxis,
|
|
226
|
-
format,
|
|
227
|
-
grid,
|
|
228
|
-
noDataOption,
|
|
229
|
-
__experimentalEChartsOptionsOverride,
|
|
230
|
-
noDataVariant,
|
|
231
|
-
timeZone,
|
|
232
|
-
isStackedBar,
|
|
233
|
-
enablePinning,
|
|
234
|
-
pinnedCrosshair
|
|
235
|
-
]);
|
|
236
|
-
// Update adjacent charts so tooltip is unpinned when current chart is clicked.
|
|
237
|
-
(0, _react.useEffect)(()=>{
|
|
238
|
-
// Only allow pinning one tooltip at a time, subsequent tooltip click unpins previous.
|
|
239
|
-
// Multiple tooltips can only be pinned if Ctrl or Cmd key is pressed while clicking.
|
|
240
|
-
const multipleTooltipsPinned = tooltipPinnedCoords !== null && lastTooltipPinnedCoords !== null;
|
|
241
|
-
if (multipleTooltipsPinned) {
|
|
242
|
-
if (!(0, _isEqual.default)(lastTooltipPinnedCoords, tooltipPinnedCoords)) {
|
|
243
|
-
setTooltipPinnedCoords(null);
|
|
244
|
-
if (tooltipPinnedCoords !== null && pinnedCrosshair !== null) {
|
|
245
|
-
setPinnedCrosshair(null);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
// tooltipPinnedCoords CANNOT be in dep array or tooltip pinning breaks in the current chart's onClick
|
|
250
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
251
|
-
}, [
|
|
252
|
-
lastTooltipPinnedCoords,
|
|
253
|
-
seriesMapping
|
|
254
|
-
]);
|
|
255
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
256
|
-
style: {
|
|
257
|
-
height
|
|
258
|
-
},
|
|
259
|
-
// onContextMenu={(e) => {
|
|
260
|
-
// // TODO: confirm tooltip pinning works correctly on Windows, should e.preventDefault() be added here
|
|
261
|
-
// e.preventDefault(); // Prevent the default behaviour when right clicked
|
|
262
|
-
// }}
|
|
263
|
-
onClick: (e)=>{
|
|
264
|
-
// Allows user to opt-in to multi tooltip pinning when Ctrl or Cmd key held down
|
|
265
|
-
const isControlKeyPressed = e.ctrlKey || e.metaKey;
|
|
266
|
-
if (isControlKeyPressed) {
|
|
267
|
-
e.preventDefault();
|
|
268
|
-
}
|
|
269
|
-
// Determine where on chart canvas to plot pinned crosshair as markLine.
|
|
270
|
-
const pointInGrid = (0, _utils.getPointInGrid)(e.nativeEvent.offsetX, e.nativeEvent.offsetY, chartRef.current);
|
|
271
|
-
if (pointInGrid === null) {
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
// Pin and unpin when clicking on chart canvas but not tooltip text.
|
|
275
|
-
if (isPinningEnabled && e.target instanceof HTMLCanvasElement) {
|
|
276
|
-
// Pin tooltip and update shared charts context to remember these coordinates.
|
|
277
|
-
const pinnedPos = {
|
|
278
|
-
page: {
|
|
279
|
-
x: e.pageX,
|
|
280
|
-
y: e.pageY
|
|
281
|
-
},
|
|
282
|
-
client: {
|
|
283
|
-
x: e.clientX,
|
|
284
|
-
y: e.clientY
|
|
285
|
-
},
|
|
286
|
-
plotCanvas: {
|
|
287
|
-
x: e.nativeEvent.offsetX,
|
|
288
|
-
y: e.nativeEvent.offsetY
|
|
289
|
-
},
|
|
290
|
-
target: e.target
|
|
291
|
-
};
|
|
292
|
-
setTooltipPinnedCoords((current)=>{
|
|
293
|
-
if (current === null) {
|
|
294
|
-
return pinnedPos;
|
|
295
|
-
} else {
|
|
296
|
-
setPinnedCrosshair(null);
|
|
297
|
-
return null;
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
setPinnedCrosshair((current)=>{
|
|
301
|
-
// Only add pinned crosshair line series when there is not one already in seriesMapping.
|
|
302
|
-
if (current === null) {
|
|
303
|
-
const cursorX = pointInGrid[0];
|
|
304
|
-
// Only need to loop through first dataset source since getCommonTimeScale ensures xAxis timestamps are consistent
|
|
305
|
-
const firstTimeSeriesValues = data[0]?.values;
|
|
306
|
-
const closestTimestamp = (0, _utils.getClosestTimestamp)(firstTimeSeriesValues, cursorX);
|
|
307
|
-
// Crosshair snaps to nearest timestamp since cursor may be slightly to left or right
|
|
308
|
-
const pinnedCrosshair = (0, _merge.default)({}, _model.DEFAULT_PINNED_CROSSHAIR, {
|
|
309
|
-
markLine: {
|
|
310
|
-
data: [
|
|
311
|
-
{
|
|
312
|
-
xAxis: closestTimestamp
|
|
313
|
-
}
|
|
314
|
-
]
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
return pinnedCrosshair;
|
|
318
|
-
} else {
|
|
319
|
-
// Clear previously set pinned crosshair
|
|
320
|
-
return null;
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
if (!isControlKeyPressed) {
|
|
324
|
-
setLastTooltipPinnedCoords(pinnedPos);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
},
|
|
328
|
-
onMouseDown: (e)=>{
|
|
329
|
-
const { clientX } = e;
|
|
330
|
-
setIsDragging(true);
|
|
331
|
-
setStartX(clientX);
|
|
332
|
-
},
|
|
333
|
-
onMouseMove: (e)=>{
|
|
334
|
-
// Allow clicking inside tooltip to copy labels.
|
|
335
|
-
if (!(e.target instanceof HTMLCanvasElement)) {
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
const { clientX } = e;
|
|
339
|
-
if (isDragging) {
|
|
340
|
-
const deltaX = clientX - startX;
|
|
341
|
-
if (deltaX > 0) {
|
|
342
|
-
// Hide tooltip when user drags to zoom.
|
|
343
|
-
setShowTooltip(false);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
},
|
|
347
|
-
onMouseUp: ()=>{
|
|
348
|
-
setIsDragging(false);
|
|
349
|
-
setStartX(0);
|
|
350
|
-
setShowTooltip(true);
|
|
351
|
-
},
|
|
352
|
-
onMouseLeave: ()=>{
|
|
353
|
-
if (tooltipPinnedCoords === null) {
|
|
354
|
-
setShowTooltip(false);
|
|
355
|
-
}
|
|
356
|
-
if (chartRef.current !== undefined) {
|
|
357
|
-
(0, _utils.clearHighlightedSeries)(chartRef.current);
|
|
358
|
-
}
|
|
359
|
-
},
|
|
360
|
-
onMouseEnter: ()=>{
|
|
361
|
-
setShowTooltip(true);
|
|
362
|
-
if (chartRef.current !== undefined) {
|
|
363
|
-
(0, _utils.enableDataZoom)(chartRef.current);
|
|
364
|
-
}
|
|
365
|
-
},
|
|
366
|
-
onDoubleClick: (e)=>{
|
|
367
|
-
setTooltipPinnedCoords(null);
|
|
368
|
-
// either dispatch ECharts restore action to return to orig state or allow consumer to define behavior
|
|
369
|
-
if (onDoubleClick === undefined) {
|
|
370
|
-
if (chartRef.current !== undefined) {
|
|
371
|
-
(0, _utils.restoreChart)(chartRef.current);
|
|
372
|
-
}
|
|
373
|
-
} else {
|
|
374
|
-
onDoubleClick(e);
|
|
375
|
-
}
|
|
376
|
-
},
|
|
377
|
-
children: [
|
|
378
|
-
showTooltip === true && option.tooltip?.showContent === false && tooltipConfig.hidden !== true && /*#__PURE__*/ (0, _jsxruntime.jsx)(_TimeSeriesTooltip.TimeChartTooltip, {
|
|
379
|
-
containerId: chartsTheme.tooltipPortalContainerId,
|
|
380
|
-
chartRef: chartRef,
|
|
381
|
-
data: data,
|
|
382
|
-
seriesMapping: seriesMapping,
|
|
383
|
-
wrapLabels: tooltipConfig.wrapLabels,
|
|
384
|
-
enablePinning: isPinningEnabled,
|
|
385
|
-
pinnedPos: tooltipPinnedCoords,
|
|
386
|
-
format: format,
|
|
387
|
-
onUnpinClick: ()=>{
|
|
388
|
-
// Unpins tooltip when clicking Pin icon in TooltipHeader.
|
|
389
|
-
setTooltipPinnedCoords(null);
|
|
390
|
-
// Clear previously set pinned crosshair.
|
|
391
|
-
setPinnedCrosshair(null);
|
|
392
|
-
}
|
|
393
|
-
}),
|
|
394
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_EChart.EChart, {
|
|
395
|
-
sx: {
|
|
396
|
-
width: '100%',
|
|
397
|
-
height: '100%'
|
|
398
|
-
},
|
|
399
|
-
option: option,
|
|
400
|
-
theme: chartsTheme.echartsTheme,
|
|
401
|
-
onEvents: handleEvents,
|
|
402
|
-
_instance: chartRef,
|
|
403
|
-
syncGroup: syncGroup
|
|
404
|
-
})
|
|
405
|
-
]
|
|
406
|
-
});
|
|
407
|
-
});
|
|
@@ -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("./TimeChart"), 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
|
-
}
|
|
@@ -1,117 +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, "LineChartTooltip", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function() {
|
|
20
|
-
return LineChartTooltip;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const _material = require("@mui/material");
|
|
25
|
-
const _react = require("react");
|
|
26
|
-
const _useresizeobserver = /*#__PURE__*/ _interop_require_default(require("use-resize-observer"));
|
|
27
|
-
const _TooltipContent = require("./TooltipContent");
|
|
28
|
-
const _TooltipHeader = require("./TooltipHeader");
|
|
29
|
-
const _nearbyseries = require("./nearby-series");
|
|
30
|
-
const _tooltipmodel = require("./tooltip-model");
|
|
31
|
-
const _utils = require("./utils");
|
|
32
|
-
function _interop_require_default(obj) {
|
|
33
|
-
return obj && obj.__esModule ? obj : {
|
|
34
|
-
default: obj
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
const LineChartTooltip = /*#__PURE__*/ (0, _react.memo)(function LineChartTooltip({ chartRef, chartData, enablePinning = true, wrapLabels, format, onUnpinClick, pinnedPos, containerId }) {
|
|
38
|
-
const [showAllSeries, setShowAllSeries] = (0, _react.useState)(false);
|
|
39
|
-
const mousePos = (0, _tooltipmodel.useMousePosition)();
|
|
40
|
-
const { height, width, ref: tooltipRef } = (0, _useresizeobserver.default)();
|
|
41
|
-
const transform = (0, _react.useRef)();
|
|
42
|
-
const isTooltipPinned = pinnedPos !== null && enablePinning;
|
|
43
|
-
if (mousePos === null || mousePos.target === null) return null;
|
|
44
|
-
// Ensure user is hovering over a chart before checking for nearby series.
|
|
45
|
-
if (pinnedPos === null && mousePos.target.tagName !== 'CANVAS') return null;
|
|
46
|
-
const chart = chartRef.current;
|
|
47
|
-
const chartWidth = chart?.getWidth() ?? _tooltipmodel.FALLBACK_CHART_WIDTH; // Fallback width not likely to ever be needed.
|
|
48
|
-
// Get series nearby the cursor and pass into tooltip content children.
|
|
49
|
-
const nearbySeries = (0, _nearbyseries.legacyGetNearbySeriesData)({
|
|
50
|
-
mousePos,
|
|
51
|
-
chartData,
|
|
52
|
-
pinnedPos,
|
|
53
|
-
chart,
|
|
54
|
-
format,
|
|
55
|
-
showAllSeries
|
|
56
|
-
});
|
|
57
|
-
if (nearbySeries.length === 0) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
const totalSeries = chartData.timeSeries.length;
|
|
61
|
-
const containerElement = containerId ? document.querySelector(containerId) : undefined;
|
|
62
|
-
// if tooltip is attached to a container, set max height to the height of the container so tooltip does not get cut off
|
|
63
|
-
const maxHeight = containerElement ? containerElement.getBoundingClientRect().height : undefined;
|
|
64
|
-
if (!isTooltipPinned) {
|
|
65
|
-
transform.current = (0, _utils.assembleTransform)(mousePos, chartWidth, pinnedPos, height ?? 0, width ?? 0, containerElement);
|
|
66
|
-
}
|
|
67
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Portal, {
|
|
68
|
-
container: containerElement,
|
|
69
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
70
|
-
ref: tooltipRef,
|
|
71
|
-
sx: (theme)=>({
|
|
72
|
-
minWidth: _tooltipmodel.TOOLTIP_MIN_WIDTH,
|
|
73
|
-
maxWidth: _tooltipmodel.TOOLTIP_MAX_WIDTH,
|
|
74
|
-
maxHeight: maxHeight ?? _tooltipmodel.TOOLTIP_MAX_HEIGHT,
|
|
75
|
-
padding: 0,
|
|
76
|
-
position: 'absolute',
|
|
77
|
-
top: 0,
|
|
78
|
-
left: 0,
|
|
79
|
-
backgroundColor: theme.palette.designSystem?.grey[800] ?? _tooltipmodel.TOOLTIP_BG_COLOR_FALLBACK,
|
|
80
|
-
borderRadius: '6px',
|
|
81
|
-
color: '#fff',
|
|
82
|
-
fontSize: '11px',
|
|
83
|
-
visibility: 'visible',
|
|
84
|
-
opacity: 1,
|
|
85
|
-
transition: 'all 0.1s ease-out',
|
|
86
|
-
// Ensure pinned tooltip shows behind edit panel drawer and sticky header
|
|
87
|
-
zIndex: pinnedPos !== null ? 'auto' : theme.zIndex.tooltip,
|
|
88
|
-
overflow: 'hidden',
|
|
89
|
-
'&:hover': {
|
|
90
|
-
overflowY: 'auto'
|
|
91
|
-
}
|
|
92
|
-
}),
|
|
93
|
-
style: {
|
|
94
|
-
transform: transform.current,
|
|
95
|
-
display: transform.current ? 'block' : 'none'
|
|
96
|
-
},
|
|
97
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
98
|
-
spacing: 0.5,
|
|
99
|
-
children: [
|
|
100
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_TooltipHeader.TooltipHeader, {
|
|
101
|
-
nearbySeries: nearbySeries,
|
|
102
|
-
totalSeries: totalSeries,
|
|
103
|
-
enablePinning: enablePinning,
|
|
104
|
-
isTooltipPinned: isTooltipPinned,
|
|
105
|
-
showAllSeries: showAllSeries,
|
|
106
|
-
onShowAllClick: (checked)=>setShowAllSeries(checked),
|
|
107
|
-
onUnpinClick: onUnpinClick
|
|
108
|
-
}),
|
|
109
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_TooltipContent.TooltipContent, {
|
|
110
|
-
series: nearbySeries,
|
|
111
|
-
wrapLabels: wrapLabels
|
|
112
|
-
})
|
|
113
|
-
]
|
|
114
|
-
})
|
|
115
|
-
})
|
|
116
|
-
});
|
|
117
|
-
});
|