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.

151 lines
5.2 KiB

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