@nice2dev/ui 1.4.23 → 1.4.24
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 +57 -0
- package/dist/{NicePivotGrid-B5Fgi5E_.cjs → NicePivotGrid-D53CQ2cY.cjs} +1 -1
- package/dist/charts/NiceAdvancedCharts.mjs +586 -773
- package/dist/charts/NiceChartRangeSelector.mjs +159 -0
- package/dist/charts/NiceHeatMap.mjs +140 -70
- package/dist/charts/NiceOrganizationChart.mjs +183 -90
- package/dist/charts/NiceSankey.mjs +166 -93
- package/dist/charts/NiceStockChart.mjs +258 -157
- package/dist/charts-CSgOgfES.cjs +867 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.d.ts +126 -102
- package/dist/charts.mjs +22 -24
- package/dist/core/lazy.mjs +50 -63
- package/dist/core-lazy-sO0xvg64.cjs +1 -0
- package/dist/data.cjs +1 -1
- package/dist/demo/docs/docPreviews.mjs +450 -466
- package/dist/demo/docs/docRegistry.mjs +5 -35
- package/dist/index.cjs +60 -67
- package/dist/index.d.ts +121 -172
- package/dist/index.mjs +831 -836
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.d.ts +41 -23
- package/dist/lazy.mjs +1 -1
- package/dist/style.css +1 -1
- package/dist/tools/NiceShowcase.mjs +1 -2
- package/package.json +4 -4
- package/dist/charts/NiceRangeSelector.mjs +0 -135
- package/dist/charts/NiceTreeMap.mjs +0 -100
- package/dist/charts/NiceVectorMap.mjs +0 -59
- package/dist/charts-C9B548D2.cjs +0 -924
- package/dist/core-lazy-B54FdghB.cjs +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useNiceTranslation as
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { jsxs as u, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useNiceTranslation as ue, NiceIcon as ge, clickOnActivationKey as xe } from "@nice2dev/ui-core";
|
|
3
|
+
import be, { useMemo as de, useState as J, useEffect as fe, useRef as he, forwardRef as ye, useCallback as R, useImperativeHandle as we, useId as Le } from "react";
|
|
4
|
+
import { CHART_COLORS as Se } from "./colors.mjs";
|
|
5
|
+
const ze = [], Ie = Se, Re = [
|
|
5
6
|
"var(--nice-color-primary, #3b82f6)",
|
|
6
7
|
"var(--nice-color-error, #ef4444)",
|
|
7
8
|
"var(--nice-color-success, #22c55e)",
|
|
@@ -13,333 +14,333 @@ const ze = [], Ie = [], De = [], ye = [
|
|
|
13
14
|
"var(--nice-color-warning, #f59e0b)",
|
|
14
15
|
"var(--nice-color-accent, #6366f1)"
|
|
15
16
|
], Te = /* @__PURE__ */ Object.assign(
|
|
16
|
-
/* @__PURE__ */
|
|
17
|
-
const { t:
|
|
18
|
-
levels:
|
|
19
|
-
initialLevelId:
|
|
20
|
-
levelId:
|
|
21
|
-
chartType:
|
|
22
|
-
width:
|
|
23
|
-
height:
|
|
24
|
-
showBreadcrumbs:
|
|
17
|
+
/* @__PURE__ */ ye((A, Y) => {
|
|
18
|
+
const { t: S } = ue(), {
|
|
19
|
+
levels: x = ze,
|
|
20
|
+
initialLevelId: Q,
|
|
21
|
+
levelId: B,
|
|
22
|
+
chartType: ee = "bar",
|
|
23
|
+
width: w = 600,
|
|
24
|
+
height: D = 400,
|
|
25
|
+
showBreadcrumbs: re = !0,
|
|
25
26
|
showBackButton: K = !0,
|
|
26
|
-
animationDuration:
|
|
27
|
+
animationDuration: E = 300,
|
|
27
28
|
onLevelChange: j,
|
|
28
|
-
onItemClick:
|
|
29
|
-
colors:
|
|
30
|
-
showValues:
|
|
31
|
-
showLegend:
|
|
32
|
-
className:
|
|
29
|
+
onItemClick: ie,
|
|
30
|
+
colors: P = Re,
|
|
31
|
+
showValues: _ = !0,
|
|
32
|
+
showLegend: ce = !0,
|
|
33
|
+
className: V,
|
|
33
34
|
style: T,
|
|
34
|
-
testId:
|
|
35
|
-
"data-testid":
|
|
36
|
-
...
|
|
37
|
-
} =
|
|
35
|
+
testId: H,
|
|
36
|
+
"data-testid": te,
|
|
37
|
+
...ne
|
|
38
|
+
} = A, F = B !== void 0, [le, ae] = J(Q || x[0]?.id), [d, Z] = J([Q || x[0]?.id]), k = R(
|
|
38
39
|
(e) => {
|
|
39
|
-
const
|
|
40
|
-
let
|
|
41
|
-
for (;
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
return
|
|
40
|
+
const a = [];
|
|
41
|
+
let o = x.find((s) => s.id === e);
|
|
42
|
+
for (; o && !a.includes(o.id); ) {
|
|
43
|
+
a.unshift(o.id);
|
|
44
|
+
const s = o.parentId;
|
|
45
|
+
o = s ? x.find((c) => c.id === s) : void 0;
|
|
46
|
+
}
|
|
47
|
+
return a.length > 0 ? a : [e];
|
|
47
48
|
},
|
|
48
|
-
[
|
|
49
|
-
),
|
|
50
|
-
() =>
|
|
51
|
-
[
|
|
52
|
-
), [
|
|
53
|
-
() =>
|
|
54
|
-
[
|
|
55
|
-
),
|
|
49
|
+
[x]
|
|
50
|
+
), z = B ?? le, r = de(
|
|
51
|
+
() => B !== void 0 ? k(B) : d,
|
|
52
|
+
[B, d, k]
|
|
53
|
+
), [m, h] = J(!1), [$, b] = J("in"), l = de(
|
|
54
|
+
() => x.find((e) => e.id === z),
|
|
55
|
+
[x, z]
|
|
56
|
+
), y = R(
|
|
56
57
|
(e) => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
},
|
|
58
|
+
x.find((o) => o.id === e) && (b("in"), h(!0), setTimeout(() => {
|
|
59
|
+
F || (ae(e), Z((o) => [...o, e])), j?.(e, F ? k(e) : [...r, e]), h(!1);
|
|
60
|
+
}, E / 2));
|
|
60
61
|
},
|
|
61
|
-
[
|
|
62
|
-
),
|
|
62
|
+
[x, r, E, j, F, k]
|
|
63
|
+
), C = R(() => {
|
|
63
64
|
if (r.length <= 1)
|
|
64
65
|
return;
|
|
65
|
-
|
|
66
|
-
const e = r.slice(0, -1),
|
|
66
|
+
b("out"), h(!0);
|
|
67
|
+
const e = r.slice(0, -1), a = e[e.length - 1];
|
|
67
68
|
setTimeout(() => {
|
|
68
|
-
|
|
69
|
-
},
|
|
70
|
-
}, [r,
|
|
71
|
-
const e =
|
|
72
|
-
e && (
|
|
73
|
-
|
|
74
|
-
},
|
|
75
|
-
}, [
|
|
76
|
-
|
|
77
|
-
|
|
69
|
+
F || (ae(a), Z(e)), j?.(a, e), h(!1);
|
|
70
|
+
}, E / 2);
|
|
71
|
+
}, [r, E, j, F]), f = R(() => {
|
|
72
|
+
const e = x[0]?.id;
|
|
73
|
+
e && (b("out"), h(!0), setTimeout(() => {
|
|
74
|
+
F || (ae(e), Z([e])), j?.(e, [e]), h(!1);
|
|
75
|
+
}, E / 2));
|
|
76
|
+
}, [x, E, j, F]);
|
|
77
|
+
we(
|
|
78
|
+
Y,
|
|
78
79
|
() => ({
|
|
79
|
-
drillDown:
|
|
80
|
-
drillUp:
|
|
81
|
-
resetToRoot:
|
|
82
|
-
getCurrentLevel: () =>
|
|
80
|
+
drillDown: y,
|
|
81
|
+
drillUp: C,
|
|
82
|
+
resetToRoot: f,
|
|
83
|
+
getCurrentLevel: () => z,
|
|
83
84
|
getPath: () => r
|
|
84
85
|
}),
|
|
85
|
-
[
|
|
86
|
+
[y, C, f, z, r]
|
|
86
87
|
);
|
|
87
|
-
const
|
|
88
|
-
(e,
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
|
|
88
|
+
const O = R(
|
|
89
|
+
(e, a) => {
|
|
90
|
+
ie?.(e, z);
|
|
91
|
+
const o = e.drillDownId ?? e.metadata?.childLevelId, s = o ? x.find((c) => c.id === o) : void 0;
|
|
92
|
+
s && y(s.id);
|
|
92
93
|
},
|
|
93
|
-
[
|
|
94
|
-
),
|
|
95
|
-
() =>
|
|
96
|
-
[
|
|
97
|
-
),
|
|
98
|
-
() => r.map((e) =>
|
|
99
|
-
[r,
|
|
100
|
-
),
|
|
101
|
-
if (!
|
|
94
|
+
[z, x, y, ie]
|
|
95
|
+
), g = de(
|
|
96
|
+
() => l?.data.reduce((e, a) => e + a.value, 0) || 0,
|
|
97
|
+
[l]
|
|
98
|
+
), L = de(
|
|
99
|
+
() => r.map((e) => x.find((a) => a.id === e)?.label || e),
|
|
100
|
+
[r, x]
|
|
101
|
+
), W = () => {
|
|
102
|
+
if (!l)
|
|
102
103
|
return null;
|
|
103
|
-
const e =
|
|
104
|
-
return /* @__PURE__ */
|
|
105
|
-
const
|
|
106
|
-
return /* @__PURE__ */
|
|
104
|
+
const e = l.data, a = Math.max(...e.map((s) => s.value)), o = Math.min(40, (D - 100) / e.length - 8);
|
|
105
|
+
return /* @__PURE__ */ t("div", { className: "nice-drilldown-bars", children: e.map((s, c) => {
|
|
106
|
+
const i = s.value / a * 100;
|
|
107
|
+
return /* @__PURE__ */ u(
|
|
107
108
|
"div",
|
|
108
109
|
{
|
|
109
110
|
role: "button",
|
|
110
111
|
tabIndex: 0,
|
|
111
|
-
onKeyDown:
|
|
112
|
+
onKeyDown: xe,
|
|
112
113
|
className: "nice-drilldown-bar-row",
|
|
113
|
-
onClick: () =>
|
|
114
|
+
onClick: () => O(s, c),
|
|
114
115
|
children: [
|
|
115
|
-
/* @__PURE__ */
|
|
116
|
-
/* @__PURE__ */
|
|
116
|
+
/* @__PURE__ */ t("span", { className: "nice-drilldown-bar-label", children: s.label || S("charts.item", "Item {i}").replace("{i}", String(c + 1)) }),
|
|
117
|
+
/* @__PURE__ */ t("div", { className: "nice-drilldown-bar-track", children: /* @__PURE__ */ t(
|
|
117
118
|
"div",
|
|
118
119
|
{
|
|
119
120
|
className: "nice-drilldown-bar-fill",
|
|
120
121
|
style: {
|
|
121
|
-
width: `${
|
|
122
|
-
backgroundColor:
|
|
123
|
-
height:
|
|
122
|
+
width: `${i}%`,
|
|
123
|
+
backgroundColor: s.color || P[c % P.length],
|
|
124
|
+
height: o
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
127
|
) }),
|
|
127
|
-
|
|
128
|
+
_ && /* @__PURE__ */ t("span", { className: "nice-drilldown-bar-value", children: s.value.toLocaleString() })
|
|
128
129
|
]
|
|
129
130
|
},
|
|
130
|
-
|
|
131
|
+
c
|
|
131
132
|
);
|
|
132
133
|
}) });
|
|
133
|
-
},
|
|
134
|
-
if (!
|
|
134
|
+
}, X = `nice-drill-gaps-${Le().replace(/[^a-zA-Z0-9_-]/g, "")}`, U = () => {
|
|
135
|
+
if (!l)
|
|
135
136
|
return null;
|
|
136
|
-
const e =
|
|
137
|
-
let
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
return
|
|
137
|
+
const e = l.data, a = D - 40, o = w / 2, s = a / 2, c = Math.max(10, Math.min(w, a) / 2 - 16);
|
|
138
|
+
let i = -90;
|
|
139
|
+
const N = e.map((p, G) => {
|
|
140
|
+
const me = p.value / g * 360, n = i + me, v = me > 180 ? 1 : 0, M = i * Math.PI / 180, oe = n * Math.PI / 180, pe = o + c * Math.cos(M), se = s + c * Math.sin(M), ke = o + c * Math.cos(oe), Ne = s + c * Math.sin(oe), ve = (i + me / 2) * Math.PI / 180, Me = o + c * 0.7 * Math.cos(ve), $e = s + c * 0.7 * Math.sin(ve), Ce = `M ${o} ${s} L ${pe} ${se} A ${c} ${c} 0 ${v} 1 ${ke} ${Ne} Z`;
|
|
141
|
+
return i = n, {
|
|
141
142
|
path: Ce,
|
|
142
|
-
startRad:
|
|
143
|
-
drillable: !!(
|
|
144
|
-
color:
|
|
145
|
-
label:
|
|
146
|
-
value:
|
|
147
|
-
percentage: (
|
|
148
|
-
labelX:
|
|
149
|
-
labelY:
|
|
150
|
-
item:
|
|
151
|
-
index:
|
|
143
|
+
startRad: M,
|
|
144
|
+
drillable: !!(p.drillDownId ?? p.metadata?.childLevelId),
|
|
145
|
+
color: p.color || P[G % P.length],
|
|
146
|
+
label: p.label || S("charts.item", "Item {i}").replace("{i}", String(G + 1)),
|
|
147
|
+
value: p.value,
|
|
148
|
+
percentage: (p.value / g * 100).toFixed(1),
|
|
149
|
+
labelX: Me,
|
|
150
|
+
labelY: $e,
|
|
151
|
+
item: p,
|
|
152
|
+
index: G
|
|
152
153
|
};
|
|
153
|
-
}),
|
|
154
|
-
return /* @__PURE__ */
|
|
155
|
-
|
|
154
|
+
}), I = N.length > 1 ? N.map((p) => p.startRad) : [];
|
|
155
|
+
return /* @__PURE__ */ u("svg", { width: w, height: a, className: "nice-drilldown-pie", children: [
|
|
156
|
+
I.length > 0 && /* @__PURE__ */ t("defs", { children: /* @__PURE__ */ u(
|
|
156
157
|
"mask",
|
|
157
158
|
{
|
|
158
|
-
id:
|
|
159
|
+
id: X,
|
|
159
160
|
maskUnits: "userSpaceOnUse",
|
|
160
161
|
x: 0,
|
|
161
162
|
y: 0,
|
|
162
|
-
width:
|
|
163
|
-
height:
|
|
163
|
+
width: w,
|
|
164
|
+
height: a,
|
|
164
165
|
children: [
|
|
165
|
-
/* @__PURE__ */
|
|
166
|
-
|
|
166
|
+
/* @__PURE__ */ t("rect", { x: 0, y: 0, width: w, height: a, fill: "white" }),
|
|
167
|
+
I.map((p, G) => /* @__PURE__ */ t(
|
|
167
168
|
"line",
|
|
168
169
|
{
|
|
169
|
-
x1:
|
|
170
|
-
y1:
|
|
171
|
-
x2:
|
|
172
|
-
y2:
|
|
170
|
+
x1: o,
|
|
171
|
+
y1: s,
|
|
172
|
+
x2: o + (c + 2) * Math.cos(p),
|
|
173
|
+
y2: s + (c + 2) * Math.sin(p),
|
|
173
174
|
stroke: "black",
|
|
174
175
|
strokeWidth: 2
|
|
175
176
|
},
|
|
176
|
-
|
|
177
|
+
G
|
|
177
178
|
))
|
|
178
179
|
]
|
|
179
180
|
}
|
|
180
181
|
) }),
|
|
181
|
-
/* @__PURE__ */
|
|
182
|
+
/* @__PURE__ */ t("g", { mask: I.length > 0 ? `url(#${X})` : void 0, children: N.map((p, G) => /* @__PURE__ */ t(
|
|
182
183
|
"path",
|
|
183
184
|
{
|
|
184
|
-
d:
|
|
185
|
-
fill:
|
|
186
|
-
className: `nice-drilldown-pie-slice${
|
|
187
|
-
onClick: () =>
|
|
188
|
-
children: /* @__PURE__ */
|
|
185
|
+
d: p.path,
|
|
186
|
+
fill: p.color,
|
|
187
|
+
className: `nice-drilldown-pie-slice${p.drillable ? " nice-drilldown-pie-slice--drillable" : ""}`,
|
|
188
|
+
onClick: () => O(p.item, p.index),
|
|
189
|
+
children: /* @__PURE__ */ t("title", { children: `${p.label}: ${p.value} (${p.percentage}%)` })
|
|
189
190
|
},
|
|
190
|
-
|
|
191
|
+
G
|
|
191
192
|
)) }),
|
|
192
|
-
|
|
193
|
-
(
|
|
193
|
+
_ && N.map(
|
|
194
|
+
(p, G) => parseFloat(p.percentage) > 5 ? /* @__PURE__ */ u(
|
|
194
195
|
"text",
|
|
195
196
|
{
|
|
196
|
-
x:
|
|
197
|
-
y:
|
|
197
|
+
x: p.labelX,
|
|
198
|
+
y: p.labelY,
|
|
198
199
|
textAnchor: "middle",
|
|
199
200
|
dominantBaseline: "middle",
|
|
200
201
|
className: "nice-piechart__label",
|
|
201
202
|
style: { fontSize: 13, pointerEvents: "none" },
|
|
202
203
|
children: [
|
|
203
|
-
|
|
204
|
+
p.percentage,
|
|
204
205
|
"%"
|
|
205
206
|
]
|
|
206
207
|
},
|
|
207
|
-
|
|
208
|
+
G
|
|
208
209
|
) : null
|
|
209
210
|
)
|
|
210
211
|
] });
|
|
211
|
-
},
|
|
212
|
-
if (!
|
|
212
|
+
}, q = () => {
|
|
213
|
+
if (!l)
|
|
213
214
|
return null;
|
|
214
|
-
const e =
|
|
215
|
-
return /* @__PURE__ */
|
|
216
|
-
[0, 0.25, 0.5, 0.75, 1].map((
|
|
217
|
-
/* @__PURE__ */
|
|
215
|
+
const e = l.data, a = Math.max(...e.map((c) => c.value)), o = Math.min(60, (w - 100) / e.length - 8), s = D - 100;
|
|
216
|
+
return /* @__PURE__ */ t("svg", { width: w, height: D - 40, className: "nice-drilldown-columns", children: /* @__PURE__ */ u("g", { transform: "translate(50, 20)", children: [
|
|
217
|
+
[0, 0.25, 0.5, 0.75, 1].map((c, i) => /* @__PURE__ */ u("g", { children: [
|
|
218
|
+
/* @__PURE__ */ t(
|
|
218
219
|
"line",
|
|
219
220
|
{
|
|
220
221
|
x1: 0,
|
|
221
|
-
y1:
|
|
222
|
-
x2:
|
|
223
|
-
y2:
|
|
222
|
+
y1: s * (1 - c),
|
|
223
|
+
x2: w - 80,
|
|
224
|
+
y2: s * (1 - c),
|
|
224
225
|
stroke: "var(--nice-border-color, #e5e7eb)",
|
|
225
|
-
strokeDasharray:
|
|
226
|
+
strokeDasharray: c === 0 ? void 0 : "4"
|
|
226
227
|
}
|
|
227
228
|
),
|
|
228
|
-
/* @__PURE__ */
|
|
229
|
+
/* @__PURE__ */ t(
|
|
229
230
|
"text",
|
|
230
231
|
{
|
|
231
232
|
x: -8,
|
|
232
|
-
y:
|
|
233
|
+
y: s * (1 - c),
|
|
233
234
|
textAnchor: "end",
|
|
234
235
|
dominantBaseline: "middle",
|
|
235
236
|
fontSize: "11",
|
|
236
237
|
fill: "var(--nice-text-secondary, #6b7280)",
|
|
237
|
-
children: Math.round(
|
|
238
|
+
children: Math.round(a * c).toLocaleString()
|
|
238
239
|
}
|
|
239
240
|
)
|
|
240
|
-
] },
|
|
241
|
-
e.map((
|
|
242
|
-
const
|
|
243
|
-
return /* @__PURE__ */
|
|
244
|
-
/* @__PURE__ */
|
|
241
|
+
] }, i)),
|
|
242
|
+
e.map((c, i) => {
|
|
243
|
+
const N = c.value / a * s, I = i * ((w - 100) / e.length) + ((w - 100) / e.length - o) / 2;
|
|
244
|
+
return /* @__PURE__ */ u("g", { onClick: () => O(c, i), children: [
|
|
245
|
+
/* @__PURE__ */ t(
|
|
245
246
|
"rect",
|
|
246
247
|
{
|
|
247
|
-
x:
|
|
248
|
-
y:
|
|
249
|
-
width:
|
|
250
|
-
height:
|
|
251
|
-
fill:
|
|
248
|
+
x: I,
|
|
249
|
+
y: s - N,
|
|
250
|
+
width: o,
|
|
251
|
+
height: N,
|
|
252
|
+
fill: c.color || P[i % P.length],
|
|
252
253
|
rx: 4,
|
|
253
254
|
className: "nice-drilldown-column-bar"
|
|
254
255
|
}
|
|
255
256
|
),
|
|
256
|
-
/* @__PURE__ */
|
|
257
|
+
/* @__PURE__ */ t(
|
|
257
258
|
"text",
|
|
258
259
|
{
|
|
259
|
-
x:
|
|
260
|
-
y:
|
|
260
|
+
x: I + o / 2,
|
|
261
|
+
y: s + 16,
|
|
261
262
|
textAnchor: "middle",
|
|
262
263
|
fontSize: "11",
|
|
263
264
|
fill: "var(--nice-text-primary, #374151)",
|
|
264
|
-
children: (
|
|
265
|
+
children: (c.label || `${i + 1}`).slice(0, 10)
|
|
265
266
|
}
|
|
266
267
|
),
|
|
267
|
-
|
|
268
|
+
_ && /* @__PURE__ */ t(
|
|
268
269
|
"text",
|
|
269
270
|
{
|
|
270
|
-
x:
|
|
271
|
-
y:
|
|
271
|
+
x: I + o / 2,
|
|
272
|
+
y: s - N - 8,
|
|
272
273
|
textAnchor: "middle",
|
|
273
274
|
fontSize: "11",
|
|
274
275
|
fill: "var(--nice-text-primary, #374151)",
|
|
275
276
|
fontWeight: "500",
|
|
276
|
-
children:
|
|
277
|
+
children: c.value.toLocaleString()
|
|
277
278
|
}
|
|
278
279
|
)
|
|
279
|
-
] },
|
|
280
|
+
] }, i);
|
|
280
281
|
})
|
|
281
282
|
] }) });
|
|
282
283
|
};
|
|
283
|
-
return /* @__PURE__ */
|
|
284
|
+
return /* @__PURE__ */ u(
|
|
284
285
|
"div",
|
|
285
286
|
{
|
|
286
|
-
className: `nice-drilldown-chart ${
|
|
287
|
-
style: { width:
|
|
288
|
-
"data-testid":
|
|
289
|
-
...
|
|
287
|
+
className: `nice-drilldown-chart ${m ? `animating ${$}` : ""} ${V || ""}`,
|
|
288
|
+
style: { width: w, ...T },
|
|
289
|
+
"data-testid": te ?? H,
|
|
290
|
+
...ne,
|
|
290
291
|
children: [
|
|
291
|
-
/* @__PURE__ */
|
|
292
|
-
K && /* @__PURE__ */
|
|
292
|
+
/* @__PURE__ */ u("div", { className: "nice-drilldown-header", children: [
|
|
293
|
+
K && /* @__PURE__ */ u(
|
|
293
294
|
"button",
|
|
294
295
|
{
|
|
295
296
|
type: "button",
|
|
296
297
|
className: "nice-drilldown-back",
|
|
297
|
-
onClick:
|
|
298
|
+
onClick: C,
|
|
298
299
|
disabled: r.length <= 1,
|
|
299
300
|
children: [
|
|
300
|
-
/* @__PURE__ */
|
|
301
|
+
/* @__PURE__ */ t(ge, { name: "arrow-left", size: 14 }),
|
|
301
302
|
" ",
|
|
302
|
-
|
|
303
|
+
S("charts.back", "Back")
|
|
303
304
|
]
|
|
304
305
|
}
|
|
305
306
|
),
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
/* @__PURE__ */
|
|
307
|
+
re && /* @__PURE__ */ t("div", { className: "nice-drilldown-breadcrumbs", children: L.map((e, a) => /* @__PURE__ */ u(be.Fragment, { children: [
|
|
308
|
+
a > 0 && /* @__PURE__ */ t("span", { className: "nice-drilldown-separator", children: "/" }),
|
|
309
|
+
/* @__PURE__ */ t(
|
|
309
310
|
"span",
|
|
310
311
|
{
|
|
311
|
-
role:
|
|
312
|
-
tabIndex:
|
|
313
|
-
"aria-current":
|
|
314
|
-
onKeyDown:
|
|
315
|
-
className: `nice-drilldown-crumb ${
|
|
312
|
+
role: a < L.length - 1 ? "button" : void 0,
|
|
313
|
+
tabIndex: a < L.length - 1 ? 0 : void 0,
|
|
314
|
+
"aria-current": a === L.length - 1 ? "location" : void 0,
|
|
315
|
+
onKeyDown: a < L.length - 1 ? xe : void 0,
|
|
316
|
+
className: `nice-drilldown-crumb ${a === L.length - 1 ? "active" : ""}`,
|
|
316
317
|
onClick: () => {
|
|
317
|
-
if (
|
|
318
|
-
const
|
|
319
|
-
|
|
318
|
+
if (a < L.length - 1) {
|
|
319
|
+
const o = r.slice(0, a + 1), s = o[o.length - 1];
|
|
320
|
+
F || (Z(o), ae(s)), j?.(s, o);
|
|
320
321
|
}
|
|
321
322
|
},
|
|
322
323
|
children: e
|
|
323
324
|
}
|
|
324
325
|
)
|
|
325
|
-
] },
|
|
326
|
+
] }, a)) })
|
|
326
327
|
] }),
|
|
327
|
-
/* @__PURE__ */
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
328
|
+
/* @__PURE__ */ u("div", { className: "nice-drilldown-content", style: { height: D - 40 }, children: [
|
|
329
|
+
ee === "bar" && W(),
|
|
330
|
+
ee === "pie" && U(),
|
|
331
|
+
ee === "column" && q()
|
|
331
332
|
] }),
|
|
332
|
-
|
|
333
|
-
/* @__PURE__ */
|
|
333
|
+
ce && l && /* @__PURE__ */ t("div", { className: "nice-drilldown-legend", children: l.data.map((e, a) => /* @__PURE__ */ u("div", { className: "nice-drilldown-legend-item", children: [
|
|
334
|
+
/* @__PURE__ */ t(
|
|
334
335
|
"span",
|
|
335
336
|
{
|
|
336
337
|
className: "nice-drilldown-legend-color",
|
|
337
|
-
style: { backgroundColor: e.color ||
|
|
338
|
+
style: { backgroundColor: e.color || P[a % P.length] }
|
|
338
339
|
}
|
|
339
340
|
),
|
|
340
|
-
/* @__PURE__ */
|
|
341
|
-
] },
|
|
342
|
-
/* @__PURE__ */
|
|
341
|
+
/* @__PURE__ */ t("span", { className: "nice-drilldown-legend-label", children: e.label || S("charts.item", "Item {i}").replace("{i}", String(a + 1)) })
|
|
342
|
+
] }, a)) }),
|
|
343
|
+
/* @__PURE__ */ t("style", { children: `
|
|
343
344
|
.nice-drilldown-chart {
|
|
344
345
|
font-family: inherit;
|
|
345
346
|
color: var(--nice-text-primary, #111827);
|
|
@@ -526,188 +527,205 @@ const ze = [], Ie = [], De = [], ye = [
|
|
|
526
527
|
);
|
|
527
528
|
}),
|
|
528
529
|
{ displayName: "NiceDrillDownChart" }
|
|
529
|
-
), Ae = [
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
width: b = 800,
|
|
540
|
-
height: H = 500,
|
|
541
|
-
viewBox: Y = "0 0 800 500",
|
|
542
|
-
colorScale: te,
|
|
530
|
+
), Ae = [18, 36, 56, 78, 100].map(
|
|
531
|
+
(A) => `color-mix(in srgb, var(--nice-color-primary, #3b82f6) ${A}%, var(--nice-bg-primary, #ffffff))`
|
|
532
|
+
), Ee = ({
|
|
533
|
+
type: A = "choropleth",
|
|
534
|
+
regions: Y = [],
|
|
535
|
+
bubbles: S = [],
|
|
536
|
+
width: x = 800,
|
|
537
|
+
height: Q = 500,
|
|
538
|
+
viewBox: B = "0 0 800 500",
|
|
539
|
+
colorScale: ee,
|
|
543
540
|
// The documented alias of `colorScale`. It was never destructured, so it did nothing
|
|
544
541
|
// and fell through `...rest` onto the root div (React warned about an unknown prop).
|
|
545
|
-
colorRange:
|
|
546
|
-
minValue:
|
|
547
|
-
maxValue:
|
|
542
|
+
colorRange: w,
|
|
543
|
+
minValue: D,
|
|
544
|
+
maxValue: re,
|
|
548
545
|
showTooltip: K = !0,
|
|
549
|
-
showLegend:
|
|
546
|
+
showLegend: E = !0,
|
|
550
547
|
onRegionClick: j,
|
|
551
|
-
onBubbleClick:
|
|
552
|
-
onRegionHover:
|
|
553
|
-
title:
|
|
554
|
-
mapSvg:
|
|
555
|
-
zoomable:
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
548
|
+
onBubbleClick: ie,
|
|
549
|
+
onRegionHover: P,
|
|
550
|
+
title: _,
|
|
551
|
+
mapSvg: ce,
|
|
552
|
+
zoomable: V = !1,
|
|
553
|
+
selectedRegionId: T,
|
|
554
|
+
bounds: H,
|
|
555
|
+
className: te,
|
|
556
|
+
style: ne,
|
|
557
|
+
testId: F,
|
|
558
|
+
"data-testid": le,
|
|
559
|
+
...ae
|
|
561
560
|
}) => {
|
|
562
|
-
const
|
|
563
|
-
(
|
|
564
|
-
|
|
565
|
-
|
|
561
|
+
const d = ee ?? w ?? Ae, { t: Z } = ue(), [k, z] = J(null), [r, m] = J(1), [h, $] = J({ x: 0, y: 0 }), b = he(null), l = he(!1), y = he({ x: 0, y: 0 }), C = he({ x: 0, y: 0 }), f = D ?? Math.min(...Y.map((n) => n.value), ...S.map((n) => n.value)), O = re ?? Math.max(...Y.map((n) => n.value), ...S.map((n) => n.value)), g = O - f, L = R(
|
|
562
|
+
(n) => Number.isFinite(g) && g > 0 ? (n - f) / g : 0.5,
|
|
563
|
+
[f, g]
|
|
564
|
+
), W = R(
|
|
565
|
+
(n) => {
|
|
566
|
+
const v = L(n);
|
|
567
|
+
if (A === "heat") {
|
|
568
|
+
const oe = Math.round(Math.max(0, Math.min(1, v)) * 100);
|
|
569
|
+
return `color-mix(in srgb, ${d[d.length - 1]} ${oe}%, ${d[0]})`;
|
|
570
|
+
}
|
|
571
|
+
const M = Math.min(Math.floor(v * d.length), d.length - 1);
|
|
572
|
+
return d[Math.max(0, M)];
|
|
566
573
|
},
|
|
567
|
-
[
|
|
568
|
-
),
|
|
569
|
-
(
|
|
570
|
-
|
|
574
|
+
[L, d, A]
|
|
575
|
+
), X = B.split(/[\s,]+/).map(Number), [U, q, e, a] = X.length === 4 && X.every(Number.isFinite) ? X : [0, 0, x, Q], o = (n, v) => {
|
|
576
|
+
if (!H)
|
|
577
|
+
return [n, v];
|
|
578
|
+
const [M, oe, pe, se] = H;
|
|
579
|
+
return [
|
|
580
|
+
U + (n - M) / (pe - M || 1) * e,
|
|
581
|
+
q + (se - v) / (se - oe || 1) * a
|
|
582
|
+
];
|
|
583
|
+
}, s = R(
|
|
584
|
+
(n) => {
|
|
585
|
+
if (!K || !k)
|
|
571
586
|
return;
|
|
572
|
-
const
|
|
573
|
-
|
|
574
|
-
(
|
|
587
|
+
const v = b.current?.getBoundingClientRect();
|
|
588
|
+
v && z(
|
|
589
|
+
(M) => M ? { ...M, x: n.clientX - v.left, y: n.clientY - v.top } : null
|
|
575
590
|
);
|
|
576
591
|
},
|
|
577
|
-
[K,
|
|
578
|
-
),
|
|
579
|
-
(
|
|
580
|
-
const
|
|
581
|
-
|
|
582
|
-
x:
|
|
583
|
-
y:
|
|
584
|
-
content: `${
|
|
585
|
-
}),
|
|
592
|
+
[K, k]
|
|
593
|
+
), c = R(
|
|
594
|
+
(n, v) => {
|
|
595
|
+
const M = b.current?.getBoundingClientRect();
|
|
596
|
+
M && K && z({
|
|
597
|
+
x: v.clientX - M.left,
|
|
598
|
+
y: v.clientY - M.top,
|
|
599
|
+
content: `${n.name}: ${n.value.toLocaleString()}`
|
|
600
|
+
}), P?.(n);
|
|
586
601
|
},
|
|
587
|
-
[K,
|
|
588
|
-
),
|
|
589
|
-
|
|
590
|
-
}, [
|
|
591
|
-
(
|
|
592
|
-
if (!
|
|
602
|
+
[K, P]
|
|
603
|
+
), i = R(() => {
|
|
604
|
+
z(null), P?.(null);
|
|
605
|
+
}, [P]), N = R(
|
|
606
|
+
(n) => {
|
|
607
|
+
if (!V)
|
|
593
608
|
return;
|
|
594
|
-
|
|
595
|
-
const
|
|
596
|
-
|
|
609
|
+
n.preventDefault();
|
|
610
|
+
const v = n.deltaY > 0 ? 0.9 : 1.1;
|
|
611
|
+
m((M) => Math.min(Math.max(M * v, 0.5), 4));
|
|
597
612
|
},
|
|
598
|
-
[
|
|
599
|
-
),
|
|
600
|
-
(
|
|
601
|
-
|
|
613
|
+
[V]
|
|
614
|
+
), I = R(
|
|
615
|
+
(n) => {
|
|
616
|
+
V && (l.current = !0, y.current = { x: n.clientX, y: n.clientY }, C.current = h);
|
|
602
617
|
},
|
|
603
|
-
[
|
|
604
|
-
),
|
|
605
|
-
|
|
606
|
-
}, []),
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
value: 100,
|
|
616
|
-
path: "M400,200 L450,200 L460,250 L420,280 L380,250 Z"
|
|
618
|
+
[V, h]
|
|
619
|
+
), p = R(() => {
|
|
620
|
+
l.current = !1;
|
|
621
|
+
}, []), G = R(
|
|
622
|
+
(n) => {
|
|
623
|
+
if (!l.current)
|
|
624
|
+
return;
|
|
625
|
+
const v = b.current?.getBoundingClientRect(), M = v && v.width > 0 ? e / v.width : 1;
|
|
626
|
+
$({
|
|
627
|
+
x: C.current.x + (n.clientX - y.current.x) * M,
|
|
628
|
+
y: C.current.y + (n.clientY - y.current.y) * M
|
|
629
|
+
});
|
|
617
630
|
},
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
name: "Wielkopolskie",
|
|
622
|
-
value: 70,
|
|
623
|
-
path: "M300,200 L350,200 L360,260 L310,270 L280,230 Z"
|
|
624
|
-
}
|
|
625
|
-
], [A]);
|
|
626
|
-
return /* @__PURE__ */ m(
|
|
631
|
+
[e]
|
|
632
|
+
), me = Y;
|
|
633
|
+
return /* @__PURE__ */ u(
|
|
627
634
|
"div",
|
|
628
635
|
{
|
|
629
|
-
className: `nice-map-chart ${
|
|
630
|
-
style: { width:
|
|
631
|
-
"data-testid":
|
|
632
|
-
...
|
|
636
|
+
className: `nice-map-chart ${te || ""}`,
|
|
637
|
+
style: { width: x, ...ne },
|
|
638
|
+
"data-testid": le ?? F,
|
|
639
|
+
...ae,
|
|
633
640
|
children: [
|
|
634
|
-
|
|
635
|
-
/* @__PURE__ */
|
|
641
|
+
_ && /* @__PURE__ */ t("div", { className: "nice-map-title", children: _ }),
|
|
642
|
+
/* @__PURE__ */ t(
|
|
636
643
|
"svg",
|
|
637
644
|
{
|
|
638
|
-
ref:
|
|
639
|
-
width:
|
|
640
|
-
height:
|
|
641
|
-
viewBox:
|
|
645
|
+
ref: b,
|
|
646
|
+
width: x,
|
|
647
|
+
height: Q,
|
|
648
|
+
viewBox: B,
|
|
642
649
|
className: "nice-map-svg",
|
|
643
650
|
onWheel: N,
|
|
644
|
-
onMouseDown:
|
|
645
|
-
onMouseUp:
|
|
646
|
-
onMouseLeave:
|
|
647
|
-
onMouseMove: (
|
|
648
|
-
|
|
651
|
+
onMouseDown: I,
|
|
652
|
+
onMouseUp: p,
|
|
653
|
+
onMouseLeave: p,
|
|
654
|
+
onMouseMove: (n) => {
|
|
655
|
+
s(n), G(n);
|
|
649
656
|
},
|
|
650
|
-
children: /* @__PURE__ */
|
|
651
|
-
|
|
652
|
-
|
|
657
|
+
children: /* @__PURE__ */ u("g", { transform: `translate(${h.x}, ${h.y}) scale(${r})`, children: [
|
|
658
|
+
ce && /* @__PURE__ */ t(
|
|
659
|
+
"image",
|
|
660
|
+
{
|
|
661
|
+
href: `data:image/svg+xml;charset=utf-8,${encodeURIComponent(ce)}`,
|
|
662
|
+
x: U,
|
|
663
|
+
y: q,
|
|
664
|
+
width: e,
|
|
665
|
+
height: a,
|
|
666
|
+
preserveAspectRatio: "xMidYMid meet"
|
|
667
|
+
}
|
|
668
|
+
),
|
|
669
|
+
(A === "choropleth" || A === "heat") && me.map((n) => /* @__PURE__ */ t(
|
|
653
670
|
"path",
|
|
654
671
|
{
|
|
655
|
-
d:
|
|
656
|
-
fill:
|
|
657
|
-
stroke: "var(--nice-bg-primary, #ffffff)",
|
|
658
|
-
strokeWidth: 1,
|
|
672
|
+
d: n.path,
|
|
673
|
+
fill: n.color || W(n.value),
|
|
674
|
+
stroke: n.id === T ? "var(--nice-text-primary, #111827)" : "var(--nice-bg-primary, #ffffff)",
|
|
675
|
+
strokeWidth: n.id === T ? 2.5 : 1,
|
|
676
|
+
"aria-selected": n.id === T || void 0,
|
|
659
677
|
className: "nice-map-region",
|
|
660
|
-
onClick: () => j?.(
|
|
661
|
-
onMouseEnter: (
|
|
662
|
-
onMouseLeave:
|
|
678
|
+
onClick: () => j?.(n),
|
|
679
|
+
onMouseEnter: (v) => c(n, v),
|
|
680
|
+
onMouseLeave: i
|
|
663
681
|
},
|
|
664
|
-
|
|
682
|
+
n.id
|
|
665
683
|
)),
|
|
666
|
-
(
|
|
667
|
-
const
|
|
668
|
-
return /* @__PURE__ */
|
|
684
|
+
(A === "bubble" || S.length > 0) && S.map((n) => {
|
|
685
|
+
const v = Math.sqrt(Math.max(0, L(n.value))) * 30 + 5, [M, oe] = o(n.lng, n.lat);
|
|
686
|
+
return /* @__PURE__ */ t(
|
|
669
687
|
"circle",
|
|
670
688
|
{
|
|
671
|
-
cx:
|
|
672
|
-
cy:
|
|
673
|
-
r:
|
|
674
|
-
fill:
|
|
689
|
+
cx: M,
|
|
690
|
+
cy: oe,
|
|
691
|
+
r: v,
|
|
692
|
+
fill: n.color || "var(--nice-color-primary, #3b82f6)",
|
|
675
693
|
fillOpacity: 0.7,
|
|
676
694
|
stroke: "var(--nice-bg-primary, #ffffff)",
|
|
677
695
|
strokeWidth: 1,
|
|
678
696
|
className: "nice-map-bubble",
|
|
679
|
-
onClick: () =>
|
|
680
|
-
onMouseEnter: (
|
|
681
|
-
const
|
|
682
|
-
|
|
683
|
-
x:
|
|
684
|
-
y:
|
|
685
|
-
content: `${
|
|
697
|
+
onClick: () => ie?.(n),
|
|
698
|
+
onMouseEnter: (pe) => {
|
|
699
|
+
const se = b.current?.getBoundingClientRect();
|
|
700
|
+
se && K && z({
|
|
701
|
+
x: pe.clientX - se.left,
|
|
702
|
+
y: pe.clientY - se.top,
|
|
703
|
+
content: `${n.label || n.id}: ${n.value.toLocaleString()}`
|
|
686
704
|
});
|
|
687
705
|
},
|
|
688
|
-
onMouseLeave:
|
|
689
|
-
children:
|
|
690
|
-
|
|
706
|
+
onMouseLeave: i,
|
|
707
|
+
children: n.label && /* @__PURE__ */ u("title", { children: [
|
|
708
|
+
n.label,
|
|
691
709
|
": ",
|
|
692
|
-
|
|
710
|
+
n.value
|
|
693
711
|
] })
|
|
694
712
|
},
|
|
695
|
-
|
|
713
|
+
n.id
|
|
696
714
|
);
|
|
697
715
|
})
|
|
698
716
|
] })
|
|
699
717
|
}
|
|
700
718
|
),
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
/* @__PURE__ */
|
|
704
|
-
/* @__PURE__ */
|
|
705
|
-
/* @__PURE__ */
|
|
706
|
-
/* @__PURE__ */
|
|
707
|
-
/* @__PURE__ */
|
|
719
|
+
k && /* @__PURE__ */ t("div", { className: "nice-map-tooltip", style: { left: k.x + 10, top: k.y - 30 }, children: k.content }),
|
|
720
|
+
E && Number.isFinite(f) && Number.isFinite(O) && /* @__PURE__ */ u("div", { className: "nice-map-legend", children: [
|
|
721
|
+
/* @__PURE__ */ t("span", { className: "nice-map-legend-title", children: Z("charts.value", "Value") }),
|
|
722
|
+
/* @__PURE__ */ t("div", { className: "nice-map-legend-scale", children: d.map((n, v) => /* @__PURE__ */ t("div", { className: "nice-map-legend-item", style: { backgroundColor: n } }, v)) }),
|
|
723
|
+
/* @__PURE__ */ u("div", { className: "nice-map-legend-labels", children: [
|
|
724
|
+
/* @__PURE__ */ t("span", { children: f.toLocaleString() }),
|
|
725
|
+
/* @__PURE__ */ t("span", { children: O.toLocaleString() })
|
|
708
726
|
] })
|
|
709
727
|
] }),
|
|
710
|
-
/* @__PURE__ */
|
|
728
|
+
/* @__PURE__ */ t("style", { children: `
|
|
711
729
|
.nice-map-chart {
|
|
712
730
|
font-family: system-ui, -apple-system, sans-serif;
|
|
713
731
|
background: var(--nice-bg-primary, #ffffff);
|
|
@@ -807,382 +825,172 @@ const ze = [], Ie = [], De = [], ye = [
|
|
|
807
825
|
]
|
|
808
826
|
}
|
|
809
827
|
);
|
|
810
|
-
},
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
onLinkClick: ne,
|
|
821
|
-
title: K,
|
|
822
|
-
className: F,
|
|
823
|
-
style: j,
|
|
824
|
-
testId: ae,
|
|
825
|
-
"data-testid": X,
|
|
826
|
-
...G
|
|
827
|
-
}) => {
|
|
828
|
-
const [q, Z] = ee(null), T = oe(null), S = ie(() => {
|
|
829
|
-
const x = /* @__PURE__ */ new Map();
|
|
830
|
-
E.forEach((t) => x.set(t.id, t));
|
|
831
|
-
const h = new Set(A.map((t) => t.target)), g = new Set(A.map((t) => t.source)), z = [], d = /* @__PURE__ */ new Map(), _ = E.filter((t) => g.has(t.id) && !h.has(t.id));
|
|
832
|
-
_.length > 0 && (z.push(_.map((t) => t.id)), _.forEach((t) => d.set(t.id, 0)));
|
|
833
|
-
const P = E.filter((t) => g.has(t.id) && h.has(t.id));
|
|
834
|
-
P.length > 0 && (z.push(P.map((t) => t.id)), P.forEach((t) => d.set(t.id, 1)));
|
|
835
|
-
const l = E.filter((t) => !g.has(t.id) && h.has(t.id));
|
|
836
|
-
l.length > 0 && (z.push(l.map((t) => t.id)), l.forEach((t) => d.set(t.id, 2))), z.length === 0 && (z.push(E.map((t) => t.id)), E.forEach((t) => d.set(t.id, 0)));
|
|
837
|
-
const r = /* @__PURE__ */ new Map();
|
|
838
|
-
A.forEach((t) => {
|
|
839
|
-
r.set(t.source, (r.get(t.source) || 0) + t.value), r.set(t.target, (r.get(t.target) || 0) + t.value);
|
|
840
|
-
});
|
|
841
|
-
const v = 40, u = $ - v * 2, C = b - v * 2, w = z.length > 1 ? u / (z.length - 1) : u, o = /* @__PURE__ */ new Map();
|
|
842
|
-
Math.max(...Array.from(r.values())), z.forEach((t, M) => {
|
|
843
|
-
const N = t.reduce((V, D) => V + (r.get(D) || 0), 0), J = (C - (t.length - 1) * Y) / N;
|
|
844
|
-
let y = v;
|
|
845
|
-
t.forEach((V) => {
|
|
846
|
-
const e = (r.get(V) || 0) * J, n = v + M * w;
|
|
847
|
-
o.set(V, { x: n, y, height: e }), y += e + Y;
|
|
848
|
-
});
|
|
849
|
-
});
|
|
850
|
-
const I = [], L = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new Map();
|
|
851
|
-
return A.forEach((t) => {
|
|
852
|
-
const M = o.get(t.source), N = o.get(t.target);
|
|
853
|
-
if (!M || !N)
|
|
854
|
-
return;
|
|
855
|
-
const J = r.get(t.source) || 1;
|
|
856
|
-
r.get(t.target);
|
|
857
|
-
const y = t.value / J * M.height, V = M.y + (L.get(t.source) || 0), D = N.y + (R.get(t.target) || 0);
|
|
858
|
-
L.set(t.source, (L.get(t.source) || 0) + y), R.set(t.target, (R.get(t.target) || 0) + y);
|
|
859
|
-
const e = M.x + H, n = N.x, i = (n - e) * 0.5, c = `
|
|
860
|
-
M ${e} ${V}
|
|
861
|
-
C ${e + i} ${V},
|
|
862
|
-
${n - i} ${D},
|
|
863
|
-
${n} ${D}
|
|
864
|
-
L ${n} ${D + y}
|
|
865
|
-
C ${n - i} ${D + y},
|
|
866
|
-
${e + i} ${V + y},
|
|
867
|
-
${e} ${V + y}
|
|
868
|
-
Z
|
|
869
|
-
`;
|
|
870
|
-
I.push({
|
|
871
|
-
path: c,
|
|
872
|
-
link: t,
|
|
873
|
-
sourcePos: M,
|
|
874
|
-
targetPos: N
|
|
875
|
-
});
|
|
876
|
-
}), { nodePositions: o, linkPaths: I, nodeMap: x, nodeValues: r };
|
|
877
|
-
}, [E, A, $, b, H, Y]), Q = W(
|
|
878
|
-
(x, h) => {
|
|
879
|
-
const g = T.current?.getBoundingClientRect();
|
|
880
|
-
g && k && Z({
|
|
881
|
-
x: h.clientX - g.left,
|
|
882
|
-
y: h.clientY - g.top,
|
|
883
|
-
content: x
|
|
884
|
-
});
|
|
885
|
-
},
|
|
886
|
-
[k]
|
|
887
|
-
);
|
|
888
|
-
return /* @__PURE__ */ m(
|
|
889
|
-
"div",
|
|
890
|
-
{
|
|
891
|
-
className: `nice-sankey-chart ${F || ""}`,
|
|
892
|
-
style: { width: $, ...j },
|
|
893
|
-
"data-testid": X ?? ae,
|
|
894
|
-
...G,
|
|
895
|
-
children: [
|
|
896
|
-
K && /* @__PURE__ */ a("div", { className: "nice-sankey-title", children: K }),
|
|
897
|
-
/* @__PURE__ */ m("svg", { ref: T, width: $, height: b, className: "nice-sankey-svg", children: [
|
|
898
|
-
/* @__PURE__ */ a("defs", { children: S.linkPaths.map((x, h) => /* @__PURE__ */ m("linearGradient", { id: `sankey-gradient-${h}`, x1: "0%", y1: "0%", x2: "100%", y2: "0%", children: [
|
|
899
|
-
/* @__PURE__ */ a(
|
|
900
|
-
"stop",
|
|
901
|
-
{
|
|
902
|
-
offset: "0%",
|
|
903
|
-
stopColor: S.nodeMap.get(x.link.source)?.color || "var(--nice-color-primary, #3b82f6)"
|
|
904
|
-
}
|
|
905
|
-
),
|
|
906
|
-
/* @__PURE__ */ a(
|
|
907
|
-
"stop",
|
|
908
|
-
{
|
|
909
|
-
offset: "100%",
|
|
910
|
-
stopColor: S.nodeMap.get(x.link.target)?.color || "var(--nice-color-error, #ef4444)"
|
|
911
|
-
}
|
|
912
|
-
)
|
|
913
|
-
] }, h)) }),
|
|
914
|
-
/* @__PURE__ */ a("g", { className: "nice-sankey-links", children: S.linkPaths.map((x, h) => /* @__PURE__ */ a(
|
|
915
|
-
"path",
|
|
916
|
-
{
|
|
917
|
-
d: x.path,
|
|
918
|
-
fill: x.link.color || `url(#sankey-gradient-${h})`,
|
|
919
|
-
fillOpacity: 0.4,
|
|
920
|
-
className: "nice-sankey-link",
|
|
921
|
-
onClick: () => ne?.(x.link),
|
|
922
|
-
onMouseEnter: (g) => Q(
|
|
923
|
-
`${S.nodeMap.get(x.link.source)?.name} → ${S.nodeMap.get(x.link.target)?.name}: ${x.link.value.toLocaleString()}`,
|
|
924
|
-
g
|
|
925
|
-
),
|
|
926
|
-
onMouseLeave: () => Z(null)
|
|
927
|
-
},
|
|
928
|
-
h
|
|
929
|
-
)) }),
|
|
930
|
-
/* @__PURE__ */ a("g", { className: "nice-sankey-nodes", children: Array.from(S.nodePositions.entries()).map(([x, h]) => {
|
|
931
|
-
const g = S.nodeMap.get(x);
|
|
932
|
-
return g ? /* @__PURE__ */ m("g", { children: [
|
|
933
|
-
/* @__PURE__ */ a(
|
|
934
|
-
"rect",
|
|
935
|
-
{
|
|
936
|
-
x: h.x,
|
|
937
|
-
y: h.y,
|
|
938
|
-
width: H,
|
|
939
|
-
height: h.height,
|
|
940
|
-
fill: g.color || "var(--nice-color-primary, #3b82f6)",
|
|
941
|
-
rx: 2,
|
|
942
|
-
className: "nice-sankey-node",
|
|
943
|
-
onClick: () => O?.(g),
|
|
944
|
-
onMouseEnter: (z) => Q(
|
|
945
|
-
`${g.label ?? g.name ?? g.id}: ${S.nodeValues.get(x)?.toLocaleString() || 0}`,
|
|
946
|
-
z
|
|
947
|
-
),
|
|
948
|
-
onMouseLeave: () => Z(null)
|
|
949
|
-
}
|
|
950
|
-
),
|
|
951
|
-
/* @__PURE__ */ m(
|
|
952
|
-
"text",
|
|
953
|
-
{
|
|
954
|
-
x: h.x + H + 6,
|
|
955
|
-
y: h.y + h.height / 2,
|
|
956
|
-
dominantBaseline: "middle",
|
|
957
|
-
fontSize: "12",
|
|
958
|
-
fill: "var(--nice-text-primary, #0f172a)",
|
|
959
|
-
children: [
|
|
960
|
-
g.label ?? g.name ?? g.id,
|
|
961
|
-
te && ` (${S.nodeValues.get(x)?.toLocaleString() || 0})`
|
|
962
|
-
]
|
|
963
|
-
}
|
|
964
|
-
)
|
|
965
|
-
] }, x) : null;
|
|
966
|
-
}) })
|
|
967
|
-
] }),
|
|
968
|
-
q && /* @__PURE__ */ a("div", { className: "nice-sankey-tooltip", style: { left: q.x + 10, top: q.y - 30 }, children: q.content }),
|
|
969
|
-
/* @__PURE__ */ a("style", { children: `
|
|
970
|
-
.nice-sankey-chart {
|
|
971
|
-
font-family: system-ui, -apple-system, sans-serif;
|
|
972
|
-
background: var(--nice-bg-primary, #ffffff);
|
|
973
|
-
border-radius: var(--nice-radius-lg, 8px);
|
|
974
|
-
position: relative;
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
.nice-sankey-title {
|
|
978
|
-
padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
|
|
979
|
-
font-size: 16px;
|
|
980
|
-
font-weight: 600;
|
|
981
|
-
color: var(--nice-text-primary, #0f172a);
|
|
982
|
-
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
.nice-sankey-link {
|
|
986
|
-
cursor: pointer;
|
|
987
|
-
transition: fill-opacity 0.2s;
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
.nice-sankey-link:hover {
|
|
991
|
-
fill-opacity: 0.7;
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
.nice-sankey-node {
|
|
995
|
-
cursor: pointer;
|
|
996
|
-
transition: opacity 0.2s;
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
.nice-sankey-node:hover {
|
|
1000
|
-
opacity: 0.8;
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
.nice-sankey-tooltip {
|
|
1004
|
-
position: absolute;
|
|
1005
|
-
/* audit-allow: token-role — inverted chip like .nice-tooltip: the text colour is the
|
|
1006
|
-
fill and the label uses --nice-text-inverse, so the pair flips together. */
|
|
1007
|
-
background: var(--nice-text-primary, #0f172a);
|
|
1008
|
-
color: var(--nice-text-inverse, #ffffff);
|
|
1009
|
-
padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
|
|
1010
|
-
border-radius: var(--nice-radius-sm, 4px);
|
|
1011
|
-
font-size: 12px;
|
|
1012
|
-
pointer-events: none;
|
|
1013
|
-
z-index: 10;
|
|
1014
|
-
white-space: nowrap;
|
|
1015
|
-
}
|
|
1016
|
-
` })
|
|
1017
|
-
]
|
|
1018
|
-
}
|
|
1019
|
-
);
|
|
1020
|
-
}, Oe = /* @__PURE__ */ Object.assign(
|
|
1021
|
-
/* @__PURE__ */ ve((E, A) => {
|
|
1022
|
-
const { t: $ } = ce(), {
|
|
1023
|
-
initialData: b,
|
|
1024
|
-
data: H,
|
|
1025
|
-
maxPoints: Y = 60,
|
|
1026
|
-
updateInterval: te = 1e3,
|
|
1027
|
-
fetchData: k,
|
|
1028
|
-
width: O = 600,
|
|
1029
|
-
height: ne = 200,
|
|
828
|
+
}, Fe = /* @__PURE__ */ Object.assign(
|
|
829
|
+
/* @__PURE__ */ ye((A, Y) => {
|
|
830
|
+
const { t: S } = ue(), {
|
|
831
|
+
initialData: x,
|
|
832
|
+
data: Q,
|
|
833
|
+
maxPoints: B = 60,
|
|
834
|
+
updateInterval: ee = 1e3,
|
|
835
|
+
fetchData: w,
|
|
836
|
+
width: D = 600,
|
|
837
|
+
height: re = 200,
|
|
1030
838
|
chartType: K = "line",
|
|
1031
|
-
color:
|
|
839
|
+
color: E = "var(--nice-color-primary, #3b82f6)",
|
|
1032
840
|
showGrid: j = !0,
|
|
1033
|
-
showTimeAxis:
|
|
1034
|
-
showCurrentValue:
|
|
1035
|
-
title:
|
|
1036
|
-
valueFormatter:
|
|
1037
|
-
timeFormatter:
|
|
841
|
+
showTimeAxis: ie = !0,
|
|
842
|
+
showCurrentValue: P = !0,
|
|
843
|
+
title: _,
|
|
844
|
+
valueFormatter: ce = (i) => i.toFixed(2),
|
|
845
|
+
timeFormatter: V = (i) => new Date(i).toLocaleTimeString(),
|
|
1038
846
|
onDataUpdate: T,
|
|
1039
|
-
paused:
|
|
1040
|
-
className:
|
|
1041
|
-
style:
|
|
1042
|
-
testId:
|
|
1043
|
-
"data-testid":
|
|
1044
|
-
...
|
|
1045
|
-
} =
|
|
847
|
+
paused: H,
|
|
848
|
+
className: te,
|
|
849
|
+
style: ne,
|
|
850
|
+
testId: F,
|
|
851
|
+
"data-testid": le,
|
|
852
|
+
...ae
|
|
853
|
+
} = A, [d, Z] = J(x ?? Q ?? []), [k, z] = J(H || !1), r = he(void 0);
|
|
1046
854
|
fe(() => {
|
|
1047
|
-
|
|
1048
|
-
}, [
|
|
1049
|
-
if (
|
|
855
|
+
H !== void 0 && z(H);
|
|
856
|
+
}, [H]), fe(() => {
|
|
857
|
+
if (k || !w)
|
|
1050
858
|
return;
|
|
1051
|
-
const
|
|
859
|
+
const i = async () => {
|
|
1052
860
|
try {
|
|
1053
|
-
const
|
|
1054
|
-
|
|
1055
|
-
const
|
|
1056
|
-
return T?.(
|
|
861
|
+
const N = await w();
|
|
862
|
+
Z((I) => {
|
|
863
|
+
const p = [...I, N].slice(-B);
|
|
864
|
+
return T?.(p), p;
|
|
1057
865
|
});
|
|
1058
|
-
} catch (
|
|
1059
|
-
console.error("Failed to fetch realtime data:",
|
|
866
|
+
} catch (N) {
|
|
867
|
+
console.error("Failed to fetch realtime data:", N);
|
|
1060
868
|
}
|
|
1061
869
|
};
|
|
1062
|
-
return r.current = setInterval(
|
|
870
|
+
return r.current = setInterval(i, ee), () => {
|
|
1063
871
|
r.current && clearInterval(r.current);
|
|
1064
872
|
};
|
|
1065
|
-
}, [
|
|
1066
|
-
const
|
|
1067
|
-
(
|
|
1068
|
-
|
|
1069
|
-
const
|
|
1070
|
-
return T?.(
|
|
873
|
+
}, [k, w, ee, B, T]);
|
|
874
|
+
const m = R(
|
|
875
|
+
(i) => {
|
|
876
|
+
Z((N) => {
|
|
877
|
+
const I = [...N, i].slice(-B);
|
|
878
|
+
return T?.(I), I;
|
|
1071
879
|
});
|
|
1072
880
|
},
|
|
1073
|
-
[
|
|
1074
|
-
),
|
|
1075
|
-
|
|
1076
|
-
}, [T]),
|
|
1077
|
-
|
|
1078
|
-
|
|
881
|
+
[B, T]
|
|
882
|
+
), h = R(() => {
|
|
883
|
+
Z([]), T?.([]);
|
|
884
|
+
}, [T]), $ = R(() => z(!0), []), b = R(() => z(!1), []);
|
|
885
|
+
we(
|
|
886
|
+
Y,
|
|
1079
887
|
() => ({
|
|
1080
|
-
addDataPoint:
|
|
1081
|
-
clearData:
|
|
1082
|
-
pause:
|
|
1083
|
-
resume:
|
|
888
|
+
addDataPoint: m,
|
|
889
|
+
clearData: h,
|
|
890
|
+
pause: $,
|
|
891
|
+
resume: b,
|
|
1084
892
|
getData: () => d
|
|
1085
893
|
}),
|
|
1086
|
-
[
|
|
894
|
+
[m, h, $, b, d]
|
|
1087
895
|
);
|
|
1088
|
-
const
|
|
1089
|
-
const
|
|
1090
|
-
return
|
|
1091
|
-
},
|
|
1092
|
-
return /* @__PURE__ */
|
|
896
|
+
const l = { top: 20, right: 60, bottom: ie ? 40 : 20, left: 50 }, y = D - l.left - l.right, C = re - l.top - l.bottom, f = d.map((i) => i.value), O = f.length ? Math.min(...f) : 0, g = f.length ? Math.max(...f) : 100, W = (g - O || 1) * 0.1, X = O - W, q = g + W - X, e = (i) => {
|
|
897
|
+
const N = w ? B - 1 : Math.max(1, d.length - 1);
|
|
898
|
+
return l.left + i / N * y;
|
|
899
|
+
}, a = (i) => l.top + C - (i - X) / q * C, o = d.map((i, N) => `${e(N)},${a(i.value)}`).join(" "), s = d.length > 0 ? `M ${e(0)},${l.top + C} L ${o} L ${e(d.length - 1)},${l.top + C} Z` : "", c = d.length > 0 ? d[d.length - 1].value : null;
|
|
900
|
+
return /* @__PURE__ */ u(
|
|
1093
901
|
"div",
|
|
1094
902
|
{
|
|
1095
|
-
className: `nice-realtime-chart ${
|
|
1096
|
-
style: { width:
|
|
1097
|
-
"data-testid":
|
|
1098
|
-
...
|
|
903
|
+
className: `nice-realtime-chart ${te || ""}`,
|
|
904
|
+
style: { width: D, ...ne },
|
|
905
|
+
"data-testid": le ?? F,
|
|
906
|
+
...ae,
|
|
1099
907
|
children: [
|
|
1100
|
-
/* @__PURE__ */
|
|
1101
|
-
/* @__PURE__ */
|
|
1102
|
-
/* @__PURE__ */
|
|
1103
|
-
/* @__PURE__ */
|
|
1104
|
-
/* @__PURE__ */
|
|
1105
|
-
/* @__PURE__ */
|
|
908
|
+
/* @__PURE__ */ u("div", { className: "nice-realtime-header", children: [
|
|
909
|
+
/* @__PURE__ */ t("span", { className: "nice-realtime-title", children: _ }),
|
|
910
|
+
/* @__PURE__ */ u("div", { className: "nice-realtime-controls", children: [
|
|
911
|
+
/* @__PURE__ */ u("span", { className: `nice-realtime-status ${k ? "paused" : "live"}`, children: [
|
|
912
|
+
/* @__PURE__ */ t("span", { className: "nice-realtime-status-dot" }),
|
|
913
|
+
/* @__PURE__ */ t("span", { children: k ? S("charts.paused", "Paused") : S("charts.live", "Live") })
|
|
1106
914
|
] }),
|
|
1107
|
-
/* @__PURE__ */
|
|
915
|
+
/* @__PURE__ */ t(
|
|
1108
916
|
"button",
|
|
1109
917
|
{
|
|
1110
|
-
className: `nice-realtime-btn ${
|
|
1111
|
-
onClick: () =>
|
|
1112
|
-
"aria-label":
|
|
1113
|
-
children: /* @__PURE__ */
|
|
918
|
+
className: `nice-realtime-btn ${k ? "paused" : ""}`,
|
|
919
|
+
onClick: () => z(!k),
|
|
920
|
+
"aria-label": k ? S("charts.resume", "Resume") : S("charts.pause", "Pause"),
|
|
921
|
+
children: /* @__PURE__ */ t(ge, { name: k ? "play" : "pause", size: 14 })
|
|
1114
922
|
}
|
|
1115
923
|
),
|
|
1116
|
-
|
|
924
|
+
P && c !== null && /* @__PURE__ */ t("span", { className: "nice-realtime-value", children: ce(c) })
|
|
1117
925
|
] })
|
|
1118
926
|
] }),
|
|
1119
|
-
/* @__PURE__ */
|
|
1120
|
-
j && /* @__PURE__ */
|
|
1121
|
-
const
|
|
1122
|
-
return /* @__PURE__ */
|
|
1123
|
-
/* @__PURE__ */
|
|
927
|
+
/* @__PURE__ */ u("svg", { width: D, height: re, className: "nice-realtime-svg", children: [
|
|
928
|
+
j && /* @__PURE__ */ t("g", { className: "nice-realtime-grid", children: [0, 0.25, 0.5, 0.75, 1].map((i, N) => {
|
|
929
|
+
const I = l.top + C * (1 - i), p = X + q * i;
|
|
930
|
+
return /* @__PURE__ */ u("g", { children: [
|
|
931
|
+
/* @__PURE__ */ t(
|
|
1124
932
|
"line",
|
|
1125
933
|
{
|
|
1126
|
-
x1:
|
|
1127
|
-
y1:
|
|
1128
|
-
x2:
|
|
1129
|
-
y2:
|
|
934
|
+
x1: l.left,
|
|
935
|
+
y1: I,
|
|
936
|
+
x2: D - l.right,
|
|
937
|
+
y2: I,
|
|
1130
938
|
stroke: "var(--nice-border-color, #e5e7eb)",
|
|
1131
|
-
strokeDasharray:
|
|
939
|
+
strokeDasharray: i === 0 ? void 0 : "3"
|
|
1132
940
|
}
|
|
1133
941
|
),
|
|
1134
|
-
/* @__PURE__ */
|
|
942
|
+
/* @__PURE__ */ t(
|
|
1135
943
|
"text",
|
|
1136
944
|
{
|
|
1137
|
-
x:
|
|
1138
|
-
y:
|
|
945
|
+
x: l.left - 8,
|
|
946
|
+
y: I,
|
|
1139
947
|
textAnchor: "end",
|
|
1140
948
|
dominantBaseline: "middle",
|
|
1141
949
|
fontSize: "10",
|
|
1142
950
|
fill: "var(--nice-text-secondary, #6b7280)",
|
|
1143
|
-
children: Math.round(
|
|
951
|
+
children: Math.round(p).toLocaleString()
|
|
1144
952
|
}
|
|
1145
953
|
)
|
|
1146
|
-
] },
|
|
954
|
+
] }, N);
|
|
1147
955
|
}) }),
|
|
1148
|
-
K === "area" && d.length > 0 && /* @__PURE__ */
|
|
1149
|
-
d.length > 1 && /* @__PURE__ */
|
|
956
|
+
K === "area" && d.length > 0 && /* @__PURE__ */ t("path", { d: s, fill: E, fillOpacity: 0.2 }),
|
|
957
|
+
d.length > 1 && /* @__PURE__ */ t(
|
|
1150
958
|
"polyline",
|
|
1151
959
|
{
|
|
1152
|
-
points:
|
|
960
|
+
points: o,
|
|
1153
961
|
fill: "none",
|
|
1154
|
-
stroke:
|
|
962
|
+
stroke: E,
|
|
1155
963
|
strokeWidth: 2,
|
|
1156
964
|
strokeLinecap: "round",
|
|
1157
965
|
strokeLinejoin: "round"
|
|
1158
966
|
}
|
|
1159
967
|
),
|
|
1160
|
-
d.length > 0 && /* @__PURE__ */
|
|
968
|
+
d.length > 0 && /* @__PURE__ */ t(
|
|
1161
969
|
"circle",
|
|
1162
970
|
{
|
|
1163
971
|
cx: e(d.length - 1),
|
|
1164
|
-
cy:
|
|
972
|
+
cy: a(d[d.length - 1].value),
|
|
1165
973
|
r: 3,
|
|
1166
|
-
fill:
|
|
974
|
+
fill: E,
|
|
1167
975
|
className: "nice-realtime-point"
|
|
1168
976
|
}
|
|
1169
977
|
),
|
|
1170
|
-
|
|
1171
|
-
new Set([0, Math.floor(d.length / 2), d.length - 1].filter((
|
|
1172
|
-
).map((
|
|
978
|
+
ie && d.length > 0 && /* @__PURE__ */ t("g", { className: "nice-realtime-time-axis", children: Array.from(
|
|
979
|
+
new Set([0, Math.floor(d.length / 2), d.length - 1].filter((i) => d[i]))
|
|
980
|
+
).map((i) => /* @__PURE__ */ t(
|
|
1173
981
|
"text",
|
|
1174
982
|
{
|
|
1175
|
-
x: e(
|
|
1176
|
-
y:
|
|
983
|
+
x: e(i),
|
|
984
|
+
y: re - 8,
|
|
1177
985
|
textAnchor: "middle",
|
|
1178
986
|
fontSize: "10",
|
|
1179
987
|
fill: "var(--nice-text-secondary, #6b7280)",
|
|
1180
|
-
children:
|
|
988
|
+
children: V(d[i].timestamp)
|
|
1181
989
|
},
|
|
1182
|
-
`tx-${
|
|
990
|
+
`tx-${i}`
|
|
1183
991
|
)) })
|
|
1184
992
|
] }),
|
|
1185
|
-
/* @__PURE__ */
|
|
993
|
+
/* @__PURE__ */ t("style", { children: `
|
|
1186
994
|
.nice-realtime-chart {
|
|
1187
995
|
font-family: inherit;
|
|
1188
996
|
color: var(--nice-text-primary, #111827);
|
|
@@ -1224,7 +1032,7 @@ const ze = [], Ie = [], De = [], ye = [
|
|
|
1224
1032
|
.nice-realtime-value {
|
|
1225
1033
|
font-size: 18px;
|
|
1226
1034
|
font-weight: 600;
|
|
1227
|
-
color: ${
|
|
1035
|
+
color: ${E};
|
|
1228
1036
|
font-variant-numeric: tabular-nums;
|
|
1229
1037
|
}
|
|
1230
1038
|
|
|
@@ -1267,178 +1075,184 @@ const ze = [], Ie = [], De = [], ye = [
|
|
|
1267
1075
|
);
|
|
1268
1076
|
}),
|
|
1269
1077
|
{ displayName: "NiceRealtimeChart" }
|
|
1270
|
-
),
|
|
1271
|
-
data:
|
|
1272
|
-
width:
|
|
1273
|
-
height:
|
|
1274
|
-
showLabels:
|
|
1275
|
-
showValues:
|
|
1276
|
-
onNodeClick:
|
|
1277
|
-
drilldownEnabled:
|
|
1278
|
-
colors:
|
|
1279
|
-
tilePadding:
|
|
1280
|
-
className:
|
|
1078
|
+
), _e = ({
|
|
1079
|
+
data: A,
|
|
1080
|
+
width: Y = 600,
|
|
1081
|
+
height: S = 400,
|
|
1082
|
+
showLabels: x = !0,
|
|
1083
|
+
showValues: Q = !0,
|
|
1084
|
+
onNodeClick: B,
|
|
1085
|
+
drilldownEnabled: ee = !0,
|
|
1086
|
+
colors: w = Ie,
|
|
1087
|
+
tilePadding: D = 2,
|
|
1088
|
+
className: re,
|
|
1281
1089
|
style: K,
|
|
1282
|
-
testId:
|
|
1090
|
+
testId: E,
|
|
1283
1091
|
"data-testid": j,
|
|
1284
|
-
...
|
|
1092
|
+
...ie
|
|
1285
1093
|
}) => {
|
|
1286
|
-
const { t:
|
|
1094
|
+
const { t: P } = ue(), _ = de(() => Array.isArray(A) ? {
|
|
1287
1095
|
id: "root",
|
|
1288
1096
|
name: "Root",
|
|
1289
|
-
value:
|
|
1290
|
-
children:
|
|
1291
|
-
id: `${
|
|
1292
|
-
name:
|
|
1293
|
-
value:
|
|
1294
|
-
color:
|
|
1097
|
+
value: A.reduce((r, m) => r + (m.value || 0), 0),
|
|
1098
|
+
children: A.map((r, m) => ({
|
|
1099
|
+
id: `${m}`,
|
|
1100
|
+
name: r.label ?? r.name ?? `Item ${m + 1}`,
|
|
1101
|
+
value: r.value,
|
|
1102
|
+
color: r.color
|
|
1295
1103
|
}))
|
|
1296
|
-
} :
|
|
1297
|
-
|
|
1298
|
-
|
|
1104
|
+
} : A, [A]), [ce, V] = J([_.id]);
|
|
1105
|
+
fe(() => V([_.id]), [_]);
|
|
1106
|
+
const T = de(() => {
|
|
1107
|
+
const r = [_];
|
|
1108
|
+
for (const m of ce.slice(1)) {
|
|
1109
|
+
const h = r[r.length - 1].children?.find(($) => $.id === m);
|
|
1110
|
+
if (!h)
|
|
1111
|
+
break;
|
|
1112
|
+
r.push(h);
|
|
1113
|
+
}
|
|
1114
|
+
return r;
|
|
1115
|
+
}, [_, ce]), H = T[T.length - 1], te = T.map((r) => r.name), [ne, F] = J(null), le = he(null), ae = de(() => {
|
|
1116
|
+
const m = H.children || [];
|
|
1117
|
+
if (m.length === 0)
|
|
1299
1118
|
return [];
|
|
1300
|
-
const
|
|
1301
|
-
node:
|
|
1302
|
-
area:
|
|
1119
|
+
const h = m.reduce((g, L) => g + L.value, 0), $ = m.map((g) => ({
|
|
1120
|
+
node: g,
|
|
1121
|
+
area: g.value / h * Y * S
|
|
1303
1122
|
}));
|
|
1304
|
-
|
|
1305
|
-
const
|
|
1306
|
-
let
|
|
1307
|
-
for (;
|
|
1308
|
-
const
|
|
1309
|
-
let
|
|
1310
|
-
const
|
|
1311
|
-
for (let
|
|
1312
|
-
const
|
|
1313
|
-
if (
|
|
1314
|
-
|
|
1123
|
+
$.sort((g, L) => L.area - g.area);
|
|
1124
|
+
const b = [];
|
|
1125
|
+
let l = 0, y = 0, C = Y, f = S, O = 0;
|
|
1126
|
+
for (; O < $.length; ) {
|
|
1127
|
+
const g = C < f;
|
|
1128
|
+
let L = 0, W = [];
|
|
1129
|
+
const X = g ? f : C;
|
|
1130
|
+
for (let e = O; e < $.length; e++) {
|
|
1131
|
+
const a = [...W, $[e]], o = a.reduce((c, i) => c + i.area, 0), s = d(a, o, X);
|
|
1132
|
+
if (W.length === 0)
|
|
1133
|
+
W = a, L = o;
|
|
1315
1134
|
else {
|
|
1316
|
-
const c =
|
|
1317
|
-
if (
|
|
1318
|
-
|
|
1135
|
+
const c = d(W, L, X);
|
|
1136
|
+
if (s <= c)
|
|
1137
|
+
W = a, L = o;
|
|
1319
1138
|
else
|
|
1320
1139
|
break;
|
|
1321
1140
|
}
|
|
1322
1141
|
}
|
|
1323
|
-
const
|
|
1324
|
-
let
|
|
1325
|
-
|
|
1326
|
-
const
|
|
1327
|
-
|
|
1328
|
-
node:
|
|
1329
|
-
x:
|
|
1330
|
-
y:
|
|
1331
|
-
w:
|
|
1332
|
-
h:
|
|
1333
|
-
color:
|
|
1334
|
-
}),
|
|
1335
|
-
}),
|
|
1142
|
+
const U = L / X;
|
|
1143
|
+
let q = 0;
|
|
1144
|
+
W.forEach((e) => {
|
|
1145
|
+
const a = e.area / U;
|
|
1146
|
+
b.push({
|
|
1147
|
+
node: e.node,
|
|
1148
|
+
x: g ? l : l + q,
|
|
1149
|
+
y: g ? y + q : y,
|
|
1150
|
+
w: g ? U : a,
|
|
1151
|
+
h: g ? a : U,
|
|
1152
|
+
color: e.node.color || w[m.indexOf(e.node) % w.length]
|
|
1153
|
+
}), q += a;
|
|
1154
|
+
}), g ? (l += U, C -= U) : (y += U, f -= U), O += W.length;
|
|
1336
1155
|
}
|
|
1337
|
-
return
|
|
1338
|
-
}, [
|
|
1339
|
-
function
|
|
1340
|
-
const
|
|
1341
|
-
let
|
|
1342
|
-
for (const
|
|
1343
|
-
const
|
|
1344
|
-
|
|
1156
|
+
return b;
|
|
1157
|
+
}, [H, Y, S, w]);
|
|
1158
|
+
function d(r, m, h) {
|
|
1159
|
+
const $ = m / h;
|
|
1160
|
+
let b = 0;
|
|
1161
|
+
for (const l of r) {
|
|
1162
|
+
const y = l.area / $, C = Math.max($ / y, y / $);
|
|
1163
|
+
b = Math.max(b, C);
|
|
1345
1164
|
}
|
|
1346
|
-
return
|
|
1165
|
+
return b;
|
|
1347
1166
|
}
|
|
1348
|
-
const
|
|
1349
|
-
|
|
1350
|
-
},
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
}
|
|
1359
|
-
Z(l), S(r);
|
|
1360
|
-
}, P = (l, r) => {
|
|
1361
|
-
const v = h.current?.getBoundingClientRect();
|
|
1362
|
-
v && x({
|
|
1363
|
-
x: r.clientX - v.left,
|
|
1364
|
-
y: r.clientY - v.top,
|
|
1365
|
-
content: l
|
|
1167
|
+
const Z = (r) => {
|
|
1168
|
+
B?.(r, [...te, r.name]), ee && r.children && r.children.length > 0 && V((m) => [...m, r.id]);
|
|
1169
|
+
}, k = () => {
|
|
1170
|
+
V((r) => r.length > 1 ? r.slice(0, -1) : r);
|
|
1171
|
+
}, z = (r, m) => {
|
|
1172
|
+
const h = le.current?.getBoundingClientRect();
|
|
1173
|
+
h && F({
|
|
1174
|
+
x: m.clientX - h.left,
|
|
1175
|
+
y: m.clientY - h.top,
|
|
1176
|
+
content: r
|
|
1366
1177
|
});
|
|
1367
1178
|
};
|
|
1368
|
-
return /* @__PURE__ */
|
|
1179
|
+
return /* @__PURE__ */ u(
|
|
1369
1180
|
"div",
|
|
1370
1181
|
{
|
|
1371
|
-
className: `nice-treemap-chart ${
|
|
1372
|
-
style: { width:
|
|
1373
|
-
"data-testid": j ??
|
|
1374
|
-
...
|
|
1182
|
+
className: `nice-treemap-chart ${re || ""}`,
|
|
1183
|
+
style: { width: Y, ...K },
|
|
1184
|
+
"data-testid": j ?? E,
|
|
1185
|
+
...ie,
|
|
1375
1186
|
children: [
|
|
1376
|
-
/* @__PURE__ */
|
|
1377
|
-
|
|
1378
|
-
/* @__PURE__ */
|
|
1187
|
+
/* @__PURE__ */ u("div", { className: "nice-treemap-nav", children: [
|
|
1188
|
+
te.length > 1 && /* @__PURE__ */ u("button", { className: "nice-treemap-back", onClick: k, children: [
|
|
1189
|
+
/* @__PURE__ */ t(ge, { name: "arrow-left", size: 14 }),
|
|
1379
1190
|
" ",
|
|
1380
|
-
|
|
1191
|
+
P("charts.back", "Back")
|
|
1381
1192
|
] }),
|
|
1382
|
-
/* @__PURE__ */
|
|
1383
|
-
|
|
1384
|
-
/* @__PURE__ */
|
|
1385
|
-
] },
|
|
1193
|
+
/* @__PURE__ */ t("div", { className: "nice-treemap-breadcrumbs", children: te.map((r, m) => /* @__PURE__ */ u(be.Fragment, { children: [
|
|
1194
|
+
m > 0 && /* @__PURE__ */ t("span", { className: "nice-treemap-sep", children: "/" }),
|
|
1195
|
+
/* @__PURE__ */ t("span", { className: m === te.length - 1 ? "current" : "", children: r })
|
|
1196
|
+
] }, m)) })
|
|
1386
1197
|
] }),
|
|
1387
|
-
/* @__PURE__ */
|
|
1388
|
-
const { node:
|
|
1389
|
-
return /* @__PURE__ */
|
|
1198
|
+
/* @__PURE__ */ t("svg", { ref: le, width: Y, height: S, className: "nice-treemap-svg", children: ae.map((r, m) => {
|
|
1199
|
+
const { node: h, x: $, y: b, w: l, h: y, color: C } = r, f = Math.min(18, Math.max(11, Math.min(l, y) / 5)), O = l > 40 && y > 30;
|
|
1200
|
+
return /* @__PURE__ */ u(
|
|
1390
1201
|
"g",
|
|
1391
1202
|
{
|
|
1392
|
-
onClick: () =>
|
|
1393
|
-
onMouseEnter: (
|
|
1394
|
-
onMouseLeave: () =>
|
|
1203
|
+
onClick: () => Z(h),
|
|
1204
|
+
onMouseEnter: (g) => z(`${h.name}: ${h.value.toLocaleString()}`, g),
|
|
1205
|
+
onMouseLeave: () => F(null),
|
|
1395
1206
|
children: [
|
|
1396
|
-
/* @__PURE__ */
|
|
1207
|
+
/* @__PURE__ */ t(
|
|
1397
1208
|
"rect",
|
|
1398
1209
|
{
|
|
1399
|
-
x:
|
|
1400
|
-
y:
|
|
1401
|
-
width: Math.max(0,
|
|
1402
|
-
height: Math.max(0,
|
|
1403
|
-
fill:
|
|
1404
|
-
rx: 4,
|
|
1210
|
+
x: $ + D / 2,
|
|
1211
|
+
y: b + D / 2,
|
|
1212
|
+
width: Math.max(0, l - D),
|
|
1213
|
+
height: Math.max(0, y - D),
|
|
1214
|
+
fill: C,
|
|
1405
1215
|
className: "nice-treemap-tile"
|
|
1406
1216
|
}
|
|
1407
1217
|
),
|
|
1408
|
-
|
|
1218
|
+
x && O && /* @__PURE__ */ t(
|
|
1409
1219
|
"text",
|
|
1410
1220
|
{
|
|
1411
|
-
x:
|
|
1412
|
-
y:
|
|
1221
|
+
x: $ + l / 2,
|
|
1222
|
+
y: b + y / 2 - (Q ? f * 0.5 : 0),
|
|
1413
1223
|
textAnchor: "middle",
|
|
1414
1224
|
dominantBaseline: "middle",
|
|
1415
|
-
fontSize:
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
children: v.name.length > w / L + 2 ? v.name.slice(0, Math.floor(w / L)) + "..." : v.name
|
|
1225
|
+
fontSize: f,
|
|
1226
|
+
className: "nice-piechart__label",
|
|
1227
|
+
style: { pointerEvents: "none", fontSize: f, fontWeight: 600 },
|
|
1228
|
+
children: h.name.length > l / f + 2 ? h.name.slice(0, Math.floor(l / f)) + "..." : h.name
|
|
1420
1229
|
}
|
|
1421
1230
|
),
|
|
1422
|
-
|
|
1231
|
+
Q && O && /* @__PURE__ */ t(
|
|
1423
1232
|
"text",
|
|
1424
1233
|
{
|
|
1425
|
-
x:
|
|
1426
|
-
y:
|
|
1234
|
+
x: $ + l / 2,
|
|
1235
|
+
y: b + y / 2 + f * 0.75,
|
|
1427
1236
|
textAnchor: "middle",
|
|
1428
1237
|
dominantBaseline: "middle",
|
|
1429
|
-
fontSize:
|
|
1430
|
-
|
|
1431
|
-
style: {
|
|
1432
|
-
|
|
1238
|
+
fontSize: f - 2,
|
|
1239
|
+
className: "nice-piechart__label",
|
|
1240
|
+
style: {
|
|
1241
|
+
pointerEvents: "none",
|
|
1242
|
+
fontSize: f - 2,
|
|
1243
|
+
fontWeight: 500,
|
|
1244
|
+
opacity: 0.9
|
|
1245
|
+
},
|
|
1246
|
+
children: h.value.toLocaleString()
|
|
1433
1247
|
}
|
|
1434
1248
|
)
|
|
1435
1249
|
]
|
|
1436
1250
|
},
|
|
1437
|
-
|
|
1251
|
+
m
|
|
1438
1252
|
);
|
|
1439
1253
|
}) }),
|
|
1440
|
-
|
|
1441
|
-
/* @__PURE__ */
|
|
1254
|
+
ne && /* @__PURE__ */ t("div", { className: "nice-treemap-tooltip", style: { left: ne.x + 10, top: ne.y - 30 }, children: ne.content }),
|
|
1255
|
+
/* @__PURE__ */ t("style", { children: `
|
|
1442
1256
|
.nice-treemap-chart {
|
|
1443
1257
|
font-family: system-ui, -apple-system, sans-serif;
|
|
1444
1258
|
background: var(--nice-bg-primary, #ffffff);
|
|
@@ -1514,8 +1328,7 @@ const ze = [], Ie = [], De = [], ye = [
|
|
|
1514
1328
|
};
|
|
1515
1329
|
export {
|
|
1516
1330
|
Te as NiceDrillDownChart,
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
Xe as NiceTreeMapChart
|
|
1331
|
+
Ee as NiceMapChart,
|
|
1332
|
+
Fe as NiceRealtimeChart,
|
|
1333
|
+
_e as NiceTreeMap
|
|
1521
1334
|
};
|