简体   繁体   English

D3 v4饼图更新空`d`属性

[英]D3 v4 Pie Chart Update empty `d` attributes

I'm trying to rewrite the classic Pie Chart Update, V example using latest D3 v4. 我正在尝试使用最新的D3 v4重写经典的饼图更新,V示例。 Unfortunately the paths' d attributes aren't calculated. 不幸的是,不计算路径的d属性。

Here is my gist and the block . 这是我的要点 So far I've only changed 到目前为止我只是改变了

  • d3.scale.category20() -> d3.scaleOrdinal(d3.schemeCategory20) d3.scale.category20() - > d3.scaleOrdinal(d3.schemeCategory20)

  • d3.layout.pie() -> d3.pie() d3.layout.pie() - > d3.pie()

  • d3.svg.arc() -> d3.arc() d3.svg.arc() - > d3.arc()

As you can see in the DOM the paths are there but they do not have any d attributes. 正如您在DOM中看到的那样,路径存在,但它们没有任何d属性。

Any ideas? 有任何想法吗?

I think you have a few issues, especially not setting the d attribute on enter. 我认为你有一些问题,尤其是在输入时没有设置d属性。

Here's a gist showing the change https://bl.ocks.org/tezzutezzu/c2653d42ffb4ecc01ffe2d6c97b2ee5e 这是一个显示变化的要点https://bl.ocks.org/tezzutezzu/c2653d42ffb4ecc01ffe2d6c97b2ee5e

In my code there is still a bug in calculating the adjacent arcs on change, but this should resolve your initial problem. 在我的代码中,在更改时计算相邻弧仍然存在错误,但这应该可以解决您的初始问题。

The exit animation is now also working. 退出动画现在也在工作。 I had to make sure that objects were copied before the interpolation. 我必须确保在插值之前复制了对象。

edit: grammar 编辑:语法

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

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