功率、pcs、电池堆曲线更新为折线图

This commit is contained in:
2025-09-27 17:26:08 +08:00
parent 651a78bceb
commit fb4f9d4abc
3 changed files with 411 additions and 322 deletions

View File

@ -1,28 +1,38 @@
<template> <template>
<el-card shadow="always" class="common-card-container time-range-card" style="margin-top:20px"> <el-card
shadow="always"
class="common-card-container time-range-card"
style="margin-top: 20px"
>
<div slot="header" class="time-range-header"> <div slot="header" class="time-range-header">
<span class="card-title"> <span class="card-title"> </span>
<el-button-group class="ems-btns-group">
<el-button v-for="(item,index) in btnList" :key="index+'dcdqxBtns'" size="mini" :class="{'activeBtn' : activeBtn === item.id}" @click="changeDataType(item.id)">{{item.name}}</el-button>
</el-button-group>
</span>
<date-range-select ref="dateRangeSelect" @updateDate="updateDate" /> <date-range-select ref="dateRangeSelect" @updateDate="updateDate" />
</div> </div>
<div class="card-main" v-loading="loading"> <div class="card-main" v-loading="loading">
<div id="dcdEchart" style="height: 310px;"></div> <el-button-group class="ems-btns-group">
<el-button
v-for="(item, index) in btnList"
:key="index + 'dcdqxBtns'"
size="mini"
:class="{ activeBtn: activeBtn === item.id }"
@click="changeDataType(item.id)"
>{{ item.name }}</el-button
>
</el-button-group>
<div id="dcdEchart" style="height: 310px"></div>
</div> </div>
</el-card> </el-card>
</template> </template>
<script> <script>
import * as echarts from 'echarts' import * as echarts from "echarts";
import resize from "@/mixins/ems/resize"; import resize from "@/mixins/ems/resize";
import getQuerySiteId from "@/mixins/ems/getQuerySiteId"; import getQuerySiteId from "@/mixins/ems/getQuerySiteId";
import { getStackData, getStackNameList} from '@/api/ems/dzjk' import { getStackData, getStackNameList } from "@/api/ems/dzjk";
import { formatDate } from "@/filters/ems"; import { formatDate } from "@/filters/ems";
import DateRangeSelect from "@/components/Ems/DateRangeSelect/index.vue"; import DateRangeSelect from "@/components/Ems/DateRangeSelect/index.vue";
export default { export default {
name:'DzjkTjbbDcdqx', name: "DzjkTjbbDcdqx",
components: { DateRangeSelect }, components: { DateRangeSelect },
mixins: [resize, getQuerySiteId], mixins: [resize, getQuerySiteId],
data() { data() {
@ -34,53 +44,69 @@ export default {
}, },
dateRange: [], dateRange: [],
loading: false, loading: false,
activeBtn:'1', activeBtn: "1",
btnList: [ btnList: [
{name:'堆平均维度',id:'1',attr:['temp'],source:['有功功率']}, { name: "堆平均维度", id: "1", attr: ["temp"], source: ["有功功率"] },
{name:'堆电压',id:'2',attr:['voltage'],source:['堆电压']}, { name: "堆电压", id: "2", attr: ["voltage"], source: ["堆电压"] },
{name:'堆电流',id:'3',attr:['current'],source:['堆电流']}, { name: "堆电流", id: "3", attr: ["current"], source: ["堆电流"] },
{name:'堆soc',id:'4',attr:['soc'],source:['堆soc']}, { name: "堆soc", id: "4", attr: ["soc"], source: ["堆soc"] },
], ],
} };
}, },
methods: { methods: {
changeDataType(id) { changeDataType(id) {
if (id !== this.activeBtn) { if (id !== this.activeBtn) {
this.activeBtn = id; this.activeBtn = id;
this.getData() this.getData();
} }
}, },
// 更新时间范围 重置图表 // 更新时间范围 重置图表
updateDate(data) { updateDate(data) {
this.dateRange=data || [] this.dateRange = data || [];
this.getData() this.getData();
}, },
getData() { getData() {
const { siteId, activeBtn } = this; const { siteId, activeBtn } = this;
const [start='',end='']=(this.dateRange || []) const [start = "", end = ""] = this.dateRange || [];
//接口调用完成之后 设置图表、结束loading //接口调用完成之后 设置图表、结束loading
this.loading = true; this.loading = true;
getStackData({siteId,startTime:formatDate(start),endTime:formatDate(end),dataType:activeBtn}).then(response => { getStackData({
this.setOption(response?.data || []) siteId,
}).finally(()=>{this.loading=false;}) startTime: formatDate(start),
endTime: formatDate(end),
dataType: activeBtn,
})
.then((response) => {
this.setOption(response?.data || []);
})
.finally(() => {
this.loading = false;
});
}, },
compareDate(date1, date2) { compareDate(date1, date2) {
console.log('比较时间',date1,date2) console.log("比较时间", date1, date2);
// 年2025-09/天2025-09-15/时2025-09-15/10:00 // 年2025-09/天2025-09-15/时2025-09-15/10:00
if(date1.indexOf(':') > -1 && date2.indexOf(':') > -1){ if (date1.indexOf(":") > -1 && date2.indexOf(":") > -1) {
return parseInt(date1) - parseInt(date2) return parseInt(date1) - parseInt(date2);
} }
const [date1_Y='',date1_M='',date1_D=''] = date1.split('-')//根据空格区分[年月日,小时] const [date1_Y = "", date1_M = "", date1_D = ""] = date1.split("-"); //根据空格区分[年月日,小时]
const [date2_Y='',date2_M='',date2_D=''] = date2.split('-')//根据空格区分[年月日,小时] const [date2_Y = "", date2_M = "", date2_D = ""] = date2.split("-"); //根据空格区分[年月日,小时]
return (date1_Y === date2_Y && date1_M === date2_M && date1_D - date2_D) || (date1_Y === date2_Y && date1_M - date2_M) || date1_Y - date2_Y return (
(date1_Y === date2_Y && date1_M === date2_M && date1_D - date2_D) ||
(date1_Y === date2_Y && date1_M - date2_M) ||
date1_Y - date2_Y
);
}, },
setOption(data) { setOption(data) {
const ele = this.btnList.find((item)=>{return item.id === this.activeBtn}) const ele = this.btnList.find((item) => {
const sourceBase = JSON.parse(JSON.stringify(ele.source)) return item.id === this.activeBtn;
});
const sourceBase = JSON.parse(JSON.stringify(ele.source));
// sourceBase={name:'堆平均维度',id:'1',attr:['temp'],source:['有功功率']}, // sourceBase={name:'堆平均维度',id:'1',attr:['temp'],source:['有功功率']},
const source=[] const source = [];
const sourceTop = ['日期'] const sourceTop = ["日期"];
let map={},mapArr=[] let map = {},
mapArr = [];
// 生成所有{日期:[],日期:[]}格式的对象和所有包含所有日期的[日期1,日期2...] // 生成所有{日期:[],日期:[]}格式的对象和所有包含所有日期的[日期1,日期2...]
data.forEach((item) => { data.forEach((item) => {
item.dataList.forEach((inner) => { item.dataList.forEach((inner) => {
@ -88,78 +114,78 @@ export default {
// 年2025-09/天2025-09-15/时2025-09-15/10:00 // 年2025-09/天2025-09-15/时2025-09-15/10:00
// 所有数据的日期格式一致 // 所有数据的日期格式一致
if (!map[inner.statisDate]) { if (!map[inner.statisDate]) {
map[inner.statisDate] = [] map[inner.statisDate] = [];
mapArr.push(inner.statisDate) mapArr.push(inner.statisDate);
} }
}) });
}) });
data.forEach((item, itemIndex) => { data.forEach((item, itemIndex) => {
const dataTimeList = item.dataList.map(i =>i.statisDate) const dataTimeList = item.dataList.map((i) => i.statisDate);
const noDataTime = mapArr.filter(i=>!dataTimeList.includes(i)) const noDataTime = mapArr.filter((i) => !dataTimeList.includes(i));
sourceBase.forEach((outer, outerIndex) => { sourceBase.forEach((outer, outerIndex) => {
sourceTop.push(`${item.deviceId}-${outer}`) sourceTop.push(`${item.deviceId}-${outer}`);
noDataTime.forEach(i=>map[i].push('')) noDataTime.forEach((i) => map[i].push(""));
item.dataList.forEach((inner, innerIndex) => { item.dataList.forEach((inner, innerIndex) => {
map[inner.statisDate].push(inner[ele.attr[outerIndex]]) map[inner.statisDate].push(inner[ele.attr[outerIndex]]);
}) });
}) });
}) });
mapArr = mapArr.sort((a,b)=>this.compareDate(a,b)) mapArr = mapArr.sort((a, b) => this.compareDate(a, b));
mapArr.forEach(item=>{ mapArr.forEach((item) => {
source.push([item,...map[item]]) source.push([item, ...map[item]]);
}) });
source.unshift(sourceTop) source.unshift(sourceTop);
console.log('map=',map) this.chart.setOption(
console.log('mapArr=',mapArr) {
console.log('========',source)
this.chart.setOption({
grid: { grid: {
containLabel: true containLabel: true,
}, },
legend: { legend: {
left: 'center', left: "center",
bottom: '15', bottom: "15",
}, },
tooltip: { tooltip: {
trigger: 'axis', trigger: "axis",
axisPointer: { // 坐标轴指示器,坐标轴触发有效 axisPointer: {
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow' // 坐标轴指示器,坐标轴触发有效
} type: "shadow", // 默认为直线,可选为:'line' | 'shadow'
},
}, },
textStyle: { textStyle: {
color: "#333333", color: "#333333",
}, },
xAxis: { xAxis: {
type: 'category', type: "category",
}, },
yAxis: { yAxis: {
type: 'value', type: "value",
}, },
dataset: { source }, dataset: { source },
series:source[0].slice(1).map(item=>{ series: source[0].slice(1).map((item) => {
return { return {
type:ele.type || 'scatter' type: "line",
} };
}) }),
},true) },
true
);
}, },
initChart() { initChart() {
this.chart = echarts.init(document.querySelector('#dcdEchart')); this.chart = echarts.init(document.querySelector("#dcdEchart"));
}, },
init() { init() {
this.$nextTick(() => { this.$nextTick(() => {
this.initChart() this.initChart();
this.$refs.dateRangeSelect.init() this.$refs.dateRangeSelect.init();
}) });
} },
}, },
beforeDestroy() { beforeDestroy() {
if (!this.chart) { if (!this.chart) {
return return;
} }
this.chart.dispose() this.chart.dispose();
this.chart = null this.chart = null;
}, },
} };
</script> </script>

View File

@ -1,26 +1,32 @@
<template> <template>
<el-card shadow="always" class="common-card-container time-range-card" style="margin-top:20px"> <el-card
shadow="always"
class="common-card-container time-range-card"
style="margin-top: 20px"
>
<div slot="header" class="time-range-header"> <div slot="header" class="time-range-header">
<span class="card-title">功率曲线</span> <span class="card-title">功率曲线</span>
<date-range-select ref="dateRangeSelect" @reset="resetTime" @updateDate="updateDate"/> <date-range-select
ref="dateRangeSelect"
@reset="resetTime"
@updateDate="updateDate"
/>
</div> </div>
<div class="card-main" v-loading="loading"> <div class="card-main" v-loading="loading">
<div id="glqxEchart" style="height: 310px;"></div> <div id="glqxEchart" style="height: 310px"></div>
</div> </div>
</el-card> </el-card>
</template> </template>
<script> <script>
import * as echarts from 'echarts' import * as echarts from "echarts";
import resize from "@/mixins/ems/resize"; import resize from "@/mixins/ems/resize";
import getQuerySiteId from "@/mixins/ems/getQuerySiteId"; import getQuerySiteId from "@/mixins/ems/getQuerySiteId";
import { getPcsNameList, getPowerData } from "@/api/ems/dzjk"; import { getPcsNameList, getPowerData } from "@/api/ems/dzjk";
import { formatDate } from "@/filters/ems"; import { formatDate } from "@/filters/ems";
import DateRangeSelect from "@/components/Ems/DateRangeSelect/index.vue"; import DateRangeSelect from "@/components/Ems/DateRangeSelect/index.vue";
export default { export default {
name:'DzjkTjbbGlqx', name: "DzjkTjbbGlqx",
components: { DateRangeSelect }, components: { DateRangeSelect },
mixins: [resize, getQuerySiteId], mixins: [resize, getQuerySiteId],
data() { data() {
@ -33,96 +39,113 @@ export default {
dateRange: [], dateRange: [],
loading: false, loading: false,
dateRangeInit: true, dateRangeInit: true,
} };
}, },
methods: { methods: {
// 更新时间范围 重置图表 // 更新时间范围 重置图表
updateDate(data) { updateDate(data) {
this.dateRange=data || [] this.dateRange = data || [];
this.getData() this.getData();
}, },
resetTime() { resetTime() {
this.dateRangeInit = true; this.dateRangeInit = true;
}, },
getData() { getData() {
const { siteId } = this; const { siteId } = this;
let [start='',end='']=(this.dateRange || []) let [start = "", end = ""] = this.dateRange || [];
//接口调用完成之后 设置图表、结束loading //接口调用完成之后 设置图表、结束loading
this.loading = true; this.loading = true;
if (this.dateRangeInit) { if (this.dateRangeInit) {
start = '' start = "";
end = '' end = "";
this.dateRangeInit=false this.dateRangeInit = false;
} }
getPowerData({siteId,startDate:formatDate(start),endDate:formatDate(end)}).then(response => { getPowerData({
this.setOption(response?.data || []) siteId,
}).finally(()=>{this.loading=false;}) startDate: formatDate(start),
endDate: formatDate(end),
})
.then((response) => {
this.setOption(response?.data || []);
})
.finally(() => {
this.loading = false;
});
}, },
setOption(data) { setOption(data) {
const source = [['日期','电网功率','负载功率','储能功率','光伏功率']] const source = [["日期", "电网功率", "负载功率", "储能功率", "光伏功率"]];
data.forEach(item=>{ data.forEach((item) => {
source.push([item.statisDate,item.gridPower,item.loadPower,item.storagePower,item.pvPower]) source.push([
}) item.statisDate,
this.chart.setOption({ item.gridPower,
item.loadPower,
item.storagePower,
item.pvPower,
]);
});
this.chart.setOption(
{
grid: { grid: {
containLabel: true containLabel: true,
}, },
legend: { legend: {
left: 'center', left: "center",
bottom: '15', bottom: "15",
}, },
tooltip: { tooltip: {
trigger: 'axis', trigger: "axis",
axisPointer: { // 坐标轴指示器,坐标轴触发有效 axisPointer: {
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow' // 坐标轴指示器,坐标轴触发有效
} type: "shadow", // 默认为直线,可选为:'line' | 'shadow'
},
}, },
textStyle: { textStyle: {
color: "#333333", color: "#333333",
}, },
xAxis: { xAxis: {
type: 'category', type: "category",
}, },
yAxis: { yAxis: {
type: 'value', type: "value",
}, },
dataset: { source }, dataset: { source },
series: [ series: [
{ {
type: 'scatter', type: "line",
}, },
{ {
type: 'scatter', type: "line",
}, },
{ {
type: 'scatter', type: "line",
}, },
{ {
type: 'scatter', type: "line",
} },
] ],
},true) },
true
);
}, },
initChart() { initChart() {
if(this.chart) return if (this.chart) return;
this.chart = echarts.init(document.querySelector('#glqxEchart')); this.chart = echarts.init(document.querySelector("#glqxEchart"));
}, },
init() { init() {
this.$nextTick(() => { this.$nextTick(() => {
this.dateRangeInit = true; this.dateRangeInit = true;
this.initChart() this.initChart();
this.$refs.dateRangeSelect.init() this.$refs.dateRangeSelect.init();
}) });
} },
}, },
beforeDestroy() { beforeDestroy() {
if (!this.chart) { if (!this.chart) {
return return;
} }
this.chart.dispose() this.chart.dispose();
this.chart = null this.chart = null;
}, },
} };
</script> </script>

View File

@ -1,29 +1,38 @@
<template> <template>
<el-card shadow="always" class="common-card-container time-range-card" style="margin-top:20px"> <el-card
shadow="always"
class="common-card-container time-range-card"
style="margin-top: 20px"
>
<div slot="header" class="time-range-header"> <div slot="header" class="time-range-header">
<span class="card-title"> <span class="card-title"> </span>
<el-button-group class="ems-btns-group">
<el-button v-for="(item,index) in btnList" :key="index+'flqxcBtns'" size="mini" :class="{'activeBtn' : activeBtn === item.id}" @click="changeDataType(item.id)">{{item.name}}</el-button>
</el-button-group>
</span>
<date-range-select ref="dateRangeSelect" @updateDate="updateDate" /> <date-range-select ref="dateRangeSelect" @updateDate="updateDate" />
</div> </div>
<div class="card-main" v-loading="loading"> <div class="card-main" v-loading="loading">
<div id="pcsEchart" style="height: 310px;"></div> <el-button-group class="ems-btns-group">
<el-button
v-for="(item, index) in btnList"
:key="index + 'flqxcBtns'"
size="mini"
:class="{ activeBtn: activeBtn === item.id }"
@click="changeDataType(item.id)"
>{{ item.name }}</el-button
>
</el-button-group>
<div id="pcsEchart" style="height: 310px"></div>
</div> </div>
</el-card> </el-card>
</template> </template>
<script> <script>
import * as echarts from 'echarts' import * as echarts from "echarts";
import resize from "@/mixins/ems/resize"; import resize from "@/mixins/ems/resize";
import getQuerySiteId from "@/mixins/ems/getQuerySiteId"; import getQuerySiteId from "@/mixins/ems/getQuerySiteId";
import { getPCSData, getPcsNameList} from '@/api/ems/dzjk' import { getPCSData, getPcsNameList } from "@/api/ems/dzjk";
import { formatDate } from "@/filters/ems"; import { formatDate } from "@/filters/ems";
import DateRangeSelect from "@/components/Ems/DateRangeSelect/index.vue"; import DateRangeSelect from "@/components/Ems/DateRangeSelect/index.vue";
export default { export default {
name:'DzjkTjbbPcsqx', name: "DzjkTjbbPcsqx",
components: { DateRangeSelect }, components: { DateRangeSelect },
mixins: [resize, getQuerySiteId], mixins: [resize, getQuerySiteId],
data() { data() {
@ -35,54 +44,85 @@ export default {
}, },
dateRange: [], dateRange: [],
loading: false, loading: false,
activeBtn:'1', activeBtn: "1",
btnList: [ btnList: [
{name:'有功功率',id:'1',attr:['activePower'],source:['有功功率']}, {
{name:'无功功率',id:'2',attr:['reactivePower'],source:['无功功率']}, name: "有功功率",
{name:'三相电流',id:'3',attr:['uCurrent','vCurrent','wCurrent'],source:['u电流','v电流','w电流'],type:'bar'}, id: "1",
attr: ["activePower"],
source: ["有功功率"],
},
{
name: "无功功率",
id: "2",
attr: ["reactivePower"],
source: ["无功功率"],
},
{
name: "三相电流",
id: "3",
attr: ["uCurrent", "vCurrent", "wCurrent"],
source: ["u电流", "v电流", "w电流"],
type: "bar",
},
], ],
};
}
}, },
methods: { methods: {
changeDataType(id) { changeDataType(id) {
if (id !== this.activeBtn) { if (id !== this.activeBtn) {
console.log('点击了不同的菜单,更新数据') console.log("点击了不同的菜单,更新数据");
this.activeBtn = id; this.activeBtn = id;
this.getData() this.getData();
} }
}, },
// 更新时间范围 重置图表 // 更新时间范围 重置图表
updateDate(data) { updateDate(data) {
this.dateRange=data || [] this.dateRange = data || [];
this.getData() this.getData();
}, },
getData() { getData() {
const { siteId, activeBtn } = this; const { siteId, activeBtn } = this;
const [start='',end='']=(this.dateRange || []) const [start = "", end = ""] = this.dateRange || [];
this.loading = true; this.loading = true;
//接口调用完成之后 设置图表、结束loading //接口调用完成之后 设置图表、结束loading
getPCSData({siteId,startTime:formatDate(start),endTime:formatDate(end),dataType:activeBtn}).then(response => { getPCSData({
this.setOption(response?.data || []) siteId,
}).finally(()=>{this.loading=false;}) startTime: formatDate(start),
endTime: formatDate(end),
dataType: activeBtn,
})
.then((response) => {
this.setOption(response?.data || []);
})
.finally(() => {
this.loading = false;
});
}, },
compareDate(date1, date2) { compareDate(date1, date2) {
console.log('比较时间',date1,date2) console.log("比较时间", date1, date2);
// 年2025-09/天2025-09-15/时2025-09-15/10:00 // 年2025-09/天2025-09-15/时2025-09-15/10:00
if(date1.indexOf(':') > -1 && date2.indexOf(':') > -1){ if (date1.indexOf(":") > -1 && date2.indexOf(":") > -1) {
return parseInt(date1) - parseInt(date2) return parseInt(date1) - parseInt(date2);
} }
const [date1_Y='',date1_M='',date1_D=''] = date1.split('-')//根据空格区分[年月日,小时] const [date1_Y = "", date1_M = "", date1_D = ""] = date1.split("-"); //根据空格区分[年月日,小时]
const [date2_Y='',date2_M='',date2_D=''] = date2.split('-')//根据空格区分[年月日,小时] const [date2_Y = "", date2_M = "", date2_D = ""] = date2.split("-"); //根据空格区分[年月日,小时]
return (date1_Y === date2_Y && date1_M === date2_M && date1_D - date2_D) || (date1_Y === date2_Y && date1_M - date2_M) || date1_Y - date2_Y return (
(date1_Y === date2_Y && date1_M === date2_M && date1_D - date2_D) ||
(date1_Y === date2_Y && date1_M - date2_M) ||
date1_Y - date2_Y
);
}, },
setOption(data) { setOption(data) {
const ele = this.btnList.find((item)=>{return item.id === this.activeBtn}) const ele = this.btnList.find((item) => {
const sourceBase = JSON.parse(JSON.stringify(ele.source)) return item.id === this.activeBtn;
});
const sourceBase = JSON.parse(JSON.stringify(ele.source));
// sourceBase={name:'堆平均维度',id:'1',attr:['temp'],source:['有功功率']}, // sourceBase={name:'堆平均维度',id:'1',attr:['temp'],source:['有功功率']},
const source=[] const source = [];
const sourceTop = ['日期'] const sourceTop = ["日期"];
let map={},mapArr=[] let map = {},
mapArr = [];
// 生成所有{日期:[],日期:[]}格式的对象和所有包含所有日期的[日期1,日期2...] // 生成所有{日期:[],日期:[]}格式的对象和所有包含所有日期的[日期1,日期2...]
data.forEach((item) => { data.forEach((item) => {
item.dataList.forEach((inner) => { item.dataList.forEach((inner) => {
@ -90,78 +130,78 @@ export default {
// 年2025-09/天2025-09-15/时2025-09-15/10:00 // 年2025-09/天2025-09-15/时2025-09-15/10:00
// 所有数据的日期格式一致 // 所有数据的日期格式一致
if (!map[inner.statisDate]) { if (!map[inner.statisDate]) {
map[inner.statisDate] = [] map[inner.statisDate] = [];
mapArr.push(inner.statisDate) mapArr.push(inner.statisDate);
} }
}) });
}) });
data.forEach((item, itemIndex) => { data.forEach((item, itemIndex) => {
const dataTimeList = item.dataList.map(i =>i.statisDate) const dataTimeList = item.dataList.map((i) => i.statisDate);
const noDataTime = mapArr.filter(i=>!dataTimeList.includes(i)) const noDataTime = mapArr.filter((i) => !dataTimeList.includes(i));
sourceBase.forEach((outer, outerIndex) => { sourceBase.forEach((outer, outerIndex) => {
sourceTop.push(`${item.deviceId}-${outer}`) sourceTop.push(`${item.deviceId}-${outer}`);
noDataTime.forEach(i=>map[i].push('')) noDataTime.forEach((i) => map[i].push(""));
item.dataList.forEach((inner, innerIndex) => { item.dataList.forEach((inner, innerIndex) => {
map[inner.statisDate].push(inner[ele.attr[outerIndex]]) map[inner.statisDate].push(inner[ele.attr[outerIndex]]);
}) });
}) });
}) });
mapArr = mapArr.sort((a,b)=>this.compareDate(a,b)) mapArr = mapArr.sort((a, b) => this.compareDate(a, b));
mapArr.forEach(item=>{ mapArr.forEach((item) => {
source.push([item,...map[item]]) source.push([item, ...map[item]]);
}) });
source.unshift(sourceTop) source.unshift(sourceTop);
console.log('map=',map) this.chart.setOption(
console.log('mapArr=',mapArr) {
console.log('========',source)
this.chart.setOption({
grid: { grid: {
containLabel: true containLabel: true,
}, },
legend: { legend: {
left: 'center', left: "center",
bottom: '15', bottom: "15",
}, },
tooltip: { tooltip: {
trigger: 'axis', trigger: "axis",
axisPointer: { // 坐标轴指示器,坐标轴触发有效 axisPointer: {
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow' // 坐标轴指示器,坐标轴触发有效
} type: "shadow", // 默认为直线,可选为:'line' | 'shadow'
},
}, },
textStyle: { textStyle: {
color: "#333333", color: "#333333",
}, },
xAxis: { xAxis: {
type: 'category', type: "category",
}, },
yAxis: { yAxis: {
type: 'value', type: "value",
}, },
dataset: { source }, dataset: { source },
series:source[0].slice(1).map(item=>{ series: source[0].slice(1).map((item) => {
return { return {
type:ele.type || 'scatter' type: "line",
} };
}) }),
},
},true) true
);
}, },
initChart() { initChart() {
this.chart = echarts.init(document.querySelector('#pcsEchart')); this.chart = echarts.init(document.querySelector("#pcsEchart"));
}, },
init() { init() {
this.$nextTick(() => { this.$nextTick(() => {
this.initChart() this.initChart();
this.$refs.dateRangeSelect.init() this.$refs.dateRangeSelect.init();
}) });
} },
}, },
beforeDestroy() { beforeDestroy() {
if (!this.chart) { if (!this.chart) {
return return;
} }
this.chart.dispose() this.chart.dispose();
this.chart = null this.chart = null;
}, },
} };
</script> </script>