repartition.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. "use strict";
  2. function initStats() {
  3. if (!window.Flotr) {
  4. if (window.console) {
  5. console.log('FreshRSS waiting for Flotr…');
  6. }
  7. window.setTimeout(initStats, 50);
  8. return;
  9. }
  10. var jsonRepartition = document.getElementById('jsonRepartition'),
  11. stats = JSON.parse(jsonRepartition.innerHTML);
  12. jsonRepartition.outerHTML = '';
  13. // Entry per hour
  14. Flotr.draw(document.getElementById('statsEntryPerHour'),
  15. [{
  16. data: stats.repartitionHour,
  17. bars: {horizontal: false, show: true}
  18. }],
  19. {
  20. grid: {verticalLines: false},
  21. xaxis: {noTicks: 23,
  22. tickFormatter: function(x) {
  23. var x = parseInt(x);
  24. return x + 1;
  25. },
  26. min: -0.9,
  27. max: 23.9,
  28. tickDecimals: 0},
  29. yaxis: {min: 0},
  30. mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}}
  31. });
  32. // Entry per day of week
  33. Flotr.draw(document.getElementById('statsEntryPerDayOfWeek'),
  34. [{
  35. data: stats.repartitionDayOfWeek,
  36. bars: {horizontal: false, show: true}
  37. }],
  38. {
  39. grid: {verticalLines: false},
  40. xaxis: {noTicks: 6,
  41. tickFormatter: function(x) {
  42. var x = parseInt(x);
  43. return stats.days[x];
  44. },
  45. min: -0.9,
  46. max: 6.9,
  47. tickDecimals: 0},
  48. yaxis: {min: 0},
  49. mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}}
  50. });
  51. // Entry per month
  52. Flotr.draw(document.getElementById('statsEntryPerMonth'),
  53. [{
  54. data: stats.repartitionMonth,
  55. bars: {horizontal: false, show: true}
  56. }],
  57. {
  58. grid: {verticalLines: false},
  59. xaxis: {noTicks: 12,
  60. tickFormatter: function(x) {
  61. var x = parseInt(x);
  62. return stats.months[(x - 1)];
  63. },
  64. min: 0.1,
  65. max: 12.9,
  66. tickDecimals: 0},
  67. yaxis: {min: 0},
  68. mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}}
  69. });
  70. }
  71. initStats();