@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
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
-
import {
|
|
15
|
-
import { UNIT_CONFIG, isUnitWithDecimalPlaces, isUnitWithAbbreviate } from '
|
|
16
|
-
import { shouldAbbreviate } from '../model/units/utils';
|
|
14
|
+
import { Switch } from '@mui/material';
|
|
15
|
+
import { shouldAbbreviate, UNIT_CONFIG, isUnitWithDecimalPlaces, isUnitWithAbbreviate } from '@perses-dev/core';
|
|
17
16
|
import { OptionsEditorControl } from '../OptionsEditorLayout';
|
|
17
|
+
import { SettingsAutocomplete } from '../SettingsAutocomplete';
|
|
18
18
|
const KIND_OPTIONS = Object.entries(UNIT_CONFIG).map(([id, config])=>{
|
|
19
19
|
return {
|
|
20
20
|
id: id,
|
|
@@ -23,26 +23,32 @@ const KIND_OPTIONS = Object.entries(UNIT_CONFIG).map(([id, config])=>{
|
|
|
23
23
|
}).filter((config)=>!config.disableSelectorOption);
|
|
24
24
|
const DECIMAL_PLACES_OPTIONS = [
|
|
25
25
|
{
|
|
26
|
+
id: 'default',
|
|
26
27
|
label: 'Default',
|
|
27
28
|
decimal_places: undefined
|
|
28
29
|
},
|
|
29
30
|
{
|
|
31
|
+
id: '0',
|
|
30
32
|
label: '0',
|
|
31
33
|
decimal_places: 0
|
|
32
34
|
},
|
|
33
35
|
{
|
|
36
|
+
id: '1',
|
|
34
37
|
label: '1',
|
|
35
38
|
decimal_places: 1
|
|
36
39
|
},
|
|
37
40
|
{
|
|
41
|
+
id: '2',
|
|
38
42
|
label: '2',
|
|
39
43
|
decimal_places: 2
|
|
40
44
|
},
|
|
41
45
|
{
|
|
46
|
+
id: '3',
|
|
42
47
|
label: '3',
|
|
43
48
|
decimal_places: 3
|
|
44
49
|
},
|
|
45
50
|
{
|
|
51
|
+
id: '4',
|
|
46
52
|
label: '4',
|
|
47
53
|
decimal_places: 4
|
|
48
54
|
}
|
|
@@ -87,42 +93,23 @@ export function UnitSelector({ value , onChange }) {
|
|
|
87
93
|
}),
|
|
88
94
|
/*#__PURE__*/ _jsx(OptionsEditorControl, {
|
|
89
95
|
label: "Unit",
|
|
90
|
-
control: /*#__PURE__*/ _jsx(
|
|
96
|
+
control: /*#__PURE__*/ _jsx(SettingsAutocomplete, {
|
|
91
97
|
value: {
|
|
92
98
|
id: value.kind,
|
|
93
99
|
...kindConfig
|
|
94
100
|
},
|
|
95
101
|
options: KIND_OPTIONS,
|
|
96
|
-
isOptionEqualToValue: (option, value)=>option.id === value.id,
|
|
97
102
|
groupBy: (option)=>option.group,
|
|
98
|
-
renderInput: (params)=>/*#__PURE__*/ _jsx(TextField, {
|
|
99
|
-
...params
|
|
100
|
-
}),
|
|
101
|
-
renderOption: (renderOptsProps, option)=>{
|
|
102
|
-
// Custom option needed to get some increased left padding to make
|
|
103
|
-
// the items more distinct from the group label.
|
|
104
|
-
return /*#__PURE__*/ _jsx("li", {
|
|
105
|
-
...renderOptsProps,
|
|
106
|
-
children: /*#__PURE__*/ _jsx(Box, {
|
|
107
|
-
paddingLeft: (theme)=>theme.spacing(1),
|
|
108
|
-
children: option.label
|
|
109
|
-
})
|
|
110
|
-
});
|
|
111
|
-
},
|
|
112
103
|
onChange: handleKindChange,
|
|
113
104
|
disableClearable: true
|
|
114
105
|
})
|
|
115
106
|
}),
|
|
116
107
|
/*#__PURE__*/ _jsx(OptionsEditorControl, {
|
|
117
108
|
label: "Decimals",
|
|
118
|
-
control: /*#__PURE__*/ _jsx(
|
|
109
|
+
control: /*#__PURE__*/ _jsx(SettingsAutocomplete, {
|
|
119
110
|
value: getOptionByDecimalPlaces(value.decimal_places),
|
|
120
111
|
options: DECIMAL_PLACES_OPTIONS,
|
|
121
112
|
getOptionLabel: (o)=>o.label,
|
|
122
|
-
isOptionEqualToValue: (option, value)=>option.label === value.label,
|
|
123
|
-
renderInput: (params)=>/*#__PURE__*/ _jsx(TextField, {
|
|
124
|
-
...params
|
|
125
|
-
}),
|
|
126
113
|
onChange: handleDecimalPlacesChange,
|
|
127
114
|
disabled: !hasDecimalPlaces,
|
|
128
115
|
disableClearable: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/UnitSelector/UnitSelector.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/UnitSelector/UnitSelector.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { Switch, SwitchProps } from '@mui/material';\nimport {\n shouldAbbreviate,\n UnitOptions,\n UNIT_CONFIG,\n UnitConfig,\n isUnitWithDecimalPlaces,\n isUnitWithAbbreviate,\n} from '@perses-dev/core';\nimport { OptionsEditorControl } from '../OptionsEditorLayout';\nimport { SettingsAutocomplete } from '../SettingsAutocomplete';\n\nexport interface UnitSelectorProps {\n value: UnitOptions;\n onChange: (unit: UnitOptions) => void;\n}\n\ntype AutocompleteKindOption = UnitConfig & { id: UnitOptions['kind'] };\n\nconst KIND_OPTIONS: AutocompleteKindOption[] = Object.entries(UNIT_CONFIG)\n .map(([id, config]) => {\n return {\n id: id as UnitOptions['kind'],\n ...config,\n };\n })\n .filter((config) => !config.disableSelectorOption);\n\nconst DECIMAL_PLACES_OPTIONS = [\n { id: 'default', label: 'Default', decimal_places: undefined },\n { id: '0', label: '0', decimal_places: 0 },\n { id: '1', label: '1', decimal_places: 1 },\n { id: '2', label: '2', decimal_places: 2 },\n { id: '3', label: '3', decimal_places: 3 },\n { id: '4', label: '4', decimal_places: 4 },\n];\n\nfunction getOptionByDecimalPlaces(decimal_places?: number) {\n return DECIMAL_PLACES_OPTIONS.find((o) => o.decimal_places === decimal_places);\n}\n\nexport function UnitSelector({ value, onChange }: UnitSelectorProps) {\n const hasDecimalPlaces = isUnitWithDecimalPlaces(value);\n const hasAbbreviate = isUnitWithAbbreviate(value);\n\n const handleKindChange = (_: unknown, newValue: AutocompleteKindOption) => {\n onChange({\n kind: newValue.id,\n });\n };\n\n const handleDecimalPlacesChange = (_: unknown, { decimal_places }: { decimal_places: number | undefined }) => {\n if (hasDecimalPlaces) {\n onChange({\n ...value,\n decimal_places: decimal_places,\n });\n }\n };\n\n const handleAbbreviateChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n if (hasAbbreviate) {\n onChange({\n ...value,\n abbreviate: checked,\n });\n }\n };\n\n const kindConfig = UNIT_CONFIG[value.kind];\n\n return (\n <>\n <OptionsEditorControl\n label=\"Abbreviate\"\n control={\n <Switch\n checked={hasAbbreviate ? shouldAbbreviate(value.abbreviate) : false}\n onChange={handleAbbreviateChange}\n disabled={!hasAbbreviate}\n />\n }\n />\n <OptionsEditorControl\n label=\"Unit\"\n control={\n <SettingsAutocomplete\n value={{ id: value.kind, ...kindConfig }}\n options={KIND_OPTIONS}\n groupBy={(option) => option.group}\n onChange={handleKindChange}\n disableClearable\n ></SettingsAutocomplete>\n }\n />\n <OptionsEditorControl\n label=\"Decimals\"\n control={\n <SettingsAutocomplete\n value={getOptionByDecimalPlaces(value.decimal_places)}\n options={DECIMAL_PLACES_OPTIONS}\n getOptionLabel={(o) => o.label}\n onChange={handleDecimalPlacesChange}\n disabled={!hasDecimalPlaces}\n disableClearable\n />\n }\n />\n </>\n );\n}\n"],"names":["Switch","shouldAbbreviate","UNIT_CONFIG","isUnitWithDecimalPlaces","isUnitWithAbbreviate","OptionsEditorControl","SettingsAutocomplete","KIND_OPTIONS","Object","entries","map","id","config","filter","disableSelectorOption","DECIMAL_PLACES_OPTIONS","label","decimal_places","undefined","getOptionByDecimalPlaces","find","o","UnitSelector","value","onChange","hasDecimalPlaces","hasAbbreviate","handleKindChange","_","newValue","kind","handleDecimalPlacesChange","handleAbbreviateChange","checked","abbreviate","kindConfig","control","disabled","options","groupBy","option","group","disableClearable","getOptionLabel"],"mappings":"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"}
|
package/dist/YAxisLabel.js
CHANGED
|
@@ -18,7 +18,7 @@ export function YAxisLabel({ name , height }) {
|
|
|
18
18
|
display: 'inline-block',
|
|
19
19
|
maxWidth: height,
|
|
20
20
|
position: 'absolute',
|
|
21
|
-
top:
|
|
21
|
+
top: `calc(${height}px / 2)`,
|
|
22
22
|
transform: 'translateX(-50%) rotate(-90deg)',
|
|
23
23
|
transformOrigin: 'top',
|
|
24
24
|
textAlign: 'center',
|
package/dist/YAxisLabel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/YAxisLabel.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, Typography } from '@mui/material';\n\ninterface YAxisLabelProps {\n name: string;\n height: number;\n}\n\nexport function YAxisLabel({ name, height }: YAxisLabelProps) {\n return (\n <Box\n sx={{\n display: 'inline-block',\n maxWidth: height, // allows rotated text to truncate instead of causing overlap\n position: 'absolute',\n top:
|
|
1
|
+
{"version":3,"sources":["../src/YAxisLabel.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, Typography } from '@mui/material';\n\ninterface YAxisLabelProps {\n name: string;\n height: number;\n}\n\nexport function YAxisLabel({ name, height }: YAxisLabelProps) {\n return (\n <Box\n sx={{\n display: 'inline-block',\n maxWidth: height, // allows rotated text to truncate instead of causing overlap\n position: 'absolute',\n top: `calc(${height}px / 2)`,\n transform: 'translateX(-50%) rotate(-90deg)',\n transformOrigin: 'top',\n textAlign: 'center',\n zIndex: 1,\n }}\n >\n <Typography\n variant=\"body1\"\n aria-label=\"y axis label\"\n sx={{\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n {name}\n </Typography>\n </Box>\n );\n}\n"],"names":["Box","Typography","YAxisLabel","name","height","sx","display","maxWidth","position","top","transform","transformOrigin","textAlign","zIndex","variant","aria-label","whiteSpace","overflow","textOverflow"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAOhD,OAAO,SAASC,UAAU,CAAC,EAAEC,IAAI,CAAA,EAAEC,MAAM,CAAA,EAAmB,EAAE;IAC5D,qBACE,KAACJ,GAAG;QACFK,EAAE,EAAE;YACFC,OAAO,EAAE,cAAc;YACvBC,QAAQ,EAAEH,MAAM;YAChBI,QAAQ,EAAE,UAAU;YACpBC,GAAG,EAAE,CAAC,KAAK,EAAEL,MAAM,CAAC,OAAO,CAAC;YAC5BM,SAAS,EAAE,iCAAiC;YAC5CC,eAAe,EAAE,KAAK;YACtBC,SAAS,EAAE,QAAQ;YACnBC,MAAM,EAAE,CAAC;SACV;kBAED,cAAA,KAACZ,UAAU;YACTa,OAAO,EAAC,OAAO;YACfC,YAAU,EAAC,cAAc;YACzBV,EAAE,EAAE;gBACFW,UAAU,EAAE,QAAQ;gBACpBC,QAAQ,EAAE,QAAQ;gBAClBC,YAAY,EAAE,UAAU;aACzB;sBAEAf,IAAI;UACM;MACT,CACN;AACJ,CAAC"}
|
|
@@ -21,6 +21,7 @@ Object.defineProperty(exports, "ContentWithLegend", {
|
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _react = /*#__PURE__*/ _interopRequireDefault(require("react"));
|
|
23
23
|
const _material = require("@mui/material");
|
|
24
|
+
const _core = require("@perses-dev/core");
|
|
24
25
|
const _legend = require("../Legend");
|
|
25
26
|
const _contentWithLegendModel = require("./model/content-with-legend-model");
|
|
26
27
|
function _interopRequireDefault(obj) {
|
|
@@ -28,16 +29,17 @@ function _interopRequireDefault(obj) {
|
|
|
28
29
|
default: obj
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
|
-
function ContentWithLegend({ children , legendProps , width , height , spacing =0 , minChildrenWidth =100 , minChildrenHeight =100 }) {
|
|
32
|
+
function ContentWithLegend({ children , legendProps , width , height , spacing =0 , legendSize , minChildrenWidth =100 , minChildrenHeight =100 }) {
|
|
32
33
|
const theme = (0, _material.useTheme)();
|
|
33
34
|
const { content , legend , margin } = (0, _contentWithLegendModel.getContentWithLegendLayout)({
|
|
34
35
|
width,
|
|
35
36
|
height,
|
|
36
|
-
|
|
37
|
+
legendProps,
|
|
37
38
|
minChildrenHeight,
|
|
38
39
|
minChildrenWidth,
|
|
39
40
|
spacing,
|
|
40
|
-
theme
|
|
41
|
+
theme,
|
|
42
|
+
legendSize: (0, _core.getLegendSize)(legendSize)
|
|
41
43
|
});
|
|
42
44
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
43
45
|
sx: {
|
|
@@ -24,18 +24,27 @@ _export(exports, {
|
|
|
24
24
|
TABLE_LEGEND_SIZE: ()=>TABLE_LEGEND_SIZE,
|
|
25
25
|
getContentWithLegendLayout: ()=>getContentWithLegendLayout
|
|
26
26
|
});
|
|
27
|
+
const _core = require("@perses-dev/core");
|
|
27
28
|
const _table = require("../../Table");
|
|
28
|
-
const _legend = require("../../model/legend");
|
|
29
29
|
const TABLE_LEGEND_SIZE = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
Medium: {
|
|
31
|
+
// 5 rows plus header. Value to be multiplied by row height in pixels.
|
|
32
|
+
Bottom: 6,
|
|
33
|
+
// Pixel value
|
|
34
|
+
Right: 250
|
|
35
|
+
},
|
|
36
|
+
Small: {
|
|
37
|
+
// 3 rows plus header. Value to be multiplied by row height in pixels.
|
|
38
|
+
Bottom: 4,
|
|
39
|
+
// Pixel value
|
|
40
|
+
Right: 150
|
|
41
|
+
}
|
|
34
42
|
};
|
|
35
43
|
const PANEL_HEIGHT_LG_BREAKPOINT = 300;
|
|
36
44
|
const LEGEND_HEIGHT_SM = 40;
|
|
37
45
|
const LEGEND_HEIGHT_LG = 100;
|
|
38
|
-
function getContentWithLegendLayout({ width , height ,
|
|
46
|
+
function getContentWithLegendLayout({ width , height , legendProps , legendSize , minChildrenHeight , minChildrenWidth , spacing , theme }) {
|
|
47
|
+
const legendOptions = legendProps === null || legendProps === void 0 ? void 0 : legendProps.options;
|
|
39
48
|
const hasLegend = !!legendOptions;
|
|
40
49
|
const noLegendLayout = {
|
|
41
50
|
legend: {
|
|
@@ -56,7 +65,7 @@ function getContentWithLegendLayout({ width , height , legendOptions , minChildr
|
|
|
56
65
|
return noLegendLayout;
|
|
57
66
|
}
|
|
58
67
|
const { position } = legendOptions;
|
|
59
|
-
const mode = (0,
|
|
68
|
+
const mode = (0, _core.getLegendMode)(legendOptions.mode);
|
|
60
69
|
let legendWidth;
|
|
61
70
|
let legendHeight;
|
|
62
71
|
if (mode === 'List') {
|
|
@@ -71,10 +80,20 @@ function getContentWithLegendLayout({ width , height , legendOptions , minChildr
|
|
|
71
80
|
legendHeight = LEGEND_HEIGHT_LG;
|
|
72
81
|
}
|
|
73
82
|
} else {
|
|
83
|
+
var ref;
|
|
74
84
|
// Table mode
|
|
75
85
|
const tableLayout = (0, _table.getTableCellLayout)(theme, 'compact');
|
|
76
|
-
|
|
77
|
-
|
|
86
|
+
const tableColumns = (legendProps === null || legendProps === void 0 ? void 0 : (ref = legendProps.tableProps) === null || ref === void 0 ? void 0 : ref.columns) || [];
|
|
87
|
+
const columnsWidth = tableColumns.reduce((total, col)=>{
|
|
88
|
+
if (typeof col.width === 'number') {
|
|
89
|
+
total += col.width;
|
|
90
|
+
}
|
|
91
|
+
return total;
|
|
92
|
+
}, 0);
|
|
93
|
+
legendWidth = position === 'Right' ? TABLE_LEGEND_SIZE[legendSize]['Right'] + columnsWidth : width;
|
|
94
|
+
// Use the smaller of the size-based row count or the number of legend items + 1 for the header.
|
|
95
|
+
const rowsToShow = Math.min(TABLE_LEGEND_SIZE[legendSize]['Bottom'], legendProps.data.length + 1);
|
|
96
|
+
legendHeight = position === 'Bottom' ? rowsToShow * tableLayout.height : height;
|
|
78
97
|
}
|
|
79
98
|
const contentWidth = position === 'Right' ? width - legendWidth - spacing : width;
|
|
80
99
|
const contentHeight = position === 'Bottom' ? height - legendHeight - spacing : height;
|
|
@@ -21,7 +21,7 @@ Object.defineProperty(exports, "Drawer", {
|
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _material = require("@mui/material");
|
|
23
23
|
const _utils = require("../utils");
|
|
24
|
-
const DRAWER_DEFAULT_WIDTH =
|
|
24
|
+
const DRAWER_DEFAULT_WIDTH = 1080;
|
|
25
25
|
const Drawer = ({ anchor ='right' , isOpen , onClose , PaperProps , children , ...rest })=>{
|
|
26
26
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Drawer, {
|
|
27
27
|
...rest,
|
|
@@ -22,7 +22,13 @@ const _jsxRuntime = require("react/jsx-runtime");
|
|
|
22
22
|
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
23
23
|
const _core = require("echarts/core");
|
|
24
24
|
const _material = require("@mui/material");
|
|
25
|
-
const
|
|
25
|
+
const _isEqual = /*#__PURE__*/ _interopRequireDefault(require("lodash/isEqual"));
|
|
26
|
+
const _debounce = /*#__PURE__*/ _interopRequireDefault(require("lodash/debounce"));
|
|
27
|
+
function _interopRequireDefault(obj) {
|
|
28
|
+
return obj && obj.__esModule ? obj : {
|
|
29
|
+
default: obj
|
|
30
|
+
};
|
|
31
|
+
}
|
|
26
32
|
function _getRequireWildcardCache(nodeInterop) {
|
|
27
33
|
if (typeof WeakMap !== "function") return null;
|
|
28
34
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -78,7 +84,7 @@ const batchEvents = [
|
|
|
78
84
|
'downplay',
|
|
79
85
|
'highlight'
|
|
80
86
|
];
|
|
81
|
-
const EChart = /*#__PURE__*/ _react.default.memo(function EChart({ option , theme , renderer , sx , onEvents , _instance , onChartInitialized }) {
|
|
87
|
+
const EChart = /*#__PURE__*/ _react.default.memo(function EChart({ option , theme , renderer , sx , onEvents , _instance , syncGroup , onChartInitialized }) {
|
|
82
88
|
const initialOption = (0, _react.useRef)(option);
|
|
83
89
|
const prevOption = (0, _react.useRef)(option);
|
|
84
90
|
const containerRef = (0, _react.useRef)(null);
|
|
@@ -106,9 +112,20 @@ const EChart = /*#__PURE__*/ _react.default.memo(function EChart({ option , them
|
|
|
106
112
|
theme,
|
|
107
113
|
renderer
|
|
108
114
|
]);
|
|
115
|
+
// When syncGroup is explicitly set, charts within same group share interactions such as crosshair
|
|
116
|
+
(0, _react.useEffect)(()=>{
|
|
117
|
+
if (!chartElement.current || !syncGroup) return;
|
|
118
|
+
chartElement.current.group = syncGroup;
|
|
119
|
+
(0, _core.connect)([
|
|
120
|
+
chartElement.current
|
|
121
|
+
]); // more info: https://echarts.apache.org/en/api.html#echarts.connect
|
|
122
|
+
}, [
|
|
123
|
+
syncGroup,
|
|
124
|
+
chartElement
|
|
125
|
+
]);
|
|
109
126
|
// Update chart data when option changes
|
|
110
127
|
(0, _react.useEffect)(()=>{
|
|
111
|
-
if (prevOption.current === undefined || (0,
|
|
128
|
+
if (prevOption.current === undefined || (0, _isEqual.default)(prevOption.current, option)) return;
|
|
112
129
|
if (!chartElement.current) return;
|
|
113
130
|
chartElement.current.setOption(option, true);
|
|
114
131
|
prevOption.current = option;
|
|
@@ -117,7 +134,7 @@ const EChart = /*#__PURE__*/ _react.default.memo(function EChart({ option , them
|
|
|
117
134
|
]);
|
|
118
135
|
// Resize chart, cleanup listener on unmount
|
|
119
136
|
(0, _react.useLayoutEffect)(()=>{
|
|
120
|
-
const updateSize = (0,
|
|
137
|
+
const updateSize = (0, _debounce.default)(()=>{
|
|
121
138
|
if (!chartElement.current) return;
|
|
122
139
|
chartElement.current.resize();
|
|
123
140
|
}, 200);
|
|
@@ -149,7 +166,7 @@ const EChart = /*#__PURE__*/ _react.default.memo(function EChart({ option , them
|
|
|
149
166
|
(0, _react.useEffect)(()=>{
|
|
150
167
|
// TODO: fix this debouncing. This likely isn't working as intended because
|
|
151
168
|
// the debounced function is re-created every time this useEffect is called.
|
|
152
|
-
const updateSize = (0,
|
|
169
|
+
const updateSize = (0, _debounce.default)(()=>{
|
|
153
170
|
if (!chartElement.current) return;
|
|
154
171
|
chartElement.current.resize();
|
|
155
172
|
}, 200, {
|
|
@@ -31,7 +31,6 @@ const _charts = require("echarts/charts");
|
|
|
31
31
|
const _components = require("echarts/components");
|
|
32
32
|
const _renderers = require("echarts/renderers");
|
|
33
33
|
const _chartsThemeProvider = require("../context/ChartsThemeProvider");
|
|
34
|
-
const _units = require("../model/units");
|
|
35
34
|
const _echart = require("../EChart");
|
|
36
35
|
(0, _core1.use)([
|
|
37
36
|
_charts.GaugeChart,
|
|
@@ -49,7 +48,7 @@ function GaugeChart(props) {
|
|
|
49
48
|
// useDeepMemo ensures value size util does not rerun everytime you hover on the chart
|
|
50
49
|
const option = (0, _core.useDeepMemo)(()=>{
|
|
51
50
|
var ref;
|
|
52
|
-
if (data.value === undefined
|
|
51
|
+
if (data.value === undefined) return chartsTheme.noDataOption;
|
|
53
52
|
// adjusts fontSize depending on number of characters
|
|
54
53
|
const valueSizeClamp = getResponsiveValueSize(data.value, unit, width, height);
|
|
55
54
|
var ref1;
|
|
@@ -167,8 +166,11 @@ function GaugeChart(props) {
|
|
|
167
166
|
],
|
|
168
167
|
color: 'inherit',
|
|
169
168
|
fontSize: valueSizeClamp,
|
|
170
|
-
formatter:
|
|
171
|
-
|
|
169
|
+
formatter: data.value === null ? // at this level because the `formatter` function argument is `NaN`
|
|
170
|
+
// when the value is `null`, making it difficult to differentiate
|
|
171
|
+
// `null` from a true `NaN` case.
|
|
172
|
+
()=>'null' : (value)=>{
|
|
173
|
+
return (0, _core.formatValue)(value, unit);
|
|
172
174
|
}
|
|
173
175
|
},
|
|
174
176
|
data: [
|
|
@@ -216,7 +218,7 @@ function getResponsiveValueSize(value, unit, width, height) {
|
|
|
216
218
|
const MIN_SIZE = 3;
|
|
217
219
|
const MAX_SIZE = 24;
|
|
218
220
|
const SIZE_MULTIPLIER = 0.7;
|
|
219
|
-
const formattedValue = (0,
|
|
221
|
+
const formattedValue = typeof value === 'number' ? (0, _core.formatValue)(value, unit) : `${value}`;
|
|
220
222
|
var _length;
|
|
221
223
|
const valueCharacters = (_length = formattedValue.length) !== null && _length !== void 0 ? _length : 2;
|
|
222
224
|
const valueSize = Math.min(width, height) / valueCharacters * SIZE_MULTIPLIER;
|
|
@@ -20,9 +20,9 @@ Object.defineProperty(exports, "CompactLegend", {
|
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _material = require("@mui/material");
|
|
23
|
-
const _model = require("../model");
|
|
24
23
|
const _listLegendItem = require("./ListLegendItem");
|
|
25
|
-
|
|
24
|
+
const _legendModel = require("./legend-model");
|
|
25
|
+
function CompactLegend({ height , items , selectedItems , onLegendItemClick , onItemMouseOver , onItemMouseOut }) {
|
|
26
26
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
27
27
|
component: "ul",
|
|
28
28
|
sx: {
|
|
@@ -37,9 +37,12 @@ function CompactLegend({ height , items , selectedItems , onLegendItemClick })
|
|
|
37
37
|
overflowY: 'scroll',
|
|
38
38
|
margin: 0
|
|
39
39
|
},
|
|
40
|
-
children: items.map((item)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_listLegendItem.ListLegendItem, {
|
|
40
|
+
children: items.map((item, index)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_listLegendItem.ListLegendItem, {
|
|
41
41
|
item: item,
|
|
42
|
-
|
|
42
|
+
index: index,
|
|
43
|
+
isVisuallySelected: (0, _legendModel.isLegendItemVisuallySelected)(item, selectedItems),
|
|
44
|
+
onMouseOver: onItemMouseOver,
|
|
45
|
+
onMouseOut: onItemMouseOut,
|
|
43
46
|
onClick: onLegendItemClick,
|
|
44
47
|
sx: {
|
|
45
48
|
width: 'auto',
|
|
@@ -21,7 +21,7 @@ Object.defineProperty(exports, "Legend", {
|
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _material = require("@mui/material");
|
|
23
23
|
const _immer = require("immer");
|
|
24
|
-
const
|
|
24
|
+
const _core = require("@perses-dev/core");
|
|
25
25
|
const _listLegend = require("./ListLegend");
|
|
26
26
|
const _compactLegend = require("./CompactLegend");
|
|
27
27
|
const _tableLegend = require("./TableLegend");
|
|
@@ -31,7 +31,7 @@ const _tableLegend = require("./TableLegend");
|
|
|
31
31
|
// Set this number based on testing, but it may need to be tuned a bit on the
|
|
32
32
|
// future as people test this out on different machines.
|
|
33
33
|
const NEED_VIRTUALIZATION_LIMIT = 500;
|
|
34
|
-
function Legend({ width , height , options , data , selectedItems , onSelectedItemsChange }) {
|
|
34
|
+
function Legend({ width , height , options , data , selectedItems , onSelectedItemsChange , onItemMouseOver , onItemMouseOut , tableProps }) {
|
|
35
35
|
const onLegendItemClick = (e, seriesId)=>{
|
|
36
36
|
const isModifiedClick = e.metaKey || e.shiftKey;
|
|
37
37
|
const newSelected = (0, _immer.produce)(selectedItems, (draft)=>{
|
|
@@ -64,7 +64,7 @@ function Legend({ width , height , options , data , selectedItems , onSelectedIt
|
|
|
64
64
|
});
|
|
65
65
|
onSelectedItemsChange(newSelected);
|
|
66
66
|
};
|
|
67
|
-
const mode = (0,
|
|
67
|
+
const mode = (0, _core.getLegendMode)(options.mode);
|
|
68
68
|
// The bottom legend is displayed as a list when the number of items is too
|
|
69
69
|
// large and requires virtualization. Otherwise, it is rendered more compactly.
|
|
70
70
|
// We do not need this check for the right-side legend because it is always
|
|
@@ -74,14 +74,17 @@ function Legend({ width , height , options , data , selectedItems , onSelectedIt
|
|
|
74
74
|
height,
|
|
75
75
|
items: data,
|
|
76
76
|
selectedItems,
|
|
77
|
-
onLegendItemClick
|
|
77
|
+
onLegendItemClick,
|
|
78
|
+
onItemMouseOver,
|
|
79
|
+
onItemMouseOut
|
|
78
80
|
};
|
|
79
81
|
let legendContent;
|
|
80
82
|
if (mode === 'Table') {
|
|
81
83
|
legendContent = /*#__PURE__*/ (0, _jsxRuntime.jsx)(_tableLegend.TableLegend, {
|
|
82
84
|
...commonLegendProps,
|
|
83
85
|
onSelectedItemsChange: onSelectedItemsChange,
|
|
84
|
-
width: width
|
|
86
|
+
width: width,
|
|
87
|
+
...tableProps
|
|
85
88
|
});
|
|
86
89
|
} else if (options.position === 'Right' || needsVirtualization) {
|
|
87
90
|
legendContent = /*#__PURE__*/ (0, _jsxRuntime.jsx)(_listLegend.ListLegend, {
|
|
@@ -20,9 +20,9 @@ Object.defineProperty(exports, "ListLegend", {
|
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _reactVirtuoso = require("react-virtuoso");
|
|
23
|
-
const _model = require("../model");
|
|
24
23
|
const _listLegendItem = require("./ListLegendItem");
|
|
25
|
-
|
|
24
|
+
const _legendModel = require("./legend-model");
|
|
25
|
+
function ListLegend({ items , height , width , selectedItems , onLegendItemClick , onItemMouseOver , onItemMouseOut }) {
|
|
26
26
|
// show full labels on hover when there are many total series
|
|
27
27
|
const truncateLabels = items.length > 5;
|
|
28
28
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_reactVirtuoso.Virtuoso, {
|
|
@@ -34,13 +34,14 @@ function ListLegend({ items , height , width , selectedItems , onLegendItemClick
|
|
|
34
34
|
itemContent: (index, item)=>{
|
|
35
35
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_listLegendItem.ListLegendItem, {
|
|
36
36
|
item: item,
|
|
37
|
+
index: index,
|
|
37
38
|
truncateLabel: truncateLabels,
|
|
38
|
-
isVisuallySelected: (0,
|
|
39
|
+
isVisuallySelected: (0, _legendModel.isLegendItemVisuallySelected)(item, selectedItems),
|
|
39
40
|
onClick: onLegendItemClick,
|
|
41
|
+
onMouseOver: onItemMouseOver,
|
|
42
|
+
onMouseOut: onItemMouseOut,
|
|
40
43
|
sx: {
|
|
41
|
-
|
|
42
|
-
// work correctly. Subtract padding to simulate padding.
|
|
43
|
-
width: width,
|
|
44
|
+
width: '100%',
|
|
44
45
|
wordBreak: 'break-word',
|
|
45
46
|
overflow: 'hidden'
|
|
46
47
|
}
|
|
@@ -62,14 +62,14 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
62
62
|
}
|
|
63
63
|
return newObj;
|
|
64
64
|
}
|
|
65
|
-
const ListLegendItemBase = /*#__PURE__*/ (0, _react.forwardRef)(function ListLegendItem({ item , sx , truncateLabel , onClick , isVisuallySelected , ...others }, ref) {
|
|
65
|
+
const ListLegendItemBase = /*#__PURE__*/ (0, _react.forwardRef)(function ListLegendItem({ item , sx , truncateLabel , onClick , isVisuallySelected , onMouseOver , onMouseOut , index , ...others }, ref) {
|
|
66
66
|
const [noWrap, setNoWrap] = (0, _react.useState)(truncateLabel);
|
|
67
|
-
function
|
|
67
|
+
function handleTextMouseOver() {
|
|
68
68
|
if (truncateLabel) {
|
|
69
69
|
setNoWrap(false);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function handleTextMouseOut() {
|
|
73
73
|
if (truncateLabel) {
|
|
74
74
|
setNoWrap(true);
|
|
75
75
|
}
|
|
@@ -90,6 +90,18 @@ const ListLegendItemBase = /*#__PURE__*/ (0, _react.forwardRef)(function ListLeg
|
|
|
90
90
|
dense: true,
|
|
91
91
|
key: item.id,
|
|
92
92
|
onClick: handleClick,
|
|
93
|
+
onMouseOver: (e)=>{
|
|
94
|
+
return onMouseOver === null || onMouseOver === void 0 ? void 0 : onMouseOver(e, {
|
|
95
|
+
id: item.id,
|
|
96
|
+
index
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
onMouseOut: (e)=>{
|
|
100
|
+
return onMouseOut === null || onMouseOut === void 0 ? void 0 : onMouseOut(e, {
|
|
101
|
+
id: item.id,
|
|
102
|
+
index
|
|
103
|
+
});
|
|
104
|
+
},
|
|
93
105
|
selected: isVisuallySelected,
|
|
94
106
|
ref: ref,
|
|
95
107
|
children: [
|
|
@@ -107,8 +119,8 @@ const ListLegendItemBase = /*#__PURE__*/ (0, _react.forwardRef)(function ListLeg
|
|
|
107
119
|
primaryTypographyProps: {
|
|
108
120
|
noWrap: noWrap
|
|
109
121
|
},
|
|
110
|
-
onMouseOver:
|
|
111
|
-
onMouseOut:
|
|
122
|
+
onMouseOver: handleTextMouseOver,
|
|
123
|
+
onMouseOut: handleTextMouseOut
|
|
112
124
|
})
|
|
113
125
|
]
|
|
114
126
|
});
|
|
@@ -25,6 +25,7 @@ const COLUMNS = [
|
|
|
25
25
|
{
|
|
26
26
|
accessorKey: 'label',
|
|
27
27
|
header: 'Name',
|
|
28
|
+
enableSorting: true,
|
|
28
29
|
// Starting with `title` attr instead of a tooltip because it is easier to
|
|
29
30
|
// implement. We should try adding a tooltip in the future, but we'll need
|
|
30
31
|
// to be very careful about performance when doing so with large tables.
|
|
@@ -40,7 +41,7 @@ const getRowId = (data)=>{
|
|
|
40
41
|
const getCheckboxColor = (data)=>{
|
|
41
42
|
return data.color;
|
|
42
43
|
};
|
|
43
|
-
function TableLegend({ items , selectedItems: initRowSelection , onSelectedItemsChange , height , width }) {
|
|
44
|
+
function TableLegend({ items , selectedItems: initRowSelection , onSelectedItemsChange , onItemMouseOver , onItemMouseOut , height , width , columns: additionalColumns = [] , sorting , onSortingChange }) {
|
|
44
45
|
const rowSelection = (0, _react.useMemo)(()=>{
|
|
45
46
|
return typeof initRowSelection !== 'string' ? initRowSelection : // items for checkboxes.
|
|
46
47
|
// TODO: clean this up if we switch to also using checkboxes in list legend.
|
|
@@ -52,16 +53,29 @@ function TableLegend({ items , selectedItems: initRowSelection , onSelectedItems
|
|
|
52
53
|
initRowSelection,
|
|
53
54
|
items
|
|
54
55
|
]);
|
|
56
|
+
const columns = (0, _react.useMemo)(()=>{
|
|
57
|
+
return [
|
|
58
|
+
...COLUMNS,
|
|
59
|
+
...additionalColumns
|
|
60
|
+
];
|
|
61
|
+
}, [
|
|
62
|
+
additionalColumns
|
|
63
|
+
]);
|
|
55
64
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_table.Table, {
|
|
56
65
|
height: height,
|
|
57
66
|
width: width,
|
|
58
67
|
rowSelection: rowSelection,
|
|
59
68
|
onRowSelectionChange: onSelectedItemsChange,
|
|
69
|
+
onRowMouseOver: onItemMouseOver,
|
|
70
|
+
onRowMouseOut: onItemMouseOut,
|
|
71
|
+
sorting: sorting,
|
|
72
|
+
onSortingChange: onSortingChange,
|
|
60
73
|
data: items,
|
|
61
|
-
columns:
|
|
74
|
+
columns: columns,
|
|
62
75
|
density: "compact",
|
|
63
76
|
getRowId: getRowId,
|
|
64
77
|
getCheckboxColor: getCheckboxColor,
|
|
65
|
-
checkboxSelection: true
|
|
78
|
+
checkboxSelection: true,
|
|
79
|
+
rowSelectionVariant: "legend"
|
|
66
80
|
});
|
|
67
81
|
}
|
package/dist/cjs/Legend/index.js
CHANGED
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
17
|
_exportStar(require("./Legend"), exports);
|
|
18
|
+
_exportStar(require("./legend-model"), exports);
|
|
18
19
|
function _exportStar(from, to) {
|
|
19
20
|
Object.keys(from).forEach(function(k) {
|
|
20
21
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
@@ -10,19 +10,16 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
// Common types needed across individual unit groups and the overall combined
|
|
14
|
-
// units.
|
|
15
13
|
"use strict";
|
|
16
14
|
Object.defineProperty(exports, "__esModule", {
|
|
17
15
|
value: true
|
|
18
16
|
});
|
|
19
|
-
Object.defineProperty(exports, "
|
|
17
|
+
Object.defineProperty(exports, "isLegendItemVisuallySelected", {
|
|
20
18
|
enumerable: true,
|
|
21
|
-
get: ()=>
|
|
19
|
+
get: ()=>isLegendItemVisuallySelected
|
|
22
20
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
'
|
|
27
|
-
|
|
28
|
-
];
|
|
21
|
+
function isLegendItemVisuallySelected(item, selectedItems) {
|
|
22
|
+
// In the "ALL" case, technically all legend items are selected, but we do
|
|
23
|
+
// not render them differently.
|
|
24
|
+
return selectedItems !== 'ALL' && !!selectedItems[item.id];
|
|
25
|
+
}
|