Published
Edited
Oct 4, 2021
2 stars
Insert cell
Insert cell
Insert cell
/*
viewof choice = html`<select>
title: "Choisir un diagramme: "
<option selected value="sankey1">(societe-fournisseur) -> materiel (famille) -> prestataire -> (service proprietaire-site installation)
<option value="sankey2">(site installation) -> materiel (famille) -> sous-materiel (famille) -> service proprietaire
</select>`
*/
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//await FileAttachment("sankeyS5Z5.csv").csv({typed: true});
data = {
// const links = await FileAttachment("energy@3.csv").csv({typed: true});
const links = await FileAttachment("sankeyS5Z5_2@3.csv").csv({typed: true});
// const links = dataSankey;
const nodes = Array.from(new Set(links.flatMap(l => [l.source, l.target])), name => ({name, category: name.replace(/ .*/, "")}));
return {nodes, links, units: "éléments"};
}

Insert cell
/*
dataSankey = {
let mydata;
switch (choice) {
case "sankey1": mydata = await FileAttachment("sankeyS5Z5@1.csv").csv({typed: true}); break;
case "sankey2": mydata = await FileAttachment("sankeyS5Z5_2@1.csv").csv({typed: true}); break;
}
return mydata;
}
*/
Insert cell
width = 1024
Insert cell
height = 600
Insert cell
d3 = require("d3@6", "d3-sankey@0.12")
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