Skip to content

Commit

Permalink
nvd3 stacked graphs missed data fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kulikov-a committed Feb 17, 2022
1 parent 542dbbb commit 3df5b54
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,29 @@ POSSIBILITY OF SUCH DAMAGE.
var selected_time = get_time_select();
const fetch_params = selected_time.from + '/' + selected_time.to + '/' + selected_time.resolution + '/if,direction' ;
ajaxGet('/api/diagnostics/networkinsight/timeserie/FlowInterfaceTotals/bps/' + fetch_params,{},function(data,status){
// data preparation. arrays must be the same length for nvd3 graphs stacking
// add zero values for missing times (interface not present in time range part or some)
// get "0,in" data as a base
let x_base = data[0]['values'];
let t_base = [];
$.each(x_base, function(i,v) {
t_base.push(v[0]);
});
$.each(data, function(key, val) {
if (val['values'].length < x_base.length) {
let t_cur = [];
$.each(val['values'], function(i, v){
t_cur.push(v[0]);
});
$.each(t_base, function(i, t){
if (t_cur.indexOf(t) == -1) {
data[key]['values'].push([t, 0]);
console.log("time added for " + val['key'] + ": " + t);
}
});
}
});
// data ready
$.each(['chart_intf_in', 'chart_intf_out'], function(idx, target) {
let direction = '';
if (target == 'chart_intf_in') {
Expand Down

0 comments on commit 3df5b54

Please sign in to comment.