22 lines
1.1 KiB
JavaScript
22 lines
1.1 KiB
JavaScript
function load_visualisation(id){
|
|
$.getJSON('./api.php?call=stats',function(json){
|
|
if(!json || json.status != true || !json.result){
|
|
return;
|
|
}
|
|
json = json.result;
|
|
var data = new google.visualization.DataTable();
|
|
first = true;
|
|
$.each(json[0], function(key, value){
|
|
if(first){
|
|
data.addColumn('datetime',key);
|
|
first = false;
|
|
} else {
|
|
data.addColumn('number',key);
|
|
}
|
|
});
|
|
$.each(json, function(key, value){first = true; data.addRow($.map(value, function(v) { if(first){first=false;return [new Date(v)];}else{return [(v == null || parseFloat(v) <= 0) ? 0 : parseFloat(v)];}}));});
|
|
|
|
var options = {title: id, backgroundColor: 'darkslategrey', aggregationTarget: 'category', selectionMode: 'multiple', curveType: 'function', /*focusTarget: 'category',*/ chartArea:{left:20,top:40}, interpolateNulls: false, height: "200"};
|
|
new google.visualization.LineChart(document.getElementById(id)).draw(data, options);
|
|
});
|
|
} |