Be the first user to complete this post

  • 0
Add to List

How to get the data of a node in d3

In my previous article on enter, update and exit selections, I discussed how d3 binds data to nodes using the data() function. How about the inverse case where you have a reference to a node to which data is supposedly bound and you want to get the value of that data. Take another case - when you have a reference to a node, but you want to access the data that is bound to a parent node. Turns out, you can easily get the data bound to a node as follows;
where your_node is a reference to the actual DOM node.

Also Read:

  1. Getting started with es6 generator functions
  2. Getting the parameters and arguments of a javascript function
  3. Render a d3 tree with a minimum distance between the tree nodes
  4. Using d3js to draw a bar chart with an axis and some basic transitions
  5. d3 Fundamentals: Creating a simple bar graph
  6. Selecting a node in d3js based upon the value of its data
  7. Render a d3js Tree as a React Component