Published
Edited
Sep 1, 2018
1 fork
102 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
hexbin = d3.hexbin()
.extent([[0,0],[w, h]])
.radius(r)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
imageData = image.getContext('2d').getImageData(0, 0, w, h).data
Insert cell
Insert cell
Insert cell
imageDataAlpha = imageData.filter((d,i) => i%4 === 3)
Insert cell
Insert cell
Insert cell
imageCenters = {
return centers.filter(d => imageDataAlpha[Math.floor(d[0]) + Math.floor(d[1]) * w]);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
projection = d3.geoAlbers().fitSize([w, h], us)
Insert cell
path = d3.geoPath().projection(projection)
Insert cell
Insert cell
hexgrid = d3.hexgrid()
.extent([w, h])
.geography(us)
.projection(projection)
.pathGenerator(path)
Insert cell
Insert cell
hex = hexgrid(markets)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
marketColours = d3.scaleSequential(t => {
var tNew = Math.pow(t, power);
return d3.interpolateViridis(tNew);
}).domain([...hex.grid.extentPointDensity].reverse())
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// html `<style>canvas { border: 1px solid #ccc}</style>`
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more