clean kfet statistic.js
- no longer dictToArray where it isn't necessary (because already an array) - fix chart height: - previous charts were causing bugs - height is fixed (even with window resizing) - clean whitespaces
This commit is contained in:
parent
87bc90ec8b
commit
903da795ab
|
@ -22,16 +22,16 @@
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleTimeChart (dict) {
|
function handleTimeChart (data) {
|
||||||
// reads the balance data and put it into chartjs formatting
|
// 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++) {
|
for (var i = 0; i < data.length; i++) {
|
||||||
var source = data[i];
|
var source = data[i];
|
||||||
data[i] = { x: new Date(source.at),
|
chart_data[i] = { x: new Date(source.at),
|
||||||
y: source.balance,
|
y: source.balance,
|
||||||
label: source.label }
|
label: source.label }
|
||||||
}
|
}
|
||||||
return data;
|
return chart_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showStats () {
|
function showStats () {
|
||||||
|
@ -77,6 +77,7 @@
|
||||||
var chart_options =
|
var chart_options =
|
||||||
{
|
{
|
||||||
responsive: true,
|
responsive: true,
|
||||||
|
maintainAspectRatio: false,
|
||||||
tooltips: {
|
tooltips: {
|
||||||
mode: 'index',
|
mode: 'index',
|
||||||
intersect: false,
|
intersect: false,
|
||||||
|
@ -129,7 +130,7 @@
|
||||||
type: 'line',
|
type: 'line',
|
||||||
options: chart_options,
|
options: chart_options,
|
||||||
data: {
|
data: {
|
||||||
labels: dictToArray(data.labels, 1),
|
labels: (data.labels || []).slice(1),
|
||||||
datasets: chart_datasets,
|
datasets: chart_datasets,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -137,15 +138,15 @@
|
||||||
// saves the previous charts to be destroyed
|
// saves the previous charts to be destroyed
|
||||||
var prev_chart = content.children();
|
var prev_chart = content.children();
|
||||||
|
|
||||||
|
// clean
|
||||||
|
prev_chart.remove();
|
||||||
|
|
||||||
// creates a blank canvas element and attach it to the DOM
|
// creates a blank canvas element and attach it to the DOM
|
||||||
var canvas = $("<canvas height='70'>");
|
var canvas = $("<canvas height='250'>");
|
||||||
content.append(canvas);
|
content.append(canvas);
|
||||||
|
|
||||||
// create the chart
|
// create the chart
|
||||||
var chart = new Chart(canvas, chart_model);
|
var chart = new Chart(canvas, chart_model);
|
||||||
|
|
||||||
// clean
|
|
||||||
prev_chart.remove();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize the interface
|
// initialize the interface
|
||||||
|
|
Loading…
Reference in a new issue