website: redesign part 11

This commit is contained in:
nym21
2026-06-06 22:29:33 +02:00
parent 66dc7cd8f5
commit 041c542046
49 changed files with 17275 additions and 193 deletions
@@ -0,0 +1,53 @@
import { createAreaPathData, createLinePathData } from "../path.js";
import { createSvgElement } from "../svg.js";
import { createStackedSeries } from "./series.js";
/**
* @param {SVGGElement} group
* @param {LoadedSeries[]} loadedSeries
* @param {number} height
* @param {SeriesHighlight} highlight
* @param {{ reversed: boolean }} options
*/
export function renderStackedPlot(
group,
loadedSeries,
height,
highlight,
options,
) {
const { lineIndexes, plottedSeries, stackIndexes } = createStackedSeries(
loadedSeries,
height,
options.reversed,
);
for (const index of stackIndexes) {
const { color, points } = plottedSeries[index];
const path = createSvgElement("path");
path.dataset.chart = "stacked";
path.dataset.series = index.toString();
path.style.setProperty("--color", color);
path.setAttribute("d", createAreaPathData(points));
highlight.add(path, index);
group.append(path);
}
for (const index of lineIndexes) {
const { color, points } = plottedSeries[index];
const path = createSvgElement("path");
path.dataset.chart = "line";
path.dataset.series = index.toString();
path.style.setProperty("--color", color);
path.setAttribute("d", createLinePathData(points));
highlight.add(path, index);
group.append(path);
}
return plottedSeries;
}
/** @typedef {import("../highlight.js").SeriesHighlight} SeriesHighlight */
/** @typedef {import("../index.js").LoadedSeries} LoadedSeries */