Public
Edited
Apr 13, 2023
Insert cell
Insert cell
Insert cell
Insert cell
graph = FileAttachment("miserables.json").json()
Insert cell
data = {
const {nodes, links} = graph1;
const groupById = new Map;
const nodeById = new Map(nodes.map(node => [node.id, node]));

for (const node of nodes) {
let group = groupById.get(node.group);
if (!group) groupById.set(node.group, group = {id: node.group, children: []});
group.children.push(node);
node.targets = [];
node.commonMetrics = [];
}

for (const {source: sourceId, target: targetId, common_metric_name: commonMetrics} of links) {
nodeById.get(sourceId).targets.push(targetId);
nodeById.get(sourceId).commonMetrics = commonMetrics
nodeById.get(targetId).commonMetrics = commonMetrics
}

return {children: [...groupById.values()]};
}
Insert cell
Insert cell
colorin = "OrangeRed"
Insert cell
colorout = "steelblue"
Insert cell
colornone = "#ccc"
Insert cell
width = 954
Insert cell
radius = width / 2
Insert cell
line = d3.lineRadial()
.curve(d3.curveBundle.beta(0.85))
.radius(d => d.y)
.angle(d => d.x)
Insert cell
tree = d3.cluster()
.size([2 * Math.PI, radius - 100])
Insert cell
d3 = require("d3@6")
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