@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,7 +1,7 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
2
|
-
import { useNiceTranslation as
|
|
3
|
-
import { useRef as
|
|
4
|
-
const
|
|
1
|
+
import { jsx as r, jsxs as M, Fragment as Ht } from "react/jsx-runtime";
|
|
2
|
+
import { useNiceTranslation as Ut, resolveCssColor as Xt, NiceIcon as Ft } from "@nice2dev/ui-core";
|
|
3
|
+
import { useRef as bt, useState as q, useMemo as H, useCallback as A } from "react";
|
|
4
|
+
const Vt = [], w = [
|
|
5
5
|
"var(--nice-color-primary, #3b82f6)",
|
|
6
6
|
"var(--nice-color-error, #ef4444)",
|
|
7
7
|
"var(--nice-color-success, #22c55e)",
|
|
@@ -10,207 +10,210 @@ const je = [], k = [
|
|
|
10
10
|
"var(--nice-color-accent-pink, #ec4899)",
|
|
11
11
|
"var(--nice-color-info, #06b6d4)",
|
|
12
12
|
"var(--nice-success, #84cc16)"
|
|
13
|
-
],
|
|
14
|
-
series:
|
|
15
|
-
categories:
|
|
16
|
-
width:
|
|
17
|
-
height:
|
|
18
|
-
title:
|
|
19
|
-
showLegend:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
13
|
+
], qt = ({
|
|
14
|
+
series: W = Vt,
|
|
15
|
+
categories: st,
|
|
16
|
+
width: g = 600,
|
|
17
|
+
height: E = 400,
|
|
18
|
+
title: C,
|
|
19
|
+
showLegend: k = !0,
|
|
20
|
+
legendPlacement: $ = "bottom",
|
|
21
|
+
showGrid: it = !0,
|
|
22
|
+
axisLabels: J = !0,
|
|
23
|
+
yAxisLabel: K,
|
|
24
|
+
xAxisLabel: Q,
|
|
25
|
+
stacked: z,
|
|
26
|
+
animated: I,
|
|
27
|
+
zoomable: Y,
|
|
28
|
+
crosshair: St,
|
|
29
|
+
annotations: kt,
|
|
30
|
+
legendInteractive: U,
|
|
31
|
+
onDataPointClick: v,
|
|
32
|
+
exportable: Rt,
|
|
33
|
+
className: lt,
|
|
34
|
+
style: ht,
|
|
35
|
+
testId: dt,
|
|
36
|
+
"data-testid": mt
|
|
36
37
|
}) => {
|
|
37
|
-
const { t:
|
|
38
|
-
() =>
|
|
39
|
-
[
|
|
40
|
-
),
|
|
41
|
-
(
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
return
|
|
38
|
+
const { t: xt } = Ut(), X = bt(null), [F, wt] = q(/* @__PURE__ */ new Set()), [N, ft] = q(null), [j, pt] = q(null), [ut, L] = q(!1), B = bt(null), P = H(
|
|
39
|
+
() => W.filter((t) => !F.has(t.name)),
|
|
40
|
+
[W, F]
|
|
41
|
+
), _t = A(
|
|
42
|
+
(t) => {
|
|
43
|
+
U && wt((n) => {
|
|
44
|
+
const c = new Set(n);
|
|
45
|
+
return c.has(t) ? c.delete(t) : c.add(t), c;
|
|
45
46
|
});
|
|
46
47
|
},
|
|
47
|
-
[
|
|
48
|
-
),
|
|
49
|
-
top:
|
|
48
|
+
[U]
|
|
49
|
+
), i = {
|
|
50
|
+
top: C ? 40 : 20,
|
|
50
51
|
right: 20,
|
|
51
|
-
bottom:
|
|
52
|
-
left:
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
52
|
+
bottom: Q ? 60 : 40,
|
|
53
|
+
left: K ? 60 : 50
|
|
54
|
+
}, Wt = W.length, Et = W.reduce((t, n) => Math.max(t, n.name.length), 0), gt = k && ($ === "left" || $ === "right"), tt = Math.min(g * 0.3, 24 + Et * 7), et = gt ? 1 : Math.max(1, Math.floor((g - i.left) / 120)), At = k ? Math.ceil(Wt / et) : 0;
|
|
55
|
+
k && $ === "right" ? i.right += tt + 12 : k && $ === "left" ? i.left += tt + 12 : k && $ === "top" && (i.top += At * 20 + 6);
|
|
56
|
+
const rt = k && $ === "bottom", V = $ === "right" ? { x: g - tt - 8, y: i.top } : $ === "left" ? { x: 8, y: i.top } : $ === "top" ? { x: i.left, y: (C ? 40 : 20) - 6 } : { x: i.left, y: E }, yt = (t) => gt ? `translate(0, ${10 + t * 20})` : `translate(${t % et * 120}, ${10 + Math.floor(t / et) * 20})`, x = g - i.left - i.right, _ = E - i.top - i.bottom, y = P[0]?.data.length ?? W[0]?.data.length ?? 0, R = j?.start ?? 0, T = j?.end ?? y, b = T - R, p = H(
|
|
57
|
+
() => P.map((t) => ({ ...t, data: t.data.slice(R, T) })),
|
|
58
|
+
[P, R, T]
|
|
59
|
+
), D = H(
|
|
60
|
+
() => st?.slice(R, T),
|
|
61
|
+
[st, R, T]
|
|
62
|
+
), { minY: Mt, maxY: Ct, yTicks: $t } = H(() => {
|
|
63
|
+
let t;
|
|
64
|
+
if (z) {
|
|
65
|
+
t = [];
|
|
66
|
+
for (let s = 0; s < b; s++)
|
|
67
|
+
t.push(p.reduce((d, f) => d + (f.data[s] || 0), 0));
|
|
65
68
|
} else
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const n = Math.min(0, ...
|
|
69
|
-
let
|
|
70
|
-
const
|
|
71
|
-
for (let
|
|
72
|
-
|
|
73
|
-
return
|
|
74
|
-
}, [p,
|
|
75
|
-
(
|
|
76
|
-
if (!
|
|
69
|
+
t = p.flatMap((s) => s.data);
|
|
70
|
+
t.length === 0 && (t = [0]);
|
|
71
|
+
const n = Math.min(0, ...t), c = Math.max(0, ...t), h = c - n || 1, l = Math.pow(10, Math.floor(Math.log10(h))) || 1, a = Math.floor(n / l) * l;
|
|
72
|
+
let o = Math.ceil(c / l) * l;
|
|
73
|
+
const e = [];
|
|
74
|
+
for (let s = a; s <= o; s += l)
|
|
75
|
+
e.push(Math.round(s * 1e6) / 1e6);
|
|
76
|
+
return e.length < 2 && (o = a + l, e.push(Math.round(o * 1e6) / 1e6)), { minY: a, maxY: o, yTicks: e };
|
|
77
|
+
}, [p, b, z]), m = (t) => _ - (t - Mt) / (Ct - Mt || 1) * _, S = (t) => (t + 0.5) / b * x, vt = (t) => (t.type || "bar") === "bar", nt = new Map(p.filter(vt).map((t, n) => [t, n])), G = b > 0 ? x / b / (z ? 1.5 : Math.max(nt.size, 1) * 1.5) : 20, Z = G * 0.9, Yt = A(
|
|
78
|
+
(t) => {
|
|
79
|
+
if (!Y)
|
|
77
80
|
return;
|
|
78
|
-
|
|
79
|
-
const n =
|
|
80
|
-
|
|
81
|
+
t.preventDefault();
|
|
82
|
+
const n = j ?? { start: 0, end: y }, c = n.end - n.start, h = (n.start + n.end) / 2, l = t.deltaY > 0 ? 1.2 : 0.8, a = Math.max(2, Math.min(y, Math.round(c * l))), o = Math.max(0, Math.round(h - a / 2)), e = Math.min(y, o + a);
|
|
83
|
+
pt({ start: o, end: e });
|
|
81
84
|
},
|
|
82
|
-
[
|
|
83
|
-
),
|
|
84
|
-
(
|
|
85
|
-
|
|
85
|
+
[Y, j, y]
|
|
86
|
+
), jt = A(
|
|
87
|
+
(t) => {
|
|
88
|
+
Y && (L(!0), B.current = { x: t.clientX, range: j ?? { start: 0, end: y } });
|
|
86
89
|
},
|
|
87
|
-
[
|
|
88
|
-
),
|
|
89
|
-
(
|
|
90
|
-
const n =
|
|
91
|
-
if (n &&
|
|
92
|
-
const
|
|
93
|
-
let
|
|
94
|
-
|
|
90
|
+
[Y, j, y]
|
|
91
|
+
), Bt = A(
|
|
92
|
+
(t) => {
|
|
93
|
+
const n = X.current?.getBoundingClientRect();
|
|
94
|
+
if (n && ft({ x: t.clientX - n.left - i.left, y: t.clientY - n.top - i.top }), ut && B.current && Y) {
|
|
95
|
+
const c = t.clientX - B.current.x, h = x / b, l = -Math.round(c / h), a = B.current.range, o = a.end - a.start;
|
|
96
|
+
let e = a.start + l;
|
|
97
|
+
e < 0 && (e = 0), e + o > y && (e = y - o), pt({ start: e, end: e + o });
|
|
95
98
|
}
|
|
96
99
|
},
|
|
97
|
-
[
|
|
98
|
-
),
|
|
99
|
-
|
|
100
|
-
}, []),
|
|
101
|
-
|
|
102
|
-
}, []),
|
|
103
|
-
const
|
|
104
|
-
if (!
|
|
100
|
+
[ut, Y, x, b, y, i.left, i.top]
|
|
101
|
+
), Ot = A(() => {
|
|
102
|
+
L(!1), B.current = null;
|
|
103
|
+
}, []), zt = A(() => {
|
|
104
|
+
ft(null), L(!1), B.current = null;
|
|
105
|
+
}, []), It = A(() => {
|
|
106
|
+
const t = X.current;
|
|
107
|
+
if (!t)
|
|
105
108
|
return;
|
|
106
|
-
const n = new XMLSerializer().serializeToString(
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
if (!
|
|
109
|
+
const n = new XMLSerializer().serializeToString(t), c = document.createElement("canvas");
|
|
110
|
+
c.width = g, c.height = E + (rt ? 30 : 0);
|
|
111
|
+
const h = c.getContext("2d");
|
|
112
|
+
if (!h)
|
|
110
113
|
return;
|
|
111
114
|
const l = new Image();
|
|
112
115
|
l.onload = () => {
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
+
h.fillStyle = Xt("var(--nice-bg-primary, #fff)", h.canvas), h.fillRect(0, 0, c.width, c.height), h.drawImage(l, 0, 0);
|
|
117
|
+
const a = document.createElement("a");
|
|
118
|
+
a.download = "chart.png", a.href = c.toDataURL("image/png"), a.click();
|
|
116
119
|
}, l.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(n);
|
|
117
|
-
}, [
|
|
118
|
-
if (!
|
|
120
|
+
}, [g, E, rt]), Nt = E + (rt ? 30 : 0), ct = p.length > 0 && p.every((t) => t.type === "radar"), at = H(() => {
|
|
121
|
+
if (!ct)
|
|
119
122
|
return 1;
|
|
120
|
-
const
|
|
121
|
-
return Math.max(1, ...
|
|
122
|
-
}, [
|
|
123
|
-
if (
|
|
124
|
-
const
|
|
125
|
-
const d =
|
|
126
|
-
return [
|
|
127
|
-
},
|
|
123
|
+
const t = p.flatMap((n) => n.data);
|
|
124
|
+
return Math.max(1, ...t);
|
|
125
|
+
}, [ct, p]);
|
|
126
|
+
if (ct) {
|
|
127
|
+
const t = g / 2, n = (E - i.top - i.bottom) / 2 + i.top, c = Math.min(x, E - i.top - i.bottom) / 2 - 10, h = D?.length ?? p[0]?.data.length ?? 0, l = (e) => e / h * Math.PI * 2 - Math.PI / 2, a = (e, s) => {
|
|
128
|
+
const d = s / at * c;
|
|
129
|
+
return [t + Math.cos(l(e)) * d, n + Math.sin(l(e)) * d];
|
|
130
|
+
}, o = 4;
|
|
128
131
|
return /* @__PURE__ */ r(
|
|
129
132
|
"div",
|
|
130
133
|
{
|
|
131
|
-
className: `nice-chart nice-chart--radar ${
|
|
132
|
-
style:
|
|
133
|
-
"data-testid":
|
|
134
|
-
children: /* @__PURE__ */
|
|
134
|
+
className: `nice-chart nice-chart--radar ${lt || ""}`,
|
|
135
|
+
style: ht,
|
|
136
|
+
"data-testid": mt ?? dt,
|
|
137
|
+
children: /* @__PURE__ */ M(
|
|
135
138
|
"svg",
|
|
136
139
|
{
|
|
137
|
-
ref:
|
|
138
|
-
viewBox: `0 0 ${
|
|
140
|
+
ref: X,
|
|
141
|
+
viewBox: `0 0 ${g} ${Nt}`,
|
|
139
142
|
preserveAspectRatio: "xMidYMid meet",
|
|
140
143
|
width: "100%",
|
|
141
144
|
height: "100%",
|
|
142
145
|
className: "nice-chart__svg",
|
|
143
146
|
style: { display: "block", maxWidth: "100%", maxHeight: "100%" },
|
|
144
147
|
children: [
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const d = (
|
|
148
|
-
for (let
|
|
149
|
-
|
|
148
|
+
C && /* @__PURE__ */ r("text", { x: g / 2, y: 20, textAnchor: "middle", className: "nice-chart__title", children: C }),
|
|
149
|
+
it && Array.from({ length: o }, (e, s) => {
|
|
150
|
+
const d = (s + 1) / o * c, f = [];
|
|
151
|
+
for (let u = 0; u < h; u++)
|
|
152
|
+
f.push(`${t + Math.cos(l(u)) * d},${n + Math.sin(l(u)) * d}`);
|
|
150
153
|
return /* @__PURE__ */ r(
|
|
151
154
|
"polygon",
|
|
152
155
|
{
|
|
153
|
-
points:
|
|
156
|
+
points: f.join(" "),
|
|
154
157
|
fill: "none",
|
|
155
158
|
className: "nice-chart__grid-line"
|
|
156
159
|
},
|
|
157
|
-
|
|
160
|
+
s
|
|
158
161
|
);
|
|
159
162
|
}),
|
|
160
|
-
Array.from({ length:
|
|
161
|
-
const [d,
|
|
162
|
-
return /* @__PURE__ */ r("line", { x1:
|
|
163
|
+
Array.from({ length: h }, (e, s) => {
|
|
164
|
+
const [d, f] = a(s, at);
|
|
165
|
+
return /* @__PURE__ */ r("line", { x1: t, y1: n, x2: d, y2: f, className: "nice-chart__grid-line" }, s);
|
|
163
166
|
}),
|
|
164
|
-
|
|
165
|
-
const [d,
|
|
167
|
+
J && D?.map((e, s) => {
|
|
168
|
+
const [d, f] = a(s, at * 1.12);
|
|
166
169
|
return /* @__PURE__ */ r(
|
|
167
170
|
"text",
|
|
168
171
|
{
|
|
169
172
|
x: d,
|
|
170
|
-
y:
|
|
173
|
+
y: f,
|
|
171
174
|
textAnchor: "middle",
|
|
172
175
|
dominantBaseline: "middle",
|
|
173
176
|
className: "nice-chart__axis-label",
|
|
174
|
-
children:
|
|
177
|
+
children: e
|
|
175
178
|
},
|
|
176
|
-
|
|
179
|
+
s
|
|
177
180
|
);
|
|
178
181
|
}),
|
|
179
|
-
p.map((
|
|
180
|
-
const d =
|
|
181
|
-
return /* @__PURE__ */
|
|
182
|
+
p.map((e, s) => {
|
|
183
|
+
const d = e.color || w[s % w.length], f = e.data.map((u, O) => a(O, u).join(",")).join(" ");
|
|
184
|
+
return /* @__PURE__ */ M(
|
|
182
185
|
"g",
|
|
183
186
|
{
|
|
184
|
-
className:
|
|
187
|
+
className: I ? "nice-chart__series nice-chart__series--radar nice-chart__series--anim" : "nice-chart__series nice-chart__series--radar",
|
|
185
188
|
children: [
|
|
186
189
|
/* @__PURE__ */ r(
|
|
187
190
|
"polygon",
|
|
188
191
|
{
|
|
189
|
-
points:
|
|
192
|
+
points: f,
|
|
190
193
|
fill: d,
|
|
191
194
|
fillOpacity: 0.2,
|
|
192
195
|
stroke: d,
|
|
193
196
|
strokeWidth: 2
|
|
194
197
|
}
|
|
195
198
|
),
|
|
196
|
-
|
|
197
|
-
const [
|
|
198
|
-
return /* @__PURE__ */ r("circle", { cx:
|
|
199
|
+
e.data.map((u, O) => {
|
|
200
|
+
const [ot, Tt] = a(O, u);
|
|
201
|
+
return /* @__PURE__ */ r("circle", { cx: ot, cy: Tt, r: 3, fill: d, children: /* @__PURE__ */ r("title", { children: `${e.name}: ${u}` }) }, O);
|
|
199
202
|
})
|
|
200
203
|
]
|
|
201
204
|
},
|
|
202
|
-
|
|
205
|
+
e.name
|
|
203
206
|
);
|
|
204
207
|
}),
|
|
205
|
-
|
|
206
|
-
const d =
|
|
207
|
-
return /* @__PURE__ */
|
|
208
|
+
k && /* @__PURE__ */ r("g", { transform: `translate(${V.x}, ${V.y})`, children: W.map((e, s) => {
|
|
209
|
+
const d = F.has(e.name);
|
|
210
|
+
return /* @__PURE__ */ M(
|
|
208
211
|
"g",
|
|
209
212
|
{
|
|
210
|
-
transform:
|
|
211
|
-
style:
|
|
212
|
-
onClick: () =>
|
|
213
|
-
opacity:
|
|
213
|
+
transform: yt(s),
|
|
214
|
+
style: U ? { cursor: "pointer" } : void 0,
|
|
215
|
+
onClick: () => _t(e.name),
|
|
216
|
+
opacity: d ? 0.35 : 1,
|
|
214
217
|
children: [
|
|
215
218
|
/* @__PURE__ */ r(
|
|
216
219
|
"rect",
|
|
@@ -218,13 +221,13 @@ const je = [], k = [
|
|
|
218
221
|
width: 12,
|
|
219
222
|
height: 12,
|
|
220
223
|
rx: 2,
|
|
221
|
-
fill:
|
|
224
|
+
fill: e.color || w[s % w.length]
|
|
222
225
|
}
|
|
223
226
|
),
|
|
224
|
-
/* @__PURE__ */ r("text", { x: 16, y: 10, className: "nice-chart__legend-text", children:
|
|
227
|
+
/* @__PURE__ */ r("text", { x: 16, y: 10, className: "nice-chart__legend-text", children: e.name })
|
|
225
228
|
]
|
|
226
229
|
},
|
|
227
|
-
|
|
230
|
+
e.name
|
|
228
231
|
);
|
|
229
232
|
}) })
|
|
230
233
|
]
|
|
@@ -233,113 +236,113 @@ const je = [], k = [
|
|
|
233
236
|
}
|
|
234
237
|
);
|
|
235
238
|
}
|
|
236
|
-
return /* @__PURE__ */
|
|
239
|
+
return /* @__PURE__ */ M(
|
|
237
240
|
"div",
|
|
238
241
|
{
|
|
239
|
-
className: `nice-chart ${
|
|
240
|
-
style:
|
|
241
|
-
"data-testid":
|
|
242
|
+
className: `nice-chart ${lt || ""}`,
|
|
243
|
+
style: ht,
|
|
244
|
+
"data-testid": mt ?? dt,
|
|
242
245
|
children: [
|
|
243
|
-
|
|
246
|
+
Rt && /* @__PURE__ */ r(
|
|
244
247
|
"button",
|
|
245
248
|
{
|
|
246
249
|
type: "button",
|
|
247
250
|
className: "nice-chart__export-btn",
|
|
248
|
-
onClick:
|
|
249
|
-
title:
|
|
250
|
-
"aria-label":
|
|
251
|
-
children: /* @__PURE__ */ r(
|
|
251
|
+
onClick: It,
|
|
252
|
+
title: xt("chart.exportPng", "Export PNG"),
|
|
253
|
+
"aria-label": xt("chart.exportPng", "Export PNG"),
|
|
254
|
+
children: /* @__PURE__ */ r(Ft, { name: "camera", size: 16 })
|
|
252
255
|
}
|
|
253
256
|
),
|
|
254
|
-
/* @__PURE__ */
|
|
257
|
+
/* @__PURE__ */ M(
|
|
255
258
|
"svg",
|
|
256
259
|
{
|
|
257
|
-
ref:
|
|
258
|
-
viewBox: `0 0 ${
|
|
260
|
+
ref: X,
|
|
261
|
+
viewBox: `0 0 ${g} ${Nt}`,
|
|
259
262
|
preserveAspectRatio: "xMidYMid meet",
|
|
260
263
|
width: "100%",
|
|
261
264
|
height: "100%",
|
|
262
265
|
style: { display: "block", maxWidth: "100%", maxHeight: "100%" },
|
|
263
266
|
className: "nice-chart__svg",
|
|
264
|
-
onWheel:
|
|
265
|
-
onMouseDown:
|
|
266
|
-
onMouseMove:
|
|
267
|
-
onMouseUp:
|
|
268
|
-
onMouseLeave:
|
|
267
|
+
onWheel: Yt,
|
|
268
|
+
onMouseDown: jt,
|
|
269
|
+
onMouseMove: Bt,
|
|
270
|
+
onMouseUp: Ot,
|
|
271
|
+
onMouseLeave: zt,
|
|
269
272
|
children: [
|
|
270
|
-
/* @__PURE__ */
|
|
271
|
-
|
|
272
|
-
|
|
273
|
+
/* @__PURE__ */ M("g", { transform: `translate(${i.left},${i.top})`, children: [
|
|
274
|
+
C && /* @__PURE__ */ r("text", { x: x / 2, y: -10, textAnchor: "middle", className: "nice-chart__title", children: C }),
|
|
275
|
+
it && $t.map((t) => /* @__PURE__ */ r(
|
|
273
276
|
"line",
|
|
274
277
|
{
|
|
275
278
|
x1: 0,
|
|
276
|
-
y1: m(
|
|
277
|
-
x2:
|
|
278
|
-
y2: m(
|
|
279
|
+
y1: m(t),
|
|
280
|
+
x2: x,
|
|
281
|
+
y2: m(t),
|
|
279
282
|
className: "nice-chart__grid-line"
|
|
280
283
|
},
|
|
281
|
-
`grid-${
|
|
284
|
+
`grid-${t}`
|
|
282
285
|
)),
|
|
283
|
-
|
|
286
|
+
J && $t.map((t) => /* @__PURE__ */ r(
|
|
284
287
|
"text",
|
|
285
288
|
{
|
|
286
289
|
x: -8,
|
|
287
|
-
y: m(
|
|
290
|
+
y: m(t) + 4,
|
|
288
291
|
textAnchor: "end",
|
|
289
292
|
className: "nice-chart__axis-label",
|
|
290
|
-
children:
|
|
293
|
+
children: t
|
|
291
294
|
},
|
|
292
|
-
`ylabel-${
|
|
295
|
+
`ylabel-${t}`
|
|
293
296
|
)),
|
|
294
|
-
|
|
297
|
+
J && D && D.map((t, n) => /* @__PURE__ */ r(
|
|
295
298
|
"text",
|
|
296
299
|
{
|
|
297
|
-
x:
|
|
300
|
+
x: S(n),
|
|
298
301
|
y: _ + 20,
|
|
299
302
|
textAnchor: "middle",
|
|
300
303
|
className: "nice-chart__axis-label",
|
|
301
|
-
children:
|
|
304
|
+
children: t
|
|
302
305
|
},
|
|
303
306
|
n
|
|
304
307
|
)),
|
|
305
|
-
|
|
308
|
+
K && /* @__PURE__ */ r(
|
|
306
309
|
"text",
|
|
307
310
|
{
|
|
308
|
-
x: -
|
|
311
|
+
x: -i.left + 14,
|
|
309
312
|
y: _ / 2,
|
|
310
313
|
textAnchor: "middle",
|
|
311
|
-
transform: `rotate(-90, -${
|
|
314
|
+
transform: `rotate(-90, -${i.left - 14}, ${_ / 2})`,
|
|
312
315
|
className: "nice-chart__axis-title",
|
|
313
|
-
children:
|
|
316
|
+
children: K
|
|
314
317
|
}
|
|
315
318
|
),
|
|
316
|
-
|
|
319
|
+
Q && /* @__PURE__ */ r("text", { x: x / 2, y: _ + 45, textAnchor: "middle", className: "nice-chart__axis-title", children: Q }),
|
|
317
320
|
/* @__PURE__ */ r("line", { x1: 0, y1: 0, x2: 0, y2: _, className: "nice-chart__axis" }),
|
|
318
|
-
/* @__PURE__ */ r("line", { x1: 0, y1: _, x2:
|
|
319
|
-
|
|
320
|
-
if (
|
|
321
|
-
const
|
|
322
|
-
return /* @__PURE__ */
|
|
321
|
+
/* @__PURE__ */ r("line", { x1: 0, y1: _, x2: x, y2: _, className: "nice-chart__axis" }),
|
|
322
|
+
kt?.map((t, n) => {
|
|
323
|
+
if (t.type === "line") {
|
|
324
|
+
const c = m(t.value);
|
|
325
|
+
return /* @__PURE__ */ M("g", { children: [
|
|
323
326
|
/* @__PURE__ */ r(
|
|
324
327
|
"line",
|
|
325
328
|
{
|
|
326
329
|
x1: 0,
|
|
327
|
-
y1:
|
|
328
|
-
x2:
|
|
329
|
-
y2:
|
|
330
|
-
stroke:
|
|
330
|
+
y1: c,
|
|
331
|
+
x2: x,
|
|
332
|
+
y2: c,
|
|
333
|
+
stroke: t.color || "var(--nice-color-error, #ef4444)",
|
|
331
334
|
strokeWidth: 1.5,
|
|
332
|
-
strokeDasharray:
|
|
335
|
+
strokeDasharray: t.dash || "6,3"
|
|
333
336
|
}
|
|
334
337
|
),
|
|
335
|
-
|
|
338
|
+
t.label && /* @__PURE__ */ r(
|
|
336
339
|
"text",
|
|
337
340
|
{
|
|
338
|
-
x:
|
|
339
|
-
y:
|
|
341
|
+
x: x + 4,
|
|
342
|
+
y: c + 4,
|
|
340
343
|
className: "nice-chart__annotation-label",
|
|
341
|
-
fill:
|
|
342
|
-
children:
|
|
344
|
+
fill: t.color || "var(--nice-color-error, #ef4444)",
|
|
345
|
+
children: t.label
|
|
343
346
|
}
|
|
344
347
|
)
|
|
345
348
|
] }, n);
|
|
@@ -347,23 +350,23 @@ const je = [], k = [
|
|
|
347
350
|
return /* @__PURE__ */ r(
|
|
348
351
|
"text",
|
|
349
352
|
{
|
|
350
|
-
x:
|
|
353
|
+
x: S(t.value),
|
|
351
354
|
y: -4,
|
|
352
355
|
textAnchor: "middle",
|
|
353
356
|
className: "nice-chart__annotation-label",
|
|
354
|
-
fill:
|
|
355
|
-
children:
|
|
357
|
+
fill: t.color || "var(--nice-text-muted, #6b7280)",
|
|
358
|
+
children: t.label
|
|
356
359
|
},
|
|
357
360
|
n
|
|
358
361
|
);
|
|
359
362
|
}),
|
|
360
|
-
|
|
363
|
+
St && N && N.x >= 0 && N.x <= x && N.y >= 0 && N.y <= _ && /* @__PURE__ */ M(Ht, { children: [
|
|
361
364
|
/* @__PURE__ */ r(
|
|
362
365
|
"line",
|
|
363
366
|
{
|
|
364
|
-
x1:
|
|
367
|
+
x1: N.x,
|
|
365
368
|
y1: 0,
|
|
366
|
-
x2:
|
|
369
|
+
x2: N.x,
|
|
367
370
|
y2: _,
|
|
368
371
|
stroke: "var(--nice-text-muted, #9ca3af)",
|
|
369
372
|
strokeWidth: 1,
|
|
@@ -374,87 +377,87 @@ const je = [], k = [
|
|
|
374
377
|
"line",
|
|
375
378
|
{
|
|
376
379
|
x1: 0,
|
|
377
|
-
y1:
|
|
378
|
-
x2:
|
|
379
|
-
y2:
|
|
380
|
+
y1: N.y,
|
|
381
|
+
x2: x,
|
|
382
|
+
y2: N.y,
|
|
380
383
|
stroke: "var(--nice-text-muted, #9ca3af)",
|
|
381
384
|
strokeWidth: 1,
|
|
382
385
|
strokeDasharray: "4,2"
|
|
383
386
|
}
|
|
384
387
|
)
|
|
385
388
|
] }),
|
|
386
|
-
p.map((
|
|
387
|
-
const
|
|
388
|
-
if (
|
|
389
|
+
p.map((t, n) => {
|
|
390
|
+
const c = t.color || w[n % w.length], h = t.type || "bar";
|
|
391
|
+
if (h === "bar")
|
|
389
392
|
return /* @__PURE__ */ r(
|
|
390
393
|
"g",
|
|
391
394
|
{
|
|
392
|
-
className:
|
|
393
|
-
children:
|
|
394
|
-
let
|
|
395
|
-
if (
|
|
396
|
-
const
|
|
397
|
-
|
|
395
|
+
className: I ? "nice-chart__series nice-chart__series--bar nice-chart__series--anim" : "nice-chart__series nice-chart__series--bar",
|
|
396
|
+
children: t.data.map((a, o) => {
|
|
397
|
+
let e, s;
|
|
398
|
+
if (z) {
|
|
399
|
+
const u = p.slice(0, n).filter(vt).reduce((O, ot) => O + (ot.data[o] || 0), 0);
|
|
400
|
+
e = m(u + a), s = m(u) - e;
|
|
398
401
|
} else
|
|
399
|
-
|
|
400
|
-
const d =
|
|
402
|
+
e = m(Math.max(0, a)), s = Math.abs(m(a) - m(0));
|
|
403
|
+
const d = nt.get(t) ?? 0, f = z ? S(o) - Z / 2 : S(o) - nt.size * G / 2 + d * G + (G - Z) / 2;
|
|
401
404
|
return /* @__PURE__ */ r(
|
|
402
405
|
"rect",
|
|
403
406
|
{
|
|
404
|
-
x,
|
|
405
|
-
y:
|
|
406
|
-
width:
|
|
407
|
-
height: Math.max(0,
|
|
408
|
-
fill:
|
|
407
|
+
x: f,
|
|
408
|
+
y: e,
|
|
409
|
+
width: Z,
|
|
410
|
+
height: Math.max(0, s),
|
|
411
|
+
fill: c,
|
|
409
412
|
rx: 2,
|
|
410
413
|
style: {
|
|
411
|
-
transformOrigin: `${
|
|
412
|
-
...
|
|
414
|
+
transformOrigin: `${f + Z / 2}px ${m(0)}px`,
|
|
415
|
+
...v ? { cursor: "pointer" } : {}
|
|
413
416
|
},
|
|
414
|
-
onClick:
|
|
415
|
-
children: /* @__PURE__ */ r("title", { children: `${
|
|
417
|
+
onClick: v ? () => v(t.name, R + o, a) : void 0,
|
|
418
|
+
children: /* @__PURE__ */ r("title", { children: `${t.name}: ${a}` })
|
|
416
419
|
},
|
|
417
|
-
|
|
420
|
+
o
|
|
418
421
|
);
|
|
419
422
|
})
|
|
420
423
|
},
|
|
421
|
-
|
|
424
|
+
t.name
|
|
422
425
|
);
|
|
423
|
-
if (
|
|
426
|
+
if (h === "scatter")
|
|
424
427
|
return /* @__PURE__ */ r(
|
|
425
428
|
"g",
|
|
426
429
|
{
|
|
427
|
-
className:
|
|
428
|
-
children:
|
|
430
|
+
className: I ? "nice-chart__series nice-chart__series--scatter nice-chart__series--anim" : "nice-chart__series nice-chart__series--scatter",
|
|
431
|
+
children: t.data.map((a, o) => /* @__PURE__ */ r(
|
|
429
432
|
"circle",
|
|
430
433
|
{
|
|
431
|
-
cx:
|
|
432
|
-
cy: m(
|
|
434
|
+
cx: S(o),
|
|
435
|
+
cy: m(a),
|
|
433
436
|
r: 5,
|
|
434
|
-
fill:
|
|
437
|
+
fill: c,
|
|
435
438
|
fillOpacity: 0.7,
|
|
436
|
-
stroke:
|
|
439
|
+
stroke: c,
|
|
437
440
|
strokeWidth: 1.5,
|
|
438
|
-
style:
|
|
439
|
-
onClick:
|
|
440
|
-
children: /* @__PURE__ */ r("title", { children: `${
|
|
441
|
+
style: v ? { cursor: "pointer" } : void 0,
|
|
442
|
+
onClick: v ? () => v(t.name, R + o, a) : void 0,
|
|
443
|
+
children: /* @__PURE__ */ r("title", { children: `${t.name}: ${a}` })
|
|
441
444
|
},
|
|
442
|
-
|
|
445
|
+
o
|
|
443
446
|
))
|
|
444
447
|
},
|
|
445
|
-
|
|
448
|
+
t.name
|
|
446
449
|
);
|
|
447
|
-
const l =
|
|
448
|
-
return /* @__PURE__ */
|
|
450
|
+
const l = t.data.map((a, o) => `${S(o)},${m(a)}`);
|
|
451
|
+
return /* @__PURE__ */ M(
|
|
449
452
|
"g",
|
|
450
453
|
{
|
|
451
|
-
className:
|
|
454
|
+
className: I ? `nice-chart__series nice-chart__series--${h} nice-chart__series--anim` : `nice-chart__series nice-chart__series--${h}`,
|
|
452
455
|
children: [
|
|
453
|
-
|
|
456
|
+
h === "area" && b > 0 && /* @__PURE__ */ r(
|
|
454
457
|
"polygon",
|
|
455
458
|
{
|
|
456
|
-
points: `${
|
|
457
|
-
fill:
|
|
459
|
+
points: `${S(0)},${m(0)} ${l.join(" ")} ${S(b - 1)},${m(0)}`,
|
|
460
|
+
fill: c,
|
|
458
461
|
opacity: 0.15
|
|
459
462
|
}
|
|
460
463
|
),
|
|
@@ -463,54 +466,54 @@ const je = [], k = [
|
|
|
463
466
|
{
|
|
464
467
|
points: l.join(" "),
|
|
465
468
|
fill: "none",
|
|
466
|
-
stroke:
|
|
469
|
+
stroke: c,
|
|
467
470
|
strokeWidth: 2,
|
|
468
|
-
className:
|
|
471
|
+
className: I ? "nice-chart__line" : void 0
|
|
469
472
|
}
|
|
470
473
|
),
|
|
471
|
-
|
|
474
|
+
t.data.map((a, o) => /* @__PURE__ */ r(
|
|
472
475
|
"circle",
|
|
473
476
|
{
|
|
474
|
-
cx:
|
|
475
|
-
cy: m(
|
|
477
|
+
cx: S(o),
|
|
478
|
+
cy: m(a),
|
|
476
479
|
r: 3,
|
|
477
|
-
fill:
|
|
478
|
-
style:
|
|
479
|
-
onClick:
|
|
480
|
-
children: /* @__PURE__ */ r("title", { children: `${
|
|
480
|
+
fill: c,
|
|
481
|
+
style: v ? { cursor: "pointer" } : void 0,
|
|
482
|
+
onClick: v ? () => v(t.name, R + o, a) : void 0,
|
|
483
|
+
children: /* @__PURE__ */ r("title", { children: `${t.name}: ${a}` })
|
|
481
484
|
},
|
|
482
|
-
|
|
485
|
+
o
|
|
483
486
|
))
|
|
484
487
|
]
|
|
485
488
|
},
|
|
486
|
-
|
|
489
|
+
t.name
|
|
487
490
|
);
|
|
488
491
|
})
|
|
489
492
|
] }),
|
|
490
|
-
|
|
491
|
-
const
|
|
492
|
-
return /* @__PURE__ */
|
|
493
|
+
k && /* @__PURE__ */ r("g", { transform: `translate(${V.x}, ${V.y})`, children: W.map((t, n) => {
|
|
494
|
+
const c = F.has(t.name);
|
|
495
|
+
return /* @__PURE__ */ M(
|
|
493
496
|
"g",
|
|
494
497
|
{
|
|
495
|
-
transform:
|
|
496
|
-
style:
|
|
497
|
-
onClick: () =>
|
|
498
|
-
opacity:
|
|
498
|
+
transform: yt(n),
|
|
499
|
+
style: U ? { cursor: "pointer" } : void 0,
|
|
500
|
+
onClick: () => _t(t.name),
|
|
501
|
+
opacity: c ? 0.35 : 1,
|
|
499
502
|
children: [
|
|
500
|
-
/* @__PURE__ */ r("rect", { width: 12, height: 12, rx: 2, fill:
|
|
503
|
+
/* @__PURE__ */ r("rect", { width: 12, height: 12, rx: 2, fill: t.color || w[n % w.length] }),
|
|
501
504
|
/* @__PURE__ */ r(
|
|
502
505
|
"text",
|
|
503
506
|
{
|
|
504
507
|
x: 16,
|
|
505
508
|
y: 10,
|
|
506
509
|
className: "nice-chart__legend-text",
|
|
507
|
-
style:
|
|
508
|
-
children:
|
|
510
|
+
style: c ? { textDecoration: "line-through" } : void 0,
|
|
511
|
+
children: t.name
|
|
509
512
|
}
|
|
510
513
|
)
|
|
511
514
|
]
|
|
512
515
|
},
|
|
513
|
-
|
|
516
|
+
t.name
|
|
514
517
|
);
|
|
515
518
|
}) })
|
|
516
519
|
]
|
|
@@ -521,5 +524,5 @@ const je = [], k = [
|
|
|
521
524
|
);
|
|
522
525
|
};
|
|
523
526
|
export {
|
|
524
|
-
|
|
527
|
+
qt as NiceChart
|
|
525
528
|
};
|