function loadCiShuAndKeHuShu(name) { var ajax1 = $.get(clientUrl_Order,{"dataType":"dp1169_app_zh_gmcs_jk","fresh":"1"}).done(function(data){ data_LN=data; }); var ajax2 = $.get(clientUrl_Order,{"dataType":"dp1169_app_zh_gmcs_lj","fresh":"1"}).done(function(data){ data_LJ=data; }); $.when(ajax1,ajax2).done(function(){ var xAxis=[]; var series_LN=[]; var series_LJ=[]; var series=[]; if ('綜合'==name) { $.each(data_LN.monthly_trend, function(index,item) { if(xAxis.indexOf(item.vday_ym)==-1){ xAxis.push(item.stat); } }); $.each(data_LJ.monthly_trend, function(index,item) { if(xAxis.indexOf(item.stat)==-1){ xAxis.push(item.stat); } }); xAxis.sort(); console.log("--------------",xAxis) $.each(data_LN.monthly_trend,function(index,item){ var num=xAxis.indexOf(item.stat); series_LN[num]=item.custnum; }) $.each(data_LJ.monthly_trend,function(index,item){ var num=xAxis.indexOf(item.stat); series_LJ[num]=item.custnum; }) } console.log("&&&&&&&&&&&&&&&&&&",series_LN) //購買次數與客戶數 let ec005_hBar = echarts.init($("#ec005_hBar")[0]); ec005_hBar.clear(); ec005_hBar.setOption(opt_line); ec005_hBar.setOption(opt_bar_vertical); ec005_hBar.setOption({ grid: { top: '25%', bottom: '10%', left: '15%', right: '5%', }, xAxis: { // name: '月份', data: xAxis, axisLabel:{ interval:0 } }, yAxis: [ { }, ], series: [ { name: '樂家 ', type: 'bar', itemStyle: { color: colors[0] }, barWidth: '20%', data: series_LJ, }, { name: '樂農 ', type: 'bar', itemStyle: { color: colors[1] }, barWidth: '20%', data: series_LN, } ] }); // 產品轉化率 }); }
重點:ajax
var ajax1 = $.get(clientUrl_Order,{"dataType":"dp1169_app_zh_gmcs_jk","fresh":"1"}).done(function(data){ data_LN=data; }); var ajax2 = $.get(clientUrl_Order,{"dataType":"dp1169_app_zh_gmcs_lj","fresh":"1"}).done(function(data){ data_LJ=data; }); $.when(ajax1,ajax2).done(function(){ })