8
8
<div class =" flex flex-col" >
9
9
<div class =" flex justify-between items-center mb-1" >
10
10
<span class =" text-gray-500 text-base font-medium" >品类数量</span >
11
- <Icon icon =" ep:menu" class =" text-2xl text-blue-400" />
11
+ <Icon icon =" ep:menu" class =" text-[32px] text-blue-400" />
12
12
</div >
13
13
<span class =" text-3xl font-bold text-gray-700" >{{ statsData.categoryTotal }}</span >
14
14
<el-divider class =" my-2" />
24
24
<div class =" flex flex-col" >
25
25
<div class =" flex justify-between items-center mb-1" >
26
26
<span class =" text-gray-500 text-base font-medium" >产品数量</span >
27
- <Icon icon =" ep:box" class =" text-2xl text-orange-400" />
27
+ <Icon icon =" ep:box" class =" text-[32px] text-orange-400" />
28
28
</div >
29
29
<span class =" text-3xl font-bold text-gray-700" >{{ statsData.productTotal }}</span >
30
30
<el-divider class =" my-2" />
40
40
<div class =" flex flex-col" >
41
41
<div class =" flex justify-between items-center mb-1" >
42
42
<span class =" text-gray-500 text-base font-medium" >设备数量</span >
43
- <Icon icon =" ep:cpu" class =" text-2xl text-purple-400" />
43
+ <Icon icon =" ep:cpu" class =" text-[32px] text-purple-400" />
44
44
</div >
45
45
<span class =" text-3xl font-bold text-gray-700" >{{ statsData.deviceTotal }}</span >
46
46
<el-divider class =" my-2" />
56
56
<div class =" flex flex-col" >
57
57
<div class =" flex justify-between items-center mb-1" >
58
58
<span class =" text-gray-500 text-base font-medium" >物模型消息</span >
59
- <Icon icon =" ep:message" class =" text-2xl text-teal-400" />
59
+ <Icon icon =" ep:message" class =" text-[32px] text-teal-400" />
60
60
</div >
61
61
<span class =" text-3xl font-bold text-gray-700" >{{ statsData.reportTotal }}</span >
62
62
<el-divider class =" my-2" />
@@ -236,12 +236,19 @@ const initCharts = () => {
236
236
237
237
/** 初始化仪表盘图表 */
238
238
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
+
239
244
echarts .init (el ).setOption ({
240
245
series: [
241
246
{
242
247
type: ' gauge' ,
243
248
startAngle: 360 ,
244
249
endAngle: 0 ,
250
+ min: 0 ,
251
+ max: 100 , // 将最大值设为100
245
252
progress: {
246
253
show: true ,
247
254
width: 12 ,
@@ -263,16 +270,29 @@ const initGaugeChart = (el: any, value: number, color: string) => {
263
270
title: { show: false },
264
271
detail: {
265
272
valueAnimation: true ,
266
- fontSize: 24 ,
273
+ fontSize: 20 ,
267
274
fontWeight: ' bold' ,
268
275
fontFamily: ' Inter, sans-serif' ,
269
276
color: color ,
270
277
offsetCenter: [0 , ' 0' ],
271
278
formatter : (value : number ) => {
272
- return value + ' 个'
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
+ }
273
293
}
274
294
},
275
- data: [{ value: value }]
295
+ data: [{ value: percentage }]
276
296
}
277
297
]
278
298
})
0 commit comments