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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more