最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can you color each circle in the D3 circle pack layout - Stack Overflow

programmeradmin6浏览0评论

Here is an example of the pack layout in d3js:

Is it possible to control the colors of the individual cirles?

Here is another example of the pack layout with colors:

Can you help me understand how the colors are assigned to the bubbles in the second chart?

Here is an example of the pack layout in d3js:

http://bl.ocks/4063530

Is it possible to control the colors of the individual cirles?

Here is another example of the pack layout with colors:

http://bl.ocks/4063269

Can you help me understand how the colors are assigned to the bubbles in the second chart?

Share Improve this question edited Jun 27, 2014 at 6:51 VividD 10.5k8 gold badges66 silver badges112 bronze badges asked Feb 8, 2013 at 5:13 nilanjannilanjan 6793 gold badges9 silver badges18 bronze badges 1
  • Did you actually try to modify it? – Stefan Hanke Commented Feb 8, 2013 at 5:40
Add a ment  | 

1 Answer 1

Reset to default 6

You can just add the attribute fill to change the color:

node.append("circle")
      .attr("r", function(d) { return d.r; })
      .style("fill", function(d){ return d.color; });

In the example above, suppose your data contains a color field.

发布评论

评论列表(0)

  1. 暂无评论