Files
emsfront/src/views/ems/home/SbgjzbChart.vue

73 lines
1.5 KiB
Vue
Raw Normal View History

<template>
2025-06-17 00:46:20 +08:00
<el-card shadow="always" class="common-card-container common-card-container-body-no-padding">
<div slot="header">
2025-06-17 00:46:20 +08:00
<span class="card-title">设备告警占比</span>
</div>
<div style="height: 360px" id="sbgjzbChart"/>
</el-card>
</template>
2025-06-17 00:46:20 +08:00
<style scoped lang="scss"></style>
<script>
import * as echarts from 'echarts'
import resize from '@/mixins/ems/resize'
export default {
mixins: [resize],
data() {
return {
chart: null
}
},
beforeDestroy() {
if (!this.chart) {
return
}
this.chart.dispose()
this.chart = null
},
methods: {
initChart(data) {
this.chart = echarts.init(document.querySelector('#sbgjzbChart'))
this.setOption(data)
},
setOption(data) {
const source= []
data.forEach(item => {
source.push({value: item.alarmNum, name: item.type})
})
this.chart.setOption({
color:['#FFBE29','#3C81FF','#A796FF','#FC6B69','#58F3AA'],
tooltip: {
trigger: 'item'
},
2025-08-13 14:51:26 +08:00
grid: {
containLabel: true
},
legend: {
left: 'center',
2025-08-13 14:51:26 +08:00
bottom: '15',
},
series: [
{
name: '设备告警占比',
type: 'pie',
radius: '50%',
data:source,
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
})
}
}
}
</script>