Today I talk about and link to Mike Bostock’s post on D3 selections, in this he talks about the basic unit of d3, the selection.
Who is Mike Bostock?
Mike Bostock is one of the key developers of d3.js and worked for a number of years creating visualizations with this library. His work creating data visualisations for the New York Times distilled many complex datasets to simple diagrams.
Now he continues to improve the library and produce visualizations to demonstrate the use of the library.
In doing so he blogs explaining some of the important concepts and recommended patterns with D3.js.
Learning about selections
Today I am talking about Mikes blog post about D3.js selections.
While it isn’t necessary to understand the inner workings of D3.js selections, knowing more about them will aid data visualisation.
In the first section of the post Mike talks about how the D3.js selections are implemented. The objective of this is to understand how the selections can be used, and then understand how they should be used. He outlines that selections are a subclass of Array which allows various standard array operations to be used.
Following this Mike contines by explaining how data is bound onto the elements on the page. This is an important part of data driven documents which allow dynamic data display.
Once the inner workings have been explained Mike goes onto discuss the d3’s update, enter and exit patterns. While you could skip to this later part of the post it is more helpful to understand how d3 works first. Once these key concepts of D3.js are understood then the update, enter and exit patterns make a bit more sense.
Each paragraph is framed with useful diagrams and animations to display some of the core concepts. These aid the explanation to make it easier to explain some of the more complex topics.
For anyone working with D3.js it is highly recommended to read. You can read the full post on Mike’s blog.