D3.js Moving From Tsv To Json With Nested Array
I am learning d3.js by following tutorials and trying to read example available (thanks mike). In this example: http://bl.ocks.org/mbostock/3884955, I have trouble understanding ho
Solution 1:
To start with, the easiest thing to do is to simply convert your nested structure to something the example can work with. The code would look something like this.
var flat = [];
json.forEach(function(d) {
d.temperature.forEach(function(e) {
e.date = d.date;
flat.push(e);
});
});
On a general note, I would advise having your numbers as numbers in the JSON and not strings (i.e. without the quotes).
Post a Comment for "D3.js Moving From Tsv To Json With Nested Array"