Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Share On Stumbleupon
Contact us
Hide Buttons

How to get the data of a node in d3

In my pre­vi­ous arti­cle on enter, update and exit selec­tions, I dis­cussed how d3 binds data to nodes using the data() func­tion. How about the inverse case where you have a ref­er­ence to a node to which data is sup­pos­edly bound and you want to get the value of that data.

Take another case — when you have a ref­er­ence to a node, but you want to access the data that is bound to a par­ent node.

Turns out, you can eas­ily get the data bound to a node as follows;

where your_node is a ref­er­ence to the actual DOM node.

Ryan Sukale

Ryan is just a regular guy next door trying to manage his life and finances.

You may also like...