diff --git a/kfet/static/kfet/js/statistic.js b/kfet/static/kfet/js/statistic.js
index f6d21237..9593c9f7 100644
--- a/kfet/static/kfet/js/statistic.js
+++ b/kfet/static/kfet/js/statistic.js
@@ -1,10 +1,10 @@
(function($){
window.StatsGroup = function (url, target) {
// a class to properly display statictics
-
+
// url : points to an ObjectResumeStat that lists the options through JSON
// target : element of the DOM where to put the stats
-
+
var self = this;
var element = $(target);
var content = $("
");
@@ -22,21 +22,21 @@
return array;
}
- function handleTimeChart (dict) {
+ function handleTimeChart (data) {
// reads the balance data and put it into chartjs formatting
- var data = dictToArray(dict, 0);
+ chart_data = new Array();
for (var i = 0; i < data.length; i++) {
var source = data[i];
- data[i] = { x: new Date(source.at),
+ chart_data[i] = { x: new Date(source.at),
y: source.balance,
label: source.label }
}
- return data;
+ return chart_data;
}
-
+
function showStats () {
// CALLBACK : called when a button is selected
-
+
// shows the focus on the correct button
buttons.find(".focus").removeClass("focus");
$(this).addClass("focus");
@@ -50,14 +50,14 @@
var chart_datasets = [];
var charts = dictToArray(data.charts);
-
+
// are the points indexed by timestamps?
var is_time_chart = data.is_time_chart || false;
// reads the charts data
for (var i = 0; i < charts.length; i++) {
var chart = charts[i];
-
+
// format the data
var chart_data = is_time_chart ? handleTimeChart(chart.values) : dictToArray(chart.values, 1);
@@ -77,6 +77,7 @@
var chart_options =
{
responsive: true,
+ maintainAspectRatio: false,
tooltips: {
mode: 'index',
intersect: false,
@@ -129,25 +130,25 @@
type: 'line',
options: chart_options,
data: {
- labels: dictToArray(data.labels, 1),
+ labels: (data.labels || []).slice(1),
datasets: chart_datasets,
}
};
// saves the previous charts to be destroyed
var prev_chart = content.children();
-
+
+ // clean
+ prev_chart.remove();
+
// creates a blank canvas element and attach it to the DOM
- var canvas = $("