You can do this using D3's data matching. The idea is to have the data "identify" the correct element for you.
Complete demo here.
To be clear, I do not recommend taking this approach. This is prone to breaking when you add more elements to the document and accidentally select some of those, use the same data in more than one place, or change the data format. It will lead to bugs that are really hard to spot unless you know what you're looking for.
A better approach is to assign an ID or class from that data to each element that you bind the data to so that you can select it directly when you have the data. This will also be more efficient.
- How can I get the dom svg element from d3 node data?
- In d3, how to get the interpolated line data from a SVG line?
- In d3 4.0, how can I get extra data from the stratified object?
- D3 - How can I show/hide a text element when hovering a circle element created from different attributes of the same data entry?
- How to get a D3.js pie chart to render data dynamically from the DOM
- How to access the DOM element that correlates to a D3 SVG object?
- How do I get the width of an svg element using d3js?
- How can I get "call" to execute for each data element in D3?
- How can I get the natural width and height of an svg image element?
- How to get the data from the c3.js
- How to get value from the element using selection in d3
- How to get web element (id) from the element position in D3.js force graph
- How to get SVG path data of TopoJSON feature without adding it to the DOM?
- How to get the index of the data element in a histogram on mouseover?
- How to get a value from a stylesheet into the code so that it can be used programmatically?
- How can I animate the top of my svg element like in this gif using d3.js?
- How can I get the d3.js bar chart start from 0 instead of from the top
- How to rearrange the DOM order of svg elements based on their data values in a dynamically changing d3 vis?
- How can I set the background color of a svg element which contains a D3 heat map?
- How can I get the equivalent to a "this" keyword from d3 using d3.select()?
- Get all the data from a clicked node in C3JS
- How do I find the associated DOM element when I have the Data object in D3?
- Get the closest element to a SVG node using Jquery closest() function
- How do append a <text> for every element of the data in a D3 svg
- How to get the JSON path from element
- How can I customize the label of X axis, that means the label in X axis is different from the data
- How to update data on a page according to data from a CSV file instead of using fixed element data on the page?
- How can i get the key of an element in stack-layout in d3?
- How to get the data of a D3 node in Chrome Extension content script
More Query from same tag
- drawing a map of the Bronx - d3.geo.path()
- D3 - ordinal scale labels with same names
- Adding nvd to map in systemjs
- Modify D3.js Circle Progress Graph to show range of percentages
- Showing online offline of a device with date and status js jquery d3
- D3 force directed uncaught type error
- D3.js Radar chart line drawing
- Line is not displayed correctly d3.js geo and google maps
- Can svg element trigger click event of svg elements under itself?
- Wrapping words in d3 to get one word in one line
- Difference between d3.js and d3.v3.js
- Setting x.domain with setInterval
- Using d3-tip with require js modules
- Can't find the center of path objects with path.centroid()
- how to modify xlink:href with jquery not working
- Can not capture mouseover event while dragging on an svg
- d3.js Representation of links values in Les Miserables Co-occurrence example
- Dimple.js bar length
- D3.js: Cannot make Y axis scrollable and X axis fixed
- Stopping onclick from propagating "through" other elements
- D3 bar chart axis not scaling correctly
- How to prevent bubbles from touching the svg frame/border when using D3.js force?
- Disabling layout reset on focus out in d3 chord diagram
- D3.js Brush Controls: getting extent width, coordinates
- How to plot animated line chart using d3 while the data table is required to be updated every 1 second?
- calculating the arc/point in d3 path
- Error Cannot read property 'getBoundingClientRect' of null in d3-gantt charts
- Dynamically Clear and Update d3.js Force Directed Layout On Change
- Display isolines at fixed z using plotly or d3 contour plot or interpolation