I recently decided to use nested json, however, I cannot access them. I have seen some examples of different way to return data using the data method e.g.:
var node = svg.selectAll("g.node")
.data(nodes, function(d) {return d.world;})
var node = svg.selectAll("g.node")
.data(nodes)
However, this has had no affect. Therefore I've also tried:
.text(function(d) { return d.world.Name; })
But I still havent had any luck!
Here's a snippet of the nested json:
var nodes = {"Galaxy":"Milkyway","life":true,"world": [
{"Name": 'Amy', "Country": 'USA', "translate":"translate(190,83)" },
{"Name": 'Nathan', "Country": 'USA', "type": 'square', "translate": "translate(190,83)"},
{"Name": 'Lewis', "Country": 'USA', "type": 'circle', "translate": "translate(20,183)" },
{"Name": 'Tom', "Country": 'Japan', "type": 'diamond', "translate": "translate(-300,-200)"},
{"Name": 'Matt', "Country": 'Russia', "type": 'cross', "translate": "translate(10,183)"},
{"Name": 'Frank', "Country": 'France', "type": 'triangle-up', "translate": "translate(30,183)"},
{"Name": 'Bob', "Country": 'Japan', "type": 'diamond', "translate": "translate(10,13)"}
]};
thanks in advance
.datafunction you used in the first instance is meant to be used for object consistency by assigningkeysto each data item..datadoes not follow the same accessor pattern asd3.max,d3.mean, etc.