Dies ist der Code, um die Koordinaten des sunburst Knoten zu berechnen:D3 V4 Sunburst Diagramm-Layout arc Berechnungs
var arc = d3.svg.arc()
.startAngle(function(d) { return d.x; })
.endAngle(function(d) { return d.x + d.dx; })
.innerRadius(function(d) { return Math.sqrt(d.y); })
.outerRadius(function(d) { return Math.sqrt(d.y + d.dy); });
Wo:
x: die minimale x-Koordinate der Knotenposition
y: die minimale y-Koordinate der Knotenposition
dx: die x-Ausdehnung der Knotenposition
dy: die Y-Ausdehnung der Knotenposition
jedoch in der kürzlich Version v4 realeased, die raumfüllende Layouts d3.treemap und d3.partition nun Ausgang x0, x1, y0, y1 on jeder Knoten anstelle von x0, dx, y0, dy
node.x0 - die linke Kante des Rechtecks
node.y0 - der obere Rand des Rechtecks
node.x1 - der rechte Rand des Rechtecks
node.y1 - die untere Kante des Rechtecks
Was wäre der entsprechende Code für v4, da das folgende nicht das richtige Layout liefert?
var arc = d3.arc()
.startAngle(function(d) { return d.x0; })
.endAngle(function(d) { return d.x0 + (d.x1 - d.x0); })
.innerRadius(function(d) { return d.y0; })
.outerRadius(function(d) { return d.y0 + (d.y1 - d.y0); });
Siehe codepen