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

99 lines
2.0 KiB
Vue
Raw Normal View History

<template>
<el-card shadow="always" class="chart-card-container">
<div slot="header">
<span class="chart-title">设备告警占比</span>
</div>
<div style="height: 360px" id="sbgjzbChart"/>
</el-card>
</template>
<style scoped lang="scss">
.chart-card-container{
::v-deep {
.el-card__header{
padding:14px;
border-bottom: none;
font-size: 12px;
background: #F1F5FB ;
.chart-title{
font-weight: 500;
color:#333333;
}
.el-button--text{
color: #666666;
}
}
.el-card__body{
padding:0;
}
}
}
</style>
<script>
import * as echarts from 'echarts'
require('echarts/theme/macarons') // echarts theme
import resize from '@/mixins/ems/resize'
export default {
mixins: [resize],
data() {
return {
chart: null
}
},
mounted() {
this.$nextTick(() => {
this.initChart()
})
},
beforeDestroy() {
if (!this.chart) {
return
}
this.chart.dispose()
this.chart = null
},
methods: {
initChart() {
this.chart = echarts.init(document.querySelector('#sbgjzbChart'), 'macarons')
this.setOptions()
},
setOptions() {
this.chart.setOption({
color:['#FFBE29','#3C81FF','#A796FF','#FC6B69','#58F3AA'],
tooltip: {
trigger: 'item'
},
legend: {
left: 'center',
bottom:'10'
},
series: [
{
name: '设备告警占比',
type: 'pie',
radius: '50%',
data: [
{ value: 1048, name: '数据一' },
{ value: 735, name: '数据二' },
{ value: 580, name: '数据三' },
{ value: 484, name: '数据四' },
{ value: 300, name: '数据五' }
],
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
})
}
}
}
</script>