Created
December 7, 2016 16:04
-
-
Save nerik/5c59af6b4cdc8369d8af3cd796cef38b to your computer and use it in GitHub Desktop.
Quick histograms in the browser console with d3
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
const bins = d3.histogram()(data); | |
const x = d3.scaleLinear().domain([0, d3.max(bins, d => d.length)]).range([0, 30]); | |
console.table(bins.filter(bin => bin.length).map(bin => { | |
const binMin = d3.min(bin).toLocaleString(); | |
const binMax = d3.max(bin).toLocaleString(); | |
return { | |
range: [binMin, binMax].join('-'), | |
bars: Array(Math.round(x(bin.length))).join('█'), | |
num: bin.length | |
}; | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment