score:3
Accepted answer
I see that you've overridden functionality to add class selector, you can add click event handler similarly, see the following example.
// Override drawNodes to set up the click.
var oldDrawNodes = renderer.drawNodes();
renderer.drawNodes(function(g, svg) {
var svgNodes = oldDrawNodes(g, svg);
// on click event handler
svgNodes.on('click', function(d) { console.log('Clicked on node - ' + d); });
return svgNodes;
});
for adding click event handler for edges, try something like below given code
var oldDrawEdges = renderer.drawEdgePaths();
renderer.drawEdgePaths(function(g, svg) {
var edges = oldDrawEdges(g, svg);
edges.on('click', function (edgeId) { alert('Clicked on - ' + edgeId);});
return edges;
});
score:1
This worked for me for handling node clicks:
svg.selectAll("g.node").on("click", function(id) {
console.log("Clicked " + id);
});
Source: stackoverflow.com
Related Query
- How do I add a click event to a directed graph using dagre d3.js(javascript library)?
- How to add a click event on nvd3.js graph
- how to add mouse events to force directed graph using the d3 canvas renderer?
- How do i add two different shapes to D3 forced directed graph based on shape field value?
- How can I add a click event to show a tooltip in an NVD3 Pie Chart?
- How to add a dynamic legend to a D3 force directed graph in Apex?
- How to add a line graph to a scatterplot using d3?
- How do I make a d3.js force directed graph interactive using ajax and python?
- How to show edges in force directed graph using d3.js and Angular?
- unable to get click event between the path link using collapse graph
- How to show directed graph using insight
- How to add click event on d3.js child of collapsible tree?
- How to add a click event or mouseover on dynamic elements ( enter/update/exit )?
- D3.js How to add tooltip in my legend using line graph
- How to change the colors of nodes in force directed graph in d3js using javascript?
- How can I add text to edges in a force directed graph d3?
- how to make simple directed graph using d3
- D3 Force Directed Graph click event not working
- How to style nodes in d3 directed graph based on groups using reactjs
- How to add text to a force directed graph in D3.js
- How to Add X and Y axis in the pre existing graph using D3
- how to display the xml tags data using force directed graph in d3.js
- How to add an image to an svg container using D3.js
- How can I make double click event on node in d3.js?
- Add text label to d3 node in Force directed Graph and resize on hover
- Add text/label onto links in D3 force directed graph
- How to add using d3.js selection.text() method
- Directed acyclic graph using d3.js without DOT
- Is there a tap and double tap event in d3.js force directed graph
- How to avoid log zero in graph using d3.js
More Query from same tag
- Message "d3.js TypeError: n is undefined" (for D3 world map with force layout)
- Include .json data in javascript code (d3.js)
- How to set zoom step in D3JS v4?
- Convert d3 event from Javascript to Typescript (Angular2)
- Get In between points of an Ordinal Scale Axis in d3
- Choosing right tool for visualization
- How to mock d3.select.selectall with sinon?
- d3.scale on JSON Data
- Is there a way to replace regions in c3?
- How do I use/retrieve the C3 scale function post generate?
- How to make two histogram plot using independent scale under Javascript Plottable.js
- Token Error in Makefile for D3js
- Filter data on multiple columns with checkboxes - D3
- (Angular 4) How to a Bind Global Touch Event Handler to Disable iOS Safari Page Drag?
- Adding label on a D3 bar chart
- thinking in D3 - select vs append
- stacked d3 bar chart - specify x/y values
- Iterating through SVGElement paths with d3js?
- How to convert this data to csv using Nodejs/ JavaScript
- Setting d3 symbol conditionally
- Title and Axis labels
- d3.js - Tree Layout - How can I flip it?
- Focus on form field after animation
- Changing the colors of each of the Stacked Bar chart with different Color in D3
- How do I centre the Y axis in a D3 Tornado Chart
- render d3 linear nice scale with whole numbers only
- c3.js. Creating graphs within a loop to multiple divs with the same class/ID?
- Problems making radial gradient in arcs using javascript, d3 with data from json file
- D3 Graph Not Showing Up
- Simple Pan and Zoom in d3 v7