p1-charts 0.2.0 → 0.3.0
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 +28 -0
- package/README.md +100 -2
- package/dist/CategoryBarChart-1Kn3Vozc.js +580 -0
- package/dist/CategoryBarChart-1Kn3Vozc.js.map +1 -0
- package/dist/ChartFrame-B1bVFM2E.js +403 -0
- package/dist/ChartFrame-B1bVFM2E.js.map +1 -0
- package/dist/{Heatmap-C1XcTUg1.js → Heatmap-CFC753mV.js} +278 -272
- package/dist/Heatmap-CFC753mV.js.map +1 -0
- package/dist/{PieLegend-BZsv9IbF.js → PieLegend-CbpjaOJH.js} +94 -111
- package/dist/PieLegend-CbpjaOJH.js.map +1 -0
- package/dist/PolarChart-hcNTWKfJ.js +450 -0
- package/dist/PolarChart-hcNTWKfJ.js.map +1 -0
- package/dist/Sparkline-BApLVWfg.js +110 -0
- package/dist/Sparkline-BApLVWfg.js.map +1 -0
- package/dist/{TimeSeriesChart-BIwJxgnD.js → TimeSeriesChart-BzeHEtQl.js} +120 -119
- package/dist/{TimeSeriesChart-BIwJxgnD.js.map → TimeSeriesChart-BzeHEtQl.js.map} +1 -1
- package/dist/category.d.ts +1 -1
- package/dist/category.d.ts.map +1 -1
- package/dist/category.js +1 -1
- package/dist/charts/CategoryBarChart/index.d.ts +1 -1
- package/dist/charts/CategoryBarChart/index.d.ts.map +1 -1
- package/dist/charts/Heatmap/index.d.ts.map +1 -1
- package/dist/charts/PolarChart/index.d.ts.map +1 -1
- package/dist/charts/ScatterChart/index.d.ts +1 -1
- package/dist/charts/ScatterChart/index.d.ts.map +1 -1
- package/dist/charts/Sparkline/index.d.ts +5 -2
- package/dist/charts/Sparkline/index.d.ts.map +1 -1
- package/dist/components/ChartFrame/index.d.ts +7 -0
- package/dist/components/ChartFrame/index.d.ts.map +1 -0
- package/dist/components/ChartStory/index.d.ts +7 -0
- package/dist/components/ChartStory/index.d.ts.map +1 -0
- package/dist/components/HeatmapCells/index.d.ts +1 -1
- package/dist/components/HeatmapCells/index.d.ts.map +1 -1
- package/dist/{css-C-rsk7-l.js → css-BtFQ2bM4.js} +2 -2
- package/dist/{css-C-rsk7-l.js.map → css-BtFQ2bM4.js.map} +1 -1
- package/dist/heatmap.js +1 -1
- package/dist/hooks/useMarkMemory.d.ts +9 -0
- package/dist/hooks/useMarkMemory.d.ts.map +1 -0
- package/dist/hooks/usePieTween.d.ts.map +1 -1
- package/dist/hooks/useSteps.d.ts +4 -0
- package/dist/hooks/useSteps.d.ts.map +1 -0
- package/dist/hooks/useTween.d.ts +12 -0
- package/dist/hooks/useTween.d.ts.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +122 -118
- package/dist/index.js.map +1 -1
- package/dist/motion.utils-DFoqptDi.js +55 -0
- package/dist/motion.utils-DFoqptDi.js.map +1 -0
- package/dist/pie.js +1 -1
- package/dist/scatter.js +1 -1
- package/dist/series.js +1 -1
- package/dist/{tooltip.utils-D7xaBSUK.js → shared-C1pGJV4T.js} +3 -7
- package/dist/shared-C1pGJV4T.js.map +1 -0
- package/dist/sparkline.d.ts +1 -1
- package/dist/sparkline.d.ts.map +1 -1
- package/dist/sparkline.js +2 -2
- package/dist/story.d.ts +11 -0
- package/dist/story.d.ts.map +1 -0
- package/dist/story.js +7 -0
- package/dist/theme.js +3 -3
- package/dist/{theme.utils-CP1XtGIe.js → theme.utils-DgmWROoe.js} +40 -20
- package/dist/theme.utils-DgmWROoe.js.map +1 -0
- package/dist/tooltip.utils-CXD_NapA.js +9 -0
- package/dist/tooltip.utils-CXD_NapA.js.map +1 -0
- package/dist/types/category.d.ts +10 -0
- package/dist/types/category.d.ts.map +1 -1
- package/dist/types/heatmap.d.ts +3 -0
- package/dist/types/heatmap.d.ts.map +1 -1
- package/dist/types/heatmapParts.d.ts +2 -0
- package/dist/types/heatmapParts.d.ts.map +1 -1
- package/dist/types/motion.d.ts +31 -0
- package/dist/types/motion.d.ts.map +1 -0
- package/dist/types/pie.d.ts +3 -4
- package/dist/types/pie.d.ts.map +1 -1
- package/dist/types/polar.d.ts +3 -0
- package/dist/types/polar.d.ts.map +1 -1
- package/dist/types/scatter.d.ts +3 -0
- package/dist/types/scatter.d.ts.map +1 -1
- package/dist/types/sparkline.d.ts +3 -0
- package/dist/types/sparkline.d.ts.map +1 -1
- package/dist/types/story.d.ts +73 -0
- package/dist/types/story.d.ts.map +1 -0
- package/dist/{useChartTheme-B06p_jvu.js → useChartTheme-KKtc1C4K.js} +2 -2
- package/dist/{useChartTheme-B06p_jvu.js.map → useChartTheme-KKtc1C4K.js.map} +1 -1
- package/dist/useControllable-Crsr0byh.js +11 -0
- package/dist/useControllable-Crsr0byh.js.map +1 -0
- package/dist/useMarkMemory-CLNY6TtT.js +15 -0
- package/dist/useMarkMemory-CLNY6TtT.js.map +1 -0
- package/dist/useTween-B0G0CcvM.js +46 -0
- package/dist/useTween-B0G0CcvM.js.map +1 -0
- package/dist/utils/category.utils.d.ts +2 -0
- package/dist/utils/category.utils.d.ts.map +1 -1
- package/dist/utils/color.utils.d.ts +9 -0
- package/dist/utils/color.utils.d.ts.map +1 -1
- package/dist/utils/csv.utils.d.ts +6 -0
- package/dist/utils/csv.utils.d.ts.map +1 -0
- package/dist/utils/motion.utils.d.ts +25 -0
- package/dist/utils/motion.utils.d.ts.map +1 -1
- package/dist/utils/pieTween.utils.d.ts +1 -1
- package/dist/utils/pieTween.utils.d.ts.map +1 -1
- package/dist/utils/sparkline.utils.d.ts +15 -0
- package/dist/utils/sparkline.utils.d.ts.map +1 -1
- package/dist/{visibility.utils-nMI5a_Et.js → visibility.utils-wuc3ZS8D.js} +18 -25
- package/dist/visibility.utils-wuc3ZS8D.js.map +1 -0
- package/package.json +10 -3
- package/src/category.ts +1 -0
- package/src/charts/CategoryBarChart/index.tsx +203 -44
- package/src/charts/Heatmap/index.tsx +4 -0
- package/src/charts/PolarChart/index.tsx +98 -5
- package/src/charts/ScatterChart/index.tsx +96 -13
- package/src/charts/Sparkline/index.tsx +54 -7
- package/src/components/ChartFrame/index.tsx +180 -0
- package/src/components/ChartStory/index.tsx +184 -0
- package/src/components/HeatmapCells/index.tsx +5 -2
- package/src/hooks/useMarkMemory.ts +29 -0
- package/src/hooks/usePieTween.ts +9 -44
- package/src/hooks/useSteps.ts +77 -0
- package/src/hooks/useTween.ts +112 -0
- package/src/index.ts +19 -0
- package/src/sparkline.ts +1 -1
- package/src/story.ts +19 -0
- package/src/types/category.ts +11 -0
- package/src/types/heatmap.ts +3 -0
- package/src/types/heatmapParts.ts +2 -0
- package/src/types/motion.ts +35 -0
- package/src/types/pie.ts +3 -3
- package/src/types/polar.ts +3 -0
- package/src/types/scatter.ts +3 -0
- package/src/types/sparkline.ts +3 -0
- package/src/types/story.ts +103 -0
- package/src/utils/category.utils.ts +22 -0
- package/src/utils/color.utils.ts +48 -0
- package/src/utils/csv.utils.ts +28 -0
- package/src/utils/motion.utils.ts +124 -0
- package/src/utils/pieTween.utils.ts +1 -2
- package/src/utils/sparkline.utils.ts +69 -0
- package/dist/CategoryBarChart-YEJ9VB8h.js +0 -453
- package/dist/CategoryBarChart-YEJ9VB8h.js.map +0 -1
- package/dist/Heatmap-C1XcTUg1.js.map +0 -1
- package/dist/PieLegend-BZsv9IbF.js.map +0 -1
- package/dist/PolarChart-BUEhn3CI.js +0 -334
- package/dist/PolarChart-BUEhn3CI.js.map +0 -1
- package/dist/Sparkline-DtNhxGVo.js +0 -67
- package/dist/Sparkline-DtNhxGVo.js.map +0 -1
- package/dist/motion.utils-C1eaZJdQ.js +0 -9
- package/dist/motion.utils-C1eaZJdQ.js.map +0 -1
- package/dist/theme.utils-CP1XtGIe.js.map +0 -1
- package/dist/tooltip.utils-D7xaBSUK.js.map +0 -1
- package/dist/visibility.utils-nMI5a_Et.js.map +0 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { c as e } from "./theme.utils-
|
|
3
|
-
import {
|
|
4
|
-
import { n as
|
|
5
|
-
import { n as
|
|
6
|
-
import { t as
|
|
7
|
-
import { t as
|
|
2
|
+
import { c as e } from "./theme.utils-DgmWROoe.js";
|
|
3
|
+
import { i as t, t as n } from "./visibility.utils-wuc3ZS8D.js";
|
|
4
|
+
import { n as r, t as i } from "./shared-C1pGJV4T.js";
|
|
5
|
+
import { n as a, t as o } from "./dom.utils-CKMWLto-.js";
|
|
6
|
+
import { t as s } from "./useChartTheme-KKtc1C4K.js";
|
|
7
|
+
import { t as c } from "./useControllable-Crsr0byh.js";
|
|
8
|
+
import { t as l } from "./tooltip.utils-CXD_NapA.js";
|
|
9
|
+
import { t as u } from "./useTween-B0G0CcvM.js";
|
|
8
10
|
import { forwardRef as d, useEffect as f, useImperativeHandle as p, useLayoutEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
|
|
9
11
|
import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
|
|
10
12
|
//#region src/utils/pie.utils.ts
|
|
@@ -138,9 +140,9 @@ var te = {
|
|
|
138
140
|
ArrowLeft: -1,
|
|
139
141
|
ArrowUp: -1
|
|
140
142
|
}, R = [], z = (e, t) => e === "none" ? R : e === "single" ? t.slice(-1) : t;
|
|
141
|
-
function B({ slices: e, activeKey: t, onActiveChange:
|
|
142
|
-
let x = g(null), [S, C] =
|
|
143
|
-
M !==
|
|
143
|
+
function B({ slices: e, activeKey: t, onActiveChange: r, selectionMode: i = "none", selectedKeys: o, defaultSelectedKeys: s = R, onSelectionChange: l, hiddenKeys: u, defaultHiddenKeys: d = R, onHiddenChange: f, drillOther: p = !1, onDrill: m, onSliceClick: v, onSliceHover: y, onSliceLeave: b }) {
|
|
144
|
+
let x = g(null), [S, C] = c(t, null), [w, T] = c(o, s), [E, D] = c(u, d), [O, k] = _(null), [A, j] = _(null), [M, N] = _(i), P = L(e, p, x), F = h(() => z(i, w), [i, w]);
|
|
145
|
+
M !== i && (N(i), o === void 0 && T(z(M, w)));
|
|
144
146
|
let I = h(() => ee(P.slices, E).map((e) => ({
|
|
145
147
|
...e,
|
|
146
148
|
selected: !e.hidden && F.includes(e.key)
|
|
@@ -149,7 +151,7 @@ function B({ slices: e, activeKey: t, onActiveChange: i, selectionMode: a = "non
|
|
|
149
151
|
E,
|
|
150
152
|
F
|
|
151
153
|
]), B = I.filter((e) => !e.hidden), V = B.find((e) => e.key === S) ?? null, H = B.find((e) => e.key === O) ?? null, U = B.filter((e) => e.selected), W = (V ?? B[0])?.index ?? 0, G = (e, t) => {
|
|
152
|
-
j(t), (e?.key ?? null) !== S && (C(e?.key ?? null),
|
|
154
|
+
j(t), (e?.key ?? null) !== S && (C(e?.key ?? null), r?.(e, t));
|
|
153
155
|
}, K = (e) => {
|
|
154
156
|
let t = e.flatMap((e) => I.filter((t) => t.key === e).map((e) => ({
|
|
155
157
|
...e,
|
|
@@ -159,13 +161,13 @@ function B({ slices: e, activeKey: t, onActiveChange: i, selectionMode: a = "non
|
|
|
159
161
|
}, q = (e) => {
|
|
160
162
|
P.setDrilled(e), m?.(e ? P.top : null), G(null, "api"), F.length > 0 && K([]), E.length > 0 && (D(R), f?.(R));
|
|
161
163
|
}, J = (e) => {
|
|
162
|
-
p && e.other ? q(!0) :
|
|
163
|
-
},
|
|
164
|
-
let
|
|
164
|
+
p && e.other ? q(!0) : i !== "none" && K(e.selected ? F.filter((t) => t !== e.key) : i === "single" ? [e.key] : [...F, e.key]), v?.(e);
|
|
165
|
+
}, Y = (e, t = !1) => {
|
|
166
|
+
let r = I.map((e) => e.key), i = n(r, E, e, t), a = F.filter((e) => !i.includes(e));
|
|
165
167
|
i !== E && (D(i), f?.(i), a.length < F.length && K(a), V && i.includes(V.key) && G(null, "legend"));
|
|
166
|
-
}, Y = (e, t) => {
|
|
167
|
-
e.hidden || (G(e, t), y?.(e));
|
|
168
168
|
}, X = (e, t) => {
|
|
169
|
+
e.hidden || (G(e, t), y?.(e));
|
|
170
|
+
}, Z = (e, t) => {
|
|
169
171
|
e.key === S && G(null, t), b?.(e);
|
|
170
172
|
};
|
|
171
173
|
return {
|
|
@@ -180,13 +182,13 @@ function B({ slices: e, activeKey: t, onActiveChange: i, selectionMode: a = "non
|
|
|
180
182
|
stop: W,
|
|
181
183
|
handlers: {
|
|
182
184
|
click: J,
|
|
183
|
-
enter:
|
|
184
|
-
leave:
|
|
185
|
+
enter: X,
|
|
186
|
+
leave: Z,
|
|
185
187
|
focus: (e, t) => {
|
|
186
|
-
k(
|
|
188
|
+
k(a(t) ? e.key : null), X(e, "keyboard");
|
|
187
189
|
},
|
|
188
190
|
blur: (e) => {
|
|
189
|
-
k(null),
|
|
191
|
+
k(null), Z(e, "keyboard");
|
|
190
192
|
},
|
|
191
193
|
keyDown: (e, t) => {
|
|
192
194
|
let n = Math.max(0, B.findIndex((e) => e.index === t)), r = e.key === "Home" ? -n : e.key === "End" ? B.length - 1 - n : te[e.key];
|
|
@@ -199,20 +201,14 @@ function B({ slices: e, activeKey: t, onActiveChange: i, selectionMode: a = "non
|
|
|
199
201
|
x.current?.querySelectorAll("[data-part=\"slice\"]")[i?.index ?? t]?.focus();
|
|
200
202
|
}
|
|
201
203
|
},
|
|
202
|
-
hide:
|
|
204
|
+
hide: Y
|
|
203
205
|
}
|
|
204
206
|
};
|
|
205
207
|
}
|
|
206
208
|
//#endregion
|
|
207
209
|
//#region src/utils/pieTween.utils.ts
|
|
208
|
-
var V = (e) =>
|
|
209
|
-
function
|
|
210
|
-
return Object.fromEntries(Object.entries(t).map(([t, [r, i]]) => {
|
|
211
|
-
let [a, o] = e[t] ?? [r, r];
|
|
212
|
-
return [t, [a + (r - a) * n, o + (i - o) * n]];
|
|
213
|
-
}));
|
|
214
|
-
}
|
|
215
|
-
function G(e, t) {
|
|
210
|
+
var V = (e) => Object.fromEntries(e.map((e) => [e.key, [e.startAngle, e.endAngle]]));
|
|
211
|
+
function H(e, t) {
|
|
216
212
|
return e.map((e) => {
|
|
217
213
|
let [n, r] = t[e.key] ?? [e.startAngle, e.endAngle];
|
|
218
214
|
return {
|
|
@@ -225,44 +221,31 @@ function G(e, t) {
|
|
|
225
221
|
}
|
|
226
222
|
//#endregion
|
|
227
223
|
//#region src/hooks/usePieTween.ts
|
|
228
|
-
var
|
|
229
|
-
function
|
|
230
|
-
let
|
|
231
|
-
return
|
|
232
|
-
|
|
233
|
-
if (U(e, i)) return;
|
|
234
|
-
if (t === !1 || n <= 0 || u()) {
|
|
235
|
-
a.current = i, s(null);
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
let o = performance.now(), c = 0, l = () => {
|
|
239
|
-
let t = Math.min(1, (performance.now() - o) / n), u = W(e, i, r(t));
|
|
240
|
-
a.current = u, s(t < 1 ? u : null), t < 1 && (c = requestAnimationFrame(l));
|
|
241
|
-
};
|
|
242
|
-
return s(W(e, i, 0)), c = requestAnimationFrame(l), () => cancelAnimationFrame(c);
|
|
243
|
-
}, [
|
|
244
|
-
i,
|
|
245
|
-
t,
|
|
224
|
+
var U = (e, [t]) => [t, t];
|
|
225
|
+
function W(e, t = !0) {
|
|
226
|
+
let n = h(() => V(e), [e]), r = u(n, t, { enter: U });
|
|
227
|
+
return h(() => r === n ? e : H(e, r), [
|
|
228
|
+
r,
|
|
246
229
|
n,
|
|
247
|
-
|
|
248
|
-
])
|
|
230
|
+
e
|
|
231
|
+
]);
|
|
249
232
|
}
|
|
250
233
|
//#endregion
|
|
251
234
|
//#region src/utils/pieRails.utils.ts
|
|
252
|
-
var
|
|
253
|
-
function
|
|
254
|
-
let t = e?.pie.selection, n = Math.min(Math.max(t?.offset ??
|
|
235
|
+
var G = 6, K = 20, q = 2, J = 4, Y = 3;
|
|
236
|
+
function X(e) {
|
|
237
|
+
let t = e?.pie.selection, n = Math.min(Math.max(t?.offset ?? G, 0), K), r = n + (t?.width ?? q) / 2 + J;
|
|
255
238
|
return {
|
|
256
239
|
selection: n,
|
|
257
240
|
focus: r,
|
|
258
|
-
room: r +
|
|
241
|
+
room: r + Y
|
|
259
242
|
};
|
|
260
243
|
}
|
|
261
244
|
//#endregion
|
|
262
245
|
//#region src/hooks/usePieChart.ts
|
|
263
|
-
var Z = 100,
|
|
264
|
-
function
|
|
265
|
-
let { data: n, innerRadius: r, gap: i, maxSlices: a, otherLabel: o, labelSpacing:
|
|
246
|
+
var Z = 100, ne = 16, re = 130, ie = new Intl.NumberFormat(), ae = (e) => Math.min(Math.max(e, 0), .95);
|
|
247
|
+
function oe(e, t) {
|
|
248
|
+
let { data: n, innerRadius: r, gap: i, maxSlices: a, otherLabel: o, labelSpacing: c, renderLabel: l, emphasis: u = "dim", selectionMode: d = "none", formatValue: f = ie.format, describeSlice: m, animate: _ } = e, v = g(null), y = s(e), b = y?.pie, x = Z * ae(r ?? b?.innerRadius ?? 0), S = y ? i ?? b?.gap ?? 0 : 0, C = h(() => A(n, {
|
|
266
249
|
maxSlices: a ?? b?.maxSlices,
|
|
267
250
|
otherLabel: o ?? b?.otherLabel
|
|
268
251
|
}), [
|
|
@@ -275,13 +258,13 @@ function le(e, t) {
|
|
|
275
258
|
...e,
|
|
276
259
|
slices: C,
|
|
277
260
|
selectionMode: d
|
|
278
|
-
}), { svgRef: E, slices: D, active: k, selected: j, handlers: M } = w, N =
|
|
261
|
+
}), { svgRef: E, slices: D, active: k, selected: j, handlers: M } = w, N = W(D, _), P = h(() => I(N.filter((e) => !e.hidden), {
|
|
279
262
|
radius: Z,
|
|
280
|
-
offset:
|
|
281
|
-
spacing:
|
|
263
|
+
offset: ne,
|
|
264
|
+
spacing: c ?? b?.labelSpacing ?? 32
|
|
282
265
|
}), [
|
|
283
266
|
N,
|
|
284
|
-
|
|
267
|
+
c,
|
|
285
268
|
b?.labelSpacing
|
|
286
269
|
]);
|
|
287
270
|
p(t, () => ({
|
|
@@ -304,7 +287,7 @@ function le(e, t) {
|
|
|
304
287
|
isolate: () => M.hide(e.key, !0),
|
|
305
288
|
enter: () => M.enter(e, "legend"),
|
|
306
289
|
leave: () => M.leave(e, "legend")
|
|
307
|
-
})), R =
|
|
290
|
+
})), R = l === null || !F, z = R ? X(y).room : re, [V, H] = [Z + z, Z + (R ? z : 28)];
|
|
308
291
|
return {
|
|
309
292
|
...w,
|
|
310
293
|
theme: y,
|
|
@@ -334,24 +317,24 @@ function le(e, t) {
|
|
|
334
317
|
}
|
|
335
318
|
//#endregion
|
|
336
319
|
//#region src/styles/pieChart.ts
|
|
337
|
-
var
|
|
320
|
+
var se = { position: "relative" }, ce = {
|
|
338
321
|
display: "block",
|
|
339
322
|
width: "100%",
|
|
340
323
|
height: "auto",
|
|
341
324
|
overflow: "visible"
|
|
342
|
-
},
|
|
325
|
+
}, le = {
|
|
343
326
|
cursor: "pointer",
|
|
344
327
|
strokeLinejoin: "round",
|
|
345
328
|
touchAction: "manipulation"
|
|
346
|
-
},
|
|
329
|
+
}, ue = {
|
|
347
330
|
fill: "none",
|
|
348
331
|
pointerEvents: "none"
|
|
349
|
-
},
|
|
332
|
+
}, de = { cursor: "pointer" }, Q = {
|
|
350
333
|
x: -4,
|
|
351
334
|
y: -18,
|
|
352
335
|
width: 120,
|
|
353
336
|
height: 36
|
|
354
|
-
},
|
|
337
|
+
}, fe = {
|
|
355
338
|
fill: "none",
|
|
356
339
|
stroke: "currentColor",
|
|
357
340
|
strokeWidth: 1,
|
|
@@ -363,8 +346,8 @@ var ue = { position: "relative" }, de = {
|
|
|
363
346
|
};
|
|
364
347
|
//#endregion
|
|
365
348
|
//#region src/components/PieRails/index.tsx
|
|
366
|
-
function
|
|
367
|
-
let o = r?.pie.selection, s =
|
|
349
|
+
function pe({ selected: e, focused: t, radius: n, theme: r, classNames: i, styles: a }) {
|
|
350
|
+
let o = r?.pie.selection, s = X(r), c = r && {
|
|
368
351
|
stroke: o?.color ?? r.palette.text,
|
|
369
352
|
strokeWidth: o?.width ?? 2
|
|
370
353
|
}, l = r && {
|
|
@@ -379,7 +362,7 @@ function ge({ selected: e, focused: t, radius: n, theme: r, classNames: i, style
|
|
|
379
362
|
d: N(e.startAngle, e.endAngle, n + s.selection),
|
|
380
363
|
className: i?.selection,
|
|
381
364
|
style: {
|
|
382
|
-
...
|
|
365
|
+
...ue,
|
|
383
366
|
...c,
|
|
384
367
|
...a?.selection
|
|
385
368
|
}
|
|
@@ -388,7 +371,7 @@ function ge({ selected: e, focused: t, radius: n, theme: r, classNames: i, style
|
|
|
388
371
|
d: N(t.startAngle, t.endAngle, n + s.focus),
|
|
389
372
|
className: i?.focus,
|
|
390
373
|
style: {
|
|
391
|
-
...
|
|
374
|
+
...ue,
|
|
392
375
|
...l,
|
|
393
376
|
...a?.focus
|
|
394
377
|
}
|
|
@@ -397,8 +380,8 @@ function ge({ selected: e, focused: t, radius: n, theme: r, classNames: i, style
|
|
|
397
380
|
}
|
|
398
381
|
//#endregion
|
|
399
382
|
//#region src/components/PieCenter/index.tsx
|
|
400
|
-
var
|
|
401
|
-
function
|
|
383
|
+
var me = 1.6, he = .6, ge = 16;
|
|
384
|
+
function _e({ summary: e, inner: t, unit: n, theme: r, formatValue: i, render: a, className: o, style: s }) {
|
|
402
385
|
if (a === null) return null;
|
|
403
386
|
let c = e.slices.length === 0;
|
|
404
387
|
if (!a && t <= 0 && !c) return null;
|
|
@@ -408,7 +391,7 @@ function be({ summary: e, inner: t, unit: n, theme: r, formatValue: i, render: a
|
|
|
408
391
|
}, u = {
|
|
409
392
|
...$,
|
|
410
393
|
...D(r?.pie.centerUnit ?? r?.typography.label)
|
|
411
|
-
}, d = e.active ? [e.active] : e.selected, f = (e) => d.reduce((t, n) => t + n[e], 0), p = Number(u.fontSize ??
|
|
394
|
+
}, d = e.active ? [e.active] : e.selected, f = (e) => d.reduce((t, n) => t + n[e], 0), p = Number(u.fontSize ?? ge), m = (e) => E(e, Math.max(1, Math.floor(t * me / (p * he)))), h = d.length ? [T(f("share")), d.length === 1 ? d[0].label : `${d.length} selected`] : n ? [n] : [];
|
|
412
395
|
return /* @__PURE__ */ y("g", {
|
|
413
396
|
"data-part": "center",
|
|
414
397
|
textAnchor: "middle",
|
|
@@ -432,7 +415,7 @@ function be({ summary: e, inner: t, unit: n, theme: r, formatValue: i, render: a
|
|
|
432
415
|
}
|
|
433
416
|
//#endregion
|
|
434
417
|
//#region src/components/PieLabels/index.tsx
|
|
435
|
-
function
|
|
418
|
+
function ve({ labels: e, theme: t, formatValue: n, dimmed: r, handlers: i, render: a, classNames: o, styles: s }) {
|
|
436
419
|
if (a === null) return null;
|
|
437
420
|
let c = t && {
|
|
438
421
|
stroke: t.pie.leader?.color ?? t.palette.grid,
|
|
@@ -454,7 +437,7 @@ function xe({ labels: e, theme: t, formatValue: n, dimmed: r, handlers: i, rende
|
|
|
454
437
|
points: h.map((e) => e.join(",")).join(" "),
|
|
455
438
|
className: o?.leader,
|
|
456
439
|
style: {
|
|
457
|
-
...
|
|
440
|
+
...fe,
|
|
458
441
|
...c,
|
|
459
442
|
..._,
|
|
460
443
|
...s?.leader
|
|
@@ -466,7 +449,7 @@ function xe({ labels: e, theme: t, formatValue: n, dimmed: r, handlers: i, rende
|
|
|
466
449
|
textAnchor: f > 0 ? "start" : "end",
|
|
467
450
|
className: o?.label,
|
|
468
451
|
style: {
|
|
469
|
-
...
|
|
452
|
+
...de,
|
|
470
453
|
..._,
|
|
471
454
|
...s?.label
|
|
472
455
|
},
|
|
@@ -496,7 +479,7 @@ function xe({ labels: e, theme: t, formatValue: n, dimmed: r, handlers: i, rende
|
|
|
496
479
|
}
|
|
497
480
|
//#endregion
|
|
498
481
|
//#region src/components/PieSlices/index.tsx
|
|
499
|
-
function
|
|
482
|
+
function ye({ slices: e, radius: t, inner: n, theme: r, gap: i, active: a, focused: s, pressable: c, dimmed: l, stop: u, describe: d, handlers: f, classNames: p, styles: m }) {
|
|
500
483
|
let h = r?.pie.dimOpacity;
|
|
501
484
|
return e.map((e, g) => {
|
|
502
485
|
let _ = l(e);
|
|
@@ -508,19 +491,19 @@ function Se({ slices: e, radius: t, inner: n, theme: r, gap: i, active: a, focus
|
|
|
508
491
|
"data-other": e.other || void 0,
|
|
509
492
|
"data-selected": e.selected || void 0,
|
|
510
493
|
"data-hidden": e.hidden || void 0,
|
|
511
|
-
"data-focus-visible":
|
|
494
|
+
"data-focus-visible": s?.key === e.key || void 0,
|
|
512
495
|
role: "button",
|
|
513
496
|
tabIndex: g === u ? 0 : -1,
|
|
514
497
|
"aria-hidden": e.hidden || void 0,
|
|
515
|
-
"aria-pressed":
|
|
498
|
+
"aria-pressed": c(e) ? e.selected : void 0,
|
|
516
499
|
"aria-label": d(e),
|
|
517
500
|
d: P(e.startAngle, e.endAngle, t, n),
|
|
518
501
|
fill: O(e, r),
|
|
519
502
|
stroke: i > 0 ? r?.palette.background : void 0,
|
|
520
503
|
strokeWidth: i > 0 ? i : void 0,
|
|
521
|
-
className:
|
|
504
|
+
className: o(p?.slice, e.className),
|
|
522
505
|
style: {
|
|
523
|
-
...
|
|
506
|
+
...le,
|
|
524
507
|
...r && { outline: "none" },
|
|
525
508
|
..._ && h !== void 0 && { opacity: h },
|
|
526
509
|
...m?.slice
|
|
@@ -536,18 +519,18 @@ function Se({ slices: e, radius: t, inner: n, theme: r, gap: i, active: a, focus
|
|
|
536
519
|
}
|
|
537
520
|
//#endregion
|
|
538
521
|
//#region src/utils/pieTooltip.utils.ts
|
|
539
|
-
function
|
|
522
|
+
function be(e, t, n, r, [i, a, o]) {
|
|
540
523
|
let [s, c] = k(e.midAngle, t), l = o ? n.width / o : 0;
|
|
541
524
|
return [n.left - r.left + (s - i) * l, n.top - r.top + (c - a) * l];
|
|
542
525
|
}
|
|
543
526
|
//#endregion
|
|
544
527
|
//#region src/components/PieTooltip/index.tsx
|
|
545
|
-
var
|
|
528
|
+
var xe = {
|
|
546
529
|
pointer: 16,
|
|
547
530
|
keyboard: 12
|
|
548
531
|
};
|
|
549
|
-
function
|
|
550
|
-
let d = g(null), [p, h] = _(null), v = t === "pointer" || t === "keyboard" ? t : null, b = n.current?.getBoundingClientRect(), x =
|
|
532
|
+
function Se({ active: e, source: t, root: n, svg: i, box: a, radius: o, render: s, className: c, style: u }) {
|
|
533
|
+
let d = g(null), [p, h] = _(null), v = t === "pointer" || t === "keyboard" ? t : null, b = n.current?.getBoundingClientRect(), x = i.current?.getBoundingClientRect(), S = !e || !v ? null : v === "pointer" ? p : b && x ? be(e, o, x, b, a) : null;
|
|
551
534
|
return f(() => {
|
|
552
535
|
let e = n.current, t = (t) => {
|
|
553
536
|
let n = e.getBoundingClientRect();
|
|
@@ -559,19 +542,19 @@ function Te({ active: e, source: t, root: n, svg: r, box: i, radius: s, render:
|
|
|
559
542
|
}, [n]), m(() => {
|
|
560
543
|
let e = d.current, t = e?.parentElement;
|
|
561
544
|
if (!e || !t || !S || !v) return;
|
|
562
|
-
let [n, r] =
|
|
545
|
+
let [n, r] = l(S, xe[v], [e.offsetWidth, e.offsetHeight], [t.clientWidth, t.clientHeight]);
|
|
563
546
|
e.style.transform = `translate(${n}px, ${r}px)`;
|
|
564
547
|
}), !e || !v || !S ? null : /* @__PURE__ */ y("div", {
|
|
565
548
|
ref: d,
|
|
566
549
|
"data-part": "tooltip",
|
|
567
550
|
"data-source": v,
|
|
568
551
|
"aria-hidden": "true",
|
|
569
|
-
className:
|
|
552
|
+
className: c,
|
|
570
553
|
style: {
|
|
571
|
-
...
|
|
554
|
+
...r,
|
|
572
555
|
...u
|
|
573
556
|
},
|
|
574
|
-
children:
|
|
557
|
+
children: s(e, {
|
|
575
558
|
source: v,
|
|
576
559
|
x: S[0],
|
|
577
560
|
y: S[1]
|
|
@@ -580,21 +563,21 @@ function Te({ active: e, source: t, root: n, svg: r, box: i, radius: s, render:
|
|
|
580
563
|
}
|
|
581
564
|
//#endregion
|
|
582
565
|
//#region src/charts/PieChart/index.tsx
|
|
583
|
-
function
|
|
584
|
-
let { unit: n, ariaLabel: r = "Pie chart", className: a, style:
|
|
566
|
+
function Ce(e, t) {
|
|
567
|
+
let { unit: n, ariaLabel: r = "Pie chart", className: a, style: s, classNames: c, styles: l, renderLabel: u, renderCenter: d, renderLegend: f, renderTooltip: p, renderBreadcrumb: m, drillOther: h, selectionMode: g = "none" } = e, _ = oe(e, t), { theme: v, radius: x, total: S, active: C, describe: w, dimmed: T } = _;
|
|
585
568
|
return /* @__PURE__ */ b("div", {
|
|
586
569
|
ref: _.rootRef,
|
|
587
570
|
"data-part": "root",
|
|
588
|
-
className:
|
|
571
|
+
className: o(a, c?.root),
|
|
589
572
|
style: {
|
|
590
|
-
...
|
|
591
|
-
...
|
|
573
|
+
...se,
|
|
574
|
+
...s,
|
|
592
575
|
...l?.root
|
|
593
576
|
},
|
|
594
577
|
children: [
|
|
595
578
|
_.other && m && /* @__PURE__ */ y("div", {
|
|
596
579
|
"data-part": "breadcrumb",
|
|
597
|
-
className:
|
|
580
|
+
className: c?.breadcrumb,
|
|
598
581
|
style: l?.breadcrumb,
|
|
599
582
|
children: m({
|
|
600
583
|
other: _.other,
|
|
@@ -606,9 +589,9 @@ function Ee(e, t) {
|
|
|
606
589
|
role: "group",
|
|
607
590
|
"aria-label": S ? r : `${r}, no data`,
|
|
608
591
|
viewBox: _.box.join(" "),
|
|
609
|
-
style:
|
|
592
|
+
style: ce,
|
|
610
593
|
children: [
|
|
611
|
-
/* @__PURE__ */ y(
|
|
594
|
+
/* @__PURE__ */ y(ye, {
|
|
612
595
|
slices: _.drawn,
|
|
613
596
|
radius: x,
|
|
614
597
|
inner: _.inner,
|
|
@@ -621,28 +604,28 @@ function Ee(e, t) {
|
|
|
621
604
|
stop: _.stop,
|
|
622
605
|
describe: w,
|
|
623
606
|
handlers: _.handlers,
|
|
624
|
-
classNames:
|
|
607
|
+
classNames: c,
|
|
625
608
|
styles: l
|
|
626
609
|
}),
|
|
627
|
-
/* @__PURE__ */ y(
|
|
610
|
+
/* @__PURE__ */ y(pe, {
|
|
628
611
|
selected: _.rails.selected,
|
|
629
612
|
focused: _.rails.focused,
|
|
630
613
|
radius: x,
|
|
631
614
|
theme: v,
|
|
632
|
-
classNames:
|
|
615
|
+
classNames: c,
|
|
633
616
|
styles: l
|
|
634
617
|
}),
|
|
635
|
-
/* @__PURE__ */ y(
|
|
618
|
+
/* @__PURE__ */ y(ve, {
|
|
636
619
|
labels: _.labels,
|
|
637
620
|
theme: v,
|
|
638
621
|
formatValue: _.formatValue,
|
|
639
622
|
dimmed: T,
|
|
640
623
|
handlers: _.handlers,
|
|
641
624
|
render: u,
|
|
642
|
-
classNames:
|
|
625
|
+
classNames: c,
|
|
643
626
|
styles: l
|
|
644
627
|
}),
|
|
645
|
-
/* @__PURE__ */ y(
|
|
628
|
+
/* @__PURE__ */ y(_e, {
|
|
646
629
|
summary: {
|
|
647
630
|
total: S,
|
|
648
631
|
slices: _.slices,
|
|
@@ -654,13 +637,13 @@ function Ee(e, t) {
|
|
|
654
637
|
theme: v,
|
|
655
638
|
formatValue: _.formatValue,
|
|
656
639
|
render: d,
|
|
657
|
-
className:
|
|
640
|
+
className: c?.center,
|
|
658
641
|
style: l?.center
|
|
659
642
|
})
|
|
660
643
|
]
|
|
661
644
|
}),
|
|
662
645
|
f?.(_.legend),
|
|
663
|
-
p && /* @__PURE__ */ y(
|
|
646
|
+
p && /* @__PURE__ */ y(Se, {
|
|
664
647
|
active: C,
|
|
665
648
|
source: _.source,
|
|
666
649
|
root: _.rootRef,
|
|
@@ -668,14 +651,14 @@ function Ee(e, t) {
|
|
|
668
651
|
box: _.box,
|
|
669
652
|
radius: _.centroid,
|
|
670
653
|
render: p,
|
|
671
|
-
className:
|
|
654
|
+
className: c?.tooltip,
|
|
672
655
|
style: l?.tooltip
|
|
673
656
|
}),
|
|
674
657
|
/* @__PURE__ */ y("div", {
|
|
675
658
|
"data-part": "readout",
|
|
676
659
|
"aria-live": "polite",
|
|
677
660
|
"aria-atomic": "true",
|
|
678
|
-
className:
|
|
661
|
+
className: c?.readout,
|
|
679
662
|
style: {
|
|
680
663
|
...i,
|
|
681
664
|
...l?.readout
|
|
@@ -685,11 +668,11 @@ function Ee(e, t) {
|
|
|
685
668
|
]
|
|
686
669
|
});
|
|
687
670
|
}
|
|
688
|
-
var
|
|
689
|
-
function
|
|
671
|
+
var we = d(Ce), Te = new Intl.NumberFormat();
|
|
672
|
+
function Ee({ entries: e, formatValue: t = Te.format, className: n, style: r, classNames: i }) {
|
|
690
673
|
return /* @__PURE__ */ y("ul", {
|
|
691
674
|
"data-part": "legend",
|
|
692
|
-
className:
|
|
675
|
+
className: o(n, i?.legend),
|
|
693
676
|
style: r,
|
|
694
677
|
children: e.map(({ slice: e, color: n, active: r, hidden: a, ...o }) => /* @__PURE__ */ y("li", { children: /* @__PURE__ */ b("button", {
|
|
695
678
|
type: "button",
|
|
@@ -724,6 +707,6 @@ function ke({ entries: e, formatValue: t = Oe.format, className: n, style: r, cl
|
|
|
724
707
|
});
|
|
725
708
|
}
|
|
726
709
|
//#endregion
|
|
727
|
-
export { A as a, P as i,
|
|
710
|
+
export { A as a, P as i, we as n, I as o, B as r, Ee as t };
|
|
728
711
|
|
|
729
|
-
//# sourceMappingURL=PieLegend-
|
|
712
|
+
//# sourceMappingURL=PieLegend-CbpjaOJH.js.map
|