折线图:
series: [
{
type: 'line',
color: '#1da7ec',
// 圆弧线连接
symbol: 'none',
smooth: true,
stack: 'Total',
areaStyle: {},
emphasis: {
focus: 'series'
},
//渐变色
areaStyle: {
normal: {
//前四个参数代表位置 左下右上,如下表示从上往下渐变色 紫色到暗蓝色
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: '#33b0ee' },
{ offset: 1, color: '#afe1f8' }
])
}
},
data: [90, 70, 50, 50, 70, 90, 50, 60, 70, 80, 90, 20]
}
]
效果图:
如果要求多数据,就在series里面增加对应数据并设置对应渐变色就ok; 如果多数据但是只有重点数据有覆盖色,其余保持线条就把上面代码中的
stack: 'Total',
areaStyle: {},
emphasis: {
focus: 'series'
},
删除,就可以了。 效果图:
监听屏幕尺寸,然后重绘
var vehicle = echarts.init(document.getElementById("vehicle"));
window.addEventListener("resize",function (){
vehicle.resize();
});