import { value, text, applyMargins, getStackClass } from "../../helpers";
import { StackedBarPlotProps } from "./StackedBarPlotProps";
export const StackedBarPlot = ({ data, axis, chart }: StackedBarPlotProps) => {
const { min: [minx, miny], max: [maxx, maxy], size: [sx, sy], margins: { margin: [mx, my], startOffset: [ox, oy] } } = axis;
const { x1, x2, y1, y2 } = applyMargins(chart, axis.margins);
const points = data.map((i, index) => {
const [_x, _y] = i;
const x = value(_x);
const textx = text(_x);
const _cx = (x - minx) * (sx) / (maxx - minx) + ox;
const cx = _cx + mx;
const yPoints = _y.map((py, yi) => {
const y = value(py);
const texty = text(py);
const _cy = (y - miny) * (sy) / (maxy - miny) + oy;
const cy = y1 - _cy;
return { cy, texty, index: yi };
}).sort((a, b) => a.cy - b.cy);
return { cx, textx, yPoints };
});
return <>
{points.map(({ cx, yPoints }, pi) => {
return yPoints.map(({ cy, index }) =>
);
})}
{points.map(({ cx, yPoints }, pi) => {
return yPoints.map(({ cy, index }) => );
})}
{points.map(({ cx, yPoints, textx }, pi) => {
return yPoints.map(({ cy, texty, index }) =>
{textx}
{texty}
);
})}
>;
};