echarts 3d饼图_Echarts图表实现后台数据统计

柱状图获取后台数据展示:

9aedc3da9f50f98a0143f71875b113dc.png

饼图获取后台数据展示:

db9340c2c18cf67f4edd05c4a831208d.png

前端实现方法:

var myChart = echarts.init(document.getElementById('div1'));var myChart1 = echarts.init(document.getElementById('div2'));var names = [];var values = [];$.ajax({    type : "POST",    async:true,url : /*[[@{/admin/getCharts}]]*/,dataType : "json",success : function(result) { if (result != null && result.length > 0) {  for(var i=0;i{b} : {c} ({d}%)'},   legend: {        bottom: 10,        left: 'center',        data: names    },series : [{    name: '数据饼图',type : 'pie',radius: '65%',            center: ['50%', '50%'],            selectedMode: 'single',data : result}]});}else{alert("图表请求数据为空,可能服务器暂未录入,您可以稍后再试!");}},error:function(errorMsg){ alert("图表请求数据失败,可能是服务器开小差了");}});

后端实现方法:

@RequestMapping(value="/getCharts",method=RequestMethod.POST)@ResponseBodypublic List getCharts(){List list=new ArrayList();//发布量int blogCount=blogService.getAllCount();//阅读量int sumViews=blogService.sumViews();//点赞量int thumbsupCount=thumbsUpService.getAllCount();//评论量int commentCount=commentService.getAllCount();//收藏量int collectionCount=collectionService.getAllCount();list.add(new EchartsData("发布量",blogCount));list.add(new EchartsData("阅读量",sumViews));list.add(new EchartsData("点赞量",thumbsupCount));list.add(new EchartsData("评论量",commentCount));list.add(new EchartsData("收藏量",collectionCount));return list;}

仪表盘界面:

af43938d96a40a1d2848132f3fecfcae.png
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值