Published
Edited
Oct 22, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = splitgraph`SELECT COALESCE(
CASE
WHEN biome = ANY('{"CHACO HUMEDO", "CHACO SECO"}') THEN 'CHACO'
WHEN biome = 'AMAZONIA' THEN 'AMAZON'
WHEN biome = 'MATA ATLANTICA' THEN 'ATLANTIC FOREST'
WHEN biome = ANY('{"DELTA E ISLAS DEL PARANA", "ESPINAL", "ESTEROS DEL IBERA", "MONTE DE SIERRAS Y BOLSONES", "MONTE DE LLANURAS Y MESETAS", "YUNGAS"}') THEN 'OTHER'
WHEN biome = 'CAATINGA' THEN 'CERRADO'
ELSE biome END, country_of_production
) AS source, exporter_group, SUM(volume) AS value
FROM "trase/supply-chains"."supply-chains"
WHERE country_of_production = ANY('{${countries}}')
AND commodity = '${commodity.toUpperCase()}'
AND year = ${year}
AND economic_bloc = 'EUROPEAN UNION'
GROUP BY source, exporter_group`.then(res =>
res.map(d => ({
source:
d.source === "COTE D'IVOIRE" ? "Cote d'Ivoire" : titleCase(d.source),
exporter_group: titleCase(d.exporter_group),
value: +d.value
}))
)
Insert cell
import { titleCase } from "@trase/visual-id@1375"
Insert cell
colour = d => d3.scaleOrdinal()
.domain(new Set(data.map(d => d.source)))
.range(traseCategory1)(d.data[1].data[0].source)
Insert cell
import { chart, traseCategory1 } with {
data,
colour
} from "@trase/grouped-bubbles"
Insert cell
years = new Map([
["Soy", 2018],
["Beef", 2017],
["Palm oil", 2018],
["Cocoa", 2018]
])
Insert cell
countries = new Map([
["Soy", ["PARAGUAY", "BRAZIL", "ARGENTINA"]],
["Beef", ["PARAGUAY", "BRAZIL"]],
["Palm oil", ["INDONESIA"]],
["Cocoa", ["COTE D''IVOIRE", "GHANA"]]
]).get(commodity)
Insert cell
year = years.get(commodity)
Insert cell
d3 = require("d3@6")
Insert cell
import { select } from "@jashkenas/inputs"
Insert cell
import { splitgraph } from "@trase/splitgraph"
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