I am facing an issue with the second loop within a function that goes through a JSON file. The problem is that it only returns the last item in the array. I need to figure out how to fix this because the chart object should be created on each iteration, based on my understanding.
var looper = function(sec0, vz, lOrR) {
$('#' + lOrR + 'Title').text(sec0);
for (var i = 0; i < vz[0]['Areas'].length; i++) {
var tText = Object.keys(vz[0]['Areas'][i]);
var root = vz[0]['Areas'][i][tText][0];
barFactory(root, sec0, lOrR, i, tText);
}
function barFactory(sec1, sec0, lOrR, i, tText) {
var dataName;
for (var j = 0; j < sec1[sec0].length; j++) {
charts.title.text = sec1[sec0][j]["Label"];
dataName = sec1[sec0][j]['Metrics'][5]['Rep Res. %'].slice(0, -1);
charts.series[0].name = dataName;
charts.series[0].data = [parseFloat(dataName)];
chart = new Highcharts.Chart(charts);
}
}
}