UNPKG

vue-data-ui

Version:

A user-empowering data visualization Vue 3 components library for eloquent data storytelling

79 lines (78 loc) 2.04 kB
import { watch as A, nextTick as D } from "vue"; function S({ timeLabelsEls: F, timeLabels: L, slicer: x, configRef: s, rotationPath: r, autoRotatePath: p, isAutoSize: N, setViewBox: y, forceResizeObserver: C, callback: o, targetClass: j = ".vue-data-ui-time-label", rotation: w = -30.0001, height: T = null, width: b = null }) { function i(a, n) { return n.reduce((e, t) => e && e[t], a); } function g(a, n, e) { n.slice(0, -1).reduce((t, l) => t[l], a)[n.slice(-1)] = e; } function q(a) { const n = /translate\(\s*([^\s,]+)\s*,\s*([^\s,]+)\s*\)/.exec(a); return n ? { x: parseFloat(n[1]), y: parseFloat(n[2]) } : { x: 0, y: 0 }; } async function c() { await D(); const a = F.value; if (!a) return; const e = Array.from(a.querySelectorAll(j)).map((u) => ({ ...q(u.getAttribute("transform")), width: u.getBBox().width })); let t = !1; const l = 4; for (let u = 0; u < e.length && !t; u += 1) for (let m = u + 1; m < e.length; m += 1) { const v = e[u], f = e[m]; if (!(v.x + v.width + l < f.x || f.x + f.width + l < v.x)) { t = !0; break; } } const d = i(s.value, r); t && !d ? (g(s.value, r, w), o && o({ collision: t }), N.value && y && C && (y(), C())) : !t && d === w && (g(s.value, r, 0), o && o({ collision: t })); } function B(a, n) { let e; return (...t) => { clearTimeout(e), e = setTimeout(() => a(...t), n); }; } const h = B(c, 200); return T && b && A([() => b.value, () => T.value], async ([a, n], [e, t]) => { if (!i(s.value, p)) return; a !== e || n !== t ? h() : await c(); }), A( [ () => L.value, () => i(s.value, r), () => x.value.start, () => x.value.end ], async ([, , a, n], [, , e, t]) => { if (!i(s.value, p)) return; a !== e || n !== t ? h() : await c(); }, { immediate: !0 } ), { detectTimeLabelCollision: c }; } export { S as u };