Public
Edited
Apr 24, 2023
1 fork
Insert cell
Insert cell
viewof raw_data_string = csvInput({
initialUrl: await FileAttachment("sankey@4.csv").url()
})
Insert cell
Insert cell
data = d3.csvParse(raw_data_string, d3.autoType)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
_ = require('lodash');
Insert cell
d3 = require("d3@5", "d3-sankey@0.12")
Insert cell
keys = data.columns.slice(0, -1) // get all but last column from the data defined above
Insert cell
data_color = [...new Set(data.map(d => d[Object.keys(d)[0]]))] // all unique values from the 1st column
Insert cell
// leaving like this if in the future different colors needed
color = d3.scaleOrdinal(data_color.slice(0,2), ["#7C6A6A","#7C6A6A"]).unknown("#7C6A6A")
Insert cell
color1 = "#DEDEDE"
Insert cell
color2 = "#CC0000"
Insert cell
height = 720 - adj*2
Insert cell
adj = 50
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