堆叠图样式更新

qianming 3 years ago
parent bf6ff4355a
commit c36dbb8ba0

@ -96,11 +96,9 @@ export default {
this.setOptionsTitle();
this.setOptionsX();
this.setOptionsY();
this.setOptionsTop();
this.setOptionsTooltip();
this.setOptionsMargin();
this.setOptionsLegend();
this.setOptionsColor();
this.setOptionsData();
},
//
@ -195,25 +193,6 @@ export default {
};
this.options.yAxis = yAxis;
},
// or
setOptionsTop() {
const optionsCollapse = this.optionsSetup;
const series = this.options.series;
for (const key in series) {
if (series[key].type == "bar") {
series[key].label = {
show: optionsCollapse.isShow,
position: "top",
distance: 10,
fontSize: optionsCollapse.fontSize,
color: optionsCollapse.subTextColor,
fontWeight: optionsCollapse.fontWeight
};
series[key].barWidth = optionsCollapse.maxWidth;
}
}
this.options.series = series;
},
// tooltip
setOptionsTooltip() {
const optionsCollapse = this.optionsSetup;
@ -255,30 +234,6 @@ export default {
};
legend.itemWidth = optionsCollapse.lengedWidth;
},
//
setOptionsColor() {
const optionsCollapse = this.optionsSetup;
const customColor = optionsCollapse.customColor;
if (!customColor) return;
const arrColor = [];
for (let i = 0; i < customColor.length; i++) {
arrColor.push(customColor[i].color);
}
const itemStyle = {
normal: {
color: params => {
return arrColor[params.dataIndex];
},
barBorderRadius : optionsCollapse.radius
},
};
for (const key in this.options.series) {
if (this.options.series[key].type == "bar") {
this.options.series[key].itemStyle = itemStyle;
}
}
this.options = Object.assign({}, this.options);
},
//
setOptionsData() {
const optionsSetup = this.optionsSetup;
@ -394,6 +349,12 @@ export default {
});
},
renderingFn(optionsSetup, val) {
//
const customColor = optionsSetup.customColor;
const arrColor = [];
for (let i = 0; i < customColor.length; i++) {
arrColor.push(customColor[i].color);
}
// x
if (optionsSetup.verticalShow) {
this.options.xAxis.data = [];
@ -406,14 +367,35 @@ export default {
this.options.xAxis.type = "category";
this.options.yAxis.type = "value";
}
const series = this.options.series;
for (const i in series) {
if (series[i].type == "bar") {
series[i].name = val.series[i].name;
series[i].data = val.series[i].data;
const series = [];
for (const i in val.series) {
if (val.series[i].type == "bar") {
series.push({
name: val.series[i].name,
type: "bar",
data: val.series[i].data,
barGap: "0%",
stack: this.getStackStyle(),
barWidth: optionsSetup.maxWidth,
label: {
show: optionsSetup.isShow,
position: "top",
distance: 10,
fontSize: optionsSetup.fontSize,
color: optionsSetup.subTextColor,
fontWeight: optionsSetup.fontWeight
},
//
itemStyle: {
normal : {
color: arrColor[i],
barBorderRadius : optionsSetup.radius,
}
}
})
}
}
this.options.series = series
}
}
};

Loading…
Cancel
Save