Skip to content

Instantly share code, notes, and snippets.

@rgdonohue
Last active February 16, 2017 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgdonohue/823a0c67087e0a66d171 to your computer and use it in GitHub Desktop.
Save rgdonohue/823a0c67087e0a66d171 to your computer and use it in GitHub Desktop.
Understanding d3 domain and range values

Mapping domain values to range outputs with d3.

d3.scale.threshold()
   .domain([
      10,
      20,
      30,
      40
    ])
    .range([
      'red',  // applies to values < 10
      'blue', // 10-19
      'green', // 20-29
      'yellow', // 30-39<
      'orange'  // 40+
    ]);

Insight by @awoodruff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment