UNPKG

vue-data-ui

Version:

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

193 lines (192 loc) • 6.48 kB
function m(e, i, t, o = {}) { if (t <= 0) return; e.save(); const { color: s = "black", lineWidth: w = 1, lineCap: f = "round", lineJoin: r = "round", lineDash: g = null, lineDashoffset: a = 0, shadowColor: l = null, shadowBlur: h = 0, shadowOffsetX: y = 0, shadowOffsetY: u = 0, fillStyle: N = "#FFFFFF" } = o; e.beginPath(), e.arc(i.x, i.y, t, 0, 2 * Math.PI), e.strokeStyle = s, e.lineWidth = w, e.lineCap = f, e.lineJoin = r, g && (e.setLineDash(g), e.lineDashoffset = a), l && (e.shadowColor = l, e.shadowOffsetX = y, e.shadowOffsetY = u), h && (e.shadowBlur = h), N && (e.fillStyle = N), e.fillStyle && e.fill(), e.stroke(), e.restore(); } function L(e, i, t = {}) { if (!i.length) return; e.save(); const { color: o = "black", lineWidth: s = 1, lineCap: w = "round", lineJoin: f = "round", lineDash: r = null, lineDashoffset: g = 0, shadowColor: a = null, shadowBlur: l = 0, shadowOffsetX: h = 0, shadowOffsetY: y = 0 } = t; e.beginPath(), e.moveTo(i[0].x, i[0].y); for (let u = 1; u < i.length; u += 1) e.lineTo(i[u].x, i[u].y); e.strokeStyle = o, e.lineWidth = s, e.lineCap = w, e.lineJoin = f, r && (e.setLineDash(r), e.lineDashoffset = g), a && (e.shadowColor = a, e.shadowOffsetX = h, e.shadowOffsetY = y), l && (e.shadowBlur = l), e.stroke(), e.restore(); } function I(e, i, t = {}) { if (!i.length) return; e.save(); const { strokeColor: o = "black", lineWidth: s = 1, lineCap: w = "round", lineJoin: f = "round", lineDash: r = null, lineDashoffset: g = 0, fillColor: a = null, gradient: l = null, shadowColor: h = null, shadowBlur: y = 0, shadowOffsetX: u = 0, shadowOffsetY: N = 0 } = t; e.beginPath(), e.moveTo(i[0].x, i[0].y); for (let n = 1; n < i.length; n += 1) e.lineTo(i[n].x, i[n].y); if (e.closePath(), e.strokeStyle = o, e.lineWidth = s, e.lineCap = w, e.lineJoin = f, r && (e.setLineDash(r), e.lineDashoffset = g), h && (e.shadowColor = h, e.shadowBlur = y, e.shadowOffsetX = u, e.shadowOffsetY = N), l) { let n; l.type === "linear" ? n = e.createLinearGradient( d(l.start.x, Number.MIN_VALUE), d(l.start.y, Number.MIN_VALUE), d(l.end.x, Number.MIN_VALUE * 2), d(l.end.y, Number.MIN_VALUE * 2) ) : l.type === "radial" && (n = e.createRadialGradient( d(l.start.x, Number.MIN_VALUE), d(l.start.y, Number.MIN_VALUE), l.start.r || 0, d(l.end.x, Number.MIN_VALUE * 2), d(l.end.y, Number.MIN_VALUE * 2), l.end.r || 0 )), n && l.stops && (l.stops.forEach((b) => { n.addColorStop(b.offset, b.color); }), e.fillStyle = n); } else a && (e.fillStyle = a); e.fillStyle && e.fill(), o && e.stroke(), e.restore(); } function O(e, i, t = {}) { if (!i.length) return; e.save(); const { strokeColor: o = "black", lineWidth: s = 1, lineCap: w = "round", lineJoin: f = "round", lineDash: r = null, lineDashoffset: g = 0, fillColor: a = null, gradient: l = null, shadowColor: h = null, shadowBlur: y = 0, shadowOffsetX: u = 0, shadowOffsetY: N = 0 } = t; e.beginPath(), e.moveTo(i[0].x, i[0].y); for (let n = 1; n < i.length; n += 1) e.lineTo(i[n].x, i[n].y); if (e.closePath(), e.strokeStyle = o, e.lineWidth = s, e.lineCap = w, e.lineJoin = f, r && (e.setLineDash(r), e.lineDashoffset = g), h && (e.shadowColor = h, e.shadowBlur = y, e.shadowOffsetX = u, e.shadowOffsetY = N), l) { let n; l.type === "linear" ? n = e.createLinearGradient( d(l.start.x, Number.MIN_VALUE), d(l.start.y, Number.MIN_VALUE), d(l.end.x, Number.MIN_VALUE * 2), d(l.end.y, Number.MIN_VALUE * 2) ) : l.type === "radial" && (n = e.createRadialGradient( d(l.start.x, Number.MIN_VALUE), d(l.start.y, Number.MIN_VALUE), l.start.r || 0, d(l.end.x, Number.MIN_VALUE * 2), d(l.end.y, Number.MIN_VALUE * 2), l.end.r || 0 )), n && l.stops && (l.stops.forEach((b) => { n.addColorStop(b.offset, b.color); }), e.fillStyle = n); } else a && (e.fillStyle = a); e.fillStyle && e.fill(), o && e.stroke(), e.restore(); } function A(e, i, t, o, s = {}) { e.save(); const { font: w = "16px sans-serif", color: f = "black", align: r = "start", baseline: g = "alphabetic", maxWidth: a = void 0, rotation: l = 0, shadowColor: h = null, shadowBlur: y = 0, shadowOffsetX: u = 0, shadowOffsetY: N = 0, strokeColor: n = null, lineWidth: b = 1, globalAlpha: p = 1 } = s; e.font = w, e.fillStyle = f, e.textAlign = r, e.textBaseline = g, e.globalAlpha = p, h && (e.shadowColor = h, e.shadowBlur = y, e.shadowOffsetX = u, e.shadowOffsetY = N), n && (e.strokeStyle = n, e.lineWidth = b), l !== 0 && (e.translate(t, o), e.rotate(Math.PI / 180 * l), e.translate(-t, -o)), e.fillText(i, t, o, a), n && e.strokeText(i, t, o, a), e.restore(); } function E(e, i = 20) { let t; return function(...o) { const s = this; t || (e.apply(s, o), t = !0, setTimeout(() => t = !1, i)); }; } function S(e, i, t = !1) { let o; return function(...s) { const w = this, f = function() { o = null, t || e.apply(w, s); }, r = t && !o; clearTimeout(o), o = setTimeout(f, i), r && e.apply(w, s); }; } function k(e) { const i = document.createElement("canvas"); return i.width = e.width || 1, i.height = e.height || 1, e.width || (e.width = 1), e.height || (e.height = 1), i.getContext("2d").drawImage(e, 0, 0), i; } function d(e, i) { return [null, void 0, NaN, 1 / 0, -1 / 0].includes(e) ? i : e; } function M({ chart: e, title: i = null, slicer: t = null, legend: o = null, source: s = null, noTitle: w = null, padding: f = null }) { let r = 0, g = 0, a = 0, l = 0, h = 0, y = 0, u = 0, N = 0, n = 0; if (e) { const b = e.parentNode, { height: p, width: C } = b.getBoundingClientRect(); i && (a = i.getBoundingClientRect().height), t && (l = t.getBoundingClientRect().height), o && (h = o.getBoundingClientRect().height), s && (y = s.getBoundingClientRect().height), w && (u = w.getBoundingClientRect().height), f && (N = f.top + f.bottom, n = f.right + f.left), r = p - a - l - h - y - u - N, g = C - n; } return { width: g, height: r, heightTitle: a, heightNoTitle: u }; } export { m as a, A as b, k as c, S as d, L as l, I as p, O as r, E as t, M as u };