Last active
August 29, 2015 14:02
-
-
Save jueyang/44e289553ab14c9726db to your computer and use it in GitHub Desktop.
Gist from mistakes.io: explaining different d3.scale()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"hello, world"; // edit this to begin | |
require('http://d3js.org/d3.v3.min.js'); | |
// equal interval | |
var color1 = d3.scale.quantize() | |
.domain([0,10]) // continuous | |
.range(["#000", "#111", "#222", "#333", "#444", "#555"]); | |
// manual interval | |
var color2 = d3.scale.threshold() | |
.domain([0,2,4,6,8,10]) // discrete, starts from -1 and ends at (i-1) | |
.range(["#000", "#111", "#222", "#333", "#444", "#555"]); | |
// sequtial | |
var color3 = d3.scale.linear() | |
.domain([0,10]) // continuous (start--->end) | |
.range(["#000", "#111"]); // gradient between #000 and #111 (start--->end) | |
color1(10); | |
color2(10); | |
color3(10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment