diff options
| author | 2021-10-16 12:00:07 +0200 | |
|---|---|---|
| committer | 2021-10-16 12:00:07 +0200 | |
| commit | 02641de32ecc6e0e4fd9de030399728080b6ed41 (patch) | |
| tree | c01ce17b89c8225f51a796e0bef589498e56a14f /app/views/stats/index.phtml | |
| parent | ebf9c70ebd4356d98fa7c2513aaab48fa14c7c9b (diff) | |
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 <alexandre@alapetite.fr>
Diffstat (limited to 'app/views/stats/index.phtml')
| -rw-r--r-- | app/views/stats/index.phtml | 54 |
1 files changed, 40 insertions, 14 deletions
diff --git a/app/views/stats/index.phtml b/app/views/stats/index.phtml index db1ccd601..dff20041d 100644 --- a/app/views/stats/index.phtml +++ b/app/views/stats/index.phtml @@ -69,29 +69,55 @@ <div class="stat"> <h2><?= _t('admin.stats.entry_per_day') ?></h2> - <div id="statsEntryPerDay" class="statGraph"></div> + <div> + <canvas id="statsEntriesPerDay"></canvas> + <script class="jsonData-stats" type="application/json"> + <?php + echo json_encode(array( + 'canvasID' => 'statsEntriesPerDay', + 'charttype' => 'barWithAverage', + 'labelBarChart' => _t('admin.stats.entry_count'), + 'dataBarChart' => $this->entryCount, + 'labelAverage' => 'Average ('.$this->average.')', + 'dataAverage' => $this->average, + 'xAxisLabels' => $this->last30DaysLabels, + ), JSON_UNESCAPED_UNICODE); + ?></script> + </div> </div> <div class="stat half"> <h2><?= _t('admin.stats.feed_per_category') ?></h2> - <div id="statsFeedPerCategory" class="statGraph"></div> - <div id="statsFeedPerCategoryLegend"></div> + <div> + <canvas id="statsFeedsPerCategory"></canvas> + <script class="jsonData-stats" type="application/json"> + <?php + echo json_encode(array( + 'canvasID' => 'statsFeedsPerCategory', + 'charttype' => 'doughnut', + 'data' => $this->feedByCategory['data'], + 'labels' => $this->feedByCategory['label'], + ), JSON_UNESCAPED_UNICODE); + ?></script> + </div> </div> <div class="stat half"> <h2><?= _t('admin.stats.entry_per_category') ?></h2> - <div id="statsEntryPerCategory" class="statGraph"></div> - <div id="statsEntryPerCategoryLegend"></div> + <div> + <canvas id="statsEntriesPerCategory"></canvas> + <script class="jsonData-stats" type="application/json"> + <?php + echo json_encode(array( + 'canvasID' => 'statsEntriesPerCategory', + 'charttype' => 'doughnut', + 'data' => $this->entryByCategory['data'], + 'labels' => $this->entryByCategory['label'], + ), JSON_UNESCAPED_UNICODE); + ?></script> + </div> </div> </div> </div> -<script id="jsonStats" type="application/json"><?php -echo json_encode(array( - 'average' => $this->average, - 'dataCount' => $this->count, - 'feedByCategory' => $this->feedByCategory, - 'entryByCategory' => $this->entryByCategory, -), JSON_UNESCAPED_UNICODE); -?></script> -<script src="../scripts/stats.js?<?= @filemtime(PUBLIC_PATH . '/scripts/stats.js') ?>"></script> +<script src="../scripts/statsWithChartjs.js?<?= @filemtime(PUBLIC_PATH . '/scripts/statsWithChartjs.js') ?>"></script> |
