|
|
@ -249,9 +249,9 @@ export default {
|
|
|
|
const legend = this.options.legend;
|
|
|
|
const legend = this.options.legend;
|
|
|
|
legend.show = optionsSetup.isShowLegend;
|
|
|
|
legend.show = optionsSetup.isShowLegend;
|
|
|
|
legend.left = optionsSetup.lateralPosition;
|
|
|
|
legend.left = optionsSetup.lateralPosition;
|
|
|
|
legend.top = optionsSetup.longitudinalPosition == "top" ? 0 : "auto";
|
|
|
|
legend.top = optionsSetup.longitudinalPosition;
|
|
|
|
legend.bottom =
|
|
|
|
legend.bottom =
|
|
|
|
optionsSetup.longitudinalPosition == "bottom" ? 0 : "auto";
|
|
|
|
optionsSetup.longitudinalPosition;
|
|
|
|
legend.orient = optionsSetup.layoutFront;
|
|
|
|
legend.orient = optionsSetup.layoutFront;
|
|
|
|
legend.textStyle = {
|
|
|
|
legend.textStyle = {
|
|
|
|
color: optionsSetup.lengedColor,
|
|
|
|
color: optionsSetup.lengedColor,
|
|
|
@ -259,6 +259,25 @@ export default {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
legend.itemWidth = optionsSetup.lengedWidth;
|
|
|
|
legend.itemWidth = optionsSetup.lengedWidth;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// 图例名称设置
|
|
|
|
|
|
|
|
setOptionsLegendName(name){
|
|
|
|
|
|
|
|
const optionsSetup = this.optionsSetup;
|
|
|
|
|
|
|
|
const series = this.options.series;
|
|
|
|
|
|
|
|
const legendName = optionsSetup.legendName;
|
|
|
|
|
|
|
|
// 图例没有手动写则显示原值,写了则显示新值
|
|
|
|
|
|
|
|
if (null == legendName || legendName == '') {
|
|
|
|
|
|
|
|
for (let i = 0; i < name.length; i++) {
|
|
|
|
|
|
|
|
series[i].name = name[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.options.legend['data'] = name;
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
const arr = legendName.split('|');
|
|
|
|
|
|
|
|
for (let i = 0; i < arr.length; i++) {
|
|
|
|
|
|
|
|
series[i].name = arr[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.options.legend['data'] = arr
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
// 图例颜色修改
|
|
|
|
// 图例颜色修改
|
|
|
|
setOptionsColor() {
|
|
|
|
setOptionsColor() {
|
|
|
|
const optionsCollapse = this.optionsSetup;
|
|
|
|
const optionsCollapse = this.optionsSetup;
|
|
|
@ -303,21 +322,22 @@ export default {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//数据
|
|
|
|
//数据
|
|
|
|
const series = [];
|
|
|
|
const series = [];
|
|
|
|
let xAxisList = []
|
|
|
|
let xAxisList = [];
|
|
|
|
let yAxisList = []
|
|
|
|
let yAxisList = [];
|
|
|
|
|
|
|
|
const legendName = [];
|
|
|
|
for (const i in val) {
|
|
|
|
for (const i in val) {
|
|
|
|
xAxisList[i] = val[i].axis
|
|
|
|
xAxisList[i] = val[i].axis;
|
|
|
|
yAxisList[i] = val[i].name
|
|
|
|
yAxisList[i] = val[i].name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xAxisList = this.setUnique(xAxisList)
|
|
|
|
xAxisList = this.setUnique(xAxisList);
|
|
|
|
yAxisList = this.setUnique(yAxisList)
|
|
|
|
yAxisList = this.setUnique(yAxisList);
|
|
|
|
for (const i in yAxisList) {
|
|
|
|
for (const i in yAxisList) {
|
|
|
|
const data = new Array(yAxisList.length).fill(0)
|
|
|
|
const data = new Array(yAxisList.length).fill(0);
|
|
|
|
for (const j in xAxisList) {
|
|
|
|
for (const j in xAxisList) {
|
|
|
|
for (const k in val) {
|
|
|
|
for (const k in val) {
|
|
|
|
if (val[k].name == yAxisList[i]) {
|
|
|
|
if (val[k].name == yAxisList[i]) {
|
|
|
|
if (val[k].axis == xAxisList[j]) {
|
|
|
|
if (val[k].axis == xAxisList[j]) {
|
|
|
|
data[j] = val[k].data
|
|
|
|
data[j] = val[k].data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -334,7 +354,7 @@ export default {
|
|
|
|
// 线条
|
|
|
|
// 线条
|
|
|
|
lineStyle: {
|
|
|
|
lineStyle: {
|
|
|
|
color: arrColor[i],
|
|
|
|
color: arrColor[i],
|
|
|
|
width: optionsSetup.lineWidth
|
|
|
|
width: optionsSetup.lineWidth,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
//点
|
|
|
|
//点
|
|
|
|
itemStyle: {
|
|
|
|
itemStyle: {
|
|
|
@ -348,11 +368,12 @@ export default {
|
|
|
|
distance: 10,
|
|
|
|
distance: 10,
|
|
|
|
fontSize: optionsSetup.fontSize,
|
|
|
|
fontSize: optionsSetup.fontSize,
|
|
|
|
color: optionsSetup.subTextColor,
|
|
|
|
color: optionsSetup.subTextColor,
|
|
|
|
fontWeight: optionsSetup.fontWeight
|
|
|
|
fontWeight: optionsSetup.fontWeight,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
legendName.push(yAxisList[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.options.series = series
|
|
|
|
this.options.series = series;
|
|
|
|
if (optionsSetup.verticalShow) {
|
|
|
|
if (optionsSetup.verticalShow) {
|
|
|
|
this.options.xAxis.data = [];
|
|
|
|
this.options.xAxis.data = [];
|
|
|
|
this.options.yAxis.data = xAxisList;
|
|
|
|
this.options.yAxis.data = xAxisList;
|
|
|
@ -364,6 +385,8 @@ export default {
|
|
|
|
this.options.xAxis.type = "category";
|
|
|
|
this.options.xAxis.type = "category";
|
|
|
|
this.options.yAxis.type = "value";
|
|
|
|
this.options.yAxis.type = "value";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.options.legend['data'] = legendName;
|
|
|
|
|
|
|
|
this.setOptionsLegendName(legendName);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// 动态数据
|
|
|
|
// 动态数据
|
|
|
|
dynamicDataFn(val, refreshTime, optionsSetup) {
|
|
|
|
dynamicDataFn(val, refreshTime, optionsSetup) {
|
|
|
@ -403,6 +426,7 @@ export default {
|
|
|
|
this.options.yAxis.type = "value";
|
|
|
|
this.options.yAxis.type = "value";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const series = [];
|
|
|
|
const series = [];
|
|
|
|
|
|
|
|
const legendName = [];
|
|
|
|
for (const i in val.series) {
|
|
|
|
for (const i in val.series) {
|
|
|
|
if (val.series[i].type == "line") {
|
|
|
|
if (val.series[i].type == "line") {
|
|
|
|
series.push({
|
|
|
|
series.push({
|
|
|
@ -418,7 +442,7 @@ export default {
|
|
|
|
// 线条
|
|
|
|
// 线条
|
|
|
|
lineStyle: {
|
|
|
|
lineStyle: {
|
|
|
|
color: arrColor[i],
|
|
|
|
color: arrColor[i],
|
|
|
|
width: optionsSetup.lineWidth
|
|
|
|
width: optionsSetup.lineWidth,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
//点
|
|
|
|
//点
|
|
|
|
itemStyle: {
|
|
|
|
itemStyle: {
|
|
|
@ -432,12 +456,15 @@ export default {
|
|
|
|
distance: 10,
|
|
|
|
distance: 10,
|
|
|
|
fontSize: optionsSetup.fontSize,
|
|
|
|
fontSize: optionsSetup.fontSize,
|
|
|
|
color: optionsSetup.subTextColor,
|
|
|
|
color: optionsSetup.subTextColor,
|
|
|
|
fontWeight: optionsSetup.fontWeight
|
|
|
|
fontWeight: optionsSetup.fontWeight,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
legendName.push(val.series[i].name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.options.series = series
|
|
|
|
this.options.series = series;
|
|
|
|
|
|
|
|
this.options.legend['data'] = legendName;
|
|
|
|
|
|
|
|
this.setOptionsLegendName(legendName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|