Public
Edited
Dec 15, 2022
Insert cell
Insert cell
d3 = require("d3@6")
Insert cell
viewof x = mapOptions()
Insert cell
chart = {
const width = 1300,
height = 800;
const svg = d3.create("svg")
.attr("viewBox", [25, 25, width-100, height-90]);

// Use Mercator projection
var projection = d3
.geoMercator()
.fitSize([width - 10, height - 40], DCbb);
var path1 = d3.geoPath().projection(projection);
var path2 = d3.geoPath().projection(projection);
var path3 = d3.geoPath().projection(projection);
var path4 = d3.geoPath().projection(projection);
var path5 = d3.geoPath().projection(projection);
var path6 = d3.geoPath().projection(projection);
var path7 = d3.geoPath().projection(projection);
var path8 = d3.geoPath().projection(projection);
var path9 = d3.geoPath().projection(projection);
var path10 = d3.geoPath().projection(projection);
var path11 = d3.geoPath().projection(projection);
var path12 = d3.geoPath().projection(projection);
var g = svg.append("g").attr("id", "paths");




g.selectAll("path9") //d3 geopath
.data(DMV_stateboundaries.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','static')
.attr("d", path6) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.style("stroke", "rgb(0,0,0)")
.style('stroke-opacity','.05')
.style("stroke-width", '3')








return svg.node();

}
Insert cell
mapRegions = [
{ region: 'boundingbox_DC',
bounds: [[-77.595155, 39.195340], [-76.780821, 38.703513]],
},
{ region: 'boundingbox_MALL',
bounds: [[-77.059341, 38.867852], [-76.980985, 38.907220]],
}
]
Insert cell
mapOptions = () => {
const buttons = html`
<form>
<input value="Full metro system" type="button" name="zoomOUT">
<input value="Zoom in to National Mall" type="button" name="zoomIN">
</form>
`
buttons.value = true
buttons.zoomOUT.onclick = event => {
buttons.value = true;
event.preventDefault(); // Don’t submit the form.
buttons.dispatchEvent(new CustomEvent("input"));
}
buttons.zoomIN.onclick = event => {
buttons.value = false;
event.preventDefault(); // Don’t submit the form.
buttons.dispatchEvent(new CustomEvent("input"));
}
return buttons
}
Insert cell
width_a = width
Insert cell
height = width_a / 2;
Insert cell
DCbb = FileAttachment("DC_BB.geojson").json()
Insert cell
DCinset = FileAttachment("DC_BB_inset.geojson").json()
Insert cell
DMV_stateboundaries = FileAttachment("DMV_stateboundaries.geojson").json()
Insert cell
DCstationsGROWTH = FileAttachment("DCnewlines5.csv").csv()
Insert cell
DClines = FileAttachment("DClinesFUTURE_5.geojson").json()
Insert cell
lines1976 = FileAttachment("1976lines_V2.geojson").json()
Insert cell
lines1978 = FileAttachment("1978lines_V2.geojson").json()
Insert cell
lines1983 = FileAttachment("1983lines_V2.geojson").json()
Insert cell
lines1991 = FileAttachment("1991lines_V2.geojson").json()
Insert cell
lines2004 = FileAttachment("2004lines_V2.geojson").json()
Insert cell
import { wrap_text, wrap_text_nchar } from "@ben-tanen/svg-text-and-tspan-word-wrapping"
Insert cell
chronology = ['Current','1976','1978','1983','1991','2004','2022','2026','2028','2030']
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