repartition.phtml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php $this->partial('aside_stats'); ?>
  2. <div class="post content">
  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')?>"></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 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 href="<?php echo _url('configure', 'feed', 'id', $this->feed->id()); ?>">
  24. <?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">
  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">
  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. Flotr.draw(document.getElementById('statsEntryPerHour'),
  52. [<?php echo $this->repartitionHour ?>],
  53. {
  54. grid: {verticalLines: false},
  55. bars: {horizontal: false, show: true},
  56. xaxis: {noTicks: 23,
  57. tickFormatter: function(x) {
  58. var x = parseInt(x);
  59. return x + 1;
  60. },
  61. min: -0.9,
  62. max: 23.9,
  63. tickDecimals: 0},
  64. yaxis: {min: 0},
  65. mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}}
  66. });
  67. // Entry per day of week
  68. Flotr.draw(document.getElementById('statsEntryPerDayOfWeek'),
  69. [<?php echo $this->repartitionDayOfWeek ?>],
  70. {
  71. grid: {verticalLines: false},
  72. bars: {horizontal: false, show: true},
  73. xaxis: {noTicks: 6,
  74. tickFormatter: function(x) {
  75. var x = parseInt(x),
  76. days = <?php echo $this->days?>;
  77. return days[x];
  78. },
  79. min: -0.9,
  80. max: 6.9,
  81. tickDecimals: 0},
  82. yaxis: {min: 0},
  83. mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}}
  84. });
  85. // Entry per month
  86. Flotr.draw(document.getElementById('statsEntryPerMonth'),
  87. [<?php echo $this->repartitionMonth ?>],
  88. {
  89. grid: {verticalLines: false},
  90. bars: {horizontal: false, show: true},
  91. xaxis: {noTicks: 12,
  92. tickFormatter: function(x) {
  93. var x = parseInt(x),
  94. months = <?php echo $this->months?>;
  95. return months[(x - 1)];
  96. },
  97. min: 0.1,
  98. max: 12.9,
  99. tickDecimals: 0},
  100. yaxis: {min: 0},
  101. mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}}
  102. });
  103. }
  104. initStats();
  105. </script>