Published
Edited
Nov 18, 2020
1 star
Insert cell
Insert cell
Insert cell
Insert cell
width = 900
Insert cell
height = 500
Insert cell
margin = ({
top: 10,
right: 0,
bottom: 30,
left: 30
})
Insert cell
colors = d3.scaleOrdinal(
Meat.categories,
d3.schemeGnBu[9].slice(3)
)
Insert cell
xScale = d3.scaleBand(
Meat.map(d => d.location),
[ margin.left, width - margin.right ]
).padding(0.2)
Insert cell
yScale = d3.scaleLinear(
[ 0, d3.max(Meat, d => d.total) ],
[ height - margin.bottom, margin.top ]
)
Insert cell
xAxis = d3.axisBottom(xScale)
.tickSizeOuter(0)
Insert cell
yAxis = d3.axisLeft(yScale)
Insert cell
stack = d3.stack()
.keys( Meat.categories )
Insert cell
stack(Meat)
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