25 lines
1.1 KiB
JavaScript
25 lines
1.1 KiB
JavaScript
var visual_id = null;
|
|
function load_visualisation(id){
|
|
visual_id = id;
|
|
sys.call('call=stats',handle_visualisation_result,{},'json',true);
|
|
}
|
|
|
|
function handle_visualisation_result(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: visual_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(visual_id)).draw(data, options);
|
|
} |