D3's Keyed Data Join: Why Your Sorted Bar Chart Flickers, and How to Fix It
Sorted or filtered D3 charts flicker because the default data join matches by array index, not identity. A key function to selection.data() restores object constancy and makes transitions meaningful.