Skip to content

Commit d6eb0cd

Browse files
committed
feat: home 1
1 parent 9a3d1ad commit d6eb0cd

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

src/views/iot/home/index.vue

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -236,19 +236,14 @@ const initCharts = () => {
236236
237237
/** 初始化仪表盘图表 */
238238
const initGaugeChart = (el: any, value: number, color: string) => {
239-
// 计算百分比,保留1位小数
240-
const percentage = statsData.value.deviceTotal > 0
241-
? Number(((value / statsData.value.deviceTotal) * 100).toFixed(1))
242-
: 0
243-
244239
echarts.init(el).setOption({
245240
series: [
246241
{
247242
type: 'gauge',
248243
startAngle: 360,
249244
endAngle: 0,
250245
min: 0,
251-
max: 100, // 将最大值设为100
246+
max: statsData.value.deviceTotal || 100, // 使用设备总数作为最大值
252247
progress: {
253248
show: true,
254249
width: 12,
@@ -270,29 +265,16 @@ const initGaugeChart = (el: any, value: number, color: string) => {
270265
title: { show: false },
271266
detail: {
272267
valueAnimation: true,
273-
fontSize: 20,
268+
fontSize: 24,
274269
fontWeight: 'bold',
275270
fontFamily: 'Inter, sans-serif',
276271
color: color,
277272
offsetCenter: [0, '0'],
278273
formatter: (value: number) => {
279-
return `${value}%\n(${statsData.value.deviceTotal > 0 ? Math.round((value / 100) * statsData.value.deviceTotal) : 0}个)`
280-
},
281-
rich: {
282-
value: {
283-
fontSize: 20,
284-
fontWeight: 'bold',
285-
color: color,
286-
padding: [0, 0, 10, 0]
287-
},
288-
unit: {
289-
fontSize: 14,
290-
color: '#6B7280',
291-
padding: [0, 0, 0, 0]
292-
}
274+
return `${value}个`
293275
}
294276
},
295-
data: [{ value: percentage }]
277+
data: [{ value: value }]
296278
}
297279
]
298280
})

0 commit comments

Comments
 (0)