function areaChart(
data,
{
x = "x",
y = "y",
grouping,
stack = false,
width,
height,
yLabel,
yTickFormat,
xLabel,
xTickFormat,
fillOpacity,
strokeWidth = 0.75,
scheme = schemeCategory10
} = {}
) {
const yParams = stack ? { y } : { y2: y };
fillOpacity = fillOpacity == null && stack ? fillOpacity : 0.125;
const stroke = stack
? "white"
: grouping == null
? main.blue["700"]
: grouping;
scheme = stack ? scheme.slice().reverse() : scheme;
return Plot.plot({
width,
height,
y: { grid: true, label: yLabel, tickFormat: yTickFormat },
x: { label: xLabel, tickFormat: xTickFormat },
color: { legend: true, range: scheme },
marks: [
Plot.areaY(data, {
...yParams,
x,
fill: grouping == null ? main.blue["700"] : grouping,
fillOpacity,
stroke,
strokeWidth
}),
Plot.ruleY([0])
]
});
}