skokenes / d3-lasso

A lasso plugin for d3
BSD 3-Clause "New" or "Revised" License
88 stars 35 forks source link

bug #20

Closed Fanyini closed 2 years ago

Fanyini commented 2 years ago

第19行到第31行,此处不应该使用append()来进行添加节点,或者说应该在添加节点之前判断g.lasso,path.drawn,path.loop_close,circle.origin这四个节点是否存在,如果存在的话就不应该在添加。 例如,同时在散点图中使用zoom和lasso,就需要对zoom和lasso进行切换,但是每一次切换lasso就会增加一个节点g 1649185232(1)

Fanyini commented 2 years ago

确保g.lasso重复添加 ` // add a new group for the lasso var g = _this.selectAll("g.lasso").data([1]).join("g").attr("class", "lasso");

// add the drawn path for the lasso var dyn_path = g.selectAll("path.drawn").data([1]).join("path") .attr("class", "drawn");

// add a closed path var close_path = g.selectAll("path.loop_close").data([1]).join("path") .attr("class", "loop_close");

// add an origin node var origin_node = g.selectAll("circle.origin").data([1]).join("circle") .attr("class", "origin"); `