Extjs 4 生成饼状图的例子
前台:
//远程抄表设备下落图表数据
var Store1 = new Ext.data.Store({
<span style="white-space:pre"> </span>proxy:{
<span style="white-space:pre"> </span>type:'ajax',
<span style="white-space:pre"> </span>url:'/newmaterial/servlet/GetCountChartGoDatas',
<span style="white-space:pre"> </span>reader:{
<span style="white-space:pre"> </span>type:'array'
<span style="white-space:pre"> </span>}<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>},
<span style="white-space:pre"> </span>fields:[
<span style="white-space:pre"> </span>"System",
<span style="white-space:pre"> </span>{name:"Share",type:"float"}
<span style="white-space:pre"> </span>]
});
Store1.load(); var mychart1 = new Ext.chart.Chart({
<span style="white-space:pre"> </span>store:Store1,
<span style="white-space:pre"> </span>title:'所有物料去向概览',
<span style="white-space:pre"> </span>width:500,
<span style="white-space:pre"> </span>height:500,
<span style="white-space:pre"> </span>insetPadding:50,
<span style="white-space:pre"> </span>legend:{position:"right"},
<span style="white-space:pre"> </span>series:[{
<span style="white-space:pre"> </span>type:'pie',
<span style="white-space:pre"> </span>field:'Share',
<span style="white-space:pre"> </span>showInLegend:true,
<span style="white-space:pre"> </span>highlight:{
<span style="white-space:pre"> </span>segment:{margin:20}
<span style="white-space:pre"> </span>},
<span style="white-space:pre"> </span>label:{
<span style="white-space:pre"> </span>field:'System',
<span style="white-space:pre"> </span>display:'rotate',
<span style="white-space:pre"> </span>contrast:true
<span style="white-space:pre"> </span>},
<span style="white-space:pre"> </span>tips:{
<span style="white-space:pre"> </span>trackMouse:true,
<span style="white-space:pre"> </span>renderer:function(rec,item){
<span style="white-space:pre"> </span>this.update(rec.get("System")+':'+rec.get("Share")+'%');
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>}]
});
后台:
public class GetCountChartGoDatas extends HttpServlet {
	/**
	 * @Fields serialVersionUID :
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * The doGet method of the servlet. <br>
	 *
	 * 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 < getlist.size(); i++) {
			Object[] row = (Object[]) getlist.get(i);
			total = total + Integer.parseInt(row[0].toString());
		}
		response.setCharacterEncoding("utf-8");
		sb.append("[");
		for (int i = 0; i < getlist.size(); i++) {
			Object[] row = (Object[]) getlist.get(i);
			List<Material> 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. <br>
	 *
	 * 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);
	}
}
版权声明:本文博主原创文章。博客,未经同意不得转载。
Extjs 4 生成饼状图的例子的更多相关文章
- JFreeChart框架中生成饼状图上怎样显示数据 [问题点数:40分,结帖人GreenLawn]
		我用JFreeChart框架生成饼状图,但想把数据信息在饼图上显示,是在饼图内部(即圆内)显示!怎样实现啊?? 去掉lablepieplot.setLabelGenerator(null);去掉线p ... 
- php 生成饼状图,折线图,条形图 通用类 2
		生成饼状图,折线图,条形图通用的php类,这里使用的是国外的 HighCharts,前台页面别忘了调用HighCahrt js HighCharts中文网站 http://www.hcharts. ... 
- php 生成饼状图,折线图,条形图 通用类
		生成饼状图,折线图,条形图通用的php类,这里使用的是百度 Echart. Echart 官方网站 http://echarts.baidu.com/ <?php class Echarts ... 
- PHP实现动态生成饼状图 (转载)
		<?php //变量定义,画椭圆弧时的角度大小 define("ANGLELENGTH", 10); /** * 绘制图片 * @param $title 3D图的标题 * ... 
- PHP实现动态生成饼状图、柱状图和折线图(转载)
		PHP在图像操作方面的表现非常出色,我们只需借助可以免费得到的GD库便可以轻松实现图.表勾画.下面将分别介绍PHP实现的饼状图.折线图和柱状图以 及他们的使用方法,这几段代码的特点就是不需要再把它们复 ... 
- Echarts生成饼状图、条形图以及线形图 JS封装
		1.在我们开发程序中,经常会用到生成一些报表,比方说饼状图,条形图,折线图等.不多说了,直接上封装好的代码,如下Echarts.js所示 以下代码是封装在Echarts.js文件中 /** * Cre ... 
- Winform 后台生成饼状图并保存为图片
		.cs代码如下 string ldt_picPath = System.Windows.Forms.Application.StartupPath + @"Pic\" + Item ... 
- echart生成饼状图
		//绘制图表. echarts.init(document.getElementById('main')).setOption({ tooltip : { trigger: 'item', //触发类 ... 
- C#应用NPOI实现导出EXcel表格中插入饼状图(可实现动态数据生成)
		一.思路: 1.excel是可以通过NPOI插入图片的: 2.C#通过NPOI生成饼状图: 3.把生成的饼状图以字节流的形式插入到表格 二.看代码: #region 生成饼图图例 /// < ... 
随机推荐
- C++ typeid实现原理
			最近看了boost::any类源码,其实现主要依赖typeid操作符.很好奇这样实现的时间和空间开销有多大,决定探一下究竟. VS2008附带的type_info类只有头文件,没有源文件,声明如下: ... 
- iOS5系统API和5个开源库的JSON解析速度测试
			iOS5系统API和5个开源库的JSON解析速度测试 iOS5新增了JSON解析的API,我们将其和其他五个开源的JSON解析库进行了解析速度的测试,下面是测试的结果和工程代码附件. 我们选择的测试对 ... 
- linux 进程(一)---基本概念
			一.进程的定义 进程是操作系统的概念,每当我们执行一个程序时,对于操作系统来讲就创建了一个进程,在这个过程中,伴随着资源的分配和释放.可以认为进程是一个程序的一次执行过程. 二.进 ... 
- LInux 下安装jdk
			安装jdk版本为1.6.0_12 一.下载jdk 下载地址:http://download.java.net/jdk6/ 选择Linux Platform jdk-6u12-linux-i586.bi ... 
- MYSQL 简单的循环存储过程
			BEGIN ; ; DO DO ); ; ) THEN ; END IF; END WHILE; ; ; END WHILE; END 
- spring MVC通过json与前台交互
			这里用的是spring4.1.4,jquery2.1.3,其它环境为:myeclipse2014,tomcat7,jdk7 首先,新建一个web工程,并导入springMVC的jar包(为了方便起见我 ... 
- instance variables may not be placed in categories
			Avoid Properties in Categories Objective-C分类中是不允许增加成员变量的(Instance variables may not be placed in cat ... 
- eclipse建立cocos2d-x开发环境
			前提: 已经安装了eclipse.能够正常开发 android应用 环境:windows 工具:1.已经集成了adt的eclipse,能够开发android应用.没有的,能够下载.下载地址:http: ... 
- oracle获取本月第一天和最后一天及Oracle trunc()函数的用法
			select to_char(trunc(add_months(last_day(sysdate), -1) + 1), 'yyyy-mm-dd') "本月第一天", to_cha ... 
- eclipse - tomcat 远程调试
			步骤:前提是tomcat上应用是eclipse打包部署上去的,代码一致. 1,在机器A上部署应用remote-debug之前,需要为机器A上的tomcat配置调试端口.在${tomcat}/bin下加 ... 
