mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-03 07:14:01 -07:00
49 lines
964 B
JavaScript
49 lines
964 B
JavaScript
import { createAreaPathData, createLinePathData } from "../path.js";
|
|
import { appendSeriesPath } from "../series-path.js";
|
|
import { createStackedSeries } from "./series.js";
|
|
|
|
/**
|
|
* @param {PlotContext} context
|
|
*/
|
|
export function renderStackedPlot({
|
|
group,
|
|
loadedSeries,
|
|
height,
|
|
highlight,
|
|
scale,
|
|
order,
|
|
}) {
|
|
const { lineIndexes, plottedSeries, stackIndexes } = createStackedSeries(
|
|
loadedSeries,
|
|
height,
|
|
order,
|
|
scale,
|
|
);
|
|
|
|
for (const index of stackIndexes) {
|
|
const { color, points } = plottedSeries[index];
|
|
appendSeriesPath({
|
|
group,
|
|
highlight,
|
|
index,
|
|
chart: "stacked",
|
|
color,
|
|
d: createAreaPathData(points),
|
|
});
|
|
}
|
|
|
|
for (const index of lineIndexes) {
|
|
const { color, points } = plottedSeries[index];
|
|
appendSeriesPath({
|
|
group,
|
|
highlight,
|
|
index,
|
|
chart: "line",
|
|
color,
|
|
d: createLinePathData(points),
|
|
});
|
|
}
|
|
|
|
return plottedSeries;
|
|
}
|