portail/site/coa/stats/stats.js
2019-09-04 19:05:26 +02:00

65 lines
2.2 KiB
JavaScript

$(document).ready(function () {
$.getJSON("../../data/chat_stat_monthly.json", function (data) {
updated = data['updated']
labels = data['labels'];
graphDisplay($('#byChannel'), data['messagesByChannel'], "Nombre de message par canaux sur 1 an (" + updated + ")");
graphDisplay($('#byTsunamy'), data['messagesByTsunamy'], "Nombre de message par Tsunami sur 1 an (" + updated + ")");
graphDisplay($("#usersByChannel"), data['usersByChannel'], "Nombre d'utilisateur actifs par canaux sur 1 an (" + updated + ")");
graphDisplay($("#usersGlobal"), data['usersGlobal'], "Nombre d'utilisateur actifs sur 1 an (" + updated + ")");
});
$.getJSON("../../data/chat_stat_daily.json", function (data) {
updated = data['updated']
labels = data['labels'];
graphDisplay($('#byChannel_daily'), data['messagesByChannel'], "Nombre de message par canaux sur 30 jours (" + updated + ")");
graphDisplay($('#byTsunamy_daily'), data['messagesByTsunamy'], "Nombre de message par Tsunami sur 30 jours (" + updated + ")");
graphDisplay($("#usersByChannel_daily"), data['usersByChannel'], "Nombre d'utilisateur actifs par canaux sur 30 jours (" + updated + ")");
graphDisplay($("#usersGlobal_daily"), data['usersGlobal'], "Nombre d'utilisateur actifs sur 30 jours (" + updated + ")");
});
});
function graphDisplay(ctx, data, 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: data,
},
// 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
}
}]
}
}
});
}