Edit the innerRadius of D3 Sunburst visualization

烈酒焚心 提交于 2019-12-06 06:04:47

问题


How can I change the radius of the innermost circle of the Sunburst visualization? See following example: (http://bl.ocks.org/d/910126/ - notice how large is central area; can it be smaller?)

Also, is it possible to define different heights for all the layers in the Sunburst?


回答1:


Yes, it is possible.


Base Example

jsfiddle


Custom layer height 1

jsfiddle


Custom layer height 2

jsfiddle


Custom layer height 3

jsfiddle




回答2:


I've just compared the examples above so can't claim any great skill\knowledge here but all the changes are in this section:

var arc = d3.svg.arc()
    .startAngle(function(d) { return d.x; })
    .endAngle(function(d) { return d.x + d.dx; })
    .innerRadius(function(d) { return radius * Math.sqrt(d.y) / 10; })
    .outerRadius(function(d) { return radius * Math.sqrt(d.y + d.dy) / 10; });

The effects are interesting but not quite what I was looking for when I found this question\answer. I wanted to be able to control the size of each layer\ring individually really. Anyway... hope this picking apart of the jsfiddles above helps someone else.



来源:https://stackoverflow.com/questions/14341836/edit-the-innerradius-of-d3-sunburst-visualization

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!