user_archive_stat.jsp
上传用户:jhtang88
上传日期:2014-01-27
资源大小:28528k
文件大小:4k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
  2. <%@ page import="com.redmoon.oa.archive.*" %>
  3. <%@ page import="cn.js.fan.util.*" %>
  4. <%@ page import="cn.js.fan.web.*" %>
  5. <%@ page import="java.util.*" %>
  6. <%@ page import="org.jfree.data.general.DefaultPieDataset"%>
  7. <%@ page import="org.jfree.chart.JFreeChart"%>
  8. <%@ page import="org.jfree.chart.plot.PiePlot"%>
  9. <%@ page import="org.jfree.chart.ChartRenderingInfo"%>
  10. <%@ page import="org.jfree.chart.servlet.ServletUtilities"%>
  11. <%@ page import="org.jfree.chart.urls.StandardPieURLGenerator"%>
  12. <%@ page import="org.jfree.chart.entity.StandardEntityCollection"%>
  13. <%@ page import="org.jfree.chart.encoders.SunPNGEncoderAdapter"%>
  14. <%@ page import="org.jfree.chart.labels.*"%>
  15. <%@ page import="java.text.*"%>
  16. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  17. <html xmlns="http://www.w3.org/1999/xhtml">
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  20. <title>档案统计分析</title>
  21. <link rel="stylesheet" type="text/css" href="../common.css">
  22. <link rel="stylesheet" type="text/css" href="../css.css">
  23. </head>
  24. <body style="background-image:url()">
  25. <jsp:useBean id="privilege" scope="page" class="com.redmoon.oa.pvg.Privilege"/>
  26. <%
  27. String priv="read";
  28. if (!privilege.isUserPrivValid(request,priv))
  29. {
  30. out.println(cn.js.fan.web.SkinUtil.makeErrMsg(request, cn.js.fan.web.SkinUtil.LoadString(request, "pvg_invalid")));
  31. return;
  32. }
  33. %>
  34. <table width="304" border="0" cellspacing="0" cellpadding="0">
  35.   <form action="?op=showChart" method="post" name="form1" id="form1">
  36.     <tr>
  37.       <td width="183"><strong>&nbsp;请选择分布类型</strong>
  38.           <select name="type" id="type">
  39.             <option value="age" selected="selected"> 年&nbsp;&nbsp;&nbsp;&nbsp;龄 </option>
  40.             <option value="xl"> 学&nbsp;&nbsp;&nbsp;&nbsp;历 </option>
  41.           </select>
  42.       </td>
  43.       <td width="121"><input type="submit" name="Submit" value="确 定" /></td>
  44.     </tr>
  45.     <tr>
  46.       <td>&nbsp;</td>
  47.       <td>&nbsp;</td>
  48.     </tr>
  49.   </form>
  50. </table>
  51. <%
  52. String op = ParamUtil.get(request, "op");
  53. op = "showChart";
  54. String type = ParamUtil.get(request, "type");
  55. if (type.equals(""))
  56. type = "age";
  57. %>
  58. <script>
  59. form1.type.value = "<%=type%>";
  60. </script>
  61. <%
  62. String[] labels = null;
  63. double[] datas = null;
  64. UserArchiveDb uad = new UserArchiveDb();
  65. if (type.equals("age")) {
  66. labels = uad.getAgeGrade();
  67. // The data for the pie chart
  68. datas = uad.getAgeEveryGradeCount();
  69. }
  70. else if (type.equals("xl")) {
  71. labels = uad.getXueLiGrade();
  72. // The data for the pie chart
  73. datas = uad.getXueLiEveryGradeCount();
  74. }
  75. DefaultPieDataset data = new DefaultPieDataset();
  76. int len = labels.length;
  77. for (int i=0; i<len; i++) {
  78. data.setValue(labels[i], datas[i]);
  79. }
  80. PiePlot plot = new PiePlot(data);
  81. JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
  82. chart.setBackgroundPaint(java.awt.Color.white);  //可选,设置图片背景色
  83. chart.setTitle("档案分析"); //可选,设置图片标题
  84. // plot.setToolTipGenerator(new org.jfree.chart.labels.StandardPieToolTipGenerator()); 
  85. plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})", NumberFormat.getNumberInstance(), new DecimalFormat("0.00%")));
  86. ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
  87. //500是图片长度,300是图片高度
  88. String filename = ServletUtilities.saveChartAsPNG(chart, 600, 360, info, session);
  89. String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + filename; 
  90. %>
  91. <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  92.   <tr>
  93.     <td align="center"><img src="<%=graphURL%>" width=600 height=360 border=0 usemap="#<%=filename %>" /></td>
  94.   </tr>
  95. </table>
  96. </body>
  97. </html>