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.

96 lines
3.3 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">유입경로별 접속 통계</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="row">
  17. <div class="col-sm-6">
  18. <div style="max-width:400px;margin:auto">
  19. <h4 class="text-center">유입경로별 접속 통계</h4>
  20. <canvas id="chart-browser" width="200" height="200"></canvas>
  21. </div>
  22. </div>
  23. <div class="col-sm-6">
  24. <div data-ax5grid>
  25. <table>
  26. <thead>
  27. <tr>
  28. <th>키워드</th>
  29. <th>접속수</th>
  30. </tr>
  31. </thead>
  32. <tbody>
  33. <?php foreach($statics['list'] as $row):?>
  34. <tr>
  35. <td class="text-center"><?=$row['sta_referrer_host']?></td>
  36. <td class="text-right"><?=number_format($row['count'])?> (<?=$statics['total']>0? round($row['count']/$statics['total']*100,2):0?>%)</td>
  37. </tr>
  38. <?php endforeach;?>
  39. <?php if(count($statics['list']) == 0):?>
  40. <tr>
  41. <td class="empty" colspan="2">키워드로 접속한 기록이 없습니다.</td>
  42. </tr>
  43. <?php endif;?>
  44. </tbody>
  45. <tfoot>
  46. <tr>
  47. <td class="text-center">TOTAL</td>
  48. <td class="text-right"><?=number_format($statics['total'])?></td>
  49. </tr>
  50. </tfoot>
  51. </table>
  52. </div>
  53. </div>
  54. </div>
  55. <script>
  56. $(function(){
  57. var $chart = $("#chart-browser");
  58. var chart_data = <?=$statics['counts']?>;
  59. var chart = new Chart($chart, {
  60. type: 'pie',
  61. data: {
  62. labels: <?=$statics['sta_referrer_host']?>,
  63. datasets: [{
  64. label : '# %',
  65. data: chart_data,
  66. backgroundColor : randomColorGenerator(chart_data.length)
  67. }]
  68. },
  69. options : {
  70. animation : {
  71. animateScale:true
  72. },
  73. legend: {
  74. labels : {
  75. fontColor : '#fff'
  76. }
  77. }
  78. }
  79. });
  80. });
  81. var randomColorGenerator = function (count) {
  82. var ret = [];
  83. for(i=0; i<count;i++)
  84. {
  85. ret.push( '#' + (Math.random().toString(16) + '0000000').slice(2, 8) );
  86. }
  87. return ret;
  88. };
  89. </script>