Nik*_*jan 5 directed-graph d3.js
我使用以下示例生成有向图
我想添加一个click事件,以便当用户单击某个节点时,将显示该节点的标题
到目前为止我做到了这一点
var circle = svg.append("svg:g").selectAll("circle")
    .data(force.nodes())
  .enter().append("svg:circle")
    .attr("r", 6)
    **.on("mouseup", disp)**
    .call(force.drag);
     ;
function disp() {
    alert("Display the heading of the node clicked here");
};
请告诉我如何显示
您可以使用.on()为了有一个点击事件
circle.on("click", function(d) {
    alert(d.name)
})
jsFiddle: http: //jsfiddle.net/chrisJamesC/HgHqy/
| 归档时间: | 
 | 
| 查看次数: | 7330 次 | 
| 最近记录: |