0
サンプルコード更新:リファクタリングD3 v3のパイ
var updateChart = function(dataset) {
arcs = arcs.data(donut(dataset), d => d.data.label);
arcs.exit().remove();
arcs.enter().append("path")
.attr("stroke", "white")
.attr("stroke-width", 0.8)
.attr("fill", function(d, i) {
return color(i);
}).attr("d", arc);
arcs.transition()
.duration(duration)
.attrTween("d", arcTween);
sliceLabel = sliceLabel.data(donut(dataset), d => d.data.label);
sliceLabel.exit().remove();
sliceLabel.enter()
.append("text")
.attr("class", "arcLabel")
.attr("transform", function(d) {
return "translate(" + (arc.centroid(d)) + ")";
})
.attr("text-anchor", "middle")
.style("fill-opacity", function(d) {
if (d.value === 0) {
return 1e-6;
} else {
return 1;
}
})
.text(function(d) {
return d.data.label;
});
sliceLabel.transition()
.duration(duration)
.attr("transform", function(d) {
return "translate(" + (arc.centroid(d)) + ")";
})
.style("fill-opacity", function(d) {
if (d.value === 0) {
return 1e-6;
} else {
return 1;
}
});
私はバージョン4にリファクタリングしないと、私はそれがエラーなしで実行するようになったが、それはもはやセグメントを削除パイを持っています。パイを動かすために私がしなければならなかった変更以外はバージョン3のものとまったく同じです。
は参考のため、ここではバージョン3での作業です:あなたは新しいmerge
方法introduced in version 4上に読む必要が version 3
ありがとうございます。私はちょうどそれを見ていた!正直! – keepTrackOfYourStack