mirror of
https://gitee.com/myxzgzs/boyue-ui-admin-vue3
synced 2025-08-08 16:32:43 +08:00
feat: home 1
This commit is contained in:
parent
9a3d1ad934
commit
d6eb0cd850
@ -236,11 +236,6 @@ const initCharts = () => {
|
|||||||
|
|
||||||
/** 初始化仪表盘图表 */
|
/** 初始化仪表盘图表 */
|
||||||
const initGaugeChart = (el: any, value: number, color: string) => {
|
const initGaugeChart = (el: any, value: number, color: string) => {
|
||||||
// 计算百分比,保留1位小数
|
|
||||||
const percentage = statsData.value.deviceTotal > 0
|
|
||||||
? Number(((value / statsData.value.deviceTotal) * 100).toFixed(1))
|
|
||||||
: 0
|
|
||||||
|
|
||||||
echarts.init(el).setOption({
|
echarts.init(el).setOption({
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
@ -248,7 +243,7 @@ const initGaugeChart = (el: any, value: number, color: string) => {
|
|||||||
startAngle: 360,
|
startAngle: 360,
|
||||||
endAngle: 0,
|
endAngle: 0,
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 100, // 将最大值设为100
|
max: statsData.value.deviceTotal || 100, // 使用设备总数作为最大值
|
||||||
progress: {
|
progress: {
|
||||||
show: true,
|
show: true,
|
||||||
width: 12,
|
width: 12,
|
||||||
@ -270,29 +265,16 @@ const initGaugeChart = (el: any, value: number, color: string) => {
|
|||||||
title: { show: false },
|
title: { show: false },
|
||||||
detail: {
|
detail: {
|
||||||
valueAnimation: true,
|
valueAnimation: true,
|
||||||
fontSize: 20,
|
fontSize: 24,
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
fontFamily: 'Inter, sans-serif',
|
fontFamily: 'Inter, sans-serif',
|
||||||
color: color,
|
color: color,
|
||||||
offsetCenter: [0, '0'],
|
offsetCenter: [0, '0'],
|
||||||
formatter: (value: number) => {
|
formatter: (value: number) => {
|
||||||
return `${value}%\n(${statsData.value.deviceTotal > 0 ? Math.round((value / 100) * statsData.value.deviceTotal) : 0}个)`
|
return `${value}个`
|
||||||
},
|
|
||||||
rich: {
|
|
||||||
value: {
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: 'bold',
|
|
||||||
color: color,
|
|
||||||
padding: [0, 0, 10, 0]
|
|
||||||
},
|
|
||||||
unit: {
|
|
||||||
fontSize: 14,
|
|
||||||
color: '#6B7280',
|
|
||||||
padding: [0, 0, 0, 0]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data: [{ value: percentage }]
|
data: [{ value: value }]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user