设置echarts曲线图颜色渐变,在series中配置areaStyle;设置Y轴单位显示,在yAxis中设置formatter
option = { xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value', axisLabel : { formatter: '{value} °C' //Y轴显示温度单位i } }, series: [{ data: [820, 932, 901, 934, 1290, 1330, 1320], type: 'line', areaStyle: {normal: { color: new echarts.graphic.LinearGradient( 0, 0, 0, 1, [ {offset: 0, color: 'red'}, {offset: 0.5, color: 'pink'}, {offset: 1, color: '#ddd'} ] ) }}, smooth: true }] };效果图如下: