UNPKG

@frontify/fondue-charts

Version:

Frontify's data viz library

19 lines (18 loc) • 795 B
import { useState as u, useEffect as L } from "react"; import { DEFAULT_PADDING as S } from "../consts.es.js"; const v = (e, s, n) => { const [c, l] = u("label"), [r, h] = u(e), i = r / 2, t = c === "label" ? n : S, f = [t.left + i, t.top + i], m = r + t.left + t.right, d = r + t.top + t.bottom; return L(() => { const o = () => { const w = e + n.left + n.right; s.current && (s.current.clientWidth < w ? (l("legend"), h(Math.min(s.current.clientWidth, e))) : (h(e), l("label"))); }; return o(), window.addEventListener("resize", o), () => { window.removeEventListener("resize", o); }; }, [e, n, s]), { radius: i, center: f, width: m, height: d, labelStyle: c }; }; export { v as useResponsiveChart }; //# sourceMappingURL=useResponsiveChart.es.js.map