userMonitor.blade.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. @extends('admin.layouts')
  2. @section('content')
  3. <div class="page-content container-fluid">
  4. <div class="panel">
  5. <div class="panel-heading">
  6. <h2 class="panel-title">用户流量</h2>
  7. </div>
  8. <div class="alert alert-info alert-dismissible">
  9. <button class="close" data-dismiss="alert" aria-label="Close"><span
  10. aria-hidden="true">&times;</span><span class="sr-only">{{trans('home.close')}}</span>
  11. </button>
  12. <h4 class="block">{{$email}}</h4>
  13. <strong>提示:</strong> 月流量统计不会统计当天,日流量统计不会统计当前小时;如果无统计数据,请检查定时任务是否正常。(每月1日和每日0时因为没有统计流量,不显示流量)
  14. </div>
  15. <div class="panel-body">
  16. <div class="row">
  17. <div class="col-md-6">
  18. <canvas id="dailyChart" aria-label="小时流量图" role="img"></canvas>
  19. </div>
  20. <div class="col-md-6">
  21. <canvas id="monthlyChart" aria-label="月流量图" role="img"></canvas>
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. @endsection
  28. @section('script')
  29. <script src="/assets/global/vendor/chart-js/Chart.min.js" type="text/javascript"></script>
  30. <script type="text/javascript">
  31. const dailyChart = new Chart(document.getElementById('dailyChart').getContext('2d'), {
  32. type: 'line',
  33. data: {
  34. labels: {{$dayHours}},
  35. datasets: [{
  36. fill: true,
  37. backgroundColor: "rgba(98, 168, 234, .1)",
  38. borderColor: Config.colors("primary", 600),
  39. pointRadius: 4,
  40. borderDashOffset: 2,
  41. pointBorderColor: "#fff",
  42. pointBackgroundColor: Config.colors("primary", 600),
  43. pointHoverBackgroundColor: "#fff",
  44. pointHoverBorderColor: Config.colors("primary", 600),
  45. data: {{$trafficHourly}},
  46. }]
  47. },
  48. options: {
  49. legend: {
  50. display: false
  51. },
  52. responsive: true,
  53. scales: {
  54. xAxes: [{
  55. display: true,
  56. scaleLabel: {
  57. display: true,
  58. labelString: '小时'
  59. }
  60. }],
  61. yAxes: [{
  62. display: true,
  63. ticks: {
  64. beginAtZero: true,
  65. userCallback: function (tick) {
  66. return tick.toString() + ' GB';
  67. }
  68. },
  69. scaleLabel: {
  70. display: true,
  71. labelString: '{{trans('home.traffic_log_24hours')}}'
  72. }
  73. }]
  74. }
  75. }
  76. });
  77. const monthlyChart = new Chart(document.getElementById('monthlyChart').getContext('2d'), {
  78. type: 'line',
  79. data: {
  80. labels: {{$monthDays}},
  81. datasets: [{
  82. fill: true,
  83. backgroundColor: "rgba(98, 168, 234, .1)",
  84. borderColor: Config.colors("primary", 600),
  85. pointRadius: 4,
  86. borderDashOffset: 2,
  87. pointBorderColor: "#fff",
  88. pointBackgroundColor: Config.colors("primary", 600),
  89. pointHoverBackgroundColor: "#fff",
  90. pointHoverBorderColor: Config.colors("primary", 600),
  91. data: {{$trafficDaily}},
  92. }]
  93. },
  94. options: {
  95. legend: {
  96. display: false
  97. },
  98. responsive: true,
  99. scales: {
  100. xAxes: [{
  101. display: true,
  102. scaleLabel: {
  103. display: true,
  104. labelString: '天'
  105. }
  106. }],
  107. yAxes: [{
  108. display: true,
  109. ticks: {
  110. beginAtZero: true,
  111. userCallback: function (tick) {
  112. return tick.toString() + ' GB';
  113. }
  114. },
  115. scaleLabel: {
  116. display: true,
  117. labelString: '{{trans('home.traffic_log_30days')}}'
  118. }
  119. }]
  120. }
  121. }
  122. });
  123. </script>
  124. @endsection