2024-05-31 20:07:00 +02:00
|
|
|
/**
|
|
|
|
* Graph Logic
|
|
|
|
*
|
|
|
|
* Scales graphs, makes graphs resizable, and stuff like that
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { $, $$ } from './utils/dom';
|
|
|
|
|
|
|
|
function resizeGraphs() {
|
|
|
|
$$<SVGSVGElement>('#js-sparkline-svg').forEach(el => {
|
|
|
|
const parent: HTMLElement | null = el.parentElement;
|
|
|
|
|
|
|
|
if (parent) {
|
|
|
|
el.viewBox.baseVal.width = parent.clientWidth;
|
|
|
|
|
|
|
|
const graph: SVGPathElement | null = $<SVGPathElement>('#js-barline-graph', el);
|
|
|
|
|
|
|
|
if (graph) {
|
2024-05-31 20:21:45 +02:00
|
|
|
graph.style.transform = `scaleX(${parent.clientWidth / 375})`;
|
2024-05-31 20:07:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function sizeGraphs() {
|
|
|
|
resizeGraphs();
|
|
|
|
window.addEventListener('resize', resizeGraphs);
|
|
|
|
}
|
|
|
|
|
|
|
|
export { sizeGraphs };
|