userMonitor.blade.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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">{{$username}}</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. },
  64. scaleLabel: {
  65. display: true,
  66. labelString: '{{trans('home.traffic_log_24hours')}}'
  67. }
  68. }]
  69. }
  70. }
  71. });
  72. const monthlyChart = new Chart(document.getElementById('monthlyChart').getContext('2d'), {
  73. type: 'line',
  74. data: {
  75. labels: [{!! $monthDays !!}],
  76. datasets: [{
  77. fill: true,
  78. backgroundColor: "rgba(98, 168, 234, .1)",
  79. borderColor: Config.colors("primary", 600),
  80. pointRadius: 4,
  81. borderDashOffset: 2,
  82. pointBorderColor: "#fff",
  83. pointBackgroundColor: Config.colors("primary", 600),
  84. pointHoverBackgroundColor: "#fff",
  85. pointHoverBorderColor: Config.colors("primary", 600),
  86. data: [{!! $trafficDaily !!}],
  87. }]
  88. },
  89. options: {
  90. legend: {
  91. display: false
  92. },
  93. responsive: true,
  94. scales: {
  95. xAxes: [{
  96. display: true,
  97. scaleLabel: {
  98. display: true,
  99. labelString: '天'
  100. }
  101. }],
  102. yAxes: [{
  103. display: true,
  104. ticks: {
  105. beginAtZero: true,
  106. },
  107. scaleLabel: {
  108. display: true,
  109. labelString: '{{trans('home.traffic_log_30days')}}'
  110. }
  111. }]
  112. }
  113. }
  114. });
  115. </script>
  116. @endsection