Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

153 wiersze
5.0 KiB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>收发查看</title>
  6. <script src="https://unpkg.com/dayjs"></script>
  7. <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  8. <script src="/echarts.min.js"></script>
  9. </head>
  10. <body>
  11. <div id="tcpContainer" style="text-align:center;margin:20px auto;width:80%;height: 300px;"></div>
  12. <div id="connContainer" style="text-align:center;margin:20px auto;width:80%;height: 300px;"></div>
  13. <script type="text/javascript">
  14. var tcpDom = document.getElementById("tcpContainer");
  15. var connDom = document.getElementById("connContainer");
  16. var tcpChart = echarts.init(tcpDom);
  17. var connChart = echarts.init(connDom);
  18. var sendData=[];
  19. var receiveData=[];
  20. var onlineData=[];
  21. var offlineData=[];
  22. var timeData=[];
  23. var tcpOption = {
  24. title: {
  25. text: 'TCP收发数'
  26. },
  27. tooltip: {
  28. trigger: 'axis',
  29. axisPointer: {
  30. animation: true
  31. }
  32. },
  33. legend: {
  34. data:['发送总次数','接收总次数']
  35. },
  36. xAxis: {
  37. type: 'category',
  38. boundaryGap: false,
  39. data: timeData
  40. },
  41. yAxis: {
  42. type: 'value',
  43. boundaryGap: [0, '100%'],
  44. splitLine: {
  45. show: true
  46. }
  47. },
  48. series: [{
  49. name: '发送总次数',
  50. type: 'line',
  51. color: "blue",
  52. data: sendData
  53. },{
  54. name: '接收总次数',
  55. type: 'line',
  56. color: "red",
  57. data: receiveData
  58. }]
  59. };
  60. var connOption = {
  61. title: {
  62. text: 'TCP连接数'
  63. },
  64. tooltip: {
  65. trigger: 'axis',
  66. axisPointer: {
  67. animation: true
  68. }
  69. },
  70. legend: {
  71. data:['tcp在线数','tcp离线数']
  72. },
  73. xAxis: {
  74. type: 'category',
  75. boundaryGap: false,
  76. data: timeData
  77. },
  78. yAxis: {
  79. type: 'value',
  80. boundaryGap: [0, '100%'],
  81. splitLine: {
  82. show: true
  83. }
  84. },
  85. series: [{
  86. name: 'tcp在线数',
  87. type: 'line',
  88. color: "blue",
  89. data: onlineData
  90. },{
  91. name: 'tcp离线数',
  92. type: 'line',
  93. color: "red",
  94. data: offlineData
  95. }]
  96. };
  97. setInterval(function () {
  98. axios.post('http://localhost:5000/JT808WebApi/QueryReport')
  99. .then((response) => {
  100. if (response.data) {
  101. if(sendData.length>16){
  102. sendData.shift();
  103. receiveData.shift();
  104. onlineData.shift();
  105. offlineData.shift();
  106. timeData.shift();
  107. }
  108. //console.log(response.data);
  109. timeData.push(dayjs(response.data.currentDate).format('HH:mm:ss'));
  110. sendData.push(response.data.sendTotalCount);
  111. receiveData.push(response.data.receiveTotalCount);
  112. onlineData.push(response.data.onlineConnections);
  113. offlineData.push(response.data.offlineConnections);
  114. tcpChart.setOption({
  115. series: [{
  116. data: sendData
  117. },{
  118. data: receiveData
  119. }],
  120. xAxis:[{
  121. data: timeData
  122. }]
  123. });
  124. connChart.setOption({
  125. series: [{
  126. data: onlineData
  127. },{
  128. data: offlineData
  129. }],
  130. xAxis:[{
  131. data: timeData
  132. }]
  133. });
  134. } else {
  135. alert("没有数据");
  136. }
  137. })
  138. .catch((error) => {
  139. console.log(error);
  140. });
  141. }, 1000);
  142. if (tcpOption && typeof tcpOption === "object") {
  143. tcpChart.setOption(tcpOption, true);
  144. }
  145. if (connOption && typeof connOption === "object") {
  146. connChart.setOption(connOption, true);
  147. }
  148. </script>
  149. </body>
  150. </html>