I am creating a graph in javascript and I need to extract my data from my JSON input. the input comes in like this [object1,object2,...*, x_axis_data] There can be indefinite amount of objects and the data can vary. Each object has a group attribute so I can further classify them. Each object always will have a key corresponding to an entry on the x_axis_data array. Ex.
x_axis_data = [Mon, Tue, Wed];
obj1 = {"group":"first","Mon":"1","Tue":"15","Wed":"22"};
obj1 = {"group":"second","Mon":"9","Tue":"13","Wed":"21"};
I have managed to separate the x_axis_data from the rest of the array and now I have 2 arrays - one for x_axis_data and one containing the objects.
for(var z in data){ //loop through all of the object properties
var val_inner_lst = []; //array of the object data for current object
group.push(data[z].group); //add the group to a separate array
for (var i=0; i<interval.length; i++){
val_inner_lst.push(data[z]+"."+interval[i]); //where my error happens
}
values.push(val_inner_lst); //add the individual array to the main array
}
expected result:
group = [first, seconds];
values = [[1,15,22][9,13,21]];
interval = [Mon, Tue, Wed];