I've got this snippet that I don't understand.
var data = [3, 2, 4, 1];
window.onload = async function() {
d3.select( '#canvas' )
.selectAll( 'rect' )
.data( data )
.join(
enter => {
enter.append( 'rect' )
.attr( 'x', d => d*50 )
.attr( 'width', 20 )
.attr( 'height', d=> d*50 )
.attr( 'y', 20 )
.attr( 'id', d => 'rect' + d )
.style( 'fill', 'blue' );
});
}
I understand that we're selecting the canvas and creating a rect for each datapoint. I believe we're passing a function into selection.join() that is used to join the rectangle to the data.
How and what is the 'enter' that being passed into the function passed into join? Also, how and what is the 'd' that is being passed into the other nested lambda functions?