|
|
|
@ -167,6 +167,7 @@ export default {
|
|
|
|
|
this.setOptionsX();
|
|
|
|
|
this.setOptionsY();
|
|
|
|
|
this.setOptionsTop();
|
|
|
|
|
this.setOptionsLegend();
|
|
|
|
|
this.setOptionsMargin();
|
|
|
|
|
this.setOptionsColor();
|
|
|
|
|
this.setOptionsData();
|
|
|
|
@ -323,11 +324,11 @@ export default {
|
|
|
|
|
const optionsSetup = this.optionsSetup;
|
|
|
|
|
const legend = this.options.legend;
|
|
|
|
|
legend.show = optionsSetup.isShowLegend;
|
|
|
|
|
legend.left = optionsSetup.lateralPosition == "left" ? 0 : "auto";
|
|
|
|
|
legend.right = optionsSetup.lateralPosition == "right" ? 0 : "auto";
|
|
|
|
|
legend.top = optionsSetup.longitudinalPosition == "top" ? 0 : "auto";
|
|
|
|
|
legend.left = optionsSetup.lateralPosition;
|
|
|
|
|
legend.right = optionsSetup.lateralPosition;
|
|
|
|
|
legend.top = optionsSetup.longitudinalPosition;
|
|
|
|
|
legend.bottom =
|
|
|
|
|
optionsSetup.longitudinalPosition == "bottom" ? 0 : "auto";
|
|
|
|
|
optionsSetup.longitudinalPosition;
|
|
|
|
|
legend.orient = optionsSetup.layoutFront;
|
|
|
|
|
legend.textStyle = {
|
|
|
|
|
color: optionsSetup.lengedColor,
|
|
|
|
@ -335,6 +336,25 @@ export default {
|
|
|
|
|
};
|
|
|
|
|
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() {
|
|
|
|
|
const optionsSetup = this.optionsSetup;
|
|
|
|
@ -416,6 +436,10 @@ export default {
|
|
|
|
|
if (series[0].type == "bar") {
|
|
|
|
|
series[0].data = data;
|
|
|
|
|
}
|
|
|
|
|
const legendName = [];
|
|
|
|
|
legendName.push('销售量')
|
|
|
|
|
this.options.legend['data'] = legendName;
|
|
|
|
|
this.setOptionsLegendName(legendName);
|
|
|
|
|
},
|
|
|
|
|
// 动态数据
|
|
|
|
|
dynamicDataFn(val, refreshTime, optionsSetup) {
|
|
|
|
@ -451,11 +475,16 @@ export default {
|
|
|
|
|
|
|
|
|
|
// series
|
|
|
|
|
const series = this.options.series;
|
|
|
|
|
const legendName = [];
|
|
|
|
|
for (const i in series) {
|
|
|
|
|
if (series[i].type == "bar") {
|
|
|
|
|
series[i].name = val.series[i].name;
|
|
|
|
|
series[i].data = val.series[i].data;
|
|
|
|
|
}
|
|
|
|
|
legendName.push(val.series[i].name);
|
|
|
|
|
}
|
|
|
|
|
this.options.legend['data'] = legendName;
|
|
|
|
|
this.setOptionsLegendName(legendName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|