//echart $(function () { var bstj_char_data = [ ]; layui.use('form', function(){ var form = layui.form; form.on('select(year)', function(data){ console.log(data.value); //得到被选中的值 getData(data.value) }); }); getData(new Date().getFullYear()) initPage(); }) function initPage() { $(window).resize(function () { chartResize($("#bstj_char")[0]); }); } function chartResize(e) { var chart = echarts.getInstanceByDom(e); if (chart && chart.resize) { chart.resize(); } } function getData(year){ $.ajax({ url: '/szinf/consult/getBanJianNumByYear', type: 'POST', async: true, data: { year: year, }, success: function (data) { $('#zxl').html(data.custom.projectnum.consultYear) $('#sll').html(data.custom.projectnum.slYear) //$('#bjl').html(data.custom.projectnum.bjYear) sjcx_char_data = [] var template = "" $("#dataSource").html('') for(var i=0; i"+ ""+ data.custom.projectnum.monthList[i].month+'月' +""+ ""+ data.custom.projectnum.monthList[i].consultNum +""+ ""+ data.custom.projectnum.monthList[i].slNum+""+ "") sjcx_char_data.unshift({ month: data.custom.projectnum.monthList[i].month+'月', v1: data.custom.projectnum.monthList[i].consultNum, v2: data.custom.projectnum.monthList[i].slNum }) } bstj_char([sjcx_char_data]) }, }) } //数据统计 function bstj_char(eData) { var chart = echarts.init($("#bstj_char")[0]); var option = { color: ["#4169e2", '#ffa200', '#cccccc'], animationEasing: 'cubicInOut', animationDuration: function (idx) { return idx * 200; }, animationDelayUpdate: function (idx) { return idx * 200; }, grid: { show: false, left: 60, right: 20, top: 30, bottom: 80 }, tooltip: { trigger: 'axis', textStyle: { fontSize: 12 }, axisPointer: { type: 'shadow', crossStyle: { color: '#999' } } }, legend: { show: true, data: ["咨询量", "办件量"], bottom: 10, itemGap: 30, textStyle: { color: "#666666", fontSize: 14 } }, xAxis: { data: [], axisLine: { lineStyle: { color: "#e3e3e3" } }, axisTick: { lineStyle: { color: "#e3e3e3" } }, axisLabel: { color: "#666666" }, axisPointer: { type: 'shadow' } }, yAxis: [{ type: 'value', name: '', axisLine: { show: false }, axisTick: { show: false }, axisLabel: { color: "#666666" }, splitLine: { show: true, lineStyle: { color: '#eeeeee' } }, axisPointer: { type: 'shadow' } // min: 'dataMin', // max: 'dataMax' // interval: 50, // axisLabel: { // formatter: '{value} ' // } }], series: [{ name: '咨询量', data: [], type: 'line' }, { name: '办件量', data: [], type: 'line' } ] }; chart.setOption(option); var chartDataObj = { xAxis: [{ data: [] }], series: [{ data: [] }, { data: [] }] }; $(eData[0]).each(function (i, map) { chartDataObj.xAxis[0].data.push(map.month); chartDataObj.series[0].data.push(map.v1); chartDataObj.series[1].data.push(map.v2); }); chart.setOption(chartDataObj); return chart; }