简体   繁体   English

尝试将饼图示例移植到d3的v4

[英]Trying to port pie chart example to v4 of d3

I am trying to port this example to d3 v4 and I am getting stuck because it is drawing a weird triangle in the pie chart. 我试图将此示例移植到d3 v4,但由于它在饼图中绘制了一个怪异的三角形,我陷入了困境。 My version is here . 我的版本在这里

I am getting 3 errors that look like this: 我收到3个看起来像这样的错误:

Error: <path> attribute d: Expected number, "…280223e-14,-100LNaN,NaNZ".

and I am unsure of how to proceed. 而且我不确定该如何进行。

Thank you for your time and patience in reading this. 感谢您的时间和耐心阅读。

I am not sure if this will help others, but I found a decent pie chart with text at the middle of the radius of the pie graph here . 我不知道这是否会帮助别人,但我发现文本像样的饼图在饼图半径的中间位置

The relevant code is: 相关代码为:

arcs.append("svg:text").attr("transform", function(d){
            d.innerRadius = 0;
            d.outerRadius = r;
    return "translate(" + arc.centroid(d) + ")";}).attr("text-anchor", "middle").text( function(d, i) {
    return data[i].label;}
        );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM