Files
brk/website_next/learn/charts/viewbox.js
T
2026-06-06 22:29:33 +02:00

12 lines
308 B
JavaScript

export const VIEWBOX_WIDTH = 640;
export const FALLBACK_VIEWBOX_HEIGHT = 220;
/** @param {SVGSVGElement} svg */
export function getViewBoxHeight(svg) {
const { width, height } = svg.getBoundingClientRect();
return width && height
? (VIEWBOX_WIDTH * height) / width
: FALLBACK_VIEWBOX_HEIGHT;
}