repartition.phtml 3.5 KB

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