mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-13 12:08:13 -07:00
57 lines
1.3 KiB
JavaScript
57 lines
1.3 KiB
JavaScript
import { createAreaPathData, createLinePathData } from "../path.js";
|
|
import { appendSeriesPath } from "../series-path.js";
|
|
import { createStackedSeries } from "./series.js";
|
|
|
|
/**
|
|
* @param {SVGGElement} group
|
|
* @param {LoadedSeries[]} loadedSeries
|
|
* @param {number} height
|
|
* @param {SeriesHighlight} highlight
|
|
* @param {import("../scale.js").ChartScale} scale
|
|
* @param {import("../order.js").ChartOrder} order
|
|
*/
|
|
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;
|
|
}
|
|
|
|
/** @typedef {import("../highlight.js").SeriesHighlight} SeriesHighlight */
|
|
/** @typedef {import("../index.js").LoadedSeries} LoadedSeries */
|