加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

extjs 之panel嵌入flash饼状图

发布时间:2020-12-15 06:50:58 所属栏目:百科 来源:网络整理
导读:java端获取数据代码 ? /** ? ?????*?创建产品线接口数量统计数据的XML格式数据 ? ?????*? ? ?????*?@param?caption ? ?????*????????????报表标题 ? ?????*?@param?xAxisName ? ?????*????????????横轴名称 ? ?????*?@param?yAxisName ? ?????*????????????

java端获取数据代码

?

 
 
  1. /** ?
  2. ?????*?创建产品线接口数量统计数据的XML格式数据 ?
  3. ?????*? ?
  4. ?????*?@param?caption ?
  5. ?????*????????????报表标题 ?
  6. ?????*?@param?xAxisName ?
  7. ?????*????????????横轴名称 ?
  8. ?????*?@param?yAxisName ?
  9. ?????*????????????纵轴名称 ?
  10. ?????*?@param?baseFontSize ?
  11. ?????*????????????字体大小?以12为佳 ?
  12. ?????*?@param?ISCreateFile ?
  13. ?????*????????????是否要创建为XML文件,TRUE表示要创建文件 ?
  14. ?????*?@param?pFileName ?
  15. ?????*????????????XML文件的输出路径与文件名称 ?
  16. ?????*?@return?String?XML格式字符串,用于图表显示 ?
  17. ?????*/?
  18. ????public?String?CreateCasePorjectDibtXmlData(TestCase?searchtc,String?caption,?String?subCaption,?
  19. ????????????String?baseFontSize,?boolean?ISCreateFile,?String?pFileName)?{ ?
  20. ???????? ?
  21. ???????? ?
  22. ????????//List<StatisticsOfIfaceNumber>?IFaceNumberList?=?StatisticsOfIfaceNumberDao ?
  23. ????????????//??.getStatisticsOfIfaceNumberList(); ?
  24. ????????//int?ListSize?=?IFaceNumberList.size(); ?
  25. ????????CaseReportService?cs?=?new?CaseReportService(); ?
  26. ???????? ?
  27. ????????List<DisCaseProject>?ldcp?=?cs.getDisCaseProjectData(searchtc); ?
  28. ????????int?ListSize?=?ldcp.size(); ?
  29. ????????Document?document?=?DocumentHelper.createDocument(); ?
  30. ????????Element?root?=?document.addElement("graph").addAttribute("caption",?
  31. ????????????????caption).addAttribute("baseFontSize",?baseFontSize) ?
  32. ????????????????.addAttribute("showNames",?"1").addAttribute( ?
  33. ????????????????????????"decimalPrecision",?"0").addAttribute( ?
  34. ????????????????????????"formatNumberScale",?"0").addAttribute("yAxisMinValue",?
  35. ????????????????????????"0"); ?
  36. ????????if?(subCaption?!=?null)?{ ?
  37. ????????????root.addAttribute("subCaption",?subCaption); ?
  38. ????????} ?
  39. ????????int?totalCaseCount?=?0; ?
  40. ???????? ?
  41. ????????Iterator<DisCaseProject>?its?=?ldcp.iterator(); ?
  42. ????????while?(its.hasNext())?{ ?
  43. ????????????DisCaseProject?Temp_CaseCount?=?its.next(); ?
  44. ????????????if?(Temp_CaseCount?==?null) ?
  45. ????????????????break; ?
  46. ????????????totalCaseCount?=?totalCaseCount?+?Temp_CaseCount.getCount(); ?
  47. ????????} ?
  48. ???????? ?
  49. ????????if?(ListSize?>?com.help.Colordef.colorCount)?{ ?
  50. ????????????String?color[]?=?new?String[ListSize]; ?
  51. ????????????for?(int?i?=?0;?i?<?ListSize;?i++)?{ ?
  52. ????????????????double?n?=?Math.random(); ?
  53. ????????????????double?m?=?Math.random(); ?
  54. ????????????????double?k?=?Math.random(); ?
  55. ????????????????int?j?=?(int)?(n?*?m?*?k?*?0xFFFFFF); ?
  56. ????????????????color[i]?=?Integer.toHexString(j); ?
  57. ????????????} ?
  58. ????????????Iterator<DisCaseProject>?it?=?ldcp.iterator(); ?
  59. ?
  60. ????????????int?iColor?=?0; ?
  61. ????????????while?(it.hasNext())?{ ?
  62. ????????????????DisCaseProject?temp?=?it.next(); ?
  63. ????????????????if?(temp?==?null) ?
  64. ????????????????????break; ?
  65. ????????????????root.addElement("set").addAttribute( ?
  66. ????????????????????????????????"name",?
  67. ????????????????????????????????temp.getProjectname() ?
  68. ????????????????????????????????????????+?":"?
  69. ????????????????????????????????????????+?(int)?(((float)?temp.getCount()/(float)totalCaseCount)?*?100) ?
  70. ????????????????????????????????????????+?"%").addAttribute("value",?
  71. ????????????????????????????????Integer.toString(temp.getCount())) ?
  72. ????????????????????????.addAttribute("color",?color[iColor]); ?
  73. ????????????????iColor++; ?
  74. ????????????} ?
  75. ????????}?else?{ ?
  76. ????????????Iterator<DisCaseProject>?it?=?ldcp.iterator(); ?
  77. ?
  78. ????????????int?iColor?=?0; ?
  79. ????????????while?(it.hasNext())?{ ?
  80. ????????????????DisCaseProject?temp?=?it.next(); ?
  81. ????????????????if?(temp?==?null) ?
  82. ????????????????????break; ?
  83. ?
  84. ????????????????root ?
  85. ????????????????????????.addElement("set") ?
  86. ????????????????????????.addAttribute( ?
  87. ????????????????????????????????"name",?
  88. ????????????????????????????????temp.getProjectname() ?
  89. ????????????????????????????????????????+?":"?
  90. ????????????????????????????????????????+?(int)?(((float)?temp.getCount()/?(float)?totalCaseCount)?*?100) ?
  91. ????????????????????????????????????????+?"%") ?
  92. ????????????????????????.addAttribute("value",?
  93. ????????????????????????????????Integer.toString(temp.getCount())) ?
  94. ????????????????????????.addAttribute( ?
  95. ????????????????????????????????"color",?
  96. ????????????????????????????????com.help.Colordef.color[iColor]); ?
  97. ?
  98. ????????????????iColor++; ?
  99. ????????????} ?
  100. ????????} ?
  101. ?
  102. ????????if?(ISCreateFile?==?true)?{ ?
  103. ????????????XMLWriter?output; ?
  104. ????????????try?{ ?
  105. ????????????????output?=?new?XMLWriter(new?FileWriter(new?File(pFileName))); ?
  106. ????????????????output.write(document); ?
  107. ?
  108. ????????????????output.close(); ?
  109. ????????????}?catch?(IOException?e)?{ ?
  110. ????????????????//?TODO?Auto-generated?catch?block ?
  111. ????????????????e.printStackTrace(); ?
  112. ????????????} ?
  113. ????????} ?
  114. ?
  115. ????????return?document.asXML(); ?
  116. ????} ?
  117. ?
  118. ????/** ?
  119. ?????*?@see?HttpServlet#doGet(HttpServletRequest?request,?HttpServletResponse ?
  120. ?????*??????response) ?
  121. ?????*/?
  122. ????protected?void?doGet(HttpServletRequest?request,?
  123. ????????????HttpServletResponse?response)?throws?ServletException,?IOException?{ ?
  124. ?
  125. ????????this.doPost(request,?response); ?
  126. ????????//?TODO?Auto-generated?method?stub ?
  127. ????} ?
  128. ?
  129. ????/** ?
  130. ?????*?@see?HttpServlet#doPost(HttpServletRequest?request,?HttpServletResponse ?
  131. ?????*??????response) ?
  132. ?????*/?
  133. ????protected?void?doPost(HttpServletRequest?request,?
  134. ????????????HttpServletResponse?response)?throws?ServletException,?IOException?{ ?
  135. ????????//?TODO?Auto-generated?method?stub ?
  136. ????????HttpSession?session?=?request.getSession(false); ?
  137. ????????TestCase?searchtc?=?(TestCase)?session.getAttribute("searchtc"); ?
  138. ?
  139. ????????String?xmldata?=?CreateCasePorjectDibtXmlData(searchtc,?"case?项目用例分布图",?"",?"12",?false,?null); ?
  140. ????????PrintWriter?out?=?response.getWriter(); ?
  141. ????????try?{ ?
  142. ????????????????xmldata?=?xmldata.replaceAll(""","'"); ?
  143. ????????????????xmldata?=?xmldata.replaceAll("%","%"); ?
  144. ???????????? ?
  145. ????????????????//xmldata?=?URLEncoder.encode(xmldata,"utf-8"); ?
  146. ????????????????System.out.println(xmldata); ?
  147. ????????????????out.write(xmldata); ?
  148. ?
  149. ????????}?catch?(NumberFormatException?e)?{ ?
  150. ????????????out.write("invalid?data"); ?
  151. ????????} ?
  152. ????????out.close(); ?
  153. ????} ?

?

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>


js页面端代码

 
 
  1. function?load_project_case_panel()?{ ?
  2. ????Ext.Ajax.request({ ?
  3. ????????url?:?'GetCasePorjectDistributedData',?
  4. ????????success?:?function(response)?{ ?
  5. ????????????xmlData?=?response.responseText; ?
  6. ????????????//alert(xmlData); ?
  7. ????????????var?strFlashVars?=?"chartWidth=500&chartHeight=200&debugMode=0&dataXML="+?xmlData+?""; ?
  8. ????????????var?dis_project_case_panel?=?new?Ext.Panel( ?
  9. ????????????????????{ ?
  10. ????????????????????????width?:?Glb.outer_center.getWidth()?*?0.7,?
  11. ????????????????????????height?:?250,?
  12. ????????????????????????html?:?'<object?classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'?
  13. ????????????????????????????????+'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0'?
  14. ????????????????????????????????+?'width=600?height=250>'?
  15. ????????????????????????????????+?'<param?name="allowScriptAccess"?value="always"?/>'?
  16. ????????????????????????????????+?'<param?name="movie"?value="/taiji/static/flash/Pie3D.swf"?/>'?
  17. ????????????????????????????????+?'<param?name="wmode"?value="transparent"?/>'?
  18. ????????????????????????????????+?'<param?name="FlashVars"?value='?+?"""+strFlashVars+"""?+'/>'?
  19. ????????????????????????????????+?'<param?name="quality"?value="high"?/>'?
  20. ????????????????????????????????+?'<embed?src='#'" /taiji/static/flash/Pie3D.swf"?'?
  21. ????????????????????????????????+?'FlashVars="'?+strFlashVars?? ?
  22. ????????????????????????????????+?'"?quality="high"?width=600?height=250?allowScriptAccess="always"?type="application/x-shockwave-flash"'?
  23. ????????????????????????????????+?'pluginspage="http://www.macromedia.com/go/getflashplayer"?wmode="transparent"/>'?
  24. ????????????????????????????????+?'</object>'?
  25. ?
  26. ????????????????????}); ?
  27. ????????????dis_project_case_panel.show(); ?
  28. ????????????outer_center_center.add(dis_project_case_panel); ?
  29. ????????????Glb.outer_center.show(); ?
  30. ????????????Glb.outer_center.doLayout(); ?
  31. ????????},?
  32. ????????failure?:?function()?{ ?
  33. ????????????Ext.Msg.alert("提示",?"连接数据库错误或连接超时!"); ?
  34. ????????} ?
  35. ????}); ?
  36. } ?

?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读