repartition.phtml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php $this->partial('aside_stats'); ?>
  2. <div class="post ">
  3. <a href="<?php echo _url('index', 'index'); ?>"><?php echo _t('back_to_rss_feeds'); ?></a>
  4. <h1><?php echo _t('stats_repartition'); ?></h1>
  5. <select id="feed_select">
  6. <option data-url="<?php echo _url('stats', 'repartition')?>"><?php echo _t('all_feeds')?></option>
  7. <?php foreach ($this->categories as $category) {
  8. $feeds = $category->feeds();
  9. if (!empty($feeds)) {
  10. echo '<optgroup label="', $category->name(), '">';
  11. foreach ($feeds as $feed) {
  12. if ($this->feed && $feed->id() == $this->feed->id()){
  13. echo '<option value="', $feed->id(), '" selected="selected" data-url="', _url('stats', 'repartition', 'id', $feed->id()), '">', $feed->name(), '</option>';
  14. } else {
  15. echo '<option value="', $feed->id(), '" data-url="', _url('stats', 'repartition', 'id', $feed->id()), '">', $feed->name(), '</option>';
  16. }
  17. }
  18. echo '</optgroup>';
  19. }
  20. }?>
  21. </select>
  22. <?php if ($this->feed) {?>
  23. <a class="btn" href="<?php echo _url('configure', 'feed', 'id', $this->feed->id()); ?>">
  24. <?php echo _i('configure'); ?> <?php echo _t('administration'); ?>
  25. </a>
  26. <?php }?>
  27. <div class="stat">
  28. <h2><?php echo _t('stats_entry_per_hour'); ?></h2>
  29. <div id="statsEntryPerHour" style="height: 300px"></div>
  30. </div>
  31. <div class="stat half">
  32. <h2><?php echo _t('stats_entry_per_day_of_week'); ?></h2>
  33. <div id="statsEntryPerDayOfWeek" style="height: 300px"></div>
  34. </div><!--
  35. --><div class="stat half">
  36. <h2><?php echo _t('stats_entry_per_month'); ?></h2>
  37. <div id="statsEntryPerMonth" style="height: 300px"></div>
  38. </div>
  39. </div>
  40. <script>
  41. "use strict";
  42. function initStats() {
  43. if (!window.Flotr) {
  44. if (window.console) {
  45. console.log('FreshRSS waiting for Flotr…');
  46. }
  47. window.setTimeout(initStats, 50);
  48. return;
  49. }
  50. // Entry per hour
  51. var avg_h = [];
  52. for (var i = -1; i <= 24; i++) {
  53. avg_h.push([i, <?php echo $this->averageHour?>]);
  54. }
  55. Flotr.draw(document.getElementById('statsEntryPerHour'),
  56. [{
  57. data: <?php echo $this->repartitionHour ?>,
  58. bars: {horizontal: false, show: true}
  59. }, {
  60. data: avg_h,
  61. lines: {show: true},
  62. label: <?php echo $this->averageHour?>,
  63. yaxis: 2
  64. }],
  65. {
  66. grid: {verticalLines: false},
  67. xaxis: {noTicks: 23,
  68. tickFormatter: function(x) {
  69. var x = parseInt(x);
  70. return x + 1;
  71. },
  72. min: -0.9,
  73. max: 23.9,
  74. tickDecimals: 0},
  75. yaxis: {min: 0},
  76. y2axis: {showLabels: false},
  77. mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}}
  78. });
  79. // Entry per day of week
  80. var avg_dow = [];
  81. for (var i = -1; i <= 7; i++) {
  82. avg_dow.push([i, <?php echo $this->averageDayOfWeek?>]);
  83. }
  84. Flotr.draw(document.getElementById('statsEntryPerDayOfWeek'),
  85. [{
  86. data: <?php echo $this->repartitionDayOfWeek ?>,
  87. bars: {horizontal: false, show: true}
  88. }, {
  89. data: avg_dow,
  90. lines: {show: true},
  91. label: <?php echo $this->averageDayOfWeek?>,
  92. yaxis: 2
  93. }],
  94. {
  95. grid: {verticalLines: false},
  96. xaxis: {noTicks: 6,
  97. tickFormatter: function(x) {
  98. var x = parseInt(x),
  99. days = <?php echo $this->days?>;
  100. return days[x];
  101. },
  102. min: -0.9,
  103. max: 6.9,
  104. tickDecimals: 0},
  105. yaxis: {min: 0},
  106. y2axis: {showLabels: false},
  107. mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}}
  108. });
  109. // Entry per month
  110. var avg_m = [];
  111. for (var i = 0; i <= 13; i++) {
  112. avg_m.push([i, <?php echo $this->averageMonth?>]);
  113. }
  114. Flotr.draw(document.getElementById('statsEntryPerMonth'),
  115. [{
  116. data: <?php echo $this->repartitionMonth ?>,
  117. bars: {horizontal: false, show: true}
  118. }, {
  119. data: avg_m,
  120. lines: {show: true},
  121. label: <?php echo $this->averageMonth?>,
  122. yaxis: 2
  123. }],
  124. {
  125. grid: {verticalLines: false},
  126. xaxis: {noTicks: 12,
  127. tickFormatter: function(x) {
  128. var x = parseInt(x),
  129. months = <?php echo $this->months?>;
  130. return months[(x - 1)];
  131. },
  132. min: 0.1,
  133. max: 12.9,
  134. tickDecimals: 0},
  135. yaxis: {min: 0},
  136. y2axis: {showLabels: false},
  137. mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}}
  138. });
  139. }
  140. initStats();
  141. </script>