@perses-dev/stat-chart-plugin 0.10.0 → 0.11.1
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/__mf/css/async/442.d3010b86.css +1 -0
- package/__mf/css/async/61.d3010b86.css +1 -0
- package/__mf/css/async/823.d3010b86.css +1 -0
- package/__mf/js/StatChart.91907838.js +6 -0
- package/__mf/js/async/{964.2c4a1982.js → 121.3f61f76f.js} +2 -2
- package/__mf/js/async/{488.daa22b59.js → 177.eb221fda.js} +1 -1
- package/__mf/js/async/192.8a915b5e.js +1 -0
- package/__mf/js/async/2.086684e1.js +1 -0
- package/__mf/js/async/205.1bcd0ed9.js +83 -0
- package/__mf/js/async/235.046777ba.js +1 -0
- package/__mf/js/async/252.71d76564.js +22 -0
- package/__mf/js/async/274.d4e1eee8.js +2 -0
- package/__mf/js/async/293.d523e0ab.js +1 -0
- package/__mf/js/async/302.b54c0505.js +2 -0
- package/__mf/js/async/302.b54c0505.js.LICENSE.txt +13 -0
- package/__mf/js/async/356.f5a1c439.js +1 -0
- package/__mf/js/async/392.a8143615.js +2 -0
- package/__mf/js/async/450.13fefb05.js +1 -0
- package/__mf/js/async/465.fc9973fc.js +2 -0
- package/__mf/js/async/470.57be52e3.js +2 -0
- package/__mf/js/async/{214.fbd87600.js → 587.6d7b1a7f.js} +1 -1
- package/__mf/js/async/588.496be9cb.js +1 -0
- package/__mf/js/async/616.f83c59ff.js +1 -0
- package/__mf/js/async/71.603fe88a.js +1 -0
- package/__mf/js/async/721.0467c07c.js +1 -0
- package/__mf/js/async/790.42bd307b.js +7 -0
- package/__mf/js/async/873.bde3655e.js +1 -0
- package/__mf/js/async/911.29a700f7.js +65 -0
- package/__mf/js/async/941.c1c0755a.js +2 -0
- package/__mf/js/async/{738.ab4d3413.js → 968.eb198ceb.js} +1 -1
- package/__mf/js/async/978.c7471d24.js +1 -0
- package/__mf/js/async/__federation_expose_StatChart.fd6bf4ac.js +1 -0
- package/__mf/js/async/lib-router.ed92c54d.js +2 -0
- package/__mf/js/main.5a7ad716.js +6 -0
- package/lib/StatChartBase.d.ts +2 -0
- package/lib/StatChartBase.d.ts.map +1 -1
- package/lib/StatChartBase.js +92 -30
- package/lib/StatChartBase.js.map +1 -1
- package/lib/StatChartOptionsEditorSettings.d.ts.map +1 -1
- package/lib/StatChartOptionsEditorSettings.js +87 -31
- package/lib/StatChartOptionsEditorSettings.js.map +1 -1
- package/lib/StatChartPanel.d.ts.map +1 -1
- package/lib/StatChartPanel.js +7 -4
- package/lib/StatChartPanel.js.map +1 -1
- package/lib/bootstrap.js +1 -1
- package/lib/bootstrap.js.map +1 -1
- package/lib/cjs/StatChartBase.js +90 -28
- package/lib/cjs/StatChartOptionsEditorSettings.js +85 -29
- package/lib/cjs/StatChartPanel.js +7 -4
- package/lib/cjs/index-federation.js +12 -12
- package/lib/cjs/stat-chart-model.js +47 -4
- package/lib/stat-chart-model.d.ts +16 -1
- package/lib/stat-chart-model.d.ts.map +1 -1
- package/lib/stat-chart-model.js +33 -1
- package/lib/stat-chart-model.js.map +1 -1
- package/mf-manifest.json +34 -33
- package/mf-stats.json +34 -33
- package/package.json +12 -6
- package/__mf/css/async/263.1ed8bb01.css +0 -1
- package/__mf/css/async/341.1ed8bb01.css +0 -1
- package/__mf/css/async/759.1ed8bb01.css +0 -1
- package/__mf/js/StatChart.4380d9d9.js +0 -5
- package/__mf/js/async/109.8841516b.js +0 -73
- package/__mf/js/async/173.879ec01b.js +0 -2
- package/__mf/js/async/181.985d810b.js +0 -83
- package/__mf/js/async/224.82f1452f.js +0 -1
- package/__mf/js/async/238.e184091d.js +0 -1
- package/__mf/js/async/288.b314a020.js +0 -7
- package/__mf/js/async/292.a2435289.js +0 -1
- package/__mf/js/async/298.db4e15c8.js +0 -1
- package/__mf/js/async/409.b9808041.js +0 -1
- package/__mf/js/async/651.f2aaf868.js +0 -1
- package/__mf/js/async/694.d6624664.js +0 -1
- package/__mf/js/async/740.2a430835.js +0 -1
- package/__mf/js/async/75.0e924b9e.js +0 -1
- package/__mf/js/async/770.edf0b438.js +0 -1
- package/__mf/js/async/804.ee813935.js +0 -1
- package/__mf/js/async/828.d18e1139.js +0 -65
- package/__mf/js/async/863.41130256.js +0 -2
- package/__mf/js/async/954.8c39b26f.js +0 -2
- package/__mf/js/async/960.a322ec99.js +0 -2
- package/__mf/js/async/962.5508c92d.js +0 -1
- package/__mf/js/async/981.c97e9bc4.js +0 -2
- package/__mf/js/async/__federation_expose_StatChart.20144587.js +0 -1
- package/__mf/js/async/lib-router.5a2b101a.js +0 -2
- package/__mf/js/main.0d096334.js +0 -5
- /package/__mf/js/async/{964.2c4a1982.js.LICENSE.txt → 121.3f61f76f.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{181.985d810b.js.LICENSE.txt → 205.1bcd0ed9.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{109.8841516b.js.LICENSE.txt → 252.71d76564.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{960.a322ec99.js.LICENSE.txt → 274.d4e1eee8.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{981.c97e9bc4.js.LICENSE.txt → 392.a8143615.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{954.8c39b26f.js.LICENSE.txt → 465.fc9973fc.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{173.879ec01b.js.LICENSE.txt → 470.57be52e3.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{288.b314a020.js.LICENSE.txt → 790.42bd307b.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{863.41130256.js.LICENSE.txt → 941.c1c0755a.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{lib-router.5a2b101a.js.LICENSE.txt → lib-router.ed92c54d.js.LICENSE.txt} +0 -0
package/lib/StatChartBase.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
2
|
// Copyright 2023 The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,15 +11,15 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { useMemo } from 'react';
|
|
15
|
-
import { Box, Typography, styled } from '@mui/material';
|
|
15
|
+
import { Box, Typography, styled, useTheme } from '@mui/material';
|
|
16
16
|
import merge from 'lodash/merge';
|
|
17
17
|
import { use } from 'echarts/core';
|
|
18
18
|
import { LineChart as EChartsLineChart } from 'echarts/charts';
|
|
19
19
|
import { GridComponent, DatasetComponent, TitleComponent, TooltipComponent } from 'echarts/components';
|
|
20
20
|
import { CanvasRenderer } from 'echarts/renderers';
|
|
21
21
|
import { EChart, useChartsTheme } from '@perses-dev/components';
|
|
22
|
+
import chroma from 'chroma-js';
|
|
22
23
|
import { useOptimalFontSize } from './utils/calculate-font-size';
|
|
23
24
|
import { formatStatChartValue } from './utils/format-stat-chart-value';
|
|
24
25
|
use([
|
|
@@ -33,10 +34,12 @@ const LINE_HEIGHT = 1.2;
|
|
|
33
34
|
const SERIES_NAME_MAX_FONT_SIZE = 30;
|
|
34
35
|
const SERIES_NAME_FONT_WEIGHT = 400;
|
|
35
36
|
const VALUE_FONT_WEIGHT = 700;
|
|
37
|
+
const WHITE_COLOR_CODE = '#FFFFFF';
|
|
38
|
+
const BLACK_COLOR_CODE = '#000000';
|
|
36
39
|
export const StatChartBase = (props)=>{
|
|
37
|
-
const { width, height, data, sparkline, showSeriesName, format, valueFontSize } = props;
|
|
40
|
+
const { width, height, data, data: { color }, sparkline, showSeriesName, format, valueFontSize, colorMode } = props;
|
|
41
|
+
const { palette: { mode: paletteMode, text: { secondary } } } = useTheme();
|
|
38
42
|
const chartsTheme = useChartsTheme();
|
|
39
|
-
const color = data.color;
|
|
40
43
|
const formattedValue = formatStatChartValue(data.calculatedValue, format);
|
|
41
44
|
const containerPadding = chartsTheme.container.padding.default;
|
|
42
45
|
// calculate series name font size and height
|
|
@@ -68,10 +71,10 @@ export const StatChartBase = (props)=>{
|
|
|
68
71
|
// make sure the series name font size is slightly smaller than value font size
|
|
69
72
|
seriesNameFontSize = Math.min(optimalValueFontSize * 0.7, seriesNameFontSize);
|
|
70
73
|
const option = useMemo(()=>{
|
|
71
|
-
if (data.seriesData
|
|
74
|
+
if (!data.seriesData) return chartsTheme.noDataOption;
|
|
72
75
|
const series = data.seriesData;
|
|
73
76
|
const statSeries = [];
|
|
74
|
-
if (sparkline
|
|
77
|
+
if (sparkline) {
|
|
75
78
|
const lineSeries = {
|
|
76
79
|
type: 'line',
|
|
77
80
|
name: series.name,
|
|
@@ -81,7 +84,20 @@ export const StatChartBase = (props)=>{
|
|
|
81
84
|
animation: false,
|
|
82
85
|
silent: true
|
|
83
86
|
};
|
|
84
|
-
const
|
|
87
|
+
const clonedSparkLine = {
|
|
88
|
+
...sparkline
|
|
89
|
+
};
|
|
90
|
+
if (colorMode === 'background_solid') {
|
|
91
|
+
clonedSparkLine.areaStyle = {
|
|
92
|
+
color: WHITE_COLOR_CODE,
|
|
93
|
+
opacity: 0.4
|
|
94
|
+
};
|
|
95
|
+
clonedSparkLine.lineStyle = {
|
|
96
|
+
color: WHITE_COLOR_CODE,
|
|
97
|
+
opacity: 1
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const mergedSeries = merge(lineSeries, clonedSparkLine);
|
|
85
101
|
statSeries.push(mergedSeries);
|
|
86
102
|
}
|
|
87
103
|
const option = {
|
|
@@ -121,35 +137,81 @@ export const StatChartBase = (props)=>{
|
|
|
121
137
|
}, [
|
|
122
138
|
data,
|
|
123
139
|
chartsTheme,
|
|
124
|
-
sparkline
|
|
140
|
+
sparkline,
|
|
141
|
+
colorMode
|
|
125
142
|
]);
|
|
126
143
|
const textAlignment = sparkline ? 'auto' : 'center';
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
144
|
+
const styledFormattedValue = useMemo(()=>{
|
|
145
|
+
let valueColor = '';
|
|
146
|
+
switch(colorMode){
|
|
147
|
+
case 'background_solid':
|
|
148
|
+
valueColor = chroma.contrast(color, WHITE_COLOR_CODE) > chroma.contrast(color, BLACK_COLOR_CODE) ? WHITE_COLOR_CODE : BLACK_COLOR_CODE;
|
|
149
|
+
break;
|
|
150
|
+
case 'none':
|
|
151
|
+
valueColor = paletteMode === 'dark' ? WHITE_COLOR_CODE : BLACK_COLOR_CODE;
|
|
152
|
+
break;
|
|
153
|
+
case 'value':
|
|
154
|
+
default:
|
|
155
|
+
valueColor = color;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
return /*#__PURE__*/ _jsx(Value, {
|
|
159
|
+
variant: "h3",
|
|
160
|
+
color: valueColor,
|
|
161
|
+
fontSize: optimalValueFontSize,
|
|
162
|
+
padding: containerPadding,
|
|
163
|
+
children: formattedValue
|
|
164
|
+
});
|
|
165
|
+
}, [
|
|
166
|
+
colorMode,
|
|
167
|
+
containerPadding,
|
|
168
|
+
optimalValueFontSize,
|
|
169
|
+
formattedValue,
|
|
170
|
+
color,
|
|
171
|
+
paletteMode
|
|
172
|
+
]);
|
|
173
|
+
const seriesName = useMemo(()=>{
|
|
174
|
+
if (!showSeriesName) return null;
|
|
175
|
+
let textColor = '';
|
|
176
|
+
switch(colorMode){
|
|
177
|
+
case 'background_solid':
|
|
178
|
+
textColor = chroma.contrast(color, WHITE_COLOR_CODE) > chroma.contrast(color, BLACK_COLOR_CODE) ? WHITE_COLOR_CODE : BLACK_COLOR_CODE;
|
|
179
|
+
break;
|
|
180
|
+
case 'none':
|
|
181
|
+
case 'value':
|
|
182
|
+
default:
|
|
183
|
+
textColor = secondary;
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
return /*#__PURE__*/ _jsx(SeriesName, {
|
|
187
|
+
padding: containerPadding,
|
|
188
|
+
fontSize: seriesNameFontSize,
|
|
189
|
+
color: textColor,
|
|
190
|
+
children: data.seriesData?.name
|
|
191
|
+
});
|
|
192
|
+
}, [
|
|
193
|
+
colorMode,
|
|
194
|
+
showSeriesName,
|
|
195
|
+
secondary,
|
|
196
|
+
color,
|
|
197
|
+
containerPadding,
|
|
198
|
+
seriesNameFontSize,
|
|
199
|
+
data?.seriesData?.name
|
|
200
|
+
]);
|
|
133
201
|
return /*#__PURE__*/ _jsxs(Box, {
|
|
134
202
|
sx: {
|
|
135
203
|
height: '100%',
|
|
136
204
|
width: '100%',
|
|
137
|
-
|
|
205
|
+
backgroundColor: colorMode === 'background_solid' ? color : 'transparent',
|
|
206
|
+
display: 'flex',
|
|
207
|
+
flexDirection: 'column',
|
|
208
|
+
justifyContent: textAlignment,
|
|
209
|
+
alignItems: textAlignment
|
|
138
210
|
},
|
|
139
211
|
children: [
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
children: data.seriesData?.name
|
|
144
|
-
}),
|
|
145
|
-
/*#__PURE__*/ _jsx(Value, {
|
|
146
|
-
variant: "h3",
|
|
147
|
-
color: color,
|
|
148
|
-
fontSize: optimalValueFontSize,
|
|
149
|
-
padding: containerPadding,
|
|
150
|
-
children: formattedValue
|
|
151
|
-
}),
|
|
152
|
-
sparkline !== undefined && /*#__PURE__*/ _jsx(EChart, {
|
|
212
|
+
seriesName,
|
|
213
|
+
styledFormattedValue,
|
|
214
|
+
sparkline && /*#__PURE__*/ _jsx(EChart, {
|
|
153
215
|
sx: {
|
|
154
216
|
width: '100%'
|
|
155
217
|
},
|
|
@@ -167,8 +229,8 @@ export const StatChartBase = (props)=>{
|
|
|
167
229
|
};
|
|
168
230
|
const SeriesName = styled(Typography, {
|
|
169
231
|
shouldForwardProp: (prop)=>prop !== 'padding' && prop !== 'fontSize'
|
|
170
|
-
})(({
|
|
171
|
-
color:
|
|
232
|
+
})(({ padding, fontSize, color })=>({
|
|
233
|
+
color: color,
|
|
172
234
|
padding: `${padding}px`,
|
|
173
235
|
fontSize: `${fontSize}px`,
|
|
174
236
|
overflow: 'hidden',
|
package/lib/StatChartBase.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/StatChartBase.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 { FC, useMemo } from 'react';\nimport { FormatOptions } from '@perses-dev/core';\nimport { Box, Typography, styled } from '@mui/material';\nimport merge from 'lodash/merge';\nimport { use, EChartsCoreOption } from 'echarts/core';\nimport { LineChart as EChartsLineChart, LineSeriesOption } from 'echarts/charts';\nimport { GridComponent, DatasetComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { EChart, FontSizeOption, GraphSeries, useChartsTheme } from '@perses-dev/components';\nimport { useOptimalFontSize } from './utils/calculate-font-size';\nimport { formatStatChartValue } from './utils/format-stat-chart-value';\n\nuse([EChartsLineChart, GridComponent, DatasetComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nconst LINE_HEIGHT = 1.2;\nconst SERIES_NAME_MAX_FONT_SIZE = 30;\nconst SERIES_NAME_FONT_WEIGHT = 400;\nconst VALUE_FONT_WEIGHT = 700;\n\nexport interface StatChartData {\n color: string;\n calculatedValue?: string | number | null;\n seriesData?: GraphSeries;\n}\n\nexport interface StatChartProps {\n width: number;\n height: number;\n data: StatChartData;\n format?: FormatOptions;\n sparkline?: LineSeriesOption;\n showSeriesName?: boolean;\n valueFontSize?: FontSizeOption;\n}\n\nexport const StatChartBase: FC<StatChartProps> = (props) => {\n const { width, height, data, sparkline, showSeriesName, format, valueFontSize } = props;\n const chartsTheme = useChartsTheme();\n const color = data.color;\n\n const formattedValue = formatStatChartValue(data.calculatedValue, format);\n\n const containerPadding = chartsTheme.container.padding.default;\n\n // calculate series name font size and height\n let seriesNameFontSize = useOptimalFontSize({\n text: data?.seriesData?.name ?? '',\n fontWeight: SERIES_NAME_FONT_WEIGHT,\n width,\n height: height * 0.125, // assume series name will take 12.5% of available height\n lineHeight: LINE_HEIGHT,\n maxSize: SERIES_NAME_MAX_FONT_SIZE,\n });\n\n const seriesNameHeight = showSeriesName ? seriesNameFontSize * LINE_HEIGHT + containerPadding : 0;\n\n // calculate value font size and height\n const availableWidth = width - containerPadding * 2;\n const availableHeight = height - seriesNameHeight;\n const optimalValueFontSize = useOptimalFontSize({\n text: formattedValue,\n // override the font size if user selects it in the settings\n fontSizeOverride: valueFontSize,\n fontWeight: VALUE_FONT_WEIGHT,\n // without sparkline, use only 50% of the available width so it looks better for multiseries\n width: sparkline ? availableWidth : availableWidth * 0.5,\n // with sparkline, use only 25% of available height to leave room for chart\n // without sparkline, value should take up 90% of available space\n height: sparkline ? availableHeight * 0.25 : availableHeight * 0.9,\n lineHeight: LINE_HEIGHT,\n });\n const valueFontHeight = optimalValueFontSize * LINE_HEIGHT;\n\n // make sure the series name font size is slightly smaller than value font size\n seriesNameFontSize = Math.min(optimalValueFontSize * 0.7, seriesNameFontSize);\n\n const option: EChartsCoreOption = useMemo(() => {\n if (data.seriesData === undefined) return chartsTheme.noDataOption;\n\n const series = data.seriesData;\n const statSeries: LineSeriesOption[] = [];\n\n if (sparkline !== undefined) {\n const lineSeries = {\n type: 'line',\n name: series.name,\n data: series.values,\n zlevel: 1,\n symbol: 'none',\n animation: false,\n silent: true,\n };\n const mergedSeries = merge(lineSeries, sparkline);\n statSeries.push(mergedSeries);\n }\n\n const option = {\n title: {\n show: false,\n },\n grid: {\n show: false,\n top: '35%', // adds space above sparkline\n right: 0,\n bottom: 0,\n left: 0,\n containLabel: false,\n },\n xAxis: {\n type: 'time',\n show: false,\n boundaryGap: false,\n },\n yAxis: {\n type: 'value',\n show: false,\n min: (value: { min: number; max: number }): number => {\n if (value.min >= 0 && value.min <= 1) {\n // helps with percent-decimal units, or datasets that return 0 or 1 booleans\n return 0;\n }\n return value.min;\n },\n },\n tooltip: {\n show: false,\n },\n series: statSeries,\n };\n\n return option;\n }, [data, chartsTheme, sparkline]);\n\n const textAlignment = sparkline ? 'auto' : 'center';\n const textStyles = {\n display: 'flex',\n flexDirection: 'column',\n justifyContent: textAlignment,\n alignItems: textAlignment,\n };\n\n return (\n <Box sx={{ height: '100%', width: '100%', ...textStyles }}>\n {showSeriesName && (\n <SeriesName padding={containerPadding} fontSize={seriesNameFontSize}>\n {data.seriesData?.name}\n </SeriesName>\n )}\n <Value variant=\"h3\" color={color} fontSize={optimalValueFontSize} padding={containerPadding}>\n {formattedValue}\n </Value>\n {sparkline !== undefined && (\n <EChart\n sx={{\n width: '100%',\n }}\n style={{\n // ECharts rounds the height to the nearest integer by default.\n // This can cause unneccessary scrollbars when the total height of this chart exceeds the 'height' prop.\n height: Math.floor(height - seriesNameHeight - valueFontHeight),\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n renderer=\"svg\"\n />\n )}\n </Box>\n );\n};\n\nconst SeriesName = styled(Typography, {\n shouldForwardProp: (prop) => prop !== 'padding' && prop !== 'fontSize',\n})<{ padding?: number; fontSize?: number; textAlignment?: string }>(({ theme, padding, fontSize }) => ({\n color: theme.palette.text.secondary,\n padding: `${padding}px`,\n fontSize: `${fontSize}px`,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}));\n\nconst Value = styled(Typography, {\n shouldForwardProp: (prop) => prop !== 'color' && prop !== 'padding' && prop !== 'fontSize' && prop !== 'sparkline',\n})<{ color?: string; padding?: number; fontSize?: number; sparkline?: boolean }>(\n ({ theme, color, padding, fontSize, sparkline }) => ({\n color: color ?? theme.palette.text.primary,\n fontSize: `${fontSize}px`,\n padding: sparkline ? `${padding}px ${padding}px 0 ${padding}px` : ` 0 ${padding}px`,\n whiteSpace: 'nowrap',\n lineHeight: LINE_HEIGHT,\n })\n);\n"],"names":["useMemo","Box","Typography","styled","merge","use","LineChart","EChartsLineChart","GridComponent","DatasetComponent","TitleComponent","TooltipComponent","CanvasRenderer","EChart","useChartsTheme","useOptimalFontSize","formatStatChartValue","LINE_HEIGHT","SERIES_NAME_MAX_FONT_SIZE","SERIES_NAME_FONT_WEIGHT","VALUE_FONT_WEIGHT","StatChartBase","props","width","height","data","sparkline","showSeriesName","format","valueFontSize","chartsTheme","color","formattedValue","calculatedValue","containerPadding","container","padding","default","seriesNameFontSize","text","seriesData","name","fontWeight","lineHeight","maxSize","seriesNameHeight","availableWidth","availableHeight","optimalValueFontSize","fontSizeOverride","valueFontHeight","Math","min","option","undefined","noDataOption","series","statSeries","lineSeries","type","values","zlevel","symbol","animation","silent","mergedSeries","push","title","show","grid","top","right","bottom","left","containLabel","xAxis","boundaryGap","yAxis","value","tooltip","textAlignment","textStyles","display","flexDirection","justifyContent","alignItems","sx","SeriesName","fontSize","Value","variant","style","floor","theme","echartsTheme","renderer","shouldForwardProp","prop","palette","secondary","overflow","textOverflow","whiteSpace","primary"],"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,SAAaA,OAAO,QAAQ,QAAQ;AAEpC,SAASC,GAAG,EAAEC,UAAU,EAAEC,MAAM,QAAQ,gBAAgB;AACxD,OAAOC,WAAW,eAAe;AACjC,SAASC,GAAG,QAA2B,eAAe;AACtD,SAASC,aAAaC,gBAAgB,QAA0B,iBAAiB;AAC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AEA,QAAQ,KAAK,EAAEA,QAAQ,EAAE,CAAC,GAAG,CAAC,GAAG,EAAEA,QAAQ,EAAE,CAAC;QACnFkE,YAAY;QACZ3D,YAAY1B;IACd,CAAA"}
|
|
1
|
+
{"version":3,"sources":["../../src/StatChartBase.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 { FC, ReactNode, useMemo } from 'react';\nimport { FormatOptions } from '@perses-dev/core';\nimport { Box, Typography, styled, useTheme } from '@mui/material';\nimport merge from 'lodash/merge';\nimport { use, EChartsCoreOption } from 'echarts/core';\nimport { LineChart as EChartsLineChart, LineSeriesOption } from 'echarts/charts';\nimport { GridComponent, DatasetComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { EChart, FontSizeOption, GraphSeries, useChartsTheme } from '@perses-dev/components';\nimport chroma from 'chroma-js';\nimport { useOptimalFontSize } from './utils/calculate-font-size';\nimport { formatStatChartValue } from './utils/format-stat-chart-value';\nimport { ColorMode } from './stat-chart-model';\n\nuse([EChartsLineChart, GridComponent, DatasetComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nconst LINE_HEIGHT = 1.2;\nconst SERIES_NAME_MAX_FONT_SIZE = 30;\nconst SERIES_NAME_FONT_WEIGHT = 400;\nconst VALUE_FONT_WEIGHT = 700;\nconst WHITE_COLOR_CODE = '#FFFFFF';\nconst BLACK_COLOR_CODE = '#000000';\n\nexport interface StatChartData {\n color: string;\n calculatedValue?: string | number | null;\n seriesData?: GraphSeries;\n}\n\nexport interface StatChartProps {\n width: number;\n height: number;\n data: StatChartData;\n format?: FormatOptions;\n sparkline?: LineSeriesOption;\n showSeriesName?: boolean;\n valueFontSize?: FontSizeOption;\n colorMode?: ColorMode;\n}\n\nexport const StatChartBase: FC<StatChartProps> = (props) => {\n const {\n width,\n height,\n data,\n data: { color },\n sparkline,\n showSeriesName,\n format,\n valueFontSize,\n colorMode,\n } = props;\n\n const {\n palette: {\n mode: paletteMode,\n text: { secondary },\n },\n } = useTheme();\n const chartsTheme = useChartsTheme();\n const formattedValue = formatStatChartValue(data.calculatedValue, format);\n const containerPadding = chartsTheme.container.padding.default;\n\n // calculate series name font size and height\n let seriesNameFontSize = useOptimalFontSize({\n text: data?.seriesData?.name ?? '',\n fontWeight: SERIES_NAME_FONT_WEIGHT,\n width,\n height: height * 0.125, // assume series name will take 12.5% of available height\n lineHeight: LINE_HEIGHT,\n maxSize: SERIES_NAME_MAX_FONT_SIZE,\n });\n\n const seriesNameHeight = showSeriesName ? seriesNameFontSize * LINE_HEIGHT + containerPadding : 0;\n\n // calculate value font size and height\n const availableWidth = width - containerPadding * 2;\n const availableHeight = height - seriesNameHeight;\n const optimalValueFontSize = useOptimalFontSize({\n text: formattedValue,\n // override the font size if user selects it in the settings\n fontSizeOverride: valueFontSize,\n fontWeight: VALUE_FONT_WEIGHT,\n // without sparkline, use only 50% of the available width so it looks better for multiseries\n width: sparkline ? availableWidth : availableWidth * 0.5,\n // with sparkline, use only 25% of available height to leave room for chart\n // without sparkline, value should take up 90% of available space\n height: sparkline ? availableHeight * 0.25 : availableHeight * 0.9,\n lineHeight: LINE_HEIGHT,\n });\n const valueFontHeight = optimalValueFontSize * LINE_HEIGHT;\n\n // make sure the series name font size is slightly smaller than value font size\n seriesNameFontSize = Math.min(optimalValueFontSize * 0.7, seriesNameFontSize);\n\n const option: EChartsCoreOption = useMemo(() => {\n if (!data.seriesData) return chartsTheme.noDataOption;\n\n const series = data.seriesData;\n const statSeries: LineSeriesOption[] = [];\n\n if (sparkline) {\n const lineSeries = {\n type: 'line',\n name: series.name,\n data: series.values,\n zlevel: 1,\n symbol: 'none',\n animation: false,\n silent: true,\n };\n\n const clonedSparkLine = { ...sparkline };\n if (colorMode === 'background_solid') {\n clonedSparkLine.areaStyle = { color: WHITE_COLOR_CODE, opacity: 0.4 };\n clonedSparkLine.lineStyle = { color: WHITE_COLOR_CODE, opacity: 1 };\n }\n\n const mergedSeries = merge(lineSeries, clonedSparkLine);\n statSeries.push(mergedSeries);\n }\n\n const option: EChartsCoreOption = {\n title: {\n show: false,\n },\n grid: {\n show: false,\n top: '35%', // adds space above sparkline\n right: 0,\n bottom: 0,\n left: 0,\n containLabel: false,\n },\n xAxis: {\n type: 'time',\n show: false,\n boundaryGap: false,\n },\n yAxis: {\n type: 'value',\n show: false,\n min: (value: { min: number; max: number }): number => {\n if (value.min >= 0 && value.min <= 1) {\n // helps with percent-decimal units, or datasets that return 0 or 1 booleans\n return 0;\n }\n return value.min;\n },\n },\n tooltip: {\n show: false,\n },\n series: statSeries,\n };\n\n return option;\n }, [data, chartsTheme, sparkline, colorMode]);\n\n const textAlignment = sparkline ? 'auto' : 'center';\n\n const styledFormattedValue = useMemo(() => {\n let valueColor = '';\n\n switch (colorMode) {\n case 'background_solid':\n valueColor =\n chroma.contrast(color, WHITE_COLOR_CODE) > chroma.contrast(color, BLACK_COLOR_CODE)\n ? WHITE_COLOR_CODE\n : BLACK_COLOR_CODE;\n break;\n case 'none':\n valueColor = paletteMode === 'dark' ? WHITE_COLOR_CODE : BLACK_COLOR_CODE;\n break;\n case 'value':\n default:\n valueColor = color;\n break;\n }\n\n return (\n <Value variant=\"h3\" color={valueColor} fontSize={optimalValueFontSize} padding={containerPadding}>\n {formattedValue}\n </Value>\n );\n }, [colorMode, containerPadding, optimalValueFontSize, formattedValue, color, paletteMode]);\n\n const seriesName = useMemo((): ReactNode | null => {\n if (!showSeriesName) return null;\n\n let textColor = '';\n\n switch (colorMode) {\n case 'background_solid':\n textColor =\n chroma.contrast(color, WHITE_COLOR_CODE) > chroma.contrast(color, BLACK_COLOR_CODE)\n ? WHITE_COLOR_CODE\n : BLACK_COLOR_CODE;\n break;\n case 'none':\n case 'value':\n default:\n textColor = secondary;\n break;\n }\n\n return (\n <SeriesName padding={containerPadding} fontSize={seriesNameFontSize} color={textColor}>\n {data.seriesData?.name}\n </SeriesName>\n );\n }, [colorMode, showSeriesName, secondary, color, containerPadding, seriesNameFontSize, data?.seriesData?.name]);\n\n return (\n <Box\n sx={{\n height: '100%',\n width: '100%',\n backgroundColor: colorMode === 'background_solid' ? color : 'transparent',\n display: 'flex',\n flexDirection: 'column',\n justifyContent: textAlignment,\n alignItems: textAlignment,\n }}\n >\n {seriesName}\n {styledFormattedValue}\n {sparkline && (\n <EChart\n sx={{\n width: '100%',\n }}\n style={{\n // ECharts rounds the height to the nearest integer by default.\n // This can cause unneccessary scrollbars when the total height of this chart exceeds the 'height' prop.\n height: Math.floor(height - seriesNameHeight - valueFontHeight),\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n renderer=\"svg\"\n />\n )}\n </Box>\n );\n};\n\nconst SeriesName = styled(Typography, {\n shouldForwardProp: (prop) => prop !== 'padding' && prop !== 'fontSize',\n})<{ padding?: number; fontSize?: number; textAlignment?: string; color?: string }>(({ padding, fontSize, color }) => ({\n color: color,\n padding: `${padding}px`,\n fontSize: `${fontSize}px`,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}));\n\nconst Value = styled(Typography, {\n shouldForwardProp: (prop) => prop !== 'color' && prop !== 'padding' && prop !== 'fontSize' && prop !== 'sparkline',\n})<{ color?: string; padding?: number; fontSize?: number; sparkline?: boolean }>(\n ({ theme, color, padding, fontSize, sparkline }) => ({\n color: color ?? theme.palette.text.primary,\n fontSize: `${fontSize}px`,\n padding: sparkline ? `${padding}px ${padding}px 0 ${padding}px` : ` 0 ${padding}px`,\n whiteSpace: 'nowrap',\n lineHeight: LINE_HEIGHT,\n })\n);\n"],"names":["useMemo","Box","Typography","styled","useTheme","merge","use","LineChart","EChartsLineChart","GridComponent","DatasetComponent","TitleComponent","TooltipComponent","CanvasRenderer","EChart","useChartsTheme","chroma","useOptimalFontSize","formatStatChartValue","LINE_HEIGHT","SERIES_NAME_MAX_FONT_SIZE","SERIES_NAME_FONT_WEIGHT","VALUE_FONT_WEIGHT","WHITE_COLOR_CODE","BLACK_COLOR_CODE","StatChartBase","props","width","height","data","color","sparkline","showSeriesName","format","valueFontSize","colorMode","palette","mode","paletteMode","text","secondary","chartsTheme","formattedValue","calculatedValue","containerPadding","container","padding","default","seriesNameFontSize","seriesData","name","fontWeight","lineHeight","maxSize","seriesNameHeight","availableWidth","availableHeight","optimalValueFontSize","fontSizeOverride","valueFontHeight","Math","min","option","noDataOption","series","statSeries","lineSeries","type","values","zlevel","symbol","animation","silent","clonedSparkLine","areaStyle","opacity","lineStyle","mergedSeries","push","title","show","grid","top","right","bottom","left","containLabel","xAxis","boundaryGap","yAxis","value","tooltip","textAlignment","styledFormattedValue","valueColor","contrast","Value","variant","fontSize","seriesName","textColor","SeriesName","sx","backgroundColor","display","flexDirection","justifyContent","alignItems","style","floor","theme","echartsTheme","renderer","shouldForwardProp","prop","overflow","textOverflow","whiteSpace","primary"],"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,SAAwBA,OAAO,QAAQ,QAAQ;AAE/C,SAASC,GAAG,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,gBAAgB;AAClE,OAAOC,WAAW,eAAe;AACjC,SAASC,GAAG,QAA2B,eAAe;AACtD,SAASC,aAAaC,gBAAgB,QAA0B,iBAAiB;AACjF,SAASC,aAAa,EAAEC,gBAAgB,EAAEC,cAAc,EAAEC,gBAAgB,QAAQ,qBAAqB;AACvG,SA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sx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StatChartOptionsEditorSettings.d.ts","sourceRoot":"","sources":["../../src/StatChartOptionsEditorSettings.tsx"],"names":[],"mappings":"AAqCA,OAAO,EAAE,YAAY,EAAwB,MAAM,OAAO,CAAC;AAC3D,OAAO,EAML,2BAA2B,EAC5B,MAAM,oBAAoB,CAAC;AAI5B,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,2BAA2B,GAAG,YAAY,CA0I/F"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
2
|
// Copyright 2023 The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,12 +11,13 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { Switch } from '@mui/material';
|
|
15
|
-
import { FontSizeSelector, FormatControls, OptionsEditorColumn, OptionsEditorControl, OptionsEditorGrid, OptionsEditorGroup, ThresholdsEditor } from '@perses-dev/components';
|
|
15
|
+
import { FontSizeSelector, FormatControls, OptionsEditorColumn, OptionsEditorControl, OptionsEditorGrid, OptionsEditorGroup, SettingsAutocomplete, ThresholdsEditor } from '@perses-dev/components';
|
|
16
16
|
import { CalculationSelector, MetricLabelInput } from '@perses-dev/plugin-system';
|
|
17
17
|
import { produce } from 'immer';
|
|
18
18
|
import merge from 'lodash/merge';
|
|
19
|
+
import { useCallback, useMemo } from 'react';
|
|
20
|
+
import { COLOR_MODE_LABELS, SHOW_LEGEND_LABELS } from './stat-chart-model';
|
|
19
21
|
const DEFAULT_FORMAT = {
|
|
20
22
|
unit: 'percent-decimal'
|
|
21
23
|
};
|
|
@@ -33,6 +35,14 @@ export function StatChartOptionsEditorSettings(props) {
|
|
|
33
35
|
draft.metricLabel = newCalculation;
|
|
34
36
|
}));
|
|
35
37
|
};
|
|
38
|
+
const handleShowLegendChange = useCallback((_, newShowLegend)=>{
|
|
39
|
+
onChange(produce(value, (draft)=>{
|
|
40
|
+
draft.legendMode = newShowLegend.id;
|
|
41
|
+
}));
|
|
42
|
+
}, [
|
|
43
|
+
onChange,
|
|
44
|
+
value
|
|
45
|
+
]);
|
|
36
46
|
const handleUnitChange = (newFormat)=>{
|
|
37
47
|
onChange(produce(value, (draft)=>{
|
|
38
48
|
draft.format = newFormat;
|
|
@@ -56,37 +66,83 @@ export function StatChartOptionsEditorSettings(props) {
|
|
|
56
66
|
draft.valueFontSize = fontSize;
|
|
57
67
|
}));
|
|
58
68
|
};
|
|
69
|
+
const handleColorModeChange = useCallback((_, newColorMode)=>{
|
|
70
|
+
onChange(produce(value, (draft)=>{
|
|
71
|
+
draft.colorMode = newColorMode.id;
|
|
72
|
+
}));
|
|
73
|
+
}, [
|
|
74
|
+
onChange,
|
|
75
|
+
value
|
|
76
|
+
]);
|
|
77
|
+
const selectShowLegend = useMemo(()=>{
|
|
78
|
+
return /*#__PURE__*/ _jsx(OptionsEditorControl, {
|
|
79
|
+
label: "Show",
|
|
80
|
+
control: /*#__PURE__*/ _jsx(SettingsAutocomplete, {
|
|
81
|
+
onChange: handleShowLegendChange,
|
|
82
|
+
options: SHOW_LEGEND_LABELS,
|
|
83
|
+
disableClearable: true,
|
|
84
|
+
value: SHOW_LEGEND_LABELS.find((i)=>i.id === value.legendMode) ?? SHOW_LEGEND_LABELS.find((i)=>i.id === 'auto')
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
}, [
|
|
88
|
+
value.legendMode,
|
|
89
|
+
handleShowLegendChange
|
|
90
|
+
]);
|
|
91
|
+
const selectColorMode = useMemo(()=>{
|
|
92
|
+
return /*#__PURE__*/ _jsx(OptionsEditorControl, {
|
|
93
|
+
label: "Color mode",
|
|
94
|
+
control: /*#__PURE__*/ _jsx(SettingsAutocomplete, {
|
|
95
|
+
onChange: handleColorModeChange,
|
|
96
|
+
options: COLOR_MODE_LABELS.map(({ id, label })=>({
|
|
97
|
+
id,
|
|
98
|
+
label
|
|
99
|
+
})),
|
|
100
|
+
disableClearable: true,
|
|
101
|
+
value: COLOR_MODE_LABELS.find((i)=>i.id === value.colorMode) ?? COLOR_MODE_LABELS.find((i)=>i.id === 'value')
|
|
102
|
+
})
|
|
103
|
+
});
|
|
104
|
+
}, [
|
|
105
|
+
value.colorMode,
|
|
106
|
+
handleColorModeChange
|
|
107
|
+
]);
|
|
59
108
|
return /*#__PURE__*/ _jsxs(OptionsEditorGrid, {
|
|
60
109
|
children: [
|
|
61
|
-
/*#__PURE__*/
|
|
62
|
-
children:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
110
|
+
/*#__PURE__*/ _jsxs(OptionsEditorColumn, {
|
|
111
|
+
children: [
|
|
112
|
+
/*#__PURE__*/ _jsx(OptionsEditorGroup, {
|
|
113
|
+
title: "Legend",
|
|
114
|
+
children: selectShowLegend
|
|
115
|
+
}),
|
|
116
|
+
/*#__PURE__*/ _jsxs(OptionsEditorGroup, {
|
|
117
|
+
title: "Misc",
|
|
118
|
+
children: [
|
|
119
|
+
/*#__PURE__*/ _jsx(OptionsEditorControl, {
|
|
120
|
+
label: "Sparkline",
|
|
121
|
+
control: /*#__PURE__*/ _jsx(Switch, {
|
|
122
|
+
checked: !!value.sparkline,
|
|
123
|
+
onChange: handleSparklineChange
|
|
124
|
+
})
|
|
125
|
+
}),
|
|
126
|
+
/*#__PURE__*/ _jsx(FormatControls, {
|
|
127
|
+
value: format,
|
|
128
|
+
onChange: handleUnitChange
|
|
129
|
+
}),
|
|
130
|
+
/*#__PURE__*/ _jsx(CalculationSelector, {
|
|
131
|
+
value: value.calculation,
|
|
132
|
+
onChange: handleCalculationChange
|
|
133
|
+
}),
|
|
134
|
+
/*#__PURE__*/ _jsx(MetricLabelInput, {
|
|
135
|
+
value: value.metricLabel,
|
|
136
|
+
onChange: handleMetricLabelChange
|
|
137
|
+
}),
|
|
138
|
+
/*#__PURE__*/ _jsx(FontSizeSelector, {
|
|
139
|
+
value: value.valueFontSize,
|
|
140
|
+
onChange: handleFontSizeChange
|
|
141
|
+
}),
|
|
142
|
+
selectColorMode
|
|
143
|
+
]
|
|
144
|
+
})
|
|
145
|
+
]
|
|
90
146
|
}),
|
|
91
147
|
/*#__PURE__*/ _jsx(OptionsEditorColumn, {
|
|
92
148
|
children: /*#__PURE__*/ _jsx(ThresholdsEditor, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/StatChartOptionsEditorSettings.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 { Switch, SwitchProps } from '@mui/material';\nimport {\n FontSizeOption,\n FontSizeSelector,\n FontSizeSelectorProps,\n FormatControls,\n FormatControlsProps,\n OptionsEditorColumn,\n OptionsEditorControl,\n OptionsEditorGrid,\n OptionsEditorGroup,\n ThresholdsEditor,\n ThresholdsEditorProps,\n} from '@perses-dev/components';\nimport { FormatOptions } from '@perses-dev/core';\nimport {\n CalculationSelector,\n CalculationSelectorProps,\n MetricLabelInput,\n MetricLabelInputProps,\n} from '@perses-dev/plugin-system';\nimport { produce } from 'immer';\nimport merge from 'lodash/merge';\nimport { ReactElement } from 'react';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/StatChartOptionsEditorSettings.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 { Switch, SwitchProps } from '@mui/material';\nimport {\n FontSizeOption,\n FontSizeSelector,\n FontSizeSelectorProps,\n FormatControls,\n FormatControlsProps,\n OptionsEditorColumn,\n OptionsEditorControl,\n OptionsEditorGrid,\n OptionsEditorGroup,\n SettingsAutocomplete,\n ThresholdsEditor,\n ThresholdsEditorProps,\n} from '@perses-dev/components';\nimport { FormatOptions } from '@perses-dev/core';\nimport {\n CalculationSelector,\n CalculationSelectorProps,\n MetricLabelInput,\n MetricLabelInputProps,\n} from '@perses-dev/plugin-system';\nimport { produce } from 'immer';\nimport merge from 'lodash/merge';\nimport { ReactElement, useCallback, useMemo } from 'react';\nimport {\n COLOR_MODE_LABELS,\n ColorModeLabelItem,\n SHOW_LEGEND_LABELS,\n ShowLegendLabelItem,\n StatChartOptions,\n StatChartOptionsEditorProps,\n} from './stat-chart-model';\n\nconst DEFAULT_FORMAT: FormatOptions = { unit: 'percent-decimal' };\n\nexport function StatChartOptionsEditorSettings(props: StatChartOptionsEditorProps): ReactElement {\n const { onChange, value } = props;\n\n // ensures decimalPlaces defaults to correct value\n const format = merge({}, DEFAULT_FORMAT, value.format);\n\n const handleCalculationChange: CalculationSelectorProps['onChange'] = (metricLabel) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.calculation = metricLabel;\n })\n );\n };\n\n const handleMetricLabelChange: MetricLabelInputProps['onChange'] = (newCalculation) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.metricLabel = newCalculation;\n })\n );\n };\n\n const handleShowLegendChange = useCallback(\n (_: unknown, newShowLegend: ShowLegendLabelItem): void => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.legendMode = newShowLegend.id;\n })\n );\n },\n [onChange, value]\n );\n\n const handleUnitChange: FormatControlsProps['onChange'] = (newFormat) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.format = newFormat;\n })\n );\n };\n\n const handleSparklineChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n // For now, setting to an empty object when checked, so the stat chart\n // uses the default chart color and line styles. In the future, this\n // will likely be configurable in the UI.\n draft.sparkline = checked ? {} : undefined;\n })\n );\n };\n\n const handleThresholdsChange: ThresholdsEditorProps['onChange'] = (thresholds) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.thresholds = thresholds;\n })\n );\n };\n\n const handleFontSizeChange: FontSizeSelectorProps['onChange'] = (fontSize: FontSizeOption) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.valueFontSize = fontSize;\n })\n );\n };\n\n const handleColorModeChange = useCallback(\n (_: unknown, newColorMode: ColorModeLabelItem): void => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.colorMode = newColorMode.id;\n })\n );\n },\n [onChange, value]\n );\n\n const selectShowLegend = useMemo((): ReactElement => {\n return (\n <OptionsEditorControl\n label=\"Show\"\n control={\n <SettingsAutocomplete\n onChange={handleShowLegendChange}\n options={SHOW_LEGEND_LABELS}\n disableClearable\n value={\n SHOW_LEGEND_LABELS.find((i) => i.id === value.legendMode) ??\n SHOW_LEGEND_LABELS.find((i) => i.id === 'auto')!\n }\n />\n }\n />\n );\n }, [value.legendMode, handleShowLegendChange]);\n\n const selectColorMode = useMemo((): ReactElement => {\n return (\n <OptionsEditorControl\n label=\"Color mode\"\n control={\n <SettingsAutocomplete\n onChange={handleColorModeChange}\n options={COLOR_MODE_LABELS.map(({ id, label }) => ({ id, label }))}\n disableClearable\n value={\n COLOR_MODE_LABELS.find((i) => i.id === value.colorMode) ??\n COLOR_MODE_LABELS.find((i) => i.id === 'value')!\n }\n />\n }\n />\n );\n }, [value.colorMode, handleColorModeChange]);\n\n return (\n <OptionsEditorGrid>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Legend\">{selectShowLegend}</OptionsEditorGroup>\n <OptionsEditorGroup title=\"Misc\">\n <OptionsEditorControl\n label=\"Sparkline\"\n control={<Switch checked={!!value.sparkline} onChange={handleSparklineChange} />}\n />\n <FormatControls value={format} onChange={handleUnitChange} />\n <CalculationSelector value={value.calculation} onChange={handleCalculationChange} />\n <MetricLabelInput value={value.metricLabel} onChange={handleMetricLabelChange} />\n <FontSizeSelector value={value.valueFontSize} onChange={handleFontSizeChange} />\n {selectColorMode}\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n <OptionsEditorColumn>\n <ThresholdsEditor disablePercentMode thresholds={value.thresholds} onChange={handleThresholdsChange} />\n </OptionsEditorColumn>\n </OptionsEditorGrid>\n );\n}\n"],"names":["Switch","FontSizeSelector","FormatControls","OptionsEditorColumn","OptionsEditorControl","OptionsEditorGrid","OptionsEditorGroup","SettingsAutocomplete","ThresholdsEditor","CalculationSelector","MetricLabelInput","produce","merge","useCallback","useMemo","COLOR_MODE_LABELS","SHOW_LEGEND_LABELS","DEFAULT_FORMAT","unit","StatChartOptionsEditorSettings","props","onChange","value","format","handleCalculationChange","metricLabel","draft","calculation","handleMetricLabelChange","newCalculation","handleShowLegendChange","_","newShowLegend","legendMode","id","handleUnitChange","newFormat","handleSparklineChange","checked","sparkline","undefined","handleThresholdsChange","thresholds","handleFontSizeChange","fontSize","valueFontSize","handleColorModeChange","newColorMode","colorMode","selectShowLegend","label","control","options","disableClearable","find","i","selectColorMode","map","title","disablePercentMode"],"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,SAASA,MAAM,QAAqB,gBAAgB;AACpD,SAEEC,gBAAgB,EAEhBC,cAAc,EAEdC,mBAAmB,EACnBC,oBAAoB,EACpBC,iBAAiB,EACjBC,kBAAkB,EAClBC,oBAAoB,EACpBC,gBAAgB,QAEX,yBAAyB;AAEhC,SACEC,mBAAmB,EAEnBC,gBAAgB,QAEX,4BAA4B;AACnC,SAASC,OAAO,QAAQ,QAAQ;AAChC,OAAOC,WAAW,eAAe;AACjC,SAAuBC,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AAC3D,SACEC,iBAAiB,EAEjBC,kBAAkB,QAIb,qBAAqB;AAE5B,MAAMC,iBAAgC;IAAEC,MAAM;AAAkB;AAEhE,OAAO,SAASC,+BAA+BC,KAAkC;IAC/E,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGF;IAE5B,kDAAkD;IAClD,MAAMG,SAASX,MAAM,CAAC,GAAGK,gBAAgBK,MAAMC,MAAM;IAErD,MAAMC,0BAAgE,CAACC;QACrEJ,SACEV,QAAQW,OAAO,CAACI;YACdA,MAAMC,WAAW,GAAGF;QACtB;IAEJ;IAEA,MAAMG,0BAA6D,CAACC;QAClER,SACEV,QAAQW,OAAO,CAACI;YACdA,MAAMD,WAAW,GAAGI;QACtB;IAEJ;IAEA,MAAMC,yBAAyBjB,YAC7B,CAACkB,GAAYC;QACXX,SACEV,QAAQW,OAAO,CAACI;YACdA,MAAMO,UAAU,GAAGD,cAAcE,EAAE;QACrC;IAEJ,GACA;QAACb;QAAUC;KAAM;I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"file":"StatChartPanel.d.ts","sourceRoot":"","sources":["../../src/StatChartPanel.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,EAAE,EAAW,MAAM,OAAO,CAAC;AACpC,OAAO,EAAoD,cAAc,EAAgB,MAAM,kBAAkB,CAAC;AAClH,OAAO,EAAE,UAAU,EAAa,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAStD,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;AAE/E,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CA0DlD,CAAC"}
|
package/lib/StatChartPanel.js
CHANGED
|
@@ -23,11 +23,13 @@ const MIN_WIDTH = 100;
|
|
|
23
23
|
const SPACING = 2;
|
|
24
24
|
export const StatChartPanel = (props)=>{
|
|
25
25
|
const { spec, contentDimensions, queryResults } = props;
|
|
26
|
-
const { format, sparkline, valueFontSize: valueFontSize } = spec;
|
|
26
|
+
const { format, sparkline, valueFontSize: valueFontSize, colorMode } = spec;
|
|
27
27
|
const chartsTheme = useChartsTheme();
|
|
28
28
|
const statChartData = useStatChartData(queryResults, spec, chartsTheme);
|
|
29
29
|
const isMultiSeries = statChartData.length > 1;
|
|
30
|
-
|
|
30
|
+
// Handle three-state showLegend: 'on' | 'off' | 'auto' (or undefined for backward compatibility)
|
|
31
|
+
const shouldShowLegend = spec.legendMode === 'on' ? true : spec.legendMode === 'off' ? false : isMultiSeries;
|
|
32
|
+
if (!contentDimensions) return null;
|
|
31
33
|
// Calculates chart width
|
|
32
34
|
const spacing = SPACING * (statChartData.length - 1);
|
|
33
35
|
let chartWidth = (contentDimensions.width - spacing) / statChartData.length;
|
|
@@ -53,8 +55,9 @@ export const StatChartPanel = (props)=>{
|
|
|
53
55
|
data: series,
|
|
54
56
|
format: format,
|
|
55
57
|
sparkline: sparklineConfig,
|
|
56
|
-
showSeriesName:
|
|
57
|
-
valueFontSize: valueFontSize
|
|
58
|
+
showSeriesName: shouldShowLegend,
|
|
59
|
+
valueFontSize: valueFontSize,
|
|
60
|
+
colorMode: colorMode
|
|
58
61
|
}, index);
|
|
59
62
|
}) : /*#__PURE__*/ _jsx(Typography, {
|
|
60
63
|
sx: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/StatChartPanel.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 { TitleComponentOption } from 'echarts';\nimport { useChartsTheme, GraphSeries, PersesChartsTheme } from '@perses-dev/components';\nimport { Stack, Typography, SxProps } from '@mui/material';\nimport { FC, useMemo } from 'react';\nimport { applyValueMapping, Labels, createRegexFromString, TimeSeriesData, ValueMapping } from '@perses-dev/core';\nimport { PanelProps, PanelData } from '@perses-dev/plugin-system';\nimport { StatChartOptions } from './stat-chart-model';\nimport { convertSparkline } from './utils/data-transform';\nimport { calculateValue } from './utils/calculate-value';\nimport { getStatChartColor } from './utils/get-color';\nimport { StatChartBase, StatChartData } from './StatChartBase';\n\nconst MIN_WIDTH = 100;\nconst SPACING = 2;\n\nexport type StatChartPanelProps = PanelProps<StatChartOptions, TimeSeriesData>;\n\nexport const StatChartPanel: FC<StatChartPanelProps> = (props) => {\n const { spec, contentDimensions, queryResults } = props;\n\n const { format, sparkline, valueFontSize: valueFontSize } = spec;\n const chartsTheme = useChartsTheme();\n const statChartData = useStatChartData(queryResults, spec, chartsTheme);\n\n const isMultiSeries = statChartData.length > 1;\n\n
|
|
1
|
+
{"version":3,"sources":["../../src/StatChartPanel.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 { TitleComponentOption } from 'echarts';\nimport { useChartsTheme, GraphSeries, PersesChartsTheme } from '@perses-dev/components';\nimport { Stack, Typography, SxProps } from '@mui/material';\nimport { FC, useMemo } from 'react';\nimport { applyValueMapping, Labels, createRegexFromString, TimeSeriesData, ValueMapping } from '@perses-dev/core';\nimport { PanelProps, PanelData } from '@perses-dev/plugin-system';\nimport { StatChartOptions } from './stat-chart-model';\nimport { convertSparkline } from './utils/data-transform';\nimport { calculateValue } from './utils/calculate-value';\nimport { getStatChartColor } from './utils/get-color';\nimport { StatChartBase, StatChartData } from './StatChartBase';\n\nconst MIN_WIDTH = 100;\nconst SPACING = 2;\n\nexport type StatChartPanelProps = PanelProps<StatChartOptions, TimeSeriesData>;\n\nexport const StatChartPanel: FC<StatChartPanelProps> = (props) => {\n const { spec, contentDimensions, queryResults } = props;\n\n const { format, sparkline, valueFontSize: valueFontSize, colorMode } = spec;\n const chartsTheme = useChartsTheme();\n const statChartData = useStatChartData(queryResults, spec, chartsTheme);\n\n const isMultiSeries = statChartData.length > 1;\n\n // Handle three-state showLegend: 'on' | 'off' | 'auto' (or undefined for backward compatibility)\n const shouldShowLegend = spec.legendMode === 'on' ? true : spec.legendMode === 'off' ? false : isMultiSeries;\n\n if (!contentDimensions) return null;\n\n // Calculates chart width\n const spacing = SPACING * (statChartData.length - 1);\n let chartWidth = (contentDimensions.width - spacing) / statChartData.length;\n if (isMultiSeries && chartWidth < MIN_WIDTH) {\n chartWidth = MIN_WIDTH;\n }\n\n const noDataTextStyle = (chartsTheme.noDataOption.title as TitleComponentOption).textStyle;\n\n return (\n <Stack\n height={contentDimensions.height}\n width={contentDimensions.width}\n spacing={`${SPACING}px`}\n direction=\"row\"\n justifyContent={isMultiSeries ? 'left' : 'center'}\n alignItems=\"center\"\n sx={{\n overflowX: isMultiSeries ? 'scroll' : 'auto',\n }}\n >\n {statChartData.length ? (\n statChartData.map((series, index) => {\n const sparklineConfig = convertSparkline(chartsTheme, series.color, sparkline);\n\n return (\n <StatChartBase\n key={index}\n width={chartWidth}\n height={contentDimensions.height}\n data={series}\n format={format}\n sparkline={sparklineConfig}\n showSeriesName={shouldShowLegend}\n valueFontSize={valueFontSize}\n colorMode={colorMode}\n />\n );\n })\n ) : (\n <Typography sx={{ ...noDataTextStyle } as SxProps}>No data</Typography>\n )}\n </Stack>\n );\n};\n\nconst useStatChartData = (\n queryResults: Array<PanelData<TimeSeriesData>>,\n spec: StatChartOptions,\n chartsTheme: PersesChartsTheme\n): StatChartData[] => {\n return useMemo(() => {\n const { calculation, mappings, metricLabel } = spec;\n\n const statChartData: StatChartData[] = [];\n for (const result of queryResults) {\n for (const seriesData of result.data.series) {\n const calculatedValue = calculateValue(calculation, seriesData);\n\n // get label metric value\n const labelValue = getLabelValue(metricLabel, seriesData.labels);\n\n // get actual value to display\n const displayValue = getValueOrLabel(calculatedValue, mappings, labelValue);\n\n const color = getStatChartColor(chartsTheme, spec, calculatedValue);\n\n const series: GraphSeries = {\n name: seriesData.formattedName ?? '',\n values: seriesData.values,\n };\n\n statChartData.push({ calculatedValue: displayValue, seriesData: series, color });\n }\n }\n return statChartData;\n }, [queryResults, spec, chartsTheme]);\n};\n\nconst getValueOrLabel = (\n value?: number | null,\n mappings?: ValueMapping[],\n label?: string\n): string | number | undefined | null => {\n if (label) {\n return label;\n }\n if (mappings?.length && value !== undefined && value !== null) {\n return applyValueMapping(value, mappings).value;\n } else {\n return value;\n }\n};\n\nconst getLabelValue = (fieldLabel?: string, labels?: Labels): string | undefined => {\n if (!labels || !fieldLabel) {\n return undefined;\n }\n for (const [key, value] of Object.entries(labels)) {\n const regex = createRegexFromString(fieldLabel);\n if (regex.test(key)) {\n return value;\n }\n }\n return undefined;\n};\n"],"names":["useChartsTheme","Stack","Typography","useMemo","applyValueMapping","createRegexFromString","convertSparkline","calculateValue","getStatChartColor","StatChartBase","MIN_WIDTH","SPACING","StatChartPanel","props","spec","contentDimensions","queryResults","format","sparkline","valueFontSize","colorMode","chartsTheme","statChartData","useStatChartData","isMultiSeries","length","shouldShowLegend","legendMode","spacing","chartWidth","width","noDataTextStyle","noDataOption","title","textStyle","height","direction","justifyContent","alignItems","sx","overflowX","map","series","index","sparklineConfig","color","data","showSeriesName","calculation","mappings","metricLabel","result","seriesData","calculatedValue","labelValue","getLabelValue","labels","displayValue","getValueOrLabel","name","formattedName","values","push","value","label","undefined","fieldLabel","key","Object","entries","regex","test"],"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;;AAGjC,SAASA,cAAc,QAAwC,yBAAyB;AACxF,SAASC,KAAK,EAAEC,UAAU,QAAiB,gBAAgB;AAC3D,SAAaC,OAAO,QAAQ,QAAQ;AACpC,SAASC,iBAAiB,EAAUC,qBAAqB,QAAsC,mBAAmB;AAGlH,SAASC,gBAAgB,QAAQ,yBAAyB;AAC1D,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,iBAAiB,QAAQ,oBAAoB;AACtD,SAASC,aAAa,QAAuB,kBAAkB;AAE/D,MAAMC,YAAY;AAClB,MAAMC,UAAU;AAIhB,OAAO,MAAMC,iBAA0C,CAACC;IACtD,MAAM,EAAEC,IAAI,EAAEC,iBAAiB,EAAEC,YAAY,EAAE,GAAGH;IAElD,MAAM,EAAEI,MAAM,EAAEC,SAAS,EAAEC,eAAeA,aAAa,EAAEC,SAAS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|
|
1
2
|
// Copyright 2024 The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import React from 'react';
|
|
15
15
|
import ReactDOM from 'react-dom/client';
|
|
16
16
|
const root = ReactDOM.createRoot(document.getElementById('root'));
|
package/lib/bootstrap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bootstrap.tsx"],"sourcesContent":["// Copyright 2024 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 ReactDOM from 'react-dom/client';\n\nconst root = ReactDOM.createRoot(document.getElementById('root')!);\nroot.render(<React.StrictMode></React.StrictMode>);\n"],"names":["React","ReactDOM","root","createRoot","document","getElementById","render","StrictMode"],"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
|
|
1
|
+
{"version":3,"sources":["../../src/bootstrap.tsx"],"sourcesContent":["// Copyright 2024 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 ReactDOM from 'react-dom/client';\n\nconst root = ReactDOM.createRoot(document.getElementById('root')!);\nroot.render(<React.StrictMode></React.StrictMode>);\n"],"names":["React","ReactDOM","root","createRoot","document","getElementById","render","StrictMode"],"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,OAAOA,WAAW,QAAQ;AAC1B,OAAOC,cAAc,mBAAmB;AAExC,MAAMC,OAAOD,SAASE,UAAU,CAACC,SAASC,cAAc,CAAC;AACzDH,KAAKI,MAAM,eAAC,KAACN,MAAMO,UAAU"}
|