logrp-chart.jsp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2. <%@include file="/context/mytags.jsp"%>
  3. <!DOCTYPE html>
  4. <html>
  5. <head>
  6. <t:base type="jquery"></t:base>
  7. <link rel="stylesheet" type="text/css" href="plug-in/ichart/css/gallery.css"></link>
  8. <script type="text/javascript" src="plug-in/ichart/js/ichart-1.0.js"></script>
  9. <!-- <script src="webpage/jeecg/cgdynamgraph/core/cgDynamGraphDesignMobile.js"></script> -->
  10. <style type="text/css">
  11. #canvasLineDiv{
  12. position: absolute;
  13. top: 550px;
  14. }
  15. </style>
  16. </head>
  17. <script type="text/javascript">
  18. $(function(){
  19. var logsData=eval('${logs}');
  20. var xAxisCategories = new Array();
  21. var yArr = new Array();
  22. for(var i = 0; i < logsData.length; i++){
  23. xAxisCategories[i] = logsData[i].name;
  24. yArr[i]=logsData[i].value;
  25. }
  26. var chart1=new iChart.Column2D({
  27. id:"mychart",
  28. render : 'canvasDiv',
  29. data: logsData,
  30. title : '用户浏览器使用次数统计柱状图',
  31. //showpercent:true,
  32. //decimalsnum:2,
  33. width : 800,
  34. height : 500,
  35. coordinate:{
  36. background_color:'#fefefe',
  37. scale:[{
  38. position:'left',
  39. start_scale:0,
  40. end_scale:4000,
  41. scale_space:500,
  42. /* listeners:{
  43. parseText:function(t,x,y){
  44. return {text:t+"%"}
  45. }
  46. } */
  47. }]
  48. }
  49. });
  50. chart1.draw();
  51. window.onresize=function(){
  52. dosize(chart1);
  53. }
  54. var data = [
  55. {
  56. name : '浏览器',
  57. value:yArr,
  58. color:'#1f7e92',
  59. line_width:3
  60. }
  61. ];
  62. var chart2 = new iChart.LineBasic2D({
  63. render : 'canvasLineDiv',
  64. data: data,
  65. title : '用户浏览器使用次数统计折线图',
  66. width : 800,
  67. height : 400,
  68. coordinate:{height:'90%',background_color:'#f6f9fa'},
  69. sub_option:{
  70. hollow_inside:false,//设置一个点的亮色在外环的效果
  71. point_size:16
  72. },
  73. labels:xAxisCategories
  74. });
  75. chart2.draw();
  76. });
  77. function dosize(obj){
  78. //var chart = $.get('mychart');//根据ID获取图表对象
  79. //chart.eventOn();
  80. //console.log(chart);
  81. //chart.push("column_width",null);//设置为null则每次重新计算柱子宽度
  82. // 获取窗口宽度
  83. if (window.innerWidth)
  84. var winWidth = window.innerWidth;
  85. else if ((document.body) && (document.body.clientWidth))
  86. winWidth = document.body.clientWidth;
  87. // 获取窗口高度
  88. if (window.innerHeight)
  89. var winHeight = window.innerHeight;
  90. else if ((document.body) && (document.body.clientHeight))
  91. winHeight = document.body.clientHeight;
  92. // 通过深入 Document 内部对 body 进行检测,获取窗口大小
  93. if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth)
  94. {
  95. winHeight = document.documentElement.clientHeight;
  96. winWidth = document.documentElement.clientWidth;
  97. }
  98. chart.resize(winWidth*0.8,winHeight*0.8);
  99. }
  100. </script>
  101. <body>
  102. <div style="height:1000px">
  103. <div id="canvasDiv" style="width: 100%; position: absolute;left:0px"></div>
  104. <div id="canvasLineDiv" style="width: 80%; height:50%"></div>
  105. </div>
  106. </body>
  107. </html>