@ck-ui/component-library 1.0.10 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doughnutHelper.d.ts","sourceRoot":"","sources":["../../../../lib/components/FusionChart/_helpers/doughnutHelper.ts"],"names":[],"mappings":"AAAA,UAAU,gBAAgB;IACxB,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,WAAW,CAAC;QACxB,kBAAkB,CAAC,EAAE;YACnB,KAAK,CAAC,EAAE;gBAAE,YAAY,CAAC,EAAE,MAAM,CAAA;aAAE,CAAC;YAClC,IAAI,CAAC,EAAE,KAAK,CAAC;gBAAE,KAAK,CAAC,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,CAAA;aAAE,CAAC,CAAC;SACjD,CAAC;KACH,CAAC;CACH;
|
|
1
|
+
{"version":3,"file":"doughnutHelper.d.ts","sourceRoot":"","sources":["../../../../lib/components/FusionChart/_helpers/doughnutHelper.ts"],"names":[],"mappings":"AAAA,UAAU,gBAAgB;IACxB,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,WAAW,CAAC;QACxB,kBAAkB,CAAC,EAAE;YACnB,KAAK,CAAC,EAAE;gBAAE,YAAY,CAAC,EAAE,MAAM,CAAA;aAAE,CAAC;YAClC,IAAI,CAAC,EAAE,KAAK,CAAC;gBAAE,KAAK,CAAC,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,CAAA;aAAE,CAAC,CAAC;SACjD,CAAC;KACH,CAAC;CACH;AAsKD,wBAAgB,oBAAoB,CAAC,MAAM,GAAE,gBAAqB,GAAG,IAAI,CAkKxE"}
|
|
@@ -1,80 +1,119 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
function v(i, b) {
|
|
2
|
+
if (i.length < 2) return;
|
|
3
|
+
const h = [], o = [];
|
|
4
|
+
i.forEach((t) => {
|
|
5
|
+
t.x < b ? h.push(t) : o.push(t);
|
|
6
|
+
}), E(h), E(o);
|
|
7
|
+
}
|
|
8
|
+
function E(i) {
|
|
9
|
+
if (i.length < 2) return;
|
|
10
|
+
i.sort((t, n) => t.originalY - n.originalY);
|
|
11
|
+
for (let t = 1; t < i.length; t++) {
|
|
12
|
+
const n = i[t - 1], l = i[t], c = 54;
|
|
13
|
+
if (Math.abs(n.x - l.x) > 100) continue;
|
|
14
|
+
l.y - n.y < c && (l.y = n.y + c);
|
|
15
|
+
}
|
|
16
|
+
const b = i.reduce((t, n) => t + n.originalY, 0) / i.length, o = i.reduce((t, n) => t + n.y, 0) / i.length - b;
|
|
17
|
+
if (o > 10) {
|
|
18
|
+
const t = Math.min(o * 0.5, i[0].y - i[0].originalY);
|
|
19
|
+
t > 0 && i.forEach((n) => {
|
|
20
|
+
n.y -= t;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
i.forEach((t) => {
|
|
24
|
+
const n = t.y - t.originalY;
|
|
25
|
+
if (Math.abs(n) < 1) return;
|
|
26
|
+
t.el.setAttribute("y", String(t.y));
|
|
27
|
+
const l = t.el.querySelectorAll("tspan");
|
|
28
|
+
if (l.length > 0) {
|
|
29
|
+
const c = l[0], f = c.getAttribute("y");
|
|
30
|
+
f && c.setAttribute("y", String(parseFloat(f) + n));
|
|
31
|
+
}
|
|
32
|
+
t.connectorPath && t.originalD && I(t.connectorPath, t.originalD, n);
|
|
7
33
|
});
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
34
|
+
}
|
|
35
|
+
function I(i, b, h) {
|
|
36
|
+
const o = /(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)/g, t = [];
|
|
37
|
+
let n;
|
|
38
|
+
for (; (n = o.exec(b)) !== null; )
|
|
39
|
+
t.push({
|
|
40
|
+
x: n[1],
|
|
41
|
+
y: n[2],
|
|
42
|
+
index: n.index,
|
|
43
|
+
length: n[0].length
|
|
44
|
+
});
|
|
45
|
+
if (t.length < 2) return;
|
|
46
|
+
let l = b;
|
|
47
|
+
for (let c = t.length - 1; c >= 1; c--) {
|
|
48
|
+
const f = t[c], m = parseFloat(f.y) + h, y = `${f.x},${m}`;
|
|
49
|
+
l = l.substring(0, f.index) + y + l.substring(f.index + f.length);
|
|
50
|
+
}
|
|
51
|
+
i.setAttribute("d", l);
|
|
52
|
+
}
|
|
53
|
+
function T(i = {}) {
|
|
54
|
+
const b = i?.sender?.container;
|
|
55
|
+
if (!b) return;
|
|
56
|
+
const h = i?.sender?.originalDataSource?.data || [], o = i?.sender?.originalDataSource?.chart?.numberPrefix || "", t = h.reduce((s, r) => s + (Number(r.value) || 0), 0), n = {};
|
|
57
|
+
h.forEach((s) => {
|
|
58
|
+
s.label && (n[s.label] = { value: s.value, label: s.label });
|
|
59
|
+
});
|
|
60
|
+
const l = new Set(h.map((s) => s.label).filter(Boolean)), c = b.querySelector("svg"), f = c ? parseFloat(c.getAttribute("width") || String(c.getBoundingClientRect().width)) / 2 : 300, m = Array.from(b.querySelectorAll("text")), y = [];
|
|
61
|
+
m.forEach((s) => {
|
|
62
|
+
const r = s, a = r?.textContent?.trim() || "";
|
|
63
|
+
if (n[a] || a.length === 0) return;
|
|
64
|
+
const A = String(t);
|
|
65
|
+
if (h.some((u) => {
|
|
66
|
+
const e = Number(u.value) || 0, d = t > 0 ? (e / t * 100).toFixed(2) : "0", x = `${o}${u.value} (${d}%)`;
|
|
67
|
+
return a.includes(x) || u.label && a.includes(u.label) && a.includes(o);
|
|
16
68
|
})) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
69
|
+
y.push(r);
|
|
70
|
+
const u = r.querySelectorAll("tspan");
|
|
71
|
+
u.length > 0 ? u.forEach((e, d) => {
|
|
72
|
+
const x = e.textContent?.trim() || "";
|
|
73
|
+
if (e.setAttribute("font-family", "Inter, sans-serif"), d === 0 || !l.has(x) && x.includes(o)) {
|
|
74
|
+
const w = x.match(/^(.+?)(\s*\(\d+\.\d+%\))$/);
|
|
75
|
+
if (w) {
|
|
76
|
+
const B = w[1], L = w[2];
|
|
77
|
+
e.textContent = "", e.setAttribute("font-size", "10"), e.setAttribute("fill", "#2B2B2B"), e.setAttribute("font-weight", "600");
|
|
78
|
+
const S = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
|
|
79
|
+
S.textContent = L, S.setAttribute("font-weight", "400"), e.appendChild(document.createTextNode(B)), e.appendChild(S);
|
|
27
80
|
} else
|
|
28
|
-
|
|
81
|
+
e.setAttribute("font-weight", "600"), e.setAttribute("font-size", "10"), e.setAttribute("fill", "#2b2b2b");
|
|
29
82
|
} else
|
|
30
|
-
|
|
31
|
-
}) : (
|
|
83
|
+
e.setAttribute("font-weight", "400"), e.setAttribute("font-size", "10"), e.setAttribute("fill", "#737373"), d === 1 && e.setAttribute("dy", "16");
|
|
84
|
+
}) : (r.setAttribute("font-family", "Inter, sans-serif"), r.setAttribute("font-weight", "700"), r.setAttribute("fill", "#2b2b2b"));
|
|
32
85
|
return;
|
|
33
86
|
}
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
}) : (
|
|
87
|
+
if (a.includes(A) || a.includes("Total") || a.includes("Resource")) {
|
|
88
|
+
const u = r.querySelectorAll("tspan");
|
|
89
|
+
u.length > 0 ? u.forEach((e) => {
|
|
90
|
+
const d = e.textContent?.trim() || "";
|
|
91
|
+
e.setAttribute("font-family", "Inter, sans-serif"), d === A || d === `${o}${t}` ? (e.setAttribute("font-weight", "600"), e.setAttribute("font-size", "11"), e.setAttribute("fill", "#2B2B2B"), e.setAttribute("dy", "16")) : (e.setAttribute("font-weight", "400"), e.setAttribute("font-size", "10"), e.setAttribute("fill", "#737373"));
|
|
92
|
+
}) : (r.setAttribute("font-family", "Inter, sans-serif"), a === A || a === `${o}${t}` ? (r.setAttribute("font-weight", "600"), r.setAttribute("font-size", "11"), r.setAttribute("fill", "#2B2B2B")) : (r.setAttribute("font-weight", "400"), r.setAttribute("font-size", "10"), r.setAttribute("fill", "#737373")));
|
|
40
93
|
}
|
|
41
94
|
});
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
x[n] && p.push(e);
|
|
50
|
-
});
|
|
51
|
-
const S = [];
|
|
52
|
-
p.forEach((e) => {
|
|
53
|
-
const n = parseFloat(e?.getAttribute?.("x") || "0"), o = parseFloat(e?.getAttribute?.("y") || "0"), a = e?.textContent?.trim?.() || "", w = S?.findIndex?.(
|
|
54
|
-
(s) => Math.abs(s.x - n) < 40 && Math.abs(s.y - o) < 50
|
|
55
|
-
);
|
|
56
|
-
if (w !== -1) {
|
|
57
|
-
const s = S?.[w], t = s?.el, i = y?.[a] || 9999, l = y?.[s.text] || 9999;
|
|
58
|
-
let r;
|
|
59
|
-
i === 2 ? r = e : l === 2 ? r = t : r = i > l ? e : t;
|
|
60
|
-
const v = parseFloat(r?.getAttribute?.("y") || "0") + $;
|
|
61
|
-
r?.setAttribute?.("y", String(v));
|
|
62
|
-
const u = r?.nextElementSibling;
|
|
63
|
-
if (u && u?.tagName === "path") {
|
|
64
|
-
const c = (u?.getAttribute?.("d") || "")?.match?.(/(-?\d+(\.\d+)?,-?\d+(\.\d+)?)/g);
|
|
65
|
-
if (c && c?.length >= 2) {
|
|
66
|
-
for (let d = 1; d < c?.length; d += 1) {
|
|
67
|
-
const C = c[d].split(","), I = C[0], L = parseFloat(C[1]) + $;
|
|
68
|
-
c[d] = `${I},${L}`;
|
|
69
|
-
}
|
|
70
|
-
const z = `M${c?.[0]}L${c?.slice?.(1)?.join?.(",")}`;
|
|
71
|
-
u?.setAttribute?.("d", z);
|
|
72
|
-
}
|
|
95
|
+
const C = y.map((s) => {
|
|
96
|
+
const r = parseFloat(s.getAttribute("x") || "0"), a = parseFloat(s.getAttribute("y") || "0");
|
|
97
|
+
let A = null, g = s.nextElementSibling;
|
|
98
|
+
for (let u = 0; u < 3 && g; u++) {
|
|
99
|
+
if (g.tagName === "path") {
|
|
100
|
+
A = g;
|
|
101
|
+
break;
|
|
73
102
|
}
|
|
103
|
+
g = g.nextElementSibling;
|
|
74
104
|
}
|
|
75
|
-
|
|
105
|
+
return {
|
|
106
|
+
el: s,
|
|
107
|
+
originalY: a,
|
|
108
|
+
y: a,
|
|
109
|
+
x: r,
|
|
110
|
+
connectorPath: A,
|
|
111
|
+
originalD: A?.getAttribute("d") || "",
|
|
112
|
+
text: s.textContent?.trim() || ""
|
|
113
|
+
};
|
|
76
114
|
});
|
|
115
|
+
v(C, f);
|
|
77
116
|
}
|
|
78
117
|
export {
|
|
79
|
-
|
|
118
|
+
T as adjustDoughnutLabels
|
|
80
119
|
};
|