Published
Edited
Dec 21, 2018
Importers
10 stars
Also listed in…
California fire zones
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
formatTick = v => metric == 'in_pct' ? percent(v) : intcomma(roundHundred(v))
Insert cell
percent = v => (v*100).toFixed(1) + "%"
Insert cell
intcomma = d3.format(",")
Insert cell
roundHundred = v => Math.round(v/100)*100
Insert cell
legendBreaks = color.range().map(c => {
var d = color.invertExtent(c);
if (d[0] == null) d[0] = 1;
return d;
})
Insert cell
legendAxis = d3.axisBottom(legendScale)
.tickSize(13)
.tickValues(color.domain())
.ticks(breaks)
Insert cell
legendScale = d3.scaleLinear()
.domain(d3.extent(hexes.features.map(d => d.properties[metric])))
.range([0, width*0.66]);
Insert cell
color = d3.scaleThreshold()
.domain(ckMeansGroups.map(d => d3.min(d)))
.range(d3.schemeReds[breaks])
Insert cell
ckMeansGroups = ss.ckmeans(hexes.features.map(d => d.properties[metric]), breaks)
Insert cell
Insert cell
path = d3.geoPath().projection(projection)
Insert cell
projection = d3.geoMercator()
.center([-118.75, 37.5])
.scale((1 << 19) / (40 * Math.PI))
.translate([width / 2, height / 2])
Insert cell
height = 900
Insert cell
Insert cell
Insert cell
state = {
const url = "https://gist.githubusercontent.com/palewire/e001c971f2cab1664168658caa7536da/raw/state.json";
const r = await d3.json(url);
return topojson.feature(r, r.objects["state"]).features[0];
}
Insert cell
hexes = {
const r = await d3.json(hexConfig.url);
const layer = topojson.feature(r, r.objects[hexConfig.name]);
return {
type: "FeatureCollection",
features: layer.features.filter(d => d.properties[metric] >= minimum)
};
}
Insert cell
hexConfig = {
return {
Big: {
name: "big-hexes-with-analysis",
url: "https://gist.githubusercontent.com/palewire/a57662d364a131bc4d17ca436cc4e20b/raw/big-hexes-with-analysis.json"
},
Small: {
name: "small-hexes-with-analysis",
url: "https://gist.githubusercontent.com/palewire/37354699bc3855ccf5e1b48eff6fc146/raw/small-hexes-with-analysis.json"
}
}[hexSize];
}
Insert cell
minimum = {
return {
in_zone: 10,
in_pct: 0.01,
total: 1
}[metric]
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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