d3.geo.circle角度不起作用?

时间:2014-07-31 10:08:39

标签: d3.js

所以,我试过跟随杰森戴维斯'回答Circle clip and projection with D3 orthographic帖子......

我尝试了3种不同的可能性:

svg.append("g").attr("class","points")
  .selectAll("path")
    .data(places.features)
    .enter()
    .append("path")
    //THIS COMMENTED PART DOES NOT WORK
    //though the console spits out an array
    /*.datum(function(d){
         console.log(d.geometry.coordinates)
         return d3.geo.circle()
           .origin(d.geometry.coordinates)
           .angle(2)
    })*/

    //THIS UNCOMMENTED PART WORKS
    //and places the circles accordingly with a fixed size radius
    .datum(d3.geo.circle()
      .origin(function(d){return d.geometry.coordinates})
      .angle(2)
    )

    //THIS COMMENTED PART DOES NOT WORK
    //which is a shame, as my goal is to change the angle of each circle
    /*.datum(d3.geo.circle()
          .origin(function(d){return d.geometry.coordinates})
          .angle(function(d){return 2})
    )*/

    .attr("class", "point")
    .attr("d", path)

如何让最后一个评论的部分发挥作用,以便我可以更改圆圈的半径? Thanx很多。

1 个答案:

答案 0 :(得分:0)

更新到d3版本“ 5.7.0”后,我遇到了同样的问题。 通过使用geoCircle.center(center).radius(angle)而非geo.circle().angle(angle)进行了修复。

Here,您可以找到它的工作方式。