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
- assign new id attribute to each element created
- Coloring svg elements depending on data value with d3.js
- Plotting an empty interval for elasticsearch date histogram
- Trigger several buttons and lines at once D3.js
- d3.join() enter called instead of update?
- d3 error displaying datetime on x-axis line chart
- d3js jumpy zoom behavior
- TypeError: Cannot read property 'bar' of undefined
- How do I properly add transitions to D3 Polygons?
- How to set default value to dc selectMenu
- d3 select throws invalid query selector error
- Svg brush as slider. How to set slider scale graduation frequency
- Change text color of SVG when clicked on it
- useInteractiveGuideline not working correctly in Angular nvd3
- D3, Change the style of collapsible tree attribute
- d3js does not enter into line function
- Changing the xAxis to say Months instead of Numbers
- SVG: drawing inside a child element
- How to simplify this D3 code?
- how to set color and grid in areaplot using d3.js?
- Show the tooltip inside a div in a D3 stacked area chart
- parallel links between nodes
- Not able to show min and max value on x-axis in d3 js
- D3JS blink link
- Append is not a function in d3.js?
- get values of single candlestick in mouseover in candlestick chart in d3
- Avoid ovrelapping of points in technology radar
- d3.js json http authentication issue (no data receive)
- Scale SVG but nothing else?
- nvd3.js chart ajax data redraw - missing hovereffect + former yAxis scale