json - D3 - not all children nodes are shown at the same time -
i'm trying create network graph based on example. tried using json file have doesn't show nodes @ same times.
{ "name":"plant", "children":[ { "name":"delonix regia", "children": [ { "id" : "family", "name" : "fabaceae", "size": 10000 }, { "id" : "common name", "name" : "semarak api", "size": 10000 }, { "id" : "habitat", "name" : "humid", "size": 10000 } ] }, { "name":"ixora javanica", "children": [ { "id" : "family", "name" : "fabaceae", "size": 10000 }, { "id" : "common name", "name" : "bunga air", "size": 10000 }, { "id" : "habitat", "name" : "hot", "size": 10000 } ] }, { "name":"dracaena reflexa", "children": [ { "id" : "family", "name" : "asparagaceae", "size": 10000 }, { "id" : "common name", "name" : "pleomele", "size": 10000 }, { "id" : "habitat", "name" : "unknown", "size": 10000 } ] } ] }
here how looks.
when click @ other parent node delonix regia
or ixora javanica
node opened close.
i have json more complicated works , nodes showing.
how can make nodes or parent nodes shown?
i have updated code provided in example , added json datasource. working fine - https://jsfiddle.net/zlehvltd/
i have replaced id name @ 2 places in code:
// update links. link = link.data(links, function(d) { return d.target.name; }); // update nodes. node = node.data(nodes, function(d) { return d.name; });
other method create complete tree add unique "id" each object in json. reason behind d3.js accepts json in nested format atleast 1 unique property each object.
Comments
Post a Comment