@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;AAED,wBAAgB,oBAAoB,CAAC,MAAM,GAAE,gBAAqB,GAAG,IAAI,CAiMxE"}
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 N(g = {}) {
2
- const m = g?.sender?.container;
3
- if (!m) return;
4
- const f = g?.sender?.originalDataSource?.data || [], b = g?.sender?.originalDataSource?.chart?.numberPrefix || "", h = f.reduce((e, n) => e + (Number(n.value) || 0), 0), $ = 50, x = {};
5
- f.forEach((e) => {
6
- e.label && (x[e.label] = { value: e.value, label: e.label });
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
- const B = new Set(f.map((e) => e.label).filter(Boolean));
9
- Array.from(m.querySelectorAll("text")).forEach((e) => {
10
- const n = e, o = n?.textContent?.trim() || "";
11
- if (x[o] || o.length === 0) return;
12
- const a = String(h);
13
- if (f.some((s) => {
14
- const t = Number(s.value) || 0, i = h > 0 ? (t / h * 100).toFixed(2) : "0", l = `${b}${s.value} (${i}%)`;
15
- return o.includes(l) || s.label && o.includes(s.label) && o.includes(b);
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
- const s = n.querySelectorAll("tspan");
18
- s.length > 0 ? s.forEach((t, i) => {
19
- const l = t.textContent?.trim() || "";
20
- if (t.setAttribute("font-family", "Inter, sans-serif"), i === 0 || !B.has(l) && l.includes(b)) {
21
- const r = l.match(/^(.+?)(\s*\(\d+\.\d+%\))$/);
22
- if (r) {
23
- const v = r[1], u = r[2];
24
- t.textContent = "", t.setAttribute("font-size", "10"), t.setAttribute("fill", "#2B2B2B"), t.setAttribute("font-weight", "600");
25
- const A = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
26
- A.textContent = u, A.setAttribute("font-weight", "400"), t.appendChild(document.createTextNode(v)), t.appendChild(A);
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
- t.setAttribute("font-weight", "600"), t.setAttribute("font-size", "10"), t.setAttribute("fill", "#2b2b2b");
81
+ e.setAttribute("font-weight", "600"), e.setAttribute("font-size", "10"), e.setAttribute("fill", "#2b2b2b");
29
82
  } else
30
- t.setAttribute("font-weight", "400"), t.setAttribute("font-size", "10"), t.setAttribute("fill", "#737373"), i === 1 && t.setAttribute("dy", "16");
31
- }) : (n.setAttribute("font-family", "Inter, sans-serif"), n.setAttribute("font-weight", "700"), n.setAttribute("fill", "#2b2b2b"));
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 (o.includes(a) || o.includes("Total") || o.includes("Resource")) {
35
- const s = n.querySelectorAll("tspan");
36
- s.length > 0 ? s.forEach((t) => {
37
- const i = t.textContent?.trim() || "";
38
- t.setAttribute("font-family", "Inter, sans-serif"), i === a || i === `${b}${h}` ? (t.setAttribute("font-weight", "600"), t.setAttribute("font-size", "11"), t.setAttribute("fill", "#2B2B2B"), t.setAttribute("dy", "16")) : (t.setAttribute("font-weight", "400"), t.setAttribute("font-size", "10"), t.setAttribute("fill", "#737373"));
39
- }) : (n.setAttribute("font-family", "Inter, sans-serif"), o === a || o === `${b}${h}` ? (n.setAttribute("font-weight", "600"), n.setAttribute("font-size", "11"), n.setAttribute("fill", "#2B2B2B")) : (n.setAttribute("font-weight", "400"), n.setAttribute("font-size", "10"), n.setAttribute("fill", "#737373")));
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 y = {};
43
- f.slice().sort((e, n) => n.value - e.value).forEach((e, n) => {
44
- e.label && (y[e.label] = n + 1);
45
- });
46
- const T = Array.from(m.querySelectorAll("text")), p = [];
47
- T.forEach((e) => {
48
- const n = e?.textContent?.trim() || "";
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
- S.push({ x: n, y: o, el: e, text: a });
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
- N as adjustDoughnutLabels
118
+ T as adjustDoughnutLabels
80
119
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ck-ui/component-library",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "type": "module",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",