@perses-dev/components 0.0.0-snapshot-saving-defaults-refinements-1b25cec → 0.0.0-snapshot-time-chart-rewrite-4667058
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/ContentWithLegend/ContentWithLegend.d.ts +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.d.ts.map +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.js +5 -3
- package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +10 -4
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.js +27 -8
- package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
- package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts +1 -1
- package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts.map +1 -1
- package/dist/DateTimeRangePicker/DateTimeRangePicker.js.map +1 -1
- package/dist/DateTimeRangePicker/TimeRangeSelector.d.ts +2 -5
- package/dist/DateTimeRangePicker/TimeRangeSelector.d.ts.map +1 -1
- package/dist/DateTimeRangePicker/TimeRangeSelector.js.map +1 -1
- package/dist/Drawer/Drawer.js +1 -1
- package/dist/Drawer/Drawer.js.map +1 -1
- package/dist/EChart/EChart.d.ts +2 -1
- package/dist/EChart/EChart.d.ts.map +1 -1
- package/dist/EChart/EChart.js +15 -3
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/GaugeChart/GaugeChart.d.ts +2 -2
- package/dist/GaugeChart/GaugeChart.d.ts.map +1 -1
- package/dist/GaugeChart/GaugeChart.js +7 -5
- package/dist/GaugeChart/GaugeChart.js.map +1 -1
- package/dist/Legend/CompactLegend.d.ts +4 -2
- package/dist/Legend/CompactLegend.d.ts.map +1 -1
- package/dist/Legend/CompactLegend.js +6 -3
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.d.ts +17 -3
- package/dist/Legend/Legend.d.ts.map +1 -1
- package/dist/Legend/Legend.js +7 -4
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/ListLegend.d.ts +4 -2
- package/dist/Legend/ListLegend.d.ts.map +1 -1
- package/dist/Legend/ListLegend.js +6 -5
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.d.ts +16 -3
- package/dist/Legend/ListLegendItem.d.ts.map +1 -1
- package/dist/Legend/ListLegendItem.js +17 -5
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/Legend/TableLegend.d.ts +6 -3
- package/dist/Legend/TableLegend.d.ts.map +1 -1
- package/dist/Legend/TableLegend.js +17 -3
- package/dist/Legend/TableLegend.js.map +1 -1
- package/dist/Legend/index.d.ts +1 -0
- package/dist/Legend/index.d.ts.map +1 -1
- package/dist/Legend/index.js +1 -0
- package/dist/Legend/index.js.map +1 -1
- package/dist/Legend/legend-model.d.ts +24 -0
- package/dist/Legend/legend-model.d.ts.map +1 -0
- package/dist/Legend/legend-model.js +19 -0
- package/dist/Legend/legend-model.js.map +1 -0
- package/dist/LineChart/LineChart.d.ts +6 -11
- package/dist/LineChart/LineChart.d.ts.map +1 -1
- package/dist/LineChart/LineChart.js +36 -9
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/LineChart/index.d.ts +0 -1
- package/dist/LineChart/index.d.ts.map +1 -1
- package/dist/LineChart/index.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.d.ts +12 -0
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.d.ts.map +1 -0
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +45 -0
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -0
- package/dist/RefreshIntervalPicker/index.d.ts +2 -0
- package/dist/RefreshIntervalPicker/index.d.ts.map +1 -0
- package/dist/{model/units → RefreshIntervalPicker}/index.js +1 -3
- package/dist/RefreshIntervalPicker/index.js.map +1 -0
- package/dist/SettingsAutocomplete/SettingsAutocomplete.d.ts +36 -0
- package/dist/SettingsAutocomplete/SettingsAutocomplete.d.ts.map +1 -0
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js +65 -0
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -0
- package/dist/SettingsAutocomplete/index.d.ts +2 -0
- package/dist/SettingsAutocomplete/index.d.ts.map +1 -0
- package/dist/{model/units/constants.js → SettingsAutocomplete/index.js} +2 -4
- package/dist/SettingsAutocomplete/index.js.map +1 -0
- package/dist/StatChart/StatChart.d.ts +3 -2
- package/dist/StatChart/StatChart.d.ts.map +1 -1
- package/dist/StatChart/StatChart.js +75 -22
- package/dist/StatChart/StatChart.js.map +1 -1
- package/dist/StatChart/calculateFontSize.d.ts +14 -0
- package/dist/StatChart/calculateFontSize.d.ts.map +1 -0
- package/dist/StatChart/calculateFontSize.js +47 -0
- package/dist/StatChart/calculateFontSize.js.map +1 -0
- package/dist/Table/InnerTable.js +3 -3
- package/dist/Table/InnerTable.js.map +1 -1
- package/dist/Table/Table.d.ts +1 -1
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +58 -10
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableCell.d.ts +16 -3
- package/dist/Table/TableCell.d.ts.map +1 -1
- package/dist/Table/TableCell.js +13 -5
- package/dist/Table/TableCell.js.map +1 -1
- package/dist/Table/TableCheckbox.js +1 -1
- package/dist/Table/TableCheckbox.js.map +1 -1
- package/dist/Table/TableHeaderCell.d.ts +23 -0
- package/dist/Table/TableHeaderCell.d.ts.map +1 -0
- package/dist/Table/TableHeaderCell.js +53 -0
- package/dist/Table/TableHeaderCell.js.map +1 -0
- package/dist/Table/TableRow.d.ts.map +1 -1
- package/dist/Table/TableRow.js +3 -3
- package/dist/Table/TableRow.js.map +1 -1
- package/dist/Table/VirtualizedTable.d.ts +3 -3
- package/dist/Table/VirtualizedTable.d.ts.map +1 -1
- package/dist/Table/VirtualizedTable.js +51 -10
- package/dist/Table/VirtualizedTable.js.map +1 -1
- package/dist/Table/model/table-model.d.ts +81 -3
- package/dist/Table/model/table-model.d.ts.map +1 -1
- package/dist/Table/model/table-model.js +22 -7
- package/dist/Table/model/table-model.js.map +1 -1
- package/dist/TimeChart/TimeChart.d.ts +23 -0
- package/dist/TimeChart/TimeChart.d.ts.map +1 -0
- package/dist/TimeChart/TimeChart.js +314 -0
- package/dist/TimeChart/TimeChart.js.map +1 -0
- package/dist/TimeChart/index.d.ts +2 -0
- package/dist/TimeChart/index.d.ts.map +1 -0
- package/dist/{LegendOptionsEditor → TimeChart}/index.js +1 -1
- package/dist/TimeChart/index.js.map +1 -0
- package/dist/TimeSeriesTooltip/{TimeSeriesTooltip.d.ts → LineChartTooltip.d.ts} +5 -4
- package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +1 -0
- package/dist/TimeSeriesTooltip/{TimeSeriesTooltip.js → LineChartTooltip.js} +7 -6
- package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +1 -0
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +16 -0
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -0
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js +76 -0
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -0
- package/dist/TimeSeriesTooltip/TooltipHeader.d.ts +2 -2
- package/dist/TimeSeriesTooltip/TooltipHeader.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js +10 -8
- package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
- package/dist/TimeSeriesTooltip/index.d.ts +2 -1
- package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/index.js +2 -1
- package/dist/TimeSeriesTooltip/index.js.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts +23 -4
- package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.js +175 -17
- package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts +4 -0
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
- package/dist/TimeSeriesTooltip/utils.d.ts +25 -0
- package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/utils.js +29 -1
- package/dist/TimeSeriesTooltip/utils.js.map +1 -1
- package/dist/UnitSelector/UnitSelector.d.ts +1 -1
- package/dist/UnitSelector/UnitSelector.d.ts.map +1 -1
- package/dist/UnitSelector/UnitSelector.js +11 -24
- package/dist/UnitSelector/UnitSelector.js.map +1 -1
- package/dist/YAxisLabel.js +1 -1
- package/dist/YAxisLabel.js.map +1 -1
- package/dist/cjs/ContentWithLegend/ContentWithLegend.js +5 -3
- package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +28 -9
- package/dist/cjs/Drawer/Drawer.js +1 -1
- package/dist/cjs/EChart/EChart.js +22 -5
- package/dist/cjs/GaugeChart/GaugeChart.js +7 -5
- package/dist/cjs/Legend/CompactLegend.js +7 -4
- package/dist/cjs/Legend/Legend.js +8 -5
- package/dist/cjs/Legend/ListLegend.js +7 -6
- package/dist/cjs/Legend/ListLegendItem.js +17 -5
- package/dist/cjs/Legend/TableLegend.js +17 -3
- package/dist/cjs/Legend/index.js +1 -0
- package/dist/cjs/{model/units/types.js → Legend/legend-model.js} +7 -10
- package/dist/cjs/LineChart/LineChart.js +35 -47
- package/dist/cjs/OptionsEditorLayout/OptionsEditorControl.js +1 -1
- package/dist/cjs/RefreshIntervalPicker/RefreshIntervalPicker.js +51 -0
- package/dist/cjs/{model/units → RefreshIntervalPicker}/index.js +1 -3
- package/dist/cjs/SettingsAutocomplete/SettingsAutocomplete.js +66 -0
- package/dist/cjs/SettingsAutocomplete/index.js +28 -0
- package/dist/cjs/StatChart/StatChart.js +82 -24
- package/dist/cjs/StatChart/calculateFontSize.js +51 -0
- package/dist/cjs/Table/InnerTable.js +3 -3
- package/dist/cjs/Table/Table.js +57 -9
- package/dist/cjs/Table/TableCell.js +13 -5
- package/dist/cjs/Table/TableCheckbox.js +1 -1
- package/dist/cjs/Table/TableHeaderCell.js +59 -0
- package/dist/cjs/Table/TableRow.js +2 -2
- package/dist/cjs/Table/VirtualizedTable.js +51 -10
- package/dist/cjs/Table/model/table-model.js +22 -7
- package/dist/cjs/TimeChart/TimeChart.js +320 -0
- package/dist/cjs/{LegendOptionsEditor → TimeChart}/index.js +1 -1
- package/dist/cjs/TimeSeriesTooltip/{TimeSeriesTooltip.js → LineChartTooltip.js} +7 -45
- package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +87 -0
- package/dist/cjs/TimeSeriesTooltip/TooltipHeader.js +10 -8
- package/dist/cjs/TimeSeriesTooltip/index.js +2 -1
- package/dist/cjs/TimeSeriesTooltip/nearby-series.js +171 -17
- package/dist/cjs/TimeSeriesTooltip/utils.js +35 -3
- package/dist/cjs/UnitSelector/UnitSelector.js +15 -28
- package/dist/cjs/YAxisLabel.js +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/model/index.js +1 -2
- package/dist/cjs/model/timeOption.js +16 -0
- package/dist/cjs/{model/units/constants.js → theme/component-overrides/paper.js} +9 -5
- package/dist/cjs/theme/palette/background.js +2 -2
- package/dist/cjs/theme/theme.js +2 -0
- package/dist/cjs/utils/axis.js +58 -0
- package/dist/cjs/{LineChart/utils.js → utils/chart-actions.js} +9 -47
- package/dist/cjs/utils/format.js +47 -1
- package/dist/cjs/utils/index.js +3 -1
- package/dist/cjs/utils/theme-gen.js +44 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/model/graph.d.ts +20 -3
- package/dist/model/graph.d.ts.map +1 -1
- package/dist/model/graph.js.map +1 -1
- package/dist/model/index.d.ts +1 -2
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +1 -2
- package/dist/model/index.js.map +1 -1
- package/dist/model/theme.d.ts +4 -6
- package/dist/model/theme.d.ts.map +1 -1
- package/dist/model/theme.js.map +1 -1
- package/dist/model/timeOption.d.ts +6 -0
- package/dist/model/timeOption.d.ts.map +1 -0
- package/dist/model/{units/types.js → timeOption.js} +2 -9
- package/dist/model/timeOption.js.map +1 -0
- package/dist/theme/component-overrides/paper.d.ts +3 -0
- package/dist/theme/component-overrides/paper.d.ts.map +1 -0
- package/dist/theme/component-overrides/paper.js +21 -0
- package/dist/theme/component-overrides/paper.js.map +1 -0
- package/dist/theme/palette/background.js +2 -2
- package/dist/theme/palette/background.js.map +1 -1
- package/dist/theme/theme.d.ts.map +1 -1
- package/dist/theme/theme.js +2 -0
- package/dist/theme/theme.js.map +1 -1
- package/dist/utils/axis.d.ts +14 -0
- package/dist/utils/axis.d.ts.map +1 -0
- package/dist/utils/axis.js +45 -0
- package/dist/utils/axis.js.map +1 -0
- package/dist/utils/chart-actions.d.ts +18 -0
- package/dist/utils/chart-actions.d.ts.map +1 -0
- package/dist/utils/chart-actions.js +52 -0
- package/dist/utils/chart-actions.js.map +1 -0
- package/dist/utils/format.d.ts +6 -0
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +47 -0
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/theme-gen.d.ts.map +1 -1
- package/dist/utils/theme-gen.js +38 -1
- package/dist/utils/theme-gen.js.map +1 -1
- package/package.json +5 -9
- package/dist/LegendOptionsEditor/LegendOptionsEditor.d.ts +0 -8
- package/dist/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +0 -1
- package/dist/LegendOptionsEditor/LegendOptionsEditor.js +0 -109
- package/dist/LegendOptionsEditor/LegendOptionsEditor.js.map +0 -1
- package/dist/LegendOptionsEditor/index.d.ts +0 -2
- package/dist/LegendOptionsEditor/index.d.ts.map +0 -1
- package/dist/LegendOptionsEditor/index.js.map +0 -1
- package/dist/LineChart/utils.d.ts +0 -30
- package/dist/LineChart/utils.d.ts.map +0 -1
- package/dist/LineChart/utils.js +0 -90
- package/dist/LineChart/utils.js.map +0 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +0 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +0 -1
- package/dist/cjs/LegendOptionsEditor/LegendOptionsEditor.js +0 -115
- package/dist/cjs/model/legend.js +0 -102
- package/dist/cjs/model/units/bytes.js +0 -84
- package/dist/cjs/model/units/decimal.js +0 -62
- package/dist/cjs/model/units/percent.js +0 -73
- package/dist/cjs/model/units/time.js +0 -105
- package/dist/cjs/model/units/units.js +0 -101
- package/dist/cjs/model/units/utils.js +0 -42
- package/dist/model/legend.d.ts +0 -36
- package/dist/model/legend.d.ts.map +0 -1
- package/dist/model/legend.js +0 -81
- package/dist/model/legend.js.map +0 -1
- package/dist/model/units/bytes.d.ts +0 -13
- package/dist/model/units/bytes.d.ts.map +0 -1
- package/dist/model/units/bytes.js +0 -66
- package/dist/model/units/bytes.js.map +0 -1
- package/dist/model/units/constants.d.ts +0 -2
- package/dist/model/units/constants.d.ts.map +0 -1
- package/dist/model/units/constants.js.map +0 -1
- package/dist/model/units/decimal.d.ts +0 -13
- package/dist/model/units/decimal.d.ts.map +0 -1
- package/dist/model/units/decimal.js +0 -49
- package/dist/model/units/decimal.js.map +0 -1
- package/dist/model/units/index.d.ts +0 -4
- package/dist/model/units/index.d.ts.map +0 -1
- package/dist/model/units/index.js.map +0 -1
- package/dist/model/units/percent.d.ts +0 -12
- package/dist/model/units/percent.d.ts.map +0 -1
- package/dist/model/units/percent.js +0 -60
- package/dist/model/units/percent.js.map +0 -1
- package/dist/model/units/time.d.ts +0 -22
- package/dist/model/units/time.d.ts.map +0 -1
- package/dist/model/units/time.js +0 -91
- package/dist/model/units/time.js.map +0 -1
- package/dist/model/units/types.d.ts +0 -47
- package/dist/model/units/types.d.ts.map +0 -1
- package/dist/model/units/types.js.map +0 -1
- package/dist/model/units/units.d.ts +0 -40
- package/dist/model/units/units.d.ts.map +0 -1
- package/dist/model/units/units.js +0 -80
- package/dist/model/units/units.js.map +0 -1
- package/dist/model/units/utils.d.ts +0 -4
- package/dist/model/units/utils.d.ts.map +0 -1
- package/dist/model/units/utils.js +0 -32
- package/dist/model/units/utils.js.map +0 -1
|
@@ -27,7 +27,7 @@ const StyledMuiTableCell = (0, _material.styled)(_material.TableCell)(({ theme
|
|
|
27
27
|
backgroundColor: 'inherit',
|
|
28
28
|
'&.MuiTableCell-head': {
|
|
29
29
|
// Important to avoid scrolling behind the header showing through.
|
|
30
|
-
backgroundColor: theme.palette.background.
|
|
30
|
+
backgroundColor: theme.palette.background.default
|
|
31
31
|
},
|
|
32
32
|
'&:focus-visible': {
|
|
33
33
|
outline: `solid 1px ${theme.palette.primary.main}`,
|
|
@@ -37,7 +37,7 @@ const StyledMuiTableCell = (0, _material.styled)(_material.TableCell)(({ theme
|
|
|
37
37
|
borderRadius: 0
|
|
38
38
|
}
|
|
39
39
|
}));
|
|
40
|
-
function TableCell({ children , density , variant , width , focusState ='none' , onFocusTrigger , ...otherProps }) {
|
|
40
|
+
function TableCell({ children , density , variant , width , focusState ='none' , onFocusTrigger , isFirstColumn , isLastColumn , description , ...otherProps }) {
|
|
41
41
|
const theme = (0, _material.useTheme)();
|
|
42
42
|
const elRef = (0, _react.useRef)();
|
|
43
43
|
const isHeader = variant === 'head';
|
|
@@ -51,7 +51,7 @@ function TableCell({ children , density , variant , width , focusState ='none' ,
|
|
|
51
51
|
const handleFocus = (e)=>{
|
|
52
52
|
var ref;
|
|
53
53
|
// From https://zellwk.com/blog/keyboard-focusable-elements/
|
|
54
|
-
const nestedFocusTarget = (ref = e.currentTarget) === null || ref === void 0 ? void 0 : ref.querySelector('a[href], button, input, textarea, select, details');
|
|
54
|
+
const nestedFocusTarget = (ref = e.currentTarget) === null || ref === void 0 ? void 0 : ref.querySelector('a[href], button, input, textarea, select, details,[role="button"]');
|
|
55
55
|
if (nestedFocusTarget) {
|
|
56
56
|
// If the cell has a focusable child, focus it instead. Mostly used for
|
|
57
57
|
// checkbox cells, but could have other uses.
|
|
@@ -83,14 +83,22 @@ function TableCell({ children , density , variant , width , focusState ='none' ,
|
|
|
83
83
|
ref: elRef,
|
|
84
84
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
85
85
|
sx: {
|
|
86
|
-
...(0, _tableModel.getTableCellLayout)(theme, density
|
|
86
|
+
...(0, _tableModel.getTableCellLayout)(theme, density, {
|
|
87
|
+
isLastColumn,
|
|
88
|
+
isFirstColumn
|
|
89
|
+
}),
|
|
87
90
|
position: 'relative',
|
|
88
91
|
// Text truncation. Currently enforced on all cells. We may control
|
|
89
92
|
// this with a prop on column config in the future.
|
|
90
93
|
whiteSpace: 'nowrap',
|
|
91
94
|
overflow: 'hidden',
|
|
92
|
-
textOverflow: 'ellipsis'
|
|
95
|
+
textOverflow: 'ellipsis',
|
|
96
|
+
// Need to inherit from the MUI cell because this manages some ordering
|
|
97
|
+
// that the `TableSortLabel` uses to determine the location of the icon
|
|
98
|
+
// in headers.
|
|
99
|
+
flexDirection: 'inherit'
|
|
93
100
|
},
|
|
101
|
+
title: description,
|
|
94
102
|
children: children
|
|
95
103
|
})
|
|
96
104
|
});
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
Object.defineProperty(exports, "TableHeaderCell", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>TableHeaderCell
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _material = require("@mui/material");
|
|
23
|
+
const _tableCell = require("./TableCell");
|
|
24
|
+
function TableHeaderCell({ onSort , sortDirection , nextSortDirection , children , ...cellProps }) {
|
|
25
|
+
const showSortLabel = !!onSort;
|
|
26
|
+
const headerText = /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
27
|
+
noWrap: true,
|
|
28
|
+
variant: "inherit",
|
|
29
|
+
component: "div",
|
|
30
|
+
color: "inherit",
|
|
31
|
+
children: children
|
|
32
|
+
});
|
|
33
|
+
const isActive = !!sortDirection;
|
|
34
|
+
const direction = isActive ? sortDirection : nextSortDirection;
|
|
35
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_tableCell.TableCell, {
|
|
36
|
+
...cellProps,
|
|
37
|
+
children: showSortLabel ? /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableSortLabel, {
|
|
38
|
+
onClick: onSort,
|
|
39
|
+
direction: direction,
|
|
40
|
+
active: isActive,
|
|
41
|
+
sx: {
|
|
42
|
+
// Overrides a default vertical alignment in the CSS that changes
|
|
43
|
+
// the header vertical rhythm in a way that's inconsistent with
|
|
44
|
+
// non-sorting headers.
|
|
45
|
+
verticalAlign: 'unset',
|
|
46
|
+
// Makes it possible to ellipsize the text if it's too long.
|
|
47
|
+
maxWidth: '100%',
|
|
48
|
+
// Make the arrow visible when focused using the keyboard to assist
|
|
49
|
+
// with a11y.
|
|
50
|
+
'&:focus-visible': {
|
|
51
|
+
[`& .${_material.tableSortLabelClasses.icon}`]: {
|
|
52
|
+
opacity: isActive ? 1 : 0.5
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
children: headerText
|
|
57
|
+
}) : headerText
|
|
58
|
+
});
|
|
59
|
+
}
|
|
@@ -26,9 +26,9 @@ const TableRow = /*#__PURE__*/ (0, _react.forwardRef)(function TableRow(props, r
|
|
|
26
26
|
...props,
|
|
27
27
|
ref: ref,
|
|
28
28
|
sx: {
|
|
29
|
-
backgroundColor: (theme)=>theme.palette.background.
|
|
29
|
+
backgroundColor: (theme)=>theme.palette.background.default,
|
|
30
30
|
'&:hover': {
|
|
31
|
-
backgroundColor: (theme)=>theme.palette.primary.
|
|
31
|
+
backgroundColor: (theme)=>(0, _material.alpha)(theme.palette.primary.main, theme.palette.action.hoverOpacity)
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
});
|
|
@@ -27,10 +27,11 @@ const _tableRow = require("./TableRow");
|
|
|
27
27
|
const _tableBody = require("./TableBody");
|
|
28
28
|
const _innerTable = require("./InnerTable");
|
|
29
29
|
const _tableHead = require("./TableHead");
|
|
30
|
+
const _tableHeaderCell = require("./TableHeaderCell");
|
|
30
31
|
const _tableCell = require("./TableCell");
|
|
31
32
|
const _virtualizedTableContainer = require("./VirtualizedTableContainer");
|
|
32
33
|
const _useVirtualizedTableKeyboardNav = require("./hooks/useVirtualizedTableKeyboardNav");
|
|
33
|
-
function VirtualizedTable({ width , height , density , onRowClick , rows , columns , headers }) {
|
|
34
|
+
function VirtualizedTable({ width , height , density , onRowClick , onRowMouseOver , onRowMouseOut , rows , columns , headers }) {
|
|
34
35
|
const virtuosoRef = (0, _react.useRef)(null);
|
|
35
36
|
// Use a ref for these values because they are only needed for keyboard
|
|
36
37
|
// focus interactions and setting them on state will lead to a significant
|
|
@@ -74,10 +75,20 @@ function VirtualizedTable({ width , height , density , onRowClick , rows , colum
|
|
|
74
75
|
if (!row) {
|
|
75
76
|
return null;
|
|
76
77
|
}
|
|
78
|
+
const rowEventOpts = {
|
|
79
|
+
id: row.id,
|
|
80
|
+
index: row.index
|
|
81
|
+
};
|
|
77
82
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_tableRow.TableRow, {
|
|
78
83
|
...props,
|
|
79
|
-
onClick: ()=>onRowClick(row.id),
|
|
80
|
-
density: density
|
|
84
|
+
onClick: (e)=>onRowClick(e, row.id),
|
|
85
|
+
density: density,
|
|
86
|
+
onMouseOver: (e)=>{
|
|
87
|
+
onRowMouseOver === null || onRowMouseOver === void 0 ? void 0 : onRowMouseOver(e, rowEventOpts);
|
|
88
|
+
},
|
|
89
|
+
onMouseOut: (e)=>{
|
|
90
|
+
onRowMouseOut === null || onRowMouseOut === void 0 ? void 0 : onRowMouseOut(e, rowEventOpts);
|
|
91
|
+
}
|
|
81
92
|
});
|
|
82
93
|
},
|
|
83
94
|
TableBody: _tableBody.TableBody
|
|
@@ -86,6 +97,8 @@ function VirtualizedTable({ width , height , density , onRowClick , rows , colum
|
|
|
86
97
|
density,
|
|
87
98
|
keyboardNav.onTableKeyDown,
|
|
88
99
|
onRowClick,
|
|
100
|
+
onRowMouseOut,
|
|
101
|
+
onRowMouseOver,
|
|
89
102
|
rows,
|
|
90
103
|
width
|
|
91
104
|
]);
|
|
@@ -107,18 +120,28 @@ function VirtualizedTable({ width , height , density , onRowClick , rows , colum
|
|
|
107
120
|
children: headers.map((headerGroup)=>{
|
|
108
121
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_tableRow.TableRow, {
|
|
109
122
|
density: density,
|
|
110
|
-
children: headerGroup.headers.map((header, i)=>{
|
|
123
|
+
children: headerGroup.headers.map((header, i, headers)=>{
|
|
124
|
+
var ref, ref1;
|
|
111
125
|
const column = header.column;
|
|
112
126
|
const position = {
|
|
113
127
|
row: 0,
|
|
114
128
|
column: i
|
|
115
129
|
};
|
|
116
|
-
|
|
130
|
+
const isSorted = column.getIsSorted();
|
|
131
|
+
const nextSorting = column.getNextSortingOrder();
|
|
132
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_tableHeaderCell.TableHeaderCell, {
|
|
133
|
+
onSort: column.getCanSort() ? column.getToggleSortingHandler() : undefined,
|
|
134
|
+
sortDirection: typeof isSorted === 'string' ? isSorted : undefined,
|
|
135
|
+
nextSortDirection: typeof nextSorting === 'string' ? nextSorting : undefined,
|
|
117
136
|
width: column.getSize() || 'auto',
|
|
137
|
+
align: (ref = column.columnDef.meta) === null || ref === void 0 ? void 0 : ref.align,
|
|
118
138
|
variant: "head",
|
|
119
139
|
density: density,
|
|
140
|
+
description: (ref1 = column.columnDef.meta) === null || ref1 === void 0 ? void 0 : ref1.headerDescription,
|
|
120
141
|
focusState: getFocusState(position),
|
|
121
142
|
onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
|
|
143
|
+
isFirstColumn: i === 0,
|
|
144
|
+
isLastColumn: i === headers.length - 1,
|
|
122
145
|
children: (0, _reactTable.flexRender)(column.columnDef.header, header.getContext())
|
|
123
146
|
}, header.id);
|
|
124
147
|
})
|
|
@@ -132,20 +155,38 @@ function VirtualizedTable({ width , height , density , onRowClick , rows , colum
|
|
|
132
155
|
return null;
|
|
133
156
|
}
|
|
134
157
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
135
|
-
children: row.getVisibleCells().map((cell, i)=>{
|
|
158
|
+
children: row.getVisibleCells().map((cell, i, cells)=>{
|
|
159
|
+
var ref, ref1;
|
|
136
160
|
const position = {
|
|
137
161
|
// Add 1 to the row index because the header is row 0
|
|
138
162
|
row: index + 1,
|
|
139
163
|
column: i
|
|
140
164
|
};
|
|
165
|
+
const cellContext = cell.getContext();
|
|
166
|
+
const cellRenderFn = cell.column.columnDef.cell;
|
|
167
|
+
const cellContent = typeof cellRenderFn == 'function' ? cellRenderFn(cellContext) : null;
|
|
168
|
+
const cellDescriptionDef = (ref = cell.column.columnDef.meta) === null || ref === void 0 ? void 0 : ref.cellDescription;
|
|
169
|
+
let description = undefined;
|
|
170
|
+
if (typeof cellDescriptionDef === 'function') {
|
|
171
|
+
// If the cell description is a function, set the value using
|
|
172
|
+
// the function.
|
|
173
|
+
description = cellDescriptionDef(cellContext);
|
|
174
|
+
} else if (cellDescriptionDef && typeof cellContent === 'string') {
|
|
175
|
+
// If the cell description is `true` AND the cell content is
|
|
176
|
+
// a string (and thus viable as a `title` attribute), use the
|
|
177
|
+
// cell content.
|
|
178
|
+
description = cellContent;
|
|
179
|
+
}
|
|
141
180
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_tableCell.TableCell, {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
},
|
|
181
|
+
width: cell.column.getSize() || 'auto',
|
|
182
|
+
align: (ref1 = cell.column.columnDef.meta) === null || ref1 === void 0 ? void 0 : ref1.align,
|
|
145
183
|
density: density,
|
|
146
184
|
focusState: getFocusState(position),
|
|
147
185
|
onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
|
|
148
|
-
|
|
186
|
+
isFirstColumn: i === 0,
|
|
187
|
+
isLastColumn: i === cells.length - 1,
|
|
188
|
+
description: description,
|
|
189
|
+
children: cellContent
|
|
149
190
|
}, cell.id);
|
|
150
191
|
})
|
|
151
192
|
});
|
|
@@ -31,13 +31,16 @@ function calculateTableCellHeight(lineHeight, paddingY) {
|
|
|
31
31
|
const verticalPaddingNum = typeof paddingY === 'string' ? parseInt(paddingY, 10) : paddingY;
|
|
32
32
|
return lineHeightNum + verticalPaddingNum * 2;
|
|
33
33
|
}
|
|
34
|
-
function getTableCellLayout(theme, density) {
|
|
34
|
+
function getTableCellLayout(theme, density, { isLastColumn , isFirstColumn } = {}) {
|
|
35
35
|
if (density === 'compact') {
|
|
36
36
|
const paddingY = theme.spacing(0.5);
|
|
37
|
-
const
|
|
37
|
+
const basePaddingX = theme.spacing(0.5);
|
|
38
|
+
const edgePaddingX = theme.spacing(1);
|
|
39
|
+
const paddingLeft = isFirstColumn ? edgePaddingX : basePaddingX;
|
|
40
|
+
const paddingRight = isLastColumn ? edgePaddingX : basePaddingX;
|
|
38
41
|
const lineHeight = theme.typography.body2.lineHeight;
|
|
39
42
|
return {
|
|
40
|
-
padding: `${paddingY} ${
|
|
43
|
+
padding: `${paddingY} ${paddingRight} ${paddingY} ${paddingLeft}`,
|
|
41
44
|
height: calculateTableCellHeight(lineHeight, paddingY),
|
|
42
45
|
fontSize: theme.typography.body2.fontSize,
|
|
43
46
|
lineHeight: lineHeight
|
|
@@ -45,17 +48,20 @@ function getTableCellLayout(theme, density) {
|
|
|
45
48
|
}
|
|
46
49
|
// standard density
|
|
47
50
|
const paddingY1 = theme.spacing(1);
|
|
48
|
-
const
|
|
51
|
+
const basePaddingX1 = theme.spacing(1.25);
|
|
52
|
+
const edgePaddingX1 = theme.spacing(2);
|
|
53
|
+
const paddingLeft1 = isFirstColumn ? edgePaddingX1 : basePaddingX1;
|
|
54
|
+
const paddingRight1 = isLastColumn ? edgePaddingX1 : basePaddingX1;
|
|
49
55
|
const lineHeight1 = theme.typography.body1.lineHeight;
|
|
50
56
|
return {
|
|
51
|
-
padding: `${paddingY1} ${
|
|
57
|
+
padding: `${paddingY1} ${paddingRight1} ${paddingY1} ${paddingLeft1}`,
|
|
52
58
|
height: calculateTableCellHeight(lineHeight1, paddingY1),
|
|
53
59
|
fontSize: theme.typography.body1.fontSize,
|
|
54
60
|
lineHeight: lineHeight1
|
|
55
61
|
};
|
|
56
62
|
}
|
|
57
63
|
function persesColumnsToTanstackColumns(columns) {
|
|
58
|
-
const tableCols = columns.map(({ width , ...otherProps })=>{
|
|
64
|
+
const tableCols = columns.map(({ width , align , headerDescription , cellDescription , enableSorting , ...otherProps })=>{
|
|
59
65
|
// Tanstack Table does not support an "auto" value to naturally size to fit
|
|
60
66
|
// the space in a table. We translate our custom "auto" setting to 0 size
|
|
61
67
|
// for these columns, so it is easy to fall back to auto when rendering.
|
|
@@ -72,7 +78,16 @@ function persesColumnsToTanstackColumns(columns) {
|
|
|
72
78
|
};
|
|
73
79
|
const result = {
|
|
74
80
|
...otherProps,
|
|
75
|
-
...sizeProps
|
|
81
|
+
...sizeProps,
|
|
82
|
+
// Default sorting to false, so it is very explicitly set per column.
|
|
83
|
+
enableSorting: !!enableSorting,
|
|
84
|
+
// Open-ended store for extra metadata in TanStack Table, so you can bake
|
|
85
|
+
// in your own features.
|
|
86
|
+
meta: {
|
|
87
|
+
align,
|
|
88
|
+
headerDescription,
|
|
89
|
+
cellDescription
|
|
90
|
+
}
|
|
76
91
|
};
|
|
77
92
|
return result;
|
|
78
93
|
});
|
|
@@ -0,0 +1,320 @@
|
|
|
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
|
+
Object.defineProperty(exports, "TimeChart", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>TimeChart
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = require("react");
|
|
23
|
+
const _material = require("@mui/material");
|
|
24
|
+
const _dateFnsTz = require("date-fns-tz");
|
|
25
|
+
const _core = require("@perses-dev/core");
|
|
26
|
+
const _core1 = require("echarts/core");
|
|
27
|
+
const _charts = require("echarts/charts");
|
|
28
|
+
const _components = require("echarts/components");
|
|
29
|
+
const _renderers = require("echarts/renderers");
|
|
30
|
+
const _echart = require("../EChart");
|
|
31
|
+
const _chartsThemeProvider = require("../context/ChartsThemeProvider");
|
|
32
|
+
const _utils = require("../utils");
|
|
33
|
+
const _timeSeriesTooltip = require("../TimeSeriesTooltip");
|
|
34
|
+
const _timeZoneProvider = require("../context/TimeZoneProvider");
|
|
35
|
+
(0, _core1.use)([
|
|
36
|
+
_charts.LineChart,
|
|
37
|
+
_components.GridComponent,
|
|
38
|
+
_components.DatasetComponent,
|
|
39
|
+
_components.DataZoomComponent,
|
|
40
|
+
_components.MarkAreaComponent,
|
|
41
|
+
_components.MarkLineComponent,
|
|
42
|
+
_components.MarkPointComponent,
|
|
43
|
+
_components.TitleComponent,
|
|
44
|
+
_components.ToolboxComponent,
|
|
45
|
+
_components.TooltipComponent,
|
|
46
|
+
_components.LegendComponent,
|
|
47
|
+
_renderers.CanvasRenderer
|
|
48
|
+
]);
|
|
49
|
+
const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ height , data , seriesMapping , timeScale: timeScaleProp , yAxis , unit , grid , tooltipConfig ={
|
|
50
|
+
wrapLabels: true
|
|
51
|
+
} , noDataVariant ='message' , syncGroup , onDataZoom , onDoubleClick , __experimentalEChartsOptionsOverride , }, ref) {
|
|
52
|
+
var ref1;
|
|
53
|
+
const chartsTheme = (0, _chartsThemeProvider.useChartsTheme)();
|
|
54
|
+
const chartRef = (0, _react.useRef)();
|
|
55
|
+
const [showTooltip, setShowTooltip] = (0, _react.useState)(true);
|
|
56
|
+
const [tooltipPinnedCoords, setTooltipPinnedCoords] = (0, _react.useState)(null);
|
|
57
|
+
const [isDragging, setIsDragging] = (0, _react.useState)(false);
|
|
58
|
+
const [startX, setStartX] = (0, _react.useState)(0);
|
|
59
|
+
const { timeZone } = (0, _timeZoneProvider.useTimeZone)();
|
|
60
|
+
var ref2;
|
|
61
|
+
const totalSeries = (ref2 = data === null || data === void 0 ? void 0 : data.length) !== null && ref2 !== void 0 ? ref2 : 0;
|
|
62
|
+
let timeScale;
|
|
63
|
+
if (timeScaleProp === undefined) {
|
|
64
|
+
const commonTimeScale = (0, _core.getCommonTimeScale)(data);
|
|
65
|
+
if (commonTimeScale === undefined) {
|
|
66
|
+
// set default to past 5 years
|
|
67
|
+
const today = new Date();
|
|
68
|
+
const pastDate = new Date(today);
|
|
69
|
+
pastDate.setFullYear(today.getFullYear() - 5);
|
|
70
|
+
const todayMs = today.getTime();
|
|
71
|
+
const pastDateMs = pastDate.getTime();
|
|
72
|
+
timeScale = {
|
|
73
|
+
startMs: pastDateMs,
|
|
74
|
+
endMs: todayMs,
|
|
75
|
+
stepMs: 1,
|
|
76
|
+
rangeMs: todayMs - pastDateMs
|
|
77
|
+
};
|
|
78
|
+
} else {
|
|
79
|
+
timeScale = commonTimeScale;
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
timeScale = timeScaleProp;
|
|
83
|
+
}
|
|
84
|
+
(0, _react.useImperativeHandle)(ref, ()=>{
|
|
85
|
+
return {
|
|
86
|
+
highlightSeries ({ name }) {
|
|
87
|
+
if (!chartRef.current) {
|
|
88
|
+
// No chart. Do nothing.
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
chartRef.current.dispatchAction({
|
|
92
|
+
type: 'highlight',
|
|
93
|
+
seriesId: name
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
clearHighlightedSeries: ()=>{
|
|
97
|
+
if (!chartRef.current) {
|
|
98
|
+
// No chart. Do nothing.
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
(0, _utils.clearHighlightedSeries)(chartRef.current, totalSeries);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}, [
|
|
105
|
+
totalSeries
|
|
106
|
+
]);
|
|
107
|
+
const handleEvents = (0, _react.useMemo)(()=>{
|
|
108
|
+
return {
|
|
109
|
+
datazoom: (params)=>{
|
|
110
|
+
if (onDataZoom === undefined) {
|
|
111
|
+
setTimeout(()=>{
|
|
112
|
+
// workaround so unpin happens after click event
|
|
113
|
+
setTooltipPinnedCoords(null);
|
|
114
|
+
}, 10);
|
|
115
|
+
}
|
|
116
|
+
if (onDataZoom === undefined || params.batch[0] === undefined) return;
|
|
117
|
+
const xAxisStartValue = params.batch[0].startValue;
|
|
118
|
+
const xAxisEndValue = params.batch[0].endValue;
|
|
119
|
+
if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {
|
|
120
|
+
const zoomEvent = {
|
|
121
|
+
start: xAxisStartValue,
|
|
122
|
+
end: xAxisEndValue
|
|
123
|
+
};
|
|
124
|
+
onDataZoom(zoomEvent);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}, [
|
|
129
|
+
onDataZoom,
|
|
130
|
+
setTooltipPinnedCoords
|
|
131
|
+
]);
|
|
132
|
+
if (chartRef.current !== undefined) {
|
|
133
|
+
(0, _utils.enableDataZoom)(chartRef.current);
|
|
134
|
+
}
|
|
135
|
+
const { noDataOption } = chartsTheme;
|
|
136
|
+
const option = (0, _react.useMemo)(()=>{
|
|
137
|
+
// TODO: fix loading state and noData variants
|
|
138
|
+
// if (data === undefined) return {};
|
|
139
|
+
// The "chart" `noDataVariant` is only used when the `timeSeries` is an
|
|
140
|
+
// empty array because a `null` value will throw an error.
|
|
141
|
+
if (data === null || data.length === 0 && noDataVariant === 'message') return noDataOption;
|
|
142
|
+
// Utilizes ECharts dataset so raw data is separate from series option style properties
|
|
143
|
+
// https://apache.github.io/echarts-handbook/en/concepts/dataset/
|
|
144
|
+
const dataset = [];
|
|
145
|
+
const isLocalTimeZone = timeZone === 'local';
|
|
146
|
+
data.map((d, index)=>{
|
|
147
|
+
const values = d.values.map(([timestamp, value])=>{
|
|
148
|
+
const val = value === null ? '-' : value; // echarts use '-' to represent null data
|
|
149
|
+
return [
|
|
150
|
+
isLocalTimeZone ? timestamp : (0, _dateFnsTz.utcToZonedTime)(timestamp, timeZone),
|
|
151
|
+
val
|
|
152
|
+
];
|
|
153
|
+
});
|
|
154
|
+
dataset.push({
|
|
155
|
+
id: index,
|
|
156
|
+
source: [
|
|
157
|
+
...values
|
|
158
|
+
],
|
|
159
|
+
dimensions: [
|
|
160
|
+
'time',
|
|
161
|
+
'value'
|
|
162
|
+
]
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
var _rangeMs;
|
|
166
|
+
const option = {
|
|
167
|
+
dataset: dataset,
|
|
168
|
+
series: seriesMapping,
|
|
169
|
+
xAxis: {
|
|
170
|
+
type: 'time',
|
|
171
|
+
min: isLocalTimeZone ? timeScale.startMs : (0, _dateFnsTz.utcToZonedTime)(timeScale.startMs, timeZone),
|
|
172
|
+
max: isLocalTimeZone ? timeScale.endMs : (0, _dateFnsTz.utcToZonedTime)(timeScale.endMs, timeZone),
|
|
173
|
+
axisLabel: {
|
|
174
|
+
hideOverlap: true,
|
|
175
|
+
formatter: (0, _utils.getFormattedAxisLabel)((_rangeMs = timeScale.rangeMs) !== null && _rangeMs !== void 0 ? _rangeMs : 0)
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
yAxis: (0, _utils.getYAxes)(yAxis, unit),
|
|
179
|
+
animation: false,
|
|
180
|
+
tooltip: {
|
|
181
|
+
show: true,
|
|
182
|
+
trigger: 'axis',
|
|
183
|
+
showContent: false
|
|
184
|
+
},
|
|
185
|
+
// https://echarts.apache.org/en/option.html#axisPointer
|
|
186
|
+
axisPointer: {
|
|
187
|
+
type: 'line',
|
|
188
|
+
z: 0,
|
|
189
|
+
triggerEmphasis: false,
|
|
190
|
+
triggerTooltip: false,
|
|
191
|
+
snap: true
|
|
192
|
+
},
|
|
193
|
+
toolbox: {
|
|
194
|
+
feature: {
|
|
195
|
+
dataZoom: {
|
|
196
|
+
icon: null,
|
|
197
|
+
yAxisIndex: 'none'
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
grid
|
|
202
|
+
};
|
|
203
|
+
if (__experimentalEChartsOptionsOverride) {
|
|
204
|
+
return __experimentalEChartsOptionsOverride(option);
|
|
205
|
+
}
|
|
206
|
+
return option;
|
|
207
|
+
}, [
|
|
208
|
+
data,
|
|
209
|
+
seriesMapping,
|
|
210
|
+
timeScale,
|
|
211
|
+
yAxis,
|
|
212
|
+
unit,
|
|
213
|
+
grid,
|
|
214
|
+
noDataOption,
|
|
215
|
+
__experimentalEChartsOptionsOverride,
|
|
216
|
+
noDataVariant,
|
|
217
|
+
timeZone
|
|
218
|
+
]);
|
|
219
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
220
|
+
sx: {
|
|
221
|
+
height
|
|
222
|
+
},
|
|
223
|
+
onClick: (e)=>{
|
|
224
|
+
// Pin and unpin when clicking on chart canvas but not tooltip text.
|
|
225
|
+
if (e.target instanceof HTMLCanvasElement) {
|
|
226
|
+
setTooltipPinnedCoords((current)=>{
|
|
227
|
+
if (current === null) {
|
|
228
|
+
return {
|
|
229
|
+
page: {
|
|
230
|
+
x: e.pageX,
|
|
231
|
+
y: e.pageY
|
|
232
|
+
},
|
|
233
|
+
client: {
|
|
234
|
+
x: e.clientX,
|
|
235
|
+
y: e.clientY
|
|
236
|
+
},
|
|
237
|
+
plotCanvas: {
|
|
238
|
+
x: e.nativeEvent.offsetX,
|
|
239
|
+
y: e.nativeEvent.offsetY
|
|
240
|
+
},
|
|
241
|
+
target: e.target
|
|
242
|
+
};
|
|
243
|
+
} else {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
onMouseDown: (e)=>{
|
|
250
|
+
const { clientX } = e;
|
|
251
|
+
setIsDragging(true);
|
|
252
|
+
setStartX(clientX);
|
|
253
|
+
},
|
|
254
|
+
onMouseMove: (e)=>{
|
|
255
|
+
// Allow clicking inside tooltip to copy labels.
|
|
256
|
+
if (!(e.target instanceof HTMLCanvasElement)) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const { clientX } = e;
|
|
260
|
+
if (isDragging) {
|
|
261
|
+
const deltaX = clientX - startX;
|
|
262
|
+
if (deltaX > 0) {
|
|
263
|
+
// Hide tooltip when user drags to zoom.
|
|
264
|
+
setShowTooltip(false);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
onMouseUp: ()=>{
|
|
269
|
+
setIsDragging(false);
|
|
270
|
+
setStartX(0);
|
|
271
|
+
setShowTooltip(true);
|
|
272
|
+
},
|
|
273
|
+
onMouseLeave: ()=>{
|
|
274
|
+
if (tooltipPinnedCoords === null) {
|
|
275
|
+
setShowTooltip(false);
|
|
276
|
+
}
|
|
277
|
+
if (chartRef.current !== undefined) {
|
|
278
|
+
(0, _utils.clearHighlightedSeries)(chartRef.current, totalSeries);
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
onMouseEnter: ()=>{
|
|
282
|
+
setShowTooltip(true);
|
|
283
|
+
if (chartRef.current !== undefined) {
|
|
284
|
+
(0, _utils.enableDataZoom)(chartRef.current);
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
onDoubleClick: (e)=>{
|
|
288
|
+
setTooltipPinnedCoords(null);
|
|
289
|
+
// either dispatch ECharts restore action to return to orig state or allow consumer to define behavior
|
|
290
|
+
if (onDoubleClick === undefined) {
|
|
291
|
+
if (chartRef.current !== undefined) {
|
|
292
|
+
(0, _utils.restoreChart)(chartRef.current);
|
|
293
|
+
}
|
|
294
|
+
} else {
|
|
295
|
+
onDoubleClick(e);
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
children: [
|
|
299
|
+
showTooltip === true && ((ref1 = option.tooltip) === null || ref1 === void 0 ? void 0 : ref1.showContent) === false && tooltipConfig.hidden !== true && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeSeriesTooltip.TimeChartTooltip, {
|
|
300
|
+
chartRef: chartRef,
|
|
301
|
+
data: data,
|
|
302
|
+
seriesMapping: seriesMapping,
|
|
303
|
+
wrapLabels: tooltipConfig.wrapLabels,
|
|
304
|
+
pinnedPos: tooltipPinnedCoords,
|
|
305
|
+
unit: unit
|
|
306
|
+
}),
|
|
307
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_echart.EChart, {
|
|
308
|
+
sx: {
|
|
309
|
+
width: '100%',
|
|
310
|
+
height: '100%'
|
|
311
|
+
},
|
|
312
|
+
option: option,
|
|
313
|
+
theme: chartsTheme.echartsTheme,
|
|
314
|
+
onEvents: handleEvents,
|
|
315
|
+
_instance: chartRef,
|
|
316
|
+
syncGroup: syncGroup
|
|
317
|
+
})
|
|
318
|
+
]
|
|
319
|
+
});
|
|
320
|
+
});
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
_exportStar(require("./
|
|
17
|
+
_exportStar(require("./TimeChart"), exports);
|
|
18
18
|
function _exportStar(from, to) {
|
|
19
19
|
Object.keys(from).forEach(function(k) {
|
|
20
20
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|