@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.
@@ -1,7 +1,7 @@
1
- import { jsx as r, jsxs as y, Fragment as Ee } from "react/jsx-runtime";
2
- import { useNiceTranslation as Ye, resolveCssColor as Ae, NiceIcon as Ce } from "@nice2dev/ui-core";
3
- import { useRef as _e, useState as G, useMemo as H, useCallback as R } from "react";
4
- const je = [], k = [
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
- ], Te = ({
14
- series: C = je,
15
- categories: re,
16
- width: w = 600,
17
- height: b = 400,
18
- title: j,
19
- showLegend: z = !0,
20
- showGrid: ne = !0,
21
- axisLabels: P = !0,
22
- yAxisLabel: Z,
23
- xAxisLabel: q,
24
- stacked: B,
25
- animated: O,
26
- zoomable: W,
27
- crosshair: ge,
28
- annotations: ye,
29
- legendInteractive: I,
30
- onDataPointClick: M,
31
- exportable: Me,
32
- className: ce,
33
- style: ae,
34
- testId: se,
35
- "data-testid": oe
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: ie } = Ye(), U = _e(null), [X, ve] = G(/* @__PURE__ */ new Set()), [v, le] = G(null), [E, he] = G(null), [de, J] = G(!1), Y = _e(null), K = H(
38
- () => C.filter((e) => !X.has(e.name)),
39
- [C, X]
40
- ), me = R(
41
- (e) => {
42
- I && ve((n) => {
43
- const a = new Set(n);
44
- return a.has(e) ? a.delete(e) : a.add(e), a;
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
- [I]
48
- ), h = {
49
- top: j ? 40 : 20,
48
+ [U]
49
+ ), i = {
50
+ top: C ? 40 : 20,
50
51
  right: 20,
51
- bottom: q ? 60 : 40,
52
- left: Z ? 60 : 50
53
- }, u = w - h.left - h.right, _ = b - h.top - h.bottom, g = K[0]?.data.length ?? C[0]?.data.length ?? 0, S = E?.start ?? 0, T = E?.end ?? g, $ = T - S, p = H(
54
- () => K.map((e) => ({ ...e, data: e.data.slice(S, T) })),
55
- [K, S, T]
56
- ), F = H(
57
- () => re?.slice(S, T),
58
- [re, S, T]
59
- ), { minY: xe, maxY: $e, yTicks: ue } = H(() => {
60
- let e;
61
- if (B) {
62
- e = [];
63
- for (let o = 0; o < $; o++)
64
- e.push(p.reduce((d, x) => d + (x.data[o] || 0), 0));
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
- e = p.flatMap((o) => o.data);
67
- e.length === 0 && (e = [0]);
68
- const n = Math.min(0, ...e), a = Math.max(0, ...e), i = a - n || 1, l = Math.pow(10, Math.floor(Math.log10(i))) || 1, c = Math.floor(n / l) * l;
69
- let s = Math.ceil(a / l) * l;
70
- const t = [];
71
- for (let o = c; o <= s; o += l)
72
- t.push(Math.round(o * 1e6) / 1e6);
73
- return t.length < 2 && (s = c + l, t.push(Math.round(s * 1e6) / 1e6)), { minY: c, maxY: s, yTicks: t };
74
- }, [p, $, B]), m = (e) => _ - (e - xe) / ($e - xe || 1) * _, N = (e) => (e + 0.5) / $ * u, pe = (e) => (e.type || "bar") === "bar", Q = new Map(p.filter(pe).map((e, n) => [e, n])), V = $ > 0 ? u / $ / (B ? 1.5 : Math.max(Q.size, 1) * 1.5) : 20, D = V * 0.9, Ne = R(
75
- (e) => {
76
- if (!W)
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
- e.preventDefault();
79
- const n = E ?? { start: 0, end: g }, a = n.end - n.start, i = (n.start + n.end) / 2, l = e.deltaY > 0 ? 1.2 : 0.8, c = Math.max(2, Math.min(g, Math.round(a * l))), s = Math.max(0, Math.round(i - c / 2)), t = Math.min(g, s + c);
80
- he({ start: s, end: t });
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
- [W, E, g]
83
- ), be = R(
84
- (e) => {
85
- W && (J(!0), Y.current = { x: e.clientX, range: E ?? { start: 0, end: g } });
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
- [W, E, g]
88
- ), Se = R(
89
- (e) => {
90
- const n = U.current?.getBoundingClientRect();
91
- if (n && le({ x: e.clientX - n.left - h.left, y: e.clientY - n.top - h.top }), de && Y.current && W) {
92
- const a = e.clientX - Y.current.x, i = u / $, l = -Math.round(a / i), c = Y.current.range, s = c.end - c.start;
93
- let t = c.start + l;
94
- t < 0 && (t = 0), t + s > g && (t = g - s), he({ start: t, end: t + s });
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
- [de, W, u, $, g, h.left, h.top]
98
- ), ke = R(() => {
99
- J(!1), Y.current = null;
100
- }, []), we = R(() => {
101
- le(null), J(!1), Y.current = null;
102
- }, []), Re = R(() => {
103
- const e = U.current;
104
- if (!e)
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(e), a = document.createElement("canvas");
107
- a.width = w, a.height = b + (z ? 30 : 0);
108
- const i = a.getContext("2d");
109
- if (!i)
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
- i.fillStyle = Ae("var(--nice-bg-primary, #fff)", i.canvas), i.fillRect(0, 0, a.width, a.height), i.drawImage(l, 0, 0);
114
- const c = document.createElement("a");
115
- c.download = "chart.png", c.href = a.toDataURL("image/png"), c.click();
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
- }, [w, b, z]), fe = b + (z ? 30 : 0), L = p.length > 0 && p.every((e) => e.type === "radar"), ee = H(() => {
118
- if (!L)
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 e = p.flatMap((n) => n.data);
121
- return Math.max(1, ...e);
122
- }, [L, p]);
123
- if (L) {
124
- const e = w / 2, n = (b - h.top - h.bottom) / 2 + h.top, a = Math.min(u, b - h.top - h.bottom) / 2 - 10, i = F?.length ?? p[0]?.data.length ?? 0, l = (t) => t / i * Math.PI * 2 - Math.PI / 2, c = (t, o) => {
125
- const d = o / ee * a;
126
- return [e + Math.cos(l(t)) * d, n + Math.sin(l(t)) * d];
127
- }, s = 4;
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 ${ce || ""}`,
132
- style: ae,
133
- "data-testid": oe ?? se,
134
- children: /* @__PURE__ */ y(
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: U,
138
- viewBox: `0 0 ${w} ${fe}`,
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
- j && /* @__PURE__ */ r("text", { x: w / 2, y: 20, textAnchor: "middle", className: "nice-chart__title", children: j }),
146
- ne && Array.from({ length: s }, (t, o) => {
147
- const d = (o + 1) / s * a, x = [];
148
- for (let f = 0; f < i; f++)
149
- x.push(`${e + Math.cos(l(f)) * d},${n + Math.sin(l(f)) * d}`);
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: x.join(" "),
156
+ points: f.join(" "),
154
157
  fill: "none",
155
158
  className: "nice-chart__grid-line"
156
159
  },
157
- o
160
+ s
158
161
  );
159
162
  }),
160
- Array.from({ length: i }, (t, o) => {
161
- const [d, x] = c(o, ee);
162
- return /* @__PURE__ */ r("line", { x1: e, y1: n, x2: d, y2: x, className: "nice-chart__grid-line" }, o);
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
- P && F?.map((t, o) => {
165
- const [d, x] = c(o, ee * 1.12);
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: x,
173
+ y: f,
171
174
  textAnchor: "middle",
172
175
  dominantBaseline: "middle",
173
176
  className: "nice-chart__axis-label",
174
- children: t
177
+ children: e
175
178
  },
176
- o
179
+ s
177
180
  );
178
181
  }),
179
- p.map((t, o) => {
180
- const d = t.color || k[o % k.length], x = t.data.map((f, A) => c(A, f).join(",")).join(" ");
181
- return /* @__PURE__ */ y(
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: O ? "nice-chart__series nice-chart__series--radar nice-chart__series--anim" : "nice-chart__series nice-chart__series--radar",
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: x,
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
- t.data.map((f, A) => {
197
- const [te, We] = c(A, f);
198
- return /* @__PURE__ */ r("circle", { cx: te, cy: We, r: 3, fill: d, children: /* @__PURE__ */ r("title", { children: `${t.name}: ${f}` }) }, A);
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
- t.name
205
+ e.name
203
206
  );
204
207
  }),
205
- z && /* @__PURE__ */ r("g", { transform: `translate(${h.left}, ${b})`, children: C.map((t, o) => {
206
- const d = o * 120, x = X.has(t.name);
207
- return /* @__PURE__ */ y(
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: `translate(${d}, 10)`,
211
- style: I ? { cursor: "pointer" } : void 0,
212
- onClick: () => me(t.name),
213
- opacity: x ? 0.35 : 1,
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: t.color || k[o % k.length]
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: t.name })
227
+ /* @__PURE__ */ r("text", { x: 16, y: 10, className: "nice-chart__legend-text", children: e.name })
225
228
  ]
226
229
  },
227
- t.name
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__ */ y(
239
+ return /* @__PURE__ */ M(
237
240
  "div",
238
241
  {
239
- className: `nice-chart ${ce || ""}`,
240
- style: ae,
241
- "data-testid": oe ?? se,
242
+ className: `nice-chart ${lt || ""}`,
243
+ style: ht,
244
+ "data-testid": mt ?? dt,
242
245
  children: [
243
- Me && /* @__PURE__ */ r(
246
+ Rt && /* @__PURE__ */ r(
244
247
  "button",
245
248
  {
246
249
  type: "button",
247
250
  className: "nice-chart__export-btn",
248
- onClick: Re,
249
- title: ie("chart.exportPng", "Export PNG"),
250
- "aria-label": ie("chart.exportPng", "Export PNG"),
251
- children: /* @__PURE__ */ r(Ce, { name: "camera", size: 16 })
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__ */ y(
257
+ /* @__PURE__ */ M(
255
258
  "svg",
256
259
  {
257
- ref: U,
258
- viewBox: `0 0 ${w} ${fe}`,
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: Ne,
265
- onMouseDown: be,
266
- onMouseMove: Se,
267
- onMouseUp: ke,
268
- onMouseLeave: we,
267
+ onWheel: Yt,
268
+ onMouseDown: jt,
269
+ onMouseMove: Bt,
270
+ onMouseUp: Ot,
271
+ onMouseLeave: zt,
269
272
  children: [
270
- /* @__PURE__ */ y("g", { transform: `translate(${h.left},${h.top})`, children: [
271
- j && /* @__PURE__ */ r("text", { x: u / 2, y: -10, textAnchor: "middle", className: "nice-chart__title", children: j }),
272
- ne && ue.map((e) => /* @__PURE__ */ r(
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(e),
277
- x2: u,
278
- y2: m(e),
279
+ y1: m(t),
280
+ x2: x,
281
+ y2: m(t),
279
282
  className: "nice-chart__grid-line"
280
283
  },
281
- `grid-${e}`
284
+ `grid-${t}`
282
285
  )),
283
- P && ue.map((e) => /* @__PURE__ */ r(
286
+ J && $t.map((t) => /* @__PURE__ */ r(
284
287
  "text",
285
288
  {
286
289
  x: -8,
287
- y: m(e) + 4,
290
+ y: m(t) + 4,
288
291
  textAnchor: "end",
289
292
  className: "nice-chart__axis-label",
290
- children: e
293
+ children: t
291
294
  },
292
- `ylabel-${e}`
295
+ `ylabel-${t}`
293
296
  )),
294
- P && F && F.map((e, n) => /* @__PURE__ */ r(
297
+ J && D && D.map((t, n) => /* @__PURE__ */ r(
295
298
  "text",
296
299
  {
297
- x: N(n),
300
+ x: S(n),
298
301
  y: _ + 20,
299
302
  textAnchor: "middle",
300
303
  className: "nice-chart__axis-label",
301
- children: e
304
+ children: t
302
305
  },
303
306
  n
304
307
  )),
305
- Z && /* @__PURE__ */ r(
308
+ K && /* @__PURE__ */ r(
306
309
  "text",
307
310
  {
308
- x: -h.left + 14,
311
+ x: -i.left + 14,
309
312
  y: _ / 2,
310
313
  textAnchor: "middle",
311
- transform: `rotate(-90, -${h.left - 14}, ${_ / 2})`,
314
+ transform: `rotate(-90, -${i.left - 14}, ${_ / 2})`,
312
315
  className: "nice-chart__axis-title",
313
- children: Z
316
+ children: K
314
317
  }
315
318
  ),
316
- q && /* @__PURE__ */ r("text", { x: u / 2, y: _ + 45, textAnchor: "middle", className: "nice-chart__axis-title", children: q }),
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: u, y2: _, className: "nice-chart__axis" }),
319
- ye?.map((e, n) => {
320
- if (e.type === "line") {
321
- const a = m(e.value);
322
- return /* @__PURE__ */ y("g", { children: [
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: a,
328
- x2: u,
329
- y2: a,
330
- stroke: e.color || "var(--nice-color-error, #ef4444)",
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: e.dash || "6,3"
335
+ strokeDasharray: t.dash || "6,3"
333
336
  }
334
337
  ),
335
- e.label && /* @__PURE__ */ r(
338
+ t.label && /* @__PURE__ */ r(
336
339
  "text",
337
340
  {
338
- x: u + 4,
339
- y: a + 4,
341
+ x: x + 4,
342
+ y: c + 4,
340
343
  className: "nice-chart__annotation-label",
341
- fill: e.color || "var(--nice-color-error, #ef4444)",
342
- children: e.label
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: N(e.value),
353
+ x: S(t.value),
351
354
  y: -4,
352
355
  textAnchor: "middle",
353
356
  className: "nice-chart__annotation-label",
354
- fill: e.color || "var(--nice-text-muted, #6b7280)",
355
- children: e.label
357
+ fill: t.color || "var(--nice-text-muted, #6b7280)",
358
+ children: t.label
356
359
  },
357
360
  n
358
361
  );
359
362
  }),
360
- ge && v && v.x >= 0 && v.x <= u && v.y >= 0 && v.y <= _ && /* @__PURE__ */ y(Ee, { children: [
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: v.x,
367
+ x1: N.x,
365
368
  y1: 0,
366
- x2: v.x,
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: v.y,
378
- x2: u,
379
- y2: v.y,
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((e, n) => {
387
- const a = e.color || k[n % k.length], i = e.type || "bar";
388
- if (i === "bar")
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: O ? "nice-chart__series nice-chart__series--bar nice-chart__series--anim" : "nice-chart__series nice-chart__series--bar",
393
- children: e.data.map((c, s) => {
394
- let t, o;
395
- if (B) {
396
- const f = p.slice(0, n).filter(pe).reduce((A, te) => A + (te.data[s] || 0), 0);
397
- t = m(f + c), o = m(f) - t;
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
- t = m(Math.max(0, c)), o = Math.abs(m(c) - m(0));
400
- const d = Q.get(e) ?? 0, x = B ? N(s) - D / 2 : N(s) - Q.size * V / 2 + d * V + (V - D) / 2;
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: t,
406
- width: D,
407
- height: Math.max(0, o),
408
- fill: a,
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: `${x + D / 2}px ${m(0)}px`,
412
- ...M ? { cursor: "pointer" } : {}
414
+ transformOrigin: `${f + Z / 2}px ${m(0)}px`,
415
+ ...v ? { cursor: "pointer" } : {}
413
416
  },
414
- onClick: M ? () => M(e.name, S + s, c) : void 0,
415
- children: /* @__PURE__ */ r("title", { children: `${e.name}: ${c}` })
417
+ onClick: v ? () => v(t.name, R + o, a) : void 0,
418
+ children: /* @__PURE__ */ r("title", { children: `${t.name}: ${a}` })
416
419
  },
417
- s
420
+ o
418
421
  );
419
422
  })
420
423
  },
421
- e.name
424
+ t.name
422
425
  );
423
- if (i === "scatter")
426
+ if (h === "scatter")
424
427
  return /* @__PURE__ */ r(
425
428
  "g",
426
429
  {
427
- className: O ? "nice-chart__series nice-chart__series--scatter nice-chart__series--anim" : "nice-chart__series nice-chart__series--scatter",
428
- children: e.data.map((c, s) => /* @__PURE__ */ r(
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: N(s),
432
- cy: m(c),
434
+ cx: S(o),
435
+ cy: m(a),
433
436
  r: 5,
434
- fill: a,
437
+ fill: c,
435
438
  fillOpacity: 0.7,
436
- stroke: a,
439
+ stroke: c,
437
440
  strokeWidth: 1.5,
438
- style: M ? { cursor: "pointer" } : void 0,
439
- onClick: M ? () => M(e.name, S + s, c) : void 0,
440
- children: /* @__PURE__ */ r("title", { children: `${e.name}: ${c}` })
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
- s
445
+ o
443
446
  ))
444
447
  },
445
- e.name
448
+ t.name
446
449
  );
447
- const l = e.data.map((c, s) => `${N(s)},${m(c)}`);
448
- return /* @__PURE__ */ y(
450
+ const l = t.data.map((a, o) => `${S(o)},${m(a)}`);
451
+ return /* @__PURE__ */ M(
449
452
  "g",
450
453
  {
451
- className: O ? `nice-chart__series nice-chart__series--${i} nice-chart__series--anim` : `nice-chart__series nice-chart__series--${i}`,
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
- i === "area" && $ > 0 && /* @__PURE__ */ r(
456
+ h === "area" && b > 0 && /* @__PURE__ */ r(
454
457
  "polygon",
455
458
  {
456
- points: `${N(0)},${m(0)} ${l.join(" ")} ${N($ - 1)},${m(0)}`,
457
- fill: a,
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: a,
469
+ stroke: c,
467
470
  strokeWidth: 2,
468
- className: O ? "nice-chart__line" : void 0
471
+ className: I ? "nice-chart__line" : void 0
469
472
  }
470
473
  ),
471
- e.data.map((c, s) => /* @__PURE__ */ r(
474
+ t.data.map((a, o) => /* @__PURE__ */ r(
472
475
  "circle",
473
476
  {
474
- cx: N(s),
475
- cy: m(c),
477
+ cx: S(o),
478
+ cy: m(a),
476
479
  r: 3,
477
- fill: a,
478
- style: M ? { cursor: "pointer" } : void 0,
479
- onClick: M ? () => M(e.name, S + s, c) : void 0,
480
- children: /* @__PURE__ */ r("title", { children: `${e.name}: ${c}` })
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
- s
485
+ o
483
486
  ))
484
487
  ]
485
488
  },
486
- e.name
489
+ t.name
487
490
  );
488
491
  })
489
492
  ] }),
490
- z && /* @__PURE__ */ r("g", { transform: `translate(${h.left}, ${b})`, children: C.map((e, n) => {
491
- const a = n * 120, i = X.has(e.name);
492
- return /* @__PURE__ */ y(
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: `translate(${a}, 10)`,
496
- style: I ? { cursor: "pointer" } : void 0,
497
- onClick: () => me(e.name),
498
- opacity: i ? 0.35 : 1,
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: e.color || k[n % k.length] }),
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: i ? { textDecoration: "line-through" } : void 0,
508
- children: e.name
510
+ style: c ? { textDecoration: "line-through" } : void 0,
511
+ children: t.name
509
512
  }
510
513
  )
511
514
  ]
512
515
  },
513
- e.name
516
+ t.name
514
517
  );
515
518
  }) })
516
519
  ]
@@ -521,5 +524,5 @@ const je = [], k = [
521
524
  );
522
525
  };
523
526
  export {
524
- Te as NiceChart
527
+ qt as NiceChart
525
528
  };