0
我正在使用d3製作最適合的應用程序,我希望最適合的線條可以在我拖動點時進行更新。我得到它的工作,以便當你的拖動結束時,行自行更新。但是,當實際更新點被拖動時,我無法這樣做。正在更新圖形,因爲我拖動了一個點
這是我拖累功能:
var move = d3.behavior.drag()
.on("drag",drag)
.on("dragend",function(){
dict.length = 0;
var dragPoint = d3.select(this);
var newX = x_scale2(parseInt(dragPoint.attr("cx")));
var newY = y_scale2(parseInt(dragPoint.attr("cy")));
model.replace_point(dragPoint.attr("id"),newX,newY);
updateDisplay();
});
function drag(){
var dragPoint = d3.select(this);
dragPoint
.attr("cx",function(){return d3.event.dx + parseInt(dragPoint.attr("cx"));})
.attr("cy",function(){return d3.event.dy +parseInt(dragPoint.attr("cy"));})
}
**就如何實現我的目標任何幫助,將不勝感激**
哦,我看到我一直在做錯了!謝謝您的幫助 – user2525805