@perses-dev/components 0.8.1 → 0.10.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,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SeriesInfo = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
// Copyright 2021 The Perses Authors
|
|
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.
|
|
8
4
|
// You may obtain a copy of the License at
|
|
@@ -14,64 +10,140 @@ 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
|
-
|
|
19
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "SeriesInfo", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>SeriesInfo
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _material = require("@mui/material");
|
|
23
|
+
const _seriesMarker = require("./SeriesMarker");
|
|
24
|
+
const _tooltipModel = require("./tooltip-model");
|
|
20
25
|
function SeriesInfo(props) {
|
|
21
|
-
const { seriesName, y, markerColor, totalSeries, wrapLabels
|
|
26
|
+
const { seriesName , y , markerColor , totalSeries , wrapLabels } = props;
|
|
22
27
|
// TODO (sjcobb): regex to remove __name__, improve series labels
|
|
23
28
|
const formattedSeriesLabels = seriesName.replace(/[{}"]/g, '');
|
|
24
29
|
if (totalSeries === 1) {
|
|
25
30
|
const jsonFormattedSeries = seriesName[0] === '{' ? true : false;
|
|
26
|
-
return (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
32
|
+
spacing: 0.5,
|
|
33
|
+
children: [
|
|
34
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
35
|
+
sx: (theme)=>({
|
|
36
|
+
height: '16px',
|
|
37
|
+
display: 'flex',
|
|
38
|
+
flexDirection: 'row',
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
justifyContent: 'left',
|
|
41
|
+
color: theme.palette.common.white,
|
|
42
|
+
fontSize: '11px'
|
|
43
|
+
}),
|
|
44
|
+
children: [
|
|
45
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_seriesMarker.SeriesMarker, {
|
|
46
|
+
markerColor: markerColor
|
|
47
|
+
}),
|
|
48
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
49
|
+
component: "span",
|
|
50
|
+
children: [
|
|
51
|
+
"value:",
|
|
52
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
53
|
+
component: "span",
|
|
54
|
+
sx: (theme)=>({
|
|
55
|
+
color: theme.palette.common.white,
|
|
56
|
+
fontWeight: 700,
|
|
57
|
+
paddingLeft: '2px'
|
|
58
|
+
}),
|
|
59
|
+
children: y
|
|
60
|
+
})
|
|
61
|
+
]
|
|
62
|
+
})
|
|
63
|
+
]
|
|
64
|
+
}),
|
|
65
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Divider, {
|
|
66
|
+
sx: (theme)=>({
|
|
67
|
+
borderColor: theme.palette.grey['500']
|
|
68
|
+
})
|
|
69
|
+
}),
|
|
70
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
71
|
+
sx: (theme)=>({
|
|
72
|
+
color: theme.palette.common.white
|
|
73
|
+
}),
|
|
74
|
+
children: formattedSeriesLabels.split(',').map((name)=>{
|
|
43
75
|
if (name) {
|
|
44
76
|
const [key, value] = jsonFormattedSeries ? name.split(':') : name.split('=');
|
|
45
77
|
const formattedKey = value !== undefined ? `${key}: ` : key;
|
|
46
|
-
return (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
78
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
79
|
+
sx: {
|
|
80
|
+
display: 'flex',
|
|
81
|
+
gap: '4px'
|
|
82
|
+
},
|
|
83
|
+
children: [
|
|
84
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
85
|
+
sx: {
|
|
86
|
+
fontSize: '11px'
|
|
87
|
+
},
|
|
88
|
+
children: formattedKey
|
|
89
|
+
}),
|
|
90
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
91
|
+
sx: (theme)=>({
|
|
92
|
+
color: theme.palette.common.white,
|
|
93
|
+
fontWeight: 700,
|
|
94
|
+
fontSize: '11px'
|
|
95
|
+
}),
|
|
96
|
+
children: value
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
}, name);
|
|
51
100
|
}
|
|
52
|
-
})
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
]
|
|
104
|
+
});
|
|
53
105
|
}
|
|
54
106
|
const inlineSeriesLabels = formattedSeriesLabels.replace(/[,]/g, ', ').replace(/[:=]/g, ': ');
|
|
55
|
-
return (
|
|
107
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
108
|
+
sx: {
|
|
56
109
|
display: 'table-row',
|
|
57
|
-
paddingTop: 0.5
|
|
58
|
-
},
|
|
110
|
+
paddingTop: 0.5
|
|
111
|
+
},
|
|
112
|
+
children: [
|
|
113
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
114
|
+
sx: {
|
|
59
115
|
display: 'table-cell',
|
|
60
|
-
maxWidth: '520px'
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
116
|
+
maxWidth: '520px'
|
|
117
|
+
},
|
|
118
|
+
children: [
|
|
119
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_seriesMarker.SeriesMarker, {
|
|
120
|
+
markerColor: markerColor
|
|
121
|
+
}),
|
|
122
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
123
|
+
component: "span",
|
|
124
|
+
sx: (theme)=>({
|
|
125
|
+
color: theme.palette.common.white,
|
|
126
|
+
display: 'inline-block',
|
|
127
|
+
maxWidth: _tooltipModel.TOOLTIP_LABELS_MAX_WIDTH,
|
|
128
|
+
overflow: 'hidden',
|
|
129
|
+
textOverflow: 'ellipsis',
|
|
130
|
+
whiteSpace: wrapLabels ? 'normal' : 'nowrap',
|
|
131
|
+
width: 'calc(100% - 20px)'
|
|
132
|
+
}),
|
|
133
|
+
children: inlineSeriesLabels
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
}),
|
|
137
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
138
|
+
sx: {
|
|
70
139
|
display: 'table-cell',
|
|
71
140
|
fontWeight: '700',
|
|
72
141
|
paddingLeft: 1.5,
|
|
73
142
|
textAlign: 'right',
|
|
74
|
-
verticalAlign: 'top'
|
|
75
|
-
},
|
|
143
|
+
verticalAlign: 'top'
|
|
144
|
+
},
|
|
145
|
+
children: y
|
|
146
|
+
})
|
|
147
|
+
]
|
|
148
|
+
});
|
|
76
149
|
}
|
|
77
|
-
exports.SeriesInfo = SeriesInfo;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SeriesMarker = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
// Copyright 2021 The Perses Authors
|
|
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.
|
|
8
4
|
// You may obtain a copy of the License at
|
|
@@ -14,17 +10,30 @@ 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
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "SeriesMarker", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>SeriesMarker
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _material = require("@mui/material");
|
|
18
23
|
function SeriesMarker(props) {
|
|
19
|
-
const { markerColor
|
|
20
|
-
return (
|
|
24
|
+
const { markerColor } = props;
|
|
25
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
26
|
+
sx: {
|
|
21
27
|
display: 'inline-block',
|
|
22
28
|
width: '12px',
|
|
23
29
|
borderRadius: '2px',
|
|
24
30
|
height: '12px',
|
|
25
31
|
marginTop: 0.25,
|
|
26
32
|
marginRight: 1,
|
|
27
|
-
verticalAlign: 'top'
|
|
28
|
-
},
|
|
33
|
+
verticalAlign: 'top'
|
|
34
|
+
},
|
|
35
|
+
style: {
|
|
36
|
+
backgroundColor: markerColor
|
|
37
|
+
}
|
|
38
|
+
});
|
|
29
39
|
}
|
|
30
|
-
exports.SeriesMarker = SeriesMarker;
|
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Tooltip = void 0;
|
|
27
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
1
|
// Copyright 2022 The Perses Authors
|
|
29
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
30
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -37,52 +10,107 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
37
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
38
11
|
// See the License for the specific language governing permissions and
|
|
39
12
|
// limitations under the License.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "Tooltip", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>Tooltip
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
23
|
+
const _material = require("@mui/material");
|
|
24
|
+
const _focusedSeries = require("./focused-series");
|
|
25
|
+
const _tooltipModel = require("./tooltip-model");
|
|
26
|
+
const _tooltipContent = require("./TooltipContent");
|
|
27
|
+
const _utils = require("./utils");
|
|
28
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
29
|
+
if (typeof WeakMap !== "function") return null;
|
|
30
|
+
var cacheBabelInterop = new WeakMap();
|
|
31
|
+
var cacheNodeInterop = new WeakMap();
|
|
32
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
33
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
34
|
+
})(nodeInterop);
|
|
35
|
+
}
|
|
36
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
37
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
38
|
+
return obj;
|
|
39
|
+
}
|
|
40
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
41
|
+
return {
|
|
42
|
+
default: obj
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
46
|
+
if (cache && cache.has(obj)) {
|
|
47
|
+
return cache.get(obj);
|
|
48
|
+
}
|
|
49
|
+
var newObj = {};
|
|
50
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
51
|
+
for(var key in obj){
|
|
52
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
53
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
54
|
+
if (desc && (desc.get || desc.set)) {
|
|
55
|
+
Object.defineProperty(newObj, key, desc);
|
|
56
|
+
} else {
|
|
57
|
+
newObj[key] = obj[key];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
newObj.default = obj;
|
|
62
|
+
if (cache) {
|
|
63
|
+
cache.set(obj, newObj);
|
|
64
|
+
}
|
|
65
|
+
return newObj;
|
|
66
|
+
}
|
|
67
|
+
const Tooltip = /*#__PURE__*/ _react.default.memo(function Tooltip({ chartRef , chartData , wrapLabels , pinTooltip }) {
|
|
68
|
+
const [pinnedPos, setPinnedPos] = (0, _react.useState)(null);
|
|
69
|
+
const mousePos = (0, _tooltipModel.useMousePosition)();
|
|
70
|
+
if (mousePos === null || mousePos.target === null) return null;
|
|
52
71
|
// ensure user is hovering over a chart before checking for nearby series
|
|
53
|
-
if (pinnedPos === null && mousePos.target.tagName !== 'CANVAS')
|
|
54
|
-
return null;
|
|
72
|
+
if (pinnedPos === null && mousePos.target.tagName !== 'CANVAS') return null;
|
|
55
73
|
const chart = chartRef.current;
|
|
56
|
-
const focusedSeries = (0,
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
74
|
+
const focusedSeries = (0, _focusedSeries.getFocusedSeriesData)(mousePos, chartData, pinnedPos, chart);
|
|
75
|
+
var ref;
|
|
76
|
+
const chartWidth = (ref = chart === null || chart === void 0 ? void 0 : chart.getWidth()) !== null && ref !== void 0 ? ref : 750;
|
|
77
|
+
var ref1;
|
|
78
|
+
const chartHeight = (ref1 = chart === null || chart === void 0 ? void 0 : chart.getHeight()) !== null && ref1 !== void 0 ? ref1 : 230;
|
|
79
|
+
const cursorTransform = (0, _utils.assembleTransform)(mousePos, focusedSeries.length, chartWidth, chartHeight, pinnedPos);
|
|
60
80
|
if (focusedSeries.length === 0) {
|
|
61
81
|
return null;
|
|
62
82
|
}
|
|
63
83
|
if (pinTooltip === true && pinnedPos === null) {
|
|
64
84
|
setPinnedPos(mousePos);
|
|
65
85
|
}
|
|
66
|
-
return (
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Portal, {
|
|
87
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
88
|
+
sx: (theme)=>({
|
|
89
|
+
maxWidth: _tooltipModel.TOOLTIP_MAX_WIDTH,
|
|
90
|
+
maxHeight: _tooltipModel.TOOLTIP_MAX_HEIGHT,
|
|
91
|
+
position: 'absolute',
|
|
92
|
+
top: 0,
|
|
93
|
+
left: 0,
|
|
94
|
+
backgroundColor: '#2E313E',
|
|
95
|
+
borderRadius: '6px',
|
|
96
|
+
color: '#fff',
|
|
97
|
+
fontSize: '11px',
|
|
98
|
+
visibility: 'visible',
|
|
99
|
+
opacity: 1,
|
|
100
|
+
transition: 'all 0.1s ease-out',
|
|
101
|
+
zIndex: theme.zIndex.tooltip,
|
|
102
|
+
overflow: 'hidden',
|
|
103
|
+
'&:hover': {
|
|
104
|
+
overflowY: 'auto'
|
|
105
|
+
}
|
|
106
|
+
}),
|
|
107
|
+
style: {
|
|
108
|
+
transform: cursorTransform
|
|
109
|
+
},
|
|
110
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_tooltipContent.TooltipContent, {
|
|
111
|
+
focusedSeries: focusedSeries,
|
|
112
|
+
wrapLabels: wrapLabels
|
|
113
|
+
})
|
|
114
|
+
})
|
|
115
|
+
});
|
|
87
116
|
});
|
|
88
|
-
exports.Tooltip = Tooltip;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TooltipContent = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
// Copyright 2021 The Perses Authors
|
|
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.
|
|
8
4
|
// You may obtain a copy of the License at
|
|
@@ -14,37 +10,86 @@ 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
|
-
|
|
19
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "TooltipContent", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>TooltipContent
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = require("react");
|
|
23
|
+
const _material = require("@mui/material");
|
|
24
|
+
const _seriesInfo = require("./SeriesInfo");
|
|
20
25
|
function TooltipContent(props) {
|
|
21
|
-
const { focusedSeries, wrapLabels
|
|
26
|
+
const { focusedSeries , wrapLabels } = props;
|
|
22
27
|
const seriesTime = focusedSeries && focusedSeries[0] && focusedSeries[0].date ? focusedSeries[0].date : null;
|
|
23
|
-
const formatTimeSeriesHeader = (timeString)
|
|
28
|
+
const formatTimeSeriesHeader = (timeString)=>{
|
|
24
29
|
const [month, year, time] = timeString.split(',');
|
|
25
|
-
return (
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
31
|
+
children: [
|
|
32
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
33
|
+
variant: "caption",
|
|
34
|
+
sx: (theme)=>({
|
|
35
|
+
color: theme.palette.common.white
|
|
36
|
+
}),
|
|
37
|
+
children: [
|
|
38
|
+
month,
|
|
39
|
+
", ",
|
|
40
|
+
year,
|
|
41
|
+
" –"
|
|
42
|
+
]
|
|
43
|
+
}),
|
|
44
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
45
|
+
variant: "caption",
|
|
46
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)("strong", {
|
|
47
|
+
children: time
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
});
|
|
28
52
|
};
|
|
29
|
-
const sortedFocusedSeries = (0,
|
|
30
|
-
if (focusedSeries === null)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
53
|
+
const sortedFocusedSeries = (0, _react.useMemo)(()=>{
|
|
54
|
+
if (focusedSeries === null) return null;
|
|
55
|
+
return focusedSeries.sort((a, b)=>a.y > b.y ? -1 : 1);
|
|
56
|
+
}, [
|
|
57
|
+
focusedSeries
|
|
58
|
+
]);
|
|
34
59
|
if (sortedFocusedSeries !== null && seriesTime !== null) {
|
|
35
|
-
return (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
60
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
61
|
+
py: 1,
|
|
62
|
+
px: 1.5,
|
|
63
|
+
spacing: 0.5,
|
|
64
|
+
children: [
|
|
65
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
66
|
+
variant: "caption",
|
|
67
|
+
children: formatTimeSeriesHeader(seriesTime)
|
|
68
|
+
}),
|
|
69
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Divider, {
|
|
70
|
+
sx: (theme)=>({
|
|
71
|
+
borderColor: theme.palette.grey['500']
|
|
72
|
+
})
|
|
73
|
+
}),
|
|
74
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
75
|
+
sx: {
|
|
76
|
+
display: 'table'
|
|
77
|
+
},
|
|
78
|
+
children: sortedFocusedSeries.map(({ datumIdx , seriesIdx , seriesName , y , markerColor })=>{
|
|
79
|
+
if (datumIdx === null || seriesIdx === null) return null;
|
|
42
80
|
const key = seriesIdx.toString() + datumIdx.toString();
|
|
43
|
-
return (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
81
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_seriesInfo.SeriesInfo, {
|
|
82
|
+
seriesName: seriesName,
|
|
83
|
+
y: y,
|
|
84
|
+
markerColor: markerColor,
|
|
85
|
+
totalSeries: sortedFocusedSeries.length,
|
|
86
|
+
wrapLabels: wrapLabels
|
|
87
|
+
}, key);
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {});
|
|
48
94
|
}
|
|
49
95
|
}
|
|
50
|
-
exports.TooltipContent = TooltipContent;
|