@perses-dev/components 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Drawer/Drawer.d.ts +3 -4
- package/dist/Drawer/Drawer.d.ts.map +1 -1
- package/dist/Drawer/Drawer.js +35 -1
- package/dist/Drawer/Drawer.js.map +1 -0
- package/dist/Drawer/index.js +15 -1
- package/dist/Drawer/index.js.map +1 -0
- package/dist/EChart.d.ts.map +1 -1
- package/dist/EChart.js +142 -1
- package/dist/EChart.js.map +1 -0
- package/dist/ErrorAlert.js +25 -1
- package/dist/ErrorAlert.js.map +1 -0
- package/dist/ErrorBoundary.js +16 -1
- package/dist/ErrorBoundary.js.map +1 -0
- package/dist/GaugeChart/GaugeChart.js +172 -1
- package/dist/GaugeChart/GaugeChart.js.map +1 -0
- package/dist/GaugeChart/index.js +15 -1
- package/dist/GaugeChart/index.js.map +1 -0
- package/dist/InfoTooltip/InfoTooltip.js +79 -1
- package/dist/InfoTooltip/InfoTooltip.js.map +1 -0
- package/dist/InfoTooltip/InfoTooltip.test.js +36 -1
- package/dist/InfoTooltip/InfoTooltip.test.js.map +1 -0
- package/dist/InfoTooltip/index.js +15 -1
- package/dist/InfoTooltip/index.js.map +1 -0
- package/dist/LineChart/LineChart.js +198 -1
- package/dist/LineChart/LineChart.js.map +1 -0
- package/dist/LineChart/index.js +15 -1
- package/dist/LineChart/index.js.map +1 -0
- package/dist/LineChart/utils.js +63 -1
- package/dist/LineChart/utils.js.map +1 -0
- package/dist/StatChart/StatChart.js +121 -1
- package/dist/StatChart/StatChart.js.map +1 -0
- package/dist/StatChart/StatChart.test.js +82 -1
- package/dist/StatChart/StatChart.test.js.map +1 -0
- package/dist/StatChart/index.js +15 -1
- package/dist/StatChart/index.js.map +1 -0
- package/dist/TimeRangeSelector/AbsoluteTimePicker.js +175 -1
- package/dist/TimeRangeSelector/AbsoluteTimePicker.js.map +1 -0
- package/dist/TimeRangeSelector/TimeRangeSelector.js +52 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -0
- package/dist/TimeRangeSelector/index.js +16 -1
- package/dist/TimeRangeSelector/index.js.map +1 -0
- package/dist/TimeRangeSelector/utils.js +36 -1
- package/dist/TimeRangeSelector/utils.js.map +1 -0
- package/dist/Tooltip/SeriesInfo.js +143 -1
- package/dist/Tooltip/SeriesInfo.js.map +1 -0
- package/dist/Tooltip/SeriesMarker.js +33 -1
- package/dist/Tooltip/SeriesMarker.js.map +1 -0
- package/dist/Tooltip/Tooltip.js +72 -1
- package/dist/Tooltip/Tooltip.js.map +1 -0
- package/dist/Tooltip/TooltipContent.js +89 -1
- package/dist/Tooltip/TooltipContent.js.map +1 -0
- package/dist/Tooltip/focused-series.js +108 -1
- package/dist/Tooltip/focused-series.js.map +1 -0
- package/dist/Tooltip/focused-series.test.js +75 -1
- package/dist/Tooltip/focused-series.test.js.map +1 -0
- package/dist/Tooltip/index.js +16 -1
- package/dist/Tooltip/index.js.map +1 -0
- package/dist/Tooltip/tooltip-model.js +80 -1
- package/dist/Tooltip/tooltip-model.js.map +1 -0
- package/dist/Tooltip/utils.js +46 -1
- package/dist/Tooltip/utils.js.map +1 -0
- package/dist/cjs/Drawer/Drawer.js +26 -13
- package/dist/cjs/Drawer/index.js +16 -17
- package/dist/cjs/EChart.js +114 -89
- package/dist/cjs/ErrorAlert.js +16 -12
- package/dist/cjs/ErrorBoundary.js +10 -6
- package/dist/cjs/GaugeChart/GaugeChart.js +90 -57
- package/dist/cjs/GaugeChart/index.js +16 -17
- package/dist/cjs/InfoTooltip/InfoTooltip.js +90 -33
- package/dist/cjs/InfoTooltip/InfoTooltip.test.js +27 -17
- package/dist/cjs/InfoTooltip/index.js +16 -17
- package/dist/cjs/LineChart/LineChart.js +122 -87
- package/dist/cjs/LineChart/index.js +16 -17
- package/dist/cjs/LineChart/utils.js +23 -23
- package/dist/cjs/StatChart/StatChart.js +107 -46
- package/dist/cjs/StatChart/StatChart.test.js +65 -21
- package/dist/cjs/StatChart/index.js +16 -17
- package/dist/cjs/TimeRangeSelector/AbsoluteTimePicker.js +144 -64
- package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +45 -22
- package/dist/cjs/TimeRangeSelector/index.js +17 -18
- package/dist/cjs/TimeRangeSelector/utils.js +19 -16
- package/dist/cjs/Tooltip/SeriesInfo.js +120 -48
- package/dist/cjs/Tooltip/SeriesMarker.js +20 -11
- package/dist/cjs/Tooltip/Tooltip.js +95 -67
- package/dist/cjs/Tooltip/TooltipContent.js +76 -31
- package/dist/cjs/Tooltip/focused-series.js +40 -36
- package/dist/cjs/Tooltip/focused-series.test.js +36 -16
- package/dist/cjs/Tooltip/index.js +17 -18
- package/dist/cjs/Tooltip/tooltip-model.js +46 -30
- package/dist/cjs/Tooltip/utils.js +13 -16
- package/dist/cjs/context/ChartsThemeProvider.js +65 -13
- package/dist/cjs/index.js +27 -28
- package/dist/cjs/model/graph.js +10 -5
- package/dist/cjs/model/index.js +18 -19
- package/dist/cjs/model/theme.js +4 -2
- package/dist/cjs/model/units.js +68 -51
- package/dist/cjs/test/index.js +16 -17
- package/dist/cjs/test/render.js +22 -12
- package/dist/cjs/test/setup-tests.js +4 -2
- package/dist/cjs/utils/combine-sx.js +15 -16
- package/dist/cjs/utils/index.js +17 -18
- package/dist/cjs/utils/theme-gen.js +64 -55
- package/dist/cjs/utils/theme-gen.test.js +14 -12
- package/dist/context/ChartsThemeProvider.js +36 -1
- package/dist/context/ChartsThemeProvider.js.map +1 -0
- package/dist/index.js +26 -1
- package/dist/index.js.map +1 -0
- package/dist/model/graph.js +15 -1
- package/dist/model/graph.js.map +1 -0
- package/dist/model/index.js +17 -1
- package/dist/model/index.js.map +1 -0
- package/dist/model/theme.js +15 -1
- package/dist/model/theme.js.map +1 -0
- package/dist/model/units.d.ts.map +1 -1
- package/dist/model/units.js +196 -1
- package/dist/model/units.js.map +1 -0
- package/dist/test/index.js +15 -1
- package/dist/test/index.js.map +1 -0
- package/dist/test/render.js +32 -1
- package/dist/test/render.js.map +1 -0
- package/dist/test/setup-tests.js +18 -1
- package/dist/test/setup-tests.js.map +1 -0
- package/dist/utils/combine-sx.js +27 -1
- package/dist/utils/combine-sx.js.map +1 -0
- package/dist/utils/index.js +16 -1
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/theme-gen.js +183 -1
- package/dist/utils/theme-gen.js.map +1 -0
- package/dist/utils/theme-gen.test.js +196 -1
- package/dist/utils/theme-gen.test.js.map +1 -0
- package/package.json +8 -4
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Copyright 2021 The Perses Authors
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
5
4
|
// You may obtain a copy of the License at
|
|
@@ -11,38 +10,49 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
getNearbySeries: ()=>getNearbySeries,
|
|
25
|
+
getFocusedSeriesData: ()=>getFocusedSeriesData
|
|
26
|
+
});
|
|
27
|
+
const _tooltipModel = require("./tooltip-model");
|
|
21
28
|
function getNearbySeries(data, pointInGrid, yBuffer) {
|
|
22
|
-
var _a, _b, _c, _d, _e;
|
|
23
29
|
const currentFocusedData = [];
|
|
24
|
-
|
|
25
|
-
const
|
|
30
|
+
var ref;
|
|
31
|
+
const focusedX = (ref = pointInGrid[0]) !== null && ref !== void 0 ? ref : null;
|
|
32
|
+
var ref1;
|
|
33
|
+
const focusedY = (ref1 = pointInGrid[1]) !== null && ref1 !== void 0 ? ref1 : null;
|
|
26
34
|
if (focusedX === null || focusedY === null) {
|
|
27
35
|
return currentFocusedData;
|
|
28
36
|
}
|
|
29
37
|
if (Array.isArray(data.xAxis) && Array.isArray(data.timeSeries)) {
|
|
30
|
-
for
|
|
38
|
+
for(let seriesIdx = 0; seriesIdx < data.timeSeries.length; seriesIdx++){
|
|
31
39
|
const currentSeries = data.timeSeries[seriesIdx];
|
|
32
|
-
if (currentFocusedData.length >=
|
|
33
|
-
break;
|
|
40
|
+
if (currentFocusedData.length >= _tooltipModel.TOOLTIP_MAX_ITEMS) break;
|
|
34
41
|
if (currentSeries !== undefined) {
|
|
35
42
|
const currentSeriesName = currentSeries.name ? currentSeries.name.toString() : '';
|
|
36
|
-
|
|
43
|
+
var _color;
|
|
44
|
+
const markerColor = (_color = currentSeries.color) !== null && _color !== void 0 ? _color : '#000';
|
|
37
45
|
if (Array.isArray(currentSeries.data)) {
|
|
38
|
-
for
|
|
39
|
-
|
|
40
|
-
const
|
|
46
|
+
for(let datumIdx = 0; datumIdx < currentSeries.data.length; datumIdx++){
|
|
47
|
+
var _datumIdx;
|
|
48
|
+
const xValue = (_datumIdx = data.xAxis[datumIdx]) !== null && _datumIdx !== void 0 ? _datumIdx : 0;
|
|
49
|
+
var _datumIdx1;
|
|
50
|
+
const yValue = (_datumIdx1 = currentSeries.data[datumIdx]) !== null && _datumIdx1 !== void 0 ? _datumIdx1 : 0;
|
|
41
51
|
if (focusedX === datumIdx) {
|
|
42
52
|
if (yValue !== '-' && focusedY <= yValue + yBuffer && focusedY >= yValue - yBuffer) {
|
|
43
53
|
// determine whether to convert timestamp to ms, see: https://stackoverflow.com/a/23982005/17575201
|
|
44
54
|
const xValueMilliSeconds = xValue > 99999999999 ? xValue : xValue * 1000;
|
|
45
|
-
const formattedDate =
|
|
55
|
+
const formattedDate = _tooltipModel.TOOLTIP_DATE_FORMAT.format(xValueMilliSeconds);
|
|
46
56
|
currentFocusedData.push({
|
|
47
57
|
seriesIdx: seriesIdx,
|
|
48
58
|
datumIdx: datumIdx,
|
|
@@ -50,7 +60,7 @@ function getNearbySeries(data, pointInGrid, yBuffer) {
|
|
|
50
60
|
date: formattedDate,
|
|
51
61
|
x: xValue,
|
|
52
62
|
y: yValue,
|
|
53
|
-
markerColor: markerColor.toString()
|
|
63
|
+
markerColor: markerColor.toString()
|
|
54
64
|
});
|
|
55
65
|
}
|
|
56
66
|
}
|
|
@@ -61,15 +71,8 @@ function getNearbySeries(data, pointInGrid, yBuffer) {
|
|
|
61
71
|
}
|
|
62
72
|
return currentFocusedData;
|
|
63
73
|
}
|
|
64
|
-
exports.getNearbySeries = getNearbySeries;
|
|
65
|
-
/**
|
|
66
|
-
* Uses mouse position to determine whether user is hovering over a chart canvas
|
|
67
|
-
* If yes, convert from pixel values to logical cartesian coordinates and return all focused series
|
|
68
|
-
*/
|
|
69
74
|
function getFocusedSeriesData(mousePos, chartData, pinnedPos, chart) {
|
|
70
|
-
|
|
71
|
-
if (chart === undefined || mousePos === null)
|
|
72
|
-
return [];
|
|
75
|
+
if (chart === undefined || mousePos === null) return [];
|
|
73
76
|
// prevents multiple tooltips showing from adjacent charts
|
|
74
77
|
let cursorTargetMatchesChart = false;
|
|
75
78
|
if (mousePos.target !== null) {
|
|
@@ -89,16 +92,18 @@ function getFocusedSeriesData(mousePos, chartData, pinnedPos, chart) {
|
|
|
89
92
|
mousePos = pinnedPos;
|
|
90
93
|
cursorTargetMatchesChart = true;
|
|
91
94
|
}
|
|
92
|
-
if (cursorTargetMatchesChart === false)
|
|
93
|
-
|
|
94
|
-
if (chart['_model'] === undefined)
|
|
95
|
-
return [];
|
|
95
|
+
if (cursorTargetMatchesChart === false) return [];
|
|
96
|
+
if (chart['_model'] === undefined) return [];
|
|
96
97
|
const chartModel = chart['_model'];
|
|
97
98
|
const yAxisInterval = chartModel.getComponent('yAxis').axis.scale._interval;
|
|
98
99
|
const seriesNum = chartData.timeSeries.length;
|
|
99
100
|
// tooltip trigger area gets smaller with more series
|
|
100
|
-
const yBuffer = seriesNum >
|
|
101
|
-
|
|
101
|
+
const yBuffer = seriesNum > _tooltipModel.TOOLTIP_MAX_ITEMS ? yAxisInterval * 0.5 : yAxisInterval * 2;
|
|
102
|
+
var _x, _y;
|
|
103
|
+
const pointInPixel = [
|
|
104
|
+
(_x = mousePos.plotCanvas.x) !== null && _x !== void 0 ? _x : 0,
|
|
105
|
+
(_y = mousePos.plotCanvas.y) !== null && _y !== void 0 ? _y : 0
|
|
106
|
+
];
|
|
102
107
|
if (chart.containPixel('grid', pointInPixel)) {
|
|
103
108
|
const pointInGrid = chart.convertFromPixel('grid', pointInPixel);
|
|
104
109
|
if (pointInGrid[0] !== undefined && pointInGrid[1] !== undefined) {
|
|
@@ -107,4 +112,3 @@ function getFocusedSeriesData(mousePos, chartData, pinnedPos, chart) {
|
|
|
107
112
|
}
|
|
108
113
|
return [];
|
|
109
114
|
}
|
|
110
|
-
exports.getFocusedSeriesData = getFocusedSeriesData;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,9 +10,12 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
const _focusedSeries = require("./focused-series");
|
|
18
|
+
describe('getNearbySeries', ()=>{
|
|
17
19
|
const chartData = {
|
|
18
20
|
timeSeries: [
|
|
19
21
|
{
|
|
@@ -21,24 +23,42 @@ describe('getNearbySeries', () => {
|
|
|
21
23
|
name: 'env="demo", instance="demo.do.prometheus", job="node", mode="test"',
|
|
22
24
|
color: 'hsla(-1365438424,50%,50%,0.8)',
|
|
23
25
|
data: [
|
|
24
|
-
0.0002315202231525094,
|
|
26
|
+
0.0002315202231525094,
|
|
25
27
|
0.00022873082287300112,
|
|
28
|
+
0.00023152022315149463,
|
|
29
|
+
0.00023152022315149463,
|
|
30
|
+
0.00022873082287300112
|
|
26
31
|
],
|
|
27
|
-
symbol: 'circle'
|
|
32
|
+
symbol: 'circle'
|
|
28
33
|
},
|
|
29
34
|
{
|
|
30
35
|
type: 'line',
|
|
31
36
|
name: 'env="demo", instance="demo.do.prometheus", job="node", mode="test alt"',
|
|
32
37
|
color: 'hsla(286664040,50%,50%,0.8)',
|
|
33
|
-
data: [
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
data: [
|
|
39
|
+
0.05245188284519867,
|
|
40
|
+
0.0524463040446356,
|
|
41
|
+
0.0524463040446356,
|
|
42
|
+
0.05247140864723438,
|
|
43
|
+
0.052482566248230646
|
|
44
|
+
],
|
|
45
|
+
symbol: 'circle'
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
xAxis: [
|
|
49
|
+
1654007865000,
|
|
50
|
+
1654007880000,
|
|
51
|
+
1654007895000,
|
|
52
|
+
1654007910000,
|
|
53
|
+
1654007925000
|
|
36
54
|
],
|
|
37
|
-
|
|
38
|
-
rangeMs: 60000,
|
|
55
|
+
rangeMs: 60000
|
|
39
56
|
};
|
|
40
57
|
// https://echarts.apache.org/en/api.html#echartsInstance.convertFromPixel
|
|
41
|
-
const pointInGrid = [
|
|
58
|
+
const pointInGrid = [
|
|
59
|
+
2,
|
|
60
|
+
0.0560655737704918
|
|
61
|
+
]; // converted from chart.getZr() mousemove coordinates
|
|
42
62
|
const yBuffer = 0.02; // calculated from y axis interval
|
|
43
63
|
const focusedSeriesOutput = [
|
|
44
64
|
{
|
|
@@ -48,10 +68,10 @@ describe('getNearbySeries', () => {
|
|
|
48
68
|
seriesName: 'env="demo", instance="demo.do.prometheus", job="node", mode="test alt"',
|
|
49
69
|
seriesIdx: 1,
|
|
50
70
|
x: 1654007895000,
|
|
51
|
-
y: 0.0524463040446356
|
|
52
|
-
}
|
|
71
|
+
y: 0.0524463040446356
|
|
72
|
+
}
|
|
53
73
|
];
|
|
54
|
-
it('should return focused series data for points nearby the cursor', ()
|
|
55
|
-
expect((0,
|
|
74
|
+
it('should return focused series data for points nearby the cursor', ()=>{
|
|
75
|
+
expect((0, _focusedSeries.getNearbySeries)(chartData, pointInGrid, yBuffer)).toEqual(focusedSeriesOutput);
|
|
56
76
|
});
|
|
57
77
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,20 +10,20 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_exportStar(require("./Tooltip"), exports);
|
|
18
|
+
_exportStar(require("./SeriesMarker"), exports);
|
|
19
|
+
function _exportStar(from, to) {
|
|
20
|
+
Object.keys(from).forEach(function(k) {
|
|
21
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return from[k];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
return from;
|
|
29
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Copyright 2021 The Perses Authors
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
5
4
|
// You may obtain a copy of the License at
|
|
@@ -11,72 +10,89 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
TOOLTIP_MAX_WIDTH: ()=>TOOLTIP_MAX_WIDTH,
|
|
25
|
+
TOOLTIP_MAX_HEIGHT: ()=>TOOLTIP_MAX_HEIGHT,
|
|
26
|
+
TOOLTIP_LABELS_MAX_WIDTH: ()=>TOOLTIP_LABELS_MAX_WIDTH,
|
|
27
|
+
TOOLTIP_MAX_ITEMS: ()=>TOOLTIP_MAX_ITEMS,
|
|
28
|
+
TOOLTIP_DATE_FORMAT: ()=>TOOLTIP_DATE_FORMAT,
|
|
29
|
+
defaultCursorData: ()=>defaultCursorData,
|
|
30
|
+
emptyTooltipData: ()=>emptyTooltipData,
|
|
31
|
+
useMousePosition: ()=>useMousePosition
|
|
32
|
+
});
|
|
33
|
+
const _react = require("react");
|
|
34
|
+
const TOOLTIP_MAX_WIDTH = 650;
|
|
35
|
+
const TOOLTIP_MAX_HEIGHT = 230;
|
|
36
|
+
const TOOLTIP_LABELS_MAX_WIDTH = TOOLTIP_MAX_WIDTH - 150;
|
|
37
|
+
const TOOLTIP_MAX_ITEMS = 50;
|
|
38
|
+
const TOOLTIP_DATE_FORMAT = new Intl.DateTimeFormat(undefined, {
|
|
22
39
|
year: 'numeric',
|
|
23
40
|
month: 'short',
|
|
24
41
|
day: 'numeric',
|
|
25
42
|
hour: 'numeric',
|
|
26
43
|
minute: 'numeric',
|
|
27
44
|
second: 'numeric',
|
|
28
|
-
hour12: true
|
|
45
|
+
hour12: true
|
|
29
46
|
});
|
|
30
|
-
|
|
47
|
+
const defaultCursorData = {
|
|
31
48
|
coords: {
|
|
32
49
|
viewport: {
|
|
33
50
|
x: 0,
|
|
34
|
-
y: 0
|
|
51
|
+
y: 0
|
|
35
52
|
},
|
|
36
53
|
plotCanvas: {
|
|
37
54
|
x: 0,
|
|
38
|
-
y: 0
|
|
55
|
+
y: 0
|
|
39
56
|
},
|
|
40
57
|
zrender: {
|
|
41
58
|
x: 0,
|
|
42
|
-
y: 0
|
|
59
|
+
y: 0
|
|
43
60
|
},
|
|
44
|
-
target: null
|
|
61
|
+
target: null
|
|
45
62
|
},
|
|
46
|
-
chartWidth: 0
|
|
63
|
+
chartWidth: 0
|
|
47
64
|
};
|
|
48
|
-
|
|
49
|
-
cursor:
|
|
50
|
-
focusedSeries: null
|
|
65
|
+
const emptyTooltipData = {
|
|
66
|
+
cursor: defaultCursorData,
|
|
67
|
+
focusedSeries: null
|
|
51
68
|
};
|
|
52
|
-
const useMousePosition = ()
|
|
53
|
-
const [coords, setCoords] = (0,
|
|
54
|
-
(0,
|
|
55
|
-
const setFromEvent = (e)
|
|
69
|
+
const useMousePosition = ()=>{
|
|
70
|
+
const [coords, setCoords] = (0, _react.useState)(null);
|
|
71
|
+
(0, _react.useEffect)(()=>{
|
|
72
|
+
const setFromEvent = (e)=>{
|
|
56
73
|
return setCoords({
|
|
57
74
|
viewport: {
|
|
58
75
|
x: e.clientX,
|
|
59
|
-
y: e.clientY
|
|
76
|
+
y: e.clientY
|
|
60
77
|
},
|
|
61
78
|
plotCanvas: {
|
|
62
79
|
x: e.offsetX,
|
|
63
|
-
y: e.offsetY
|
|
80
|
+
y: e.offsetY
|
|
64
81
|
},
|
|
65
82
|
zrender: {
|
|
66
83
|
// echarts canvas coordinates added automatically by zrender
|
|
67
84
|
// zrX and zrY are similar to offsetX and offsetY but they return undefined when not hovering over a chart canvas
|
|
68
85
|
x: e.zrX,
|
|
69
|
-
y: e.zrY
|
|
86
|
+
y: e.zrY
|
|
70
87
|
},
|
|
71
88
|
// necessary to check whether cursor target matches correct chart canvas (since each chart has its own mousemove listener)
|
|
72
|
-
target: e.target
|
|
89
|
+
target: e.target
|
|
73
90
|
});
|
|
74
91
|
};
|
|
75
92
|
window.addEventListener('mousemove', setFromEvent);
|
|
76
|
-
return ()
|
|
93
|
+
return ()=>{
|
|
77
94
|
window.removeEventListener('mousemove', setFromEvent);
|
|
78
95
|
};
|
|
79
96
|
}, []);
|
|
80
97
|
return coords;
|
|
81
98
|
};
|
|
82
|
-
exports.useMousePosition = useMousePosition;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,12 +10,15 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
exports
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "assembleTransform", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>assembleTransform
|
|
20
|
+
});
|
|
21
|
+
const _tooltipModel = require("./tooltip-model");
|
|
20
22
|
function assembleTransform(mousePos, seriesNum, chartWidth, chartHeight, pinnedPos) {
|
|
21
23
|
if (mousePos === null) {
|
|
22
24
|
return 'translate3d(0, 0)';
|
|
@@ -34,20 +36,15 @@ function assembleTransform(mousePos, seriesNum, chartWidth, chartHeight, pinnedP
|
|
|
34
36
|
if (isCloseToBottom === true) {
|
|
35
37
|
if (seriesNum > 6) {
|
|
36
38
|
y = mousePos.viewport.y * 0.65;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
+
} else {
|
|
39
40
|
y = mousePos.viewport.y * 0.75;
|
|
40
41
|
}
|
|
41
|
-
}
|
|
42
|
-
else if (mousePos.plotCanvas.y > yPosAdjustThreshold) {
|
|
42
|
+
} else if (mousePos.plotCanvas.y > yPosAdjustThreshold) {
|
|
43
43
|
y = mousePos.viewport.y * 0.85;
|
|
44
44
|
}
|
|
45
45
|
// use tooltip width to determine when to repos from right to left (width is narrower when only 1 focused series since labels wrap)
|
|
46
|
-
const tooltipWidth = seriesNum > 1 ?
|
|
46
|
+
const tooltipWidth = seriesNum > 1 ? _tooltipModel.TOOLTIP_MAX_WIDTH : _tooltipModel.TOOLTIP_MAX_WIDTH / 2;
|
|
47
47
|
const xPosAdjustThreshold = chartWidth - tooltipWidth * 0.9;
|
|
48
48
|
// reposition so tooltip is never too close to right side of chart or left side of browser window
|
|
49
|
-
return mousePos.plotCanvas.x > xPosAdjustThreshold && x >
|
|
50
|
-
? `translate3d(${x - cursorPaddingX}px, ${y}px, 0) translateX(-100%)`
|
|
51
|
-
: `translate3d(${x + cursorPaddingX}px, ${y}px, 0)`;
|
|
49
|
+
return mousePos.plotCanvas.x > xPosAdjustThreshold && x > _tooltipModel.TOOLTIP_MAX_WIDTH ? `translate3d(${x - cursorPaddingX}px, ${y}px, 0) translateX(-100%)` : `translate3d(${x + cursorPaddingX}px, ${y}px, 0)`;
|
|
52
50
|
}
|
|
53
|
-
exports.assembleTransform = assembleTransform;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useChartsTheme = exports.ChartsThemeContext = exports.ChartsThemeProvider = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
1
|
// Copyright 2022 The Perses Authors
|
|
6
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -14,23 +10,79 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
14
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
11
|
// See the License for the specific language governing permissions and
|
|
16
12
|
// limitations under the License.
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
ChartsThemeProvider: ()=>ChartsThemeProvider,
|
|
25
|
+
ChartsThemeContext: ()=>ChartsThemeContext,
|
|
26
|
+
useChartsTheme: ()=>useChartsTheme
|
|
27
|
+
});
|
|
28
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
29
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
30
|
+
const _echarts = require("echarts");
|
|
31
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
32
|
+
if (typeof WeakMap !== "function") return null;
|
|
33
|
+
var cacheBabelInterop = new WeakMap();
|
|
34
|
+
var cacheNodeInterop = new WeakMap();
|
|
35
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
36
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
37
|
+
})(nodeInterop);
|
|
38
|
+
}
|
|
39
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
40
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
41
|
+
return obj;
|
|
42
|
+
}
|
|
43
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
44
|
+
return {
|
|
45
|
+
default: obj
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
49
|
+
if (cache && cache.has(obj)) {
|
|
50
|
+
return cache.get(obj);
|
|
51
|
+
}
|
|
52
|
+
var newObj = {};
|
|
53
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
54
|
+
for(var key in obj){
|
|
55
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
56
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
57
|
+
if (desc && (desc.get || desc.set)) {
|
|
58
|
+
Object.defineProperty(newObj, key, desc);
|
|
59
|
+
} else {
|
|
60
|
+
newObj[key] = obj[key];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
newObj.default = obj;
|
|
65
|
+
if (cache) {
|
|
66
|
+
cache.set(obj, newObj);
|
|
67
|
+
}
|
|
68
|
+
return newObj;
|
|
69
|
+
}
|
|
19
70
|
function ChartsThemeProvider(props) {
|
|
20
|
-
const { children, themeName, chartsTheme
|
|
71
|
+
const { children , themeName , chartsTheme } = props;
|
|
21
72
|
if (chartsTheme !== undefined && chartsTheme.echartsTheme !== undefined) {
|
|
22
73
|
// register ECharts theme to be used in individual charts, see: https://apache.github.io/echarts-handbook/en/concepts/style/#theme
|
|
23
|
-
(0,
|
|
74
|
+
(0, _echarts.registerTheme)(themeName, chartsTheme.echartsTheme);
|
|
24
75
|
}
|
|
25
|
-
return (0,
|
|
76
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(ChartsThemeContext.Provider, {
|
|
77
|
+
value: chartsTheme,
|
|
78
|
+
children: children
|
|
79
|
+
});
|
|
26
80
|
}
|
|
27
|
-
|
|
28
|
-
exports.ChartsThemeContext = (0, react_1.createContext)(undefined);
|
|
81
|
+
const ChartsThemeContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
|
|
29
82
|
function useChartsTheme() {
|
|
30
|
-
const ctx = (0,
|
|
83
|
+
const ctx = (0, _react.useContext)(ChartsThemeContext);
|
|
31
84
|
if (ctx === undefined) {
|
|
32
85
|
throw new Error('No ChartsThemeContext found. Did you forget a Provider?');
|
|
33
86
|
}
|
|
34
87
|
return ctx;
|
|
35
88
|
}
|
|
36
|
-
exports.useChartsTheme = useChartsTheme;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,30 +10,30 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_exportStar(require("./Drawer"), exports);
|
|
18
|
+
_exportStar(require("./EChart"), exports);
|
|
19
|
+
_exportStar(require("./ErrorAlert"), exports);
|
|
20
|
+
_exportStar(require("./ErrorBoundary"), exports);
|
|
21
|
+
_exportStar(require("./InfoTooltip"), exports);
|
|
22
|
+
_exportStar(require("./LineChart"), exports);
|
|
23
|
+
_exportStar(require("./GaugeChart"), exports);
|
|
24
|
+
_exportStar(require("./StatChart"), exports);
|
|
25
|
+
_exportStar(require("./TimeRangeSelector"), exports);
|
|
26
|
+
_exportStar(require("./context/ChartsThemeProvider"), exports);
|
|
27
|
+
_exportStar(require("./utils"), exports);
|
|
28
|
+
_exportStar(require("./model"), exports);
|
|
29
|
+
function _exportStar(from, to) {
|
|
30
|
+
Object.keys(from).forEach(function(k) {
|
|
31
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function() {
|
|
34
|
+
return from[k];
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
return from;
|
|
39
|
+
}
|
package/dist/cjs/model/graph.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Copyright 2021 The Perses Authors
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
5
4
|
// You may obtain a copy of the License at
|
|
@@ -11,6 +10,12 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
exports
|
|
16
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "PROGRESSIVE_MODE_SERIES_LIMIT", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>PROGRESSIVE_MODE_SERIES_LIMIT
|
|
20
|
+
});
|
|
21
|
+
const PROGRESSIVE_MODE_SERIES_LIMIT = 500;
|