How can I make double click event on node in d3.js?

前端 未结 2 1774
误落风尘
误落风尘 2021-02-03 19:00

I want to make double click event on nodes. So I tried

.on(\"dbclick\",function(d){return \"http://google.com\");});

and

.bin         


        
相关标签:
2条回答
  • 2021-02-03 19:28

    You can use "dblclick" instead of "dbclick":

    nodes.on("dblclick",function(d){ alert("node was double clicked"); });
    
    0 讨论(0)
  • 2021-02-03 19:39

    If using D3 Observable:

    const nodeEnter = node.enter().append("g")
            .on("dblclick", d => {
              d3.event.preventDefault();
              // do your thing
            });
    
    0 讨论(0)
提交回复
热议问题