//引入echart.js//echart的data引入getStatus()函数,在函数中调用后台接口,从而获取到后台数据,按照echart所需要的格式在sql中查取数据 echart所要的格式为:[26, 59, 80, 24, 87, 70, 175, 1072, 48, 18, 69, 63] 后台sql语句的格式必须和echart的格式对应,若某个月份没有收入则默认为0,此时sql语句为: SELECT B.temp AS tempFROM (SELECT month(r_addtime)as months ,sum(r_paid_in) AS tempFROM recordWHERE r_status=#{rstatus} and shop_id=#{shopId} and year(r_addtime)=2019group by year(r_addtime), month(r_addtime)UNIONSELECT '1' as mon,'0' as tempunion SELECT '2' as mon,'0' as tempunion SELECT '3' as mon,'0' as temp union SELECT '4' as mon,'0' as temp union SELECT '5' as mon,'0' as temp union SELECT '6' as mon,'0' as temp union SELECT '7' as mon,'0' as temp union SELECT '8' as mon,'0' as temp union SELECT '9' as mon,'0' as temp union SELECT '10' as mon,'0' as temp union SELECT '11' as mon,'0' as temp union SELECT '12' as mon,'0' as temp) BGROUP BY B.monthsORDER BY B.months复制代码
效果图如下: