var liftMonthDtoList=[ {month:1,thisYear:30,lastYear:33}, {month:2,thisYear:32,lastYear:38}, {month:3,thisYear:31,lastYear:30}, {month:4,thisYear:30,lastYear:36}, ] var data=[],year=[],lastYear=[]; liftMonthDtoList.forEach((item) => { data.push(item.month + "月"); year.push(Number(item.thisYear).toFixed(2)); lastYear.push(Number(item.lastYear).toFixed(2)); }) option = { backgroundColor: '#000', tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } }, grid: { top: '14%', right: '3%', left: '7%', bottom: '20%' }, legend: { top: '-3%', itemWidth: 10, itemHeight: 10, textStyle: { color: "#ffffff", fontSize: 15 }, data: ['用水量', '去年同期'], }, xAxis: [{ type: 'category', data: data, axisLine: { lineStyle: { color: 'rgba(255,255,255,1)' } }, axisLabel: { margin: 10, color: '#e2e9ff', }, }], yAxis: [{ name: '万m³', boundaryGap: ['0%', '20%'], nameTextStyle: { verticalAlign: 'middle', align: "right" }, axisLabel: { formatter: '{value}', color: '#e2e9ff', }, axisLine: { show: false, lineStyle: { color: 'rgba(255,255,255,1)' } }, splitLine: { lineStyle: { color: 'rgba(255,255,255,0.12)' } } }], series: [{ name: "用水量", type: 'bar', data: year, barWidth: '12px', itemStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: 'rgba(4, 187, 255, 1)' // 0% 处的颜色 }, { offset: 1, color: 'rgba(4, 187, 255, 1)' // 100% 处的颜色 }], false), borderRadius: [5, 5, 0, 0], shadowColor: 'rgba(0,160,221,1)', shadowBlur: 4, } }, { name: "去年同期", type: 'bar', data: lastYear, barWidth: '12px', itemStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: 'rgba(250, 201, 87, 1)' // 0% 处的颜色 }, { offset: 1, color: 'rgba(250, 201, 87, 1)' // 100% 处的颜色 }], false), borderRadius: [5, 5, 0, 0], shadowColor: 'rgba(0,160,221,1)', shadowBlur: 4, } }] };