| | |
| | | }); |
| | | } |
| | | |
| | | // 退费图与营收图使用同一接口返回的退款流水,保证统计口径一致。 |
| | | function renderRefundChart(chart, resp) { |
| | | var labelsByPeriod = { |
| | | '年度退费': resp.yearLabels, |
| | | '月度退费': resp.monthLabels, |
| | | '周度退费': resp.weekLabels, |
| | | '日度退费': resp.dayLabels |
| | | }; |
| | | var statisticsByPeriod = { |
| | | '年度退费': resp.yearIncomeStatistics, |
| | | '月度退费': resp.monthIncomeStatistics, |
| | | '周度退费': resp.weekIncomeStatistics, |
| | | '日度退费': resp.dayIncomeStatistics |
| | | }; |
| | | chart.off('legendselectchanged'); |
| | | chart.setOption({ |
| | | tooltip: {trigger: 'axis'}, |
| | | legend: { |
| | | data: ['年度退费', '月度退费', '周度退费', '日度退费'], |
| | | icon: 'stack', |
| | | selectedMode: 'single', |
| | | selected: {'年度退费': true, '月度退费': false, '周度退费': false, '日度退费': false} |
| | | }, |
| | | grid: {left: '3%', right: '4%', bottom: '12%', containLabel: true}, |
| | | toolbox: {feature: {saveAsImage: {}}}, |
| | | xAxis: {type: 'category', boundaryGap: false, data: labelsByPeriod['年度退费'], axisLabel: {rotate: 35, interval: 0}}, |
| | | yAxis: {type: 'value'}, |
| | | series: Object.keys(statisticsByPeriod).map(function (period) { |
| | | return { |
| | | name: period, |
| | | type: 'line', |
| | | data: statisticsByPeriod[period].map(function (item) { return item.refundAmount; }) |
| | | }; |
| | | }) |
| | | }, true); |
| | | chart.on('legendselectchanged', function (event) { |
| | | var labels = labelsByPeriod[event.name]; |
| | | chart.setOption({xAxis: {data: labels, axisLabel: {rotate: labels.length > 7 ? 35 : 0, interval: 0}}}); |
| | | }); |
| | | } |
| | | |
| | | $(function(){ |
| | | getContent(1); |
| | | getContent1(1); |
| | |
| | | ptCourse(); |
| | | |
| | | |
| | | var myChart1 = echarts.init(document.getElementById('refund')); |
| | | var ajax = new $ax(Feng.ctxPath + "/data/getIncomeData", function(resp){ |
| | | // 运营、教学等其他图表仍复用年度横轴。 |
| | | yearX = resp.year; |
| | |
| | | renderIncomeTrendChart("incomeMonthChart", "本年各月营收趋势", resp.monthLabels, resp.monthIncomeStatistics); |
| | | renderIncomeTrendChart("incomeWeekChart", "近四周营收趋势", resp.weekLabels, resp.weekIncomeStatistics); |
| | | renderIncomeTrendChart("incomeDayChart", "近七日营收趋势", resp.dayLabels, resp.dayIncomeStatistics); |
| | | $("#back1").text(resp.yearIncomeStatistics[resp.yearIncomeStatistics.length - 1].refundAmount || 0); |
| | | $("#back2").text(resp.monthIncomeStatistics[new Date().getMonth()].refundAmount || 0); |
| | | $("#back3").text(resp.weekIncomeStatistics[resp.weekIncomeStatistics.length - 1].refundAmount || 0); |
| | | $("#back4").text(resp.dayIncomeStatistics[resp.dayIncomeStatistics.length - 1].refundAmount || 0); |
| | | renderRefundChart(myChart1, resp); |
| | | }); |
| | | ajax.set("type",1); |
| | | ajax.start(); |
| | | |
| | | var myChart1 = echarts.init(document.getElementById('refund')); |
| | | |
| | | var myChart7 = echarts.init(document.getElementById('courseData')); |
| | | var ajax3 = new $ax(Feng.ctxPath + "/data/backPt", function(data){ |
| | | $("#back1").text(data.thisYear); |
| | | $("#back2").text(data.thisMonth); |
| | | $("#back3").text(data.thisWeek); |
| | | $("#back4").text(data.thisDay); |
| | | optionBack = { |
| | | |
| | | tooltip: { |
| | | trigger: 'axis' |
| | | }, |
| | | legend: { |
| | | |
| | | data: ['年度退费', '月度退费','周度退费','日度退费'], |
| | | icon: 'stack', |
| | | selectedMode: 'single', // 单选 |
| | | selected: { |
| | | 年度会员数: true, |
| | | 月度会员数: false, |
| | | 周度会员数: false, |
| | | 日度会员数: false |
| | | } |
| | | }, |
| | | grid: { |
| | | left: '3%', |
| | | right: '4%', |
| | | bottom: '3%', |
| | | containLabel: true |
| | | }, |
| | | toolbox: { |
| | | feature: { |
| | | saveAsImage: {} |
| | | } |
| | | }, |
| | | xAxis: { |
| | | type: 'category', |
| | | boundaryGap: false, |
| | | data: yearX |
| | | }, |
| | | yAxis: { |
| | | type: 'value' |
| | | }, |
| | | series: [ |
| | | { |
| | | name: '年度退费', |
| | | type: 'line', |
| | | stack: 'Total', |
| | | data: data.yearData |
| | | }, |
| | | { |
| | | name: '月度退费', |
| | | type: 'line', |
| | | stack: 'Total', |
| | | data: data.monthData |
| | | }, |
| | | { |
| | | name: '周度退费', |
| | | type: 'line', |
| | | stack: 'Total', |
| | | data: data.weekData |
| | | }, |
| | | { |
| | | name: '日度退费', |
| | | type: 'line', |
| | | stack: 'Total', |
| | | data: data.dayData |
| | | } |
| | | ] |
| | | |
| | | }; |
| | | }); |
| | | ajax3.start(); |
| | | |
| | | |
| | | |
| | | var ajax4 = new $ax(Feng.ctxPath + "/data/userAndVipPt", function(data){ |
| | | option1 = { |
| | | |
| | |
| | | }; |
| | | }); |
| | | ajax4.start(); |
| | | |
| | | myChart1.on('legendselectchanged', obj => { |
| | | var options = myChart1.getOption() |
| | | //这里是选择切换什么样的x轴,那么他会进行对Y值的切换 |
| | | if (obj.name == '年度退费') { |
| | | options.xAxis[0].data = yearX |
| | | } else if (obj.name == '月度退费') { |
| | | options.xAxis[0].data = monthX |
| | | } else if (obj.name == '周度退费') { |
| | | options.xAxis[0].data = ["1周","2周","3周","4周"] |
| | | } else if (obj.name == '日度退费') { |
| | | options.xAxis[0].data = dataX |
| | | } |
| | | myChart1.setOption(options, true) |
| | | }) |
| | | |
| | | |
| | | // 使用刚指定的配置项和数据显示图表。 |
| | | myChart1.setOption(optionBack); |
| | | |
| | | myChart7.setOption(option7); |
| | | }); |