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

126 lines
3.0 KiB
Vue
Raw Normal View History

2025-06-18 01:01:17 +08:00
<template>
2025-09-27 14:50:20 +08:00
<el-card
shadow="always"
class="common-card-container common-card-container-body-no-padding"
>
2025-06-18 01:01:17 +08:00
<div slot="header">
2025-09-27 14:50:20 +08:00
<span class="card-title">PCS有功功率/PCS无功功率</span>
2025-06-18 01:01:17 +08:00
</div>
2025-09-27 14:50:20 +08:00
<div style="height: 360px" id="cnglqxChart" />
2025-06-18 01:01:17 +08:00
</el-card>
</template>
<style scoped lang="scss"></style>
<script>
2025-09-27 14:50:20 +08:00
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 {
2025-09-27 14:50:20 +08:00
chart: null,
};
2025-06-18 01:01:17 +08:00
},
mounted() {
2025-09-27 14:50:20 +08:00
this.chart = echarts.init(document.querySelector("#cnglqxChart"));
2025-06-18 01:01:17 +08:00
},
beforeDestroy() {
if (!this.chart) {
2025-09-27 14:50:20 +08:00
return;
2025-06-18 01:01:17 +08:00
}
2025-09-27 14:50:20 +08:00
this.chart.dispose();
this.chart = null;
2025-06-18 01:01:17 +08:00
},
methods: {
2025-09-27 14:50:20 +08:00
init(siteId) {
this.chart.showLoading();
const x = [];
const data1 = [],
data2 = [];
storagePower(siteId)
.then((response) => {
this.setOption(response?.data?.pcsPowerList || []);
})
2025-09-27 14:50:20 +08:00
.finally(() => {
this.chart.hideLoading();
});
2025-06-18 01:01:17 +08:00
},
2025-09-27 14:50:20 +08:00
setOption(data) {
// data=[{deviceId:'pcs1',energyStoragePowList:[{createDate,deviceId,pcsTotalActPower,pcsTotalReactivePower}]}]
let xdata = [],
series = [];
data.forEach((element, index) => {
if (index === 0) {
xdata = (element.energyStoragePowList || []).map((i) => i.createDate);
}
series.push(
{
type: "line",
name: `${element.deviceId}有功功率`,
areaStyle: {
// color:'#FFBD00'
},
data: (element.energyStoragePowList || []).map(
(i) => i.pcsTotalActPower
),
},
{
type: "line",
name: `${element.deviceId}无功功率`,
areaStyle: {
// color:'#FFBD00'
},
data: (element.energyStoragePowList || []).map(
(i) => i.pcsTotalReactivePower
),
}
);
});
2025-06-18 01:01:17 +08:00
this.chart.setOption({
legend: {
2025-09-27 14:50:20 +08:00
left: "center",
top: "5",
itemWidth: 10,
itemHeight: 5,
textStyle: {
fontSize: 9,
},
},
grid: {
2025-09-27 14:50:20 +08:00
containLabel: true,
2025-06-18 01:01:17 +08:00
},
tooltip: {
2025-09-27 14:50:20 +08:00
trigger: "axis",
axisPointer: {
// 坐标轴指示器,坐标轴触发有效
type: "shadow", // 默认为直线,可选为:'line' | 'shadow'
},
2025-06-18 01:01:17 +08:00
},
2025-09-27 14:50:20 +08:00
textStyle: {
color: "#333333",
2025-06-18 01:01:17 +08:00
},
2025-09-27 14:50:20 +08:00
xAxis: { type: "category", data: xdata },
2025-06-18 01:01:17 +08:00
yAxis: {
2025-09-27 14:50:20 +08:00
type: "value",
2025-06-18 01:01:17 +08:00
},
dataZoom: [
{
2025-09-27 14:50:20 +08:00
type: "inside",
start: 0,
2025-09-27 14:50:20 +08:00
end: 100,
},
{
start: 0,
2025-09-27 14:50:20 +08:00
end: 100,
},
],
2025-09-27 14:50:20 +08:00
series,
});
},
},
};
2025-06-18 01:01:17 +08:00
</script>