const stateData = { xAxisData: [2016, 2017, 2018, 2019, 2020], sgData: [10, 8, 30, 40, 5], bgData: [6, 70, 8, 90, 10] } option = { tooltip: {}, legend: { itemWidth: 7, itemHeight: 7, // itemGap: 15, icon: 'rect', // right: 0, textStyle: { fontSize: 14, fontFamily: 'PingFangSC, PingFang SC', fontWeight: 400 } }, xAxis: { type: 'category', boundaryGap: false, data: stateData.xAxisData, axisLabel: { fontSize: 14, fontFamily: 'PingFangSC, PingFang SC', fontWeight: 400 } }, yAxis: { type: 'value', name: '单位/件', nameTextStyle: { fontSize: 14, fontFamily: 'PingFangSC, PingFang SC', fontWeight: 400 }, axisLabel: { fontSize: 14, fontFamily: 'PingFangSC, PingFang SC', fontWeight: 400 } }, series: [ { name: '事故', data: stateData.sgData, type: 'line', smooth: true, itemStyle: { normal: { color: 'rgba(255, 116, 133, 1)', lineStyle: { color: 'rgba(255, 116, 133, 1)', width: 2 }, areaStyle: { color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [ { offset: 0, color: 'rgba(255, 116, 133, 0)' }, { offset: 1, color: 'rgba(255, 116, 133, 1)' } ]) } } }, }, { name: '报警', data: stateData.bgData, type: 'line', smooth: true, itemStyle: { normal: { color: 'rgba(95, 175, 255, 1)', lineStyle: { color: 'rgba(95, 175, 255, 1)', width: 2 }, areaStyle: { color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [ { offset: 0, color: 'rgba(95, 175, 255, 0)' }, { offset: 1, color: 'rgba(95, 175, 255, 1)' } ]) } } }, } ] }