0

I'm basicaly working with this.

Now, the flare.json is something like

{ "name": "flare", "children": [  {   "name": "analytics",   "children": [    {     "name": "cluster",...

I need more information to be displayed, not just the name so after fetching the data I have something like.

{ "name": "John Smith", "Age": "20", "Country": "Canada", "children": [  {  //and so on

All nodes will have more fields than just "name", let's say 3 or 4 items in total.

The code part for appending the data is

nodeEnter.append("svg:text")
  .attr("dy", 3.5)
  .attr("dx", 5.5)
  .text(function(d) { return d.name; });

I've tryed return d.name + ' - ' + d.age;}); but it just works on the root node. On all the children it says the name properly but instead of the Age.Text it says [object Object]

Basicaly I need to access not just the "name" from the flare.json file but a few more items.

Thanks in advance.

4

1 回答 1

1

它适用size于数据中已经存在的属性。有关示例,请参见此处。我所做的是.text

.text(function(d) { return d.name + (d.size ? " " + d.size : ""); });

如果存在,它将显示尺寸信息。

于 2013-09-14T09:29:05.710 回答