前台:

  1. //远程抄表设备下落图表数据
  2. var Store1 = new Ext.data.Store({
  3. <span style="white-space:pre"> </span>proxy:{
  4. <span style="white-space:pre"> </span>type:'ajax',
  5. <span style="white-space:pre"> </span>url:'/newmaterial/servlet/GetCountChartGoDatas',
  6. <span style="white-space:pre"> </span>reader:{
  7. <span style="white-space:pre"> </span>type:'array'
  8. <span style="white-space:pre"> </span>}<span style="white-space:pre"> </span>
  9. <span style="white-space:pre"> </span>},
  10. <span style="white-space:pre"> </span>fields:[
  11. <span style="white-space:pre"> </span>"System",
  12. <span style="white-space:pre"> </span>{name:"Share",type:"float"}
  13. <span style="white-space:pre"> </span>]
  14. });
  15. Store1.load();
  16.  
  17. var mychart1 = new Ext.chart.Chart({
  18. <span style="white-space:pre"> </span>store:Store1,
  19. <span style="white-space:pre"> </span>title:'所有物料去向概览',
  20. <span style="white-space:pre"> </span>width:500,
  21. <span style="white-space:pre"> </span>height:500,
  22. <span style="white-space:pre"> </span>insetPadding:50,
  23. <span style="white-space:pre"> </span>legend:{position:"right"},
  24. <span style="white-space:pre"> </span>series:[{
  25. <span style="white-space:pre"> </span>type:'pie',
  26. <span style="white-space:pre"> </span>field:'Share',
  27. <span style="white-space:pre"> </span>showInLegend:true,
  28. <span style="white-space:pre"> </span>highlight:{
  29. <span style="white-space:pre"> </span>segment:{margin:20}
  30. <span style="white-space:pre"> </span>},
  31. <span style="white-space:pre"> </span>label:{
  32. <span style="white-space:pre"> </span>field:'System',
  33. <span style="white-space:pre"> </span>display:'rotate',
  34. <span style="white-space:pre"> </span>contrast:true
  35. <span style="white-space:pre"> </span>},
  36. <span style="white-space:pre"> </span>tips:{
  37. <span style="white-space:pre"> </span>trackMouse:true,
  38. <span style="white-space:pre"> </span>renderer:function(rec,item){
  39. <span style="white-space:pre"> </span>this.update(rec.get("System")+':'+rec.get("Share")+'%');
  40. <span style="white-space:pre"> </span>}
  41. <span style="white-space:pre"> </span>}
  42. <span style="white-space:pre"> </span>
  43. <span style="white-space:pre"> </span>}]
  44. });

后台:

  1. public class GetCountChartGoDatas extends HttpServlet {
  2.  
  3. /**
  4. * @Fields serialVersionUID :
  5. */
  6. private static final long serialVersionUID = 1L;
  7.  
  8. /**
  9. * The doGet method of the servlet. <br>
  10. *
  11. * This method is called when a form has its tag value method equals to get.
  12. *
  13. * @param request
  14. * the request send by the client to the server
  15. * @param response
  16. * the response send by the server to the client
  17. * @throws ServletException
  18. * if an error occurred
  19. * @throws IOException
  20. * if an error occurred
  21. */
  22. public void doGet(HttpServletRequest request, HttpServletResponse response)
  23. throws ServletException, IOException {
  24. request.setCharacterEncoding("utf-8");
  25. response.setContentType("text/html");
  26. StringBuffer sb = new StringBuffer();
  27. NowmaterialDAO nmd = new NowmaterialDAO();
  28. MaterialDAO md = new MaterialDAO();
  29. List getlist = nmd.getSession().createCriteria(Nowmaterial.class)
  30. .setProjection(
  31. Projections.projectionList()
  32. .add(Projections.rowCount()).add(
  33. Projections.groupProperty("material.msCode")))
  34. .list();
  35. int total = 0;
  36. for (int i = 0; i < getlist.size(); i++) {
  37. Object[] row = (Object[]) getlist.get(i);
  38. total = total + Integer.parseInt(row[0].toString());
  39. }
  40. response.setCharacterEncoding("utf-8");
  41. sb.append("[");
  42.  
  43. for (int i = 0; i < getlist.size(); i++) {
  44. Object[] row = (Object[]) getlist.get(i);
  45. List<Material> getonelist = md.findByProperty("msCode", row[1]);
  46. sb.append("['" + getonelist.get(0).getMsName() + "',"
  47. + Float.parseFloat(row[0].toString()) + "],");
  48. }
  49. sb.append("]");
  50. int qu = sb.lastIndexOf(",");
  51. sb.deleteCharAt(qu);
  52. response.getWriter().print(sb.toString());
  53. }
  54.  
  55. /**
  56. * The doPost method of the servlet. <br>
  57. *
  58. * This method is called when a form has its tag value method equals to
  59. * post.
  60. *
  61. * @param request
  62. * the request send by the client to the server
  63. * @param response
  64. * the response send by the server to the client
  65. * @throws ServletException
  66. * if an error occurred
  67. * @throws IOException
  68. * if an error occurred
  69. */
  70. public void doPost(HttpServletRequest request, HttpServletResponse response)
  71. throws ServletException, IOException {
  72. doGet(request, response);
  73.  
  74. }
  75.  
  76. }

版权声明:本文博主原创文章。博客,未经同意不得转载。

Extjs 4 生成饼状图的例子的更多相关文章

  1. JFreeChart框架中生成饼状图上怎样显示数据 [问题点数:40分,结帖人GreenLawn]

    我用JFreeChart框架生成饼状图,但想把数据信息在饼图上显示,是在饼图内部(即圆内)显示!怎样实现啊??  去掉lablepieplot.setLabelGenerator(null);去掉线p ...

  2. php 生成饼状图,折线图,条形图 通用类 2

    生成饼状图,折线图,条形图通用的php类,这里使用的是国外的 HighCharts,前台页面别忘了调用HighCahrt  js HighCharts中文网站  http://www.hcharts. ...

  3. php 生成饼状图,折线图,条形图 通用类

    生成饼状图,折线图,条形图通用的php类,这里使用的是百度 Echart. Echart 官方网站  http://echarts.baidu.com/ <?php class Echarts ...

  4. PHP实现动态生成饼状图 (转载)

    <?php //变量定义,画椭圆弧时的角度大小 define("ANGLELENGTH", 10); /** * 绘制图片 * @param $title 3D图的标题 * ...

  5. PHP实现动态生成饼状图、柱状图和折线图(转载)

    PHP在图像操作方面的表现非常出色,我们只需借助可以免费得到的GD库便可以轻松实现图.表勾画.下面将分别介绍PHP实现的饼状图.折线图和柱状图以 及他们的使用方法,这几段代码的特点就是不需要再把它们复 ...

  6. Echarts生成饼状图、条形图以及线形图 JS封装

    1.在我们开发程序中,经常会用到生成一些报表,比方说饼状图,条形图,折线图等.不多说了,直接上封装好的代码,如下Echarts.js所示 以下代码是封装在Echarts.js文件中 /** * Cre ...

  7. Winform 后台生成饼状图并保存为图片

    .cs代码如下 string ldt_picPath = System.Windows.Forms.Application.StartupPath + @"Pic\" + Item ...

  8. echart生成饼状图

    //绘制图表. echarts.init(document.getElementById('main')).setOption({ tooltip : { trigger: 'item', //触发类 ...

  9. C#应用NPOI实现导出EXcel表格中插入饼状图(可实现动态数据生成)

    一.思路:   1.excel是可以通过NPOI插入图片的: 2.C#通过NPOI生成饼状图: 3.把生成的饼状图以字节流的形式插入到表格 二.看代码: #region 生成饼图图例 /// < ...

随机推荐

  1. CloudEra Email Search

    http://blog.cloudera.com/blog/2013/09/email-indexing-using-cloudera-search/ http://blog.cloudera.com ...

  2. android4.0 禁止横竖屏切换使用 android:configChanges="orientation|keyboardHidden"无效

    android4.0 禁止横竖屏切换使用 android:configChanges="orientation|keyboardHidden"无效    在之前的版本中都是在Man ...

  3. PLA 多维情况下的vc维

    对于d维的数据集,vc = d+1 证明: $vc \geq d+1$  :  存在d+1个点可以被H shatter 构造矩阵(注意加上$w_0$对应的$x_0$) 注意x可逆,构造$w=X^{-1 ...

  4. 解决Boost.Regex对中文支持不好的问题

    解决Boost.Regex对中文支持不好的问题 - k.m.Cao - 博客频道 - CSDN.NET 解决Boost.Regex对中文支持不好的问题 k.m.Caov0.1   问题的提出: Boo ...

  5. 克拉夫斯曼高端定制 刘霞---【YBC中国国际青年创业计划】

    克拉夫斯曼高端定制 刘霞---[YBC中国国际青年创业计划] 克拉夫斯曼高端定制 刘霞

  6. JAVA之数组查询binarySearch()方法详解

    binarySearch()方法提供了多种重载形式,用于满足各种类型数组的查找需要,binarySearch()有两种参数类型 注:此法为二分搜索法,故查询前需要用sort()方法将数组排序,如果数组 ...

  7. wx.Notebook

    wx.Notebook This class represents a notebook control, which manages multiple windows with associated ...

  8. SQLite使用报告

    SQLite简介 SQLite是遵守ACID的关联式数据库管理系统,它包含在一个相对小的C库中.它是D.RichardHipp建立的公有领域项目. 不像常见的客户-服务器范例,SQLite引擎不是个程 ...

  9. ChartControl一个小Demo

    我X轴设置的是时间,类型是DatetimeY轴设置的是数量,类型是Numerical当日期不一样时显示曲线正常,但是如果是同一天的话就成了下面的效果 怎么做才能让全部是同一天的时候显示小时为单位的曲线 ...

  10. 根据自己的需要适度使用Web开发框架

    软件系统发展到今天已经很复杂了,特别是服务器端软件,涉及到的知识,内容,问题太多.Web开发框架能够帮我们大大减少工作量,但是我们应该如何正确看待Web开发框架,并且如何去使用他们呢? 对框架的依赖 ...