Using this as reference. I am trying to implement this into my page. However, the JSON data that I am using has JSON within it. So my JSON looks similar to 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 I am trying to get the id within data as my text display. I have tried several things but it seems like I can't reach within to get 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 to work.
代替d.data[id]
使用d.data['id']
或者,如d.data.id
建议的那样,使用d.data.id
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.