Published
Edited
Jun 16, 2020
2 forks
6 stars
Insert cell
Insert cell
Insert cell
belgium = (await fetch("https://raw.githubusercontent.com/bmesuere/belgium-topojson/master/belgium.json")).json()
Insert cell
Insert cell
vl.markGeoshape({stroke: 'gray', fill: "white", strokeWidth: 1})
.data(vl.topojson(belgium).feature('municipalities'))
.width(850).height(600)
.config({view: {stroke: null}})
.render();
Insert cell
Insert cell
{
const muni = vl.markGeoshape({stroke: 'gray', fill: "white", strokeWidth: 1})
.data(vl.topojson(belgium).feature('municipalities'));
const prov = vl.markGeoshape({stroke: 'black', fillOpacity: 0, strokeWidth: 1})
.data(vl.topojson(belgium).feature('provinces'));
return vl.layer(muni, prov)
.width(850).height(600)
.config({view: {stroke: null}})
.render();
}
Insert cell
Insert cell
vl.markGeoshape({stroke: 'white', strokeWidth: 1})
.data(vl.topojson(belgium).feature('municipalities'))
.encode(
vl.color()
.fieldQ('properties.population')
.scale({type: 'sqrt'})
.legend({title: 'Population'}),
vl.tooltip([
{field: "properties.name_nl", title: 'City'},
{field: "properties.population", title: 'Population'}
])
)
.width(850).height(600)
.config({view: {stroke: null}})
.render();
Insert cell
Insert cell
caseData = (await fetch("https://epistat.sciensano.be/Data/COVID19BE_CASES_MUNI_CUM.json")).json()
Insert cell
Insert cell
Insert cell
vl.markGeoshape({stroke: 'white', strokeWidth: 1})
.data(vl.topojson(belgium).feature('municipalities'))
.transform(
vl.lookup('properties.nis').default(0).from(vl.data(caseData).key('NIS5').fields('CASES')),
vl.calculate('datum.CASES == "<5" ? 0 : datum.CASES').as('Cases'),
vl.calculate('1000 * datum["Cases"] / datum.properties.population').as('cases_per_1000'),
)
.encode(
vl.color().fieldQ('cases_per_1000').legend({title: 'Cases per 1000 inhabitants', orient: 'top'}),
vl.tooltip([
{field: "properties.name_nl", title: 'City'},
{field: "CASES", title: 'cases'}
])
)
.width(850).height(600)
.config({view: {stroke: null}})
.render();
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