I am trying to remap data using JavaScript
data[year].map(function(val1,index1){
for(var prop in val1){
if (plotdata[prop] === undefined)
plotdata[prop] = new Array();
if (plotdata[prop][year] === undefined)
plotdata[prop][year] = new Array();
plotdata[prop][year][index1] = val1[prop];
}
});
data is an array with a key "2012".
plotdata is also an array.
data['2012'] contains 12 months, indexed from 0 to 11. I am trying to remap the data so I can access it like plotdata[property][year][month], but the problem is that plotdata is empty after the mapping.
I have checked and val1[prop] does indeed have a value. What could be the problem here?
Per the above comment-thread . . . this:
should instead be this:
because you want an associative array with years as keys, not a length-2,013 regular array.