svg拓扑图修改为canvas拓扑图

This commit is contained in:
huangjp
2026-03-09 14:50:40 +08:00
parent b0a6891bce
commit ad1d898e7d
30 changed files with 5463 additions and 3395 deletions

View File

@ -14,7 +14,11 @@
return {
charge_option: {},
stationId: null,
chartLoading: false
chartLoading: false,
chartChargePv:{
chartChargeEle:[],
chartPv:[]
}
}
},
props: {
@ -27,13 +31,16 @@
currentStation() {
return this.vuex_currentStation;
},
inverterFlag(){
return this.vuex_inverterFlag;
},
},
watch: {
currentStation: {
handler(val) {
if (val && val.id) {
this.stationId = val.id
this.GetChargeChart()
this.getData();
}
},
deep: true,
@ -42,7 +49,7 @@
activeTime: {
handler(val) {
if (val && this.stationId) {
this.GetChargeChart()
this.getData();
}
},
deep: true,
@ -51,8 +58,32 @@
},
methods: {
getData() {
this.GetChargeChart()
async getData() {
await this.GetChargeChart()
if(this.inverterFlag === 1){
this.GetPvChart()
}
},
async GetPvChart() {
this.chartLoading = true
//充放电曲线
let self = this;
return new Promise((resolve, reject) => {
self.$u.api.homePageData
.getPvElecData({
stationId: this.stationId,
type: this.activeTime,
})
.then((res) => {
self.chartLoading = false;
self.chartChargePv.chartPv = res.data;
self.initChargeChart(self.chartChargePv);
resolve();
})
.catch((err) => {
reject("错误");
});
});
},
async GetChargeChart() {
this.chartLoading = true
@ -66,7 +97,11 @@
})
.then((res) => {
self.chartLoading = false
self.initChargeChart(res.data);
if(self.inverterFlag !== 1){
self.initChargeChart(res.data);
}else{
self.chartChargePv.chartChargeEle = res.data;
}
resolve();
})
.catch((err) => {
@ -80,12 +115,13 @@
let discharge_data = [];
let pv_data = [];
let benefit_data = [];
if (val && val.length > 0) {
val.forEach((item) => {
let self = this;
if (val.chartChargeEle && val.chartChargeEle.length > 0) {
val.chartChargeEle.forEach((item,idx) => {
x_data.push(item.date);
charge_data.push(item.chargeElec);
discharge_data.push(item.dischargeElec);
pv_data.push(item.pvChargeElec);
if(self.inverterFlag === 1){pv_data.push(val.chartPv.length > 0? val.chartPv[idx].powerGenerate:'0')};
benefit_data.push(item.income);
});
} else {
@ -95,6 +131,43 @@
pv_data = [0, 0, 0, 0, 0, 0, 0];
benefit_data = [0, 0, 0, 0, 0, 0, 0];
}
let optionConfigPv = {
color: ["#009458", "#BFE49F", "#3977B1"],
legend:[this.$t('homePage.home.charge'), this.$t('homePage.home.disCharge'), this.$t(
'homePage.home.photovoltaicCharge')],
series: [{
data: charge_data,
type: "bar",
name: this.$t('homePage.home.charge'),
},
{
data: discharge_data,
type: "bar",
name: this.$t('homePage.home.disCharge'),
},
{
data: pv_data,
type: "bar",
name: this.$t('homePage.home.photovoltaicCharge'),
}
]
};
let optionConfig = {
color: ["#009458", "#BFE49F"],
legend:[this.$t('homePage.home.charge'), this.$t('homePage.home.disCharge')],
series: [{
data: charge_data,
type: "bar",
name: this.$t('homePage.home.charge'),
},
{
data: discharge_data,
type: "bar",
name: this.$t('homePage.home.disCharge'),
}
]
};
//充放电图表
this.charge_option = {
tooltip: {
@ -144,7 +217,7 @@
return [x, y];
},
},
color: ["#009458", "#BFE49F", "#3977B1"],
color: self.inverterFlag === 1? optionConfigPv.color:optionConfig.color,
legend: {
animation: false,
right: "0",
@ -152,8 +225,7 @@
icon: "rect",
itemWidth: 10,
itemHeight: 10,
data: [this.$t('homePage.home.charge'), this.$t('homePage.home.disCharge'), this.$t(
'homePage.home.photovoltaicCharge')],
data: self.inverterFlag === 1? optionConfigPv.legend:optionConfig.legend,
},
grid: {
left: "15%",
@ -211,23 +283,7 @@
},
},
},
series: [{
data: charge_data,
type: "bar",
name: this.$t('homePage.home.charge'),
},
{
data: discharge_data,
type: "bar",
name: this.$t('homePage.home.disCharge'),
},
{
data: pv_data,
type: "bar",
name: this.$t('homePage.home.photovoltaicCharge'),
},
],
series: self.inverterFlag === 1? optionConfigPv.series:optionConfig.series,
};
},
},