趋势图柱状宽度等功能修改

This commit is contained in:
hey7845
2022-02-12 23:22:10 +08:00
parent 96059c7d94
commit b9ba66dcb2
5 changed files with 56 additions and 12 deletions

View File

@@ -256,23 +256,31 @@ export default {
yAxis: this.trendData.yAxis,
series: this.trendData.series
};
//添加一个新的刻度线 实现折线在柱状图的中间显示
// option.xAxis[1] = {
// type: 'value',
// max: option.xAxis[0].data.length,
// show: false
// };
let barArray = option.series.filter(item => item.type === 'bar')
if (barArray && barArray.length <= 6) {
barArray.forEach(item => {
item.barWidth = 80
if (barArray.length === 1) {
item.itemStyle = { color: '#9fe080' }
}
})
}
let lineArray = option.series.filter(item => item.type === 'line');
lineArray.forEach((item, index) => {
// item.xAxisIndex = 1;
console.log("item", item);
item.lineStyle = {
type: 'dashed'
type: 'dashed',
};
if (lineArray.length === 2) {
if (index === 0) {
item.lineStyle.color = '#e8cd6a'
} else {
item.lineStyle.color = '#5c7bd9'
}
}
if (index === 0) {
item.label.offset = [20,30]
}
// item.data = item.data.map((x, i) => [i + (1 / (option.legend.data.length + 1)) * (index + 1), x]);
});
console.log('option', option);
trendChart.setOption(option);