@perses-dev/components 0.29.1 → 0.31.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/DateTimeRangePicker/TimeRangeSelector.d.ts.map +1 -1
- package/dist/DateTimeRangePicker/TimeRangeSelector.js +7 -1
- package/dist/DateTimeRangePicker/TimeRangeSelector.js.map +1 -1
- package/dist/EChart/EChart.d.ts.map +1 -1
- package/dist/EChart/EChart.js +1 -7
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/Legend/CompactLegend.d.ts +6 -4
- package/dist/Legend/CompactLegend.d.ts.map +1 -1
- package/dist/Legend/CompactLegend.js +4 -1
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.d.ts +11 -9
- package/dist/Legend/Legend.d.ts.map +1 -1
- package/dist/Legend/Legend.js +45 -11
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/ListLegend.d.ts +5 -8
- package/dist/Legend/ListLegend.d.ts.map +1 -1
- package/dist/Legend/ListLegend.js +34 -99
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.d.ts +8 -8
- package/dist/Legend/ListLegendItem.d.ts.map +1 -1
- package/dist/Legend/ListLegendItem.js +9 -12
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/LineChart/LineChart.d.ts +2 -1
- package/dist/LineChart/LineChart.d.ts.map +1 -1
- package/dist/LineChart/LineChart.js +35 -22
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/StatChart/StatChart.d.ts.map +1 -1
- package/dist/StatChart/StatChart.js +5 -1
- package/dist/StatChart/StatChart.js.map +1 -1
- package/dist/Table/InnerTable.d.ts +9 -0
- package/dist/Table/InnerTable.d.ts.map +1 -0
- package/dist/Table/InnerTable.js +38 -0
- package/dist/Table/InnerTable.js.map +1 -0
- package/dist/Table/Table.d.ts +10 -0
- package/dist/Table/Table.d.ts.map +1 -0
- package/dist/Table/Table.js +101 -0
- package/dist/Table/Table.js.map +1 -0
- package/dist/Table/TableBody.d.ts +6 -0
- package/dist/Table/TableBody.d.ts.map +1 -0
- package/dist/Table/TableBody.js +23 -0
- package/dist/Table/TableBody.js.map +1 -0
- package/dist/Table/TableCell.d.ts +18 -0
- package/dist/Table/TableCell.d.ts.map +1 -0
- package/dist/Table/TableCell.js +91 -0
- package/dist/Table/TableCell.js.map +1 -0
- package/dist/Table/TableCheckbox.d.ts +9 -0
- package/dist/Table/TableCheckbox.d.ts.map +1 -0
- package/dist/Table/TableCheckbox.js +49 -0
- package/dist/Table/TableCheckbox.js.map +1 -0
- package/dist/Table/TableHead.d.ts +6 -0
- package/dist/Table/TableHead.d.ts.map +1 -0
- package/dist/Table/TableHead.js +23 -0
- package/dist/Table/TableHead.js.map +1 -0
- package/dist/Table/TableRow.d.ts +9 -0
- package/dist/Table/TableRow.d.ts.map +1 -0
- package/dist/Table/TableRow.js +29 -0
- package/dist/Table/TableRow.js.map +1 -0
- package/dist/Table/VirtualizedTable.d.ts +11 -0
- package/dist/Table/VirtualizedTable.d.ts.map +1 -0
- package/dist/Table/VirtualizedTable.js +152 -0
- package/dist/Table/VirtualizedTable.js.map +1 -0
- package/dist/Table/VirtualizedTableContainer.d.ts +6 -0
- package/dist/Table/VirtualizedTableContainer.d.ts.map +1 -0
- package/dist/Table/VirtualizedTableContainer.js +24 -0
- package/dist/Table/VirtualizedTableContainer.js.map +1 -0
- package/dist/Table/hooks/useTableKeyboardNav.d.ts +32 -0
- package/dist/Table/hooks/useTableKeyboardNav.d.ts.map +1 -0
- package/dist/Table/hooks/useTableKeyboardNav.js +98 -0
- package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -0
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts +29 -0
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts.map +1 -0
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +89 -0
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -0
- package/dist/Table/index.d.ts +4 -0
- package/dist/Table/index.d.ts.map +1 -0
- package/dist/Table/index.js +16 -0
- package/dist/Table/index.js.map +1 -0
- package/dist/Table/model/table-model.d.ts +83 -0
- package/dist/Table/model/table-model.d.ts.map +1 -0
- package/dist/Table/model/table-model.js +73 -0
- package/dist/Table/model/table-model.js.map +1 -0
- package/dist/TimeSeriesTooltip/SeriesInfo.d.ts +1 -0
- package/dist/TimeSeriesTooltip/SeriesInfo.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js +11 -9
- package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts +3 -2
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js +63 -17
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.d.ts +5 -3
- package/dist/TimeSeriesTooltip/TooltipContent.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js +81 -44
- package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
- package/dist/TimeSeriesTooltip/index.d.ts +1 -1
- package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/index.js +1 -1
- package/dist/TimeSeriesTooltip/index.js.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts +46 -0
- package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -0
- package/dist/TimeSeriesTooltip/nearby-series.js +200 -0
- package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -0
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts +12 -4
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.js +10 -2
- 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 +7 -15
- package/dist/TimeSeriesTooltip/utils.js.map +1 -1
- package/dist/UnitSelector/UnitSelector.d.ts.map +1 -1
- package/dist/UnitSelector/UnitSelector.js +40 -17
- package/dist/UnitSelector/UnitSelector.js.map +1 -1
- package/dist/cjs/DateTimeRangePicker/TimeRangeSelector.js +7 -1
- package/dist/cjs/EChart/EChart.js +1 -7
- package/dist/cjs/Legend/CompactLegend.js +4 -1
- package/dist/cjs/Legend/Legend.js +45 -11
- package/dist/cjs/Legend/ListLegend.js +33 -98
- package/dist/cjs/Legend/ListLegendItem.js +8 -11
- package/dist/cjs/LineChart/LineChart.js +35 -22
- package/dist/cjs/StatChart/StatChart.js +5 -1
- package/dist/cjs/Table/InnerTable.js +44 -0
- package/dist/cjs/Table/Table.js +102 -0
- package/dist/cjs/Table/TableBody.js +29 -0
- package/dist/cjs/Table/TableCell.js +97 -0
- package/dist/cjs/Table/TableCheckbox.js +55 -0
- package/dist/cjs/Table/TableHead.js +29 -0
- package/dist/cjs/Table/TableRow.js +35 -0
- package/dist/cjs/Table/VirtualizedTable.js +155 -0
- package/dist/cjs/Table/VirtualizedTableContainer.js +30 -0
- package/dist/cjs/Table/hooks/useTableKeyboardNav.js +99 -0
- package/dist/cjs/Table/hooks/useVirtualizedTableKeyboardNav.js +93 -0
- package/dist/cjs/Table/index.js +33 -0
- package/dist/cjs/Table/model/table-model.js +80 -0
- package/dist/cjs/TimeSeriesTooltip/SeriesInfo.js +10 -8
- package/dist/cjs/TimeSeriesTooltip/TimeSeriesTooltip.js +67 -16
- package/dist/cjs/TimeSeriesTooltip/TooltipContent.js +85 -43
- package/dist/cjs/TimeSeriesTooltip/index.js +1 -1
- package/dist/cjs/TimeSeriesTooltip/nearby-series.js +206 -0
- package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +15 -3
- package/dist/cjs/TimeSeriesTooltip/utils.js +6 -14
- package/dist/cjs/UnitSelector/UnitSelector.js +39 -16
- package/dist/cjs/context/SnackbarProvider.js +66 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/model/legend.js +7 -1
- package/dist/cjs/model/units/bytes.js +25 -21
- package/dist/cjs/model/units/constants.js +3 -3
- package/dist/cjs/model/units/decimal.js +22 -19
- package/dist/cjs/model/units/percent.js +15 -22
- package/dist/cjs/model/units/time.js +24 -20
- package/dist/cjs/model/units/units.js +2 -2
- package/dist/cjs/model/units/utils.js +42 -0
- package/dist/cjs/theme/palette/grey.js +6 -2
- package/dist/context/SnackbarProvider.d.ts +23 -0
- package/dist/context/SnackbarProvider.d.ts.map +1 -0
- package/dist/context/SnackbarProvider.js +59 -0
- package/dist/context/SnackbarProvider.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/model/legend.d.ts +10 -2
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js +5 -0
- package/dist/model/legend.js.map +1 -1
- package/dist/model/units/bytes.d.ts +1 -1
- package/dist/model/units/bytes.d.ts.map +1 -1
- package/dist/model/units/bytes.js +26 -22
- package/dist/model/units/bytes.js.map +1 -1
- package/dist/model/units/constants.d.ts +1 -1
- package/dist/model/units/constants.js +1 -1
- package/dist/model/units/constants.js.map +1 -1
- package/dist/model/units/decimal.d.ts +2 -2
- package/dist/model/units/decimal.d.ts.map +1 -1
- package/dist/model/units/decimal.js +22 -19
- package/dist/model/units/decimal.js.map +1 -1
- package/dist/model/units/percent.d.ts +1 -1
- package/dist/model/units/percent.d.ts.map +1 -1
- package/dist/model/units/percent.js +14 -21
- package/dist/model/units/percent.js.map +1 -1
- package/dist/model/units/time.d.ts +1 -1
- package/dist/model/units/time.d.ts.map +1 -1
- package/dist/model/units/time.js +24 -20
- package/dist/model/units/time.js.map +1 -1
- package/dist/model/units/units.js +2 -2
- package/dist/model/units/units.js.map +1 -1
- package/dist/model/units/utils.d.ts +4 -0
- package/dist/model/units/utils.d.ts.map +1 -0
- package/dist/model/units/utils.js +32 -0
- package/dist/model/units/utils.js.map +1 -0
- package/dist/theme/palette/grey.d.ts.map +1 -1
- package/dist/theme/palette/grey.js +6 -2
- package/dist/theme/palette/grey.js.map +1 -1
- package/package.json +6 -6
- package/dist/TimeSeriesTooltip/focused-series.d.ts +0 -25
- package/dist/TimeSeriesTooltip/focused-series.d.ts.map +0 -1
- package/dist/TimeSeriesTooltip/focused-series.js +0 -111
- package/dist/TimeSeriesTooltip/focused-series.js.map +0 -1
- package/dist/cjs/TimeSeriesTooltip/focused-series.js +0 -117
|
@@ -20,18 +20,25 @@ Object.defineProperty(exports, "TooltipContent", {
|
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _react = require("react");
|
|
23
|
+
const _pinOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/PinOutline"));
|
|
24
|
+
const _pin = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Pin"));
|
|
23
25
|
const _material = require("@mui/material");
|
|
24
26
|
const _timeZoneProvider = require("../context/TimeZoneProvider");
|
|
25
27
|
const _seriesInfo = require("./SeriesInfo");
|
|
28
|
+
function _interopRequireDefault(obj) {
|
|
29
|
+
return obj && obj.__esModule ? obj : {
|
|
30
|
+
default: obj
|
|
31
|
+
};
|
|
32
|
+
}
|
|
26
33
|
function TooltipContent(props) {
|
|
27
|
-
const {
|
|
34
|
+
const { series , wrapLabels , isTooltipPinned , onUnpinClick } = props;
|
|
28
35
|
const { formatWithUserTimeZone } = (0, _timeZoneProvider.useTimeZone)();
|
|
29
|
-
const seriesTime =
|
|
30
|
-
const formatTimeSeriesHeader = (
|
|
31
|
-
const date = new Date(
|
|
36
|
+
const seriesTime = series && series[0] && series[0].date ? series[0].date : null;
|
|
37
|
+
const formatTimeSeriesHeader = (timeMs)=>{
|
|
38
|
+
const date = new Date(timeMs);
|
|
32
39
|
const formattedDate = formatWithUserTimeZone(date, 'MMM dd, yyyy - ');
|
|
33
40
|
const formattedTime = formatWithUserTimeZone(date, 'HH:mm:ss');
|
|
34
|
-
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(
|
|
41
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
35
42
|
children: [
|
|
36
43
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
37
44
|
variant: "caption",
|
|
@@ -50,46 +57,81 @@ function TooltipContent(props) {
|
|
|
50
57
|
});
|
|
51
58
|
};
|
|
52
59
|
const sortedFocusedSeries = (0, _react.useMemo)(()=>{
|
|
53
|
-
if (
|
|
54
|
-
return
|
|
60
|
+
if (series === null) return null;
|
|
61
|
+
return series.sort((a, b)=>a.y > b.y ? -1 : 1);
|
|
55
62
|
}, [
|
|
56
|
-
|
|
63
|
+
series
|
|
57
64
|
]);
|
|
58
|
-
if (sortedFocusedSeries
|
|
59
|
-
return
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
65
|
+
if (sortedFocusedSeries === null || seriesTime === null) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
// TODO: use react-virtuoso to improve performance
|
|
69
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
70
|
+
py: 1,
|
|
71
|
+
spacing: 0.5,
|
|
72
|
+
children: [
|
|
73
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
74
|
+
sx: {
|
|
75
|
+
display: 'flex',
|
|
76
|
+
justifyContent: 'start',
|
|
77
|
+
alignItems: 'center'
|
|
78
|
+
},
|
|
79
|
+
children: [
|
|
80
|
+
formatTimeSeriesHeader(seriesTime),
|
|
81
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
82
|
+
direction: "row",
|
|
83
|
+
gap: 1,
|
|
84
|
+
sx: {
|
|
85
|
+
marginLeft: 'auto'
|
|
86
|
+
},
|
|
87
|
+
children: [
|
|
88
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
89
|
+
sx: {
|
|
90
|
+
fontSize: 11
|
|
91
|
+
},
|
|
92
|
+
children: [
|
|
93
|
+
"Click to ",
|
|
94
|
+
isTooltipPinned ? 'Unpin' : 'Pin'
|
|
95
|
+
]
|
|
96
|
+
}),
|
|
97
|
+
isTooltipPinned ? /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pin.default, {
|
|
98
|
+
onClick: onUnpinClick,
|
|
99
|
+
sx: {
|
|
100
|
+
fontSize: 16,
|
|
101
|
+
cursor: 'pointer'
|
|
102
|
+
}
|
|
103
|
+
}) : /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pinOutline.default, {
|
|
104
|
+
sx: {
|
|
105
|
+
fontSize: 16
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
]
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
}),
|
|
112
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Divider, {
|
|
113
|
+
sx: (theme)=>({
|
|
114
|
+
borderColor: theme.palette.grey['500']
|
|
88
115
|
})
|
|
116
|
+
}),
|
|
117
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
118
|
+
sx: {
|
|
119
|
+
display: 'table'
|
|
120
|
+
},
|
|
121
|
+
children: sortedFocusedSeries.map(({ datumIdx , seriesIdx , seriesName , y , formattedY , markerColor , isClosestToCursor })=>{
|
|
122
|
+
if (datumIdx === null || seriesIdx === null) return null;
|
|
123
|
+
const key = seriesIdx.toString() + datumIdx.toString();
|
|
124
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_seriesInfo.SeriesInfo, {
|
|
125
|
+
seriesName: seriesName,
|
|
126
|
+
y: y,
|
|
127
|
+
formattedY: formattedY,
|
|
128
|
+
markerColor: markerColor,
|
|
129
|
+
totalSeries: sortedFocusedSeries.length,
|
|
130
|
+
wrapLabels: wrapLabels,
|
|
131
|
+
emphasizeText: isClosestToCursor
|
|
132
|
+
}, key);
|
|
89
133
|
})
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {});
|
|
94
|
-
}
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
});
|
|
95
137
|
}
|
|
@@ -19,7 +19,7 @@ _exportStar(require("./SeriesInfo"), exports);
|
|
|
19
19
|
_exportStar(require("./SeriesLabelsStack"), exports);
|
|
20
20
|
_exportStar(require("./SeriesMarker"), exports);
|
|
21
21
|
_exportStar(require("./TooltipContent"), exports);
|
|
22
|
-
_exportStar(require("./
|
|
22
|
+
_exportStar(require("./nearby-series"), exports);
|
|
23
23
|
_exportStar(require("./tooltip-model"), exports);
|
|
24
24
|
_exportStar(require("./utils"), exports);
|
|
25
25
|
function _exportStar(from, to) {
|
|
@@ -0,0 +1,206 @@
|
|
|
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
|
+
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
|
+
INCREASE_NEARBY_SERIES_MULTIPLIER: ()=>INCREASE_NEARBY_SERIES_MULTIPLIER,
|
|
25
|
+
DYNAMIC_NEARBY_SERIES_MULTIPLIER: ()=>DYNAMIC_NEARBY_SERIES_MULTIPLIER,
|
|
26
|
+
SHOW_FEWER_SERIES_LIMIT: ()=>SHOW_FEWER_SERIES_LIMIT,
|
|
27
|
+
checkforNearbySeries: ()=>checkforNearbySeries,
|
|
28
|
+
getNearbySeriesData: ()=>getNearbySeriesData,
|
|
29
|
+
isWithinPercentageRange: ()=>isWithinPercentageRange,
|
|
30
|
+
getYBuffer: ()=>getYBuffer
|
|
31
|
+
});
|
|
32
|
+
const _model = require("../model");
|
|
33
|
+
const INCREASE_NEARBY_SERIES_MULTIPLIER = 5.5; // adjusts how many series show in tooltip (higher == more series shown)
|
|
34
|
+
const DYNAMIC_NEARBY_SERIES_MULTIPLIER = 30; // used for adjustment after series number divisor
|
|
35
|
+
const SHOW_FEWER_SERIES_LIMIT = 5;
|
|
36
|
+
function checkforNearbySeries(data, pointInGrid, yBuffer, chart, unit) {
|
|
37
|
+
const currentNearbySeriesData = [];
|
|
38
|
+
var ref;
|
|
39
|
+
const cursorX = (ref = pointInGrid[0]) !== null && ref !== void 0 ? ref : null;
|
|
40
|
+
var ref1;
|
|
41
|
+
const cursorY = (ref1 = pointInGrid[1]) !== null && ref1 !== void 0 ? ref1 : null;
|
|
42
|
+
if (cursorX === null || cursorY === null) {
|
|
43
|
+
return currentNearbySeriesData;
|
|
44
|
+
}
|
|
45
|
+
const nearbySeriesIndexes = [];
|
|
46
|
+
const emphasizedSeriesIndexes = [];
|
|
47
|
+
const nonEmphasizedSeriesIndexes = [];
|
|
48
|
+
const totalSeries = data.timeSeries.length;
|
|
49
|
+
if (Array.isArray(data.xAxis) && Array.isArray(data.timeSeries)) {
|
|
50
|
+
for(let seriesIdx = 0; seriesIdx < totalSeries; seriesIdx++){
|
|
51
|
+
const currentSeries = data.timeSeries[seriesIdx];
|
|
52
|
+
if (currentNearbySeriesData.length >= _model.OPTIMIZED_MODE_SERIES_LIMIT) break;
|
|
53
|
+
if (currentSeries !== undefined) {
|
|
54
|
+
const currentSeriesName = currentSeries.name ? currentSeries.name.toString() : '';
|
|
55
|
+
var _color;
|
|
56
|
+
const markerColor = (_color = currentSeries.color) !== null && _color !== void 0 ? _color : '#000';
|
|
57
|
+
if (Array.isArray(currentSeries.data)) {
|
|
58
|
+
for(let datumIdx = 0; datumIdx < currentSeries.data.length; datumIdx++){
|
|
59
|
+
var _datumIdx;
|
|
60
|
+
const xValue = (_datumIdx = data.xAxis[datumIdx]) !== null && _datumIdx !== void 0 ? _datumIdx : 0;
|
|
61
|
+
const yValue = currentSeries.data[datumIdx];
|
|
62
|
+
// ensure null values not displayed in tooltip
|
|
63
|
+
if (yValue !== undefined && yValue !== null && cursorX === datumIdx) {
|
|
64
|
+
if (yValue !== '-' && cursorY <= yValue + yBuffer && cursorY >= yValue - yBuffer) {
|
|
65
|
+
// show fewer bold series in tooltip when many total series
|
|
66
|
+
const minPercentRange = totalSeries > SHOW_FEWER_SERIES_LIMIT ? 2 : 5;
|
|
67
|
+
const percentRangeToCheck = Math.max(minPercentRange, 100 / totalSeries);
|
|
68
|
+
const isClosestToCursor = isWithinPercentageRange({
|
|
69
|
+
valueToCheck: cursorY,
|
|
70
|
+
baseValue: yValue,
|
|
71
|
+
percentage: percentRangeToCheck
|
|
72
|
+
});
|
|
73
|
+
if (isClosestToCursor) {
|
|
74
|
+
emphasizedSeriesIndexes.push(seriesIdx);
|
|
75
|
+
} else {
|
|
76
|
+
nonEmphasizedSeriesIndexes.push(seriesIdx);
|
|
77
|
+
// ensure series not close to cursor are not highlighted
|
|
78
|
+
if ((chart === null || chart === void 0 ? void 0 : chart.dispatchAction) !== undefined) {
|
|
79
|
+
chart.dispatchAction({
|
|
80
|
+
type: 'downplay',
|
|
81
|
+
seriesIndex: seriesIdx
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// determine whether to convert timestamp to ms, see: https://stackoverflow.com/a/23982005/17575201
|
|
86
|
+
const xValueMilliSeconds = xValue > 99999999999 ? xValue : xValue * 1000;
|
|
87
|
+
const formattedY = (0, _model.formatValue)(yValue, unit);
|
|
88
|
+
currentNearbySeriesData.push({
|
|
89
|
+
seriesIdx: seriesIdx,
|
|
90
|
+
datumIdx: datumIdx,
|
|
91
|
+
seriesName: currentSeriesName,
|
|
92
|
+
date: xValueMilliSeconds,
|
|
93
|
+
x: xValue,
|
|
94
|
+
y: yValue,
|
|
95
|
+
formattedY: formattedY,
|
|
96
|
+
markerColor: markerColor.toString(),
|
|
97
|
+
isClosestToCursor
|
|
98
|
+
});
|
|
99
|
+
nearbySeriesIndexes.push(seriesIdx);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if ((chart === null || chart === void 0 ? void 0 : chart.dispatchAction) !== undefined) {
|
|
108
|
+
// Clears emphasis state of all lines that are not emphasized.
|
|
109
|
+
// Emphasized is a subset of just the nearby series that are closest to cursor.
|
|
110
|
+
chart.dispatchAction({
|
|
111
|
+
type: 'downplay',
|
|
112
|
+
seriesIndex: nonEmphasizedSeriesIndexes
|
|
113
|
+
});
|
|
114
|
+
// https://echarts.apache.org/en/api.html#action.highlight
|
|
115
|
+
if (emphasizedSeriesIndexes.length > 0) {
|
|
116
|
+
// Fadeout opacity of all series not closest to cursor.
|
|
117
|
+
chart.dispatchAction({
|
|
118
|
+
type: 'highlight',
|
|
119
|
+
seriesIndex: emphasizedSeriesIndexes,
|
|
120
|
+
notBlur: false
|
|
121
|
+
});
|
|
122
|
+
} else {
|
|
123
|
+
// When no emphasized series with bold text, notBlur allows opacity fadeout to not trigger.
|
|
124
|
+
chart.dispatchAction({
|
|
125
|
+
type: 'highlight',
|
|
126
|
+
seriesIndex: nearbySeriesIndexes,
|
|
127
|
+
notBlur: true
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return currentNearbySeriesData;
|
|
132
|
+
}
|
|
133
|
+
function getNearbySeriesData({ mousePos , pinnedPos , chartData , chart , unit , showAllSeries =false }) {
|
|
134
|
+
if (chart === undefined || mousePos === null) return [];
|
|
135
|
+
// prevents multiple tooltips showing from adjacent charts
|
|
136
|
+
let cursorTargetMatchesChart = false;
|
|
137
|
+
if (mousePos.target !== null) {
|
|
138
|
+
const currentParent = mousePos.target.parentElement;
|
|
139
|
+
if (currentParent !== null) {
|
|
140
|
+
const currentGrandparent = currentParent.parentElement;
|
|
141
|
+
if (currentGrandparent !== null) {
|
|
142
|
+
const chartDom = chart.getDom();
|
|
143
|
+
if (chartDom === currentGrandparent) {
|
|
144
|
+
cursorTargetMatchesChart = true;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// allows moving cursor inside tooltip
|
|
150
|
+
if (pinnedPos !== null) {
|
|
151
|
+
mousePos = pinnedPos;
|
|
152
|
+
cursorTargetMatchesChart = true;
|
|
153
|
+
}
|
|
154
|
+
if (cursorTargetMatchesChart === false) return [];
|
|
155
|
+
if (chart['_model'] === undefined) return [];
|
|
156
|
+
const chartModel = chart['_model'];
|
|
157
|
+
const yInterval = chartModel.getComponent('yAxis').axis.scale._interval;
|
|
158
|
+
const totalSeries = chartData.timeSeries.length;
|
|
159
|
+
const yBuffer = getYBuffer({
|
|
160
|
+
yInterval,
|
|
161
|
+
totalSeries,
|
|
162
|
+
showAllSeries
|
|
163
|
+
});
|
|
164
|
+
var _x, _y;
|
|
165
|
+
const pointInPixel = [
|
|
166
|
+
(_x = mousePos.plotCanvas.x) !== null && _x !== void 0 ? _x : 0,
|
|
167
|
+
(_y = mousePos.plotCanvas.y) !== null && _y !== void 0 ? _y : 0
|
|
168
|
+
];
|
|
169
|
+
if (chart.containPixel('grid', pointInPixel)) {
|
|
170
|
+
const pointInGrid = chart.convertFromPixel('grid', pointInPixel);
|
|
171
|
+
if (pointInGrid[0] !== undefined && pointInGrid[1] !== undefined) {
|
|
172
|
+
return checkforNearbySeries(chartData, pointInGrid, yBuffer, chart, unit);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// clear all highlighted series when cursor exits canvas
|
|
176
|
+
// https://echarts.apache.org/en/api.html#action.downplay
|
|
177
|
+
for(let i = 0; i < totalSeries; i++){
|
|
178
|
+
if ((chart === null || chart === void 0 ? void 0 : chart.dispatchAction) !== undefined) {
|
|
179
|
+
chart.dispatchAction({
|
|
180
|
+
type: 'downplay',
|
|
181
|
+
seriesIndex: i
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return [];
|
|
186
|
+
}
|
|
187
|
+
function isWithinPercentageRange({ valueToCheck , baseValue , percentage }) {
|
|
188
|
+
const range = percentage / 100 * baseValue;
|
|
189
|
+
const lowerBound = baseValue - range;
|
|
190
|
+
const upperBound = baseValue + range;
|
|
191
|
+
return valueToCheck >= lowerBound && valueToCheck <= upperBound;
|
|
192
|
+
}
|
|
193
|
+
function getYBuffer({ yInterval , totalSeries , showAllSeries =false }) {
|
|
194
|
+
if (showAllSeries) {
|
|
195
|
+
return yInterval * 10; // roughly correlates with grid so entire canvas is searched
|
|
196
|
+
}
|
|
197
|
+
// never let nearby series range be less than roughly the size of a single tick
|
|
198
|
+
const yBufferMin = yInterval * 0.3;
|
|
199
|
+
// tooltip trigger area gets smaller with more series
|
|
200
|
+
if (totalSeries > SHOW_FEWER_SERIES_LIMIT) {
|
|
201
|
+
const adjustedBuffer = yInterval * DYNAMIC_NEARBY_SERIES_MULTIPLIER / totalSeries;
|
|
202
|
+
return Math.max(yBufferMin, adjustedBuffer);
|
|
203
|
+
}
|
|
204
|
+
// increase multiplier to expand nearby series range
|
|
205
|
+
return Math.max(yBufferMin, yInterval * INCREASE_NEARBY_SERIES_MULTIPLIER);
|
|
206
|
+
}
|
|
@@ -21,20 +21,28 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
+
TOOLTIP_MIN_WIDTH: ()=>TOOLTIP_MIN_WIDTH,
|
|
24
25
|
TOOLTIP_MAX_WIDTH: ()=>TOOLTIP_MAX_WIDTH,
|
|
25
26
|
TOOLTIP_MAX_HEIGHT: ()=>TOOLTIP_MAX_HEIGHT,
|
|
26
27
|
TOOLTIP_LABELS_MAX_WIDTH: ()=>TOOLTIP_LABELS_MAX_WIDTH,
|
|
27
|
-
|
|
28
|
+
TOOLTIP_ADJUST_Y_POS_MULTIPLIER: ()=>TOOLTIP_ADJUST_Y_POS_MULTIPLIER,
|
|
29
|
+
FALLBACK_CHART_WIDTH: ()=>FALLBACK_CHART_WIDTH,
|
|
30
|
+
NEARBY_SERIES_DESCRIPTION: ()=>NEARBY_SERIES_DESCRIPTION,
|
|
31
|
+
EMPHASIZED_SERIES_DESCRIPTION: ()=>EMPHASIZED_SERIES_DESCRIPTION,
|
|
28
32
|
TOOLTIP_DATE_FORMAT: ()=>TOOLTIP_DATE_FORMAT,
|
|
29
33
|
defaultCursorData: ()=>defaultCursorData,
|
|
30
34
|
emptyTooltipData: ()=>emptyTooltipData,
|
|
31
35
|
useMousePosition: ()=>useMousePosition
|
|
32
36
|
});
|
|
33
37
|
const _react = require("react");
|
|
38
|
+
const TOOLTIP_MIN_WIDTH = 375;
|
|
34
39
|
const TOOLTIP_MAX_WIDTH = 650;
|
|
35
|
-
const TOOLTIP_MAX_HEIGHT =
|
|
40
|
+
const TOOLTIP_MAX_HEIGHT = 600;
|
|
36
41
|
const TOOLTIP_LABELS_MAX_WIDTH = TOOLTIP_MAX_WIDTH - 150;
|
|
37
|
-
const
|
|
42
|
+
const TOOLTIP_ADJUST_Y_POS_MULTIPLIER = 0.75;
|
|
43
|
+
const FALLBACK_CHART_WIDTH = 750;
|
|
44
|
+
const NEARBY_SERIES_DESCRIPTION = 'nearby series showing in tooltip';
|
|
45
|
+
const EMPHASIZED_SERIES_DESCRIPTION = 'emphasized series showing as bold in tooltip';
|
|
38
46
|
const TOOLTIP_DATE_FORMAT = new Intl.DateTimeFormat(undefined, {
|
|
39
47
|
year: 'numeric',
|
|
40
48
|
month: 'short',
|
|
@@ -71,6 +79,10 @@ const useMousePosition = ()=>{
|
|
|
71
79
|
x: e.pageX,
|
|
72
80
|
y: e.pageY
|
|
73
81
|
},
|
|
82
|
+
client: {
|
|
83
|
+
x: e.clientX,
|
|
84
|
+
y: e.clientY
|
|
85
|
+
},
|
|
74
86
|
plotCanvas: {
|
|
75
87
|
x: e.offsetX,
|
|
76
88
|
y: e.offsetY
|
|
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "assembleTransform", {
|
|
|
19
19
|
get: ()=>assembleTransform
|
|
20
20
|
});
|
|
21
21
|
const _tooltipModel = require("./tooltip-model");
|
|
22
|
-
function assembleTransform(mousePos,
|
|
22
|
+
function assembleTransform(mousePos, chartWidth, pinnedPos, tooltipHeight, tooltipWidth) {
|
|
23
23
|
if (mousePos === null) {
|
|
24
24
|
return 'translate3d(0, 0)';
|
|
25
25
|
}
|
|
@@ -33,20 +33,12 @@ function assembleTransform(mousePos, seriesNum, chartWidth, chartHeight, pinnedP
|
|
|
33
33
|
// absolutely positioned correctly as the user scrolls
|
|
34
34
|
const x = mousePos.page.x;
|
|
35
35
|
let y = mousePos.page.y + cursorPaddingY;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (seriesNum > 6) {
|
|
41
|
-
y = mousePos.page.y * 0.75;
|
|
42
|
-
} else {
|
|
43
|
-
y = mousePos.page.y * 0.9;
|
|
44
|
-
}
|
|
45
|
-
} else if (mousePos.plotCanvas.y > yPosAdjustThreshold) {
|
|
46
|
-
y = mousePos.page.y * 0.95;
|
|
36
|
+
// adjust so tooltip does not get cut off at bottom of chart
|
|
37
|
+
if (mousePos.client.y + tooltipHeight + cursorPaddingY > window.innerHeight) {
|
|
38
|
+
// multiplier ensures tooltip isn't overly adjusted and gets cut off at the top of the viewport
|
|
39
|
+
y = mousePos.page.y - tooltipHeight * _tooltipModel.TOOLTIP_ADJUST_Y_POS_MULTIPLIER;
|
|
47
40
|
}
|
|
48
|
-
// use tooltip width to determine when to repos from right to left
|
|
49
|
-
const tooltipWidth = seriesNum > 1 ? _tooltipModel.TOOLTIP_MAX_WIDTH : _tooltipModel.TOOLTIP_MAX_WIDTH / 2;
|
|
41
|
+
// use tooltip width to determine when to repos from right to left
|
|
50
42
|
const xPosAdjustThreshold = chartWidth - tooltipWidth * 0.9;
|
|
51
43
|
// reposition so tooltip is never too close to right side of chart or left side of browser window
|
|
52
44
|
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)`;
|
|
@@ -21,6 +21,7 @@ Object.defineProperty(exports, "UnitSelector", {
|
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _material = require("@mui/material");
|
|
23
23
|
const _model = require("../model");
|
|
24
|
+
const _utils = require("../model/units/utils");
|
|
24
25
|
const _optionsEditorLayout = require("../OptionsEditorLayout");
|
|
25
26
|
const KIND_OPTIONS = Object.entries(_model.UNIT_CONFIG).map(([id, config])=>{
|
|
26
27
|
return {
|
|
@@ -28,13 +29,35 @@ const KIND_OPTIONS = Object.entries(_model.UNIT_CONFIG).map(([id, config])=>{
|
|
|
28
29
|
...config
|
|
29
30
|
};
|
|
30
31
|
}).filter((config)=>!config.disableSelectorOption);
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
const DECIMAL_PLACES_OPTIONS = [
|
|
33
|
+
{
|
|
34
|
+
label: 'Default',
|
|
35
|
+
decimal_places: undefined
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: '0',
|
|
39
|
+
decimal_places: 0
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
label: '1',
|
|
43
|
+
decimal_places: 1
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
label: '2',
|
|
47
|
+
decimal_places: 2
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: '3',
|
|
51
|
+
decimal_places: 3
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
label: '4',
|
|
55
|
+
decimal_places: 4
|
|
56
|
+
}
|
|
37
57
|
];
|
|
58
|
+
function getOptionByDecimalPlaces(decimal_places) {
|
|
59
|
+
return DECIMAL_PLACES_OPTIONS.find((o)=>o.decimal_places === decimal_places);
|
|
60
|
+
}
|
|
38
61
|
function UnitSelector({ value , onChange }) {
|
|
39
62
|
const hasDecimalPlaces = (0, _model.isUnitWithDecimalPlaces)(value);
|
|
40
63
|
const hasAbbreviate = (0, _model.isUnitWithAbbreviate)(value);
|
|
@@ -43,11 +66,11 @@ function UnitSelector({ value , onChange }) {
|
|
|
43
66
|
kind: newValue.id
|
|
44
67
|
});
|
|
45
68
|
};
|
|
46
|
-
const
|
|
69
|
+
const handleDecimalPlacesChange = (_, { decimal_places })=>{
|
|
47
70
|
if (hasDecimalPlaces) {
|
|
48
71
|
onChange({
|
|
49
72
|
...value,
|
|
50
|
-
decimal_places:
|
|
73
|
+
decimal_places: decimal_places
|
|
51
74
|
});
|
|
52
75
|
}
|
|
53
76
|
};
|
|
@@ -60,19 +83,18 @@ function UnitSelector({ value , onChange }) {
|
|
|
60
83
|
}
|
|
61
84
|
};
|
|
62
85
|
const kindConfig = _model.UNIT_CONFIG[value.kind];
|
|
63
|
-
var _decimal_places;
|
|
64
86
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
65
87
|
children: [
|
|
66
88
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_optionsEditorLayout.OptionsEditorControl, {
|
|
67
89
|
label: "Abbreviate",
|
|
68
90
|
control: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Switch, {
|
|
69
|
-
checked: hasAbbreviate ?
|
|
91
|
+
checked: hasAbbreviate ? (0, _utils.shouldAbbreviate)(value.abbreviate) : false,
|
|
70
92
|
onChange: handleAbbreviateChange,
|
|
71
93
|
disabled: !hasAbbreviate
|
|
72
94
|
})
|
|
73
95
|
}),
|
|
74
96
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_optionsEditorLayout.OptionsEditorControl, {
|
|
75
|
-
label: "
|
|
97
|
+
label: "Unit",
|
|
76
98
|
control: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Autocomplete, {
|
|
77
99
|
value: {
|
|
78
100
|
id: value.kind,
|
|
@@ -100,15 +122,16 @@ function UnitSelector({ value , onChange }) {
|
|
|
100
122
|
})
|
|
101
123
|
}),
|
|
102
124
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_optionsEditorLayout.OptionsEditorControl, {
|
|
103
|
-
label: "
|
|
125
|
+
label: "Decimals",
|
|
104
126
|
control: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Autocomplete, {
|
|
105
|
-
value:
|
|
106
|
-
options:
|
|
107
|
-
getOptionLabel: (
|
|
127
|
+
value: getOptionByDecimalPlaces(value.decimal_places),
|
|
128
|
+
options: DECIMAL_PLACES_OPTIONS,
|
|
129
|
+
getOptionLabel: (o)=>o.label,
|
|
130
|
+
isOptionEqualToValue: (option, value)=>option.label === value.label,
|
|
108
131
|
renderInput: (params)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
109
132
|
...params
|
|
110
133
|
}),
|
|
111
|
-
onChange:
|
|
134
|
+
onChange: handleDecimalPlacesChange,
|
|
112
135
|
disabled: !hasDecimalPlaces,
|
|
113
136
|
disableClearable: true
|
|
114
137
|
})
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
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
|
+
SnackbarProvider: ()=>_notistack.SnackbarProvider,
|
|
25
|
+
useSnackbar: ()=>useSnackbar
|
|
26
|
+
});
|
|
27
|
+
const _react = require("react");
|
|
28
|
+
const _notistack = require("notistack");
|
|
29
|
+
function useSnackbar() {
|
|
30
|
+
const { enqueueSnackbar , closeSnackbar } = (0, _notistack.useSnackbar)();
|
|
31
|
+
// Create variant-specific callbacks
|
|
32
|
+
const errorSnackbar = useEnqueueFunction(enqueueSnackbar, 'error');
|
|
33
|
+
const infoSnackbar = useEnqueueFunction(enqueueSnackbar, 'info');
|
|
34
|
+
const warningSnackbar = useEnqueueFunction(enqueueSnackbar, 'warning');
|
|
35
|
+
const successSnackbar = useEnqueueFunction(enqueueSnackbar, 'success');
|
|
36
|
+
const exceptionSnackbar = (0, _react.useCallback)((error, options)=>{
|
|
37
|
+
// Try to use message prop, but fallback to a default message that
|
|
38
|
+
// will just stringify the error provided
|
|
39
|
+
const message = error instanceof Error ? error.message : `An unexpected error occurred: ${error}`;
|
|
40
|
+
return errorSnackbar(message, options);
|
|
41
|
+
}, [
|
|
42
|
+
errorSnackbar
|
|
43
|
+
]);
|
|
44
|
+
return {
|
|
45
|
+
enqueueSnackbar,
|
|
46
|
+
closeSnackbar,
|
|
47
|
+
errorSnackbar,
|
|
48
|
+
infoSnackbar,
|
|
49
|
+
warningSnackbar,
|
|
50
|
+
successSnackbar,
|
|
51
|
+
exceptionSnackbar
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
// Helper to create a variant-specific enqueue function
|
|
55
|
+
function useEnqueueFunction(enqueueSnackbar, variant) {
|
|
56
|
+
return (0, _react.useCallback)((message, options)=>{
|
|
57
|
+
const allOptions = {
|
|
58
|
+
...options,
|
|
59
|
+
variant
|
|
60
|
+
};
|
|
61
|
+
return enqueueSnackbar(message, allOptions);
|
|
62
|
+
}, [
|
|
63
|
+
enqueueSnackbar,
|
|
64
|
+
variant
|
|
65
|
+
]);
|
|
66
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -29,12 +29,14 @@ _exportStar(require("./LegendOptionsEditor"), exports);
|
|
|
29
29
|
_exportStar(require("./LineChart"), exports);
|
|
30
30
|
_exportStar(require("./OptionsEditorLayout"), exports);
|
|
31
31
|
_exportStar(require("./StatChart"), exports);
|
|
32
|
+
_exportStar(require("./Table"), exports);
|
|
32
33
|
_exportStar(require("./ThresholdsEditor"), exports);
|
|
33
34
|
_exportStar(require("./TimeSeriesTooltip"), exports);
|
|
34
35
|
_exportStar(require("./UnitSelector"), exports);
|
|
35
36
|
_exportStar(require("./YAxisLabel"), exports);
|
|
36
37
|
_exportStar(require("./context/ChartsThemeProvider"), exports);
|
|
37
38
|
_exportStar(require("./context/TimeZoneProvider"), exports);
|
|
39
|
+
_exportStar(require("./context/SnackbarProvider"), exports);
|
|
38
40
|
_exportStar(require("./utils"), exports);
|
|
39
41
|
_exportStar(require("./model"), exports);
|
|
40
42
|
_exportStar(require("./test-utils"), exports);
|
package/dist/cjs/model/legend.js
CHANGED
|
@@ -26,7 +26,8 @@ _export(exports, {
|
|
|
26
26
|
DEFAULT_LEGEND: ()=>DEFAULT_LEGEND,
|
|
27
27
|
getLegendPosition: ()=>getLegendPosition,
|
|
28
28
|
isValidLegendPosition: ()=>isValidLegendPosition,
|
|
29
|
-
validateLegendSpec: ()=>validateLegendSpec
|
|
29
|
+
validateLegendSpec: ()=>validateLegendSpec,
|
|
30
|
+
isLegendItemVisuallySelected: ()=>isLegendItemVisuallySelected
|
|
30
31
|
});
|
|
31
32
|
const legendPositions = [
|
|
32
33
|
'Bottom',
|
|
@@ -65,3 +66,8 @@ function validateLegendSpec(legend) {
|
|
|
65
66
|
}
|
|
66
67
|
return true;
|
|
67
68
|
}
|
|
69
|
+
function isLegendItemVisuallySelected(item, selectedItems) {
|
|
70
|
+
// In the "ALL" case, technically all legend items are selected, but we do
|
|
71
|
+
// not render them differently.
|
|
72
|
+
return selectedItems !== 'ALL' && !!selectedItems[item.id];
|
|
73
|
+
}
|