湖里大屏:优化若干布局和样式

This commit is contained in:
Luck-Xiaomi 2022-08-27 17:58:27 +08:00
parent 7e7afecc33
commit fd345d9654

View File

@ -3,12 +3,22 @@
<Card :title="title"> <Card :title="title">
<div class="contentBox"> <div class="contentBox">
<div class="myChart" ref="myChart" /> <div class="myChart" ref="myChart" />
<div class="count">
<div class="count-item">
<div class="label">扬尘噪声报警</div>
<div class="num">{{ alarmData.noiseNum }}</div>
</div>
<div class="count-item">
<div class="label">PM2.5超标报警</div>
<div class="num">{{ alarmData.pm25Num }}</div>
</div>
</div>
</div> </div>
</Card> </Card>
</template> </template>
<script> <script>
import Card from '../components/Card'; import Card from '../components/Card'
import echarts from 'echarts4' import echarts from 'echarts4'
import { selectEnvironmentAlarmCountTotalApi } from '@/assets/js/api/dataBoard' import { selectEnvironmentAlarmCountTotalApi } from '@/assets/js/api/dataBoard'
@ -38,7 +48,7 @@ export default {
sn: this.$store.state.projectSn sn: this.$store.state.projectSn
}).then(res => { }).then(res => {
this.alarmData = res.result this.alarmData = res.result
// console.log('',res.result); console.log('报警统计',res.result);
this.initMyChart() this.initMyChart()
}) })
}, },
@ -47,7 +57,7 @@ export default {
const option = { const option = {
title: { title: {
textAlign: 'center', textAlign: 'center',
x: '29%', x: '48%',
y: '38%', y: '38%',
text: this.alarmData.totalAlarm, text: this.alarmData.totalAlarm,
textStyle: { textStyle: {
@ -65,27 +75,27 @@ export default {
tooltip: { tooltip: {
trigger: 'item' trigger: 'item'
}, },
legend: { // legend: {
type: 'scroll', // type: 'scroll',
orient: 'vertical', // orient: 'vertical',
right: 30, // right: 30,
top: 'center', // top: 'center',
itemWidth: 10, // // itemWidth: 10, //
itemHeight: 10, // // itemHeight: 10, //
selectedMode: true, // selectedMode: true,
itemGap: 50, // itemGap: 50,
icon: 'circle', // icon: 'circle',
textStyle: { // textStyle: {
color: '#ffffff', // color: '#ffffff',
fontSize: 16, // fontSize: 16,
} // }
}, // },
color: ['#ff6c7f', '#567cf6'], color: ['#ff6c7f', '#567cf6'],
series: [ series: [
{ {
type: 'pie', type: 'pie',
radius: ['50%', '65%'], radius: ['50%', '65%'],
center: ['30%', '50%'], center: ['50%', '50%'],
avoidLabelOverlap: true, avoidLabelOverlap: true,
// itemStyle: { // itemStyle: {
// borderRadius: 8, // borderRadius: 8,
@ -109,8 +119,8 @@ export default {
show: false show: false
}, },
data: [ data: [
{ value: this.alarmData.noiseNum, name: `扬尘噪声报警 : ${this.alarmData.noiseNum}` }, { value: this.alarmData.noiseNum, name: `扬尘噪声报警` },
{ value: this.alarmData.pm25Num, name: `PM2.5超标报警 : ${this.alarmData.pm25Num}` } { value: this.alarmData.pm25Num, name: `PM2.5超标报警` }
] ]
} }
] ]
@ -124,13 +134,57 @@ export default {
<style lang="less" scoped> <style lang="less" scoped>
.contentBox { .contentBox {
display: flex;
width: 100%; width: 100%;
height: 100%; height: 100%;
.myChart { .myChart {
width: 100%; width: 50%;
height: 100%; height: 100%;
} }
.count {
flex: 1;
height: 100%;
display: flex;
box-sizing: border-box;
padding-left: 10%;
flex-direction: column;
justify-content: center;
align-items: flex-start;
.count-item {
position: relative;
&::before {
position: absolute;
left: -16px;
top: 10px;
content: '';
width: 10px;
height: 10px;
border-radius: 50%;
}
&:first-child {
margin-bottom: 20px;
}
&:first-child::before {
background-color: #ff768b;
transform: translateY(-6px);
}
&:last-child::before {
background-color: #3cabfd;
transform: translateY(-6px);
}
.label {
margin-bottom: 8px;
font-size: 14px;
color: rgba(255, 255, 255, 0.7);
}
.num {
font-size: 20px;
}
}
}
} }
</style> </style>