function marimekko({
sequence = "xy",
anchor = "",
reverseX,
reverseY,
...options
}) {
const [first, second] = maybeAnchor("" + anchor);
switch (sequence) {
case "xy":
return marimekkoXY(
Plot[["stackX", "stackX1", "stackX2"][first]],
Plot[["stackY", "stackY1", "stackY2"][second]],
{ reverseX, reverseY, ...options }
);
case "yx":
return marimekkoYX(
Plot[["stackY", "stackY1", "stackY2"][first]],
Plot[["stackX", "stackX1", "stackX2"][second]],
{ reverseX: reverseY, reverseY: reverseX, ...options }
);
default:
throw new Error(`Unkown marimekko sequence: ${sequence}`);
}
function maybeAnchor(anchor) {
let sx = 0;
let sy = 0;
if (anchor.match(/^bottom\b/i)) sy = 1;
if (anchor.match(/^top\b/i)) sy = 2;
if (anchor.match(/\bleft$/i)) sx = 1;
if (anchor.match(/\bright$/i)) sx = 2;
return [sx, sy];
}
}