@nice2dev/ui 1.4.22 → 1.4.23
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.
- package/CHANGELOG.md +39 -0
- package/dist/{NicePivotGrid-BshofJh1.cjs → NicePivotGrid-B5Fgi5E_.cjs} +1 -1
- package/dist/charts/NiceAdvancedCharts.mjs +657 -613
- package/dist/charts/NiceBarGauge.mjs +100 -65
- package/dist/charts/NiceBullet.mjs +103 -98
- package/dist/charts/NiceChart.mjs +269 -266
- package/dist/charts/NiceCircularGauge.mjs +99 -70
- package/dist/charts/NiceLinearGauge.mjs +168 -119
- package/dist/charts/NicePieChart.mjs +94 -49
- package/dist/charts/NicePolarChart.mjs +2 -2
- package/dist/charts-C9B548D2.cjs +924 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.d.ts +24 -2
- package/dist/{core-lazy-CUnBYI-T.cjs → core-lazy-B54FdghB.cjs} +1 -1
- package/dist/data.cjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +24 -2
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.d.ts +8 -0
- package/dist/style.css +1 -1
- package/package.json +4 -4
- package/dist/charts-C3Q3r8Yz.cjs +0 -918
|
@@ -1,56 +1,81 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { jsx as a, jsxs as y } from "react/jsx-runtime";
|
|
2
|
+
import { useId as ht } from "react";
|
|
3
|
+
import { CHART_COLORS as N } from "./colors.mjs";
|
|
4
|
+
const rt = [], n = 12, J = 20, K = 7, Q = 22, mt = ({
|
|
5
|
+
data: M = rt,
|
|
6
|
+
width: $ = 400,
|
|
7
|
+
height: p = 400,
|
|
8
|
+
innerRadius: h = 0,
|
|
9
|
+
title: k,
|
|
10
|
+
showLegend: E = !0,
|
|
11
|
+
legendPlacement: r = "right",
|
|
12
|
+
showLabels: S = !0,
|
|
13
|
+
splitSize: b = 2,
|
|
14
|
+
className: V,
|
|
15
|
+
style: P,
|
|
16
|
+
testId: z,
|
|
17
|
+
"data-testid": R
|
|
15
18
|
}) => {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
const L = `nice-pie-gaps-${ht().replace(/[^a-zA-Z0-9_-]/g, "")}`, H = M.reduce((t, c) => t + c.value, 0), I = k ? 32 : 0, tt = M.reduce((t, c) => Math.max(t, c.label.length), 0), O = r === "left" || r === "right", x = Math.min($ * (O ? 0.42 : 0.9), Q + tt * K), d = O ? 1 : Math.max(1, Math.floor(($ - 2 * n) / (x + 12))), f = (E ? Math.ceil(M.length / d) : 0) * J, l = { x: n, y: I + n / 2, w: $ - 2 * n, h: p - I - n };
|
|
20
|
+
E && M.length > 0 && (r === "right" ? l.w -= x + n : r === "left" ? (l.x += x + n, l.w -= x + n) : (r === "top" && (l.y += f + 8), l.h -= f + 8));
|
|
21
|
+
const e = l.x + l.w / 2, s = l.y + l.h / 2, o = Math.max(10, Math.min(l.w, l.h) / 2 - 4), ct = r === "right" ? $ - n - x : n, ot = r === "top" ? I + 4 : r === "bottom" ? p - n / 2 - f : s - f / 2, T = (t) => {
|
|
22
|
+
const c = Math.max(3, Math.floor((x - Q) / K));
|
|
23
|
+
return t.length > c ? `${t.slice(0, c - 1)}…` : t;
|
|
24
|
+
};
|
|
25
|
+
let C = -Math.PI / 2;
|
|
26
|
+
const D = [], Z = M.map((t, c) => {
|
|
27
|
+
const _ = t.value / (H || 1) * Math.PI * 2, m = C;
|
|
28
|
+
C += _;
|
|
29
|
+
const A = C, X = (m + A) / 2;
|
|
30
|
+
_ > 0 && D.push(m);
|
|
31
|
+
const j = e + o * Math.cos(m), w = s + o * Math.sin(m), B = e + o * Math.cos(A), U = s + o * Math.sin(A), W = _ > Math.PI ? 1 : 0, st = t.color || N[c % N.length], Y = _ >= Math.PI * 2 - 1e-9;
|
|
32
|
+
let u;
|
|
33
|
+
if (Y) {
|
|
34
|
+
const g = (i, v) => `M${e - i},${s} A${i},${i} 0 1,${v} ${e + i},${s} A${i},${i} 0 1,${v} ${e - i},${s} Z`;
|
|
35
|
+
u = h > 0 ? `${g(o, 1)} ${g(h, 0)}` : g(o, 1);
|
|
36
|
+
} else if (h > 0) {
|
|
37
|
+
const g = e + h * Math.cos(m), i = s + h * Math.sin(m), v = e + h * Math.cos(A), at = s + h * Math.sin(A);
|
|
38
|
+
u = `M${j},${w} A${o},${o} 0 ${W},1 ${B},${U} L${v},${at} A${h},${h} 0 ${W},0 ${g},${i} Z`;
|
|
29
39
|
} else
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
return { ...t, path:
|
|
33
|
-
});
|
|
34
|
-
return /* @__PURE__ */
|
|
40
|
+
u = `M${e},${s} L${j},${w} A${o},${o} 0 ${W},1 ${B},${U} Z`;
|
|
41
|
+
const q = Math.min(Math.max(h, 0), o), F = q > 0 ? (q + o) / 2 : o * 0.65, lt = Y ? e : e + F * Math.cos(X), et = Y ? s : s + F * Math.sin(X), nt = H > 0 ? Math.round(t.value / H * 100) : 0;
|
|
42
|
+
return { ...t, path: u, labelX: lt, labelY: et, pct: nt, color: st };
|
|
43
|
+
}), G = b > 0 && D.length > 1;
|
|
44
|
+
return /* @__PURE__ */ a(
|
|
35
45
|
"div",
|
|
36
46
|
{
|
|
37
|
-
className: `nice-piechart ${
|
|
38
|
-
style:
|
|
39
|
-
"data-testid":
|
|
40
|
-
children: /* @__PURE__ */
|
|
47
|
+
className: `nice-piechart ${V || ""}`,
|
|
48
|
+
style: P,
|
|
49
|
+
"data-testid": R ?? z,
|
|
50
|
+
children: /* @__PURE__ */ y(
|
|
41
51
|
"svg",
|
|
42
52
|
{
|
|
43
|
-
viewBox: `0 0 ${
|
|
53
|
+
viewBox: `0 0 ${$} ${p}`,
|
|
44
54
|
preserveAspectRatio: "xMidYMid meet",
|
|
45
55
|
width: "100%",
|
|
46
56
|
height: "100%",
|
|
47
57
|
style: { display: "block", maxWidth: "100%", maxHeight: "100%" },
|
|
48
58
|
className: "nice-piechart__svg",
|
|
49
59
|
children: [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
60
|
+
G && /* @__PURE__ */ a("defs", { children: /* @__PURE__ */ y("mask", { id: L, maskUnits: "userSpaceOnUse", x: 0, y: 0, width: $, height: p, children: [
|
|
61
|
+
/* @__PURE__ */ a("rect", { x: 0, y: 0, width: $, height: p, fill: "white" }),
|
|
62
|
+
D.map((t, c) => /* @__PURE__ */ a(
|
|
63
|
+
"line",
|
|
64
|
+
{
|
|
65
|
+
x1: e,
|
|
66
|
+
y1: s,
|
|
67
|
+
x2: e + (o + b) * Math.cos(t),
|
|
68
|
+
y2: s + (o + b) * Math.sin(t),
|
|
69
|
+
stroke: "black",
|
|
70
|
+
strokeWidth: b
|
|
71
|
+
},
|
|
72
|
+
c
|
|
73
|
+
))
|
|
74
|
+
] }) }),
|
|
75
|
+
k && /* @__PURE__ */ a("text", { x: $ / 2, y: 20, textAnchor: "middle", className: "nice-chart__title", children: k }),
|
|
76
|
+
/* @__PURE__ */ a("g", { mask: G ? `url(#${L})` : void 0, children: Z.map((t, c) => /* @__PURE__ */ a("path", { d: t.path, fill: t.color, children: /* @__PURE__ */ a("title", { children: `${t.label}: ${t.value} (${t.pct}%)` }) }, c)) }),
|
|
77
|
+
S && Z.map(
|
|
78
|
+
(t, c) => t.pct >= 5 ? /* @__PURE__ */ y(
|
|
54
79
|
"text",
|
|
55
80
|
{
|
|
56
81
|
x: t.labelX,
|
|
@@ -62,13 +87,33 @@ const q = [], F = ({
|
|
|
62
87
|
t.pct,
|
|
63
88
|
"%"
|
|
64
89
|
]
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
90
|
+
},
|
|
91
|
+
c
|
|
92
|
+
) : null
|
|
93
|
+
),
|
|
94
|
+
E && /* @__PURE__ */ a("g", { transform: `translate(${ct}, ${ot})`, children: M.map((t, c) => /* @__PURE__ */ y(
|
|
95
|
+
"g",
|
|
96
|
+
{
|
|
97
|
+
transform: `translate(${c % d * (x + 12)}, ${Math.floor(c / d) * J})`,
|
|
98
|
+
children: [
|
|
99
|
+
/* @__PURE__ */ a(
|
|
100
|
+
"rect",
|
|
101
|
+
{
|
|
102
|
+
y: 3,
|
|
103
|
+
width: 10,
|
|
104
|
+
height: 10,
|
|
105
|
+
rx: 2,
|
|
106
|
+
fill: t.color || N[c % N.length]
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
/* @__PURE__ */ y("text", { x: 16, y: 12, className: "nice-chart__legend-text", children: [
|
|
110
|
+
T(t.label) !== t.label && /* @__PURE__ */ a("title", { children: t.label }),
|
|
111
|
+
T(t.label)
|
|
112
|
+
] })
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
c
|
|
116
|
+
)) })
|
|
72
117
|
]
|
|
73
118
|
}
|
|
74
119
|
)
|
|
@@ -76,5 +121,5 @@ const q = [], F = ({
|
|
|
76
121
|
);
|
|
77
122
|
};
|
|
78
123
|
export {
|
|
79
|
-
|
|
124
|
+
mt as NicePieChart
|
|
80
125
|
};
|
|
@@ -13,7 +13,7 @@ const R = [], T = [], B = ({
|
|
|
13
13
|
testId: I,
|
|
14
14
|
"data-testid": S
|
|
15
15
|
}) => {
|
|
16
|
-
const u = g ?
|
|
16
|
+
const u = g ? 54 : 0, $ = p - (M ? 30 : 0) - u, s = f / 2, y = u + $ / 2, P = Math.min(s, $ / 2) - 60, b = x.length, _ = N ?? Math.max(...m.flatMap((t) => t.data), 1), k = Math.PI * 2 / b, E = 5, i = (t, n) => {
|
|
17
17
|
const a = t * k - Math.PI / 2, o = n / _ * P;
|
|
18
18
|
return { x: s + o * Math.cos(a), y: y + o * Math.sin(a) };
|
|
19
19
|
};
|
|
@@ -24,7 +24,7 @@ const R = [], T = [], B = ({
|
|
|
24
24
|
style: A,
|
|
25
25
|
"data-testid": S ?? I,
|
|
26
26
|
children: /* @__PURE__ */ d("svg", { width: f, height: p, className: "nice-polarchart__svg", children: [
|
|
27
|
-
g && /* @__PURE__ */ c("text", { x: s, y:
|
|
27
|
+
g && /* @__PURE__ */ c("text", { x: s, y: 30, textAnchor: "middle", className: "nice-chart__title", children: g }),
|
|
28
28
|
Array.from({ length: E }, (t, n) => {
|
|
29
29
|
const a = P * ((n + 1) / E);
|
|
30
30
|
return /* @__PURE__ */ c(
|