All examples By author By category About

clhenrick

Barley Punchcard - Dynamic

D3 General Update Pattern – Punchcard Example

Demonstrates the general update pattern (exit, update, enter) with d3.transition and d3.dispatch. Plus, it's a good example of data binding using nested d3 selections: first we select a top level element (svg), do a selectAll on svg groups for each gen type, then do another selectAll on svg circles for each gen type's year & yield.

The tricky part to figure out here (to me at least) was reselecting each "gen" type's svg group after performing the general update pattern on them. If they are not reselected, then the selection will not contain any new svg groups and no additional circles will be rendered for them!

Forked from syntagmatic's block: Barley Punchcard

With cues taken from Mike Bostock's blocks: