From 02641de32ecc6e0e4fd9de030399728080b6ed41 Mon Sep 17 00:00:00 2001 From: maTh Date: Sat, 16 Oct 2021 12:00:07 +0200 Subject: Stats: replace flotr2 with chart.js (#3858) * include Chart.js * page: main statistics. Flotr.js replaced with Chart.js * main stats + repartition * Delete: repartition.js + stats.js * delete flotr2 * add libs in README * polish * code polish * fixed amount of week days and months * added manget link for LibreJS * added: @license-end * phpcbf + jshint formatting * delete old code * fix stats * fix Comments * finally I found the issue and fixed its best * fix the month stats * Whitespace fixes * Remove flotr2 * Rename to chart.min.js * Remove console.log Co-authored-by: Alexandre Alapetite --- p/scripts/stats.js | 67 ------------------------------------------------------ 1 file changed, 67 deletions(-) delete mode 100644 p/scripts/stats.js (limited to 'p/scripts/stats.js') diff --git a/p/scripts/stats.js b/p/scripts/stats.js deleted file mode 100644 index 7e02868a3..000000000 --- a/p/scripts/stats.js +++ /dev/null @@ -1,67 +0,0 @@ -// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0 -"use strict"; -/* globals Flotr, numberFormat */ -/* jshint esversion:6, strict:global */ - -function initStats() { - if (!window.Flotr) { - if (window.console) { - console.log('FreshRSS waiting for Flotr…'); - } - window.setTimeout(initStats, 50); - return; - } - const jsonStats = document.getElementById('jsonStats'), - stats = JSON.parse(jsonStats.innerHTML); - // Entry per day - const avg = []; - for (let i = -31; i <= 0; i++) { - avg.push([i, stats.average]); - } - Flotr.draw(document.getElementById('statsEntryPerDay'), - [{ - data: stats.dataCount, - bars: {horizontal: false, show: true} - },{ - data: avg, - lines: {show: true}, - label: stats.average, - }], - { - grid: {verticalLines: false}, - xaxis: {noTicks: 6, showLabels: false, tickDecimals: 0, min: -30.75, max: -0.25}, - yaxis: {min: 0}, - mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function (obj) { return numberFormat(obj.y); }}, - }); - // Feed per category - Flotr.draw(document.getElementById('statsFeedPerCategory'), - stats.feedByCategory, - { - grid: {verticalLines: false, horizontalLines: false}, - pie: {explode: 10, show: true, labelFormatter: function(){return '';}}, - xaxis: {showLabels: false}, - yaxis: {showLabels: false}, - mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function (obj) { - return obj.series.label + ' - ' + numberFormat(obj.y) + ' (' + (obj.fraction * 100).toFixed(1) + '%)'; - }}, - legend: {container: document.getElementById('statsFeedPerCategoryLegend'), noColumns: 3} - }); - // Entry per category - Flotr.draw(document.getElementById('statsEntryPerCategory'), - stats.entryByCategory, - { - grid: {verticalLines: false, horizontalLines: false}, - pie: {explode: 10, show: true, labelFormatter: function () { return ''; }}, - xaxis: {showLabels: false}, - yaxis: {showLabels: false}, - mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function (obj) { - return obj.series.label + ' - ' + numberFormat(obj.y) + ' (' + (obj.fraction * 100).toFixed(1) + '%)'; - }}, - legend: {container: document.getElementById('statsEntryPerCategoryLegend'), noColumns: 3} - }); -} -initStats(); - -window.addEventListener('resize', initStats); - -// @license-end -- cgit v1.2.3