【发布时间】:2015-04-13 02:37:24
【问题描述】:
我想在更改 x1 和 x2 属性时更改我的线对象的数据变量中的 x 值。我怎么做?请参阅下面的代码和图像。
function updateBorder(x, whichBorder) {
temp_border = svg.selectAll(whichBorder)
.attr("x1", x)
.attr("x2", x);
}
【问题讨论】:
标签: d3.js
我想在更改 x1 和 x2 属性时更改我的线对象的数据变量中的 x 值。我怎么做?请参阅下面的代码和图像。
function updateBorder(x, whichBorder) {
temp_border = svg.selectAll(whichBorder)
.attr("x1", x)
.attr("x2", x);
}
【问题讨论】:
标签: d3.js
您可以在 d3 回调中修改数据。
function updateBorder(x, whichBorder) {
temp_border = svg.selectAll(whichBorder)
.each(function (d) { d.x = x })
.attr("x1", x)
.attr("x2", x);
}
但在随机位置改变数据并不总是好主意。
【讨论】: