extjs 之panel嵌入flash饼状图
发布时间:2020-12-15 06:50:57 所属栏目:百科 来源:网络整理
导读:java端获取数据代码 /** * 创建产品线接口数量统计数据的XML格式数据 * * @param caption * 报表标题 * @param xAxisName * 横轴名称 * @param yAxisName * 纵轴名称 * @param baseFontSize * 字体大小 以12为佳 * @param ISCreateFile * 是否要创建为XML文
java端获取数据代码/** * 创建产品线接口数量统计数据的XML格式数据 * * @param caption * 报表标题 * @param xAxisName * 横轴名称 * @param yAxisName * 纵轴名称 * @param baseFontSize * 字体大小 以12为佳 * @param ISCreateFile * 是否要创建为XML文件,TRUE表示要创建文件 * @param pFileName * XML文件的输出路径与文件名称 * @return String XML格式字符串,用于图表显示 */ public String CreateCasePorjectDibtXmlData(TestCase searchtc,String caption,String subCaption,String baseFontSize,boolean ISCreateFile,String pFileName) { //List<StatisticsOfIfaceNumber> IFaceNumberList = StatisticsOfIfaceNumberDao // .getStatisticsOfIfaceNumberList(); //int ListSize = IFaceNumberList.size(); CaseReportService cs = new CaseReportService(); List<DisCaseProject> ldcp = cs.getDisCaseProjectData(searchtc); int ListSize = ldcp.size(); Document document = DocumentHelper.createDocument(); Element root = document.addElement("graph").addAttribute("caption",caption).addAttribute("baseFontSize",baseFontSize) .addAttribute("showNames","1").addAttribute( "decimalPrecision","0").addAttribute( "formatNumberScale","0").addAttribute("yAxisMinValue","0"); if (subCaption != null) { root.addAttribute("subCaption",subCaption); } int totalCaseCount = 0; Iterator<DisCaseProject> its = ldcp.iterator(); while (its.hasNext()) { DisCaseProject Temp_CaseCount = its.next(); if (Temp_CaseCount == null) break; totalCaseCount = totalCaseCount + Temp_CaseCount.getCount(); } if (ListSize > com.help.Colordef.colorCount) { String color[] = new String[ListSize]; for (int i = 0; i < ListSize; i++) { double n = Math.random(); double m = Math.random(); double k = Math.random(); int j = (int) (n * m * k * 0xFFFFFF); color[i] = Integer.toHexString(j); } Iterator<DisCaseProject> it = ldcp.iterator(); int iColor = 0; while (it.hasNext()) { DisCaseProject temp = it.next(); if (temp == null) break; root.addElement("set").addAttribute( "name",temp.getProjectname() + ":" + (int) (((float) temp.getCount()/(float)totalCaseCount) * 100) + "%").addAttribute("value",Integer.toString(temp.getCount())) .addAttribute("color",color[iColor]); iColor++; } } else { Iterator<DisCaseProject> it = ldcp.iterator(); int iColor = 0; while (it.hasNext()) { DisCaseProject temp = it.next(); if (temp == null) break; root .addElement("set") .addAttribute( "name",temp.getProjectname() + ":" + (int) (((float) temp.getCount()/ (float) totalCaseCount) * 100) + "%") .addAttribute("value",Integer.toString(temp.getCount())) .addAttribute( "color",com.help.Colordef.color[iColor]); iColor++; } } if (ISCreateFile == true) { XMLWriter output; try { output = new XMLWriter(new FileWriter(new File(pFileName))); output.write(document); output.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return document.asXML(); } /** * @see HttpServlet#doGet(HttpServletRequest request,HttpServletResponse * response) */ protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException { this.doPost(request,response); // TODO Auto-generated method stub } /** * @see HttpServlet#doPost(HttpServletRequest request,HttpServletResponse * response) */ protected void doPost(HttpServletRequest request,IOException { // TODO Auto-generated method stub HttpSession session = request.getSession(false); TestCase searchtc = (TestCase) session.getAttribute("searchtc"); String xmldata = CreateCasePorjectDibtXmlData(searchtc,"case 项目用例分布图","","12",false,null); PrintWriter out = response.getWriter(); try { xmldata = xmldata.replaceAll(""","'"); xmldata = xmldata.replaceAll("%","%"); //xmldata = URLEncoder.encode(xmldata,"utf-8"); System.out.println(xmldata); out.write(xmldata); } catch (NumberFormatException e) { out.write("invalid data"); } out.close(); } XMLDATA数据如下:
<?xml version='1.0' encoding='UTF-8'?>
<graph caption='case 项目用例分布图' baseFontSize='12' showNames='1' decimalPrecision='0' formatNumberScale='0' yAxisMinValue='0' subCaption=''><set name='bvt:37%' value='77' color='AFD8F8'/><set name='bonline:33%' value='70' color='F6BD0F'/><set name='chatroam:12%' value='25' color='8BBA00'/><set name='imuser_migrate:7%' value='16' color='FF8E46'/><set name='es_refactoring_1:6%' value='13' color='008E8E'/><set name='sms:1%' value='4' color='D64646'/><set name='ww_site_msg:1%' value='3' color='8E468E'/></graph>
|