Public
Edited
Dec 14, 2023
1 star
Insert cell
Insert cell
Select a data source…
Type Chart, then Shift-Enter. Ctrl-space for more options.

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
Insert cell
top = d3.csvParse(await FileAttachment("topcoach.csv").text())
Insert cell
Insert cell
Plot.plot({
marginLeft: 100,
marks: [
Plot.barX(top, {x: "years", y: "coach", fill: "purple", sort: {y: "x", reverse: true}}),
Plot.ruleX([0])
]
})
Insert cell
Insert cell
win_rates = d3.csvParse(await FileAttachment("belichick_coaches@3.csv").text())
Insert cell
Plot.rectY(win_rates, Plot.binX({y: "count"}, {x: "total_wr"})).plot()
Insert cell
Insert cell
Plot.plot({
round: true,
color: {legend: true},
marks: [
Plot.rectY(win_rates, Plot.binX({y2: "count"}, {x: "total_wr", fill: "type_of_coach", mixBlendMode: "multiply"})),
Plot.ruleY([0])
]
})
Insert cell
Insert cell
Plot.plot({
y: {
grid: true,
inset: 6,
type: "linear"
},
marks: [
Plot.boxY(win_rates, {x: "depth", y: "total_wr"}),
]
})
Insert cell
Insert cell
FileAttachment("sparql.txt").text()
Insert cell
Select a data source…
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
FileAttachment("belichick_preprocess.py").text()
Insert cell
FileAttachment("belichick_tree.txt").text()
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