使用echarts展示分区分布图

第一步:引入JS文件

<script type="text/javascript" src="${pageContext.request.contextPath }/js/echarts.js"></script>

第二步:准备一个容器放图表

<div id="ec1" style="width: 500px;height: 400px;"></div>

第三步:基于准备好的dom,初始化echarts实例(因为需要的是dom节点,所以要有[0])

 var myEc1 = echarts.init($("#ec1")[0]);

第四步:ajax请求区域分区数据

$.post("${pageContext.request.contextPath }/subareaAction_findCountGroupByProvince.action",function(data){
myEc1.setOption({
title : {
text: '区域分区分布图',
subtext: '每个省份的分区数',
x:'center'
},
tooltip : {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
toolbox: {
show : true,
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false},
magicType : {
show: true,
type: ['pie', 'funnel'],
option: {
funnel: {
x: '25%',
width: '50%',
funnelAlign: 'left',
max: 1548
}
}
},
restore : {show: true},
saveAsImage : {show: true}
}
},
calculable : true,
series : [
{
name:'访问来源',
type:'pie',
radius : '55%',
center: ['50%', '60%'],
data:data
}
]
});
});

猜你喜欢

转载自www.cnblogs.com/naixin007/p/9096235.html