Files
emsfront/src/views/ems/dzjk/sbjk/ssyx/CnglqxChart.vue

108 lines
2.5 KiB
Vue
Raw Normal View History

2025-06-18 01:01:17 +08:00
<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="cnglqxChart"/>
</el-card>
</template>
<style scoped lang="scss"></style>
<script>
import * as echarts from 'echarts'
import resize from '@/mixins/ems/resize'
import {formatDate} from "@/filters/ems";
import {storagePower} from '@/api/ems/dzjk'
2025-06-18 01:01:17 +08:00
export default {
mixins: [resize],
data() {
return {
chart: null
}
},
mounted() {
this.chart = echarts.init(document.querySelector('#cnglqxChart'))
2025-06-18 01:01:17 +08:00
},
beforeDestroy() {
if (!this.chart) {
return
}
this.chart.dispose()
this.chart = null
},
methods: {
init(siteId){
this.chart.showLoading()
const x = []
const data1 =[],data2 =[]
storagePower(siteId).then(response => {
const source = response?.data?.energyStoragePowList || []
source.forEach(item=>{
x.push(formatDate(item.createDate,false,true))
data1.push(item.pcsTotalActPower)
data2.push(item.pcsTotalReactivePower)
})
this.setOption(x,data1,data2)
}).finally(()=>{
this.chart.hideLoading()
})
2025-06-18 01:01:17 +08:00
},
setOption(x,data1,data2) {
2025-06-18 01:01:17 +08:00
this.chart.setOption({
color:['#FFBD00','#3C81FF'],
legend: {
left: 'center',
top: '10',
},
grid: {
2025-08-11 21:50:38 +08:00
containLabel: true
2025-06-18 01:01:17 +08:00
},
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
textStyle:{
color:"#333333",
},
xAxis: {type:'category',data:x},
2025-06-18 01:01:17 +08:00
yAxis: {
type: 'value',
},
dataZoom: [
{
type: 'inside',
start: 0,
2025-07-11 17:24:45 +08:00
end: 100
},
{
start: 0,
2025-07-11 17:24:45 +08:00
end: 100
}
],
2025-06-18 01:01:17 +08:00
series: [
{
name:'PCS实时有功功率',
2025-06-18 01:01:17 +08:00
type: 'line',
areaStyle: {
color:'#FFBD00'
},
data: data1,
2025-06-18 01:01:17 +08:00
},{
name:'PCS实时无功功率',
2025-06-18 01:01:17 +08:00
type: 'line',
areaStyle: {
color: '#3C81FF'
},
data: data2
2025-06-18 01:01:17 +08:00
}]
})
}
}
}
</script>