D3.js d3.geo.圆角度不起作用?
所以,我试着按照Jason Davies对线索的回答 我尝试了3种不同的可能性:D3.js d3.geo.圆角度不起作用?,d3.js,D3.js,所以,我试着按照Jason Davies对线索的回答 我尝试了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 /
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很多。在升级到d3版本“5.7.0”后,我遇到了同样的问题。 使用
geo.circle.center(center).radius(angle)
而不是geo.circle().angle(angle)
进行修复
你可以找到它是如何工作的。你能详细说明一下它是如何工作的吗?有错误信息吗?发生了什么?你期望发生什么?它是如何工作的:圆圈只是没有被创造出来。。。第一个注释部分没有给我任何消息错误。第二个注释部分说:“Uncaught TypeError:无法读取未定义的属性'0'”我只是想弄明白为什么我不能在angle属性中放置一个带返回的函数。你需要一个
函数(d)
就在.datum()
之后,就像第一个注释部分一样。我得到了它。datum(函数(d){var origin=d.geometry.coordinates var angle=avions[d.properties.index].total_morts/100返回d3.geo.circle().angle(angle.origin(origin)(})这是有效的!!诀窍在结尾的括号中。为什么呢?哦,对了,没有看到--d3.geo.circle()
是一个工厂函数(即返回函数的函数),您仍然需要调用它。