@perses-dev/components 0.50.1 → 0.51.0-beta.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/ColorPicker/ColorPicker.js +2 -2
- package/dist/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.js +2 -3
- package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
- package/dist/DragAndDrop/DragButton.d.ts +2 -2
- package/dist/DragAndDrop/DragButton.d.ts.map +1 -1
- package/dist/DragAndDrop/DragButton.js +6 -4
- package/dist/DragAndDrop/DragButton.js.map +1 -1
- package/dist/Drawer/Drawer.js +1 -1
- package/dist/Drawer/Drawer.js.map +1 -1
- package/dist/EChart/EChart.js +3 -4
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/GaugeChart/GaugeChart.js +2 -5
- package/dist/GaugeChart/GaugeChart.js.map +1 -1
- package/dist/InfoTooltip/InfoTooltip.js +5 -4
- package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
- package/dist/Legend/ListLegendItem.js +3 -4
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/LineChart/LineChart.js +4 -8
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/LinksEditor/LinksEditor.js +9 -18
- package/dist/LinksEditor/LinksEditor.js.map +1 -1
- package/dist/Overlay/Overlay.js +1 -1
- package/dist/Overlay/Overlay.js.map +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js +1 -2
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
- package/dist/StatChart/StatChart.js +3 -5
- package/dist/StatChart/StatChart.js.map +1 -1
- package/dist/StatChart/calculateFontSize.js +2 -4
- package/dist/StatChart/calculateFontSize.js.map +1 -1
- package/dist/StatusHistoryChart/StatusHistoryChart.js +1 -2
- package/dist/StatusHistoryChart/StatusHistoryChart.js.map +1 -1
- package/dist/Table/Table.js +5 -5
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableCell.js +5 -6
- package/dist/Table/TableCell.js.map +1 -1
- package/dist/Table/VirtualizedTable.js +11 -14
- package/dist/Table/VirtualizedTable.js.map +1 -1
- package/dist/Table/hooks/useTableKeyboardNav.js +1 -1
- package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -1
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +7 -13
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -1
- package/dist/Table/model/table-model.js +1 -1
- package/dist/Table/model/table-model.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js +15 -23
- package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
- package/dist/TimeChart/TimeChart.js +3 -6
- package/dist/TimeChart/TimeChart.js.map +1 -1
- package/dist/TimeSeriesTooltip/LineChartTooltip.js +6 -11
- package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js +1 -2
- package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js +2 -3
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js +4 -10
- package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.js +13 -23
- package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
- package/dist/TimeSeriesTooltip/utils.js +2 -4
- package/dist/TimeSeriesTooltip/utils.js.map +1 -1
- package/dist/TransformsEditor/TransformEditor.js +4 -7
- package/dist/TransformsEditor/TransformEditor.js.map +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.js +3 -5
- package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
- package/dist/TransformsEditor/TransformsEditor.js +3 -6
- package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.js +11 -24
- package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
- package/dist/cjs/ColorPicker/ColorPicker.js +2 -2
- package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +2 -3
- package/dist/cjs/DragAndDrop/DragButton.js +5 -3
- package/dist/cjs/Drawer/Drawer.js +1 -1
- package/dist/cjs/EChart/EChart.js +3 -4
- package/dist/cjs/GaugeChart/GaugeChart.js +2 -5
- package/dist/cjs/InfoTooltip/InfoTooltip.js +5 -4
- package/dist/cjs/Legend/ListLegendItem.js +3 -4
- package/dist/cjs/LineChart/LineChart.js +4 -8
- package/dist/cjs/LinksEditor/LinksEditor.js +9 -18
- package/dist/cjs/Overlay/Overlay.js +1 -1
- package/dist/cjs/SettingsAutocomplete/SettingsAutocomplete.js +1 -2
- package/dist/cjs/StatChart/StatChart.js +3 -5
- package/dist/cjs/StatChart/calculateFontSize.js +2 -4
- package/dist/cjs/StatusHistoryChart/StatusHistoryChart.js +1 -2
- package/dist/cjs/Table/Table.js +5 -5
- package/dist/cjs/Table/TableCell.js +5 -6
- package/dist/cjs/Table/VirtualizedTable.js +11 -14
- package/dist/cjs/Table/hooks/useTableKeyboardNav.js +1 -1
- package/dist/cjs/Table/hooks/useVirtualizedTableKeyboardNav.js +7 -13
- package/dist/cjs/Table/model/table-model.js +1 -1
- package/dist/cjs/ThresholdsEditor/ThresholdsEditor.js +15 -23
- package/dist/cjs/TimeChart/TimeChart.js +3 -6
- package/dist/cjs/TimeSeriesTooltip/LineChartTooltip.js +6 -11
- package/dist/cjs/TimeSeriesTooltip/SeriesInfo.js +1 -2
- package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +2 -3
- package/dist/cjs/TimeSeriesTooltip/TooltipHeader.js +4 -10
- package/dist/cjs/TimeSeriesTooltip/nearby-series.js +13 -23
- package/dist/cjs/TimeSeriesTooltip/utils.js +2 -4
- package/dist/cjs/TransformsEditor/TransformEditor.js +4 -7
- package/dist/cjs/TransformsEditor/TransformEditorContainer.js +3 -5
- package/dist/cjs/TransformsEditor/TransformsEditor.js +3 -6
- package/dist/cjs/ValueMappingEditor/ValueMappingEditor.js +11 -24
- package/dist/cjs/context/TimeZoneProvider.js +1 -1
- package/dist/cjs/controls/TextField.js +1 -1
- package/dist/cjs/utils/chart-actions.js +1 -2
- package/dist/cjs/utils/format.js +1 -1
- package/dist/cjs/utils/theme-gen.js +5 -7
- package/dist/context/TimeZoneProvider.js +1 -1
- package/dist/context/TimeZoneProvider.js.map +1 -1
- package/dist/controls/TextField.js +1 -1
- package/dist/controls/TextField.js.map +1 -1
- package/dist/utils/chart-actions.js +1 -2
- package/dist/utils/chart-actions.js.map +1 -1
- package/dist/utils/format.js +1 -1
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/theme-gen.js +5 -7
- package/dist/utils/theme-gen.js.map +1 -1
- package/package.json +3 -3
package/dist/cjs/Table/Table.js
CHANGED
|
@@ -39,7 +39,7 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
|
|
|
39
39
|
const theme = (0, _material.useTheme)();
|
|
40
40
|
const handleRowSelectionChange = (rowSelectionUpdater)=>{
|
|
41
41
|
const newRowSelection = typeof rowSelectionUpdater === 'function' ? rowSelectionUpdater(rowSelection) : rowSelectionUpdater;
|
|
42
|
-
onRowSelectionChange
|
|
42
|
+
onRowSelectionChange?.(newRowSelection);
|
|
43
43
|
};
|
|
44
44
|
const handleRowSelectionEvent = (0, _react.useCallback)((table, row, isModified)=>{
|
|
45
45
|
if (rowSelectionVariant === 'standard' || isModified) {
|
|
@@ -53,7 +53,7 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
|
|
|
53
53
|
table.toggleAllRowsSelected();
|
|
54
54
|
} else {
|
|
55
55
|
// Focus the selected row.
|
|
56
|
-
onRowSelectionChange
|
|
56
|
+
onRowSelectionChange?.({
|
|
57
57
|
[row.id]: true
|
|
58
58
|
});
|
|
59
59
|
}
|
|
@@ -64,14 +64,14 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
|
|
|
64
64
|
]);
|
|
65
65
|
const handleCheckboxChange = (0, _react.useCallback)((e, table, row)=>{
|
|
66
66
|
const nativePointerEvent = e.nativeEvent && (e.nativeEvent instanceof MouseEvent || e.nativeEvent instanceof KeyboardEvent) ? e.nativeEvent : undefined;
|
|
67
|
-
const isModifed = !!
|
|
67
|
+
const isModifed = !!nativePointerEvent?.metaKey || !!nativePointerEvent?.shiftKey;
|
|
68
68
|
handleRowSelectionEvent(table, row, isModifed);
|
|
69
69
|
}, [
|
|
70
70
|
handleRowSelectionEvent
|
|
71
71
|
]);
|
|
72
72
|
const handleSortingChange = (sortingUpdater)=>{
|
|
73
73
|
const newSorting = typeof sortingUpdater === 'function' ? sortingUpdater(sorting) : sortingUpdater;
|
|
74
|
-
onSortingChange
|
|
74
|
+
onSortingChange?.(newSorting);
|
|
75
75
|
};
|
|
76
76
|
const checkboxColumn = (0, _react.useMemo)(()=>{
|
|
77
77
|
return {
|
|
@@ -93,7 +93,7 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
|
|
|
93
93
|
onChange: (e)=>{
|
|
94
94
|
handleCheckboxChange(e, table, row);
|
|
95
95
|
},
|
|
96
|
-
color: getCheckboxColor
|
|
96
|
+
color: getCheckboxColor?.(row.original),
|
|
97
97
|
density: density
|
|
98
98
|
});
|
|
99
99
|
},
|
|
@@ -51,9 +51,8 @@ function TableCell({ children, density, variant, width, focusState = 'none', onF
|
|
|
51
51
|
focusState
|
|
52
52
|
]);
|
|
53
53
|
const handleFocus = (e)=>{
|
|
54
|
-
var _e_currentTarget;
|
|
55
54
|
// From https://zellwk.com/blog/keyboard-focusable-elements/
|
|
56
|
-
const nestedFocusTarget =
|
|
55
|
+
const nestedFocusTarget = e.currentTarget?.querySelector('a[href], button, input, textarea, select, details,[role="button"]');
|
|
57
56
|
if (nestedFocusTarget) {
|
|
58
57
|
// If the cell has a focusable child, focus it instead. Mostly used for
|
|
59
58
|
// checkbox cells, but could have other uses.
|
|
@@ -66,7 +65,7 @@ function TableCell({ children, density, variant, width, focusState = 'none', onF
|
|
|
66
65
|
// plays with the triggering of focus with keyboard interactions.
|
|
67
66
|
// These report that a focus event happened, so we can adjust the current
|
|
68
67
|
// tabindex and focuses to the right cell.
|
|
69
|
-
onFocusTrigger
|
|
68
|
+
onFocusTrigger?.(e);
|
|
70
69
|
};
|
|
71
70
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(StyledMuiTableCell, {
|
|
72
71
|
...otherProps,
|
|
@@ -93,7 +92,7 @@ function TableCell({ children, density, variant, width, focusState = 'none', onF
|
|
|
93
92
|
minWidth: '100%',
|
|
94
93
|
whiteSpace: 'nowrap',
|
|
95
94
|
overflow: 'visible',
|
|
96
|
-
backgroundColor: `${backgroundColor
|
|
95
|
+
backgroundColor: `${backgroundColor ?? theme.palette.background.default} !important`,
|
|
97
96
|
outline: `solid 1px ${theme.palette.info.main}`,
|
|
98
97
|
outlineOffset: '-1px'
|
|
99
98
|
}
|
|
@@ -118,8 +117,8 @@ function TableCell({ children, density, variant, width, focusState = 'none', onF
|
|
|
118
117
|
flexDirection: 'inherit'
|
|
119
118
|
},
|
|
120
119
|
style: {
|
|
121
|
-
backgroundColor: backgroundColor
|
|
122
|
-
color: color
|
|
120
|
+
backgroundColor: backgroundColor ?? 'inherit',
|
|
121
|
+
color: color ?? 'inherit'
|
|
123
122
|
},
|
|
124
123
|
title: description,
|
|
125
124
|
"aria-label": description,
|
|
@@ -86,10 +86,10 @@ function VirtualizedTable({ width, height, density, defaultColumnWidth, onRowCli
|
|
|
86
86
|
onClick: (e)=>onRowClick(e, row.id),
|
|
87
87
|
density: density,
|
|
88
88
|
onMouseOver: (e)=>{
|
|
89
|
-
onRowMouseOver
|
|
89
|
+
onRowMouseOver?.(e, rowEventOpts);
|
|
90
90
|
},
|
|
91
91
|
onMouseOut: (e)=>{
|
|
92
|
-
onRowMouseOut
|
|
92
|
+
onRowMouseOut?.(e, rowEventOpts);
|
|
93
93
|
}
|
|
94
94
|
});
|
|
95
95
|
},
|
|
@@ -123,7 +123,6 @@ function VirtualizedTable({ width, height, density, defaultColumnWidth, onRowCli
|
|
|
123
123
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_TableRow.TableRow, {
|
|
124
124
|
density: density,
|
|
125
125
|
children: headerGroup.headers.map((header, i, headers)=>{
|
|
126
|
-
var _column_columnDef_meta, _column_columnDef_meta1;
|
|
127
126
|
const column = header.column;
|
|
128
127
|
const position = {
|
|
129
128
|
row: 0,
|
|
@@ -136,10 +135,10 @@ function VirtualizedTable({ width, height, density, defaultColumnWidth, onRowCli
|
|
|
136
135
|
sortDirection: typeof isSorted === 'string' ? isSorted : undefined,
|
|
137
136
|
nextSortDirection: typeof nextSorting === 'string' ? nextSorting : undefined,
|
|
138
137
|
width: column.getSize() || defaultColumnWidth,
|
|
139
|
-
align:
|
|
138
|
+
align: column.columnDef.meta?.align,
|
|
140
139
|
variant: "head",
|
|
141
140
|
density: density,
|
|
142
|
-
description:
|
|
141
|
+
description: column.columnDef.meta?.headerDescription,
|
|
143
142
|
focusState: getFocusState(position),
|
|
144
143
|
onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
|
|
145
144
|
isFirstColumn: i === 0,
|
|
@@ -158,17 +157,16 @@ function VirtualizedTable({ width, height, density, defaultColumnWidth, onRowCli
|
|
|
158
157
|
}
|
|
159
158
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
|
|
160
159
|
children: row.getVisibleCells().map((cell, i, cells)=>{
|
|
161
|
-
var _cell_column_columnDef_meta, _cell_column_columnDef_meta1;
|
|
162
160
|
const position = {
|
|
163
161
|
// Add 1 to the row index because the header is row 0
|
|
164
162
|
row: index + 1,
|
|
165
163
|
column: i
|
|
166
164
|
};
|
|
167
165
|
const cellContext = cell.getContext();
|
|
168
|
-
const cellConfig = cellConfigs
|
|
166
|
+
const cellConfig = cellConfigs?.[cellContext.cell.id];
|
|
169
167
|
const cellRenderFn = cell.column.columnDef.cell;
|
|
170
168
|
const cellContent = typeof cellRenderFn === 'function' ? cellRenderFn(cellContext) : null;
|
|
171
|
-
const cellDescriptionDef =
|
|
169
|
+
const cellDescriptionDef = cell.column.columnDef.meta?.cellDescription;
|
|
172
170
|
let description = undefined;
|
|
173
171
|
if (typeof cellDescriptionDef === 'function') {
|
|
174
172
|
// If the cell description is a function, set the value using
|
|
@@ -180,21 +178,20 @@ function VirtualizedTable({ width, height, density, defaultColumnWidth, onRowCli
|
|
|
180
178
|
// cell content.
|
|
181
179
|
description = cellContent;
|
|
182
180
|
}
|
|
183
|
-
var _cellConfig_textColor, _cellConfig_backgroundColor;
|
|
184
181
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_TableCell.TableCell, {
|
|
185
182
|
"data-testid": cell.id,
|
|
186
|
-
title: description ||
|
|
183
|
+
title: description || cellConfig?.text || cellContent,
|
|
187
184
|
width: cell.column.getSize() || defaultColumnWidth,
|
|
188
|
-
align:
|
|
185
|
+
align: cell.column.columnDef.meta?.align,
|
|
189
186
|
density: density,
|
|
190
187
|
focusState: getFocusState(position),
|
|
191
188
|
onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
|
|
192
189
|
isFirstColumn: i === 0,
|
|
193
190
|
isLastColumn: i === cells.length - 1,
|
|
194
191
|
description: description,
|
|
195
|
-
color:
|
|
196
|
-
backgroundColor:
|
|
197
|
-
children:
|
|
192
|
+
color: cellConfig?.textColor ?? undefined,
|
|
193
|
+
backgroundColor: cellConfig?.backgroundColor ?? undefined,
|
|
194
|
+
children: cellConfig?.text || cellContent
|
|
198
195
|
}, cell.id);
|
|
199
196
|
})
|
|
200
197
|
});
|
|
@@ -78,7 +78,7 @@ function useTableKeyboardNav({ maxRows, maxColumns, onActiveCellChange }) {
|
|
|
78
78
|
column: nextColumn,
|
|
79
79
|
row: nextRow
|
|
80
80
|
};
|
|
81
|
-
const newPosition =
|
|
81
|
+
const newPosition = onActiveCellChange?.(e, curActiveCell, defaultNewPosition) || defaultNewPosition;
|
|
82
82
|
if (newPosition.row === curActiveCell.row && newPosition.column === curActiveCell.column) {
|
|
83
83
|
// Return original to avoid creating a new object if nothing
|
|
84
84
|
// changed.
|
|
@@ -28,14 +28,12 @@ function useVirtualizedTableKeyboardNav({ visibleRange, virtualTable, maxRows, m
|
|
|
28
28
|
onActiveCellChange: (e, currentPosition, defaultNewPosition)=>{
|
|
29
29
|
const key = e.key;
|
|
30
30
|
const defaultValueChanged = defaultNewPosition && (currentPosition.column !== defaultNewPosition.column || currentPosition.row !== defaultNewPosition.row);
|
|
31
|
-
|
|
32
|
-
const nextRow = (_defaultNewPosition_row = defaultNewPosition === null || defaultNewPosition === void 0 ? void 0 : defaultNewPosition.row) !== null && _defaultNewPosition_row !== void 0 ? _defaultNewPosition_row : currentPosition.row;
|
|
31
|
+
const nextRow = defaultNewPosition?.row ?? currentPosition.row;
|
|
33
32
|
if (key === 'ArrowDown' && defaultValueChanged) {
|
|
34
33
|
// Use default cell position. Shift the virtual table scroll position
|
|
35
34
|
// when needed to make the active cell visible.
|
|
36
35
|
if (nextRow - 1 < visibleRange.current.startIndex || nextRow - 1 > visibleRange.current.endIndex) {
|
|
37
|
-
|
|
38
|
-
(_virtualTable_current = virtualTable.current) === null || _virtualTable_current === void 0 ? void 0 : _virtualTable_current.scrollToIndex({
|
|
36
|
+
virtualTable.current?.scrollToIndex({
|
|
39
37
|
index: nextRow - 1,
|
|
40
38
|
align: 'end'
|
|
41
39
|
});
|
|
@@ -44,28 +42,25 @@ function useVirtualizedTableKeyboardNav({ visibleRange, virtualTable, maxRows, m
|
|
|
44
42
|
// Use default cell position. Shift the virtual table scroll position
|
|
45
43
|
// when needed to make the active cell visible.
|
|
46
44
|
if (nextRow - 1 < visibleRange.current.startIndex || nextRow - 1 > visibleRange.current.endIndex) {
|
|
47
|
-
|
|
48
|
-
(_virtualTable_current1 = virtualTable.current) === null || _virtualTable_current1 === void 0 ? void 0 : _virtualTable_current1.scrollToIndex({
|
|
45
|
+
virtualTable.current?.scrollToIndex({
|
|
49
46
|
index: nextRow - 1,
|
|
50
47
|
align: 'start'
|
|
51
48
|
});
|
|
52
49
|
}
|
|
53
50
|
} else if (defaultValueChanged && (key === 'Home' || key === 'End')) {
|
|
54
|
-
|
|
51
|
+
// Use default cell position. Shift the virtual table scroll position
|
|
55
52
|
// when needed to make the active cell visible.
|
|
56
|
-
|
|
57
|
-
(_virtualTable_current2 = virtualTable.current) === null || _virtualTable_current2 === void 0 ? void 0 : _virtualTable_current2.scrollToIndex({
|
|
53
|
+
virtualTable.current?.scrollToIndex({
|
|
58
54
|
index: Math.max(nextRow - 1, 0),
|
|
59
55
|
align: 'start'
|
|
60
56
|
});
|
|
61
57
|
} else if (key === 'PageDown') {
|
|
62
|
-
var _virtualTable_current3;
|
|
63
58
|
// Full handling of logic for `PageDown` because there is no default.
|
|
64
59
|
e.preventDefault();
|
|
65
60
|
let nextRow = currentPosition.row;
|
|
66
61
|
// Add 1 to account for header
|
|
67
62
|
nextRow = Math.min(maxRows - 1, visibleRange.current.endIndex + 1);
|
|
68
|
-
|
|
63
|
+
virtualTable.current?.scrollToIndex({
|
|
69
64
|
index: nextRow - 1,
|
|
70
65
|
align: 'start'
|
|
71
66
|
});
|
|
@@ -74,12 +69,11 @@ function useVirtualizedTableKeyboardNav({ visibleRange, virtualTable, maxRows, m
|
|
|
74
69
|
column: currentPosition.column
|
|
75
70
|
};
|
|
76
71
|
} else if (key === 'PageUp') {
|
|
77
|
-
var _virtualTable_current4;
|
|
78
72
|
// Full handling of logic for `PageUp` because there is no default.
|
|
79
73
|
let nextRow = currentPosition.row;
|
|
80
74
|
// Minus 1 to account for header
|
|
81
75
|
nextRow = Math.max(0, visibleRange.current.startIndex - 1);
|
|
82
|
-
|
|
76
|
+
virtualTable.current?.scrollToIndex({
|
|
83
77
|
index: nextRow - 1,
|
|
84
78
|
align: 'end'
|
|
85
79
|
});
|
|
@@ -35,7 +35,7 @@ const DEFAULT_COLUMN_WIDTH = 150;
|
|
|
35
35
|
function calculateTableCellHeight(lineHeight, paddingY) {
|
|
36
36
|
// Doing a bunch of math to enforce height to avoid weirdness with mismatched
|
|
37
37
|
// heights based on customization of cell contents.
|
|
38
|
-
const lineHeightNum = typeof lineHeight === 'string' ? parseInt(lineHeight, 10) : lineHeight
|
|
38
|
+
const lineHeightNum = typeof lineHeight === 'string' ? parseInt(lineHeight, 10) : lineHeight ?? 0;
|
|
39
39
|
const verticalPaddingNum = typeof paddingY === 'string' ? parseInt(paddingY, 10) : paddingY;
|
|
40
40
|
return lineHeightNum + verticalPaddingNum * 2;
|
|
41
41
|
}
|
|
@@ -81,28 +81,26 @@ const DEFAULT_STEP = 10;
|
|
|
81
81
|
function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMode }) {
|
|
82
82
|
const chartsTheme = (0, _ChartsProvider.useChartsTheme)();
|
|
83
83
|
const { thresholds: { defaultColor, palette } } = chartsTheme;
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
const [steps, setSteps] = (0, _react.useState)(thresholds === null || thresholds === void 0 ? void 0 : thresholds.steps);
|
|
84
|
+
const defaultThresholdColor = thresholds?.defaultColor ?? defaultColor;
|
|
85
|
+
const [steps, setSteps] = (0, _react.useState)(thresholds?.steps);
|
|
87
86
|
(0, _react.useEffect)(()=>{
|
|
88
|
-
setSteps(thresholds
|
|
87
|
+
setSteps(thresholds?.steps);
|
|
89
88
|
}, [
|
|
90
|
-
thresholds
|
|
89
|
+
thresholds?.steps
|
|
91
90
|
]);
|
|
92
91
|
// every time a new threshold is added, we want to focus the recently added input
|
|
93
92
|
const recentlyAddedInputRef = (0, _react.useRef)(null);
|
|
94
93
|
const focusRef = (0, _react.useRef)(false);
|
|
95
94
|
(0, _react.useEffect)(()=>{
|
|
96
|
-
var _recentlyAddedInputRef_current;
|
|
97
95
|
if (!recentlyAddedInputRef.current || !focusRef.current) return;
|
|
98
|
-
|
|
96
|
+
recentlyAddedInputRef.current?.focus();
|
|
99
97
|
focusRef.current = false;
|
|
100
98
|
}, [
|
|
101
|
-
steps
|
|
99
|
+
steps?.length
|
|
102
100
|
]);
|
|
103
101
|
const handleThresholdValueChange = (e, i)=>{
|
|
104
102
|
setSteps((0, _immer.default)(steps, (draft)=>{
|
|
105
|
-
const step = draft
|
|
103
|
+
const step = draft?.[i];
|
|
106
104
|
if (step) {
|
|
107
105
|
step.value = Number(e.target.value);
|
|
108
106
|
}
|
|
@@ -176,14 +174,12 @@ function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMod
|
|
|
176
174
|
} else {
|
|
177
175
|
onChange((0, _immer.default)(thresholds, (draft)=>{
|
|
178
176
|
const steps = draft.steps;
|
|
179
|
-
if (steps
|
|
177
|
+
if (steps?.length) {
|
|
180
178
|
const lastStep = steps[steps.length - 1];
|
|
181
|
-
|
|
182
|
-
const color = (_palette_steps_length = palette[steps.length]) !== null && _palette_steps_length !== void 0 ? _palette_steps_length : getRandomColor(); // we will assign color from the palette first, then generate random color
|
|
183
|
-
var _lastStep_value;
|
|
179
|
+
const color = palette[steps.length] ?? getRandomColor(); // we will assign color from the palette first, then generate random color
|
|
184
180
|
steps.push({
|
|
185
181
|
color,
|
|
186
|
-
value: (
|
|
182
|
+
value: (lastStep?.value ?? 0) + DEFAULT_STEP
|
|
187
183
|
}); // set new threshold value to last step value + 10
|
|
188
184
|
} else if (steps) {
|
|
189
185
|
steps.push({
|
|
@@ -205,7 +201,6 @@ function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMod
|
|
|
205
201
|
});
|
|
206
202
|
}
|
|
207
203
|
};
|
|
208
|
-
var _thresholds_mode;
|
|
209
204
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_OptionsEditorLayout.OptionsEditorGroup, {
|
|
210
205
|
title: "Thresholds",
|
|
211
206
|
icon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_InfoTooltip.InfoTooltip, {
|
|
@@ -224,7 +219,7 @@ function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMod
|
|
|
224
219
|
control: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.ToggleButtonGroup, {
|
|
225
220
|
exclusive: true,
|
|
226
221
|
disabled: disablePercentMode,
|
|
227
|
-
value:
|
|
222
|
+
value: thresholds?.mode ?? 'absolute',
|
|
228
223
|
onChange: handleModeChange,
|
|
229
224
|
sx: {
|
|
230
225
|
height: '36px',
|
|
@@ -250,14 +245,12 @@ function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMod
|
|
|
250
245
|
]
|
|
251
246
|
})
|
|
252
247
|
}),
|
|
253
|
-
steps && steps.map((step, i)
|
|
254
|
-
var _step_color, _ref;
|
|
255
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_ThresholdInput.ThresholdInput, {
|
|
248
|
+
steps && steps.map((step, i)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_ThresholdInput.ThresholdInput, {
|
|
256
249
|
inputRef: i === steps.length - 1 ? recentlyAddedInputRef : undefined,
|
|
257
250
|
label: `T${i + 1}`,
|
|
258
|
-
color:
|
|
251
|
+
color: step.color ?? palette[i] ?? defaultThresholdColor,
|
|
259
252
|
value: step.value,
|
|
260
|
-
mode: thresholds
|
|
253
|
+
mode: thresholds?.mode,
|
|
261
254
|
onColorChange: (color)=>handleThresholdColorChange(color, i),
|
|
262
255
|
onChange: (e)=>{
|
|
263
256
|
handleThresholdValueChange(e, i);
|
|
@@ -266,8 +259,7 @@ function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMod
|
|
|
266
259
|
deleteThreshold(i);
|
|
267
260
|
},
|
|
268
261
|
onBlur: handleThresholdBlur
|
|
269
|
-
}, i)
|
|
270
|
-
}).reverse(),
|
|
262
|
+
}, i)).reverse(),
|
|
271
263
|
!hideDefault && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_system.Stack, {
|
|
272
264
|
flex: 1,
|
|
273
265
|
direction: "row",
|
|
@@ -57,7 +57,6 @@ function _interop_require_default(obj) {
|
|
|
57
57
|
_renderers.CanvasRenderer
|
|
58
58
|
]);
|
|
59
59
|
const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ height, data, seriesMapping, timeScale: timeScaleProp, yAxis, format, grid, isStackedBar = false, tooltipConfig = _TimeSeriesTooltip.DEFAULT_TOOLTIP_CONFIG, noDataVariant = 'message', syncGroup, onDataZoom, onDoubleClick, __experimentalEChartsOptionsOverride }, ref) {
|
|
60
|
-
var _option_tooltip;
|
|
61
60
|
const { chartsTheme, enablePinning, lastTooltipPinnedCoords, setLastTooltipPinnedCoords } = (0, _ChartsProvider.useChartsContext)();
|
|
62
61
|
const isPinningEnabled = tooltipConfig.enablePinning && enablePinning;
|
|
63
62
|
const chartRef = (0, _react.useRef)();
|
|
@@ -172,7 +171,6 @@ const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ heig
|
|
|
172
171
|
...seriesMapping,
|
|
173
172
|
pinnedCrosshair
|
|
174
173
|
] : seriesMapping;
|
|
175
|
-
var _timeScale_rangeMs;
|
|
176
174
|
const option = {
|
|
177
175
|
dataset: dataset,
|
|
178
176
|
series: updatedSeriesMapping,
|
|
@@ -182,7 +180,7 @@ const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ heig
|
|
|
182
180
|
max: isLocalTimeZone ? timeScale.endMs : (0, _datefnstz.utcToZonedTime)(timeScale.endMs, timeZone),
|
|
183
181
|
axisLabel: {
|
|
184
182
|
hideOverlap: true,
|
|
185
|
-
formatter: (0, _utils.getFormattedAxisLabel)(
|
|
183
|
+
formatter: (0, _utils.getFormattedAxisLabel)(timeScale.rangeMs ?? 0)
|
|
186
184
|
},
|
|
187
185
|
axisPointer: {
|
|
188
186
|
snap: false
|
|
@@ -302,10 +300,9 @@ const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ heig
|
|
|
302
300
|
setPinnedCrosshair((current)=>{
|
|
303
301
|
// Only add pinned crosshair line series when there is not one already in seriesMapping.
|
|
304
302
|
if (current === null) {
|
|
305
|
-
var _data_;
|
|
306
303
|
const cursorX = pointInGrid[0];
|
|
307
304
|
// Only need to loop through first dataset source since getCommonTimeScale ensures xAxis timestamps are consistent
|
|
308
|
-
const firstTimeSeriesValues =
|
|
305
|
+
const firstTimeSeriesValues = data[0]?.values;
|
|
309
306
|
const closestTimestamp = (0, _utils.getClosestTimestamp)(firstTimeSeriesValues, cursorX);
|
|
310
307
|
// Crosshair snaps to nearest timestamp since cursor may be slightly to left or right
|
|
311
308
|
const pinnedCrosshair = (0, _merge.default)({}, _model.DEFAULT_PINNED_CROSSHAIR, {
|
|
@@ -378,7 +375,7 @@ const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ heig
|
|
|
378
375
|
}
|
|
379
376
|
},
|
|
380
377
|
children: [
|
|
381
|
-
showTooltip === true &&
|
|
378
|
+
showTooltip === true && option.tooltip?.showContent === false && tooltipConfig.hidden !== true && /*#__PURE__*/ (0, _jsxruntime.jsx)(_TimeSeriesTooltip.TimeChartTooltip, {
|
|
382
379
|
containerId: chartsTheme.tooltipPortalContainerId,
|
|
383
380
|
chartRef: chartRef,
|
|
384
381
|
data: data,
|
|
@@ -44,8 +44,7 @@ const LineChartTooltip = /*#__PURE__*/ (0, _react.memo)(function LineChartToolti
|
|
|
44
44
|
// Ensure user is hovering over a chart before checking for nearby series.
|
|
45
45
|
if (pinnedPos === null && mousePos.target.tagName !== 'CANVAS') return null;
|
|
46
46
|
const chart = chartRef.current;
|
|
47
|
-
|
|
48
|
-
const chartWidth = (_chart_getWidth = chart === null || chart === void 0 ? void 0 : chart.getWidth()) !== null && _chart_getWidth !== void 0 ? _chart_getWidth : _tooltipmodel.FALLBACK_CHART_WIDTH; // Fallback width not likely to ever be needed.
|
|
47
|
+
const chartWidth = chart?.getWidth() ?? _tooltipmodel.FALLBACK_CHART_WIDTH; // Fallback width not likely to ever be needed.
|
|
49
48
|
// Get series nearby the cursor and pass into tooltip content children.
|
|
50
49
|
const nearbySeries = (0, _nearbyseries.legacyGetNearbySeriesData)({
|
|
51
50
|
mousePos,
|
|
@@ -63,24 +62,21 @@ const LineChartTooltip = /*#__PURE__*/ (0, _react.memo)(function LineChartToolti
|
|
|
63
62
|
// if tooltip is attached to a container, set max height to the height of the container so tooltip does not get cut off
|
|
64
63
|
const maxHeight = containerElement ? containerElement.getBoundingClientRect().height : undefined;
|
|
65
64
|
if (!isTooltipPinned) {
|
|
66
|
-
transform.current = (0, _utils.assembleTransform)(mousePos, chartWidth, pinnedPos, height
|
|
65
|
+
transform.current = (0, _utils.assembleTransform)(mousePos, chartWidth, pinnedPos, height ?? 0, width ?? 0, containerElement);
|
|
67
66
|
}
|
|
68
67
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Portal, {
|
|
69
68
|
container: containerElement,
|
|
70
69
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
71
70
|
ref: tooltipRef,
|
|
72
|
-
sx: (theme)=>{
|
|
73
|
-
var _theme_palette_designSystem;
|
|
74
|
-
var _theme_palette_designSystem_grey_;
|
|
75
|
-
return {
|
|
71
|
+
sx: (theme)=>({
|
|
76
72
|
minWidth: _tooltipmodel.TOOLTIP_MIN_WIDTH,
|
|
77
73
|
maxWidth: _tooltipmodel.TOOLTIP_MAX_WIDTH,
|
|
78
|
-
maxHeight: maxHeight
|
|
74
|
+
maxHeight: maxHeight ?? _tooltipmodel.TOOLTIP_MAX_HEIGHT,
|
|
79
75
|
padding: 0,
|
|
80
76
|
position: 'absolute',
|
|
81
77
|
top: 0,
|
|
82
78
|
left: 0,
|
|
83
|
-
backgroundColor:
|
|
79
|
+
backgroundColor: theme.palette.designSystem?.grey[800] ?? _tooltipmodel.TOOLTIP_BG_COLOR_FALLBACK,
|
|
84
80
|
borderRadius: '6px',
|
|
85
81
|
color: '#fff',
|
|
86
82
|
fontSize: '11px',
|
|
@@ -93,8 +89,7 @@ const LineChartTooltip = /*#__PURE__*/ (0, _react.memo)(function LineChartToolti
|
|
|
93
89
|
'&:hover': {
|
|
94
90
|
overflowY: 'auto'
|
|
95
91
|
}
|
|
96
|
-
}
|
|
97
|
-
},
|
|
92
|
+
}),
|
|
98
93
|
style: {
|
|
99
94
|
transform: transform.current,
|
|
100
95
|
display: transform.current ? 'block' : 'none'
|
|
@@ -31,8 +31,7 @@ function SeriesInfo(props) {
|
|
|
31
31
|
// ex with metric name: node_load15{env="demo",job="node"}
|
|
32
32
|
// ex without metric name: {env="demo",job="node"}
|
|
33
33
|
const splitName = seriesName.split('{');
|
|
34
|
-
|
|
35
|
-
const seriesLabels = (_splitName_ = splitName[1]) !== null && _splitName_ !== void 0 ? _splitName_ : seriesName;
|
|
34
|
+
const seriesLabels = splitName[1] ?? seriesName;
|
|
36
35
|
// remove curly braces that wrap labels
|
|
37
36
|
const formattedSeriesLabels = seriesLabels.replace(/[{}]/g, '');
|
|
38
37
|
// determine whether to show labels on separate lines
|
|
@@ -44,13 +44,12 @@ const TimeChartTooltip = /*#__PURE__*/ (0, _react.memo)(function TimeChartToolti
|
|
|
44
44
|
// Ensure user is hovering over a chart before checking for nearby series.
|
|
45
45
|
if (pinnedPos === null && mousePos.target.tagName !== 'CANVAS') return null;
|
|
46
46
|
const chart = chartRef.current;
|
|
47
|
-
|
|
48
|
-
const chartWidth = (_chart_getWidth = chart === null || chart === void 0 ? void 0 : chart.getWidth()) !== null && _chart_getWidth !== void 0 ? _chart_getWidth : _tooltipmodel.FALLBACK_CHART_WIDTH; // Fallback width not likely to ever be needed.
|
|
47
|
+
const chartWidth = chart?.getWidth() ?? _tooltipmodel.FALLBACK_CHART_WIDTH; // Fallback width not likely to ever be needed.
|
|
49
48
|
const containerElement = containerId ? document.querySelector(containerId) : undefined;
|
|
50
49
|
// if tooltip is attached to a container, set max height to the height of the container so tooltip does not get cut off
|
|
51
50
|
const maxHeight = containerElement ? containerElement.getBoundingClientRect().height : undefined;
|
|
52
51
|
if (!isTooltipPinned) {
|
|
53
|
-
transform.current = (0, _utils.assembleTransform)(mousePos, chartWidth, pinnedPos, height
|
|
52
|
+
transform.current = (0, _utils.assembleTransform)(mousePos, chartWidth, pinnedPos, height ?? 0, width ?? 0, containerElement);
|
|
54
53
|
}
|
|
55
54
|
// Get series nearby the cursor and pass into tooltip content children.
|
|
56
55
|
const nearbySeries = (0, _nearbyseries.getNearbySeriesData)({
|
|
@@ -33,9 +33,7 @@ function _interop_require_default(obj) {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
const TooltipHeader = /*#__PURE__*/ (0, _react.memo)(function TooltipHeader({ nearbySeries, totalSeries, isTooltipPinned, showAllSeries, enablePinning = true, onShowAllClick, onUnpinClick }) {
|
|
36
|
-
|
|
37
|
-
var _nearbySeries__date;
|
|
38
|
-
const seriesTimeMs = (_nearbySeries__date = (_nearbySeries_ = nearbySeries[0]) === null || _nearbySeries_ === void 0 ? void 0 : _nearbySeries_.date) !== null && _nearbySeries__date !== void 0 ? _nearbySeries__date : null;
|
|
36
|
+
const seriesTimeMs = nearbySeries[0]?.date ?? null;
|
|
39
37
|
if (seriesTimeMs === null) {
|
|
40
38
|
return null;
|
|
41
39
|
}
|
|
@@ -63,19 +61,15 @@ const TooltipHeader = /*#__PURE__*/ (0, _react.memo)(function TooltipHeader({ ne
|
|
|
63
61
|
const showAllSeriesToggle = enablePinning && totalSeries > 5;
|
|
64
62
|
const pinTooltipHelpText = isTooltipPinned ? _tooltipmodel.UNPIN_TOOLTIP_HELP_TEXT : _tooltipmodel.PIN_TOOLTIP_HELP_TEXT;
|
|
65
63
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
66
|
-
sx: (theme)=>{
|
|
67
|
-
var _theme_palette_designSystem;
|
|
68
|
-
var _theme_palette_designSystem_grey_;
|
|
69
|
-
return {
|
|
64
|
+
sx: (theme)=>({
|
|
70
65
|
width: '100%',
|
|
71
66
|
maxWidth: _tooltipmodel.TOOLTIP_MAX_WIDTH,
|
|
72
67
|
padding: theme.spacing(1.5, 2, 0.5, 2),
|
|
73
|
-
backgroundColor:
|
|
68
|
+
backgroundColor: theme.palette.designSystem?.grey[800] ?? _tooltipmodel.TOOLTIP_BG_COLOR_FALLBACK,
|
|
74
69
|
position: 'sticky',
|
|
75
70
|
top: 0,
|
|
76
71
|
left: 0
|
|
77
|
-
}
|
|
78
|
-
},
|
|
72
|
+
}),
|
|
79
73
|
children: [
|
|
80
74
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
81
75
|
sx: {
|
|
@@ -57,12 +57,9 @@ const INCREASE_NEARBY_SERIES_MULTIPLIER = 5.5; // adjusts how many series show i
|
|
|
57
57
|
const DYNAMIC_NEARBY_SERIES_MULTIPLIER = 30; // used for adjustment after series number divisor
|
|
58
58
|
const SHOW_FEWER_SERIES_LIMIT = 5;
|
|
59
59
|
function checkforNearbyTimeSeries(data, seriesMapping, pointInGrid, yBuffer, chart, format) {
|
|
60
|
-
var _data_;
|
|
61
60
|
const currentNearbySeriesData = [];
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
var _pointInGrid_1;
|
|
65
|
-
const cursorY = (_pointInGrid_1 = pointInGrid[1]) !== null && _pointInGrid_1 !== void 0 ? _pointInGrid_1 : null;
|
|
61
|
+
const cursorX = pointInGrid[0] ?? null;
|
|
62
|
+
const cursorY = pointInGrid[1] ?? null;
|
|
66
63
|
if (cursorX === null || cursorY === null) return currentNearbySeriesData;
|
|
67
64
|
if (chart.dispatchAction === undefined) return currentNearbySeriesData;
|
|
68
65
|
if (!Array.isArray(data)) return currentNearbySeriesData;
|
|
@@ -74,7 +71,7 @@ function checkforNearbyTimeSeries(data, seriesMapping, pointInGrid, yBuffer, cha
|
|
|
74
71
|
const totalSeries = data.length;
|
|
75
72
|
const yValueCounts = new Map();
|
|
76
73
|
// Only need to loop through first dataset source since getCommonTimeScale ensures xAxis timestamps are consistent
|
|
77
|
-
const firstTimeSeriesValues =
|
|
74
|
+
const firstTimeSeriesValues = data[0]?.values;
|
|
78
75
|
const closestTimestamp = (0, _utils.getClosestTimestamp)(firstTimeSeriesValues, cursorX);
|
|
79
76
|
if (closestTimestamp === null) {
|
|
80
77
|
return _tooltipmodel.EMPTY_TOOLTIP_DATA;
|
|
@@ -89,8 +86,7 @@ function checkforNearbyTimeSeries(data, seriesMapping, pointInGrid, yBuffer, cha
|
|
|
89
86
|
if (currentDatasetValues === undefined || !Array.isArray(currentDatasetValues)) break;
|
|
90
87
|
const lineSeries = currentSeries;
|
|
91
88
|
const currentSeriesName = lineSeries.name ? lineSeries.name.toString() : '';
|
|
92
|
-
|
|
93
|
-
const markerColor = (_lineSeries_color = lineSeries.color) !== null && _lineSeries_color !== void 0 ? _lineSeries_color : '#000';
|
|
89
|
+
const markerColor = lineSeries.color ?? '#000';
|
|
94
90
|
if (Array.isArray(data)) {
|
|
95
91
|
for(let datumIdx = 0; datumIdx < currentDatasetValues.length; datumIdx++){
|
|
96
92
|
const nearbyTimeSeries = currentDatasetValues[datumIdx];
|
|
@@ -112,10 +108,9 @@ function checkforNearbyTimeSeries(data, seriesMapping, pointInGrid, yBuffer, cha
|
|
|
112
108
|
if (isClosestToCursor) {
|
|
113
109
|
// shows as bold in tooltip, customize 'emphasis' options in getTimeSeries util
|
|
114
110
|
emphasizedSeriesIndexes.push(seriesIdx);
|
|
115
|
-
var _yValueCounts_get;
|
|
116
111
|
// Used to determine which datapoint to apply select styles to.
|
|
117
112
|
// Accounts for cases where lines may be rendered directly on top of eachother.
|
|
118
|
-
const duplicateValuesCount =
|
|
113
|
+
const duplicateValuesCount = yValueCounts.get(yValue) ?? 0;
|
|
119
114
|
yValueCounts.set(yValue, duplicateValuesCount + 1);
|
|
120
115
|
if (duplicateValuesCount > 0) {
|
|
121
116
|
duplicateDatapoints.push({
|
|
@@ -164,10 +159,8 @@ function checkforNearbyTimeSeries(data, seriesMapping, pointInGrid, yBuffer, cha
|
|
|
164
159
|
}
|
|
165
160
|
function legacyCheckforNearbySeries(data, pointInGrid, yBuffer, chart, format) {
|
|
166
161
|
const currentNearbySeriesData = [];
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
var _pointInGrid_1;
|
|
170
|
-
const cursorY = (_pointInGrid_1 = pointInGrid[1]) !== null && _pointInGrid_1 !== void 0 ? _pointInGrid_1 : null;
|
|
162
|
+
const cursorX = pointInGrid[0] ?? null;
|
|
163
|
+
const cursorY = pointInGrid[1] ?? null;
|
|
171
164
|
if (cursorX === null || cursorY === null) {
|
|
172
165
|
return currentNearbySeriesData;
|
|
173
166
|
}
|
|
@@ -181,12 +174,10 @@ function legacyCheckforNearbySeries(data, pointInGrid, yBuffer, chart, format) {
|
|
|
181
174
|
if (currentSeries === undefined) break;
|
|
182
175
|
if (currentNearbySeriesData.length >= _model.OPTIMIZED_MODE_SERIES_LIMIT) break;
|
|
183
176
|
const currentSeriesName = currentSeries.name ? currentSeries.name.toString() : '';
|
|
184
|
-
|
|
185
|
-
const markerColor = (_currentSeries_color = currentSeries.color) !== null && _currentSeries_color !== void 0 ? _currentSeries_color : '#000';
|
|
177
|
+
const markerColor = currentSeries.color ?? '#000';
|
|
186
178
|
if (Array.isArray(currentSeries.data)) {
|
|
187
179
|
for(let datumIdx = 0; datumIdx < currentSeries.data.length; datumIdx++){
|
|
188
|
-
|
|
189
|
-
const xValue = (_data_xAxis_datumIdx = data.xAxis[datumIdx]) !== null && _data_xAxis_datumIdx !== void 0 ? _data_xAxis_datumIdx : 0;
|
|
180
|
+
const xValue = data.xAxis[datumIdx] ?? 0;
|
|
190
181
|
const yValue = currentSeries.data[datumIdx];
|
|
191
182
|
// ensure null values not displayed in tooltip
|
|
192
183
|
if (yValue !== undefined && yValue !== null && cursorX === datumIdx) {
|
|
@@ -204,7 +195,7 @@ function legacyCheckforNearbySeries(data, pointInGrid, yBuffer, chart, format) {
|
|
|
204
195
|
} else {
|
|
205
196
|
nonEmphasizedSeriesIndexes.push(seriesIdx);
|
|
206
197
|
// ensure series not close to cursor are not highlighted
|
|
207
|
-
if (
|
|
198
|
+
if (chart?.dispatchAction !== undefined) {
|
|
208
199
|
chart.dispatchAction({
|
|
209
200
|
type: 'downplay',
|
|
210
201
|
seriesIndex: seriesIdx
|
|
@@ -232,7 +223,7 @@ function legacyCheckforNearbySeries(data, pointInGrid, yBuffer, chart, format) {
|
|
|
232
223
|
}
|
|
233
224
|
}
|
|
234
225
|
}
|
|
235
|
-
if (
|
|
226
|
+
if (chart?.dispatchAction !== undefined) {
|
|
236
227
|
// Clears emphasis state of all lines that are not emphasized.
|
|
237
228
|
// Emphasized is a subset of just the nearby series that are closest to cursor.
|
|
238
229
|
chart.dispatchAction({
|
|
@@ -330,10 +321,9 @@ function legacyGetNearbySeriesData({ mousePos, pinnedPos, chartData, chart, form
|
|
|
330
321
|
totalSeries,
|
|
331
322
|
showAllSeries
|
|
332
323
|
});
|
|
333
|
-
var _mousePos_plotCanvas_x, _mousePos_plotCanvas_y;
|
|
334
324
|
const pointInPixel = [
|
|
335
|
-
|
|
336
|
-
|
|
325
|
+
mousePos.plotCanvas.x ?? 0,
|
|
326
|
+
mousePos.plotCanvas.y ?? 0
|
|
337
327
|
];
|
|
338
328
|
if (chart.containPixel('grid', pointInPixel)) {
|
|
339
329
|
const pointInGrid = chart.convertFromPixel('grid', pointInPixel);
|