我正在使用D3.js创建一个应用程序,其中我在D3中使用画笔事件选择了几个节点。选择做得很好,即我能够选择我想要的节点。现在我要添加一个上下文菜单到我的应用程序的选定部分,以便我能够进一步处理所选项目。这是选择工作的部分。
}
var brush = svg.append("g")
.datum(function() { return {selected: false, previouslySelected: false}; })
.attr("class", "brush")
.call(d3.svg.brush()
.x(d3.scale.identity().domain([0, width]))
.y(d3.scale.identity().domain([0, height]))
.on("brushend", function(d) { //printing the array of data to the console;
console.log(d3.selectAll("circle.selected").data().map(function(d){return d.name;}));
})
.on("brush", function() {
var extent = d3.event.target.extent();
circle.classed("selected", function(d) {
return d.selected = d.previouslySelected ^
(extent[0][0] <= d.x && d.x < extent[1][0]
&& extent[0][1] <= d.y && d.y < extent[1][1]);
});
brushend负责将值打印到控制台,并且画笔正在进行选择。现在任何人都可以帮我添加上下文菜单到选定的部分???