function handleSuccess(data) { var paperNumber = []; var totalNumber = []; var month = ['一月','二月','三月','四月','五月','六月','七月', '八月','九月','十月','十一月','十二月']; //k 数组下标 i 月份 layui.each(month,function (k,i) { var contain = false; layui.each(data.totalCount,function (key,item) { if(k+1 == parseInt(item.createTime.substr(-2))){ paperNumber.push(item.count); contain = true; } }); if (!contain) paperNumber.push(0); var contain = false; layui.each(data.map,function (key,item) { if(k+1 == parseInt(item.createTime.substr(-2))){ totalNumber.push(item.count); contain = true; } }); if (!contain) totalNumber.push(0); }); var options = { title:{text:"月度统计"}, chart: { type: 'bar' }, //纵轴 yaxis:{ show:true, labels:{show:true}, title: { text: '数量/篇', rotate: -90, offsetX: 0, offsetY: 0, style: { color: undefined, fontSize: '12px', fontFamily: 'Helvetica, Arial, sans-serif', fontWeight: 600, cssClass: 'apexcharts-yaxis-title', }, }, axisBorder: { show: true, color: '#78909C', offsetX: 0, offsetY: 0 } }, series: [{ name: '您', data: paperNumber },{ name: '总数', data: totalNumber }], //横轴 xaxis: { categories: month }, tooltip: { y: { formatter: function (val) { return "提交 " + val + " 篇" } } } }; new ApexCharts( document.querySelector("#barChart"), options ).render(); }