Unable to get click event in D3 JavaScript library

后端 未结 2 1667
孤街浪徒
孤街浪徒 2021-01-04 19:33

I am using D3 JavaScript library to display data as a force directed marker. It works fine. But I am unable to add click event to the circle. so when I click on the circle,

2条回答
  •  我在风中等你
    2021-01-04 20:32

    Try this:

    var circle = svg.append("svg:g").selectAll("circle")
      .data(force.nodes())
      .enter().append("svg:circle")
      .attr("r", 6)
      .on("click", function(d,i) { alert("Hello world"); })
      .call(force.drag);
    

提交回复
热议问题