Published
Edited
Apr 20, 2021
4 stars
Insert cell
Insert cell
Insert cell
Insert cell
gigaformat = d3.formatPrefix(".3",1e+9)
Insert cell
padding = 10
Insert cell
Insert cell
colors = d3.scaleSequential()
.domain([Math.log(min), Math.log(max)])
.interpolator(d3.piecewise(d3.interpolateRgb.gamma(0.5), ["#3B9AB2","#78B7C5", "#EBCC2A", "#F21A00"]))
Insert cell
hierarchy = d3.hierarchy(data)
.sum(d => d.value)
.sort((a, b) => b.value - a.value)
Insert cell
pack = squarePacking(hierarchy, "Tons of Plastic", "produced: 1950-2015")
Insert cell
data = {
var children = []
for (let dec of decades){
let m = d3.min([dec+9,2015])
children.push({"name":dec+"-"+m,"children":data_raw.filter(d => d.name>=dec & d.name <= m)});
}
return ({"children":children});
}
Insert cell
decades = [1950, 1960, 1970,1980,1990,2000,2010]
Insert cell
data_raw = d3.csvParse(await FileAttachment("30daychart - plastic_year-2.csv").text(), ({name, m_tons}) => ({name: name, value: +m_tons})).sort((a, b) => b.year - a.year)
Insert cell
max = d3.sum(data_raw, d=>d.value)
Insert cell
min = d3.min(data_raw.map(d =>d.value))
Insert cell
x = d3
.scaleSqrt()
.domain([d3.min(data_raw.map(d =>d.value)), d3.max(data_raw.map(d =>d.value)) ])
.range([width/100, 15*width])
.nice()
Insert cell
Insert cell
import {d3, chart, color} from "@d3/circle-packing"
Insert cell
import { boundingBox, SquareArrangement } from "@esperanc/square-packing"
Insert cell
html`<link href="https://fonts.googleapis.com/css?family=IBM+Plex+Mono&display=swap" rel="stylesheet">`
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