Public
Edited
Jul 11, 2023
Insert cell
Insert cell
Insert cell
sankeyPlus = import("https://cdn.skypack.dev/sankey-plus@0.6.0?min")
Insert cell
Insert cell
nodes = [
{ name: "Mining" },
{ name: "Refining" },
{ name: "Material Formulation" },
{ name: "Component Manufact" },
{ name: "Product Assembly" },
{ name: "Product Distribution" },
{ name: "Usage" },
{ name: "Collection/Separation" },
{ name: "Resale" },
{ name: "Maintenance" },
{ name: "Refurbish" },
{ name: "Remanufacture" },
{ name: "Material Recycling" },
{ name: "Urban Mining" },
{ name: "Disposal" }
]
Insert cell
Insert cell
Insert cell
Insert cell
sankeyConfig = ({
width: width,
nodes: {
data: clone(nodes)
},
links: {
data: clone(links)
}
})
Insert cell
Insert cell
Insert cell
sankey = {
let obj = new sankeyPlus.SankeyChart(sankeyConfig);
obj.process();
return obj;
}
Insert cell
Insert cell
Insert cell
chart = {
let containerId = "chart-div";
let container = d3.create("div").attr("id", containerId);

//div needs to be rendered for the .draw() method to work with Observable
yield container.node();

sankey.draw(containerId);

return container.node();
}
Insert cell
Insert cell
exampleChart = draw(
{
width: width,
height: 400,
nodes: { data: clone(nodes), virtualNodePadding: 25 },
links: { virtualLinkType: "virtual", opacity: 0.5, data: clone(links) },
arrows: { enabled: true, color: "grey", length: 10, gap: 50 }
},
"chart-exampleChart-div"
)
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
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
circularGapChart = draw(
{
width: width,
nodes: { data: clone(nodes) },
links: {
circularGap: 20,
data: clone(links)
}
},
"chart-circulargap-div"
)
Insert cell
#### links.circularLinkPortionTopBottom
Insert cell
#### links.circularLinkPortionLeftRight
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
simpleNodes = [{ name: "node1" }, { name: "node2" }, { name: "node3" }]
Insert cell
Insert cell
Insert cell
Insert cell
#### links.baseRadius
Insert cell
#### links.verticalMargin
Insert cell
#### links.virtualLinkType
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
#### arrows.gap
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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