All examples By author By category About

weiglemc

D3 Scatterplot Example

d3 scatterplot example using the Breakfast Cereal Dataset from http://idvbook.com and based on the scatterplot example at /mbostock/3887118

Coding style based on mbostock's DRY Bar Chart at http://gist.github.com/mbostock/5977197

A variation of the example bar chart using a slightly more D.R.Y. style. The visual encoding is represented by two functions and their composition:

  • The value accessor returns the value (or property) to encode for a given data object.
  • The scale maps this value to a visual display encoding, such as a pixel position.
  • The map function represents the composition valuescale, mapping from data to display.

Inspired by Andrew Winterman’s post, Tooling for the Lazy Programmer: DRYing up D3.