chartstat.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <head>
  2. <link rel="stylesheet" href="/static/css/common.css"/>
  3. <link rel="stylesheet" href="/static/layui/css/layui.css" media="all"/>
  4. <script type="text/javascript" src="/static/layui/layui.js"></script>
  5. <script type="text/javascript" src="/static/js/jquery.min.js"></script>
  6. <script type="text/javascript" src="/static/js/echarts.min.js"></script>
  7. <style type="text/css">
  8. .layout_dialog {
  9. background: linear-gradient(39deg, #081531 0%, #233d76 100%);
  10. overflow: hidden;
  11. outline: 0;
  12. border-radius: 2px;
  13. position: fixed !important;
  14. z-index: 10000;
  15. color: #B9E3FF;
  16. border: 1px solid #62A9FF;
  17. display: none;
  18. left: 50%;
  19. top: 50%;
  20. }
  21. .layout_close {
  22. background-image: url(/static/images/btn_close.png);
  23. width: 14px;
  24. height: 14px;
  25. float: right;
  26. background-repeat: no-repeat;
  27. margin: 12px 15px 0 0;
  28. cursor: pointer;
  29. }
  30. .person_info_title {
  31. float: left;
  32. width: 100%;
  33. height: 3rem;
  34. line-height: 3rem;
  35. background-color: rgb(29, 38, 71);
  36. text-align: center;
  37. color: #fff;
  38. letter-spacing: 1px;
  39. font-size: 1rem;
  40. }
  41. .clearn {
  42. background: #000000 !important;
  43. opacity: 0.7;
  44. width: 100%;
  45. height: 100%;
  46. z-index: 102;
  47. position: absolute;
  48. left: 0;
  49. top: 0;
  50. line-height: 0;
  51. font-size: 0;
  52. overflow: hidden;
  53. display: none;
  54. }
  55. .layui-form-radio{
  56. padding:0 !important;
  57. margin: 0 !important;
  58. }
  59. </style>
  60. </head>
  61. <div class="layui-form" lay-filter="example" style="margin:20px auto 0 auto;width:93%;" id="add_container">
  62. <div class="layui-row">
  63. <div class="layui-col-md12" id="cycletype" style="height: 2rem;line-height: 2rem;width: 100%;">
  64. <span>统计周期:</span>
  65. <span style="margin-right: 1.2rem;"><input lay-filter="cycletype" name="cycletype" type="radio" value="year">年</span>
  66. <span style="margin-right: 1.2rem;"><input lay-filter="cycletype" name="cycletype" type="radio" value="month">月</span>
  67. <span style="margin-right: 1.2rem;"><input lay-filter="cycletype" name="cycletype" type="radio" value="week">周</span>
  68. <span style="margin-right: 1.2rem;"><input lay-filter="cycletype" name="cycletype" type="radio" value="day">日</span>
  69. <span style="margin-right: 1.2rem;"><input lay-filter="cycletype" name="cycletype" type="radio" checked="" value="hour">时</span>
  70. </div>
  71. <div class="layui-col-md12" id="echarts" style="height: 20rem;width: 100%;">
  72. </div>
  73. </div>
  74. <div class="layui-row" id="otherdata" style="background-color: #f2f2f2;">
  75. <table style="width: 100%;text-align: center;line-height: 1.5rem;">
  76. <thead style="font-weight: bold;font-size: 1rem;color: #aa8989;border-bottom: 1px solid #e1d4d4;">
  77. <tr><td width="20%">系统事件量</td><td width="20%">业务事件量</td><td width="20%">操作类型统计</td><td width="20%">用户量</td><td width="20%">IP量</td></tr>
  78. </thead>
  79. <tbody>
  80. <tr>
  81. <td><span id="systemevent_num">-</span></td><td><span id="busevent_num">-</span></td><td><span id="opttype_num">-</span></td><td><span id="staff_num">-</span></td><td><span id="ip_num">-</span></td>
  82. </tr>
  83. </tbody>
  84. </table>
  85. </div>
  86. </div>
  87. <script type="text/javascript">
  88. var TypeColor = "#134BEA";
  89. $(document).ready(function () {
  90. layui.use(['layer', 'form'], function () {
  91. loadData("");
  92. layui.form.on('radio(cycletype)', function(data){
  93. //console.log(data.elem); //得到radio原始DOM对象
  94. //console.log(data.value); //被点击的radio的value值
  95. var v = data.value;//被点击的radio的value值
  96. loadData(v);
  97. });
  98. /*
  99. parent.$.getJSON("/api/log/datastat",{"startdate":startdate,"enddate":enddate},function(jsodnata){
  100. })*/
  101. });
  102. });
  103. function loadData(cycletype){
  104. var startdate=parent.$("#text_startdate").val();
  105. var enddate=parent.$("#text_startdate").val();
  106. parent.$.getJSON("/api/log/chartstat",{"startdate":startdate,"enddate":enddate,"cycletype":cycletype},function(jsodnata){
  107. if(jsodnata.code!=0){
  108. layer.msg(jsodnata.msg);
  109. return;
  110. }
  111. for (var i = 0; i < jsodnata.data.eventstat.length; i++) {
  112. var item=jsodnata.data.eventstat[i];
  113. if(item.eventtype==0) $("#systemevent_num").html(item.num);
  114. if(item.eventtype==1) $("#busevent_num").html(item.num);
  115. }
  116. $("#opttype_num").html(jsodnata.data.optypestat.length);
  117. $("#staff_num").html(jsodnata.data.staffstat.length);
  118. $("#ip_num").html(jsodnata.data.ipstat.length);
  119. var linedata=jsodnata.data["list"];
  120. var XData=[],YData=[];
  121. for (var i = 0; i < linedata.length; i++) {
  122. XData.push(linedata[i]["dt"]);
  123. YData.push(linedata[i]["num"]);
  124. }
  125. var chartDom = document.getElementById("echarts");
  126. echarts.init(chartDom).dispose();
  127. var myChart = echarts.init(chartDom);
  128. var option = {
  129. grid: {
  130. top: '15%',
  131. left: '13%',
  132. right: '10%',
  133. bottom: '20%',
  134. },
  135. xAxis: [{
  136. type: 'category',
  137. boundaryGap: true, //柱子是否不从0开始
  138. axisLine: { //坐标轴轴线相关设置。数学上的x轴
  139. show: true,
  140. lineStyle: {
  141. color: '#000'
  142. },
  143. },
  144. axisLabel: { //坐标轴刻度标签的相关设置
  145. interval: 0, //显示全部标签
  146. rotate: -30,
  147. textStyle: {
  148. color: '#000',
  149. padding: 0,
  150. fontSize: 12
  151. }
  152. },
  153. splitLine: {
  154. show: false
  155. },
  156. axisTick: {
  157. show: false,
  158. },
  159. data: XData
  160. }],
  161. yAxis: [{
  162. name: "条",
  163. nameTextStyle: {
  164. color: "#000",
  165. fontSize: 10 ,
  166. padding: 0
  167. },
  168. min: 0,
  169. splitLine: {
  170. show: true,
  171. lineStyle: {
  172. type: "dashed",
  173. color: '#000'
  174. }
  175. },
  176. axisLine: {
  177. show: false,
  178. lineStyle: {
  179. color: "#F3F5FA"
  180. }
  181. },
  182. axisLabel: {
  183. show: true,
  184. textStyle: {
  185. color: '#000',
  186. fontSize: 10 ,
  187. padding: 0
  188. }
  189. },
  190. axisTick: {
  191. show: false,
  192. },
  193. }],
  194. series: [{
  195. type: 'line',
  196. label: {
  197. show: true,
  198. position: 'top',
  199. textStyle: {
  200. color: TypeColor,
  201. }
  202. },
  203. itemStyle: {
  204. color: TypeColor,
  205. //borderColor: TypeColor,
  206. //borderWidth: 2,
  207. barBorderRadius: [10, 10, 0, 0]
  208. },
  209. tooltip: {
  210. show: false
  211. },
  212. data: YData
  213. }]
  214. };
  215. option && myChart.setOption(option);
  216. })
  217. }
  218. </script>