var data1 = [ 2.0, 5.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3 ] var data2 = [ 2.0, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3 ] option = { legend: { data: ['日计划', '日完成'] }, xAxis: [ { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], axisPointer: { type: 'shadow' } } ], yAxis: [ { show :false, type: 'value', min: 0, max: 250, interval: 50, axisLabel: { formatter: '{value}' }, splitLine: { show: false }, axisLine:{ show:false }, axisTick:{ show:false }, }, ], series: [ { name: '日计划', type: 'bar', itemStyle: { //通常情况下: normal: { label: { show: true, //开启显示数值 position: 'top', //数值在上方显示 textStyle: { //数值样式 color: '#293441', //字体颜色 fontSize: 14 //字体大小 } }, // 每个柱子的颜色即为colorList数组里的每一项,如果柱子数目多于colorList的长度,则柱子颜色循环使用该数组 color: '#3F77FE' }, }, data: data1 }, { name: '日完成', type: 'bar', tooltip: { valueFormatter: function (value) { return value ; } }, itemStyle: { //通常情况下: normal: { label: { show: true, //开启显示数值 position: 'top', //数值在上方显示 textStyle: { //数值样式 color: '#293441', //字体颜色 fontSize: 14 //字体大小 } }, // 每个柱子的颜色即为colorList数组里的每一项,如果柱子数目多于colorList的长度,则柱子颜色循环使用该数组 color: function (params) { console.log(params) if (data2[params.dataIndex] < data1[params.dataIndex]) { return "red"; } else { return 'green' } } }, }, data: data2 } ] };