Created
January 12, 2014 19:29
-
-
Save daguar/8389275 to your computer and use it in GitHub Desktop.
D3 OOPy quantizer for 1-5 range
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
// Quantizing data into buckets | |
function Quantizer(data_array) { | |
min = d3.min(data) | |
max = d3.max(data) | |
this.quantizeNumber = d3.scale.quantize() | |
.domain([min,max]) | |
.range([1,5]) // Start with only mapping on 1-5 color scale | |
} | |
/* Test for Quantizer | |
data = [1,2,3,10]; | |
var quantizer = new Quantizer(data) | |
console.log(quantizer.quantizeNumber(2)); | |
console.log(quantizer.quantizeNumber(10)); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment