Published
Edited
May 2, 2019
Insert cell
Insert cell
d3 = require("d3@5") //d3 version5
Insert cell
md`## Setting parameters for the visualization chart.`
Insert cell
width = 800
Insert cell
height = 600
Insert cell
margin = 15
Insert cell
md`## Loading Seattle map data`
Insert cell
seattle = d3.json('https://raw.githubusercontent.com/seattleio/seattle-boundaries-data/master/data/zip-codes.geojson')
Insert cell
projection = d3.geoMercator().fitExtent([[margin, margin], [width - margin, height - margin]], seattle)
Insert cell
pathGenerator = d3.geoPath().projection(projection)
Insert cell
md`## Drawing Seattle map`
Insert cell
seattleMap = {
// create SVG element
let svg = d3.select(DOM.svg(width, height))
// construct the element
svg.append('path')
.datum(seattle)
.attr('d', pathGenerator)
.attr('fill', 'none')
.attr('stroke', '#999999')
.attr('stroke-width', '1')
// pass to Observable to draw this block
return svg.node()
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more