chartsuncount.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="renderer" content="webkit|ie-comp|ie-stand">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
  8. <meta http-equiv="Cache-Control" content="no-siteapp" />
  9. <LINK rel="Bookmark" href="/favicon.ico" >
  10. <LINK rel="Shortcut Icon" href="/favicon.ico" />
  11. <script type="text/javascript">
  12. var ctx="${ctx}";
  13. </script>
  14. <!--[if lt IE 9]>
  15. <script type="text/javascript" src="${ctx}/assets/lib/html5.js"></script>
  16. <script type="text/javascript" src="${ctx}/assets/lib/respond.min.js"></script>
  17. <script type="text/javascript" src="${ctx}/assets/lib/PIE_IE678.js"></script>
  18. <![endif]-->
  19. <link rel="stylesheet" href="${ctx}/assets/lib/bootstrap-3.3.7/css/bootstrap.min.css">
  20. <link rel="stylesheet" href="${ctx}/assets/lib/bootstrap-upload/css/default.css">
  21. <link rel="stylesheet" href="${ctx}/assets/lib/bootstrap-upload/css/fileinput.css">
  22. <script type="text/javascript" src="${ctx}/assets/lib/jquery/1.9.1/jquery.min.js"></script>
  23. <script type="text/javascript" src="${ctx}/assets/lib/jquery.form/jquery.form.min.js"></script>
  24. <script type="text/javascript" src="${ctx}/assets/lib/layer/3.0.3/layer.js"></script>
  25. <script type="text/javascript" src="${ctx}/assets/lib/My97DatePicker/WdatePicker.js"></script>
  26. <script type="text/javascript" src="${ctx}/assets/lib/bootstrap-upload/js/fileinput.js"></script>
  27. <script type="text/javascript" src="${ctx}/assets/lib/bootstrap-upload/js/locales/zh.js"></script>
  28. <script type="text/javascript" src="${ctx}/assets/lib/bootstrap-3.3.7/js/bootstrap.min.js"></script>
  29. <!--请在下方写此页面业务相关的脚本-->
  30. <script type="text/javascript" src="${ctx}/assets/lib/ueditor/1.4.3/third-party/highcharts/highcharts.js"></script>
  31. <script type="text/javascript" src="${ctx}/assets/lib/ueditor/1.4.3/third-party/highcharts/modules/exporting.js"></script>
  32. <script type="text/javascript" src="${ctx}/assets/lib/ueditor/1.4.3/third-party/highcharts/highcharts-zh_CN.js"></script>
  33. <script type="text/javascript" src="${ctx}/assets/lib/layer/3.0.3/layer.js"></script>
  34. <script type="text/javascript" src="${ctx}/assets/lib/ueditor/1.4.3/third-party/highcharts/sand-signika.js"></script>
  35. <script type="text/javascript" src="${ctx}/assets/js/base.js"></script>
  36. <style type="text/css">
  37. .margintop{margin-bottom:5px;}
  38. .placeholder{height:14px;}
  39. </style>
  40. <!--/请在上方写此页面业务相关的脚本-->
  41. <title>柱状图/折线图显示</title>
  42. <meta name="keywords" content="">
  43. <meta name="description" content="">
  44. </head>
  45. <body style="line-height:1;">
  46. <div align="left" style="height: 10px; margin: 2% 0 2% 2%">
  47. <select style="width: 80px" id="retType">
  48. <option value="1">柱状图</option>
  49. <option value="2">折线图</option>
  50. </select>
  51. </div>
  52. <div id="container" align="center"
  53. style="height: 520px; margin: 0 4% 2% 2%"></div>
  54. <script>
  55. //调用查询,加载数据 定义全局变量
  56. var strAppealBeginDate='${AppealDateBegin}';
  57. var strAppealEndDate='${AppealDateEnd}';
  58. var strValidState='${ValidState}';
  59. var strTitle='${ReportType}';
  60. //定义一个索引,便于加载完成后关闭加载动画
  61. var index = "";
  62. //默认加载柱状图
  63. $(function(){
  64. getColimn();
  65. });
  66. //图形切换
  67. $("#retType").change(function(){
  68. var retType = $("#retType").val();
  69. if(retType == 1){
  70. getColimn();
  71. }else{
  72. getLine();
  73. }
  74. });
  75. //折线图
  76. function getLine(){
  77. var chart1;
  78. var options = {
  79. chart: {
  80. renderTo: 'container', //在哪个区域呈现,对应HTML中的一个元素ID
  81. type: 'line',
  82. plotBackgroundColor: "white",//设置绘图区背景色
  83. plotBorderWidth: null,//设置绘图区高度
  84. plotShadow: false//是否设置阴影
  85. },
  86. //图表的主标题
  87. title: {
  88. text: '${StartDate}${ReportName}折线图',
  89. style:{
  90. color: "#000000",
  91. fontSize: "20px",
  92. fontFamily: "宋体"
  93. }
  94. },
  95. credits: {
  96. enabled: false
  97. },
  98. xAxis: {
  99. categories: [
  100. '一月',
  101. '二月',
  102. '三月',
  103. '四月',
  104. '五月',
  105. '六月',
  106. '七月',
  107. '八月',
  108. '九月',
  109. '十月',
  110. '十一月',
  111. '十二月'
  112. ],
  113. crosshair: true
  114. },
  115. yAxis: {
  116. min: 0,
  117. title: {
  118. text: '数量 (件)'
  119. }
  120. },
  121. tooltip: {
  122. headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
  123. pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
  124. '<td style="padding:0"><b>{point.y} 件</b></td></tr>',
  125. footerFormat: '</table>',
  126. shared: true,
  127. useHTML: true
  128. },
  129. //每种图表类型属性设置
  130. plotOptions: {
  131. line: {
  132. dataLabels: {
  133. // 开启数据标签
  134. enabled: true
  135. },
  136. }
  137. },
  138. //数据来源(多个对比的)
  139. series: []
  140. };
  141. $.ajax({
  142. type: "post",
  143. //同步调用,不显示默认为异步
  144. async: false,
  145. url: "${ctx}/myconsole/complaint/report/gettransact1?AppealDateBegin="+strAppealBeginDate+"&AppealDateEnd="+strAppealEndDate+"&ValidState="+strValidState+"&ReportType="+strTitle,
  146. cache: false,
  147. dataType:"json",
  148. //弹出加载动画
  149. beforeSend: function () {
  150. index = layer.msg('加载中...', {
  151. icon: 16 ,shade: 0.05,
  152. });
  153. },
  154. success:function(data){
  155. var i,len=data.length;
  156. options.series = new Array();
  157. for( i=0;i<len;i++){
  158. //赋值 series
  159. var strData = data[i].data;
  160. var dataArr = [];
  161. //遍历数组将字符串转为int
  162. for(var k in strData){
  163. dataArr.push(parseInt(strData[k]));
  164. }
  165. //折线图填充数据
  166. options.series[i] = new Object();
  167. options.series[i].data = dataArr;
  168. options.series[i].name = data[i].name;
  169. }
  170. chart1 = new Highcharts.Chart(options);
  171. },
  172. error:function(e){
  173. alert(请求数据错误);
  174. },
  175. //关闭加载动画
  176. complete: function () {
  177. setTimeout("layer.close("+index+")", 1000 );
  178. },
  179. });
  180. }
  181. //柱状图
  182. function getColimn(){
  183. var chart;
  184. var options1 = {
  185. chart: {
  186. renderTo: 'container', //在哪个区域呈现,对应HTML中的一个元素ID
  187. type: 'column',
  188. plotBackgroundColor: "white",//设置绘图区背景色
  189. plotBorderWidth: null,//设置绘图区高度
  190. plotShadow: false//是否设置阴影
  191. },
  192. //图表的主标题
  193. title: {
  194. text: '${StartDate}${ReportName}柱状图',
  195. style:{
  196. color: "#000000",
  197. fontSize: "20px",
  198. fontFamily: "宋体"
  199. }
  200. },
  201. credits: {
  202. enabled: false
  203. },
  204. xAxis: {
  205. categories: [
  206. '一月',
  207. '二月',
  208. '三月',
  209. '四月',
  210. '五月',
  211. '六月',
  212. '七月',
  213. '八月',
  214. '九月',
  215. '十月',
  216. '十一月',
  217. '十二月'
  218. ],
  219. crosshair: true
  220. },
  221. yAxis: {
  222. min: 0,
  223. title: {
  224. text: '数量 (件)'
  225. }
  226. },
  227. //当鼠标经过时的提示设置
  228. tooltip: {
  229. headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
  230. pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
  231. '<td style="padding:0"><b>{point.y} 件</b></td></tr>',
  232. footerFormat: '</table>',
  233. shared: true,
  234. useHTML: true
  235. },
  236. //每种图表类型属性设置
  237. plotOptions: {
  238. column: {
  239. pointPadding: 0.2,
  240. borderWidth: 1,
  241. dataLabels:{
  242. enabled:true, // dataLabels设为true
  243. /* style:{
  244. color:'#D7DEE9'
  245. } */
  246. }
  247. }
  248. },
  249. //数据来源(多个对比的)
  250. series: []
  251. };
  252. $.ajax({
  253. type: "post",
  254. //同步调用,不显示默认为异步
  255. async: false,
  256. url: "${ctx}/myconsole/complaint/report/gettransact1?AppealDateBegin="+strAppealBeginDate+"&AppealDateEnd="+strAppealEndDate+"&ValidState="+strValidState+"&ReportType="+strTitle,
  257. cache: false,
  258. dataType:"json",
  259. //弹出加载动画
  260. beforeSend: function () {
  261. index = layer.msg('加载中...', {
  262. icon: 16 ,shade: 0.05,
  263. });
  264. },
  265. success:function(data){
  266. var i,len=data.length;
  267. options1.series = new Array();
  268. for( i=0;i<len;i++){
  269. //赋值 series
  270. var strData = data[i].data;
  271. var dataArr = [];
  272. //遍历数组将字符串转为int
  273. for(var k in strData){
  274. dataArr.push(parseInt(strData[k]));
  275. }
  276. //柱状图填充数据
  277. options1.series[i] = new Object();
  278. options1.series[i].data = dataArr;
  279. options1.series[i].name = data[i].name;
  280. }
  281. chart = new Highcharts.Chart(options1);
  282. },
  283. error:function(e){
  284. alert("请求数据错误");
  285. },
  286. //关闭加载动画
  287. complete: function () {
  288. setTimeout("layer.close("+index+")", 1000 );
  289. },
  290. });
  291. }
  292. </script>
  293. </body>
  294. </html>