Published
Edited
Apr 21, 2020
1 fork
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
d3 = require('d3@5')
Insert cell
topojson = require('topojson-client@3')
Insert cell
Insert cell
Insert cell
Insert cell
us = d3.json('https://d3js.org/us-10m.v2.json')
Insert cell
data = topojson.feature(us, us.objects.states).features
Insert cell
Insert cell
{
// Create an empty SVG with 960px width and 600px height.
const svg = DOM.svg(960, 600);
// Create an instance of geoPath.
const path = d3.geoPath();
// Use the path to plot the US map based on the geometry data.
d3.select(svg)
.append('g')
.selectAll('path')
.data(data)
.enter()
.append('path')
.attr('d', path);
return svg;
}
Insert cell
Insert cell
html`
<style>
path {
fill: #fff;
stroke: #000;
}
</style>`
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