Extjs 4 生成饼状图实例
2020-12-13 16:45
标签:java extjs 4.2 jsp 实例 servlet 前台:
Extjs 4 生成饼状图实例,搜素材,soscw.com Extjs 4 生成饼状图实例 标签:java extjs 4.2 jsp 实例 servlet 原文地址:http://blog.csdn.net/primary_wind/article/details/32332885//远程读取设备去向图表数据
var Store1 = new Ext.data.Store({
proxy:{
type:'ajax',
url:'/newmaterial/servlet/GetCountChartGoDatas',
reader:{
type:'array'
}
},
fields:[
"System",
{name:"Share",type:"float"}
]
});
Store1.load();
var mychart1 = new Ext.chart.Chart({
store:Store1,
title:'全部物料去向概览',
width:500,
height:500,
insetPadding:50,
legend:{position:"right"},
series:[{
type:'pie',
field:'Share',
showInLegend:true,
highlight:{
segment:{margin:20}
},
label:{
field:'System',
display:'rotate',
contrast:true
},
tips:{
trackMouse:true,
renderer:function(rec,item){
this.update(rec.get("System")+':'+rec.get("Share")+'%');
}
}
}]
});
后台:
public class GetCountChartGoDatas extends HttpServlet {
/**
* @Fields serialVersionUID :
*/
private static final long serialVersionUID = 1L;
/**
* The doGet method of the servlet.
*
* This method is called when a form has its tag value method equals to get.
*
* @param request
* the request send by the client to the server
* @param response
* the response send by the server to the client
* @throws ServletException
* if an error occurred
* @throws IOException
* if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html");
StringBuffer sb = new StringBuffer();
NowmaterialDAO nmd = new NowmaterialDAO();
MaterialDAO md = new MaterialDAO();
List getlist = nmd.getSession().createCriteria(Nowmaterial.class)
.setProjection(
Projections.projectionList()
.add(Projections.rowCount()).add(
Projections.groupProperty("material.msCode")))
.list();
int total = 0;
for (int i = 0; i getonelist = md.findByProperty("msCode", row[1]);
sb.append("['" + getonelist.get(0).getMsName() + "',"
+ Float.parseFloat(row[0].toString()) + "],");
}
sb.append("]");
int qu = sb.lastIndexOf(",");
sb.deleteCharAt(qu);
response.getWriter().print(sb.toString());
}
/**
* The doPost method of the servlet.
*
* This method is called when a form has its tag value method equals to
* post.
*
* @param request
* the request send by the client to the server
* @param response
* the response send by the server to the client
* @throws ServletException
* if an error occurred
* @throws IOException
* if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
下一篇:phpmyadmin常见错误