|
@@ -0,0 +1,209 @@
|
|
|
+<template>
|
|
|
+ <div class="item sensor-status-chart-circle">
|
|
|
+ <div class="title">
|
|
|
+ <span class="name">传感器状态<span class="number" style="padding-left:10px;">{{ total }}</span></span>
|
|
|
+ <!-- <span class="detail" @click="linkTo">详情>></span> -->
|
|
|
+ </div>
|
|
|
+ <div class="container">
|
|
|
+ <div v-if="status" id="sensor-status-chart-circle" />
|
|
|
+ <div class="legend">
|
|
|
+ <div v-for="(legend,index) in option.series" :key="index" class="legend-item">
|
|
|
+ <div class="lable">{{ legend.name }}</div>
|
|
|
+ <div class="number" :style="{background: `linear-gradient(90deg, #021a34 0%, ${legend.data[0].itemStyle.color} 100%)`}">
|
|
|
+ <span>{{ legend.data[0].value }}</span>
|
|
|
+ <span class="unit">台</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import * as echarts from 'echarts'
|
|
|
+export default {
|
|
|
+ name: 'SensorStatusCircle',
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ myChart: null,
|
|
|
+ status: true,
|
|
|
+ total: '',
|
|
|
+ option: {
|
|
|
+ tooltip: {
|
|
|
+ trigger: 'item',
|
|
|
+ formatter: '{a} <br/>{b}: {c} ({d}%)'
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ name: '正常报警',
|
|
|
+ type: 'pie',
|
|
|
+ selectedMode: 'single',
|
|
|
+ radius: ['65%', '70%'],
|
|
|
+ center: ['25%', '50%'],
|
|
|
+ clockWise: false,
|
|
|
+ label: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ labelLine: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ { value: 0, name: '正常报警', itemStyle: { color: '#2affff' }},
|
|
|
+ { value: 0, name: '总数', itemStyle: { color: '#021a34' }}
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'C级报警',
|
|
|
+ type: 'pie',
|
|
|
+ clockWise: false,
|
|
|
+ selectedMode: 'single',
|
|
|
+ radius: ['55%', '60%'],
|
|
|
+ center: ['25%', '50%'],
|
|
|
+ label: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ labelLine: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ { value: 0, name: 'C级报警', itemStyle: { color: '#fac858' }},
|
|
|
+ { value: 0, name: '总数', itemStyle: { color: '#021a34' }}
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'D级报警',
|
|
|
+ type: 'pie',
|
|
|
+ clockWise: false,
|
|
|
+ selectedMode: 'single',
|
|
|
+ radius: ['45%', '50%'],
|
|
|
+ center: ['25%', '50%'],
|
|
|
+ label: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ labelLine: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ { value: 0, name: 'D级报警', itemStyle: { color: '#f44336' }},
|
|
|
+ { value: 0, name: '总数', itemStyle: { color: '#021a34' }}
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '离线报警',
|
|
|
+ type: 'pie',
|
|
|
+ clockWise: false,
|
|
|
+ radius: ['35%', '40%'],
|
|
|
+ center: ['25%', '50%'],
|
|
|
+ label: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ { value: 0, name: '离线报警', itemStyle: { color: '#5470c6' }},
|
|
|
+ { value: 0, name: '总数', itemStyle: { color: '#021a34' }}
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.init()
|
|
|
+ this.reload()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ destroyed() {
|
|
|
+ this.status = false
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ init() {
|
|
|
+ var chartDom = document.getElementById('sensor-status-chart-circle')
|
|
|
+ var myChart = echarts.init(chartDom)
|
|
|
+
|
|
|
+ this.option && myChart.setOption(this.option)
|
|
|
+ myChart.on('click', function(params) {
|
|
|
+ console.log('SensorStatus', params)
|
|
|
+ })
|
|
|
+ this.myChart = myChart
|
|
|
+ },
|
|
|
+ reload() {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.goafdevstatis()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ goafdevstatis() {
|
|
|
+ const option = JSON.parse(JSON.stringify(this.option))
|
|
|
+ const total = 1000
|
|
|
+ option.series[0].data[0].value = 600
|
|
|
+ option.series[1].data[0].value = 100
|
|
|
+ option.series[2].data[0].value = 80
|
|
|
+ option.series[3].data[0].value = 50
|
|
|
+
|
|
|
+ option.series[0].data[1].value = total
|
|
|
+ option.series[1].data[1].value = total
|
|
|
+ option.series[2].data[1].value = total
|
|
|
+ option.series[3].data[1].value = total
|
|
|
+ this.option = option
|
|
|
+ if (!this.myChart) {
|
|
|
+ var chartDom = document.getElementById('sensor-status-chart-circle')
|
|
|
+ var myChart = echarts.init(chartDom)
|
|
|
+ this.myChart = myChart
|
|
|
+ }
|
|
|
+ this.myChart.setOption(option)
|
|
|
+ this.myChart.on('click', (params) => {
|
|
|
+ this.$router.push({
|
|
|
+ path: '/particulars/sensor',
|
|
|
+ query: {
|
|
|
+ id: '0'
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ linkTo() {
|
|
|
+ this.$router.push({
|
|
|
+ path: '/particulars/sensor',
|
|
|
+ query: {
|
|
|
+ id: '0'
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.sensor-status-chart-circle{
|
|
|
+ ::v-deep .container{
|
|
|
+ height: 26vh !important;
|
|
|
+ // min-height: 164px;
|
|
|
+ position: relative;
|
|
|
+ #sensor-status-chart-circle{
|
|
|
+ width: 95%;
|
|
|
+ height: 100%;
|
|
|
+ }
|
|
|
+ .legend{
|
|
|
+ position: absolute;
|
|
|
+ right: 20px;
|
|
|
+ top: 20%;
|
|
|
+ .legend-item{
|
|
|
+ color: #fff;
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-end;
|
|
|
+ align-items: center;
|
|
|
+ .lable{
|
|
|
+ padding: 8px 10px;
|
|
|
+ flex: 1;
|
|
|
+ }
|
|
|
+ .number{
|
|
|
+ width: 100px;
|
|
|
+ padding: 8px 10px;
|
|
|
+ margin-left: 10px;
|
|
|
+ text-align: center;
|
|
|
+ .unit{
|
|
|
+ padding-left: 10px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+</style>
|