73 lines
1.5 KiB
Vue
73 lines
1.5 KiB
Vue
|
|
<template>
|
|
<el-card shadow="always" class="common-card-container common-card-container-body-no-padding">
|
|
<div slot="header">
|
|
<span class="card-title">设备告警占比</span>
|
|
</div>
|
|
<div style="height: 360px" id="sbgjzbChart"/>
|
|
</el-card>
|
|
</template>
|
|
|
|
<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'
|
|
},
|
|
grid: {
|
|
containLabel: true
|
|
},
|
|
legend: {
|
|
left: 'center',
|
|
bottom: '15',
|
|
},
|
|
series: [
|
|
{
|
|
name: '设备告警占比',
|
|
type: 'pie',
|
|
radius: '50%',
|
|
data:source,
|
|
emphasis: {
|
|
itemStyle: {
|
|
shadowBlur: 10,
|
|
shadowOffsetX: 0,
|
|
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
|
}
|
|
}
|
|
}
|
|
]
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
</script>
|