You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think there is a bug in bargraph.js in the for-loop on lines 64 thru 90.
The outer for-loop iterates through the items in data.
The inner for-loop iterates through the keys in each item.
In the inner for-loop, you check to see if the key matches a string. If it matches, you change an attribute in tmp and then push it to object[]. The problem is, there are multiple keys in each data item, so tmp gets pushed to object[] multiple times.
The text was updated successfully, but these errors were encountered:
You want to move object.push(tmp) outside and after the inner for-loop but inside the outer for-loop.
//Convert the data from the controller
//Should be mobed to controller
for (var i = 0; i < data.length; i++){ //for every element in data array
var tmp = {};
for(var key in data[i]){ //for every attribute of the element
compItem = key;;
//see if it matches one of the following terms and add value and key to tmp
if (compItem == "dns_name"){
tmp.dns_name = data[i][key];
object.push(tmp); //<=== REMOVE!!!
}
else if(compItem == "datacenter_id" || compItem == "host_id"){
tmp.group = data[i][key];
object.push(tmp); //<=== REMOVE!!!
}
else if(compItem == "gathered"){
tmp.gathered = data[i][key];
object.push(tmp); //<=== REMOVE!!!
}
else if(compItem == "destination_ip" || compItem == "source_ip" ){
tmp.dns_name = (data[i].destination_ip
+ " - " + data[i].source_ip);
object.push(tmp); //<=== REMOVE!!!
}
else if(data[i].hasOwnProperty(key)){
tmp.data = data[i][key];
object.push(tmp); //<=== REMOVE!!!
}
}
//*********** ADD IT HERE ****************
}
//Set up graph
console.log(object);
makeGraph(object, compItem);
}, "json");
I think there is a bug in bargraph.js in the for-loop on lines 64 thru 90.
The outer for-loop iterates through the items in data.
The inner for-loop iterates through the keys in each item.
In the inner for-loop, you check to see if the key matches a string. If it matches, you change an attribute in tmp and then push it to object[]. The problem is, there are multiple keys in each data item, so tmp gets pushed to object[] multiple times.
The text was updated successfully, but these errors were encountered: