我有csv格式的数据,如下图所示,我在绘图圆圈中使用了lat和long数据,但我想将宽度和高度传递给矩形,这将在点击圆圈时填充
我面临的问题是数据会转到圆形功能,但它不会转到矩形(点击圆圈)(内部功能)
DATA
district,lat,lon,width,height
andhra,19.41079,79.177427,100,200
HIMACHAL PRADESH,30.970288,76.802893,200,300
d3.csv("newcsv.csv",function(data)
{
group.selectAll("circle")
.data(data)
.enter()
.append("circle")
.attr("cx",function(d)
{return projection([d.lon, d.lat])[0];})
.attr("cy", function(d) {
return projection([d.lon, d.lat])[1];
})
.attr("r",5)
.attr("fill","red")
.on("click",function(d)
{
canvas.append("rect")
.attr("width",d.width)
.attr("height",d.height)
.attr("x",500)
.attr("y",500);
}
)
});