@perses-dev/components 0.0.0-snapshot-datasource-browser-test-28cbb71 → 0.0.0-snapshot-datasource-create-transform-e9f8493
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ColorPicker/ColorPicker.d.ts +12 -0
- package/dist/ColorPicker/ColorPicker.d.ts.map +1 -0
- package/dist/ColorPicker/ColorPicker.js +78 -0
- package/dist/ColorPicker/ColorPicker.js.map +1 -0
- package/dist/ColorPicker/index.d.ts +2 -0
- package/dist/ColorPicker/index.d.ts.map +1 -0
- package/dist/ColorPicker/index.js +15 -0
- package/dist/ColorPicker/index.js.map +1 -0
- package/dist/Dialog/Dialog.d.ts +2 -1
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +12 -1
- package/dist/Dialog/Dialog.js.map +1 -1
- package/dist/{EChart.d.ts → EChart/EChart.d.ts} +3 -3
- package/dist/EChart/EChart.d.ts.map +1 -0
- package/dist/EChart/EChart.js.map +1 -0
- package/dist/EChart/index.d.ts +2 -0
- package/dist/EChart/index.d.ts.map +1 -0
- package/dist/EChart/index.js +15 -0
- package/dist/EChart/index.js.map +1 -0
- package/dist/GaugeChart/GaugeChart.d.ts +1 -2
- package/dist/GaugeChart/GaugeChart.d.ts.map +1 -1
- package/dist/GaugeChart/GaugeChart.js.map +1 -1
- package/dist/InfoTooltip/InfoTooltip.d.ts.map +1 -1
- package/dist/InfoTooltip/InfoTooltip.js +7 -3
- package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
- package/dist/Legend/Legend.d.ts +1 -2
- package/dist/Legend/Legend.d.ts.map +1 -1
- package/dist/Legend/Legend.js +6 -9
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/LineChart/LineChart.d.ts +4 -2
- package/dist/LineChart/LineChart.d.ts.map +1 -1
- package/dist/LineChart/LineChart.js +1 -1
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.d.ts +3 -2
- package/dist/OptionsEditorLayout/OptionsEditorGroup.d.ts.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js +17 -5
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
- package/dist/StatChart/StatChart.d.ts +1 -3
- package/dist/StatChart/StatChart.d.ts.map +1 -1
- package/dist/StatChart/StatChart.js +1 -3
- package/dist/StatChart/StatChart.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdColorPicker.d.ts +4 -0
- package/dist/ThresholdsEditor/ThresholdColorPicker.d.ts.map +1 -0
- package/dist/ThresholdsEditor/ThresholdColorPicker.js +76 -0
- package/dist/ThresholdsEditor/ThresholdColorPicker.js.map +1 -0
- package/dist/ThresholdsEditor/ThresholdInput.d.ts +13 -0
- package/dist/ThresholdsEditor/ThresholdInput.d.ts.map +1 -0
- package/dist/ThresholdsEditor/ThresholdInput.js +61 -0
- package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -0
- package/dist/ThresholdsEditor/ThresholdsEditor.d.ts +10 -0
- package/dist/ThresholdsEditor/ThresholdsEditor.d.ts.map +1 -0
- package/dist/ThresholdsEditor/ThresholdsEditor.js +215 -0
- package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -0
- package/dist/ThresholdsEditor/index.d.ts +2 -0
- package/dist/ThresholdsEditor/index.d.ts.map +1 -0
- package/dist/ThresholdsEditor/index.js +15 -0
- package/dist/ThresholdsEditor/index.js.map +1 -0
- package/dist/TimeSeriesTooltip/focused-series.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/focused-series.js +3 -3
- package/dist/TimeSeriesTooltip/focused-series.js.map +1 -1
- package/dist/cjs/ColorPicker/ColorPicker.js +128 -0
- package/dist/cjs/{model/legend.test.js → ColorPicker/index.js} +11 -12
- package/dist/cjs/Dialog/Dialog.js +11 -0
- package/dist/{model/legend.test.js → cjs/EChart/index.js} +15 -14
- package/dist/cjs/InfoTooltip/InfoTooltip.js +7 -3
- package/dist/cjs/Legend/Legend.js +5 -8
- package/dist/cjs/LineChart/LineChart.js +40 -1
- package/dist/cjs/OptionsEditorLayout/OptionsEditorControl.js +1 -1
- package/dist/cjs/OptionsEditorLayout/OptionsEditorGroup.js +22 -5
- package/dist/cjs/StatChart/StatChart.js +1 -41
- package/dist/cjs/ThresholdsEditor/ThresholdColorPicker.js +87 -0
- package/dist/cjs/ThresholdsEditor/ThresholdInput.js +72 -0
- package/dist/cjs/ThresholdsEditor/ThresholdsEditor.js +265 -0
- package/dist/cjs/ThresholdsEditor/index.js +28 -0
- package/dist/cjs/TimeSeriesTooltip/focused-series.js +3 -3
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/test-utils/theme.js +8 -0
- package/dist/cjs/theme/component-overrides/alert.js +102 -0
- package/dist/cjs/theme/theme.js +4 -8
- package/dist/cjs/utils/theme-gen.js +8 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/model/graph.d.ts +2 -2
- package/dist/model/graph.d.ts.map +1 -1
- package/dist/model/graph.js.map +1 -1
- package/dist/model/legend.d.ts +1 -1
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js.map +1 -1
- package/dist/model/theme.d.ts +5 -0
- package/dist/model/theme.d.ts.map +1 -1
- package/dist/model/theme.js.map +1 -1
- package/dist/model/units/bytes.d.ts +1 -1
- package/dist/model/units/bytes.d.ts.map +1 -1
- package/dist/model/units/bytes.js.map +1 -1
- package/dist/model/units/decimal.d.ts +1 -1
- package/dist/model/units/decimal.d.ts.map +1 -1
- package/dist/model/units/decimal.js.map +1 -1
- package/dist/model/units/percent.d.ts +1 -1
- package/dist/model/units/percent.d.ts.map +1 -1
- package/dist/model/units/percent.js.map +1 -1
- package/dist/model/units/time.d.ts +1 -1
- package/dist/model/units/time.d.ts.map +1 -1
- package/dist/model/units/time.js.map +1 -1
- package/dist/model/units/types.d.ts +1 -1
- package/dist/model/units/types.d.ts.map +1 -1
- package/dist/model/units/types.js.map +1 -1
- package/dist/test-utils/theme.d.ts.map +1 -1
- package/dist/test-utils/theme.js +8 -0
- package/dist/test-utils/theme.js.map +1 -1
- package/dist/theme/component-overrides/alert.d.ts +3 -0
- package/dist/theme/component-overrides/alert.d.ts.map +1 -0
- package/dist/theme/component-overrides/alert.js +96 -0
- package/dist/theme/component-overrides/alert.js.map +1 -0
- package/dist/theme/theme.d.ts.map +1 -1
- package/dist/theme/theme.js +5 -9
- package/dist/theme/theme.js.map +1 -1
- package/dist/utils/theme-gen.d.ts.map +1 -1
- package/dist/utils/theme-gen.js +8 -0
- package/dist/utils/theme-gen.js.map +1 -1
- package/package.json +8 -3
- package/dist/EChart.d.ts.map +0 -1
- package/dist/EChart.js.map +0 -1
- package/dist/InfoTooltip/InfoTooltip.test.d.ts +0 -2
- package/dist/InfoTooltip/InfoTooltip.test.d.ts.map +0 -1
- package/dist/InfoTooltip/InfoTooltip.test.js +0 -36
- package/dist/InfoTooltip/InfoTooltip.test.js.map +0 -1
- package/dist/LegendOptionsEditor/LegendOptionsEditor.test.d.ts +0 -2
- package/dist/LegendOptionsEditor/LegendOptionsEditor.test.d.ts.map +0 -1
- package/dist/LegendOptionsEditor/LegendOptionsEditor.test.js +0 -62
- package/dist/LegendOptionsEditor/LegendOptionsEditor.test.js.map +0 -1
- package/dist/StatChart/StatChart.test.d.ts +0 -2
- package/dist/StatChart/StatChart.test.d.ts.map +0 -1
- package/dist/StatChart/StatChart.test.js +0 -94
- package/dist/StatChart/StatChart.test.js.map +0 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.test.d.ts +0 -2
- package/dist/TimeSeriesTooltip/SeriesInfo.test.d.ts.map +0 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.test.js +0 -52
- package/dist/TimeSeriesTooltip/SeriesInfo.test.js.map +0 -1
- package/dist/TimeSeriesTooltip/TooltipContent.test.d.ts +0 -2
- package/dist/TimeSeriesTooltip/TooltipContent.test.d.ts.map +0 -1
- package/dist/TimeSeriesTooltip/TooltipContent.test.js +0 -78
- package/dist/TimeSeriesTooltip/TooltipContent.test.js.map +0 -1
- package/dist/TimeSeriesTooltip/focused-series.test.d.ts +0 -2
- package/dist/TimeSeriesTooltip/focused-series.test.d.ts.map +0 -1
- package/dist/TimeSeriesTooltip/focused-series.test.js +0 -93
- package/dist/TimeSeriesTooltip/focused-series.test.js.map +0 -1
- package/dist/UnitSelector/UnitSelector.test.d.ts +0 -2
- package/dist/UnitSelector/UnitSelector.test.d.ts.map +0 -1
- package/dist/UnitSelector/UnitSelector.test.js +0 -204
- package/dist/UnitSelector/UnitSelector.test.js.map +0 -1
- package/dist/cjs/InfoTooltip/InfoTooltip.test.js +0 -43
- package/dist/cjs/LegendOptionsEditor/LegendOptionsEditor.test.js +0 -69
- package/dist/cjs/StatChart/StatChart.test.js +0 -96
- package/dist/cjs/TimeSeriesTooltip/SeriesInfo.test.js +0 -54
- package/dist/cjs/TimeSeriesTooltip/TooltipContent.test.js +0 -80
- package/dist/cjs/TimeSeriesTooltip/focused-series.test.js +0 -95
- package/dist/cjs/UnitSelector/UnitSelector.test.js +0 -211
- package/dist/cjs/model/units/units.test.js +0 -206
- package/dist/cjs/utils/format.test.js +0 -47
- package/dist/cjs/utils/theme-gen.test.js +0 -202
- package/dist/model/legend.test.d.ts +0 -2
- package/dist/model/legend.test.d.ts.map +0 -1
- package/dist/model/legend.test.js.map +0 -1
- package/dist/model/units/units.test.d.ts +0 -2
- package/dist/model/units/units.test.d.ts.map +0 -1
- package/dist/model/units/units.test.js +0 -204
- package/dist/model/units/units.test.js.map +0 -1
- package/dist/utils/format.test.d.ts +0 -2
- package/dist/utils/format.test.d.ts.map +0 -1
- package/dist/utils/format.test.js +0 -45
- package/dist/utils/format.test.js.map +0 -1
- package/dist/utils/theme-gen.test.d.ts +0 -2
- package/dist/utils/theme-gen.test.d.ts.map +0 -1
- package/dist/utils/theme-gen.test.js +0 -200
- package/dist/utils/theme-gen.test.js.map +0 -1
- /package/dist/{EChart.js → EChart/EChart.js} +0 -0
- /package/dist/cjs/{EChart.js → EChart/EChart.js} +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface ColorPickerProps {
|
|
3
|
+
color: string;
|
|
4
|
+
onChange?: (color: string) => void;
|
|
5
|
+
/**
|
|
6
|
+
* Preset color palette
|
|
7
|
+
*/
|
|
8
|
+
palette?: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare const ColorPicker: ({ color, onChange, palette }: ColorPickerProps) => JSX.Element;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=ColorPicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorPicker.d.ts","sourceRoot":"","sources":["../../src/ColorPicker/ColorPicker.tsx"],"names":[],"mappings":";AAkBA,UAAU,gBAAgB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,WAAW,iCAAkC,gBAAgB,gBA4CzE,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { IconButton, Stack, TextField } from '@mui/material';
|
|
15
|
+
import React, { useState } from 'react';
|
|
16
|
+
import { HexColorPicker } from 'react-colorful';
|
|
17
|
+
import CircleIcon from 'mdi-material-ui/Circle';
|
|
18
|
+
export const ColorPicker = ({ color , onChange , palette })=>{
|
|
19
|
+
// value is the visible value for the controlled text input
|
|
20
|
+
const [value, setValue] = useState(color);
|
|
21
|
+
const handleColorChange = (color)=>{
|
|
22
|
+
setValue(color);
|
|
23
|
+
onChange && onChange(color);
|
|
24
|
+
};
|
|
25
|
+
// we should update this if https://github.com/omgovich/react-colorful/issues/157 is resolved
|
|
26
|
+
const handleInputChange = (e)=>{
|
|
27
|
+
const inputValue = e.target.value.replace(/([^0-9A-F]+)/gi, '').substring(0, 8);
|
|
28
|
+
setValue(`#${inputValue}`); // always prefix input value with # to indicate hex format
|
|
29
|
+
// only set color if input value is a valid hex color
|
|
30
|
+
if (isValidHex(e.target.value)) {
|
|
31
|
+
onChange && onChange(e.target.value);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
35
|
+
spacing: 1,
|
|
36
|
+
children: [
|
|
37
|
+
/*#__PURE__*/ _jsx(HexColorPicker, {
|
|
38
|
+
color: color,
|
|
39
|
+
onChange: handleColorChange
|
|
40
|
+
}),
|
|
41
|
+
/*#__PURE__*/ _jsx(Stack, {
|
|
42
|
+
direction: "row",
|
|
43
|
+
flexWrap: "wrap",
|
|
44
|
+
justifyContent: "space-evenly",
|
|
45
|
+
width: '200px',
|
|
46
|
+
children: palette && palette.map((color, i)=>/*#__PURE__*/ _jsx(IconButton, {
|
|
47
|
+
size: "small",
|
|
48
|
+
"aria-label": `change color to ${color}`,
|
|
49
|
+
sx: {
|
|
50
|
+
color
|
|
51
|
+
},
|
|
52
|
+
onClick: ()=>handleColorChange(color),
|
|
53
|
+
children: /*#__PURE__*/ _jsx(CircleIcon, {})
|
|
54
|
+
}, i))
|
|
55
|
+
}),
|
|
56
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
57
|
+
inputProps: {
|
|
58
|
+
'aria-label': 'enter hex color'
|
|
59
|
+
},
|
|
60
|
+
fullWidth: true,
|
|
61
|
+
value: value,
|
|
62
|
+
onChange: handleInputChange
|
|
63
|
+
})
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
const isValidHex = (value, alpha)=>{
|
|
68
|
+
const matcher = /^#?([0-9A-F]{3,8})$/i;
|
|
69
|
+
const match = matcher.exec(value);
|
|
70
|
+
const length = match && match[1] ? match[1].length : 0;
|
|
71
|
+
return length === 3 || // '#rgb' format
|
|
72
|
+
length === 6 || // '#rrggbb' format
|
|
73
|
+
!!alpha && length === 4 || // '#rgba' format
|
|
74
|
+
!!alpha && length === 8 // '#rrggbbaa' format
|
|
75
|
+
;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=ColorPicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ColorPicker/ColorPicker.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 { IconButton, Stack, TextField } from '@mui/material';\nimport React, { useState } from 'react';\nimport { HexColorPicker } from 'react-colorful';\nimport CircleIcon from 'mdi-material-ui/Circle';\n\ninterface ColorPickerProps {\n color: string;\n onChange?: (color: string) => void;\n /**\n * Preset color palette\n */\n palette?: string[];\n}\n\nexport const ColorPicker = ({ color, onChange, palette }: ColorPickerProps) => {\n // value is the visible value for the controlled text input\n const [value, setValue] = useState(color);\n\n const handleColorChange = (color: string) => {\n setValue(color);\n onChange && onChange(color);\n };\n\n // we should update this if https://github.com/omgovich/react-colorful/issues/157 is resolved\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const inputValue = e.target.value.replace(/([^0-9A-F]+)/gi, '').substring(0, 8);\n setValue(`#${inputValue}`); // always prefix input value with # to indicate hex format\n // only set color if input value is a valid hex color\n if (isValidHex(e.target.value)) {\n onChange && onChange(e.target.value);\n }\n };\n\n return (\n <Stack spacing={1}>\n <HexColorPicker color={color} onChange={handleColorChange} />\n <Stack direction=\"row\" flexWrap=\"wrap\" justifyContent=\"space-evenly\" width={'200px'}>\n {palette &&\n palette.map((color, i) => (\n <IconButton\n key={i}\n size=\"small\"\n aria-label={`change color to ${color}`}\n sx={{ color }}\n onClick={() => handleColorChange(color)}\n >\n <CircleIcon />\n </IconButton>\n ))}\n </Stack>\n <TextField\n inputProps={{ 'aria-label': 'enter hex color' }}\n fullWidth\n value={value}\n onChange={handleInputChange}\n />\n </Stack>\n );\n};\n\nconst isValidHex = (value: string, alpha?: boolean): boolean => {\n const matcher = /^#?([0-9A-F]{3,8})$/i;\n const match = matcher.exec(value);\n const length = match && match[1] ? match[1].length : 0;\n return (\n length === 3 || // '#rgb' format\n length === 6 || // '#rrggbb' format\n (!!alpha && length === 4) || // '#rgba' format\n (!!alpha && length === 8) // '#rrggbbaa' format\n );\n};\n"],"names":["IconButton","Stack","TextField","React","useState","HexColorPicker","CircleIcon","ColorPicker","color","onChange","palette","value","setValue","handleColorChange","handleInputChange","e","inputValue","target","replace","substring","isValidHex","spacing","direction","flexWrap","justifyContent","width","map","i","size","aria-label","sx","onClick","inputProps","fullWidth","alpha","matcher","match","exec","length"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C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zB;AACJ,CAAC,AAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ColorPicker/index.ts"],"names":[],"mappings":"AAaA,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export * from './ColorPicker';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ColorPicker/index.ts"],"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\nexport * from './ColorPicker';\n"],"names":[],"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,cAAc,eAAe,CAAC"}
|
package/dist/Dialog/Dialog.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ButtonProps, DialogActions, DialogContentProps as MuiDialogContentProps, DialogProps, DialogTitleProps } from '@mui/material';
|
|
2
|
+
import { ButtonProps, DialogActions, DialogContentProps as MuiDialogContentProps, DialogProps, DialogTitleProps, Theme } from '@mui/material';
|
|
3
3
|
export interface DialogHeaderProps extends DialogTitleProps {
|
|
4
4
|
/**
|
|
5
5
|
* Callback fired when close button is clicked. If undefined, close button will not appear in header.
|
|
@@ -16,6 +16,7 @@ export interface DialogContentProps extends MuiDialogContentProps {
|
|
|
16
16
|
export declare const Dialog: {
|
|
17
17
|
({ children, ...props }: DialogProps): JSX.Element;
|
|
18
18
|
Header: ({ children, onClose, ...props }: DialogHeaderProps) => JSX.Element;
|
|
19
|
+
Form: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<Theme>, React.DetailedHTMLProps<React.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, {}>;
|
|
19
20
|
Content: ({ children, width, sx, ...props }: DialogContentProps) => JSX.Element;
|
|
20
21
|
PrimaryButton: ({ children, ...props }: DialogButtonProps) => JSX.Element;
|
|
21
22
|
SecondaryButton: ({ children, ...props }: DialogButtonProps) => JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../src/Dialog/Dialog.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAEL,WAAW,EAEX,aAAa,EAEb,kBAAkB,IAAI,qBAAqB,EAC3C,WAAW,EAEX,gBAAgB,
|
|
1
|
+
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../src/Dialog/Dialog.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAEL,WAAW,EAEX,aAAa,EAEb,kBAAkB,IAAI,qBAAqB,EAC3C,WAAW,EAEX,gBAAgB,EAGhB,KAAK,EACN,MAAM,eAAe,CAAC;AAIvB,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACzD;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CACtD;AAED,oBAAY,iBAAiB,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC,CAAC;AAEhF,MAAM,WAAW,kBAAmB,SAAQ,qBAAqB;IAC/D;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAqDD,eAAO,MAAM,MAAM;6BAA4B,WAAW;8CAnDT,iBAAiB;;iDAaR,kBAAkB;4CAM7B,iBAAiB;8CAMf,iBAAiB;;CA0ByC,CAAC"}
|
package/dist/Dialog/Dialog.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
14
|
import React from 'react';
|
|
15
|
-
import { Button, Dialog as MuiDialog, DialogActions, DialogContent, DialogTitle, IconButton } from '@mui/material';
|
|
15
|
+
import { Button, Dialog as MuiDialog, DialogActions, DialogContent, DialogTitle, IconButton, styled } from '@mui/material';
|
|
16
16
|
import CloseIcon from 'mdi-material-ui/Close';
|
|
17
17
|
import { combineSx } from '../utils';
|
|
18
18
|
const Header = ({ children , onClose , ...props })=>{
|
|
@@ -51,6 +51,16 @@ const SecondaryButton = ({ children , ...props })=>/*#__PURE__*/ _jsx(Button, {
|
|
|
51
51
|
...props,
|
|
52
52
|
children: children
|
|
53
53
|
});
|
|
54
|
+
/*
|
|
55
|
+
* Material-ui has a prop "scroll=paper" that is specifically for dialog header and actions to be sticky and body to scroll,
|
|
56
|
+
* but that doesn't work when dialog content is wrapped in form.
|
|
57
|
+
* https://github.com/mui-org/material-ui/issues/13253
|
|
58
|
+
* This component adds style to get expected behavior & should be used whenever we have a Form inside a Dialog
|
|
59
|
+
*/ const Form = styled('form')({
|
|
60
|
+
overflowY: 'auto',
|
|
61
|
+
display: 'flex',
|
|
62
|
+
flexDirection: 'column'
|
|
63
|
+
});
|
|
54
64
|
/**
|
|
55
65
|
* Render the CSS of the dialog's close button, according to the given material theme.
|
|
56
66
|
* @param theme material theme
|
|
@@ -66,6 +76,7 @@ export const Dialog = ({ children , ...props })=>/*#__PURE__*/ _jsx(MuiDialog, {
|
|
|
66
76
|
children: children
|
|
67
77
|
});
|
|
68
78
|
Dialog.Header = Header;
|
|
79
|
+
Dialog.Form = Form;
|
|
69
80
|
Dialog.Content = Content;
|
|
70
81
|
Dialog.PrimaryButton = PrimaryButton;
|
|
71
82
|
Dialog.SecondaryButton = SecondaryButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Dialog/Dialog.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 React from 'react';\nimport {\n Button,\n ButtonProps,\n Dialog as MuiDialog,\n DialogActions,\n DialogContent,\n DialogContentProps as MuiDialogContentProps,\n DialogProps,\n DialogTitle,\n DialogTitleProps,\n IconButton,\n Theme,\n} from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { combineSx } from '../utils';\n\nexport interface DialogHeaderProps extends DialogTitleProps {\n /**\n * Callback fired when close button is clicked. If undefined, close button will not appear in header.\n */\n onClose?: (e: React.MouseEvent<HTMLElement>) => void;\n}\n\nexport type DialogButtonProps = Omit<ButtonProps, 'variant' | 'color' | 'type'>;\n\nexport interface DialogContentProps extends MuiDialogContentProps {\n /**\n * @default 500\n */\n width?: number;\n}\n\nconst Header = ({ children, onClose, ...props }: DialogHeaderProps) => {\n return (\n <>\n <DialogTitle {...props}>{children}</DialogTitle>\n {onClose && (\n <IconButton aria-label=\"Close\" onClick={onClose} sx={dialogCloseIconButtonStyle}>\n <CloseIcon />\n </IconButton>\n )}\n </>\n );\n};\n\nconst Content = ({ children, width = 500, sx, ...props }: DialogContentProps) => (\n <DialogContent dividers {...props} sx={combineSx({ width: `${width}px` }, sx)}>\n {children}\n </DialogContent>\n);\n\nconst PrimaryButton = ({ children, ...props }: DialogButtonProps) => (\n <Button variant=\"contained\" type=\"submit\" {...props}>\n {children}\n </Button>\n);\n\nconst SecondaryButton = ({ children, ...props }: DialogButtonProps) => (\n <Button variant=\"outlined\" color=\"secondary\" {...props}>\n {children}\n </Button>\n);\n\n/**\n * Render the CSS of the dialog's close button, according to the given material theme.\n * @param theme material theme\n */\nconst dialogCloseIconButtonStyle = (theme: Theme) => {\n return { position: 'absolute', top: theme.spacing(0.5), right: theme.spacing(0.5) };\n};\n\nexport const Dialog = ({ children, ...props }: DialogProps) => <MuiDialog {...props}>{children}</MuiDialog>;\n\nDialog.Header = Header;\nDialog.Content = Content;\nDialog.PrimaryButton = PrimaryButton;\nDialog.SecondaryButton = SecondaryButton;\nDialog.Actions = DialogActions;\n"],"names":["React","Button","Dialog","MuiDialog","DialogActions","DialogContent","DialogTitle","IconButton","CloseIcon","combineSx","Header","children","onClose","props","aria-label","onClick","sx","dialogCloseIconButtonStyle","Content","width","dividers","PrimaryButton","variant","type","SecondaryButton","color","theme","position","top","spacing","right","Actions"],"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,OAAOA,KAAK,MAAM,OAAO,CAAC;AAC1B,SACEC,MAAM,EAENC,MAAM,IAAIC,SAAS,EACnBC,aAAa,EACbC,aAAa,EAGbC,WAAW,EAEXC,UAAU,
|
|
1
|
+
{"version":3,"sources":["../../src/Dialog/Dialog.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 React from 'react';\nimport {\n Button,\n ButtonProps,\n Dialog as MuiDialog,\n DialogActions,\n DialogContent,\n DialogContentProps as MuiDialogContentProps,\n DialogProps,\n DialogTitle,\n DialogTitleProps,\n IconButton,\n styled,\n Theme,\n} from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { combineSx } from '../utils';\n\nexport interface DialogHeaderProps extends DialogTitleProps {\n /**\n * Callback fired when close button is clicked. If undefined, close button will not appear in header.\n */\n onClose?: (e: React.MouseEvent<HTMLElement>) => void;\n}\n\nexport type DialogButtonProps = Omit<ButtonProps, 'variant' | 'color' | 'type'>;\n\nexport interface DialogContentProps extends MuiDialogContentProps {\n /**\n * @default 500\n */\n width?: number;\n}\n\nconst Header = ({ children, onClose, ...props }: DialogHeaderProps) => {\n return (\n <>\n <DialogTitle {...props}>{children}</DialogTitle>\n {onClose && (\n <IconButton aria-label=\"Close\" onClick={onClose} sx={dialogCloseIconButtonStyle}>\n <CloseIcon />\n </IconButton>\n )}\n </>\n );\n};\n\nconst Content = ({ children, width = 500, sx, ...props }: DialogContentProps) => (\n <DialogContent dividers {...props} sx={combineSx({ width: `${width}px` }, sx)}>\n {children}\n </DialogContent>\n);\n\nconst PrimaryButton = ({ children, ...props }: DialogButtonProps) => (\n <Button variant=\"contained\" type=\"submit\" {...props}>\n {children}\n </Button>\n);\n\nconst SecondaryButton = ({ children, ...props }: DialogButtonProps) => (\n <Button variant=\"outlined\" color=\"secondary\" {...props}>\n {children}\n </Button>\n);\n\n/*\n * Material-ui has a prop \"scroll=paper\" that is specifically for dialog header and actions to be sticky and body to scroll,\n * but that doesn't work when dialog content is wrapped in form.\n * https://github.com/mui-org/material-ui/issues/13253\n * This component adds style to get expected behavior & should be used whenever we have a Form inside a Dialog\n */\nconst Form = styled('form')({\n overflowY: 'auto',\n display: 'flex',\n flexDirection: 'column',\n});\n\n/**\n * Render the CSS of the dialog's close button, according to the given material theme.\n * @param theme material theme\n */\nconst dialogCloseIconButtonStyle = (theme: Theme) => {\n return { position: 'absolute', top: theme.spacing(0.5), right: theme.spacing(0.5) };\n};\n\nexport const Dialog = ({ children, ...props }: DialogProps) => <MuiDialog {...props}>{children}</MuiDialog>;\n\nDialog.Header = Header;\nDialog.Form = Form;\nDialog.Content = Content;\nDialog.PrimaryButton = PrimaryButton;\nDialog.SecondaryButton = SecondaryButton;\nDialog.Actions = DialogActions;\n"],"names":["React","Button","Dialog","MuiDialog","DialogActions","DialogContent","DialogTitle","IconButton","styled","CloseIcon","combineSx","Header","children","onClose","props","aria-label","onClick","sx","dialogCloseIconButtonStyle","Content","width","dividers","PrimaryButton","variant","type","SecondaryButton","color","Form","overflowY","display","flexDirection","theme","position","top","spacing","right","Actions"],"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,OAAOA,KAAK,MAAM,OAAO,CAAC;AAC1B,SACEC,MAAM,EAENC,MAAM,IAAIC,SAAS,EACnBC,aAAa,EACbC,aAAa,EA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F;;;;;CAKC,GACD,MAAMe,IAAI,GAAGnB,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1BoB,SAAS,EAAE,MAAM;IACjBC,OAAO,EAAE,MAAM;IACfC,aAAa,EAAE,QAAQ;CACxB,CAAC,AAAC;AAEH;;;CAGC,GACD,MAAMZ,0BAA0B,GAAG,CAACa,KAAY,GAAK;IACnD,OAAO;QAAEC,QAAQ,EAAE,UAAU;QAAEC,GAAG,EAAEF,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;QAAEC,KAAK,EAAEJ,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;KAAE,CAAC;AACtF,CAAC,AAAC;AAEF,OAAO,MAAMhC,MAAM,GAAG,CAAC,EAAEU,QAAQ,CAAA,EAAE,GAAGE,KAAK,EAAe,iBAAK,KAACX,SAAS;QAAE,GAAGW,KAAK;kBAAGF,QAAQ;MAAa,CAAC;AAE5GV,MAAM,CAACS,MAAM,GAAGA,MAAM,CAAC;AACvBT,MAAM,CAACyB,IAAI,GAAGA,IAAI,CAAC;AACnBzB,MAAM,CAACiB,OAAO,GAAGA,OAAO,CAAC;AACzBjB,MAAM,CAACoB,aAAa,GAAGA,aAAa,CAAC;AACrCpB,MAAM,CAACuB,eAAe,GAAGA,eAAe,CAAC;AACzCvB,MAAM,CAACkC,OAAO,GAAGhC,aAAa,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ECharts, EChartsCoreOption } from 'echarts/core';
|
|
3
3
|
import { SxProps, Theme } from '@mui/material';
|
|
4
|
-
import { EChartsTheme } from '
|
|
4
|
+
import { EChartsTheme } from '../model';
|
|
5
5
|
export interface MouseEventsParameters<T> {
|
|
6
6
|
componentType: string;
|
|
7
7
|
seriesType: string;
|
|
@@ -17,7 +17,7 @@ export interface MouseEventsParameters<T> {
|
|
|
17
17
|
}
|
|
18
18
|
declare type OnEventFunction<T> = (params: MouseEventsParameters<T>, instance?: ECharts) => void;
|
|
19
19
|
declare const mouseEvents: readonly ["click", "dblclick", "mousedown", "mousemove", "mouseup", "mouseover", "mouseout", "globalout", "contextmenu"];
|
|
20
|
-
export declare type MouseEventName = typeof mouseEvents[number];
|
|
20
|
+
export declare type MouseEventName = (typeof mouseEvents)[number];
|
|
21
21
|
export interface DataZoomPayloadBatchItem {
|
|
22
22
|
dataZoomId: string;
|
|
23
23
|
start?: number;
|
|
@@ -38,7 +38,7 @@ export interface BatchEventsParameters {
|
|
|
38
38
|
}
|
|
39
39
|
declare type OnBatchEventFunction = (params: BatchEventsParameters) => void;
|
|
40
40
|
declare const batchEvents: readonly ["datazoom", "downplay", "highlight"];
|
|
41
|
-
export declare type BatchEventName = typeof batchEvents[number];
|
|
41
|
+
export declare type BatchEventName = (typeof batchEvents)[number];
|
|
42
42
|
declare type ChartEventName = 'finished';
|
|
43
43
|
export declare type OnEventsType<T> = {
|
|
44
44
|
[mouseEventName in MouseEventName]?: OnEventFunction<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EChart.d.ts","sourceRoot":"","sources":["../../src/EChart/EChart.tsx"],"names":[],"mappings":"AAaA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAQ,MAAM,cAAc,CAAC;AAChE,OAAO,EAAO,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAClC,QAAQ,EAAE,MA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,CAAC,CAAC;CACxD,GAAG;KACD,cAAc,IAAI,cAAc,CAAC,CAAC,EAAE,oBAAoB;CAC1D,GAAG;KACD,SAAS,IAAI,cAAc,CAAC,CAAC,EAAE,MAAM,IAAI;CAC3C,CAAC;AAEF,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IAC9B,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IAC5B,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IAC3B,SAAS,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;IACxD,kBAAkB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;CAClD;AAED,eAAO,MAAM,MAAM,6IA2EjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/EChart/EChart.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 React, { useEffect, useLayoutEffect, useRef } from 'react';\nimport { ECharts, EChartsCoreOption, init } from 'echarts/core';\nimport { Box, SxProps, Theme } from '@mui/material';\nimport { isEqual, debounce } from 'lodash-es';\nimport { EChartsTheme } from '../model';\n\n// see docs for info about each property: https://echarts.apache.org/en/api.html#events\nexport interface MouseEventsParameters<T> {\n componentType: string;\n seriesType: string;\n seriesIndex: number;\n seriesName: string;\n name: string;\n dataIndex: number;\n data: Record<string, unknown> & T;\n dataType: string;\n value: number | number[];\n color: string;\n info: Record<string, unknown>;\n}\n\ntype OnEventFunction<T> = (\n params: MouseEventsParameters<T>,\n // This is potentially undefined for testing purposes\n instance?: ECharts\n) => void;\n\nconst mouseEvents = [\n 'click',\n 'dblclick',\n 'mousedown',\n 'mousemove',\n 'mouseup',\n 'mouseover',\n 'mouseout',\n 'globalout',\n 'contextmenu',\n] as const;\n\nexport type MouseEventName = (typeof mouseEvents)[number];\n\n// batch event types\nexport interface DataZoomPayloadBatchItem {\n dataZoomId: string;\n // start and end not returned unless dataZoom is based on percentProp,\n // which is for cases when a dataZoom component controls multiple axes\n start?: number;\n end?: number;\n // startValue and endValue return data index for 'category' axes,\n // for axis types 'value' and 'time', actual values are returned\n startValue?: number;\n endValue?: number;\n}\n\nexport interface HighlightPayloadBatchItem {\n dataIndex: number;\n dataIndexInside: number;\n seriesIndex: number;\n // highlight action can effect multiple connected charts\n escapeConnect?: boolean;\n // whether blur state was triggered\n notBlur?: boolean;\n}\n\nexport interface BatchEventsParameters {\n type: BatchEventName;\n batch: DataZoomPayloadBatchItem[] & HighlightPayloadBatchItem[];\n}\n\ntype OnBatchEventFunction = (params: BatchEventsParameters) => void;\n\nconst batchEvents = ['datazoom', 'downplay', 'highlight'] as const;\n\nexport type BatchEventName = (typeof batchEvents)[number];\n\ntype ChartEventName = 'finished';\n\ntype EventName = MouseEventName | ChartEventName | BatchEventName;\n\nexport type OnEventsType<T> = {\n [mouseEventName in MouseEventName]?: OnEventFunction<T>;\n} & {\n [batchEventName in BatchEventName]?: OnBatchEventFunction;\n} & {\n [eventName in ChartEventName]?: () => void;\n};\n\nexport interface EChartsProps<T> {\n option: EChartsCoreOption;\n theme?: string | EChartsTheme;\n renderer?: 'canvas' | 'svg';\n sx?: SxProps<Theme>;\n onEvents?: OnEventsType<T>;\n _instance?: React.MutableRefObject<ECharts | undefined>;\n onChartInitialized?: (instance: ECharts) => void;\n}\n\nexport const EChart = React.memo(function EChart<T>({\n option,\n theme,\n renderer,\n sx,\n onEvents,\n _instance,\n onChartInitialized,\n}: EChartsProps<T>) {\n const initialOption = useRef<EChartsCoreOption>(option);\n const prevOption = useRef<EChartsCoreOption>(option);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const chartElement = useRef<ECharts | null>(null);\n\n // Initialize chart, dispose on unmount\n useLayoutEffect(() => {\n if (containerRef.current === null || chartElement.current !== null) return;\n chartElement.current = init(containerRef.current, theme, { renderer: renderer ?? 'canvas' });\n if (chartElement.current === undefined) return;\n chartElement.current.setOption(initialOption.current, true);\n onChartInitialized?.(chartElement.current);\n if (_instance !== undefined) {\n _instance.current = chartElement.current;\n }\n return () => {\n if (chartElement.current === null) return;\n chartElement.current.dispose();\n chartElement.current = null;\n };\n }, [_instance, onChartInitialized, theme, renderer]);\n\n // Update chart data when option changes\n useEffect(() => {\n if (prevOption.current === undefined || isEqual(prevOption.current, option)) return;\n if (!chartElement.current) return;\n chartElement.current.setOption(option, true);\n prevOption.current = option;\n }, [option]);\n\n // Resize chart, cleanup listener on unmount\n useLayoutEffect(() => {\n const updateSize = debounce(() => {\n if (!chartElement.current) return;\n chartElement.current.resize();\n }, 200);\n window.addEventListener('resize', updateSize);\n updateSize();\n return () => {\n window.removeEventListener('resize', updateSize);\n };\n }, []);\n\n // Bind and unbind chart events passed as prop\n useEffect(() => {\n const chart = chartElement.current;\n if (!chart || onEvents === undefined) return;\n bindEvents(chart, onEvents);\n return () => {\n if (chart === undefined) return;\n if (chart.isDisposed() === true) return;\n for (const event in onEvents) {\n chart.off(event);\n }\n };\n }, [onEvents]);\n\n useEffect(() => {\n const updateSize = debounce(() => {\n if (!chartElement.current) return;\n chartElement.current.resize();\n }, 200);\n updateSize();\n }, [sx]);\n\n return <Box ref={containerRef} sx={sx}></Box>;\n});\n\n// Validate event config and bind custom events\nfunction bindEvents<T>(instance: ECharts, events?: OnEventsType<T>) {\n if (events === undefined) return;\n\n function bindEvent(eventName: EventName, OnEventFunction: unknown) {\n if (typeof OnEventFunction === 'function') {\n if (isMouseEvent(eventName)) {\n instance.on(eventName, (params) => OnEventFunction(params, instance));\n } else if (isBatchEvent(eventName)) {\n instance.on(eventName, (params) => OnEventFunction(params));\n } else {\n instance.on(eventName, () => OnEventFunction(null, instance));\n }\n }\n }\n\n for (const eventName in events) {\n if (Object.prototype.hasOwnProperty.call(events, eventName)) {\n const customEvent = events[eventName as EventName] ?? null;\n if (customEvent) {\n bindEvent(eventName as EventName, customEvent);\n }\n }\n }\n}\n\nfunction isMouseEvent(eventName: EventName): eventName is MouseEventName {\n return (mouseEvents as readonly string[]).includes(eventName);\n}\n\nfunction isBatchEvent(eventName: EventName): eventName is BatchEventName {\n return (batchEvents as readonly string[]).includes(eventName);\n}\n"],"names":["React","useEffect","useLayoutEffect","useRef","init","Box","isEqual","debounce","mouseEvents","batchEvents","EChart","memo","option","theme","renderer","sx","onEvents","_instance","onChartInitialized","initialOption","prevOption","containerRef","chartElement","current","undefined","setOption","dispose","updateSize","resize","window","addEventListener","removeEventListener","chart","bindEvents","isDisposed","event","off","ref","instance","events","bindEvent","eventName","OnEventFunction","isMouseEvent","on","params","isBatchEvent","Object","prototype","hasOwnProperty","call","customEvent","includes"],"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,OAAOA,KAAK,IAAIC,SAAS,EAAEC,eAAe,EAAEC,MAAM,QAAQ,OAAO,CAAC;AAClE,SAAqCC,IAAI,QAAQ,cAAc,CAAC;AAChE,SAASC,GAAG,QAAwB,eAAe,CAAC;AACpD,SAASC,OAAO,EAAEC,QAAQ,QAAQ,WAAW,CAAC;AAwB9C,MAAMC,WAAW,GAAG;IAClB,OAAO;IACP,UAAU;IACV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AAO,IAAIQ,YAAY,CAACL,SAAS,CAAC,EAAE;gBAClCH,QAAQ,CAACM,EAAE,CAACH,SAAS,EAAE,CAACI,MAAM,GAAKH,eAAe,CAACG,MAAM,CAAC,CAAC,CAAC;YAC9D,OAAO;gBACLP,QAAQ,CAACM,EAAE,CAACH,SAAS,EAAE,IAAMC,eAAe,CAAC,IAAI,EAAEJ,QAAQ,CAAC,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAK,MAAMG,SAAS,IAAIF,MAAM,CAAE;QAC9B,IAAIQ,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACX,MAAM,EAAEE,SAAS,CAAC,EAAE;gBACvCF,UAA8B;YAAlD,MAAMY,WAAW,GAAGZ,CAAAA,UAA8B,GAA9BA,MAAM,CAACE,SAAS,CAAc,cAA9BF,UAA8B,cAA9BA,UAA8B,GAAI,IAAI,AAAC;YAC3D,IAAIY,WAAW,EAAE;gBACfX,SAAS,CAACC,SAAS,EAAeU,WAAW,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAASR,YAAY,CAACF,SAAoB,EAA+B;IACvE,OAAO,AAACjC,WAAW,CAAuB4C,QAAQ,CAACX,SAAS,CAAC,CAAC;AAChE,CAAC;AAED,SAASK,YAAY,CAACL,SAAoB,EAA+B;IACvE,OAAO,AAAChC,WAAW,CAAuB2C,QAAQ,CAACX,SAAS,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/EChart/index.ts"],"names":[],"mappings":"AAaA,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export * from './EChart';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/EChart/index.ts"],"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\nexport * from './EChart';\n"],"names":[],"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,cAAc,UAAU,CAAC"}
|
|
@@ -6,7 +6,7 @@ export declare type GaugeSeries = {
|
|
|
6
6
|
value: GaugeChartValue;
|
|
7
7
|
label: string;
|
|
8
8
|
};
|
|
9
|
-
interface GaugeChartProps {
|
|
9
|
+
export interface GaugeChartProps {
|
|
10
10
|
width: number;
|
|
11
11
|
height: number;
|
|
12
12
|
data: GaugeSeries;
|
|
@@ -20,5 +20,4 @@ export declare function GaugeChart(props: GaugeChartProps): JSX.Element;
|
|
|
20
20
|
* to ensure size stays within given range
|
|
21
21
|
*/
|
|
22
22
|
export declare function getResponsiveValueSize(value: number, unit: UnitOptions, width: number, height: number): string;
|
|
23
|
-
export {};
|
|
24
23
|
//# sourceMappingURL=GaugeChart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GaugeChart.d.ts","sourceRoot":"","sources":["../../src/GaugeChart/GaugeChart.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAmC,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIpF,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAU1D,oBAAY,eAAe,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAExD,oBAAY,WAAW,GAAG;IACxB,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,
|
|
1
|
+
{"version":3,"file":"GaugeChart.d.ts","sourceRoot":"","sources":["../../src/GaugeChart/GaugeChart.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAmC,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIpF,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAU1D,oBAAY,eAAe,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAExD,oBAAY,WAAW,GAAG;IACxB,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eAgJhD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAQrG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/GaugeChart/GaugeChart.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 { useDeepMemo } from '@perses-dev/core';\nimport { use, EChartsCoreOption } from 'echarts/core';\nimport { GaugeChart as EChartsGaugeChart, GaugeSeriesOption } from 'echarts/charts';\nimport { GridComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { useChartsTheme } from '../context/ChartsThemeProvider';\nimport { formatValue, UnitOptions } from '../model/units';\nimport { EChart } from '../EChart';\n\nuse([EChartsGaugeChart, GridComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nconst PROGRESS_WIDTH = 16;\n\n// adjusts when to show pointer icon\nconst GAUGE_SMALL_BREAKPOINT = 170;\n\nexport type GaugeChartValue = number | null | undefined;\n\nexport type GaugeSeries = {\n value: GaugeChartValue;\n label: string;\n};\n\ninterface GaugeChartProps {\n width: number;\n height: number;\n data: GaugeSeries;\n unit: UnitOptions;\n axisLine: GaugeSeriesOption['axisLine'];\n max?: number;\n}\n\nexport function GaugeChart(props: GaugeChartProps) {\n const { width, height, data, unit, axisLine, max } = props;\n const chartsTheme = useChartsTheme();\n\n // useDeepMemo ensures value size util does not rerun everytime you hover on the chart\n const option: EChartsCoreOption = useDeepMemo(() => {\n if (data.value === undefined || data.value === null) return chartsTheme.noDataOption;\n\n // adjusts fontSize depending on number of characters\n const valueSizeClamp = getResponsiveValueSize(data.value, unit, width, height);\n\n return {\n title: {\n show: false,\n },\n tooltip: {\n show: false,\n },\n series: [\n {\n type: 'gauge',\n center: ['50%', '65%'],\n radius: '86%',\n startAngle: 200,\n endAngle: -20,\n min: 0,\n max,\n silent: true,\n progress: {\n show: true,\n width: PROGRESS_WIDTH,\n itemStyle: {\n color: 'auto',\n },\n },\n pointer: {\n show: false,\n },\n axisLine: {\n lineStyle: {\n color: [[1, '#e1e5e9']], // TODO (sjcobb): use future chart theme colors\n width: PROGRESS_WIDTH,\n },\n },\n axisTick: {\n show: false,\n distance: 0,\n },\n splitLine: {\n show: false,\n },\n axisLabel: {\n show: false,\n distance: -18,\n color: '#999',\n fontSize: 12,\n },\n anchor: {\n show: false,\n },\n title: {\n show: false,\n },\n detail: {\n show: false,\n },\n data: [\n {\n value: data.value,\n },\n ],\n },\n {\n type: 'gauge',\n center: ['50%', '65%'],\n radius: '100%',\n startAngle: 200,\n endAngle: -20,\n min: 0,\n max,\n pointer: {\n show: true,\n // pointer hidden for small panels, path taken from ex: https://echarts.apache.org/examples/en/editor.html?c=gauge-grade\n icon: width > GAUGE_SMALL_BREAKPOINT ? 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z' : 'none',\n length: 10,\n width: 5,\n offsetCenter: [0, '-49%'],\n itemStyle: {\n color: 'auto',\n },\n },\n axisLine,\n axisTick: {\n show: false,\n },\n splitLine: {\n show: false,\n },\n axisLabel: {\n show: false,\n },\n detail: {\n show: true,\n width: '60%',\n borderRadius: 8,\n offsetCenter: [0, '-9%'],\n color: 'inherit', // allows value color to match active threshold color\n fontSize: valueSizeClamp,\n formatter: (value: number) => {\n return formatValue(value, unit);\n },\n },\n data: [\n {\n value: data.value,\n name: data.label,\n // TODO: new UX for series names, create separate React component or reuse ListLegendItem\n // https://echarts.apache.org/en/option.html#series-gauge.data.title\n title: {\n show: true,\n color: chartsTheme.echartsTheme.textStyle?.color ?? 'inherit', // series name font color\n offsetCenter: [0, '55%'],\n overflow: 'truncate',\n fontSize: 12,\n width: width * 0.8,\n },\n },\n ],\n },\n ],\n };\n }, [data, width, height, chartsTheme, unit, axisLine, max]);\n\n return (\n <EChart\n sx={{\n width: width,\n height: height,\n padding: `${chartsTheme.container.padding.default}px`,\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n />\n );\n}\n\n/**\n * Responsive font size depending on number of characters, clamp used\n * to ensure size stays within given range\n */\nexport function getResponsiveValueSize(value: number, unit: UnitOptions, width: number, height: number) {\n const MIN_SIZE = 3;\n const MAX_SIZE = 24;\n const SIZE_MULTIPLIER = 0.7;\n const formattedValue = formatValue(value, unit);\n const valueCharacters = formattedValue.length ?? 2;\n const valueSize = (Math.min(width, height) / valueCharacters) * SIZE_MULTIPLIER;\n return `clamp(${MIN_SIZE}px, ${valueSize}px, ${MAX_SIZE}px)`;\n}\n"],"names":["useDeepMemo","use","GaugeChart","EChartsGaugeChart","GridComponent","TitleComponent","TooltipComponent","CanvasRenderer","useChartsTheme","formatValue","EChart","PROGRESS_WIDTH","GAUGE_SMALL_BREAKPOINT","props","width","height","data","unit","axisLine","max","chartsTheme","option","value","undefined","noDataOption","valueSizeClamp","getResponsiveValueSize","title","show","tooltip","series","type","center","radius","startAngle","endAngle","min","silent","progress","itemStyle","color","pointer","lineStyle","axisTick","distance","splitLine","axisLabel","fontSize","anchor","detail","icon","length","offsetCenter","borderRadius","formatter","name","label","echartsTheme","textStyle","overflow","sx","padding","container","default","theme","MIN_SIZE","MAX_SIZE","SIZE_MULTIPLIER","formattedValue","valueCharacters","valueSize","Math"],"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,WAAW,QAAQ,kBAAkB,CAAC;AAC/C,SAASC,GAAG,QAA2B,cAAc,CAAC;AACtD,SAASC,U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,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC/D,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/GaugeChart/GaugeChart.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 { useDeepMemo } from '@perses-dev/core';\nimport { use, EChartsCoreOption } from 'echarts/core';\nimport { GaugeChart as EChartsGaugeChart, GaugeSeriesOption } from 'echarts/charts';\nimport { GridComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { useChartsTheme } from '../context/ChartsThemeProvider';\nimport { formatValue, UnitOptions } from '../model/units';\nimport { EChart } from '../EChart';\n\nuse([EChartsGaugeChart, GridComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nconst PROGRESS_WIDTH = 16;\n\n// adjusts when to show pointer icon\nconst GAUGE_SMALL_BREAKPOINT = 170;\n\nexport type GaugeChartValue = number | null | undefined;\n\nexport type GaugeSeries = {\n value: GaugeChartValue;\n label: string;\n};\n\nexport interface GaugeChartProps {\n width: number;\n height: number;\n data: GaugeSeries;\n unit: UnitOptions;\n axisLine: GaugeSeriesOption['axisLine'];\n max?: number;\n}\n\nexport function GaugeChart(props: GaugeChartProps) {\n const { width, height, data, unit, axisLine, max } = props;\n const chartsTheme = useChartsTheme();\n\n // useDeepMemo ensures value size util does not rerun everytime you hover on the chart\n const option: EChartsCoreOption = useDeepMemo(() => {\n if (data.value === undefined || data.value === null) return chartsTheme.noDataOption;\n\n // adjusts fontSize depending on number of characters\n const valueSizeClamp = getResponsiveValueSize(data.value, unit, width, height);\n\n return {\n title: {\n show: false,\n },\n tooltip: {\n show: false,\n },\n series: [\n {\n type: 'gauge',\n center: ['50%', '65%'],\n radius: '86%',\n startAngle: 200,\n endAngle: -20,\n min: 0,\n max,\n silent: true,\n progress: {\n show: true,\n width: PROGRESS_WIDTH,\n itemStyle: {\n color: 'auto',\n },\n },\n pointer: {\n show: false,\n },\n axisLine: {\n lineStyle: {\n color: [[1, '#e1e5e9']], // TODO (sjcobb): use future chart theme colors\n width: PROGRESS_WIDTH,\n },\n },\n axisTick: {\n show: false,\n distance: 0,\n },\n splitLine: {\n show: false,\n },\n axisLabel: {\n show: false,\n distance: -18,\n color: '#999',\n fontSize: 12,\n },\n anchor: {\n show: false,\n },\n title: {\n show: false,\n },\n detail: {\n show: false,\n },\n data: [\n {\n value: data.value,\n },\n ],\n },\n {\n type: 'gauge',\n center: ['50%', '65%'],\n radius: '100%',\n startAngle: 200,\n endAngle: -20,\n min: 0,\n max,\n pointer: {\n show: true,\n // pointer hidden for small panels, path taken from ex: https://echarts.apache.org/examples/en/editor.html?c=gauge-grade\n icon: width > GAUGE_SMALL_BREAKPOINT ? 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z' : 'none',\n length: 10,\n width: 5,\n offsetCenter: [0, '-49%'],\n itemStyle: {\n color: 'auto',\n },\n },\n axisLine,\n axisTick: {\n show: false,\n },\n splitLine: {\n show: false,\n },\n axisLabel: {\n show: false,\n },\n detail: {\n show: true,\n width: '60%',\n borderRadius: 8,\n offsetCenter: [0, '-9%'],\n color: 'inherit', // allows value color to match active threshold color\n fontSize: valueSizeClamp,\n formatter: (value: number) => {\n return formatValue(value, unit);\n },\n },\n data: [\n {\n value: data.value,\n name: data.label,\n // TODO: new UX for series names, create separate React component or reuse ListLegendItem\n // https://echarts.apache.org/en/option.html#series-gauge.data.title\n title: {\n show: true,\n color: chartsTheme.echartsTheme.textStyle?.color ?? 'inherit', // series name font color\n offsetCenter: [0, '55%'],\n overflow: 'truncate',\n fontSize: 12,\n width: width * 0.8,\n },\n },\n ],\n },\n ],\n };\n }, [data, width, height, chartsTheme, unit, axisLine, max]);\n\n return (\n <EChart\n sx={{\n width: width,\n height: height,\n padding: `${chartsTheme.container.padding.default}px`,\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n />\n );\n}\n\n/**\n * Responsive font size depending on number of characters, clamp used\n * to ensure size stays within given range\n */\nexport function getResponsiveValueSize(value: number, unit: UnitOptions, width: number, height: number) {\n const MIN_SIZE = 3;\n const MAX_SIZE = 24;\n const SIZE_MULTIPLIER = 0.7;\n const formattedValue = formatValue(value, unit);\n const valueCharacters = formattedValue.length ?? 2;\n const valueSize = (Math.min(width, height) / valueCharacters) * SIZE_MULTIPLIER;\n return `clamp(${MIN_SIZE}px, ${valueSize}px, ${MAX_SIZE}px)`;\n}\n"],"names":["useDeepMemo","use","GaugeChart","EChartsGaugeChart","GridComponent","TitleComponent","TooltipComponent","CanvasRenderer","useChartsTheme","formatValue","EChart","PROGRESS_WIDTH","GAUGE_SMALL_BREAKPOINT","props","width","height","data","unit","axisLine","max","chartsTheme","option","value","undefined","noDataOption","valueSizeClamp","getResponsiveValueSize","title","show","tooltip","series","type","center","radius","startAngle","endAngle","min","silent","progress","itemStyle","color","pointer","lineStyle","axisTick","distance","splitLine","axisLabel","fontSize","anchor","detail","icon","length","offsetCenter","borderRadius","formatter","name","label","echartsTheme","textStyle","overflow","sx","padding","container","default","theme","MIN_SIZE","MAX_SIZE","SIZE_MULTIPLIER","formattedValue","valueCharacters","valueSize","Math"],"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,WAAW,QAAQ,kBAAkB,CAAC;AAC/C,SAASC,GAAG,QAA2B,cAAc,CAAC;AACtD,SAASC,UAAU,IAAIC,iBAAiB,QA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AC,CAAC;AAC/D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InfoTooltip.d.ts","sourceRoot":"","sources":["../../src/InfoTooltip/InfoTooltip.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,oBAAY,gBAAgB,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEnE,UAAU,gBAAgB;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,WAAW,iFAQrB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"InfoTooltip.d.ts","sourceRoot":"","sources":["../../src/InfoTooltip/InfoTooltip.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,oBAAY,gBAAgB,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEnE,UAAU,gBAAgB;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,WAAW,iFAQrB,gBAAgB,gBAkBlB,CAAC"}
|
|
@@ -14,6 +14,12 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
14
14
|
import React from 'react';
|
|
15
15
|
import { styled, Tooltip as MuiTooltip, tooltipClasses, Typography } from '@mui/material';
|
|
16
16
|
export const InfoTooltip = ({ id , title , description , placement , children , enterDelay , enterNextDelay })=>{
|
|
17
|
+
// Only wrap in a div if passed a non-element. This enables the tooltip to
|
|
18
|
+
// support text with a wrapper div while avoiding breaking css on element
|
|
19
|
+
// children by unnecessarily wrapping them.
|
|
20
|
+
const formattedChildren = /*#__PURE__*/ React.isValidElement(children) ? children : /*#__PURE__*/ _jsx("div", {
|
|
21
|
+
children: children
|
|
22
|
+
});
|
|
17
23
|
return /*#__PURE__*/ _jsx(StyledTooltip, {
|
|
18
24
|
arrow: true,
|
|
19
25
|
id: id,
|
|
@@ -24,9 +30,7 @@ export const InfoTooltip = ({ id , title , description , placement , children ,
|
|
|
24
30
|
}),
|
|
25
31
|
enterDelay: enterDelay !== null && enterDelay !== void 0 ? enterDelay : 500,
|
|
26
32
|
enterNextDelay: enterNextDelay !== null && enterNextDelay !== void 0 ? enterNextDelay : 500,
|
|
27
|
-
children:
|
|
28
|
-
children: children
|
|
29
|
-
})
|
|
33
|
+
children: formattedChildren
|
|
30
34
|
});
|
|
31
35
|
};
|
|
32
36
|
const TooltipContent = ({ title , description })=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/InfoTooltip/InfoTooltip.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 React from 'react';\nimport {\n styled,\n TooltipProps as MuiTooltipProps,\n Tooltip as MuiTooltip,\n tooltipClasses,\n Typography,\n} from '@mui/material';\n\nexport type TooltipPlacement = 'top' | 'left' | 'right' | 'bottom';\n\ninterface InfoTooltipProps {\n description: string;\n children: React.ReactNode;\n id?: string;\n title?: string;\n placement?: TooltipPlacement;\n enterDelay?: number; // default is 500ms\n enterNextDelay?: number; // default is 500ms\n}\n\nexport const InfoTooltip = ({\n id,\n title,\n description,\n placement,\n children,\n enterDelay,\n enterNextDelay,\n}: InfoTooltipProps) => {\n return (\n <StyledTooltip\n arrow\n id={id}\n placement={placement ?? 'top'}\n title={<TooltipContent title={title} description={description} />}\n enterDelay={enterDelay ?? 500}\n enterNextDelay={enterNextDelay ?? 500}\n >\n
|
|
1
|
+
{"version":3,"sources":["../../src/InfoTooltip/InfoTooltip.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 React from 'react';\nimport {\n styled,\n TooltipProps as MuiTooltipProps,\n Tooltip as MuiTooltip,\n tooltipClasses,\n Typography,\n} from '@mui/material';\n\nexport type TooltipPlacement = 'top' | 'left' | 'right' | 'bottom';\n\ninterface InfoTooltipProps {\n description: string;\n children: React.ReactNode;\n id?: string;\n title?: string;\n placement?: TooltipPlacement;\n enterDelay?: number; // default is 500ms\n enterNextDelay?: number; // default is 500ms\n}\n\nexport const InfoTooltip = ({\n id,\n title,\n description,\n placement,\n children,\n enterDelay,\n enterNextDelay,\n}: InfoTooltipProps) => {\n // Only wrap in a div if passed a non-element. This enables the tooltip to\n // support text with a wrapper div while avoiding breaking css on element\n // children by unnecessarily wrapping them.\n const formattedChildren = React.isValidElement(children) ? children : <div>{children}</div>;\n\n return (\n <StyledTooltip\n arrow\n id={id}\n placement={placement ?? 'top'}\n title={<TooltipContent title={title} description={description} />}\n enterDelay={enterDelay ?? 500}\n enterNextDelay={enterNextDelay ?? 500}\n >\n {formattedChildren}\n </StyledTooltip>\n );\n};\n\nconst TooltipContent = ({ title, description }: Pick<InfoTooltipProps, 'title' | 'description'>) => {\n return (\n <>\n {title && (\n <Typography\n variant=\"body2\"\n sx={(theme) => ({\n color: theme.palette.text.primary,\n fontWeight: theme.typography.fontWeightMedium,\n })}\n >\n {title}\n </Typography>\n )}\n <Typography\n variant=\"caption\"\n sx={(theme) => ({\n color: theme.palette.text.primary,\n })}\n >\n {description}\n </Typography>\n </>\n );\n};\n\nconst StyledTooltip = styled(({ className, ...props }: MuiTooltipProps) => (\n <MuiTooltip {...props} classes={{ popper: className }} />\n))(({ theme }) => ({\n [`& .${tooltipClasses.tooltip}`]: {\n backgroundColor: theme.palette.background.tooltip,\n color: theme.palette.text.primary,\n maxWidth: '300px',\n padding: theme.spacing(1),\n boxShadow: theme.shadows[1],\n },\n [`& .${tooltipClasses.arrow}`]: {\n color: theme.palette.background.tooltip,\n },\n}));\n"],"names":["React","styled","Tooltip","MuiTooltip","tooltipClasses","Typography","InfoTooltip","id","title","description","placement","children","enterDelay","enterNextDelay","formattedChildren","isValidElement","div","StyledTooltip","arrow","TooltipContent","variant","sx","theme","color","palette","text","primary","fontWeight","typography","fontWeightMedium","className","props","classes","popper","tooltip","backgroundColor","background","maxWidth","padding","spacing","boxShadow","shadows"],"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,OAAOA,KAAK,MAAM,OAAO,CAAC;AAC1B,SACEC,MAAM,EAENC,OAAO,IAAIC,UAAU,EACrBC,cAAc,EACdC,UAAU,QACL,eAAe,CAAC;AAcvB,OAAO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CAACC,OAAO;qBAClC,CAAA,AAAC;0BAEDjB,WAAW;cACD;;MACZ,CACH;AACJ,CAAC,AAAC;AAEF,MAAMQ,aAAa,GAAGhB,MAAM,CAAC,CAAC,EAAE6B,SAAS,CAAA,EAAE,GAAGC,KAAK,EAAmB,iBACpE,KAAC5B,UAAU;QAAE,GAAG4B,KAAK;QAAEC,OAAO,EAAE;YAAEC,MAAM,EAAEH,SAAS;SAAE;MAAI,AAC1D,CAAC,CAAC,CAAC,EAAER,KAAK,CAAA,EAAE,GAAM,CAAA;QACjB,CAAC,CAAC,GAAG,EAAElB,cAAc,CAAC8B,OAAO,CAAC,CAAC,CAAC,EAAE;YAChCC,eAAe,EAAEb,KAAK,CAACE,OAAO,CAACY,UAAU,CAACF,OAAO;YACjDX,KAAK,EAAED,KAAK,CAACE,OAAO,CAACC,IAAI,CAACC,OAAO;YACjCW,QAAQ,EAAE,OAAO;YACjBC,OAAO,EAAEhB,KAAK,CAACiB,OAAO,CAAC,CAAC,CAAC;YACzBC,SAAS,EAAElB,KAAK,CAACmB,OAAO,CAAC,CAAC,CAAC;SAC5B;QACD,CAAC,CAAC,GAAG,EAAErC,cAAc,CAACc,KAAK,CAAC,CAAC,CAAC,EAAE;YAC9BK,KAAK,EAAED,KAAK,CAACE,OAAO,CAACY,UAAU,CAACF,OAAO;SACxC;KACF,CAAA,AAAC,CAAC,AAAC"}
|
package/dist/Legend/Legend.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { LegendOptions, LegendItem } from '../model';
|
|
3
|
-
interface LegendProps {
|
|
3
|
+
export interface LegendProps {
|
|
4
4
|
width: number;
|
|
5
5
|
height: number;
|
|
6
6
|
data: LegendItem[];
|
|
7
7
|
options: LegendOptions;
|
|
8
8
|
}
|
|
9
9
|
export declare function Legend({ width, height, options, data }: LegendProps): JSX.Element;
|
|
10
|
-
export {};
|
|
11
10
|
//# sourceMappingURL=Legend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Legend.d.ts","sourceRoot":"","sources":["../../src/Legend/Legend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAIrD,
|
|
1
|
+
{"version":3,"file":"Legend.d.ts","sourceRoot":"","sources":["../../src/Legend/Legend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAIrD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,wBAAgB,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,WAAW,eA+BnE"}
|
package/dist/Legend/Legend.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
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
|
-
import { jsx as _jsx
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { Box } from '@mui/material';
|
|
15
15
|
import { ListLegend } from './ListLegend';
|
|
16
16
|
import { CompactLegend } from './CompactLegend';
|
|
@@ -31,20 +31,17 @@ export function Legend({ width , height , options , data }) {
|
|
|
31
31
|
})
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
-
return /*#__PURE__*/
|
|
34
|
+
return /*#__PURE__*/ _jsx(Box, {
|
|
35
35
|
sx: {
|
|
36
36
|
width: width,
|
|
37
37
|
height: height,
|
|
38
38
|
position: 'absolute',
|
|
39
39
|
bottom: 0
|
|
40
40
|
},
|
|
41
|
-
children:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}),
|
|
46
|
-
";"
|
|
47
|
-
]
|
|
41
|
+
children: /*#__PURE__*/ _jsx(CompactLegend, {
|
|
42
|
+
items: data,
|
|
43
|
+
height: height
|
|
44
|
+
})
|
|
48
45
|
});
|
|
49
46
|
}
|
|
50
47
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Legend/Legend.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 } from '@mui/material';\nimport { LegendOptions, LegendItem } from '../model';\nimport { ListLegend } from './ListLegend';\nimport { CompactLegend } from './CompactLegend';\n\
|
|
1
|
+
{"version":3,"sources":["../../src/Legend/Legend.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 } from '@mui/material';\nimport { LegendOptions, LegendItem } from '../model';\nimport { ListLegend } from './ListLegend';\nimport { CompactLegend } from './CompactLegend';\n\nexport interface LegendProps {\n width: number;\n height: number;\n data: LegendItem[];\n options: LegendOptions;\n}\n\nexport function Legend({ width, height, options, data }: LegendProps) {\n if (options.position === 'Right') {\n return (\n <Box\n sx={{\n width: width,\n height: '100%',\n position: 'absolute',\n top: 0,\n right: 0,\n overflowX: 'hidden',\n overflowY: 'scroll',\n }}\n >\n <ListLegend items={data} />\n </Box>\n );\n }\n\n return (\n <Box\n sx={{\n width: width,\n height: height,\n position: 'absolute',\n bottom: 0,\n }}\n >\n <CompactLegend items={data} height={height} />\n </Box>\n );\n}\n"],"names":["Box","ListLegend","CompactLegend","Legend","width","height","options","data","position","sx","top","right","overflowX","overflowY","items","bottom"],"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,QAAQ,eAAe,CAAC;AAEpC,SAASC,UAAU,QAAQ,cAAc,CAAC;AAC1C,SAASC,aAAa,QAAQ,iBAAiB,CAAC;AAShD,OAAO,SAASC,MAAM,CAAC,EAAEC,KAAK,CAAA,EAAEC,MAAM,CAAA,EAAEC,OAAO,CAAA,EAAEC,IAAI,CAAA,EAAe,EAAE;IACpE,IAAID,OAAO,CAACE,QAAQ,KAAK,OAAO,EAAE;QAChC,qBACE,KAACR,GAAG;YACFS,EAAE,EAAE;gBACFL,KAAK,EAAEA,KAAK;gBACZC,MAAM,EAAE,MAAM;gBACdG,QAAQ,EAAE,UAAU;gBACpBE,GAAG,EAAE,CAAC;gBACNC,KAAK,EAAE,CAAC;gBACRC,SAAS,EAAE,QAAQ;gBACnBC,SAAS,EAAE,QAAQ;aACpB;sBAED,cAAA,KAACZ,UAAU;gBAACa,KAAK,EAAEP,IAAI;cAAI;UACvB,CACN;IACJ,CAAC;IAED,qBACE,KAACP,GAAG;QACFS,EAAE,EAAE;YACFL,KAAK,EAAEA,KAAK;YACZC,MAAM,EAAEA,MAAM;YACdG,QAAQ,EAAE,UAAU;YACpBO,MAAM,EAAE,CAAC;SACV;kBAED,cAAA,KAACb,aAAa;YAACY,KAAK,EAAEP,IAAI;YAAEF,MAAM,EAAEA,MAAM;UAAI;MAC1C,CACN;AACJ,CAAC"}
|
|
@@ -3,7 +3,10 @@ import type { GridComponentOption, LegendComponentOption, YAXisComponentOption }
|
|
|
3
3
|
import { EChartsDataFormat } from '../model/graph';
|
|
4
4
|
import { UnitOptions } from '../model/units';
|
|
5
5
|
import { ZoomEventData } from './utils';
|
|
6
|
-
interface LineChartProps {
|
|
6
|
+
export interface LineChartProps {
|
|
7
|
+
/**
|
|
8
|
+
* Height of the chart
|
|
9
|
+
*/
|
|
7
10
|
height: number;
|
|
8
11
|
data: EChartsDataFormat;
|
|
9
12
|
yAxis?: YAXisComponentOption;
|
|
@@ -14,5 +17,4 @@ interface LineChartProps {
|
|
|
14
17
|
onDoubleClick?: (e: MouseEvent) => void;
|
|
15
18
|
}
|
|
16
19
|
export declare function LineChart({ height, data, yAxis, unit, grid, legend, onDataZoom, onDoubleClick }: LineChartProps): JSX.Element;
|
|
17
|
-
export {};
|
|
18
20
|
//# sourceMappingURL=LineChart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../src/LineChart/LineChart.tsx"],"names":[],"mappings":"AAaA,
|
|
1
|
+
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../src/LineChart/LineChart.tsx"],"names":[],"mappings":"AAaA,OAAc,EAAE,UAAU,EAA6B,MAAM,OAAO,CAAC;AAErE,OAAO,KAAK,EAEV,mBAAmB,EAEnB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAgBjB,OAAO,EAAE,iBAAiB,EAA+B,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAI7C,OAAO,EAA0E,aAAa,EAAE,MAAM,SAAS,CAAC;AAgBhH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;CACzC;AAED,wBAAgB,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE,cAAc,eAgJ/G"}
|
|
@@ -11,7 +11,7 @@
|
|
|
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 } from "react/jsx-runtime";
|
|
14
|
-
import { useMemo, useRef, useState } from 'react';
|
|
14
|
+
import React, { useMemo, useRef, useState } from 'react';
|
|
15
15
|
import { Box } from '@mui/material';
|
|
16
16
|
import { use } from 'echarts/core';
|
|
17
17
|
import { LineChart as EChartsLineChart } from 'echarts/charts';
|