From 8f99caa42ccd53072a26dbf1833d2f999104aeea Mon Sep 17 00:00:00 2001 From: Mickael Date: Sun, 1 Sep 2019 20:40:49 +0200 Subject: [PATCH] First refacto on stat.js --- site/coa/stats/index.html | 153 +------------------------------------- site/coa/stats/stats.js | 52 +++++++++++++ 2 files changed, 53 insertions(+), 152 deletions(-) create mode 100644 site/coa/stats/stats.js diff --git a/site/coa/stats/index.html b/site/coa/stats/index.html index e06272d..1dc927b 100644 --- a/site/coa/stats/index.html +++ b/site/coa/stats/index.html @@ -2,6 +2,7 @@ + Statistiques du chat (aussi connu sous le nom de mare aux crapauds) : @@ -9,157 +10,5 @@ - diff --git a/site/coa/stats/stats.js b/site/coa/stats/stats.js new file mode 100644 index 0000000..162f39b --- /dev/null +++ b/site/coa/stats/stats.js @@ -0,0 +1,52 @@ +$(document).ready(function () { + $.getJSON("../../data/chat_stat_monthly.json", function (datas) { + updated = datas['updated'] + + labels = datas['labels']; + + graphDisplay($('#byChannel'), datas['messagesByChannel'], "Nombre de message par canaux (" + updated + ")"); + + graphDisplay($('#byTsunamy'), datas['messagesByTsunamy'], "Nombre de message par Tsunami (" + updated + ")"); + + graphDisplay($("#usersByChannel"), datas['usersByChannel'], "Nombre d'utilisateur actifs par canaux (" + updated + ")"); + + graphDisplay($("#usersGlobal"), datas['usersGlobal'], "Nombre d'utilisateur actifs (" + updated + ")"); + }); +}); + +function graphDisplay(ctx, datas, title) { + var chart = new Chart(ctx, { + // The type of chart we want to create + type: 'bar', + + // The data for our dataset + data: { + labels: labels, + datasets: datas, + }, + + // Configuration options go here + options: { + legend: { + display: false + }, + title: { + display: true, + text: title, + position: "top" + }, + responsive: true, + scales: { + xAxes: [{ + stacked: true + }], + yAxes: [{ + stacked: true, + ticks: { + stepSize: 500 + } + }] + } + } + }); +} \ No newline at end of file