Published
Edited
Jan 19, 2022
3 forks
17 stars
Insert cell
Insert cell
mutable station = ""
Insert cell
chart = d3
.create("div")
.datum(data)
.call(map)
.call((g) => g.select("svg").attr("height", height))
.call(
d3.zoom().on("zoom", function (e) {
d3.select(this).select("g").attr("transform", e.transform.toString());
})
)
.node()
Insert cell
data = FileAttachment("stations.json").json()
Insert cell
height = 1000
Insert cell
map = tubeMap()
.width(width)
.height(height)
.margin({
top: 20,
right: 20,
bottom: 40,
left: 100
})
.on("click", (name) => (mutable station = name))
Insert cell
style = htl.html`<style>
text {
font-family: sans-serif;
fill: #0019A8;
cursor: pointer;
}
</style>`
Insert cell
tubeMap = (await require("d3-tube-map@1.5.0/dist/d3-tube-map.min.js")).tubeMap
Insert cell
d3 = require("d3@7")
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