trafficLog.blade.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. @extends('user.layouts')
  2. @section('css')
  3. @endsection
  4. @section('title', '控制面板')
  5. @section('content')
  6. <!-- BEGIN CONTENT BODY -->
  7. <div class="page-content">
  8. <!-- BEGIN PAGE BREADCRUMB -->
  9. <ul class="page-breadcrumb breadcrumb">
  10. <li>
  11. <a href="{{url('user/trafficLog')}}">流量日志</a>
  12. <i class="fa fa-circle"></i>
  13. </li>
  14. </ul>
  15. <!-- END PAGE BREADCRUMB -->
  16. <!-- BEGIN PAGE BASE CONTENT -->
  17. <div class="row">
  18. <div class="col-md-12">
  19. <div class="portlet light bordered">
  20. <div class="portlet-title">
  21. <div class="caption">
  22. <i class="icon-settings font-dark"></i>
  23. <span class="caption-subject font-dark sbold uppercase">流量日志</span>
  24. </div>
  25. </div>
  26. <div class="portlet-body">
  27. <div id="chart" class="chart"> </div>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. <!-- END PAGE BASE CONTENT -->
  33. </div>
  34. <!-- END CONTENT BODY -->
  35. @endsection
  36. @section('script')
  37. <script src="/assets/global/plugins/flot/jquery.flot.min.js" type="text/javascript"></script>
  38. <script src="/assets/global/plugins/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
  39. <script src="/assets/global/plugins/bootbox/bootbox.min.js" type="text/javascript"></script>
  40. <script type="text/javascript">
  41. var ChartsFlotcharts = function() {
  42. return {
  43. init: function() {
  44. App.addResizeHandler(function() {
  45. Charts.initPieCharts();
  46. });
  47. },
  48. initCharts: function() {
  49. if (!jQuery.plot) {
  50. return;
  51. }
  52. function chart() {
  53. if ($('#chart').size() != 1) {
  54. return;
  55. }
  56. var chartData = [
  57. @if (!empty($trafficList))
  58. @foreach ($trafficList as $key => $vo)
  59. [{{$key + 1}}, {{$vo->total}}],
  60. @endforeach
  61. @endif
  62. ];
  63. var plot = $.plot($("#chart"), [
  64. {data: chartData, label: "30日流量走势", lines: {lineWidth: 1}, shadowSize: 0},
  65. ], {
  66. series: {
  67. lines: {
  68. show: true,
  69. lineWidth: 2,
  70. fill: true,
  71. fillColor: {
  72. colors: [{
  73. opacity: 0.05
  74. }, {
  75. opacity: 0.01
  76. }]
  77. }
  78. },
  79. points: {
  80. show: true,
  81. radius: 3,
  82. lineWidth: 1
  83. },
  84. shadowSize: 2
  85. },
  86. grid: {
  87. hoverable: true,
  88. clickable: true,
  89. tickColor: "#eee",
  90. borderColor: "#eee",
  91. borderWidth: 1
  92. },
  93. colors: ["#d12610", "#37b7f3", "#52e136"],
  94. xaxis: {
  95. ticks: 11,
  96. tickDecimals: 0,
  97. tickColor: "#eee",
  98. },
  99. yaxis: {
  100. ticks: 11,
  101. tickDecimals: 0,
  102. tickColor: "#eee",
  103. }
  104. });
  105. function showTooltip(x, y, contents) {
  106. $('<div id="tooltip">' + contents + '</div>').css({
  107. position: 'absolute',
  108. display: 'none',
  109. top: y + 5,
  110. left: x + 15,
  111. border: '1px solid #333',
  112. padding: '4px',
  113. color: '#fff',
  114. 'border-radius': '3px',
  115. 'background-color': '#333',
  116. opacity: 0.80
  117. }).appendTo("body").fadeIn(200);
  118. }
  119. var previousPoint = null;
  120. $("#chart").bind("plothover", function(event, pos, item) {
  121. $("#x").text(pos.x.toFixed(2));
  122. $("#y").text(pos.y.toFixed(2));
  123. if (item) {
  124. if (previousPoint != item.dataIndex) {
  125. previousPoint = item.dataIndex;
  126. $("#tooltip").remove();
  127. var x = item.datapoint[0].toFixed(2),
  128. y = item.datapoint[1].toFixed(2);
  129. showTooltip(item.pageX, item.pageY, item.series.label + ": " + y + 'M');
  130. }
  131. } else {
  132. $("#tooltip").remove();
  133. previousPoint = null;
  134. }
  135. });
  136. }
  137. chart();
  138. }
  139. };
  140. }();
  141. jQuery(document).ready(function() {
  142. ChartsFlotcharts.init();
  143. ChartsFlotcharts.initCharts();
  144. });
  145. </script>
  146. @endsection