monitor.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. function drawLayer02Label(canvasObj,text,textBeginX,lineEndX){
  2. var colorValue = '#04918B';
  3. var ctx = canvasObj.getContext("2d");
  4. ctx.beginPath();
  5. ctx.arc(35,55,2,0,2*Math.PI);
  6. ctx.closePath();
  7. ctx.fillStyle = colorValue;
  8. ctx.fill();
  9. ctx.moveTo(35,55);
  10. ctx.lineTo(60,80);
  11. ctx.lineTo(lineEndX,80);
  12. ctx.lineWidth = 1;
  13. ctx.strokeStyle = colorValue;
  14. ctx.stroke();
  15. ctx.font='12px Georgia';
  16. ctx.fillStyle = colorValue;
  17. ctx.fillText(text,textBeginX,92);
  18. }
  19. //接入机型占比
  20. var COLOR = {
  21. MACHINE:{
  22. TYPE_A:'#0175EE',
  23. TYPE_B:'#D89446',
  24. TYPE_C:'#373693',
  25. TYPE_D:'#25AE4F',
  26. TYPE_E:'#06B5C6',
  27. TYPE_F:'#009E9A',
  28. TYPE_G:'#AC266F'
  29. }
  30. };
  31. function renderLegend(){
  32. drawLegend(COLOR.MACHINE.TYPE_A,25,'A机型');
  33. drawLegend(COLOR.MACHINE.TYPE_B,50,'B机型');
  34. drawLegend(COLOR.MACHINE.TYPE_C,75,'C机型');
  35. drawLegend(COLOR.MACHINE.TYPE_D,100,'D机型');
  36. drawLegend(COLOR.MACHINE.TYPE_E,125,'E机型');
  37. drawLegend(COLOR.MACHINE.TYPE_F,150,'F机型');
  38. drawLegend(COLOR.MACHINE.TYPE_G,175,'G机型');
  39. }
  40. function drawLegend(pointColor,pointY,text){
  41. var ctx = $("#layer03_left_01 canvas").get(0).getContext("2d");
  42. ctx.beginPath();
  43. ctx.arc(20,pointY,6,0,2*Math.PI);
  44. ctx.fillStyle = pointColor;
  45. ctx.fill();
  46. ctx.font='20px';
  47. ctx.fillStyle = '#FEFFFE';
  48. ctx.fillText(text,40,pointY+3);
  49. }
  50. //存储
  51. function renderLayer03Right(){
  52. drawLayer03Right($("#layer03_right_chart01 canvas").get(0),"#027825",0.66);
  53. drawLayer03Right($("#layer03_right_chart02 canvas").get(0),"#006DD6",0.52);
  54. drawLayer03Right($("#layer03_right_chart03 canvas").get(0),"#238681",0.34);
  55. }
  56. function drawLayer03Right(canvasObj,colorValue,rate){
  57. var ctx = canvasObj.getContext("2d");
  58. var circle = {
  59. x : 65, //圆心的x轴坐标值
  60. y : 80, //圆心的y轴坐标值
  61. r : 60 //圆的半径
  62. };
  63. //画扇形
  64. //ctx.sector(circle.x,circle.y,circle.r,1.5*Math.PI,(1.5+rate*2)*Math.PI);
  65. //ctx.fillStyle = colorValue;
  66. //ctx.fill();
  67. ctx.beginPath();
  68. ctx.arc(circle.x,circle.y,circle.r,0,Math.PI*2)
  69. ctx.lineWidth = 10;
  70. ctx.strokeStyle = '#052639';
  71. ctx.stroke();
  72. ctx.closePath();
  73. ctx.beginPath();
  74. ctx.arc(circle.x,circle.y,circle.r,1.5*Math.PI,(1.5+rate*2)*Math.PI)
  75. ctx.lineWidth = 10;
  76. ctx.lineCap = 'round';
  77. ctx.strokeStyle = colorValue;
  78. ctx.stroke();
  79. ctx.closePath();
  80. ctx.fillStyle = 'white';
  81. ctx.font = '20px Calibri';
  82. ctx.fillText(rate*100+'%',circle.x-15,circle.y+10);
  83. }
  84. function renderChartBar01(){
  85. var myChart = echarts.init(document.getElementById("layer03_left_02"));
  86. myChart.setOption(
  87. {
  88. title : {
  89. text: '',
  90. subtext: '',
  91. x:'center'
  92. },
  93. tooltip : {
  94. trigger: 'item',
  95. formatter: "{b} : {c} ({d}%)"
  96. },
  97. legend: {
  98. show:false,
  99. x : 'center',
  100. y : 'bottom',
  101. data:['A机型','B机型','C机型','D机型','E机型','F机型','G机型']
  102. },
  103. toolbox: {
  104. },
  105. label:{
  106. normal:{
  107. show: true,
  108. formatter: "{b} \n{d}%"
  109. }
  110. },
  111. calculable : true,
  112. color:[COLOR.MACHINE.TYPE_A,COLOR.MACHINE.TYPE_B,COLOR.MACHINE.TYPE_C,COLOR.MACHINE.TYPE_D,COLOR.MACHINE.TYPE_E,COLOR.MACHINE.TYPE_F,COLOR.MACHINE.TYPE_G],
  113. series : [
  114. {
  115. name:'',
  116. type:'pie',
  117. radius : [40, 80],
  118. center : ['50%', '50%'],
  119. //roseType : 'area',
  120. data:[
  121. {value:4600, name:'A机型'},
  122. {value:4600, name:'B机型'},
  123. {value:15600, name:'C机型'},
  124. {value:6600, name:'D机型'},
  125. {value:5700, name:'E机型'},
  126. {value:7600, name:'F机型'},
  127. {value:3500, name:'G机型'}
  128. ]
  129. }
  130. ]
  131. }
  132. );
  133. }
  134. /*
  135. function renderChartBar02(){
  136. var myChart = echarts.init(document.getElementById("layer03_left_03"));
  137. myChart.setOption(
  138. {
  139. title : {
  140. text: '',
  141. subtext: '',
  142. x:'center'
  143. },
  144. tooltip : {
  145. show:true,
  146. trigger: 'item',
  147. formatter: "上线率<br>{b} : {c} ({d}%)"
  148. },
  149. legend: {
  150. show:false,
  151. orient: 'vertical',
  152. left: 'left',
  153. data: ['A机型','B机型','C机型','D机型','E机型','F机型','G机型']
  154. },
  155. series : [
  156. {
  157. name: '',
  158. type: 'pie',
  159. radius : '50%',
  160. center: ['50%', '60%'],
  161. data:[
  162. {value:7600, name:'A机型'},
  163. {value:6600, name:'B机型'},
  164. {value:15600, name:'C机型'},
  165. {value:5700, name:'D机型'},
  166. {value:4600, name:'E机型'},
  167. {value:4600, name:'F机型'},
  168. {value:3500, name:'G机型'}
  169. ],
  170. itemStyle: {
  171. emphasis: {
  172. shadowBlur: 10,
  173. shadowOffsetX: 0,
  174. shadowColor: 'rgba(0, 0, 0, 0.5)'
  175. }
  176. }
  177. }
  178. ],
  179. color:[COLOR.MACHINE.TYPE_A,COLOR.MACHINE.TYPE_B,COLOR.MACHINE.TYPE_C,COLOR.MACHINE.TYPE_D,COLOR.MACHINE.TYPE_E,COLOR.MACHINE.TYPE_F,COLOR.MACHINE.TYPE_G]
  180. }
  181. );
  182. }*/
  183. function renderLayer04Left(){
  184. var myChart = echarts.init(document.getElementById("layer04_left_chart"));
  185. myChart.setOption(
  186. {
  187. title: {
  188. text: ''
  189. },
  190. tooltip : {
  191. trigger: 'axis'
  192. },
  193. legend: {
  194. data:[]
  195. },
  196. grid: {
  197. left: '3%',
  198. right: '4%',
  199. bottom: '5%',
  200. top:'4%',
  201. containLabel: true
  202. },
  203. xAxis :
  204. {
  205. type : 'category',
  206. boundaryGap : false,
  207. data : getLatestDays(31),
  208. axisLabel:{
  209. textStyle:{
  210. color:"white", //刻度颜色
  211. fontSize:8 //刻度大小
  212. },
  213. rotate:45,
  214. interval:2
  215. },
  216. axisTick:{show:false},
  217. axisLine:{
  218. show:true,
  219. lineStyle:{
  220. color: '#0B3148',
  221. width: 1,
  222. type: 'solid'
  223. }
  224. }
  225. },
  226. yAxis :
  227. {
  228. type : 'value',
  229. axisTick:{show:false},
  230. axisLabel:{
  231. textStyle:{
  232. color:"white", //刻度颜色
  233. fontSize:8 //刻度大小
  234. }
  235. },
  236. axisLine:{
  237. show:true,
  238. lineStyle:{
  239. color: '#0B3148',
  240. width: 1,
  241. type: 'solid'
  242. }
  243. },
  244. splitLine:{
  245. show:false
  246. }
  247. },
  248. tooltip:{
  249. formatter:'{c}',
  250. backgroundColor:'#FE8501'
  251. },
  252. series : [
  253. {
  254. name:'',
  255. type:'line',
  256. smooth:true,
  257. areaStyle:{
  258. normal:{
  259. color:new echarts.graphic.LinearGradient(0, 0, 0, 1, [{offset: 0, color: '#026B6F'}, {offset: 1, color: '#012138' }], false),
  260. opacity:0.2
  261. }
  262. },
  263. itemStyle : {
  264. normal : {
  265. color:'#009991'
  266. },
  267. lineStyle:{
  268. normal:{
  269. color:'#009895',
  270. opacity:1
  271. }
  272. }
  273. },
  274. symbol:'none',
  275. data:[48, 52, 45, 46, 89, 120, 110,100,88,96,88,45,78,67,89,103,104,56,45,104,112,132,120,110,89,95,90,89,102,110,110]
  276. }
  277. ]
  278. }
  279. );
  280. }
  281. function renderLayer04Right(){
  282. var myChart = echarts.init(document.getElementById("layer04_right_chart"));
  283. myChart.setOption({
  284. title: {
  285. text: ''
  286. },
  287. tooltip: {
  288. trigger: 'axis'
  289. },
  290. legend: {
  291. top:20,
  292. right:5,
  293. textStyle:{
  294. color:'white'
  295. },
  296. orient:'vertical',
  297. data:[
  298. {name:'网络',icon:'circle'},
  299. {name:'内存',icon:'circle'},
  300. {name:'CPU',icon:'circle'}
  301. ]
  302. },
  303. grid: {
  304. left: '3%',
  305. right: '16%',
  306. bottom: '3%',
  307. top:'3%',
  308. containLabel: true
  309. },
  310. xAxis: {
  311. type: 'category',
  312. boundaryGap: false,
  313. axisTick:{show:false},
  314. axisLabel:{
  315. textStyle:{
  316. color:"white", //刻度颜色
  317. fontSize:8 //刻度大小
  318. }
  319. },
  320. axisLine:{
  321. show:true,
  322. lineStyle:{
  323. color: '#0B3148',
  324. width: 1,
  325. type: 'solid'
  326. }
  327. },
  328. data: get10MinutesScale()
  329. },
  330. yAxis: {
  331. type: 'value',
  332. axisTick:{show:false},
  333. axisLabel:{
  334. textStyle:{
  335. color:"white", //刻度颜色
  336. fontSize:8 //刻度大小
  337. }
  338. },
  339. axisLine:{
  340. show:true,
  341. lineStyle:{
  342. color: '#0B3148',
  343. width: 1,
  344. type: 'solid'
  345. }
  346. },
  347. splitLine:{
  348. show:false
  349. }
  350. },
  351. series: [
  352. {
  353. name:'网络',
  354. type:'line',
  355. itemStyle : {
  356. normal : {
  357. color:'#F3891B'
  358. },
  359. lineStyle:{
  360. normal:{
  361. color:'#F3891B',
  362. opacity:1
  363. }
  364. }
  365. },
  366. data:[120, 132, 101, 134, 90, 230, 210]
  367. },
  368. {
  369. name:'内存',
  370. type:'line',
  371. itemStyle : {
  372. normal : {
  373. color:'#006AD4'
  374. },
  375. lineStyle:{
  376. normal:{
  377. color:'#F3891B',
  378. opacity:1
  379. }
  380. }
  381. },
  382. data:[220, 182, 191, 234, 290, 330, 310]
  383. },
  384. {
  385. name:'CPU',
  386. type:'line',
  387. itemStyle : {
  388. normal : {
  389. color:'#009895'
  390. },
  391. lineStyle:{
  392. normal:{
  393. color:'#009895',
  394. opacity:1
  395. }
  396. }
  397. },
  398. data:[150, 232, 201, 154, 190, 330, 410]
  399. }
  400. ]
  401. }
  402. );
  403. }
  404. function get10MinutesScale()
  405. {
  406. var currDate = new Date();
  407. var odd = currDate.getMinutes()%10;
  408. var returnArr = new Array();
  409. currDate.setMinutes(currDate.getMinutes()-odd);
  410. for(var i = 0; i <7; i++){
  411. returnArr.push(currDate.getHours()+":"+(currDate.getMinutes()<10?("0"+currDate.getMinutes()):currDate.getMinutes()));
  412. currDate.setMinutes(currDate.getMinutes()-10);
  413. }
  414. return returnArr;
  415. }
  416. function getLatestDays(num)
  417. {
  418. var currentDay = new Date();
  419. var returnDays = [];
  420. for (var i = 0 ; i < num ; i++)
  421. {
  422. currentDay.setDate(currentDay.getDate() - 1);
  423. returnDays.push((currentDay.getMonth()+1)+"/"+currentDay.getDate());
  424. }
  425. return returnDays;
  426. }