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