529486 (7) [Avatar] Offline

Could someone explain the use of $ in this line:

const g = svg.append('g')
.attr('transform', `translate(${margin.left}, ${margin.top})`);

found here: https://bl.ocks.org/curran/f4ca72a38bcbb5893d37ce48ed9d4796


stevegw (39) [Avatar] Offline
The $ is a jquery selector

$(selector).action() A $ sign to define/access jQuery. A (selector) to "query (or find)" HTML elements. A jQuery action() to be performed on the element(s)

529486 (7) [Avatar] Offline
Thanks. I assume that means the non-jQuery way of accessing margin.left and margin.top would be more complicated...
stevegw (39) [Avatar] Offline
529486 (7) [Avatar] Offline
Awesome, thanks!
529486 (7) [Avatar] Offline
Actually, to answer my own question, since the reference in my example is to the variable margin, not the value of the svg.marginTop, the equivalent non-jQuery alternative would be:

const g = svg.append('g')
.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');