實現如圖Echarts漸變折線圖的方式,提供兩種解決方案:
1.series組件屬性:
{
type: 'line',
name: "總收入",
lineStyle: {
normal: {
width: 3
},
},
itemStyle: {
"color": {
"type": "linear",
"x": 0,
"y": 0,
"x2": 0,
"y2": 1,
"colorStops": [
{
"offset": 0,
"color": "#2c86e1"
},
{
"offset": 0.5,
"color": "#d4f170"
},
{
"offset": 1,
"color": "#ff943c"
}
],
"globalCoord": false
}
},
smooth: true,
}
2.視覺映射組件:
visualMap: {
min: 0,
max: 300,
left: 'left',
top: 'bottom',
color: ["#2c86e1","#d4f170","#ff943c"],
calculable: true
},
必須注意series.data的取值範圍在min,max之間。
Done!