Equivalent d3js selection.each() for single element

Viewed 45

I have this code which works perfectly when i have a selection of elements:

d3.selectAll(".myRectZone")
    .enter()
    .each((_,i) => {  
        // This is an example, just to show that I am calling my own function and stuff
        curr_data = something[i]
        calling_my_custom_function(this, curr_data)
    })

And I need the same for one single element. Something like this :

d3.select("#mySingleElement")
    .???(() => {
        // I want to call my own stuff
        curr_data = something[0]
        calling_my_custom_function(this, curr_data)
    })
    on.("A_Precise_Event", () => something()) // I don't want to precise like this

What can replace the "???" to let me call my own callback ?

0 Answers
Related