javascript - D3 getting JSON data within a JSON -


using this reference. trying implement page. however, json data using has json within it. json looks similar this:

{ "nodes": [ {"fixed":true,"classes": null,"data": {"id": "imombr","idtype":"username","visible":true },"grabbable": true,"grabbed":false,"group":null,"locked": false,"position":null}, {"fixed":true,"classes": null,"data": {"id": "stephieru_","idtype":"username","visible":true },"grabbable": true,"grabbed":false,"group":null,"locked": false,"position":null} ], "links": [     {"source":0,"target":1,"value":1},     {"source":1,"target":0,"value":1} ] } 

so trying id within data text display. have tried several things seems can't reach within id. attempted:

node.append("text")             .attr("dx", 12)             .attr("dy", ".35em")             .text(function(d) { return d.data[id] }); 

and

node.append("text")             .attr("dx", 12)             .attr("dy", ".35em")             .text(function(d) { return d.data[0] }); 

but neither seems work.

instead of d.data[id] use d.data['id'] or, boombox suggests, d.data.id


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -