Created
October 31, 2013 13:15
-
-
Save lebek/7249495 to your computer and use it in GitHub Desktop.
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
var histWidth = 2; // Number of bins in x | |
var histHeight = 2; // Number of bins in y | |
var pointWidth = 5; // Number of points in x | |
var pointHeight = 5; // Number of points in y | |
var xScale = d3.scale.quantile() | |
.domain([0, pointWidth-1]) | |
.range([0, histWidth-1]); | |
var yScale = d3.scale.quantile() | |
.domain([0, pointHeight-1]) | |
.range([0, histHeight-1]); | |
/* Returns the boundaries of bin x, y in the data */ | |
function getBin(x, y) { | |
return [xScale.invertExtent(x), yScale.invertExtent(y)]; | |
} | |
console.log(getBin(0,0)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment