Remove event listener with d3js not working

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 13:23:17

In this case, the syntax:

d3.selectAll('.classname', function() { ... });

does not work in d3.js. Instead you should use something like:

d3.selectAll('.classname').each(function() { ... });

So in your code above, this should work:

d3.selectAll('.item')
  .each(function(){

    //when an item is clicked, svgClickEvents must not be fired   
    d3.select('#canvas').on('click', null);  //this should remove the event listener

    d3.select(this).on("click",function() {
            d3.event.stopPropagation(); 
            console.log("click circle");
        });
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!