@perses-dev/gauge-chart-plugin 0.6.0 → 0.7.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/js/{481.157b10da.js → 481.38bc8574.js} +1 -1
- package/__mf/js/{GaugeChart.ab54e56d.js → GaugeChart.cfdb55a8.js} +3 -3
- package/__mf/js/async/{885.6fe431cc.js → 1.6f58f98c.js} +2 -2
- package/__mf/js/async/409.64ed758e.js +1 -0
- package/__mf/js/async/413.8c98e66f.js +2 -0
- package/__mf/js/async/422.a17fef68.js +1 -0
- package/__mf/js/async/432.e6fd356a.js +29 -0
- package/__mf/js/async/432.e6fd356a.js.LICENSE.txt +37 -0
- package/__mf/js/async/65.8ddd406b.js +73 -0
- package/__mf/js/async/957.3c868e35.js +2 -0
- package/__mf/js/async/{870.e225b77a.js.LICENSE.txt → 957.3c868e35.js.LICENSE.txt} +1 -39
- package/__mf/js/async/__federation_expose_GaugeChart.7512420d.js +1 -0
- package/__mf/js/main.d6113dbb.js +1 -0
- package/lib/GaugeChartBase.d.ts +23 -0
- package/lib/GaugeChartBase.d.ts.map +1 -0
- package/lib/GaugeChartBase.js +213 -0
- package/lib/GaugeChartBase.js.map +1 -0
- package/lib/GaugeChartPanel.d.ts.map +1 -1
- package/lib/GaugeChartPanel.js +4 -3
- package/lib/GaugeChartPanel.js.map +1 -1
- package/lib/cjs/GaugeChartBase.js +226 -0
- package/lib/cjs/GaugeChartPanel.js +3 -2
- package/mf-manifest.json +22 -20
- package/mf-stats.json +22 -20
- package/package.json +7 -4
- package/__mf/js/async/162.e82ae267.js +0 -73
- package/__mf/js/async/301.2cb371d7.js +0 -1
- package/__mf/js/async/610.ba53bb1f.js +0 -1
- package/__mf/js/async/870.e225b77a.js +0 -29
- package/__mf/js/async/996.ec5992e5.js +0 -2
- package/__mf/js/async/__federation_expose_GaugeChart.8d994ab0.js +0 -1
- package/__mf/js/main.7be7ddac.js +0 -1
- /package/__mf/js/async/{996.ec5992e5.js.LICENSE.txt → 413.8c98e66f.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{162.e82ae267.js.LICENSE.txt → 65.8ddd406b.js.LICENSE.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/GaugeChartPanel.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, Skeleton, Stack } from '@mui/material';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/GaugeChartPanel.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, Skeleton, Stack } from '@mui/material';\nimport { useChartsTheme } from '@perses-dev/components';\nimport { CalculationsMap, DEFAULT_CALCULATION, TimeSeriesData } from '@perses-dev/core';\nimport { PanelProps } from '@perses-dev/plugin-system';\nimport type { GaugeSeriesOption } from 'echarts';\nimport merge from 'lodash/merge';\nimport { ReactElement, useMemo } from 'react';\nimport {\n DEFAULT_FORMAT,\n DEFAULT_MAX_PERCENT,\n DEFAULT_MAX_PERCENT_DECIMAL,\n GaugeChartOptions,\n} from './gauge-chart-model';\nimport { convertThresholds, defaultThresholdInput } from './thresholds';\nimport { GaugeChartBase, GaugeSeries } from './GaugeChartBase';\n\nconst EMPTY_GAUGE_SERIES: GaugeSeries = { label: '', value: undefined };\nconst GAUGE_MIN_WIDTH = 90;\nconst PANEL_PADDING_OFFSET = 20;\n\nexport type GaugeChartPanelProps = PanelProps<GaugeChartOptions, TimeSeriesData>;\n\nexport function GaugeChartPanel(props: GaugeChartPanelProps): ReactElement | null {\n const { spec: pluginSpec, contentDimensions, queryResults } = props;\n const { calculation, max } = pluginSpec;\n\n const { thresholds: thresholdsColors } = useChartsTheme();\n\n // ensures all default format properties set if undef\n const format = merge({}, DEFAULT_FORMAT, pluginSpec.format);\n\n const thresholds = pluginSpec.thresholds ?? defaultThresholdInput;\n\n const gaugeData: GaugeSeries[] = useMemo(() => {\n if (queryResults[0]?.data === undefined) {\n return [];\n }\n\n if (CalculationsMap[calculation] === undefined) {\n console.warn(`Invalid GaugeChart panel calculation ${calculation}, fallback to ${DEFAULT_CALCULATION}`);\n }\n\n const calculate = CalculationsMap[calculation] ?? CalculationsMap[DEFAULT_CALCULATION];\n\n const seriesData: GaugeSeries[] = [];\n for (const timeSeries of queryResults[0].data.series) {\n const series = {\n value: calculate(timeSeries.values),\n label: timeSeries.formattedName ?? '',\n };\n seriesData.push(series);\n }\n return seriesData;\n }, [queryResults, calculation]);\n\n if (contentDimensions === undefined) return null;\n\n // needed for end value of last threshold color segment\n let thresholdMax = max;\n if (thresholdMax === undefined) {\n if (format.unit === 'percent') {\n thresholdMax = DEFAULT_MAX_PERCENT;\n } else {\n thresholdMax = DEFAULT_MAX_PERCENT_DECIMAL;\n }\n }\n const axisLineColors = convertThresholds(thresholds, format, thresholdMax, thresholdsColors);\n\n const axisLine: GaugeSeriesOption['axisLine'] = {\n show: true,\n lineStyle: {\n width: 5,\n color: axisLineColors,\n },\n };\n\n // no data message handled inside chart component\n if (gaugeData.length === 0) {\n return (\n <GaugeChartBase\n width={contentDimensions.width}\n height={contentDimensions.height}\n data={EMPTY_GAUGE_SERIES}\n format={format}\n axisLine={axisLine}\n max={thresholdMax}\n />\n );\n }\n\n // accounts for showing a separate chart for each time series\n let chartWidth = contentDimensions.width / gaugeData.length - PANEL_PADDING_OFFSET;\n if (chartWidth < GAUGE_MIN_WIDTH && gaugeData.length > 1) {\n // enables horizontal scroll when charts overflow outside of panel\n chartWidth = GAUGE_MIN_WIDTH;\n }\n\n const hasMultipleCharts = gaugeData.length > 1;\n\n return (\n <Stack\n direction=\"row\"\n spacing={hasMultipleCharts ? 2 : 0}\n justifyContent={hasMultipleCharts ? 'left' : 'center'}\n alignItems=\"center\"\n sx={{\n // so scrollbar only shows when necessary\n overflowX: gaugeData.length > 1 ? 'scroll' : 'auto',\n }}\n >\n {gaugeData.map((series, seriesIndex) => {\n return (\n <Box key={`gauge-series-${seriesIndex}`}>\n <GaugeChartBase\n width={chartWidth}\n height={contentDimensions.height}\n data={series}\n format={format}\n axisLine={axisLine}\n max={thresholdMax}\n />\n </Box>\n );\n })}\n </Stack>\n );\n}\n\nexport function GaugeChartLoading({ contentDimensions }: GaugeChartPanelProps): React.ReactElement | null {\n if (contentDimensions === undefined) return null;\n return (\n <Skeleton\n sx={{ margin: '0 auto' }}\n variant=\"circular\"\n width={contentDimensions.width > contentDimensions.height ? contentDimensions.height : contentDimensions.width}\n height={contentDimensions.height}\n />\n );\n}\n"],"names":["Box","Skeleton","Stack","useChartsTheme","CalculationsMap","DEFAULT_CALCULATION","merge","useMemo","DEFAULT_FORMAT","DEFAULT_MAX_PERCENT","DEFAULT_MAX_PERCENT_DECIMAL","convertThresholds","defaultThresholdInput","GaugeChartBase","EMPTY_GAUGE_SERIES","label","value","undefined","GAUGE_MIN_WIDTH","PANEL_PADDING_OFFSET","GaugeChartPanel","props","spec","pluginSpec","contentDimensions","queryResults","calculation","max","thresholds","thresholdsColors","format","gaugeData","data","console","warn","calculate","seriesData","timeSeries","series","values","formattedName","push","thresholdMax","unit","axisLineColors","axisLine","show","lineStyle","width","color","length","height","chartWidth","hasMultipleCharts","direction","spacing","justifyContent","align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C7CI,YAAW;QACXC,IAAI;YACF,yCAAyC;YACzCC,WAAW5B,UAAUmB,MAAM,GAAG,IAAI,WAAW;QAC/C;kBAECnB,UAAU6B,GAAG,CAAC,CAACtB,QAAQuB;YACtB,qBACE,KAAC7D;0BACC,cAAA,KAACa;oBACCmC,OAAOI;oBACPD,QAAQ3B,kBAAkB2B,MAAM;oBAChCnB,MAAMM;oBACNR,QAAQA;oBACRe,UAAUA;oBACVlB,KAAKe;;eAPC,CAAC,aAAa,EAAEmB,aAAa;QAW3C;;AAGN;AAEA,OAAO,SAASC,kBAAkB,EAAEtC,iBAAiB,EAAwB;IAC3E,IAAIA,sBAAsBP,WAAW,OAAO;IAC5C,qBACE,KAAChB;QACCyD,IAAI;YAAEK,QAAQ;QAAS;QACvBC,SAAQ;QACRhB,OAAOxB,kBAAkBwB,KAAK,GAAGxB,kBAAkB2B,MAAM,GAAG3B,kBAAkB2B,MAAM,GAAG3B,kBAAkBwB,KAAK;QAC9GG,QAAQ3B,kBAAkB2B,MAAM;;AAGtC"}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
GaugeChartBase: function() {
|
|
25
|
+
return GaugeChartBase;
|
|
26
|
+
},
|
|
27
|
+
getResponsiveValueSize: function() {
|
|
28
|
+
return getResponsiveValueSize;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
32
|
+
const _components = require("@perses-dev/components");
|
|
33
|
+
const _core = require("@perses-dev/core");
|
|
34
|
+
const _core1 = require("echarts/core");
|
|
35
|
+
const _charts = require("echarts/charts");
|
|
36
|
+
const _components1 = require("echarts/components");
|
|
37
|
+
const _renderers = require("echarts/renderers");
|
|
38
|
+
(0, _core1.use)([
|
|
39
|
+
_charts.GaugeChart,
|
|
40
|
+
_components1.GridComponent,
|
|
41
|
+
_components1.TitleComponent,
|
|
42
|
+
_components1.TooltipComponent,
|
|
43
|
+
_renderers.CanvasRenderer
|
|
44
|
+
]);
|
|
45
|
+
const PROGRESS_WIDTH = 16;
|
|
46
|
+
// adjusts when to show pointer icon
|
|
47
|
+
const GAUGE_SMALL_BREAKPOINT = 170;
|
|
48
|
+
function GaugeChartBase(props) {
|
|
49
|
+
const { width, height, data, format, axisLine, max } = props;
|
|
50
|
+
const chartsTheme = (0, _components.useChartsTheme)();
|
|
51
|
+
// useDeepMemo ensures value size util does not rerun everytime you hover on the chart
|
|
52
|
+
const option = (0, _core.useDeepMemo)(()=>{
|
|
53
|
+
if (data.value === undefined) return chartsTheme.noDataOption;
|
|
54
|
+
// adjusts fontSize depending on number of characters
|
|
55
|
+
const valueSizeClamp = getResponsiveValueSize(data.value, format, width, height);
|
|
56
|
+
return {
|
|
57
|
+
title: {
|
|
58
|
+
show: false
|
|
59
|
+
},
|
|
60
|
+
tooltip: {
|
|
61
|
+
show: false
|
|
62
|
+
},
|
|
63
|
+
series: [
|
|
64
|
+
{
|
|
65
|
+
type: 'gauge',
|
|
66
|
+
center: [
|
|
67
|
+
'50%',
|
|
68
|
+
'65%'
|
|
69
|
+
],
|
|
70
|
+
radius: '86%',
|
|
71
|
+
startAngle: 200,
|
|
72
|
+
endAngle: -20,
|
|
73
|
+
min: 0,
|
|
74
|
+
max,
|
|
75
|
+
silent: true,
|
|
76
|
+
progress: {
|
|
77
|
+
show: true,
|
|
78
|
+
width: PROGRESS_WIDTH,
|
|
79
|
+
itemStyle: {
|
|
80
|
+
color: 'auto'
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
pointer: {
|
|
84
|
+
show: false
|
|
85
|
+
},
|
|
86
|
+
axisLine: {
|
|
87
|
+
lineStyle: {
|
|
88
|
+
color: [
|
|
89
|
+
[
|
|
90
|
+
1,
|
|
91
|
+
'rgba(127,127,127,0.35)'
|
|
92
|
+
]
|
|
93
|
+
],
|
|
94
|
+
width: PROGRESS_WIDTH
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
axisTick: {
|
|
98
|
+
show: false,
|
|
99
|
+
distance: 0
|
|
100
|
+
},
|
|
101
|
+
splitLine: {
|
|
102
|
+
show: false
|
|
103
|
+
},
|
|
104
|
+
axisLabel: {
|
|
105
|
+
show: false,
|
|
106
|
+
distance: -18,
|
|
107
|
+
color: '#999',
|
|
108
|
+
fontSize: 12
|
|
109
|
+
},
|
|
110
|
+
anchor: {
|
|
111
|
+
show: false
|
|
112
|
+
},
|
|
113
|
+
title: {
|
|
114
|
+
show: false
|
|
115
|
+
},
|
|
116
|
+
detail: {
|
|
117
|
+
show: false
|
|
118
|
+
},
|
|
119
|
+
data: [
|
|
120
|
+
{
|
|
121
|
+
value: data.value
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
type: 'gauge',
|
|
127
|
+
center: [
|
|
128
|
+
'50%',
|
|
129
|
+
'65%'
|
|
130
|
+
],
|
|
131
|
+
radius: '100%',
|
|
132
|
+
startAngle: 200,
|
|
133
|
+
endAngle: -20,
|
|
134
|
+
min: 0,
|
|
135
|
+
max,
|
|
136
|
+
pointer: {
|
|
137
|
+
show: true,
|
|
138
|
+
// pointer hidden for small panels, path taken from ex: https://echarts.apache.org/examples/en/editor.html?c=gauge-grade
|
|
139
|
+
icon: width > GAUGE_SMALL_BREAKPOINT ? 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z' : 'none',
|
|
140
|
+
length: 10,
|
|
141
|
+
width: 5,
|
|
142
|
+
offsetCenter: [
|
|
143
|
+
0,
|
|
144
|
+
'-49%'
|
|
145
|
+
],
|
|
146
|
+
itemStyle: {
|
|
147
|
+
color: 'auto'
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
axisLine,
|
|
151
|
+
axisTick: {
|
|
152
|
+
show: false
|
|
153
|
+
},
|
|
154
|
+
splitLine: {
|
|
155
|
+
show: false
|
|
156
|
+
},
|
|
157
|
+
axisLabel: {
|
|
158
|
+
show: false
|
|
159
|
+
},
|
|
160
|
+
detail: {
|
|
161
|
+
show: true,
|
|
162
|
+
width: '60%',
|
|
163
|
+
borderRadius: 8,
|
|
164
|
+
offsetCenter: [
|
|
165
|
+
0,
|
|
166
|
+
'-9%'
|
|
167
|
+
],
|
|
168
|
+
color: 'inherit',
|
|
169
|
+
fontSize: valueSizeClamp,
|
|
170
|
+
formatter: data.value === null ? // at this level because the `formatter` function argument is `NaN`
|
|
171
|
+
// when the value is `null`, making it difficult to differentiate
|
|
172
|
+
// `null` from a true `NaN` case.
|
|
173
|
+
()=>'null' : (value)=>{
|
|
174
|
+
return (0, _core.formatValue)(value, format);
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
data: [
|
|
178
|
+
{
|
|
179
|
+
value: data.value,
|
|
180
|
+
name: data.label,
|
|
181
|
+
// TODO: new UX for series names, create separate React component or reuse ListLegendItem
|
|
182
|
+
// https://echarts.apache.org/en/option.html#series-gauge.data.title
|
|
183
|
+
title: {
|
|
184
|
+
show: true,
|
|
185
|
+
color: chartsTheme.echartsTheme.textStyle?.color ?? 'inherit',
|
|
186
|
+
offsetCenter: [
|
|
187
|
+
0,
|
|
188
|
+
'55%'
|
|
189
|
+
],
|
|
190
|
+
overflow: 'truncate',
|
|
191
|
+
fontSize: 12,
|
|
192
|
+
width: width * 0.8
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
]
|
|
198
|
+
};
|
|
199
|
+
}, [
|
|
200
|
+
data,
|
|
201
|
+
width,
|
|
202
|
+
height,
|
|
203
|
+
chartsTheme,
|
|
204
|
+
format,
|
|
205
|
+
axisLine,
|
|
206
|
+
max
|
|
207
|
+
]);
|
|
208
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.EChart, {
|
|
209
|
+
sx: {
|
|
210
|
+
width: width,
|
|
211
|
+
height: height,
|
|
212
|
+
padding: `${chartsTheme.container.padding.default}px`
|
|
213
|
+
},
|
|
214
|
+
option: option,
|
|
215
|
+
theme: chartsTheme.echartsTheme
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
function getResponsiveValueSize(value, format, width, height) {
|
|
219
|
+
const MIN_SIZE = 3;
|
|
220
|
+
const MAX_SIZE = 24;
|
|
221
|
+
const SIZE_MULTIPLIER = 0.7;
|
|
222
|
+
const formattedValue = typeof value === 'number' ? (0, _core.formatValue)(value, format) : `${value}`;
|
|
223
|
+
const valueCharacters = formattedValue.length ?? 2;
|
|
224
|
+
const valueSize = Math.min(width, height) / valueCharacters * SIZE_MULTIPLIER;
|
|
225
|
+
return `clamp(${MIN_SIZE}px, ${valueSize}px, ${MAX_SIZE}px)`;
|
|
226
|
+
}
|
|
@@ -36,6 +36,7 @@ const _merge = /*#__PURE__*/ _interop_require_default(require("lodash/merge"));
|
|
|
36
36
|
const _react = require("react");
|
|
37
37
|
const _gaugechartmodel = require("./gauge-chart-model");
|
|
38
38
|
const _thresholds = require("./thresholds");
|
|
39
|
+
const _GaugeChartBase = require("./GaugeChartBase");
|
|
39
40
|
function _interop_require_default(obj) {
|
|
40
41
|
return obj && obj.__esModule ? obj : {
|
|
41
42
|
default: obj
|
|
@@ -95,7 +96,7 @@ function GaugeChartPanel(props) {
|
|
|
95
96
|
};
|
|
96
97
|
// no data message handled inside chart component
|
|
97
98
|
if (gaugeData.length === 0) {
|
|
98
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
99
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_GaugeChartBase.GaugeChartBase, {
|
|
99
100
|
width: contentDimensions.width,
|
|
100
101
|
height: contentDimensions.height,
|
|
101
102
|
data: EMPTY_GAUGE_SERIES,
|
|
@@ -122,7 +123,7 @@ function GaugeChartPanel(props) {
|
|
|
122
123
|
},
|
|
123
124
|
children: gaugeData.map((series, seriesIndex)=>{
|
|
124
125
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
125
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
126
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_GaugeChartBase.GaugeChartBase, {
|
|
126
127
|
width: chartWidth,
|
|
127
128
|
height: contentDimensions.height,
|
|
128
129
|
data: series,
|
package/mf-manifest.json
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
"name": "GaugeChart",
|
|
6
6
|
"type": "app",
|
|
7
7
|
"buildInfo": {
|
|
8
|
-
"buildVersion": "0.
|
|
8
|
+
"buildVersion": "0.7.1",
|
|
9
9
|
"buildName": "@perses-dev/gauge-chart-plugin"
|
|
10
10
|
},
|
|
11
11
|
"remoteEntry": {
|
|
12
|
-
"name": "__mf/js/GaugeChart.
|
|
12
|
+
"name": "__mf/js/GaugeChart.cfdb55a8.js",
|
|
13
13
|
"path": "",
|
|
14
14
|
"type": "global"
|
|
15
15
|
},
|
|
@@ -95,9 +95,9 @@
|
|
|
95
95
|
{
|
|
96
96
|
"id": "GaugeChart:@perses-dev/components",
|
|
97
97
|
"name": "@perses-dev/components",
|
|
98
|
-
"version": "0.51.0-
|
|
98
|
+
"version": "0.51.0-rc.0",
|
|
99
99
|
"singleton": true,
|
|
100
|
-
"requiredVersion": "^0.51.0-
|
|
100
|
+
"requiredVersion": "^0.51.0-rc.0",
|
|
101
101
|
"assets": {
|
|
102
102
|
"js": {
|
|
103
103
|
"async": [
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"__mf/js/async/623.afdd0af8.js"
|
|
112
112
|
],
|
|
113
113
|
"sync": [
|
|
114
|
-
"__mf/js/async/
|
|
114
|
+
"__mf/js/async/432.e6fd356a.js"
|
|
115
115
|
]
|
|
116
116
|
},
|
|
117
117
|
"css": {
|
|
@@ -123,9 +123,9 @@
|
|
|
123
123
|
{
|
|
124
124
|
"id": "GaugeChart:@perses-dev/plugin-system",
|
|
125
125
|
"name": "@perses-dev/plugin-system",
|
|
126
|
-
"version": "0.51.0-
|
|
126
|
+
"version": "0.51.0-rc.0",
|
|
127
127
|
"singleton": true,
|
|
128
|
-
"requiredVersion": "^0.51.0-
|
|
128
|
+
"requiredVersion": "^0.51.0-rc.0",
|
|
129
129
|
"assets": {
|
|
130
130
|
"js": {
|
|
131
131
|
"async": [
|
|
@@ -138,18 +138,19 @@
|
|
|
138
138
|
"__mf/js/async/238.3b90e0d1.js",
|
|
139
139
|
"__mf/js/async/75.4ebd94ad.js",
|
|
140
140
|
"__mf/js/async/623.afdd0af8.js",
|
|
141
|
-
"__mf/js/async/
|
|
142
|
-
"__mf/js/async/
|
|
143
|
-
"__mf/js/async/
|
|
141
|
+
"__mf/js/async/413.8c98e66f.js",
|
|
142
|
+
"__mf/js/async/422.a17fef68.js",
|
|
143
|
+
"__mf/js/async/432.e6fd356a.js",
|
|
144
|
+
"__mf/js/async/957.3c868e35.js",
|
|
144
145
|
"__mf/js/async/774.db64c396.js",
|
|
145
146
|
"__mf/js/async/738.e2de8ee4.js",
|
|
146
|
-
"__mf/js/async/
|
|
147
|
+
"__mf/js/async/409.64ed758e.js",
|
|
147
148
|
"__mf/js/async/981.6ecc2fa1.js",
|
|
148
149
|
"__mf/js/async/770.1ddcdb57.js",
|
|
149
150
|
"__mf/js/async/296.6e15d7c1.js"
|
|
150
151
|
],
|
|
151
152
|
"sync": [
|
|
152
|
-
"__mf/js/async/
|
|
153
|
+
"__mf/js/async/65.8ddd406b.js"
|
|
153
154
|
]
|
|
154
155
|
},
|
|
155
156
|
"css": {
|
|
@@ -189,7 +190,7 @@
|
|
|
189
190
|
"js": {
|
|
190
191
|
"async": [],
|
|
191
192
|
"sync": [
|
|
192
|
-
"__mf/js/async/
|
|
193
|
+
"__mf/js/async/409.64ed758e.js"
|
|
193
194
|
]
|
|
194
195
|
},
|
|
195
196
|
"css": {
|
|
@@ -352,10 +353,11 @@
|
|
|
352
353
|
"assets": {
|
|
353
354
|
"js": {
|
|
354
355
|
"sync": [
|
|
356
|
+
"__mf/js/async/413.8c98e66f.js",
|
|
355
357
|
"__mf/js/async/929.fde3d617.js",
|
|
356
358
|
"__mf/js/async/808.4e339e11.js",
|
|
357
|
-
"__mf/js/async/
|
|
358
|
-
"__mf/js/async/__federation_expose_GaugeChart.
|
|
359
|
+
"__mf/js/async/957.3c868e35.js",
|
|
360
|
+
"__mf/js/async/__federation_expose_GaugeChart.7512420d.js"
|
|
359
361
|
],
|
|
360
362
|
"async": [
|
|
361
363
|
"__mf/js/async/964.80d5e8c0.js",
|
|
@@ -366,17 +368,17 @@
|
|
|
366
368
|
"__mf/js/async/238.3b90e0d1.js",
|
|
367
369
|
"__mf/js/async/224.dd9ee618.js",
|
|
368
370
|
"__mf/js/async/292.d6d07d9c.js",
|
|
369
|
-
"__mf/js/async/
|
|
370
|
-
"__mf/js/async/
|
|
371
|
-
"__mf/js/async/
|
|
371
|
+
"__mf/js/async/422.a17fef68.js",
|
|
372
|
+
"__mf/js/async/1.6f58f98c.js",
|
|
373
|
+
"__mf/js/async/432.e6fd356a.js",
|
|
372
374
|
"__mf/js/async/740.a7a03e99.js",
|
|
373
375
|
"__mf/js/async/75.4ebd94ad.js",
|
|
374
376
|
"__mf/js/async/623.afdd0af8.js",
|
|
375
377
|
"__mf/js/async/lib-router.c799dfc6.js",
|
|
376
|
-
"__mf/js/async/
|
|
378
|
+
"__mf/js/async/65.8ddd406b.js",
|
|
377
379
|
"__mf/js/async/488.6e73b2c9.js",
|
|
378
380
|
"__mf/js/async/738.e2de8ee4.js",
|
|
379
|
-
"__mf/js/async/
|
|
381
|
+
"__mf/js/async/409.64ed758e.js",
|
|
380
382
|
"__mf/js/async/981.6ecc2fa1.js",
|
|
381
383
|
"__mf/js/async/770.1ddcdb57.js",
|
|
382
384
|
"__mf/js/async/296.6e15d7c1.js"
|
package/mf-stats.json
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
"name": "GaugeChart",
|
|
6
6
|
"type": "app",
|
|
7
7
|
"buildInfo": {
|
|
8
|
-
"buildVersion": "0.
|
|
8
|
+
"buildVersion": "0.7.1",
|
|
9
9
|
"buildName": "@perses-dev/gauge-chart-plugin"
|
|
10
10
|
},
|
|
11
11
|
"remoteEntry": {
|
|
12
|
-
"name": "__mf/js/GaugeChart.
|
|
12
|
+
"name": "__mf/js/GaugeChart.cfdb55a8.js",
|
|
13
13
|
"path": "",
|
|
14
14
|
"type": "global"
|
|
15
15
|
},
|
|
@@ -103,10 +103,10 @@
|
|
|
103
103
|
},
|
|
104
104
|
{
|
|
105
105
|
"singleton": true,
|
|
106
|
-
"requiredVersion": "^0.51.0-
|
|
106
|
+
"requiredVersion": "^0.51.0-rc.0",
|
|
107
107
|
"shareScope": "default",
|
|
108
108
|
"name": "@perses-dev/components",
|
|
109
|
-
"version": "0.51.0-
|
|
109
|
+
"version": "0.51.0-rc.0",
|
|
110
110
|
"eager": false,
|
|
111
111
|
"id": "GaugeChart:@perses-dev/components",
|
|
112
112
|
"assets": {
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"__mf/js/async/623.afdd0af8.js"
|
|
123
123
|
],
|
|
124
124
|
"sync": [
|
|
125
|
-
"__mf/js/async/
|
|
125
|
+
"__mf/js/async/432.e6fd356a.js"
|
|
126
126
|
]
|
|
127
127
|
},
|
|
128
128
|
"css": {
|
|
@@ -136,10 +136,10 @@
|
|
|
136
136
|
},
|
|
137
137
|
{
|
|
138
138
|
"singleton": true,
|
|
139
|
-
"requiredVersion": "^0.51.0-
|
|
139
|
+
"requiredVersion": "^0.51.0-rc.0",
|
|
140
140
|
"shareScope": "default",
|
|
141
141
|
"name": "@perses-dev/plugin-system",
|
|
142
|
-
"version": "0.51.0-
|
|
142
|
+
"version": "0.51.0-rc.0",
|
|
143
143
|
"eager": false,
|
|
144
144
|
"id": "GaugeChart:@perses-dev/plugin-system",
|
|
145
145
|
"assets": {
|
|
@@ -154,18 +154,19 @@
|
|
|
154
154
|
"__mf/js/async/238.3b90e0d1.js",
|
|
155
155
|
"__mf/js/async/75.4ebd94ad.js",
|
|
156
156
|
"__mf/js/async/623.afdd0af8.js",
|
|
157
|
-
"__mf/js/async/
|
|
158
|
-
"__mf/js/async/
|
|
159
|
-
"__mf/js/async/
|
|
157
|
+
"__mf/js/async/413.8c98e66f.js",
|
|
158
|
+
"__mf/js/async/422.a17fef68.js",
|
|
159
|
+
"__mf/js/async/432.e6fd356a.js",
|
|
160
|
+
"__mf/js/async/957.3c868e35.js",
|
|
160
161
|
"__mf/js/async/774.db64c396.js",
|
|
161
162
|
"__mf/js/async/738.e2de8ee4.js",
|
|
162
|
-
"__mf/js/async/
|
|
163
|
+
"__mf/js/async/409.64ed758e.js",
|
|
163
164
|
"__mf/js/async/981.6ecc2fa1.js",
|
|
164
165
|
"__mf/js/async/770.1ddcdb57.js",
|
|
165
166
|
"__mf/js/async/296.6e15d7c1.js"
|
|
166
167
|
],
|
|
167
168
|
"sync": [
|
|
168
|
-
"__mf/js/async/
|
|
169
|
+
"__mf/js/async/65.8ddd406b.js"
|
|
169
170
|
]
|
|
170
171
|
},
|
|
171
172
|
"css": {
|
|
@@ -213,7 +214,7 @@
|
|
|
213
214
|
"js": {
|
|
214
215
|
"async": [],
|
|
215
216
|
"sync": [
|
|
216
|
-
"__mf/js/async/
|
|
217
|
+
"__mf/js/async/409.64ed758e.js"
|
|
217
218
|
]
|
|
218
219
|
},
|
|
219
220
|
"css": {
|
|
@@ -410,10 +411,11 @@
|
|
|
410
411
|
"assets": {
|
|
411
412
|
"js": {
|
|
412
413
|
"sync": [
|
|
414
|
+
"__mf/js/async/413.8c98e66f.js",
|
|
413
415
|
"__mf/js/async/929.fde3d617.js",
|
|
414
416
|
"__mf/js/async/808.4e339e11.js",
|
|
415
|
-
"__mf/js/async/
|
|
416
|
-
"__mf/js/async/__federation_expose_GaugeChart.
|
|
417
|
+
"__mf/js/async/957.3c868e35.js",
|
|
418
|
+
"__mf/js/async/__federation_expose_GaugeChart.7512420d.js"
|
|
417
419
|
],
|
|
418
420
|
"async": [
|
|
419
421
|
"__mf/js/async/964.80d5e8c0.js",
|
|
@@ -424,17 +426,17 @@
|
|
|
424
426
|
"__mf/js/async/238.3b90e0d1.js",
|
|
425
427
|
"__mf/js/async/224.dd9ee618.js",
|
|
426
428
|
"__mf/js/async/292.d6d07d9c.js",
|
|
427
|
-
"__mf/js/async/
|
|
428
|
-
"__mf/js/async/
|
|
429
|
-
"__mf/js/async/
|
|
429
|
+
"__mf/js/async/422.a17fef68.js",
|
|
430
|
+
"__mf/js/async/1.6f58f98c.js",
|
|
431
|
+
"__mf/js/async/432.e6fd356a.js",
|
|
430
432
|
"__mf/js/async/740.a7a03e99.js",
|
|
431
433
|
"__mf/js/async/75.4ebd94ad.js",
|
|
432
434
|
"__mf/js/async/623.afdd0af8.js",
|
|
433
435
|
"__mf/js/async/lib-router.c799dfc6.js",
|
|
434
|
-
"__mf/js/async/
|
|
436
|
+
"__mf/js/async/65.8ddd406b.js",
|
|
435
437
|
"__mf/js/async/488.6e73b2c9.js",
|
|
436
438
|
"__mf/js/async/738.e2de8ee4.js",
|
|
437
|
-
"__mf/js/async/
|
|
439
|
+
"__mf/js/async/409.64ed758e.js",
|
|
438
440
|
"__mf/js/async/981.6ecc2fa1.js",
|
|
439
441
|
"__mf/js/async/770.1ddcdb57.js",
|
|
440
442
|
"__mf/js/async/296.6e15d7c1.js"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/gauge-chart-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "rsbuild dev",
|
|
6
6
|
"build": "npm run build-mf && concurrently \"npm:build:*\"",
|
|
@@ -12,13 +12,16 @@
|
|
|
12
12
|
"test": "cross-env LC_ALL=C TZ=UTC jest",
|
|
13
13
|
"type-check": "tsc --noEmit"
|
|
14
14
|
},
|
|
15
|
+
"main": "lib/cjs/index.js",
|
|
16
|
+
"module": "lib/index.js",
|
|
17
|
+
"types": "lib/index.d.ts",
|
|
15
18
|
"peerDependencies": {
|
|
16
19
|
"@emotion/react": "^11.7.1",
|
|
17
20
|
"@emotion/styled": "^11.6.0",
|
|
18
21
|
"@hookform/resolvers": "^3.2.0",
|
|
19
|
-
"@perses-dev/components": "^0.51.0-
|
|
20
|
-
"@perses-dev/core": "^0.51.0-
|
|
21
|
-
"@perses-dev/plugin-system": "^0.51.0-
|
|
22
|
+
"@perses-dev/components": "^0.51.0-rc.0",
|
|
23
|
+
"@perses-dev/core": "^0.51.0-rc.0",
|
|
24
|
+
"@perses-dev/plugin-system": "^0.51.0-rc.0",
|
|
22
25
|
"date-fns": "^4.1.0",
|
|
23
26
|
"date-fns-tz": "^3.2.0",
|
|
24
27
|
"echarts": "5.5.0",
|