option = { //color: ["#4169e2", '#ffa200', '#cccccc'], color: ["#4169e2", '#cccccc'], tooltip: { trigger: 'axis', axisPointer: { // 坐标轴指示器,坐标轴触发有效 type: 'shadow' // 默认为直线,可选为:'line' | 'shadow' } }, legend: { top:10, right: 0, itemWidth: 10, itemHeight: 10, itemGap: 20, //data: ['咨询量', '受理量', '办结量'], data: ['咨询量', '办件量'] }, grid: { left: '3%', right: '4%', bottom: '3%', containLabel: true }, xAxis: [ { type: 'category', data: ['本日', '本月'], axisLine: { lineStyle: { color: "#e3e3e3" } }, axisTick: { lineStyle: { color: "#e3e3e3" } }, axisLabel: { color: "#666666" } } ], yAxis: [ { type: 'value', axisLine: { show: false }, axisTick: { show: false }, axisLabel: { color: "#666666" }, splitLine: { show: true, lineStyle: { color: '#eeeeee' } } } ], series: [ { name: '咨询量', type: 'bar', barWidth: '18%', data: [] }, //{ // name: '受理量', // type: 'bar', // barWidth: '18%', // data: [] //}, { name: '办件量', type: 'bar', barWidth: '18%', data: [] } ] }; var chart = echarts.init($("#section1")[0]); chart.setOption(option); //var chartDataObj = null; var chartDataObj={}; $.ajax({ url: '/szinf/consult/getMonthBjNum', type: 'GET', async: true, success: function (data) { if(data && data.custom && data.custom.code == 1 ) { var data = data.custom.projectnum chartDataObj = { series: [{ data: [data.todayConsult, data.monthConsult] }, // { // data: [data.todaySl, data.monthSl] // }, { data: [data.todaySl, data.monthSl] }] }; $.extend(option,option.series,chartDataObj) chart.setOption(option); } } }) chart.setOption(chartDataObj);