湖里大屏(环境管理):趋势图切换

This commit is contained in:
骆乐 2022-08-03 15:21:22 +08:00
parent 2874210f88
commit 41e92e7735

View File

@ -2,7 +2,7 @@
<!-- 趋势图 --> <!-- 趋势图 -->
<div class="contentBox"> <div class="contentBox">
<div class="titleTxt">{{ title }}</div> <div class="titleTxt">{{ title }}</div>
<!-- <div class="operateBar"> <div class="operateBar">
<span <span
class="greenBtn" class="greenBtn"
@click="switchingData(1)" @click="switchingData(1)"
@ -59,13 +59,16 @@
/> />
{{ $t("message.environmentalOverview.e6SelectArr")[3].title }} {{ $t("message.environmentalOverview.e6SelectArr")[3].title }}
</span> </span>
</div> --> </div>
<div class="myChart" ref="myChart" /> <div class="myChart" ref="myChart" />
</div> </div>
</template> </template>
<script> <script>
import echarts from "echarts4"; import echarts from "echarts4";
import {
getEnvironmentWarningInfo
} from "@/assets/js/api/environmentManage";
export default { export default {
props: { props: {
title: { title: {
@ -75,26 +78,77 @@ export default {
}, },
data() { data() {
return { return {
data : [90, 85, 100, 96, 100, 150, 190, 125 ] data : [90, 85, 100, 96, 100, 150, 190, 125 ],
checked:1,
dustData_24:[],
}; };
}, },
mounted() { mounted() {
this.initMyChart(); this.initMyChart();
}, },
methods: { methods: {
changeData(type){ getEnvironmentWarningInfoApi(){
if(type == 1){ // console.log('');
this.data = [110, 65, 210, 96, 100, 160, 130, 220] getEnvironmentWarningInfo({
}else if(type == 2){ deviceId: this.currentDevDetail.deviceId,
this.data = [90, 85, 100, 96, 100, 150, 190, 125] projectSn: this.projectSn,
}else if(type == 3 ){ warningType: 1
this.data = [100, 160, 130, 220, 90, 85, 100, 96,] }).then(res => {
}else{ console.log(res.result);
this.data = [130, 220, 90, 85, 100, 65, 210, 96] this.pm10Warning = res.result.pm10Warning
} this.pm25Warning = res.result.pm25Warning
this.noiseWarning = res.result.noiseWarning
this.windSpeedWarning = res.result.windSpeed
this.createdEcharts2();
})
},
// 24
switchingData(value) {
this.checked = value;
this.initMyChart();
}, },
initMyChart() { initMyChart() {
const myChart = echarts.init(this.$refs.myChart); const myChart = echarts.init(this.$refs.myChart);
// this.dustData_24.forEach((element) => {
// //
// xdata.push(element.uploadDate.split(" ")[1]);
// switch (this.checked) {
// case 1:
// ydata.push(element.pm25);
// Alert = 'pm25'+this.$t('message.dataBoard.guard') + '(' + this.pm25Warning + ')'
// AlertNumber = this.pm25Warning
// break;
// case 2:
// ydata.push(element.pm10);
// Alert = 'pm10'+this.$t('message.dataBoard.guard')+ '(' + this.pm10Warning + ')'
// AlertNumber = this.pm10Warning
// break;
// case 3:
// ydata.push(element.windspeed);
// Alert = this.$t('message.dataBoard.windSpeed')+this.$t('message.dataBoard.guard')+ '(' + this.windSpeedWarning + ')'
// AlertNumber = this.windSpeedWarning
// break;
// case 4:
// ydata.push(element.noise);
// Alert = this.$t('message.dataBoard.noise')+this.$t('message.dataBoard.guard')+ '(' + this.noiseWarning + ')'
// AlertNumber = this.noiseWarning
// break;
// }
// });
switch (this.checked) {
case 1:
this.data = [90, 85, 100, 96, 100, 150, 190, 125 ]
break;
case 2:
this.data = [ 100, 150, 190, 125,90, 85, 100, 96 ]
break;
case 3:
this.data = [100, 96, 100, 150,90, 85, 190, 125 ]
break;
case 4:
this.data = [90, 96, 100, 85, 100,150, 190, 125 ]
break;
}
const option = { const option = {
xAxis: { xAxis: {
type: "category", type: "category",
@ -167,7 +221,10 @@ export default {
} }
.myChart { .myChart {
width: 100%; width: 100%;
height: 100%; height: 90%;
}
.operateBar{
margin: 20px 0px 0px 20px;
} }
} }
</style> </style>