Public
Edited
Sep 7, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
teams = _.uniq(big_south_games.map((o) => [o.name1, o.name2]).flat())
Insert cell
Insert cell
nodes = {
let wins_by_id = d3.rollup(
big_south_games,
(a) => a.length,
(o) => o.name1
);
return d3.sort(teams, (s) => -wins_by_id.get(s));
}
Insert cell
Insert cell
edges = Array.from(
d3
.rollup(
big_south_games,
(a) => `${a[0].name1} -> ${a[0].name2} [label = ${a.length}]`,
(o) => o.team1,
(o) => o.team2
)
.values()
)
.map((map) => Array.from(map.values()))
.flat()
Insert cell
Insert cell
{
let edges = [];
for (let i = 0; i < teams.length; i++) {
for (let j = 0; j < teams.length; j++) {
let i_over_j = big_south_games.filter((o) => o.idx1 == i && o.idx2 == j);
if (i_over_j.length > 0) {
let team1 = i_over_j[0].name1;
let team2 = i_over_j[0].name2;
edges.push(`${team1} -> ${team2} [label = ${i_over_j.length}]`);
}
}
}
return edges;
}
Insert cell
Insert cell
big_south_dot = `digraph{
size="${width / 100}"
${nodes};
${edges.join(";\n ")}
}`
Insert cell
Insert cell
{
let div = d3.create("div");
d3.graphviz(div.node()).renderDot(big_south_dot);
div.selectAll("title").remove();
div.selectAll("text").style("pointer-events", "none");
return div.node();
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
big_south_games = FileAttachment("big_south_games@1.csv").csv({ typed: true })
Insert cell
tippy_style
Insert cell
import { big_south_chord_diagram, tippy_style } from "cbbe8ab362fb60e2"
Insert cell
import {
viewof forces,
viewof again,
simulation
} from "@ddv373/d3-force-to-desired-position"
Insert cell
d3 = require("d3@7", "d3-graphviz@2")
Insert cell
math = require("mathjs")
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