分段绘制颜色点的连接处颜色混乱,而且分段越多越明显,有时甚至线段之前的颜色应该是红色结果却是蓝色
配置项如下
option = {
title: {
text: '一天用电量分布',
subtext: '纯属虚构'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross'
}
},
toolbox: {
show: true,
feature: {
saveAsImage: {}
}
},
xAxis: {
type: 'category',
boundaryGap: false,
data: ['00:00', '01:15', '02:30', '03:45', '05:00', '06:15', '07:30', '08:45', '10:00', '11:15', '12:30', '13:45', '15:00', '16:15', '17:30', '18:45', '20:00', '21:15', '22:30', '23:45']
},
yAxis: {
type: 'value',
axisLabel: {
formatter: '{value} W'
},
axisPointer: {
snap: true
}
},
visualMap: {
show: false,
dimension: 0,
pieces:[{
"lte": 0,
"color": "#4085e5"
}, {
"gt": 0,
"lte": 1,
"color": "red"
}, {
"gt": 1,
"lte": 2,
"color": "red"
}, {
"gt": 2,
"lte": 3,
"color": "red"
}, {
"gt": 3,
"lte": 4,
"color": "red"
}, {
"gt": 4,
"lte": 5,
"color": "red"
}, {
"gt": 5,
"lte": 7,
"color": "#4085e5"
}, {
"gt": 7,
"lte": 8,
"color": "red"
}, {
"gt": 8,
"lte": 10,
"color": "#4085e5"
}, {
"gt": 10,
"lte": 11,
"color": "red"
}, {
"gt": 11,
"lte": 12,
"color": "red"
}, {
"gt": 12,
"lte": 14,
"color": "#4085e5"
}, {
"gt": 14,
"lte": 16,
"color": "#4085e5"
}, {
"gt": 16,
"lte": 17,
"color": "red"
}, {
"gt": 17,
"lte": 18,
"color": "red"
}, {
"gt": 18,
"lte": 19,
"color": "red"
}, {
"gt": 19,
"lte": 21,
"color": "#4085e5"
}]
},
series: [
{
name:'用电量',
type:'line',
smooth: true,
data: [300, 280, 250, 260, 270, 300, 550, 500, 400, 390, 380, 390, 400, 500, 600, 750, 800, 700, 600, 400],
markArea: {
data: [ [{
name: '早高峰',
xAxis: '07:30'
}, {
xAxis: '10:00'
}], [{
name: '晚高峰',
xAxis: '17:30'
}, {
xAxis: '21:15'
}] ]
}
}
]
};