D3.js tutorial Part 4 - Exit, Remove, Merge and the Update Pattern (2019)

preview_player
Показать описание

》Observable

》Mike Bostock's blocks page
Рекомендации по теме
Комментарии
Автор

This series had been a massive help. Really like you style of teaching and explaining every line, as well as the underlying concepts.

fosos_
Автор

Thanks a lot for these videos! Very helpful. I noticed at 9:57 the div's value was not 'hi' as one would expect - why is that the case?

andrewaquilina
Автор

This explanation is great, but... Is there a reason that you're not using join()?
When you do this:
d3.select(#content)
.selectAll('div')
.data(letters)
.join((d) => d)
This will update with and remove existing divs...

Update:
Well, when you're working with React, the order like this will not work, probably because with every update it'll get a brand new hold to the divs... So after selectedAll divs you remove and exit first, and than add your data etc...

jornejongsma