@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
|
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "LineChart", {
|
|
|
19
19
|
get: ()=>LineChart
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const _react =
|
|
22
|
+
const _react = require("react");
|
|
23
23
|
const _material = require("@mui/material");
|
|
24
24
|
const _core = require("echarts/core");
|
|
25
25
|
const _charts = require("echarts/charts");
|
|
@@ -29,46 +29,7 @@ const _echart = require("../EChart");
|
|
|
29
29
|
const _chartsThemeProvider = require("../context/ChartsThemeProvider");
|
|
30
30
|
const _timeSeriesTooltip = require("../TimeSeriesTooltip");
|
|
31
31
|
const _timeZoneProvider = require("../context/TimeZoneProvider");
|
|
32
|
-
const _utils = require("
|
|
33
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
34
|
-
if (typeof WeakMap !== "function") return null;
|
|
35
|
-
var cacheBabelInterop = new WeakMap();
|
|
36
|
-
var cacheNodeInterop = new WeakMap();
|
|
37
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
38
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
39
|
-
})(nodeInterop);
|
|
40
|
-
}
|
|
41
|
-
function _interopRequireWildcard(obj, nodeInterop) {
|
|
42
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
43
|
-
return obj;
|
|
44
|
-
}
|
|
45
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
46
|
-
return {
|
|
47
|
-
default: obj
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
51
|
-
if (cache && cache.has(obj)) {
|
|
52
|
-
return cache.get(obj);
|
|
53
|
-
}
|
|
54
|
-
var newObj = {};
|
|
55
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
56
|
-
for(var key in obj){
|
|
57
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
58
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
59
|
-
if (desc && (desc.get || desc.set)) {
|
|
60
|
-
Object.defineProperty(newObj, key, desc);
|
|
61
|
-
} else {
|
|
62
|
-
newObj[key] = obj[key];
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
newObj.default = obj;
|
|
67
|
-
if (cache) {
|
|
68
|
-
cache.set(obj, newObj);
|
|
69
|
-
}
|
|
70
|
-
return newObj;
|
|
71
|
-
}
|
|
32
|
+
const _utils = require("../utils");
|
|
72
33
|
(0, _core.use)([
|
|
73
34
|
_charts.LineChart,
|
|
74
35
|
_components.GridComponent,
|
|
@@ -82,10 +43,10 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
82
43
|
_components.LegendComponent,
|
|
83
44
|
_renderers.CanvasRenderer
|
|
84
45
|
]);
|
|
85
|
-
function LineChart({ height , data , yAxis , unit , grid , legend , tooltipConfig ={
|
|
46
|
+
const LineChart = /*#__PURE__*/ (0, _react.forwardRef)(function LineChart({ height , data , yAxis , unit , grid , legend , tooltipConfig ={
|
|
86
47
|
wrapLabels: true
|
|
87
|
-
} , noDataVariant ='message' , onDataZoom , onDoubleClick , __experimentalEChartsOptionsOverride }) {
|
|
88
|
-
var
|
|
48
|
+
} , noDataVariant ='message' , syncGroup , onDataZoom , onDoubleClick , __experimentalEChartsOptionsOverride , }, ref) {
|
|
49
|
+
var ref1;
|
|
89
50
|
const chartsTheme = (0, _chartsThemeProvider.useChartsTheme)();
|
|
90
51
|
const chartRef = (0, _react.useRef)();
|
|
91
52
|
const [showTooltip, setShowTooltip] = (0, _react.useState)(true);
|
|
@@ -93,6 +54,29 @@ function LineChart({ height , data , yAxis , unit , grid , legend , tooltipConfi
|
|
|
93
54
|
const { timeZone } = (0, _timeZoneProvider.useTimeZone)();
|
|
94
55
|
const [isDragging, setIsDragging] = (0, _react.useState)(false);
|
|
95
56
|
const [startX, setStartX] = (0, _react.useState)(0);
|
|
57
|
+
(0, _react.useImperativeHandle)(ref, ()=>{
|
|
58
|
+
return {
|
|
59
|
+
highlightSeries ({ id }) {
|
|
60
|
+
if (!chartRef.current) {
|
|
61
|
+
// No chart. Do nothing.
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
chartRef.current.dispatchAction({
|
|
65
|
+
type: 'highlight',
|
|
66
|
+
seriesId: id
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
clearHighlightedSeries: ()=>{
|
|
70
|
+
if (!chartRef.current) {
|
|
71
|
+
// No chart. Do nothing.
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
(0, _utils.clearHighlightedSeries)(chartRef.current, data.timeSeries.length);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}, [
|
|
78
|
+
data.timeSeries.length
|
|
79
|
+
]);
|
|
96
80
|
const handleEvents = (0, _react.useMemo)(()=>{
|
|
97
81
|
return {
|
|
98
82
|
datazoom: (params)=>{
|
|
@@ -247,6 +231,9 @@ function LineChart({ height , data , yAxis , unit , grid , legend , tooltipConfi
|
|
|
247
231
|
if (tooltipPinnedCoords === null) {
|
|
248
232
|
setShowTooltip(false);
|
|
249
233
|
}
|
|
234
|
+
if (chartRef.current !== undefined) {
|
|
235
|
+
(0, _utils.clearHighlightedSeries)(chartRef.current, data.timeSeries.length);
|
|
236
|
+
}
|
|
250
237
|
},
|
|
251
238
|
onMouseEnter: ()=>{
|
|
252
239
|
setShowTooltip(true);
|
|
@@ -266,7 +253,7 @@ function LineChart({ height , data , yAxis , unit , grid , legend , tooltipConfi
|
|
|
266
253
|
}
|
|
267
254
|
},
|
|
268
255
|
children: [
|
|
269
|
-
showTooltip === true && ((
|
|
256
|
+
showTooltip === true && ((ref1 = option.tooltip) === null || ref1 === void 0 ? void 0 : ref1.showContent) === false && tooltipConfig.hidden !== true && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeSeriesTooltip.LineChartTooltip, {
|
|
270
257
|
chartRef: chartRef,
|
|
271
258
|
chartData: data,
|
|
272
259
|
wrapLabels: tooltipConfig.wrapLabels,
|
|
@@ -284,8 +271,9 @@ function LineChart({ height , data , yAxis , unit , grid , legend , tooltipConfi
|
|
|
284
271
|
option: option,
|
|
285
272
|
theme: chartsTheme.echartsTheme,
|
|
286
273
|
onEvents: handleEvents,
|
|
287
|
-
_instance: chartRef
|
|
274
|
+
_instance: chartRef,
|
|
275
|
+
syncGroup: syncGroup
|
|
288
276
|
})
|
|
289
277
|
]
|
|
290
278
|
});
|
|
291
|
-
}
|
|
279
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
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, "RefreshIntervalPicker", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>RefreshIntervalPicker
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _material = require("@mui/material");
|
|
23
|
+
function RefreshIntervalPicker(props) {
|
|
24
|
+
const { value , onChange , timeOptions , height } = props;
|
|
25
|
+
const formattedValue = value;
|
|
26
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormControl, {
|
|
27
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
28
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Select, {
|
|
29
|
+
id: "refreshInterval",
|
|
30
|
+
value: formattedValue,
|
|
31
|
+
onChange: (event)=>{
|
|
32
|
+
const duration = event.target.value;
|
|
33
|
+
onChange(duration);
|
|
34
|
+
},
|
|
35
|
+
inputProps: {
|
|
36
|
+
'aria-label': `Select refresh interval. Currently set to ${formattedValue}`
|
|
37
|
+
},
|
|
38
|
+
sx: {
|
|
39
|
+
'.MuiSelect-select': height ? {
|
|
40
|
+
lineHeight: height,
|
|
41
|
+
paddingY: 0
|
|
42
|
+
} : {}
|
|
43
|
+
},
|
|
44
|
+
children: timeOptions.map((item, idx)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
|
|
45
|
+
value: item.value.pastDuration,
|
|
46
|
+
children: item.display
|
|
47
|
+
}, idx))
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -14,9 +14,7 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
_exportStar(require("./
|
|
18
|
-
_exportStar(require("./constants"), exports);
|
|
19
|
-
_exportStar(require("./types"), exports);
|
|
17
|
+
_exportStar(require("./RefreshIntervalPicker"), exports);
|
|
20
18
|
function _exportStar(from, to) {
|
|
21
19
|
Object.keys(from).forEach(function(k) {
|
|
22
20
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "SettingsAutocomplete", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>SettingsAutocomplete
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _material = require("@mui/material");
|
|
23
|
+
function SettingsAutocomplete({ options , renderInput =(params)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
24
|
+
...params
|
|
25
|
+
}) , ...otherProps }) {
|
|
26
|
+
const getOptionLabel = (option)=>{
|
|
27
|
+
var _label;
|
|
28
|
+
return (_label = option.label) !== null && _label !== void 0 ? _label : option.id;
|
|
29
|
+
};
|
|
30
|
+
// Note: this component currently is not virtualized because it is specific
|
|
31
|
+
// to being used for settings, which generally have a pretty small list of
|
|
32
|
+
// options. If this changes to include values with many options, virtualization
|
|
33
|
+
// should be added using react-virtuoso.
|
|
34
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Autocomplete, {
|
|
35
|
+
isOptionEqualToValue: (option, value)=>option.id === value.id,
|
|
36
|
+
getOptionDisabled: (option)=>!!option.disabled,
|
|
37
|
+
getOptionLabel: getOptionLabel,
|
|
38
|
+
options: options,
|
|
39
|
+
renderInput: renderInput,
|
|
40
|
+
renderOption: (props, option)=>{
|
|
41
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("li", {
|
|
42
|
+
...props,
|
|
43
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)("div", {
|
|
44
|
+
children: [
|
|
45
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
46
|
+
variant: "body1",
|
|
47
|
+
component: "div",
|
|
48
|
+
children: getOptionLabel(option)
|
|
49
|
+
}),
|
|
50
|
+
option.description && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
51
|
+
variant: "body2",
|
|
52
|
+
component: "div",
|
|
53
|
+
color: (theme)=>theme.palette.text.secondary,
|
|
54
|
+
children: option.description
|
|
55
|
+
})
|
|
56
|
+
]
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
filterOptions: (0, _material.createFilterOptions)({
|
|
61
|
+
// Include the label and the description in search.
|
|
62
|
+
stringify: (option)=>`${getOptionLabel(option)} ${option.description || ''}`
|
|
63
|
+
}),
|
|
64
|
+
...otherProps
|
|
65
|
+
});
|
|
66
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
_exportStar(require("./SettingsAutocomplete"), exports);
|
|
18
|
+
function _exportStar(from, to) {
|
|
19
|
+
Object.keys(from).forEach(function(k) {
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function() {
|
|
23
|
+
return from[k];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return from;
|
|
28
|
+
}
|
|
@@ -20,16 +20,22 @@ Object.defineProperty(exports, "StatChart", {
|
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _react = require("react");
|
|
23
|
+
const _core = require("@perses-dev/core");
|
|
23
24
|
const _material = require("@mui/material");
|
|
24
|
-
const
|
|
25
|
-
const
|
|
25
|
+
const _merge = /*#__PURE__*/ _interopRequireDefault(require("lodash/merge"));
|
|
26
|
+
const _core1 = require("echarts/core");
|
|
26
27
|
const _charts = require("echarts/charts");
|
|
27
28
|
const _components = require("echarts/components");
|
|
28
29
|
const _renderers = require("echarts/renderers");
|
|
29
30
|
const _chartsThemeProvider = require("../context/ChartsThemeProvider");
|
|
30
|
-
const _units = require("../model/units");
|
|
31
31
|
const _echart = require("../EChart");
|
|
32
|
-
(
|
|
32
|
+
const _calculateFontSize = require("./calculateFontSize");
|
|
33
|
+
function _interopRequireDefault(obj) {
|
|
34
|
+
return obj && obj.__esModule ? obj : {
|
|
35
|
+
default: obj
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
(0, _core1.use)([
|
|
33
39
|
_charts.LineChart,
|
|
34
40
|
_components.GridComponent,
|
|
35
41
|
_components.DatasetComponent,
|
|
@@ -37,12 +43,48 @@ const _echart = require("../EChart");
|
|
|
37
43
|
_components.TooltipComponent,
|
|
38
44
|
_renderers.CanvasRenderer
|
|
39
45
|
]);
|
|
40
|
-
const
|
|
41
|
-
const
|
|
46
|
+
const LINE_HEIGHT = 1.2;
|
|
47
|
+
const SERIES_NAME_MAX_FONT_SIZE = 30;
|
|
48
|
+
const SERIES_NAME_FONT_WEIGHT = 400;
|
|
49
|
+
const VALUE_FONT_WEIGHT = 700;
|
|
42
50
|
function StatChart(props) {
|
|
43
|
-
|
|
51
|
+
var ref, ref1;
|
|
52
|
+
const { width , height , data , unit , color , sparkline , showSeriesName } = props;
|
|
44
53
|
const chartsTheme = (0, _chartsThemeProvider.useChartsTheme)();
|
|
45
|
-
|
|
54
|
+
let formattedValue = '';
|
|
55
|
+
if (data.calculatedValue === null) {
|
|
56
|
+
formattedValue = 'null';
|
|
57
|
+
} else if (typeof data.calculatedValue === 'number') {
|
|
58
|
+
formattedValue = (0, _core.formatValue)(data.calculatedValue, unit);
|
|
59
|
+
}
|
|
60
|
+
const containerPadding = chartsTheme.container.padding.default;
|
|
61
|
+
var ref2;
|
|
62
|
+
// calculate series name font size and height
|
|
63
|
+
let seriesNameFontSize = (0, _calculateFontSize.useOptimalFontSize)({
|
|
64
|
+
text: (ref2 = data === null || data === void 0 ? void 0 : (ref = data.seriesData) === null || ref === void 0 ? void 0 : ref.name) !== null && ref2 !== void 0 ? ref2 : '',
|
|
65
|
+
fontWeight: SERIES_NAME_FONT_WEIGHT,
|
|
66
|
+
width,
|
|
67
|
+
height: height * 0.125,
|
|
68
|
+
lineHeight: LINE_HEIGHT,
|
|
69
|
+
maxSize: SERIES_NAME_MAX_FONT_SIZE
|
|
70
|
+
});
|
|
71
|
+
const seriesNameHeight = showSeriesName ? seriesNameFontSize * LINE_HEIGHT + containerPadding : 0;
|
|
72
|
+
// calculate value font size and height
|
|
73
|
+
const availableWidth = width - containerPadding * 2;
|
|
74
|
+
const availableHeight = height - seriesNameHeight;
|
|
75
|
+
const valueFontSize = (0, _calculateFontSize.useOptimalFontSize)({
|
|
76
|
+
text: formattedValue,
|
|
77
|
+
fontWeight: VALUE_FONT_WEIGHT,
|
|
78
|
+
// without sparkline, use only 50% of the available width so it looks better for multiseries
|
|
79
|
+
width: sparkline ? availableWidth : availableWidth * 0.5,
|
|
80
|
+
// with sparkline, use only 25% of available height to leave room for chart
|
|
81
|
+
// without sparkline, value should take up 90% of available space
|
|
82
|
+
height: sparkline ? availableHeight * 0.25 : availableHeight * 0.9,
|
|
83
|
+
lineHeight: LINE_HEIGHT
|
|
84
|
+
});
|
|
85
|
+
const valueFontHeight = valueFontSize * LINE_HEIGHT;
|
|
86
|
+
// make sure the series name font size is slightly smaller than value font size
|
|
87
|
+
seriesNameFontSize = Math.min(valueFontSize * 0.7, seriesNameFontSize);
|
|
46
88
|
const option = (0, _react.useMemo)(()=>{
|
|
47
89
|
if (data.seriesData === undefined) return chartsTheme.noDataOption;
|
|
48
90
|
const series = data.seriesData;
|
|
@@ -50,15 +92,14 @@ function StatChart(props) {
|
|
|
50
92
|
if (sparkline !== undefined) {
|
|
51
93
|
const lineSeries = {
|
|
52
94
|
type: 'line',
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
],
|
|
95
|
+
name: series.name,
|
|
96
|
+
data: series.values,
|
|
56
97
|
zlevel: 1,
|
|
57
98
|
symbol: 'none',
|
|
58
99
|
animation: false,
|
|
59
100
|
silent: true
|
|
60
101
|
};
|
|
61
|
-
const mergedSeries = (0,
|
|
102
|
+
const mergedSeries = (0, _merge.default)(lineSeries, sparkline);
|
|
62
103
|
statSeries.push(mergedSeries);
|
|
63
104
|
}
|
|
64
105
|
const option = {
|
|
@@ -100,11 +141,6 @@ function StatChart(props) {
|
|
|
100
141
|
chartsTheme,
|
|
101
142
|
sparkline
|
|
102
143
|
]);
|
|
103
|
-
const isLargePanel = width > 250 && height > 180;
|
|
104
|
-
// adjusts fontSize depending on number of characters, clamp also used in fontSize attribute
|
|
105
|
-
const charactersAdjust = formattedValue.length;
|
|
106
|
-
const valueSize = isLargePanel === true ? MAX_VALUE_SIZE : Math.min(width, height) / charactersAdjust;
|
|
107
|
-
const containerPadding = `${chartsTheme.container.padding.default}px`;
|
|
108
144
|
const textAlignment = sparkline ? 'auto' : 'center';
|
|
109
145
|
const textStyles = {
|
|
110
146
|
display: 'flex',
|
|
@@ -119,19 +155,22 @@ function StatChart(props) {
|
|
|
119
155
|
...textStyles
|
|
120
156
|
},
|
|
121
157
|
children: [
|
|
122
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(
|
|
158
|
+
showSeriesName && /*#__PURE__*/ (0, _jsxRuntime.jsx)(SeriesName, {
|
|
159
|
+
padding: containerPadding,
|
|
160
|
+
fontSize: seriesNameFontSize,
|
|
161
|
+
children: (ref1 = data.seriesData) === null || ref1 === void 0 ? void 0 : ref1.name
|
|
162
|
+
}),
|
|
163
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(Value, {
|
|
123
164
|
variant: "h3",
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
padding: sparkline ? `${containerPadding} ${containerPadding} 0 ${containerPadding}` : ` 0 ${containerPadding}`
|
|
128
|
-
}),
|
|
165
|
+
color: color,
|
|
166
|
+
fontSize: valueFontSize,
|
|
167
|
+
padding: containerPadding,
|
|
129
168
|
children: formattedValue
|
|
130
169
|
}),
|
|
131
170
|
sparkline !== undefined && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_echart.EChart, {
|
|
132
171
|
sx: {
|
|
133
172
|
width: '100%',
|
|
134
|
-
height:
|
|
173
|
+
height: height - seriesNameHeight - valueFontHeight
|
|
135
174
|
},
|
|
136
175
|
option: option,
|
|
137
176
|
theme: chartsTheme.echartsTheme,
|
|
@@ -140,3 +179,22 @@ function StatChart(props) {
|
|
|
140
179
|
]
|
|
141
180
|
});
|
|
142
181
|
}
|
|
182
|
+
const SeriesName = (0, _material.styled)(_material.Typography, {
|
|
183
|
+
shouldForwardProp: (prop)=>prop !== 'padding' && prop !== 'fontSize'
|
|
184
|
+
})(({ theme , padding , fontSize })=>({
|
|
185
|
+
color: theme.palette.text.secondary,
|
|
186
|
+
padding: `${padding}px`,
|
|
187
|
+
fontSize: `${fontSize}px`,
|
|
188
|
+
overflow: 'hidden',
|
|
189
|
+
textOverflow: 'ellipsis',
|
|
190
|
+
whiteSpace: 'nowrap'
|
|
191
|
+
}));
|
|
192
|
+
const Value = (0, _material.styled)(_material.Typography, {
|
|
193
|
+
shouldForwardProp: (prop)=>prop !== 'color' && prop !== 'padding' && prop !== 'fontSize' && prop !== 'sparkline'
|
|
194
|
+
})(({ theme , color , padding , fontSize , sparkline })=>({
|
|
195
|
+
color: color !== null && color !== void 0 ? color : theme.palette.text.primary,
|
|
196
|
+
fontSize: `${fontSize}px`,
|
|
197
|
+
padding: sparkline ? `${padding}px ${padding}px 0 ${padding}px` : ` 0 ${padding}px`,
|
|
198
|
+
whiteSpace: 'nowrap',
|
|
199
|
+
lineHeight: LINE_HEIGHT
|
|
200
|
+
}));
|
|
@@ -0,0 +1,51 @@
|
|
|
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, "useOptimalFontSize", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>useOptimalFontSize
|
|
20
|
+
});
|
|
21
|
+
const _chartsThemeProvider = require("../context/ChartsThemeProvider");
|
|
22
|
+
let canvasContext;
|
|
23
|
+
function getGlobalCanvasContext() {
|
|
24
|
+
if (!canvasContext) {
|
|
25
|
+
canvasContext = document.createElement('canvas').getContext('2d');
|
|
26
|
+
if (canvasContext === null) {
|
|
27
|
+
throw new Error('Canvas context is null.');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return canvasContext;
|
|
31
|
+
}
|
|
32
|
+
function useOptimalFontSize({ text , fontWeight , width , height , lineHeight , maxSize }) {
|
|
33
|
+
const ctx = getGlobalCanvasContext();
|
|
34
|
+
const chartsTheme = (0, _chartsThemeProvider.useChartsTheme)();
|
|
35
|
+
const textStyle = chartsTheme.echartsTheme.textStyle;
|
|
36
|
+
var ref;
|
|
37
|
+
const fontSize = (ref = Number(textStyle === null || textStyle === void 0 ? void 0 : textStyle.fontSize)) !== null && ref !== void 0 ? ref : 12;
|
|
38
|
+
var ref1;
|
|
39
|
+
const fontFamily = (ref1 = textStyle === null || textStyle === void 0 ? void 0 : textStyle.fontFamily) !== null && ref1 !== void 0 ? ref1 : 'Lato';
|
|
40
|
+
// set the font on the canvas context
|
|
41
|
+
const fontStyle = `${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
42
|
+
ctx.font = fontStyle;
|
|
43
|
+
// measure the width of the text with the given font style
|
|
44
|
+
const textMetrics = ctx.measureText(text);
|
|
45
|
+
// check how much bigger we can make the font while staying within the width and height
|
|
46
|
+
const fontSizeBasedOnWidth = width / textMetrics.width * fontSize;
|
|
47
|
+
const fontSizeBasedOnHeight = height / lineHeight;
|
|
48
|
+
// return the smaller font size
|
|
49
|
+
const finalFontSize = Math.min(fontSizeBasedOnHeight, fontSizeBasedOnWidth);
|
|
50
|
+
return maxSize ? Math.min(finalFontSize, maxSize) : finalFontSize;
|
|
51
|
+
}
|
|
@@ -25,20 +25,20 @@ const StyledMuiTable = (0, _material.styled)(_material.Table)(({ theme })=>({
|
|
|
25
25
|
// This value is needed to have a consistent table layout when scrolling.
|
|
26
26
|
tableLayout: 'fixed',
|
|
27
27
|
borderCollapse: 'separate',
|
|
28
|
-
backgroundColor: theme.palette.background.
|
|
28
|
+
backgroundColor: theme.palette.background.default
|
|
29
29
|
}));
|
|
30
30
|
const TABLE_DENSITY_CONFIG = {
|
|
31
31
|
compact: 'small',
|
|
32
32
|
standard: 'medium'
|
|
33
33
|
};
|
|
34
|
-
const InnerTable = /*#__PURE__*/ (0, _react.forwardRef)(function InnerTable({ density ,
|
|
34
|
+
const InnerTable = /*#__PURE__*/ (0, _react.forwardRef)(function InnerTable({ density , ...otherProps }, ref) {
|
|
35
35
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(StyledMuiTable, {
|
|
36
36
|
...otherProps,
|
|
37
37
|
tabIndex: -1,
|
|
38
38
|
size: TABLE_DENSITY_CONFIG[density],
|
|
39
39
|
ref: ref,
|
|
40
40
|
sx: {
|
|
41
|
-
width:
|
|
41
|
+
width: '100%'
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
44
|
});
|
package/dist/cjs/Table/Table.js
CHANGED
|
@@ -28,16 +28,53 @@ const _tableModel = require("./model/table-model");
|
|
|
28
28
|
const DEFAULT_GET_ROW_ID = (data, index)=>{
|
|
29
29
|
return `${index}`;
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
// Setting these defaults one enables them to be consistent across renders instead
|
|
32
|
+
// of being recreated every time, which can be important for perf because react
|
|
33
|
+
// does not do deep equality checking for objects and arrays.
|
|
34
|
+
const DEFAULT_ROW_SELECTION = {};
|
|
35
|
+
const DEFAULT_SORTING = [];
|
|
36
|
+
function Table({ data , columns , density ='standard' , checkboxSelection , onRowSelectionChange , onSortingChange , getCheckboxColor , getRowId =DEFAULT_GET_ROW_ID , rowSelection =DEFAULT_ROW_SELECTION , sorting =DEFAULT_SORTING , rowSelectionVariant ='standard' , ...otherProps }) {
|
|
32
37
|
const theme = (0, _material.useTheme)();
|
|
33
38
|
const handleRowSelectionChange = (rowSelectionUpdater)=>{
|
|
34
39
|
const newRowSelection = typeof rowSelectionUpdater === 'function' ? rowSelectionUpdater(rowSelection) : rowSelectionUpdater;
|
|
35
40
|
onRowSelectionChange === null || onRowSelectionChange === void 0 ? void 0 : onRowSelectionChange(newRowSelection);
|
|
36
41
|
};
|
|
42
|
+
const handleRowSelectionEvent = (0, _react.useCallback)((table, row, isModified)=>{
|
|
43
|
+
if (rowSelectionVariant === 'standard' || isModified) {
|
|
44
|
+
row.toggleSelected();
|
|
45
|
+
} else {
|
|
46
|
+
// Legend variant (when action not modified with shift/meta key).
|
|
47
|
+
// Note that this behavior needs to be kept in sync with behavior in
|
|
48
|
+
// the Legend component for list-based legends.
|
|
49
|
+
if (row.getIsSelected() && !table.getIsAllRowsSelected()) {
|
|
50
|
+
// Row was already selected. Revert to select all.
|
|
51
|
+
table.toggleAllRowsSelected();
|
|
52
|
+
} else {
|
|
53
|
+
// Focus the selected row.
|
|
54
|
+
onRowSelectionChange === null || onRowSelectionChange === void 0 ? void 0 : onRowSelectionChange({
|
|
55
|
+
[row.id]: true
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}, [
|
|
60
|
+
onRowSelectionChange,
|
|
61
|
+
rowSelectionVariant
|
|
62
|
+
]);
|
|
63
|
+
const handleCheckboxChange = (0, _react.useCallback)((e, table, row)=>{
|
|
64
|
+
const nativePointerEvent = e.nativeEvent && (e.nativeEvent instanceof MouseEvent || e.nativeEvent instanceof KeyboardEvent) ? e.nativeEvent : undefined;
|
|
65
|
+
const isModifed = !!(nativePointerEvent === null || nativePointerEvent === void 0 ? void 0 : nativePointerEvent.metaKey) || !!(nativePointerEvent === null || nativePointerEvent === void 0 ? void 0 : nativePointerEvent.shiftKey);
|
|
66
|
+
handleRowSelectionEvent(table, row, isModifed);
|
|
67
|
+
}, [
|
|
68
|
+
handleRowSelectionEvent
|
|
69
|
+
]);
|
|
70
|
+
const handleSortingChange = (sortingUpdater)=>{
|
|
71
|
+
const newSorting = typeof sortingUpdater === 'function' ? sortingUpdater(sorting) : sortingUpdater;
|
|
72
|
+
onSortingChange === null || onSortingChange === void 0 ? void 0 : onSortingChange(newSorting);
|
|
73
|
+
};
|
|
37
74
|
const checkboxColumn = (0, _react.useMemo)(()=>{
|
|
38
75
|
return {
|
|
39
76
|
id: 'checkboxRowSelect',
|
|
40
|
-
size:
|
|
77
|
+
size: 28,
|
|
41
78
|
header: ({ table })=>{
|
|
42
79
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_tableCheckbox.TableCheckbox, {
|
|
43
80
|
checked: table.getIsAllRowsSelected(),
|
|
@@ -47,22 +84,24 @@ function Table({ data , columns , density ='standard' , checkboxSelection , onRo
|
|
|
47
84
|
density: density
|
|
48
85
|
});
|
|
49
86
|
},
|
|
50
|
-
cell: ({ row })=>{
|
|
87
|
+
cell: ({ row , table })=>{
|
|
51
88
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_tableCheckbox.TableCheckbox, {
|
|
52
89
|
checked: row.getIsSelected(),
|
|
53
90
|
indeterminate: row.getIsSomeSelected(),
|
|
54
91
|
onChange: (e)=>{
|
|
55
|
-
|
|
92
|
+
handleCheckboxChange(e, table, row);
|
|
56
93
|
},
|
|
57
94
|
color: getCheckboxColor === null || getCheckboxColor === void 0 ? void 0 : getCheckboxColor(row.original),
|
|
58
95
|
density: density
|
|
59
96
|
});
|
|
60
|
-
}
|
|
97
|
+
},
|
|
98
|
+
enableSorting: false
|
|
61
99
|
};
|
|
62
100
|
}, [
|
|
101
|
+
theme.palette.text.primary,
|
|
63
102
|
density,
|
|
64
103
|
getCheckboxColor,
|
|
65
|
-
|
|
104
|
+
handleCheckboxChange
|
|
66
105
|
]);
|
|
67
106
|
const tableColumns = (0, _react.useMemo)(()=>{
|
|
68
107
|
const initTableColumns = (0, _tableModel.persesColumnsToTanstackColumns)(columns);
|
|
@@ -80,15 +119,24 @@ function Table({ data , columns , density ='standard' , checkboxSelection , onRo
|
|
|
80
119
|
columns: tableColumns,
|
|
81
120
|
getRowId,
|
|
82
121
|
getCoreRowModel: (0, _reactTable.getCoreRowModel)(),
|
|
122
|
+
getSortedRowModel: (0, _reactTable.getSortedRowModel)(),
|
|
83
123
|
enableRowSelection: !!checkboxSelection,
|
|
84
124
|
onRowSelectionChange: handleRowSelectionChange,
|
|
125
|
+
onSortingChange: handleSortingChange,
|
|
126
|
+
// For now, defaulting to sort by descending first. We can expose the ability
|
|
127
|
+
// to customize it if/when we have use cases for it.
|
|
128
|
+
sortDescFirst: true,
|
|
85
129
|
state: {
|
|
86
|
-
rowSelection
|
|
130
|
+
rowSelection,
|
|
131
|
+
sorting
|
|
87
132
|
}
|
|
88
133
|
});
|
|
89
|
-
const handleRowClick = (0, _react.useCallback)((rowId)=>{
|
|
90
|
-
table.getRow(rowId)
|
|
134
|
+
const handleRowClick = (0, _react.useCallback)((e, rowId)=>{
|
|
135
|
+
const row = table.getRow(rowId);
|
|
136
|
+
const isModifiedClick = e.metaKey || e.shiftKey;
|
|
137
|
+
handleRowSelectionEvent(table, row, isModifiedClick);
|
|
91
138
|
}, [
|
|
139
|
+
handleRowSelectionEvent,
|
|
92
140
|
table
|
|
93
141
|
]);
|
|
94
142
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_virtualizedTable.VirtualizedTable, {
|