Public
Edited
Sep 14, 2022
1 fork
24 stars
Insert cell
Insert cell
{
const canvas = DOM.canvas(width, 700);
yield canvas;
const graph = new cosmo.Graph(canvas, config);
graph.setData(nodes, links);
graph.zoom(0.9);

invalidation.then(() => {
// TODO
});
}
Insert cell
mutable clicked = null
Insert cell
cosmo = import("https://cdn.skypack.dev/@cosmograph/cosmos@1")
Insert cell
Insert cell
// "https://cosmograph.app/data/jan99jac040sc.csv"
data = FileAttachment("jan99jac040sc.csv").csv({ typed: true })
Insert cell
nodes = [...new Set(data.flatMap((d) => [d.source, d.target]))].map(id => ({id}))
Insert cell
Insert cell
config = ({
backgroundColor: "#151515",
nodeSize: 3,
nodeColor: "#984040",
linkWidth: 0.1,
linkColor: "#8C8C8C",
linkArrows: false,
simulation: {
linkDistance: 1,
linkSpring: 2,
repulsion: 0.1,
gravity: 0.1,
decay: 10000
},
events: {
onClick: (node) => (mutable clicked = node)
}
})
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