Public
Edited
Feb 5, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data1 = FileAttachment("Viz1.csv").csv({typed: true})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
types = Array.from(new Set(links.map(d => d.type)))
Insert cell
data = ({nodes: Array.from(new Set(links.flatMap(l => [l.source, l.target])), id => ({id})), links})
Insert cell
height = 1000
Insert cell
color = d3.scaleOrdinal(types, d3.schemeCategory10)
Insert cell
function linkArc(d) {
const r = Math.hypot(d.target.x - d.source.x, d.target.y - d.source.y);
return `
M${d.source.x},${d.source.y}
A${r},${r} 0 0,1 ${d.target.x},${d.target.y}
`;
}
Insert cell
drag = simulation => {
function dragstarted(event, d) {
if (!event.active) simulation.alphaTarget(0.3).restart();
d.fx = d.x;
d.fy = d.y;
}
function dragged(event, d) {
d.fx = event.x;
d.fy = event.y;
}
function dragended(event, d) {
if (!event.active) simulation.alphaTarget(0);
d.fx = null;
d.fy = null;
}
return d3.drag()
.on("start", dragstarted)
.on("drag", dragged)
.on("end", dragended);
}
Insert cell
d3 = require("d3@6")
Insert cell
import {swatches} from "@d3/color-legend"
Insert cell
Insert cell
/*
SPARQL QUERY

SELECT ?hospitalLabel ?cityLabel ?hospital ?city
WHERE {
?hospital wdt:P31 wd:Q16917.
?hospital wdt:P17 wd:Q30.
?hospital wdt:P131 ?city.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}

*/
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
hospitals = FileAttachment("Dh150 Final Project - Viz2 (1).csv").csv({typed: true})
Insert cell
namemap = new Map(us.objects.states.geometries.map(d => [d.properties.name, d.id]))
Insert cell
us = FileAttachment("counties-albers-10m.json").json()
Insert cell
import {Legend} from "@d3/color-legend"
Insert cell
valuemap = new Map(hospitals.map(d => [d.name, d.rate]))
Insert cell
Insert cell
/*
SPARQL QUERY

SELECT ?disease ?doid ?enLabel (count(?language) as ?languages)
WHERE
{
?disease wdt:P699 ?doid ;
rdfs:label ?label ;
rdfs:label ?enLabel .
FILTER (lang(?enLabel) = "en")
BIND (lang(?label) AS ?language)
}
GROUP BY ?disease ?doid ?enLabel
ORDER BY desc(?languages)

LIMIT 1000

*/
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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