Public
Edited
Sep 30, 2023
1 star
Insert cell
Insert cell
Insert cell
map = {
const container = yield htl.html`<div style="height: 500px;">`;
const map = L.map(container).setView([10, 123.0], 5);
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution: "© <a href=https://www.openstreetmap.org/copyright>OpenStreetMap</a> contributors"
}).addTo(map);
}
Insert cell
Insert cell
philippines = (await fetch("https://gist.githubusercontent.com/data-ph/2dac41bc499d626b4cc395ebb699b12b/raw/db6b205a7189c885c28afb30f8144dd4d1aead43/philippines-regions2018.json")).json()
Insert cell
chart = {
const width=400, height=600;
const svg = d3.select(DOM.svg(width, height))
// Use Mercator projection
var projection = d3.geoMercator()
// Powerfull stuff! I didnt know where exactly my dataset was located projection-wise,
// but .fitExtent() allows you to fit your dataset within a specified canvas
.fitExtent([[20, 20], [width, height]], philippines);

var path = d3.geoPath()
.projection(projection);
// Draw each province as a path
svg.append('g').selectAll('path')
.data(philippines.features)
.enter().append('path')
.attr('d', path)
// Styling
.style('fill', 'white')
.style('stroke', '#ccc')
return svg.node()
}
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