userMonitor.blade.php 4.7 KB

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