Published
Edited
Oct 18, 2021
Insert cell
Insert cell
Insert cell
Insert cell
data = Object.assign(
await splitgraph`SELECT country_of_import AS key1,
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", "MONTE DE LLANURAS Y MESETAS", "YUNGAS", "PAMPA"}') THEN 'OTHER'
WHEN biome = 'CAATINGA' THEN 'CERRADO'
ELSE biome END AS key2,
sum(COALESCE(commodity_deforestation, 0)) AS value
FROM "trase/supply-chains"."supply-chains"
WHERE scale = 'SUBNATIONAL'
AND commodity = 'BEEF'
AND year = '2017'
AND economic_bloc = 'EUROPEAN UNION'
GROUP BY country_of_import, biome
ORDER BY value DESC`.then(res =>
res.map(d => ({ ...d, key1: titleCase(d.key1), key2: titleCase(d.key2) }))
),
{ x: "Cattle deforestation risk (ha)" }
)
Insert cell
import { splitgraph } from "@trase/splitgraph"
Insert cell
import { titleCase } from "@trase/visual-id"
Insert cell
margin = ({ top: 30, right: 10, bottom: 30, left: Math.min(150, width / 4) })
Insert cell
annotate = g => g.attr("transform", `translate(${margin.left}, 0)`).append(() => legend)
Insert cell
import { chart, legend } with { data, margin, annotate } from "@trase/stacked-horizontal-bar-chart@921"
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