Public
Edited
Dec 15, 2022
Insert cell
Insert cell
Insert cell
nodes = await FileAttachment("nodes.csv").csv({ typed: true })
Insert cell
edges = await FileAttachment("edges.csv").csv({ typed: true })
Insert cell
Insert cell
parseData = (nodes, edges) => {
const data = {
nodes: [],
links: []
}
// Add nodes to data object
nodes.forEach(node => {
data.nodes.push({id: node.id, label: node.Label})
})
// Add edges to data object
edges.forEach(edge => {
data.links.push({source: edge.source, target: edge.target})
})
return data
}
Insert cell
Insert cell
network = parseData(nodes, edges);
Insert cell
Insert cell
Insert cell
import {ForceGraph} from "@d3/force-directed-graph"
Insert cell
graph = ForceGraph(network, {
nodeId: d => d.id,
nodeTitle: d => `${d.label}`, // pause mouse over node to see title
linkStrokeWidth: l => Math.sqrt(l.value),
width,
height: 600,
invalidation // a promise to stop the simulation when the cell is re-run
})
Insert cell
Insert cell
Insert cell
chart = panGraph(network)
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