@perses-dev/components 0.26.1 → 0.28.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/InfoTooltip/InfoTooltip.d.ts.map +1 -1
- package/dist/InfoTooltip/InfoTooltip.js +8 -5
- package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
- package/dist/Legend/CompactLegend.d.ts +3 -1
- package/dist/Legend/CompactLegend.d.ts.map +1 -1
- package/dist/Legend/CompactLegend.js +3 -1
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.d.ts +10 -1
- package/dist/Legend/Legend.d.ts.map +1 -1
- package/dist/Legend/Legend.js +24 -7
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/ListLegend.d.ts +14 -4
- package/dist/Legend/ListLegend.d.ts.map +1 -1
- package/dist/Legend/ListLegend.js +111 -15
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.d.ts +14 -2
- package/dist/Legend/ListLegendItem.d.ts.map +1 -1
- package/dist/Legend/ListLegendItem.js +31 -3
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/LineChart/LineChart.d.ts +0 -1
- package/dist/LineChart/LineChart.d.ts.map +1 -1
- package/dist/LineChart/LineChart.js +1 -3
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.d.ts +4 -2
- package/dist/OptionsEditorLayout/OptionsEditorControl.d.ts.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js +34 -5
- package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
- package/dist/StatChart/StatChart.d.ts +1 -0
- package/dist/StatChart/StatChart.d.ts.map +1 -1
- package/dist/StatChart/StatChart.js +2 -2
- package/dist/StatChart/StatChart.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.d.ts +3 -1
- package/dist/ThresholdsEditor/ThresholdInput.d.ts.map +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.js +9 -3
- package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.d.ts.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js +57 -35
- package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.d.ts +0 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js +3 -4
- package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts +0 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js +2 -3
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.d.ts +0 -1
- package/dist/TimeSeriesTooltip/TooltipContent.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js +1 -2
- package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts +2 -10
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.js +4 -8
- package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
- package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/utils.js +9 -6
- package/dist/TimeSeriesTooltip/utils.js.map +1 -1
- package/dist/cjs/InfoTooltip/InfoTooltip.js +8 -5
- package/dist/cjs/Legend/Legend.js +24 -7
- package/dist/cjs/Legend/ListLegend.js +106 -13
- package/dist/cjs/Legend/ListLegendItem.js +30 -2
- package/dist/cjs/LineChart/LineChart.js +1 -3
- package/dist/cjs/OptionsEditorLayout/OptionsEditorControl.js +33 -4
- package/dist/cjs/StatChart/StatChart.js +2 -2
- package/dist/cjs/ThresholdsEditor/ThresholdInput.js +8 -2
- package/dist/cjs/ThresholdsEditor/ThresholdsEditor.js +56 -34
- package/dist/cjs/TimeSeriesTooltip/SeriesInfo.js +3 -4
- package/dist/cjs/TimeSeriesTooltip/TimeSeriesTooltip.js +2 -3
- package/dist/cjs/TimeSeriesTooltip/TooltipContent.js +1 -2
- package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +4 -8
- package/dist/cjs/TimeSeriesTooltip/utils.js +9 -6
- package/dist/cjs/model/units/bytes.js +33 -39
- package/dist/cjs/model/units/decimal.js +15 -26
- package/dist/cjs/model/units/time.js +2 -3
- package/dist/cjs/utils/theme-gen.js +1 -1
- package/dist/model/legend.d.ts +1 -1
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js.map +1 -1
- package/dist/model/units/bytes.d.ts +1 -5
- package/dist/model/units/bytes.d.ts.map +1 -1
- package/dist/model/units/bytes.js +28 -42
- package/dist/model/units/bytes.js.map +1 -1
- package/dist/model/units/decimal.d.ts +1 -12
- package/dist/model/units/decimal.d.ts.map +1 -1
- package/dist/model/units/decimal.js +14 -30
- package/dist/model/units/decimal.js.map +1 -1
- package/dist/model/units/time.d.ts.map +1 -1
- package/dist/model/units/time.js +2 -3
- package/dist/model/units/time.js.map +1 -1
- package/dist/utils/theme-gen.js +1 -1
- package/dist/utils/theme-gen.js.map +1 -1
- package/package.json +11 -5
|
@@ -62,9 +62,30 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
62
62
|
}
|
|
63
63
|
return newObj;
|
|
64
64
|
}
|
|
65
|
-
const
|
|
65
|
+
const ListLegendItemBase = /*#__PURE__*/ (0, _react.forwardRef)(function ListLegendItem({ item , sx , truncateLabel , onLayoutChange , ...others }, ref) {
|
|
66
|
+
const [noWrap, setNoWrap] = (0, _react.useState)(truncateLabel);
|
|
67
|
+
function handleMouseOver() {
|
|
68
|
+
if (truncateLabel) {
|
|
69
|
+
setNoWrap(false);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function handleMouseOut() {
|
|
73
|
+
if (truncateLabel) {
|
|
74
|
+
setNoWrap(true);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
(0, _react.useEffect)(()=>{
|
|
78
|
+
// When `noWrap` changes, so does the layout of the component. Notifies the
|
|
79
|
+
// parent, so it can handle those changes.
|
|
80
|
+
onLayoutChange === null || onLayoutChange === void 0 ? void 0 : onLayoutChange();
|
|
81
|
+
}, [
|
|
82
|
+
noWrap,
|
|
83
|
+
onLayoutChange
|
|
84
|
+
]);
|
|
66
85
|
return /*#__PURE__*/ (0, _react.createElement)(_material.ListItem, {
|
|
67
86
|
...others,
|
|
87
|
+
component: "div",
|
|
88
|
+
role: "listitem",
|
|
68
89
|
sx: (0, _utils.combineSx)({
|
|
69
90
|
padding: 0,
|
|
70
91
|
cursor: 'pointer'
|
|
@@ -73,6 +94,7 @@ const ListLegendItem = /*#__PURE__*/ _react.default.memo(function ListLegendItem
|
|
|
73
94
|
key: item.id,
|
|
74
95
|
onClick: item.onClick,
|
|
75
96
|
selected: item.isSelected,
|
|
97
|
+
ref: ref,
|
|
76
98
|
children: [
|
|
77
99
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
78
100
|
sx: {
|
|
@@ -84,8 +106,14 @@ const ListLegendItem = /*#__PURE__*/ _react.default.memo(function ListLegendItem
|
|
|
84
106
|
})
|
|
85
107
|
}),
|
|
86
108
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.ListItemText, {
|
|
87
|
-
primary: item.label
|
|
109
|
+
primary: item.label,
|
|
110
|
+
primaryTypographyProps: {
|
|
111
|
+
noWrap: noWrap
|
|
112
|
+
},
|
|
113
|
+
onMouseOver: handleMouseOver,
|
|
114
|
+
onMouseOut: handleMouseOut
|
|
88
115
|
})
|
|
89
116
|
]
|
|
90
117
|
});
|
|
91
118
|
});
|
|
119
|
+
const ListLegendItem = /*#__PURE__*/ _react.default.memo(ListLegendItemBase);
|
|
@@ -84,8 +84,7 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
84
84
|
_renderers.CanvasRenderer
|
|
85
85
|
]);
|
|
86
86
|
function LineChart({ height , data , yAxis , unit , grid , legend , tooltipConfig ={
|
|
87
|
-
wrapLabels: true
|
|
88
|
-
showQuery: true
|
|
87
|
+
wrapLabels: true
|
|
89
88
|
} , onDataZoom , onDoubleClick , __experimentalEChartsOptionsOverride }) {
|
|
90
89
|
var ref;
|
|
91
90
|
const chartsTheme = (0, _chartsThemeProvider.useChartsTheme)();
|
|
@@ -226,7 +225,6 @@ function LineChart({ height , data , yAxis , unit , grid , legend , tooltipConfi
|
|
|
226
225
|
showTooltip === true && ((ref = option.tooltip) === null || ref === void 0 ? void 0 : ref.showContent) === false && tooltipConfig.hidden !== true && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeSeriesTooltip.TimeSeriesTooltip, {
|
|
227
226
|
chartRef: chartRef,
|
|
228
227
|
chartData: data,
|
|
229
|
-
showQuery: tooltipConfig.showQuery,
|
|
230
228
|
wrapLabels: tooltipConfig.wrapLabels,
|
|
231
229
|
pinTooltip: pinTooltip,
|
|
232
230
|
unit: unit
|
|
@@ -21,13 +21,15 @@ Object.defineProperty(exports, "OptionsEditorControl", {
|
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _material = require("@mui/material");
|
|
23
23
|
const _react = /*#__PURE__*/ _interopRequireDefault(require("react"));
|
|
24
|
+
const _informationOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/InformationOutline"));
|
|
24
25
|
const _utils = require("../utils");
|
|
26
|
+
const _infoTooltip = require("../InfoTooltip");
|
|
25
27
|
function _interopRequireDefault(obj) {
|
|
26
28
|
return obj && obj.__esModule ? obj : {
|
|
27
29
|
default: obj
|
|
28
30
|
};
|
|
29
31
|
}
|
|
30
|
-
const OptionsEditorControl = ({ label , control })=>{
|
|
32
|
+
const OptionsEditorControl = ({ label , control , description })=>{
|
|
31
33
|
// Make sure we have a unique ID we can use for associating labels and
|
|
32
34
|
// controls for a11y.
|
|
33
35
|
const generatedControlId = (0, _utils.useId)('EditorSectionControl');
|
|
@@ -41,9 +43,36 @@ const OptionsEditorControl = ({ label , control })=>{
|
|
|
41
43
|
alignItems: "center",
|
|
42
44
|
justifyContent: "space-between",
|
|
43
45
|
children: [
|
|
44
|
-
/*#__PURE__*/ (0, _jsxRuntime.
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
47
|
+
direction: "row",
|
|
48
|
+
alignItems: "center",
|
|
49
|
+
justifyContent: "center",
|
|
50
|
+
children: [
|
|
51
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormLabel, {
|
|
52
|
+
htmlFor: controlId,
|
|
53
|
+
children: label
|
|
54
|
+
}),
|
|
55
|
+
description && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_infoTooltip.InfoTooltip, {
|
|
56
|
+
description: description,
|
|
57
|
+
enterDelay: 100,
|
|
58
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
59
|
+
size: "small",
|
|
60
|
+
sx: (theme)=>({
|
|
61
|
+
borderRadius: theme.shape.borderRadius,
|
|
62
|
+
padding: '4x',
|
|
63
|
+
margin: '0 2px'
|
|
64
|
+
}),
|
|
65
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_informationOutline.default, {
|
|
66
|
+
"aria-describedby": "info-tooltip",
|
|
67
|
+
"aria-hidden": false,
|
|
68
|
+
fontSize: "inherit",
|
|
69
|
+
sx: {
|
|
70
|
+
color: (theme)=>theme.palette.grey[700]
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
]
|
|
47
76
|
}),
|
|
48
77
|
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
49
78
|
sx: {
|
|
@@ -40,7 +40,7 @@ const _echart = require("../EChart");
|
|
|
40
40
|
const MIN_VALUE_SIZE = 12;
|
|
41
41
|
const MAX_VALUE_SIZE = 36;
|
|
42
42
|
function StatChart(props) {
|
|
43
|
-
const { width , height , data , unit , sparkline } = props;
|
|
43
|
+
const { width , height , data , unit , color , sparkline } = props;
|
|
44
44
|
const chartsTheme = (0, _chartsThemeProvider.useChartsTheme)();
|
|
45
45
|
const formattedValue = data.calculatedValue === undefined ? '' : (0, _units.formatValue)(data.calculatedValue, unit);
|
|
46
46
|
const option = (0, _react.useMemo)(()=>{
|
|
@@ -109,7 +109,7 @@ function StatChart(props) {
|
|
|
109
109
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
110
110
|
variant: "h3",
|
|
111
111
|
sx: (theme)=>({
|
|
112
|
-
color: theme.palette.text.primary,
|
|
112
|
+
color: color !== null && color !== void 0 ? color : theme.palette.text.primary,
|
|
113
113
|
fontSize: `clamp(${MIN_VALUE_SIZE}px, ${valueSize}px, ${MAX_VALUE_SIZE}px)`,
|
|
114
114
|
padding: `${containerPadding} ${containerPadding} 0 ${containerPadding}`
|
|
115
115
|
}),
|
|
@@ -28,7 +28,7 @@ function _interopRequireDefault(obj) {
|
|
|
28
28
|
default: obj
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
function ThresholdInput({ inputRef , label , color , value , onChange , onColorChange , onBlur , onDelete }) {
|
|
31
|
+
function ThresholdInput({ inputRef , label , color , value , mode , onChange , onColorChange , onBlur , onDelete }) {
|
|
32
32
|
const [key, setKey] = (0, _react.useState)(0); // use key to cause input to lose focus when pressing enter
|
|
33
33
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
34
34
|
flex: 1,
|
|
@@ -50,7 +50,7 @@ function ThresholdInput({ inputRef , label , color , value , onChange , onColorC
|
|
|
50
50
|
id: label,
|
|
51
51
|
inputRef: inputRef,
|
|
52
52
|
type: "number",
|
|
53
|
-
value: value === 0 ?
|
|
53
|
+
value: value === 0 ? '' : value,
|
|
54
54
|
placeholder: "0",
|
|
55
55
|
onChange: onChange,
|
|
56
56
|
onBlur: onBlur,
|
|
@@ -59,6 +59,12 @@ function ThresholdInput({ inputRef , label , color , value , onChange , onColorC
|
|
|
59
59
|
onBlur();
|
|
60
60
|
setKey(key + 1);
|
|
61
61
|
}
|
|
62
|
+
},
|
|
63
|
+
InputProps: {
|
|
64
|
+
endAdornment: mode === 'Percent' ? /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
65
|
+
paddingX: 1,
|
|
66
|
+
children: "%"
|
|
67
|
+
}) : undefined
|
|
62
68
|
}
|
|
63
69
|
}, key),
|
|
64
70
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
@@ -24,9 +24,9 @@ const _immer = /*#__PURE__*/ _interopRequireDefault(require("immer"));
|
|
|
24
24
|
const _material = require("@mui/material");
|
|
25
25
|
const _plus = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Plus"));
|
|
26
26
|
const _system = require("@mui/system");
|
|
27
|
-
const _infoTooltip = require("../InfoTooltip");
|
|
28
27
|
const _chartsThemeProvider = require("../context/ChartsThemeProvider");
|
|
29
28
|
const _optionsEditorLayout = require("../OptionsEditorLayout");
|
|
29
|
+
const _infoTooltip = require("../InfoTooltip");
|
|
30
30
|
const _thresholdColorPicker = require("./ThresholdColorPicker");
|
|
31
31
|
const _thresholdInput = require("./ThresholdInput");
|
|
32
32
|
function _interopRequireDefault(obj) {
|
|
@@ -120,6 +120,10 @@ function ThresholdsEditor({ thresholds , onChange , hideDefault , disablePercent
|
|
|
120
120
|
onChange((0, _immer.default)(thresholds, (draft)=>{
|
|
121
121
|
draft.default_color = color;
|
|
122
122
|
}));
|
|
123
|
+
} else {
|
|
124
|
+
onChange({
|
|
125
|
+
default_color: color
|
|
126
|
+
});
|
|
123
127
|
}
|
|
124
128
|
};
|
|
125
129
|
// sort thresholds in ascending order every time an input blurs
|
|
@@ -156,6 +160,14 @@ function ThresholdsEditor({ thresholds , onChange , hideDefault , disablePercent
|
|
|
156
160
|
}
|
|
157
161
|
]
|
|
158
162
|
});
|
|
163
|
+
} else if (thresholds && thresholds.steps === undefined) {
|
|
164
|
+
onChange((0, _immer.default)(thresholds, (draft)=>{
|
|
165
|
+
draft.steps = [
|
|
166
|
+
{
|
|
167
|
+
value: DEFAULT_STEP
|
|
168
|
+
}
|
|
169
|
+
];
|
|
170
|
+
}));
|
|
159
171
|
} else {
|
|
160
172
|
onChange((0, _immer.default)(thresholds, (draft)=>{
|
|
161
173
|
const steps = draft.steps;
|
|
@@ -191,46 +203,55 @@ function ThresholdsEditor({ thresholds , onChange , hideDefault , disablePercent
|
|
|
191
203
|
var ref1, _color, ref2;
|
|
192
204
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_optionsEditorLayout.OptionsEditorGroup, {
|
|
193
205
|
title: "Thresholds",
|
|
194
|
-
icon: /*#__PURE__*/ (0, _jsxRuntime.jsx)(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
206
|
+
icon: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_infoTooltip.InfoTooltip, {
|
|
207
|
+
description: 'Add threshold',
|
|
208
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
209
|
+
size: "small",
|
|
210
|
+
"aria-label": "add threshold",
|
|
211
|
+
onClick: addThresholdInput,
|
|
212
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_plus.default, {})
|
|
213
|
+
})
|
|
199
214
|
}),
|
|
200
215
|
children: [
|
|
201
|
-
/*#__PURE__*/ (0, _jsxRuntime.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
216
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_optionsEditorLayout.OptionsEditorControl, {
|
|
217
|
+
label: "Mode",
|
|
218
|
+
description: "Percentage means thresholds relative to min & max",
|
|
219
|
+
control: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.ToggleButtonGroup, {
|
|
220
|
+
exclusive: true,
|
|
221
|
+
disabled: disablePercentMode,
|
|
222
|
+
value: (ref1 = thresholds === null || thresholds === void 0 ? void 0 : thresholds.mode) !== null && ref1 !== void 0 ? ref1 : 'Absolute',
|
|
223
|
+
onChange: handleModeChange,
|
|
224
|
+
sx: {
|
|
225
|
+
height: '36px',
|
|
226
|
+
marginLeft: 'auto'
|
|
227
|
+
},
|
|
228
|
+
children: [
|
|
229
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.ToggleButton, {
|
|
230
|
+
"aria-label": "absolute",
|
|
231
|
+
value: "Absolute",
|
|
232
|
+
sx: {
|
|
233
|
+
fontWeight: 500
|
|
234
|
+
},
|
|
235
|
+
children: "Absolute"
|
|
236
|
+
}),
|
|
237
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.ToggleButton, {
|
|
238
|
+
"aria-label": "percent",
|
|
239
|
+
value: "Percent",
|
|
240
|
+
sx: {
|
|
241
|
+
fontWeight: 500
|
|
242
|
+
},
|
|
243
|
+
children: "Percent"
|
|
225
244
|
})
|
|
226
|
-
|
|
227
|
-
|
|
245
|
+
]
|
|
246
|
+
})
|
|
228
247
|
}),
|
|
229
|
-
steps && steps.map((step, i)
|
|
248
|
+
steps && steps.map((step, i)=>{
|
|
249
|
+
/*#__PURE__*/ return (0, _jsxRuntime.jsx)(_thresholdInput.ThresholdInput, {
|
|
230
250
|
inputRef: i === steps.length - 1 ? recentlyAddedInputRef : undefined,
|
|
231
251
|
label: `T${i + 1}`,
|
|
232
252
|
color: (ref2 = (_color = step.color) !== null && _color !== void 0 ? _color : palette[i]) !== null && ref2 !== void 0 ? ref2 : defaultThresholdColor,
|
|
233
253
|
value: step.value,
|
|
254
|
+
mode: thresholds === null || thresholds === void 0 ? void 0 : thresholds.mode,
|
|
234
255
|
onColorChange: (color)=>handleThresholdColorChange(color, i),
|
|
235
256
|
onChange: (e)=>{
|
|
236
257
|
handleThresholdValueChange(e, i);
|
|
@@ -239,7 +260,8 @@ function ThresholdsEditor({ thresholds , onChange , hideDefault , disablePercent
|
|
|
239
260
|
deleteThreshold(i);
|
|
240
261
|
},
|
|
241
262
|
onBlur: handleThresholdBlur
|
|
242
|
-
}, i)
|
|
263
|
+
}, i);
|
|
264
|
+
}).reverse(),
|
|
243
265
|
!hideDefault && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_system.Stack, {
|
|
244
266
|
flex: 1,
|
|
245
267
|
direction: "row",
|
|
@@ -24,7 +24,7 @@ const _seriesMarker = require("./SeriesMarker");
|
|
|
24
24
|
const _seriesLabelsStack = require("./SeriesLabelsStack");
|
|
25
25
|
const _tooltipModel = require("./tooltip-model");
|
|
26
26
|
function SeriesInfo(props) {
|
|
27
|
-
const { seriesName , formattedY , markerColor , totalSeries , wrapLabels =true
|
|
27
|
+
const { seriesName , formattedY , markerColor , totalSeries , wrapLabels =true } = props;
|
|
28
28
|
// metric __name__ comes before opening curly brace, ignore if not populated
|
|
29
29
|
// ex with metric name: node_load15{env="demo",job="node"}
|
|
30
30
|
// ex without metric name: {env="demo",job="node"}
|
|
@@ -44,9 +44,8 @@ function SeriesInfo(props) {
|
|
|
44
44
|
markerColor: markerColor
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
//
|
|
48
|
-
const
|
|
49
|
-
const formattedSeriesInfo = seriesInfo.replace(/[,]/g, ', '); // add space after commas so wrapLabels works
|
|
47
|
+
// add space after commas so wrapLabels works
|
|
48
|
+
const formattedSeriesInfo = seriesName.replace(/[,]/g, ', ');
|
|
50
49
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
51
50
|
sx: {
|
|
52
51
|
display: 'table-row',
|
|
@@ -64,7 +64,7 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
64
64
|
}
|
|
65
65
|
return newObj;
|
|
66
66
|
}
|
|
67
|
-
const TimeSeriesTooltip = /*#__PURE__*/ _react.default.memo(function TimeSeriesTooltip({ chartRef , chartData , wrapLabels ,
|
|
67
|
+
const TimeSeriesTooltip = /*#__PURE__*/ _react.default.memo(function TimeSeriesTooltip({ chartRef , chartData , wrapLabels , pinTooltip , unit }) {
|
|
68
68
|
const [pinnedPos, setPinnedPos] = (0, _react.useState)(null);
|
|
69
69
|
const mousePos = (0, _tooltipModel.useMousePosition)();
|
|
70
70
|
if (mousePos === null || mousePos.target === null) return null;
|
|
@@ -109,8 +109,7 @@ const TimeSeriesTooltip = /*#__PURE__*/ _react.default.memo(function TimeSeriesT
|
|
|
109
109
|
},
|
|
110
110
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_tooltipContent.TooltipContent, {
|
|
111
111
|
focusedSeries: focusedSeries,
|
|
112
|
-
wrapLabels: wrapLabels
|
|
113
|
-
showQuery: showQuery
|
|
112
|
+
wrapLabels: wrapLabels
|
|
114
113
|
})
|
|
115
114
|
})
|
|
116
115
|
});
|
|
@@ -24,7 +24,7 @@ const _material = require("@mui/material");
|
|
|
24
24
|
const _timeZoneProvider = require("../context/TimeZoneProvider");
|
|
25
25
|
const _seriesInfo = require("./SeriesInfo");
|
|
26
26
|
function TooltipContent(props) {
|
|
27
|
-
const { focusedSeries ,
|
|
27
|
+
const { focusedSeries , wrapLabels } = props;
|
|
28
28
|
const { formatWithUserTimeZone } = (0, _timeZoneProvider.useTimeZone)();
|
|
29
29
|
const seriesTime = focusedSeries && focusedSeries[0] && focusedSeries[0].date ? focusedSeries[0].date : null;
|
|
30
30
|
const formatTimeSeriesHeader = (timeString)=>{
|
|
@@ -83,7 +83,6 @@ function TooltipContent(props) {
|
|
|
83
83
|
formattedY: formattedY,
|
|
84
84
|
markerColor: markerColor,
|
|
85
85
|
totalSeries: sortedFocusedSeries.length,
|
|
86
|
-
showQuery: showQuery,
|
|
87
86
|
wrapLabels: wrapLabels
|
|
88
87
|
}, key);
|
|
89
88
|
})
|
|
@@ -32,7 +32,7 @@ _export(exports, {
|
|
|
32
32
|
});
|
|
33
33
|
const _react = require("react");
|
|
34
34
|
const TOOLTIP_MAX_WIDTH = 650;
|
|
35
|
-
const TOOLTIP_MAX_HEIGHT =
|
|
35
|
+
const TOOLTIP_MAX_HEIGHT = 400;
|
|
36
36
|
const TOOLTIP_LABELS_MAX_WIDTH = TOOLTIP_MAX_WIDTH - 150;
|
|
37
37
|
const TOOLTIP_MAX_ITEMS = 50;
|
|
38
38
|
const TOOLTIP_DATE_FORMAT = new Intl.DateTimeFormat(undefined, {
|
|
@@ -46,10 +46,6 @@ const TOOLTIP_DATE_FORMAT = new Intl.DateTimeFormat(undefined, {
|
|
|
46
46
|
});
|
|
47
47
|
const defaultCursorData = {
|
|
48
48
|
coords: {
|
|
49
|
-
viewport: {
|
|
50
|
-
x: 0,
|
|
51
|
-
y: 0
|
|
52
|
-
},
|
|
53
49
|
plotCanvas: {
|
|
54
50
|
x: 0,
|
|
55
51
|
y: 0
|
|
@@ -71,9 +67,9 @@ const useMousePosition = ()=>{
|
|
|
71
67
|
(0, _react.useEffect)(()=>{
|
|
72
68
|
const setFromEvent = (e)=>{
|
|
73
69
|
return setCoords({
|
|
74
|
-
|
|
75
|
-
x: e.
|
|
76
|
-
y: e.
|
|
70
|
+
page: {
|
|
71
|
+
x: e.pageX,
|
|
72
|
+
y: e.pageY
|
|
77
73
|
},
|
|
78
74
|
plotCanvas: {
|
|
79
75
|
x: e.offsetX,
|
|
@@ -28,19 +28,22 @@ function assembleTransform(mousePos, seriesNum, chartWidth, chartHeight, pinnedP
|
|
|
28
28
|
}
|
|
29
29
|
const cursorPaddingX = 32;
|
|
30
30
|
const cursorPaddingY = 16;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
// Tooltip is located in a Portal attached to the body.
|
|
32
|
+
// Using page coordinates instead of viewport ensures the tooltip is
|
|
33
|
+
// absolutely positioned correctly as the user scrolls
|
|
34
|
+
const x = mousePos.page.x;
|
|
35
|
+
let y = mousePos.page.y + cursorPaddingY;
|
|
36
|
+
const isCloseToBottom = mousePos.page.y > window.innerHeight * 0.8;
|
|
34
37
|
const yPosAdjustThreshold = chartHeight * 0.75;
|
|
35
38
|
// adjust so tooltip does not get cut off at bottom of chart, reduce multiplier to move up
|
|
36
39
|
if (isCloseToBottom === true) {
|
|
37
40
|
if (seriesNum > 6) {
|
|
38
|
-
y = mousePos.
|
|
41
|
+
y = mousePos.page.y * 0.75;
|
|
39
42
|
} else {
|
|
40
|
-
y = mousePos.
|
|
43
|
+
y = mousePos.page.y * 0.9;
|
|
41
44
|
}
|
|
42
45
|
} else if (mousePos.plotCanvas.y > yPosAdjustThreshold) {
|
|
43
|
-
y = mousePos.
|
|
46
|
+
y = mousePos.page.y * 0.95;
|
|
44
47
|
}
|
|
45
48
|
// use tooltip width to determine when to repos from right to left (width is narrower when only 1 focused series since labels wrap)
|
|
46
49
|
const tooltipWidth = seriesNum > 1 ? _tooltipModel.TOOLTIP_MAX_WIDTH : _tooltipModel.TOOLTIP_MAX_WIDTH / 2;
|
|
@@ -25,7 +25,13 @@ _export(exports, {
|
|
|
25
25
|
BYTES_UNIT_CONFIG: ()=>BYTES_UNIT_CONFIG,
|
|
26
26
|
formatBytes: ()=>formatBytes
|
|
27
27
|
});
|
|
28
|
+
const _numbro = /*#__PURE__*/ _interopRequireDefault(require("numbro"));
|
|
28
29
|
const _constants = require("./constants");
|
|
30
|
+
function _interopRequireDefault(obj) {
|
|
31
|
+
return obj && obj.__esModule ? obj : {
|
|
32
|
+
default: obj
|
|
33
|
+
};
|
|
34
|
+
}
|
|
29
35
|
const bytesUnitKinds = [
|
|
30
36
|
'Bytes'
|
|
31
37
|
];
|
|
@@ -35,52 +41,40 @@ const BYTES_GROUP_CONFIG = {
|
|
|
35
41
|
abbreviate: true
|
|
36
42
|
};
|
|
37
43
|
const BYTES_UNIT_CONFIG = {
|
|
44
|
+
// This uses units that are powers of 1000.
|
|
45
|
+
// In other words, 1KB = 1000 bytes.
|
|
38
46
|
Bytes: {
|
|
39
47
|
group: 'Bytes',
|
|
40
48
|
label: 'Bytes'
|
|
41
49
|
}
|
|
42
50
|
};
|
|
43
|
-
function formatBytes(bytes,
|
|
51
|
+
function formatBytes(bytes, { abbreviate , decimal_places }) {
|
|
44
52
|
if (bytes === 0) return '0 bytes';
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
...unitOptions,
|
|
48
|
-
abbreviate: false
|
|
49
|
-
} : unitOptions;
|
|
50
|
-
var _decimal_places;
|
|
51
|
-
let decimals = (_decimal_places = options.decimal_places) !== null && _decimal_places !== void 0 ? _decimal_places : _constants.DEFAULT_DECIMAL_PLACES;
|
|
52
|
-
// avoids minimumFractionDigits value is out of range error, possible values are 0 to 20
|
|
53
|
+
decimal_places = decimal_places !== null && decimal_places !== void 0 ? decimal_places : _constants.DEFAULT_DECIMAL_PLACES;
|
|
54
|
+
// Avoids maximumFractionDigits value is out of range error. Possible values are 0 to 20.
|
|
53
55
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumfractiondigits
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
} else if (
|
|
57
|
-
|
|
56
|
+
if (decimal_places < 0) {
|
|
57
|
+
decimal_places = 0;
|
|
58
|
+
} else if (decimal_places > 20) {
|
|
59
|
+
decimal_places = 20;
|
|
58
60
|
}
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
const showFullNumber = abbreviate == false || bytes < 1000;
|
|
62
|
+
if (showFullNumber) {
|
|
63
|
+
const formatter = new Intl.NumberFormat('en-US', {
|
|
64
|
+
style: 'unit',
|
|
65
|
+
unit: 'byte',
|
|
66
|
+
unitDisplay: 'long',
|
|
67
|
+
maximumFractionDigits: decimal_places,
|
|
68
|
+
useGrouping: true
|
|
69
|
+
});
|
|
70
|
+
return formatter.format(bytes);
|
|
68
71
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
'
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
'EB',
|
|
78
|
-
'ZB',
|
|
79
|
-
'YB'
|
|
80
|
-
];
|
|
81
|
-
// Math.max(0, ...) ensures that we don't return -1 as a value for the index.
|
|
82
|
-
// Why? When the number of bytes are between -1 and 1, Math.floor(Math.log(bytes)/Math.log(1024)) returns -1.
|
|
83
|
-
const i = Math.max(0, Math.floor(Math.log(bytes) / Math.log(k)));
|
|
84
|
-
const abbreviatedValue = bytes / Math.pow(k, i);
|
|
85
|
-
return `${formatter.format(abbreviatedValue)} ${sizes[i]}`;
|
|
72
|
+
return (0, _numbro.default)(bytes).format({
|
|
73
|
+
output: 'byte',
|
|
74
|
+
base: 'decimal',
|
|
75
|
+
spaceSeparated: true,
|
|
76
|
+
mantissa: decimal_places,
|
|
77
|
+
trimMantissa: true,
|
|
78
|
+
optionalMantissa: true
|
|
79
|
+
});
|
|
86
80
|
}
|
|
@@ -23,11 +23,8 @@ function _export(target, all) {
|
|
|
23
23
|
_export(exports, {
|
|
24
24
|
PERCENT_GROUP_CONFIG: ()=>PERCENT_GROUP_CONFIG,
|
|
25
25
|
DECIMAL_UNIT_CONFIG: ()=>DECIMAL_UNIT_CONFIG,
|
|
26
|
-
formatDecimal: ()=>formatDecimal
|
|
27
|
-
abbreviateLargeNumber: ()=>abbreviateLargeNumber,
|
|
28
|
-
formatNumber: ()=>formatNumber
|
|
26
|
+
formatDecimal: ()=>formatDecimal
|
|
29
27
|
});
|
|
30
|
-
const _mathjs = require("../../utils/mathjs");
|
|
31
28
|
const _constants = require("./constants");
|
|
32
29
|
const decimalUnitKinds = [
|
|
33
30
|
'Decimal'
|
|
@@ -42,29 +39,21 @@ const DECIMAL_UNIT_CONFIG = {
|
|
|
42
39
|
label: 'Decimal'
|
|
43
40
|
}
|
|
44
41
|
};
|
|
45
|
-
function formatDecimal(value,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
function formatDecimal(value, { abbreviate , decimal_places }) {
|
|
43
|
+
decimal_places = decimal_places !== null && decimal_places !== void 0 ? decimal_places : _constants.DEFAULT_DECIMAL_PLACES;
|
|
44
|
+
// Avoids maximumFractionDigits value is out of range error. Possible values are 0 to 20.
|
|
45
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumfractiondigits
|
|
46
|
+
if (decimal_places < 0) {
|
|
47
|
+
decimal_places = 0;
|
|
48
|
+
} else if (decimal_places > 20) {
|
|
49
|
+
decimal_places = 20;
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
const formatParams = {
|
|
51
|
+
const showFullNumber = abbreviate == false || value < 1000;
|
|
52
|
+
const formatter = new Intl.NumberFormat('en-US', {
|
|
55
53
|
style: 'decimal',
|
|
56
|
-
|
|
57
|
-
maximumFractionDigits:
|
|
54
|
+
notation: showFullNumber ? 'standard' : 'compact',
|
|
55
|
+
maximumFractionDigits: decimal_places,
|
|
58
56
|
useGrouping: true
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
return decimalFormatter.format(value);
|
|
62
|
-
}
|
|
63
|
-
function abbreviateLargeNumber(num, decimals = 2) {
|
|
64
|
-
const modifier = (n)=>(0, _mathjs.round)(n, decimals);
|
|
65
|
-
return formatNumber(num, modifier);
|
|
66
|
-
}
|
|
67
|
-
function formatNumber(num, modifier) {
|
|
68
|
-
const fn = modifier !== null && modifier !== void 0 ? modifier : Math.round;
|
|
69
|
-
return num >= 1e12 ? fn(num / 1e12) + 'T' : num >= 1e9 ? fn(num / 1e9) + 'B' : num >= 1e6 ? fn(num / 1e6) + 'M' : num >= 1e3 ? fn(num / 1e3) + 'K' : num.toString();
|
|
57
|
+
});
|
|
58
|
+
return formatter.format(value);
|
|
70
59
|
}
|
|
@@ -89,14 +89,13 @@ var TimeIntlDuration;
|
|
|
89
89
|
})(TimeIntlDuration || (TimeIntlDuration = {}));
|
|
90
90
|
function formatTime(value, unitOptions) {
|
|
91
91
|
var _decimal_places;
|
|
92
|
-
const
|
|
92
|
+
const decimalPlaces = (_decimal_places = unitOptions.decimal_places) !== null && _decimal_places !== void 0 ? _decimal_places : _constants.DEFAULT_DECIMAL_PLACES;
|
|
93
93
|
const timeUnit = TimeIntlDuration[unitOptions.kind];
|
|
94
94
|
const formatter = new Intl.NumberFormat('en-US', {
|
|
95
95
|
style: 'unit',
|
|
96
96
|
unit: timeUnit,
|
|
97
97
|
unitDisplay: 'long',
|
|
98
|
-
|
|
99
|
-
maximumFractionDigits: decimals
|
|
98
|
+
maximumFractionDigits: decimalPlaces
|
|
100
99
|
});
|
|
101
100
|
return formatter.format(value);
|
|
102
101
|
}
|
package/dist/model/legend.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legend.d.ts","sourceRoot":"","sources":["../../src/model/legend.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,eAAO,MAAM,eAAe,8BAA+B,CAAC;AAE5D,oBAAY,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,eAAe,CAAC;CAC3B;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"legend.d.ts","sourceRoot":"","sources":["../../src/model/legend.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,eAAO,MAAM,eAAe,8BAA+B,CAAC;AAE5D,oBAAY,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,eAAe,CAAC;CAC3B;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;CACzC;AAED,oBAAY,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,oBAAoB,CAAC,CAG3F,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,aAE5B,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,QAAQ,CAAC,EAAE,eAAe,sBAQ3D;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,WAE9D;AAED,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,aAAa,WASxD"}
|