score:16
Accepted answer
The groups of class node translated to its location, if you want to add an item under it you can use relative coordinates. The center of the circle, for instance, is located (by default) at the (0, 0) coordinates relative to the group. If you want to add a text 10 px under the circle, and 20 px to the right, you should do:
var nodeEnter = node.enter().append("g")
.attr("class", "node")
.attr("transform", function(d) {
return "translate(" + source.y0 + "," + source.x0 + ")";
})
.on("click", click)
.on("mouseover", function(d) {
var g = d3.select(this); // The node
// The class is used to remove the additional text later
var info = g.append('text')
.classed('info', true)
.attr('x', 20)
.attr('y', 10)
.text('More info');
})
.on("mouseout", function() {
// Remove the info text on mouse out.
d3.select(this).select('text.info').remove();
});
Regards.
Source: stackoverflow.com
Related Query
- how to display name of node when mouse over on node in collapsible tree graph
- How to show and hides nodes when you move the mouse over a node in D3 Javascript
- How to display rectangular div with data on mouse over event of any node in d3 js tree?
- how to display the node attributes like person's name photo and address in a force directed graph
- how to zoom svg semantic graph when the mouse is under svg instead of node
- How to display and hide links and nodes when clicking on a node in D3 Javascript
- How to display a text when mouseover a node in D3 force layout
- d3 Tree - How to auto adjust node spacing when zooming
- Connected link line animation when mouse over on the node in force layout d3
- How to scale each node, represented as a pie chart, in a graph on mouse over using D3
- In a d3 scatterplot using data from a csv file, how do i draw lines connecting related points when the mouse is over a point?
- d3 tree layout to display text on mouse hover over links
- D3 Tree Graph - How to transition links when using straight line, not diagonal
- How to make d3js force directed graph less shaky when a node is dragged?
- d3.js v4: How to display an image after mouse click on a node
- How to assign a unique id to a node in d3 collapsible tree
- How to add progress bar inside a tree structure node or on mouse hover in D3
- How to start D3 JS Tree to render in Collapsible Mode when loaded for the first time
- D3.js Collapsible tree - Show more than only name of node
- How to fix graph so it doesn't write over itself when resizing
- D3 JS - How to display data for each element on mouse over
- How to keep mouse over object when using drag and snap to with d3.js
- How modify space between node in collapsible tree using d3.js ?
- how to capture node name upon mouse hover in a shiny network graph?
- how to make child nodes of tree layout collapsing into parent node when clicked
- D3 force directed graph with drag and drop support to make selected node position fixed when dropped
- How to access "previous sibling" of `this` when iterating over a selection?
- Add hyperlink to node text on a collapsible tree
- How to load data from an internal JSON array rather than from an external resource / file for a collapsible tree in d3.js?
- How to simulate mouse move in D3 so when you drag nodes, other nodes move automatically?
More Query from same tag
- DC.js composite chart not updating when filter is applied
- How to visualize JSON dictionary on horizontal D3.js bar chart?
- D3 Force - creating markers for links with dynamic refX to reflect varying node size
- How to remove event listener of an element when I remove the corresponding element in the midst of the event being triggered in D3?
- Binding data to each element using HTML textarea
- Scale the image pattern as the circle changes size
- MySQL - How to modify parent/child select query to add more children to existing array/JSON?
- Adding text to the center of a D3 Donut Graph
- Clean way to create scatter plot from x and y vectors
- D3.js treemap wrong rectangle size
- Old nodes in d3 chart aren't removed during update
- Datamaps are showing small size map of India
- To find nearest rect elements within specified radius or distance of another rect element using D3
- D3.js and coordinate system
- Modifiying dimple layout grouped chart
- Separated, Sorted d3 Circles displayed along the X axis
- Firefox event.clientX not functioning
- Adding space Before and after the Svg:rect - d3.js
- How to create Bubble chart in C3.js
- Multiple donut chart not showing percentage
- d3.js visualization on android 2.3
- Circles not appending to coordinates
- D3.js bar chart - axis and labels not working / transitioning
- Javascript issue with rendering updated chart in D3
- d3 sankey diagram - how to set the y position
- d3.max returns different values for tsv and json (same content)
- How can I keep a d3 mouseover open while my mouse is over the tooltip?
- How to change the curve on an SVG element
- unable to access a .csv file using java script in html
- D3.js moving a line and a circle after a button press