[TOC]
jsp中导入相关js文件,依赖于jQuery,这里面。
导入以下文件
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/highcharts/highcharts.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/highcharts/highcharts-3d.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/highcharts/modules/exporting.js"></script>
.......
{
id : 'button-doShowHighcharts',
text : '显示区域分布图',
iconCls : 'icon-search',
handler : doShowHighcharts
}
......
$('#showSubareaWindow').window({
width: 600,
modal: true,
shadow: true,
closed: true,
height: 500,
resizable:false
});
......
function doShowHighcharts(){
$("#showSubareaWindow").window("open");
}
.......
<%--区域分区分布图--%>
<div class="easyui-window" title="区域分区分布图" id="showSubareaWindow" collapsible="false" minimizable="false" maximizable="false" style="top:20px;left:200px">
<div id="container" split="false" border="false">
</div>
</div>
.....
饼状图需要的数据是 这样的
[
['北京', 1],
['天津', 1]
}
数组中包含了一个数组,里面的数组,第一个对象是对应的省市名称,第二个对象是占比
Action添加方法
/**
* 查询区域分布图数据
* @return
*/
public String findSubareasGroupByProvince(){
List<Object> list = subareaService.findSubareasGroupByProvince();
java2Json(list,new String[]{});
return NONE;
}
/**
* 查询区域分布图数据
*
* @return
*/
@Override
public List<Object> findSubareasGroupByProvince() {
String hql = "SELECT r.province,count(*) FROM Subarea s LEFT OUTER JOIN s.region r GROUP BY r.province";
return (List<Object>) getHibernateTemplate().find(hql);
}