You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
4.9 KiB

7 years ago
  1. <?=$this->site->add_js("https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.6.0/Chart.min.js")?>
  2. <?=$this->site->add_js("https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.6.0/Chart.bundle.min.js")?>
  3. <div class="page-header">
  4. <h1 class="page-title">PC / Mobile 접속 통계</h1>
  5. </div>
  6. <?=form_open(NULL, array('method'=>'get','class'=>'form-flex','autocomplete'=>'off'))?>
  7. <div class="form-group">
  8. <label class="control-label">일자 검색</label>
  9. <div class="controls">
  10. <input class="form-control form-control-inline" name="startdate" data-toggle="datepicker" value="<?=$startdate?>">
  11. <input class="form-control form-control-inline" name="enddate" data-toggle="datepicker" value="<?=$enddate?>">
  12. <button class="btn btn-default"><i class="far fa-search"></i> 필터적용</button>
  13. </div>
  14. </div>
  15. <?=form_close()?>
  16. <div class="H10"></div>
  17. <div class="row">
  18. <div class="col-sm-6">
  19. <div style="max-width:400px;margin:auto">
  20. <h4 class="text-center">PC/모바일 접속 통계</h4>
  21. <canvas id="chart-device" width="200" height="200"></canvas>
  22. </div>
  23. <div class="H30"></div>
  24. <div style="max-width:400px;margin:auto">
  25. <h4 class="text-center">모바일 기기별 통계</h4>
  26. <canvas id="chart-mobile-device" width="200" height="200"></canvas>
  27. </div>
  28. </div>
  29. <div class="col-sm-6">
  30. <h4>기기별 통계</h4>
  31. <div data-ax5grid>
  32. <table>
  33. <thead>
  34. <tr>
  35. <th class="text-center">기기</th>
  36. <th class="text-center">접속 </th>
  37. </tr>
  38. </thead>
  39. <tbody>
  40. <tr>
  41. <td class="text-center">PC</td>
  42. <td class="text-right"><?=number_format($statics['sum']['pc']['count'])?> (<?=$statics['sum']['mobile']['count']?>%)</td>
  43. </tr>
  44. <tr>
  45. <td class="text-center">Mobile</td>
  46. <td class="text-right"><?=number_format($statics['sum']['mobile']['count'])?> (<?=$statics['sum']['mobile']['count']?>%)</td>
  47. </tr>
  48. </tbody>
  49. </table>
  50. </div>
  51. <div class="H30"></div>
  52. <h4>일자별 통계</h4>
  53. <div data-ax5grid>
  54. <table>
  55. <thead>
  56. <tr>
  57. <th class="text-center">일자</th>
  58. <th class="text-center">PC</th>
  59. <th class="text-center">Mobile</th>
  60. <th class="text-center">Total</th>
  61. </tr>
  62. </thead>
  63. <tbody>
  64. <?php foreach($statics['list'] as $date=>$row):?>
  65. <tr>
  66. <td class="text-center"><?=$date?></td>
  67. <td class="text-right"><?=number_format($row['pc'])?></td>
  68. <td class="text-right"><?=number_format($row['mobile'])?></td>
  69. <td class="text-right"><?=number_format($row['total'])?></td>
  70. </tr>
  71. <?php endforeach;?>
  72. </tbody>
  73. </table>
  74. </div>
  75. </div>
  76. </div>
  77. <div class="H30"></div>
  78. <script>
  79. $(function(){
  80. var $chart = $("#chart-device");
  81. var $chart_mobile = $("#chart-mobile-device");
  82. var chart = new Chart($chart, {
  83. type: 'pie',
  84. data: {
  85. labels: ["PC", "Mobile"],
  86. datasets: [{
  87. label : '# %',
  88. data: [ <?=$statics['sum']['pc']['count']?>, <?=$statics['sum']['mobile']['count']?>],
  89. backgroundColor : ['rgb(255, 99, 132)','rgb(54, 162, 235)']
  90. }]
  91. },
  92. options : {
  93. animation : {
  94. animateScale:true
  95. },
  96. legend: {
  97. labels : {
  98. fontColor : '#fff'
  99. }
  100. }
  101. }
  102. });
  103. var mobile_chart_data = <?=$statics['device_counts']?>;
  104. var mobile_chart = new Chart($chart_mobile, {
  105. type: 'pie',
  106. data: {
  107. labels: <?=$statics['device_list']?>,
  108. datasets: [{
  109. data: mobile_chart_data,
  110. backgroundColor : randomColorGenerator(mobile_chart_data.length)
  111. }]
  112. },
  113. options : {
  114. animation : {
  115. animateScale:true
  116. },
  117. legend: {
  118. labels : {
  119. fontColor : '#fff'
  120. }
  121. }
  122. }
  123. });
  124. });
  125. var randomColorGenerator = function (count) {
  126. var ret = [];
  127. for(i=0; i<count;i++)
  128. {
  129. ret.push( '#' + (Math.random().toString(16) + '0000000').slice(2, 8) );
  130. }
  131. return ret;
  132. };
  133. </script>