@carto/ps-react-ui 4.25.0 → 4.27.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.
Files changed (91) hide show
  1. package/dist/actions-DON6fSCh.js +1289 -0
  2. package/dist/actions-DON6fSCh.js.map +1 -0
  3. package/dist/category-BoT5FHHp.js +950 -0
  4. package/dist/category-BoT5FHHp.js.map +1 -0
  5. package/dist/item-color-C1cu6EJd.js +20 -0
  6. package/dist/item-color-C1cu6EJd.js.map +1 -0
  7. package/dist/scale-0elCv3tk.js +29 -0
  8. package/dist/scale-0elCv3tk.js.map +1 -0
  9. package/dist/types/widgets-v2/actions/index.d.ts +1 -1
  10. package/dist/types/widgets-v2/actions/relative-data/index.d.ts +1 -0
  11. package/dist/types/widgets-v2/actions/relative-data/labels.d.ts +3 -0
  12. package/dist/types/widgets-v2/actions/relative-data/relative-data.d.ts +16 -2
  13. package/dist/types/widgets-v2/actions/relative-data/scale.d.ts +26 -0
  14. package/dist/types/widgets-v2/actions/relative-data/style.d.ts +12 -0
  15. package/dist/types/widgets-v2/bar/types.d.ts +6 -0
  16. package/dist/types/widgets-v2/category/category.d.ts +2 -1
  17. package/dist/types/widgets-v2/histogram/bins.d.ts +7 -0
  18. package/dist/types/widgets-v2/histogram/download.d.ts +2 -2
  19. package/dist/types/widgets-v2/histogram/index.d.ts +2 -1
  20. package/dist/types/widgets-v2/histogram/options.d.ts +1 -1
  21. package/dist/types/widgets-v2/histogram/transforms.d.ts +5 -4
  22. package/dist/types/widgets-v2/histogram/types.d.ts +22 -5
  23. package/dist/types/widgets-v2/index.d.ts +2 -2
  24. package/dist/types/widgets-v2/pie/types.d.ts +6 -0
  25. package/dist/types/widgets-v2/scatterplot/download.d.ts +2 -2
  26. package/dist/types/widgets-v2/scatterplot/index.d.ts +2 -1
  27. package/dist/types/widgets-v2/scatterplot/points.d.ts +7 -0
  28. package/dist/types/widgets-v2/scatterplot/transforms.d.ts +4 -3
  29. package/dist/types/widgets-v2/scatterplot/types.d.ts +21 -2
  30. package/dist/types/widgets-v2/timeseries/types.d.ts +6 -0
  31. package/dist/types/widgets-v2/utils/item-color.d.ts +26 -0
  32. package/dist/widgets-v2/actions.js +1 -1
  33. package/dist/widgets-v2/bar.js +91 -81
  34. package/dist/widgets-v2/bar.js.map +1 -1
  35. package/dist/widgets-v2/category.js +1 -1
  36. package/dist/widgets-v2/histogram.js +133 -100
  37. package/dist/widgets-v2/histogram.js.map +1 -1
  38. package/dist/widgets-v2/pie.js +98 -78
  39. package/dist/widgets-v2/pie.js.map +1 -1
  40. package/dist/widgets-v2/scatterplot.js +151 -110
  41. package/dist/widgets-v2/scatterplot.js.map +1 -1
  42. package/dist/widgets-v2/timeseries.js +96 -86
  43. package/dist/widgets-v2/timeseries.js.map +1 -1
  44. package/dist/widgets-v2.js +2 -2
  45. package/dist/widgets-v2.js.map +1 -1
  46. package/package.json +1 -1
  47. package/src/widgets-v2/actions/fullscreen/fullscreen-store.test.tsx +77 -13
  48. package/src/widgets-v2/actions/fullscreen/fullscreen.tsx +48 -5
  49. package/src/widgets-v2/actions/index.ts +1 -0
  50. package/src/widgets-v2/actions/relative-data/index.ts +1 -0
  51. package/src/widgets-v2/actions/relative-data/labels.ts +6 -0
  52. package/src/widgets-v2/actions/relative-data/relative-data.test.tsx +78 -1
  53. package/src/widgets-v2/actions/relative-data/relative-data.tsx +137 -20
  54. package/src/widgets-v2/actions/relative-data/scale.ts +48 -0
  55. package/src/widgets-v2/actions/relative-data/style.ts +10 -0
  56. package/src/widgets-v2/bar/options.test.ts +122 -0
  57. package/src/widgets-v2/bar/options.ts +31 -16
  58. package/src/widgets-v2/bar/types.ts +6 -0
  59. package/src/widgets-v2/category/category.relative-data.test.tsx +51 -63
  60. package/src/widgets-v2/category/category.tsx +25 -11
  61. package/src/widgets-v2/histogram/bins.ts +22 -0
  62. package/src/widgets-v2/histogram/download.test.ts +10 -0
  63. package/src/widgets-v2/histogram/download.ts +7 -3
  64. package/src/widgets-v2/histogram/index.ts +3 -0
  65. package/src/widgets-v2/histogram/options.test.ts +62 -0
  66. package/src/widgets-v2/histogram/options.ts +44 -19
  67. package/src/widgets-v2/histogram/transforms.test.ts +21 -7
  68. package/src/widgets-v2/histogram/transforms.ts +26 -12
  69. package/src/widgets-v2/histogram/types.ts +25 -5
  70. package/src/widgets-v2/index.ts +7 -1
  71. package/src/widgets-v2/pie/options.test.ts +91 -0
  72. package/src/widgets-v2/pie/options.ts +50 -20
  73. package/src/widgets-v2/pie/types.ts +6 -0
  74. package/src/widgets-v2/scatterplot/download.test.ts +9 -0
  75. package/src/widgets-v2/scatterplot/download.ts +5 -3
  76. package/src/widgets-v2/scatterplot/index.ts +3 -0
  77. package/src/widgets-v2/scatterplot/options.test.ts +90 -0
  78. package/src/widgets-v2/scatterplot/options.ts +53 -15
  79. package/src/widgets-v2/scatterplot/points.ts +35 -0
  80. package/src/widgets-v2/scatterplot/transforms.test.ts +19 -0
  81. package/src/widgets-v2/scatterplot/transforms.ts +23 -18
  82. package/src/widgets-v2/scatterplot/types.ts +25 -2
  83. package/src/widgets-v2/timeseries/options.test.ts +65 -0
  84. package/src/widgets-v2/timeseries/options.ts +38 -19
  85. package/src/widgets-v2/timeseries/types.ts +6 -0
  86. package/src/widgets-v2/utils/item-color.test.ts +74 -0
  87. package/src/widgets-v2/utils/item-color.ts +55 -0
  88. package/dist/actions-B1ss030_.js +0 -1167
  89. package/dist/actions-B1ss030_.js.map +0 -1
  90. package/dist/category-DuKx_CJX.js +0 -933
  91. package/dist/category-DuKx_CJX.js.map +0 -1
@@ -1,13 +1,14 @@
1
1
  import { n as e, t } from "../download--wRRnf19.js";
2
2
  import { r as n, t as r } from "../utils-ClB6nn4w.js";
3
3
  import { a as i, c as a, d as o, f as s, s as c, u as l } from "../chart-config-BWxjodlt.js";
4
- import { c as u } from "react/compiler-runtime";
5
- import { Box as d, Skeleton as f } from "@mui/material";
6
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
7
- import * as h from "echarts";
4
+ import { t as u } from "../item-color-C1cu6EJd.js";
5
+ import { c as d } from "react/compiler-runtime";
6
+ import { Box as f, Skeleton as p } from "@mui/material";
7
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
8
+ import * as g from "echarts";
8
9
  //#region src/widgets-v2/pie/options.ts
9
- var g = ["58%", "74%"];
10
- function _({ theme: e, formatter: t, labelFormatter: n }) {
10
+ var _ = ["58%", "74%"];
11
+ function v({ theme: e, formatter: t, labelFormatter: n }) {
11
12
  return {
12
13
  legend: {
13
14
  ...c({
@@ -29,7 +30,7 @@ function _({ theme: e, formatter: t, labelFormatter: n }) {
29
30
  fontFamily: e.typography.caption.fontFamily
30
31
  },
31
32
  position: o(e),
32
- formatter: C(t, n)
33
+ formatter: w(t, n)
33
34
  },
34
35
  color: Object.values(e.palette.qualitative?.bold ?? {}),
35
36
  series: [{
@@ -62,11 +63,11 @@ function _({ theme: e, formatter: t, labelFormatter: n }) {
62
63
  }]
63
64
  };
64
65
  }
65
- function v(e) {
66
- let { theme: t, formatter: r, labelFormatter: i, optionsOverride: a, series: o } = e, s = e.radius ?? g, c = e.selection, l = c == null || c.length === 0 ? null : new Set(c);
66
+ function y(e) {
67
+ let { theme: t, formatter: r, labelFormatter: i, optionsOverride: a, series: o } = e, s = e.radius ?? _, c = e.selection, l = c == null || c.length === 0 ? null : new Set(c);
67
68
  return (e, c, u) => {
68
69
  if (e == null) {
69
- let e = _({
70
+ let e = v({
70
71
  theme: t,
71
72
  formatter: r,
72
73
  labelFormatter: i
@@ -78,76 +79,95 @@ function v(e) {
78
79
  ...e,
79
80
  dataset: [],
80
81
  series: []
81
- } : d.length > 1 ? b(e, d, t, o, u, l) : y(e, d, s, o, u, l);
82
+ } : d.length > 1 ? x(e, d, t, o, u, l) : b(e, d, t, s, o, u, l);
82
83
  };
83
84
  }
84
- function y(e, t, n, r, i, a) {
85
- let o = Array.isArray(e.series) ? e.series : [], s = o[0] ?? {}, c = typeof e.tooltip == "object" && !Array.isArray(e.tooltip) ? e.tooltip : {}, l = typeof e.legend == "object" && !Array.isArray(e.legend) ? e.legend : {}, u = i?.formatter, d = i?.labelFormatter, f = Array.isArray(e.color) ? e.color : [], p = (e) => (f.length > 0 ? f[e.dataIndex % f.length] : void 0) ?? e.color, m = (e) => {
86
- let t = p(e);
87
- if (!a) return t;
88
- let n = e.value?.name ?? e.name;
89
- return n != null && a.has(n) ? t : h.color.modifyAlpha(t, .15);
90
- }, g = s.label?.position, _ = g === void 0 || g === "center", v = t[0] ?? [], y, b = -Infinity;
91
- for (let e of v) a && !a.has(e.name) || typeof e.value == "number" && e.value > b && (b = e.value, y = e.name);
92
- let x = (e) => {
85
+ function b(e, t, n, r, i, a, o) {
86
+ let s = Array.isArray(e.series) ? e.series : [], c = s[0] ?? {}, l = typeof e.tooltip == "object" && !Array.isArray(e.tooltip) ? e.tooltip : {}, d = typeof e.legend == "object" && !Array.isArray(e.legend) ? e.legend : {}, f = a?.formatter, p = a?.labelFormatter, m = Array.isArray(e.color) ? e.color : [], h = (e) => (m.length > 0 ? m[e.dataIndex % m.length] : void 0) ?? e.color, _ = (e, t) => {
87
+ let r = u({
88
+ theme: n,
89
+ datums: e,
90
+ template: t,
91
+ fallback: h
92
+ });
93
+ return (e) => {
94
+ let t = r(e);
95
+ if (!o) return t;
96
+ let n = e.value?.name ?? e.name;
97
+ return n != null && o.has(n) ? t : g.color.modifyAlpha(t, .15);
98
+ };
99
+ }, v = c.label?.position, y = v === void 0 || v === "center", b = t[0] ?? [], x, S = -Infinity;
100
+ for (let e of b) o && !o.has(e.name) || typeof e.value == "number" && e.value > S && (S = e.value, x = e.name);
101
+ let C = (e) => {
93
102
  let { name: t } = e;
94
- if (t == null || _ && t !== y) return "";
103
+ if (t == null || y && t !== x) return "";
95
104
  let n = e.encode?.value?.[0];
96
105
  if (n === void 0) return "";
97
- let r = Object.values(e.data ?? {}).at(n), i = typeof r == "number" ? u ? u(r) : String(r) : typeof r == "string" ? r : "", a = String(d ? d(t ?? "") : t ?? "");
98
- return `{c|${i}}${_ ? "\n\n" : "\n"}{b|${a}}`;
106
+ let r = Object.values(e.data ?? {}).at(n), i = typeof r == "number" ? f ? f(r) : String(r) : typeof r == "string" ? r : "", a = String(p ? p(t ?? "") : t ?? "");
107
+ return `{c|${i}}${y ? "\n\n" : "\n"}{b|${a}}`;
99
108
  };
100
109
  return {
101
110
  ...e,
102
111
  dataset: t.map((e) => ({ source: e })),
103
112
  series: t.map((e, t) => {
104
- let i = o[t] ?? s, a = typeof i == "object" ? i : {}, c = a.label ?? {}, l = a.itemStyle ?? {};
113
+ let n = s[t] ?? c, a = typeof n == "object" ? n : {}, o = a.label ?? {}, l = a.itemStyle ?? {};
105
114
  return {
106
115
  ...a,
107
116
  type: "pie",
108
117
  legendHoverLink: !1,
109
118
  datasetIndex: t,
110
- name: r?.[t]?.name ?? `Series ${t + 1}`,
111
- radius: [...n],
119
+ name: i?.[t]?.name ?? `Series ${t + 1}`,
120
+ radius: [...r],
112
121
  center: ["50%", "38%"],
113
122
  encode: {
114
123
  itemName: "name",
115
124
  value: "value"
116
125
  },
117
126
  label: {
118
- ...c,
119
- formatter: x
127
+ ...o,
128
+ formatter: C
120
129
  },
121
130
  itemStyle: {
122
131
  ...l,
123
- color: m
132
+ color: _(e, a)
124
133
  }
125
134
  };
126
135
  }),
127
136
  legend: {
128
- ...l,
137
+ ...d,
129
138
  show: !0,
130
139
  selectedMode: !1,
131
140
  selected: Object.fromEntries((t[0] ?? []).map((e) => [String(e.name), !0]))
132
141
  },
133
142
  tooltip: {
134
- ...c,
135
- formatter: C(u, d)
143
+ ...l,
144
+ formatter: w(f, p)
136
145
  }
137
146
  };
138
147
  }
139
- function b(e, t, n, o, s, c) {
140
- let l = typeof e.tooltip == "object" && !Array.isArray(e.tooltip) ? e.tooltip : {}, u = typeof e.legend == "object" && !Array.isArray(e.legend) ? e.legend : {}, d = typeof e.grid == "object" && !Array.isArray(e.grid) ? e.grid : {}, f = s?.formatter, p = s?.labelFormatter, { niceMinVal: m, niceMaxVal: g } = S(t), _ = Array.isArray(e.color) ? e.color : [], v = (e) => {
141
- let t = e.seriesIndex ?? 0, n = (_.length > 0 ? _[t % _.length] : void 0) ?? e.color;
142
- if (!c) return n;
143
- let r = e.value?.name ?? e.name;
144
- return r != null && c.has(r) ? n : h.color.modifyAlpha(n, .15);
148
+ function x(e, t, n, o, s, c) {
149
+ let l = typeof e.tooltip == "object" && !Array.isArray(e.tooltip) ? e.tooltip : {}, d = typeof e.legend == "object" && !Array.isArray(e.legend) ? e.legend : {}, f = typeof e.grid == "object" && !Array.isArray(e.grid) ? e.grid : {}, p = s?.formatter, m = s?.labelFormatter, { niceMinVal: h, niceMaxVal: _ } = C(t), v = Array.isArray(e.color) ? e.color : [], y = Array.isArray(e.series) ? e.series : [], b = (e) => {
150
+ let t = e.seriesIndex ?? 0;
151
+ return (v.length > 0 ? v[t % v.length] : void 0) ?? e.color;
152
+ }, x = (e, t) => {
153
+ let r = u({
154
+ theme: n,
155
+ datums: e,
156
+ template: t,
157
+ fallback: b
158
+ });
159
+ return (e) => {
160
+ let t = r(e);
161
+ if (!c) return t;
162
+ let n = e.value?.name ?? e.name;
163
+ return n != null && c.has(n) ? t : g.color.modifyAlpha(t, .15);
164
+ };
145
165
  };
146
166
  return {
147
167
  ...e,
148
168
  dataset: t.map((e) => ({ source: e })),
149
169
  grid: {
150
- ...d,
170
+ ...f,
151
171
  ...i(!0, n),
152
172
  right: parseInt(n.spacing(4)),
153
173
  containLabel: !0
@@ -161,15 +181,15 @@ function b(e, t, n, o, s, c) {
161
181
  barMaxWidth: 100,
162
182
  legendHoverLink: !1,
163
183
  emphasis: { focus: "series" },
164
- ...a(f, "x"),
165
- itemStyle: { color: v },
184
+ ...a(p, "x"),
185
+ itemStyle: { color: x(e, y[t] ?? y[0]) },
166
186
  ...i ? { color: i } : {}
167
187
  };
168
188
  }),
169
189
  xAxis: {
170
190
  type: "value",
171
- min: () => m,
172
- max: () => g,
191
+ min: () => h,
192
+ max: () => _,
173
193
  axisLine: { show: !1 },
174
194
  axisTick: { show: !1 },
175
195
  splitLine: {
@@ -182,7 +202,7 @@ function b(e, t, n, o, s, c) {
182
202
  margin: parseInt(n.spacing(1)),
183
203
  showMaxLabel: !0,
184
204
  showMinLabel: !0,
185
- formatter: (e) => e !== g && e !== m || e === 0 ? "" : f ? f(e) : String(e)
205
+ formatter: (e) => e !== _ && e !== h || e === 0 ? "" : p ? p(e) : String(e)
186
206
  }
187
207
  },
188
208
  yAxis: {
@@ -196,11 +216,11 @@ function b(e, t, n, o, s, c) {
196
216
  0,
197
217
  0
198
218
  ],
199
- ...p && { formatter: (e) => String(p(e)) }
219
+ ...m && { formatter: (e) => String(m(e)) }
200
220
  }
201
221
  },
202
222
  legend: {
203
- ...u,
223
+ ...d,
204
224
  show: !0,
205
225
  selectedMode: !1,
206
226
  selected: Object.fromEntries(t.map((e, t) => [o?.[t]?.name ?? `Series ${t + 1}`, !0]))
@@ -208,11 +228,11 @@ function b(e, t, n, o, s, c) {
208
228
  tooltip: {
209
229
  ...l,
210
230
  trigger: "axis",
211
- formatter: x(f, p)
231
+ formatter: S(p, m)
212
232
  }
213
233
  };
214
234
  }
215
- function x(e, t) {
235
+ function S(e, t) {
216
236
  return l((n) => {
217
237
  let r = n.encode?.x?.at(0), i = r === void 0 ? void 0 : n.dimensionNames?.[r], a = n.value && typeof n.value == "object" && !Array.isArray(n.value) ? n.value : void 0, o = i && a ? a[i] : void 0, s = typeof o == "number" && e ? e(o) : o ?? "", c = typeof n.marker == "string" ? n.marker : "", l = n.seriesName ? `${n.seriesName}: ` : "";
218
238
  return {
@@ -223,7 +243,7 @@ function x(e, t) {
223
243
  };
224
244
  });
225
245
  }
226
- function S(e) {
246
+ function C(e) {
227
247
  let t = 0, n = -Infinity;
228
248
  for (let r of e) for (let e of r) typeof e?.value != "number" || !Number.isFinite(e.value) || (e.value < t && (t = e.value), e.value > n && (n = e.value));
229
249
  return {
@@ -231,7 +251,7 @@ function S(e) {
231
251
  niceMaxVal: n <= 0 ? 1 : s(n)
232
252
  };
233
253
  }
234
- function C(e, t) {
254
+ function w(e, t) {
235
255
  return l((n) => {
236
256
  let r = n.encode?.value?.at(0) ?? 1, i = (n.value && typeof n.value == "object" && !Array.isArray(n.value) ? Object.values(n.value) : [])[r], a = typeof i == "number" && e ? e(i) : i ?? "", o = typeof n.marker == "string" ? n.marker : "", s = n.seriesName ? `${n.seriesName}: ` : "";
237
257
  return {
@@ -244,7 +264,7 @@ function C(e, t) {
244
264
  }
245
265
  //#endregion
246
266
  //#region src/widgets-v2/pie/skeleton.tsx
247
- var w = 160, T = 96, E = {
267
+ var T = 160, E = 96, D = {
248
268
  root: {
249
269
  display: "flex",
250
270
  flexDirection: "column",
@@ -261,14 +281,14 @@ var w = 160, T = 96, E = {
261
281
  justifyContent: "center"
262
282
  },
263
283
  ring: {
264
- width: w,
265
- height: w
284
+ width: T,
285
+ height: T
266
286
  },
267
287
  hole: {
268
288
  position: "absolute",
269
289
  zIndex: 1,
270
- width: T,
271
- height: T,
290
+ width: E,
291
+ height: E,
272
292
  borderRadius: "50%",
273
293
  bgcolor: "background.paper"
274
294
  },
@@ -292,24 +312,24 @@ var w = 160, T = 96, E = {
292
312
  gap: ({ spacing: e }) => e(1.5)
293
313
  }
294
314
  };
295
- function D(e) {
296
- let t = u(4), n, r;
297
- t[0] === Symbol.for("react.memo_cache_sentinel") ? (n = /* @__PURE__ */ p(f, {
315
+ function O(e) {
316
+ let t = d(4), n, r;
317
+ t[0] === Symbol.for("react.memo_cache_sentinel") ? (n = /* @__PURE__ */ m(p, {
298
318
  variant: "circular",
299
- sx: E.ring
300
- }), r = /* @__PURE__ */ p(d, { sx: E.hole }), t[0] = n, t[1] = r) : (n = t[0], r = t[1]);
319
+ sx: D.ring
320
+ }), r = /* @__PURE__ */ m(f, { sx: D.hole }), t[0] = n, t[1] = r) : (n = t[0], r = t[1]);
301
321
  let i;
302
- t[2] === Symbol.for("react.memo_cache_sentinel") ? (i = /* @__PURE__ */ m(d, {
303
- sx: E.donut,
322
+ t[2] === Symbol.for("react.memo_cache_sentinel") ? (i = /* @__PURE__ */ h(f, {
323
+ sx: D.donut,
304
324
  children: [
305
325
  n,
306
326
  r,
307
- /* @__PURE__ */ m(d, {
308
- sx: E.label,
309
- children: [/* @__PURE__ */ p(f, {
327
+ /* @__PURE__ */ h(f, {
328
+ sx: D.label,
329
+ children: [/* @__PURE__ */ m(p, {
310
330
  width: 56,
311
331
  height: 18
312
- }), /* @__PURE__ */ p(f, {
332
+ }), /* @__PURE__ */ m(p, {
313
333
  width: 36,
314
334
  height: 8
315
335
  })]
@@ -317,22 +337,22 @@ function D(e) {
317
337
  ]
318
338
  }), t[2] = i) : i = t[2];
319
339
  let a;
320
- return t[3] === Symbol.for("react.memo_cache_sentinel") ? (a = /* @__PURE__ */ m(d, {
321
- sx: E.root,
322
- children: [i, /* @__PURE__ */ p(d, {
323
- sx: E.legend,
324
- children: [0, 1].map(O)
340
+ return t[3] === Symbol.for("react.memo_cache_sentinel") ? (a = /* @__PURE__ */ h(f, {
341
+ sx: D.root,
342
+ children: [i, /* @__PURE__ */ m(f, {
343
+ sx: D.legend,
344
+ children: [0, 1].map(k)
325
345
  })]
326
346
  }), t[3] = a) : a = t[3], a;
327
347
  }
328
- function O(e) {
329
- return /* @__PURE__ */ m(d, {
330
- sx: E.legendItem,
331
- children: [/* @__PURE__ */ p(f, {
348
+ function k(e) {
349
+ return /* @__PURE__ */ h(f, {
350
+ sx: D.legendItem,
351
+ children: [/* @__PURE__ */ m(p, {
332
352
  variant: "circular",
333
353
  width: 8,
334
354
  height: 8
335
- }), /* @__PURE__ */ p(f, {
355
+ }), /* @__PURE__ */ m(p, {
336
356
  width: 48,
337
357
  height: 8
338
358
  })]
@@ -340,7 +360,7 @@ function O(e) {
340
360
  }
341
361
  //#endregion
342
362
  //#region src/widgets-v2/pie/download.ts
343
- function k(n) {
363
+ function A(n) {
344
364
  let r = [];
345
365
  return n.getCaptureEl && r.push(e({
346
366
  filename: n.filename,
@@ -368,6 +388,6 @@ function k(n) {
368
388
  })), r;
369
389
  }
370
390
  //#endregion
371
- export { D as PieSkeleton, k as createPieDownloadConfig, v as createPieOptionFactory, _ as pieOptions };
391
+ export { O as PieSkeleton, A as createPieDownloadConfig, y as createPieOptionFactory, v as pieOptions };
372
392
 
373
393
  //# sourceMappingURL=pie.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pie.js","names":["Theme","EChartsOption","echarts","CallbackDataParams","buildGridConfig","buildLegendConfig","buildSeriesLabelConfig","createTooltipFormatter","createTooltipPositioner","niceNum","OptionFactory","OptionFactoryContext","mergeOptions","resolveThemeColor","WidgetSeries","PieEChartsOption","PieOptionFactoryInput","PieOptionsInput","PieWidgetData","DEFAULT_RADIUS","pieOptions","theme","formatter","labelFormatter","legend","hasLegend","type","itemGap","selectedMode","tooltip","trigger","backgroundColor","palette","grey","borderWidth","padding","parseInt","spacing","textStyle","color","common","white","fontSize","fontFamily","typography","caption","position","buildPieTooltipFormatter","Object","values","qualitative","bold","Record","series","colorBy","avoidLabelOverlap","selectedOffset","legendHoverLink","emphasis","disabled","itemStyle","borderColor","background","paper","label","show","rich","b","fontWeight","lineHeight","c","createPieOptionFactory","options","optionsOverride","radius","selection","selectionSet","undefined","length","Set","option","data","ctx","structural","Partial","seriesArr","Array","isArray","dataset","buildMultiSeriesBarFusion","buildSingleSeriesPieFusion","seriesTemplates","broadcastTemplate","baseTooltip","baseLegend","resolvePaletteColor","params","swatch","dataIndex","colorFn","base","datum","value","name","has","modifyAlpha","templateLabelPosition","isCenterLabel","centerData","centerMaxName","centerMaxValue","Infinity","d","labelTextFormatter","encodeIndex","encode","at","formattedValue","String","formattedName","separator","map","s","source","_","i","template","templateObj","templateLabel","templateItemStyle","const","datasetIndex","center","itemName","selected","fromEntries","baseGrid","grid","niceMinVal","niceMaxVal","computeNiceBounds","barColorFn","seriesIdx","seriesIndex","seriesSwatch","right","containLabel","overrideColor","barMaxWidth","focus","xAxis","min","max","axisLine","axisTick","splitLine","lineStyle","black","divider","axisLabel","overlineDelicate","margin","showMaxLabel","showMinLabel","yAxis","buildHorizontalBarTooltipFormatter","item","x","dimName","dimensionNames","row","raw","marker","seriesName","Number","isFinite","Box","Skeleton","SxProps","Theme","OUTER_SIZE","HOLE_SIZE","styles","root","display","flexDirection","alignItems","justifyContent","minHeight","py","gap","spacing","donut","position","ring","width","height","hole","zIndex","borderRadius","bgcolor","label","legend","legendItem","Record","PieSkeletonProps","count","PieSkeleton","t0","$","_c","t1","t2","Symbol","for","t3","t4","map","_temp","i","buildCsvDownloadItem","buildPngDownloadItem","DownloadContext","DownloadItem","PieWidgetData","createPieDownloadConfig","args","filename","getData","ctx","seriesNames","getCaptureEl","HTMLElement","pngPixelRatio","pngBackgroundColor","items","push","pixelRatio","backgroundColor","getRows","data","rows","i","series","entries","seriesName","slice","name","value"],"sources":["../../src/widgets-v2/pie/options.ts","../../src/widgets-v2/pie/skeleton.tsx","../../src/widgets-v2/pie/download.ts"],"sourcesContent":["import type { Theme } from '@mui/material'\nimport type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildGridConfig,\n buildLegendConfig,\n buildSeriesLabelConfig,\n createTooltipFormatter,\n createTooltipPositioner,\n niceNum,\n} from '../../widgets/utils/chart-config'\nimport type { OptionFactory, OptionFactoryContext } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport type { WidgetSeries } from '../types'\nimport type {\n PieEChartsOption,\n PieOptionFactoryInput,\n PieOptionsInput,\n PieWidgetData,\n} from './types'\n\nconst DEFAULT_RADIUS: readonly [string, string] = ['58%', '74%']\n\n/**\n * Builds the **structural** ECharts option for a pie / donut widget.\n * Mirrors v1's pie look-and-feel: themed legend (`buildLegendConfig`),\n * themed tooltip via `createTooltipPositioner` / `createTooltipFormatter`,\n * `qualitative.bold` color palette, slice borders against the paper\n * background, hover-emphasis disabled, and a centered rich-text label.\n *\n * Layered like Bar / Histogram:\n * - **Theme-aware bits** live here on a series template (slice border,\n * center-label rich style sizes, emphasis-disabled).\n * - **Reactive bits** (tooltip value formatter, center-label text,\n * selection-driven dim) are re-emitted by\n * {@link createPieOptionFactory} at fusion time so RelativeData's\n * percent override flows through.\n */\nexport function pieOptions({\n theme,\n formatter,\n labelFormatter,\n}: PieOptionsInput): PieEChartsOption {\n return {\n legend: {\n ...buildLegendConfig({ hasLegend: true, labelFormatter }),\n // Bottom-left, same as every other widget — `buildLegendConfig`'s\n // `left: 0` is kept deliberately. The wider `itemGap` gives chips\n // breathing room in the typical 3–6 category case.\n type: 'scroll',\n itemGap: 16,\n // The legend is presentational only here — the pie has its own\n // click-to-select affordance on the slices themselves, so legend\n // clicks toggling series visibility would be a second, redundant/\n // conflicting interaction model. Hover-highlight is disabled per\n // series via `legendHoverLink` (ECharts has no legend-level knob\n // for it).\n selectedMode: false,\n },\n tooltip: {\n // Pie uses item-trigger (no axis); the rest of the styling mirrors\n // bar/histogram so the dashboard reads consistently — dark\n // grey[900] bg, white caption-font text, padded, with the shared\n // overflow-aware positioner.\n trigger: 'item',\n backgroundColor: theme.palette.grey[900],\n borderWidth: 0,\n padding: [parseInt(theme.spacing(1)), parseInt(theme.spacing(1))],\n textStyle: {\n color: theme.palette.common.white,\n fontSize: 11,\n fontFamily: theme.typography.caption.fontFamily,\n },\n position: createTooltipPositioner(theme),\n formatter: buildPieTooltipFormatter(formatter, labelFormatter),\n },\n // V1 used `qualitative.bold` only (no `secondary.main` prefix) because\n // pie slices are categorical — each slice deserves a distinct palette\n // entry from the start, not a primary highlight.\n color: Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n // Pie template. The merger spreads this into each per-data series it\n // emits — borderColor / borderWidth / emphasis-disabled / label rich\n // sizes all survive through.\n series: [\n {\n type: 'pie',\n colorBy: 'data',\n avoidLabelOverlap: true,\n selectedOffset: 0,\n legendHoverLink: false,\n emphasis: { disabled: true },\n itemStyle: {\n borderColor: theme.palette.background.paper,\n borderWidth: 1,\n },\n label: {\n show: true,\n position: 'center',\n rich: {\n b: { fontSize: 16, fontWeight: 'normal', lineHeight: 20 },\n c: { fontSize: 28, fontWeight: 'bold', lineHeight: 27 },\n },\n },\n },\n ],\n }\n}\n\n/**\n * Returns the pie widget's {@link OptionFactory} — one closure that owns\n * BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link pieOptions}, optionally merging the\n * consumer-supplied `optionsOverride` on top. Called once by Provider\n * to seed `rawOptions` in the store.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`PieWidgetData`) into the option via the dataset API. Single-series\n * → donut (one dataset, `series[i].encode = { itemName: 'name', value: 'value' }`).\n * Multi-series → horizontal-bar fallback (mirrors v1 pie). Reactive\n * formatters from `ctx` drive the tooltip + center label at fusion\n * time so RelativeData's percent formatter flows through without a\n * structural rebuild.\n */\nexport function createPieOptionFactory(\n options: PieOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, labelFormatter, optionsOverride, series } = options\n const radius = options.radius ?? DEFAULT_RADIUS\n const selection = options.selection\n // An explicit `[]` (deselected down to zero via chart clicks) is treated\n // the same as no selection: the pie has no bar/histogram-style \"nothing\n // selected\" affordance, so dimming every slice would just look broken —\n // it renders fully active, same as the no-interaction state.\n const selectionSet =\n selection === undefined || selection === null || selection.length === 0\n ? null\n : new Set<string | number>(selection)\n return (option, data, ctx) => {\n if (option == null) {\n const structural = pieOptions({ theme, formatter, labelFormatter })\n return optionsOverride\n ? (mergeOptions(\n structural as unknown as Record<string, unknown>,\n optionsOverride as Partial<Record<string, unknown>>,\n ) as EChartsOption)\n : structural\n }\n\n const seriesArr = Array.isArray(data) ? (data as PieWidgetData) : []\n if (seriesArr.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n if (seriesArr.length > 1) {\n return buildMultiSeriesBarFusion(\n option,\n seriesArr,\n theme,\n series,\n ctx,\n selectionSet,\n )\n }\n return buildSingleSeriesPieFusion(\n option,\n seriesArr,\n radius,\n series,\n ctx,\n selectionSet,\n )\n }\n}\n\n/**\n * Single-series donut fusion. Spreads the structural pie series template\n * into per-data series with center/radius/encoding, wires the reactive\n * center-label / tooltip formatters and the per-data palette-aware\n * selection-dim callback.\n */\nfunction buildSingleSeriesPieFusion(\n option: EChartsOption,\n seriesArr: PieWidgetData,\n radius: readonly [string, string],\n series: readonly WidgetSeries[] | undefined,\n ctx: OptionFactoryContext | undefined,\n selectionSet: Set<string | number> | null,\n): EChartsOption {\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n const formatter = ctx?.formatter\n const labelFormatter = ctx?.labelFormatter\n\n // Pie wants `colorBy: 'data'` — each slice draws from the option's\n // `color` palette by data index. But installing an `itemStyle.color`\n // callback disables ECharts' automatic per-data cycling, and\n // `params.color` collapses to the series color (so every slice goes\n // the same color). We re-implement the per-data palette resolution\n // here so the multicolor look survives selection-driven dimming.\n const palette = Array.isArray(option.color)\n ? (option.color as readonly (string | undefined)[])\n : []\n const resolvePaletteColor = (params: CallbackDataParams): string => {\n const swatch =\n palette.length > 0\n ? palette[params.dataIndex % palette.length]\n : undefined\n return swatch ?? (params.color as string)\n }\n\n // Always emit `itemStyle.color` (passthrough when nothing is selected),\n // not conditionally — same anti-stale-callback rationale as bar /\n // histogram. The slice border + width come from the structural\n // template's `itemStyle` and survive via the spread below.\n //\n // `selectionSet` is the *included* set, same direct semantics as\n // bar/histogram/timeseries (no ADR-014 exclusion inversion). Dim a slice\n // when its name is NOT in the set. `selectionSet` is never a non-null\n // empty Set — the collapse above (`selection.length === 0 → null`) rules\n // that out — so there's no \"dim everything\" case here, unlike a widget\n // that gives `[]` its own \"selected down to nothing\" meaning.\n const colorFn = (params: CallbackDataParams): string => {\n const base = resolvePaletteColor(params)\n if (!selectionSet) return base\n const datum = params.value as { name?: string | number } | undefined\n const name = datum?.name ?? params.name\n return name != null && selectionSet.has(name)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n }\n\n // ECharts anchors EVERY slice's `position: 'center'` label at the same\n // point, so at most one of them can ever be legible — the donut design\n // leans into that (one KPI inside the ring) and picks a single slice\n // below. A consumer that moves the labels off the centre gives each\n // slice its own anchor (`'outside'` with leader lines is what the PDF\n // export uses, `'inside'` / `'insideTop'` … likewise), and there the\n // single-label rule is simply wrong: every slice must render its own\n // label. Read the position off the structural template, which already\n // carries the consumer's `optionsOverride`.\n const templateLabelPosition = (\n broadcastTemplate as { label?: { position?: unknown } }\n ).label?.position\n const isCenterLabel =\n templateLabelPosition === undefined || templateLabelPosition === 'center'\n\n // Which slice renders the centre value+name: the greatest value among\n // the *included* slices (all of them when there's no active\n // selection), computed locally — no query round-trip. Only that one\n // slice's formatter call returns text; every other slice returns ''\n // so exactly one label ever renders at the shared centre anchor. Only\n // `typeof value === 'number'` participates — if every included slice's\n // value is non-numeric, `centerMaxName` stays `undefined` and no slice\n // matches it in `labelTextFormatter` below, so the chart renders with no\n // centre label at all (graceful no-op, not a crash). Skipped entirely\n // for off-centre labels, where every slice labels itself.\n const centerData = seriesArr[0] ?? []\n let centerMaxName: string | number | undefined\n let centerMaxValue = -Infinity\n for (const d of centerData) {\n if (selectionSet && !selectionSet.has(d.name)) continue\n if (typeof d.value === 'number' && d.value > centerMaxValue) {\n centerMaxValue = d.value\n centerMaxName = d.name\n }\n }\n\n // Slice label formatter — lives in the merger because it reads\n // reactive `formatter` / `labelFormatter` from ctx. The rich tags\n // `{c|…}` and `{b|…}` reference the rich styles baked into the\n // structural label template.\n const labelTextFormatter = (params: CallbackDataParams): string => {\n const { name } = params\n if (name == null) return ''\n if (isCenterLabel && name !== centerMaxName) return ''\n const encodeIndex = params.encode?.value?.[0]\n if (encodeIndex === undefined) return ''\n const value = (Object.values(params.data ?? {}) as unknown[]).at(\n encodeIndex,\n )\n // `value` here is the resolved dataset cell — for pie data it's a\n // `string | number` primitive. Anything else is a misuse we won't\n // dress up with `String(...)` (would render \"[object Object]\").\n const formattedValue =\n typeof value === 'number'\n ? formatter\n ? formatter(value)\n : String(value)\n : typeof value === 'string'\n ? value\n : ''\n const formattedName = labelFormatter\n ? String(labelFormatter(name ?? ''))\n : String(name ?? '')\n // The blank line is what separates the big centre KPI from its\n // caption. Off-centre labels sit next to their own slice and are\n // laid out against their neighbours, so the spacer only inflates\n // each label's bounding box — enough, with a hidden `{b|…}` block,\n // to make ECharts drop colliding labels altogether.\n const separator = isCenterLabel ? '\\n\\n' : '\\n'\n return `{c|${formattedValue}}${separator}{b|${formattedName}}`\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n series: seriesArr.map((_, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n const templateObj = typeof template === 'object' ? template : {}\n const templateLabel = (templateObj as { label?: object }).label ?? {}\n const templateItemStyle =\n (templateObj as { itemStyle?: object }).itemStyle ?? {}\n return {\n ...templateObj,\n type: 'pie' as const,\n legendHoverLink: false,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n radius: [...radius],\n // Lift the donut up so the bottom-anchored legend has the\n // vertical real estate to wrap to multiple rows for long\n // category lists — at exactly `50%` the bottom slices crowd\n // the chips and `type: 'plain'` legends can't expand upward\n // without overlapping the donut.\n center: ['50%', '38%'] as [string, string],\n encode: { itemName: 'name', value: 'value' },\n label: {\n ...templateLabel,\n formatter: labelTextFormatter,\n },\n itemStyle: {\n ...templateItemStyle,\n color: colorFn,\n },\n }\n }),\n // Legend always shows for pie (mirrors v1) — slice names drive the\n // entries, so even a single donut benefits from a category list.\n //\n // Exclusion is conveyed purely via `colorFn`/`labelTextFormatter`\n // dimming above, never via the legend's `selected` map: for a pie\n // series, ECharts treats `legend.selected[name] = false` as \"remove\n // this data point,\" which recomputes every remaining slice's angle —\n // the excluded slice disappears instead of rendering dimmed. Forcing\n // every name to `true` on every render also overrides ECharts' own\n // internal toggle state from a native legend click (which flips a\n // name to `false` and hides it before our `legendselectchanged`\n // handler gets a chance to react), so a legend click never leaves a\n // slice structurally removed — only the color/label dimming reflects\n // exclusion, and it stays in sync with the slice itself since both\n // read `selectionSet` on the same render.\n legend: {\n ...baseLegend,\n show: true,\n selectedMode: false,\n selected: Object.fromEntries(\n (seriesArr[0] ?? []).map((d) => [String(d.name), true]),\n ),\n },\n tooltip: {\n ...baseTooltip,\n formatter: buildPieTooltipFormatter(formatter, labelFormatter),\n },\n }\n}\n\n/**\n * Multi-series horizontal-bar fusion. Mirrors v1 pie's \"pie data with\n * >1 series collapses into a horizontal bar chart\" behavior — side-by-\n * side donuts don't read well when you're comparing the same categories\n * across cohorts, so swap to a value-on-x / category-on-y bar layout.\n *\n * Pie data shape is identical to bar's (`{ name, value }[][]`), so the\n * same dataset feeds either layout without transformation.\n */\nfunction buildMultiSeriesBarFusion(\n option: EChartsOption,\n seriesArr: PieWidgetData,\n theme: Theme,\n series: readonly WidgetSeries[] | undefined,\n ctx: OptionFactoryContext | undefined,\n selectionSet: Set<string | number> | null,\n): EChartsOption {\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n const baseGrid =\n typeof option.grid === 'object' && !Array.isArray(option.grid)\n ? option.grid\n : {}\n const formatter = ctx?.formatter\n const labelFormatter = ctx?.labelFormatter\n\n const { niceMinVal, niceMaxVal } = computeNiceBounds(seriesArr)\n\n // Per-series palette — multi-series bars take one color per series\n // (not per-data, unlike donut slices). Same anti-stale-callback rule:\n // always emit the callback so a transition to/from a selection\n // replaces the previous closure cleanly.\n const palette = Array.isArray(option.color)\n ? (option.color as readonly (string | undefined)[])\n : []\n const barColorFn = (params: CallbackDataParams): string => {\n const seriesIdx = params.seriesIndex ?? 0\n const seriesSwatch =\n palette.length > 0 ? palette[seriesIdx % palette.length] : undefined\n const base = (seriesSwatch ?? params.color) as string\n if (!selectionSet) return base\n const datum = params.value as { name?: string | number } | undefined\n const name = datum?.name ?? params.name\n return name != null && selectionSet.has(name)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n grid: {\n ...baseGrid,\n ...buildGridConfig(true, theme),\n right: parseInt(theme.spacing(4)),\n containLabel: true,\n },\n // Drop pie-specific structural keys that shouldn't render in the\n // bar fallback. ECharts ignores undefined keys, so this is a clean\n // override.\n series: seriesArr.map((_, i) => {\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n datasetIndex: i,\n type: 'bar' as const,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n barMaxWidth: 100,\n legendHoverLink: false,\n emphasis: { focus: 'series' },\n ...buildSeriesLabelConfig(formatter, 'x'),\n itemStyle: { color: barColorFn },\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n xAxis: {\n type: 'value',\n // Closures over the pre-computed nice bounds — ECharts calls them\n // once per render to resolve the axis extents.\n min: () => niceMinVal,\n max: () => niceMaxVal,\n axisLine: { show: false },\n axisTick: { show: false },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n // Value labels render BELOW the axis line (default placement),\n // NOT inside the plot. Bar/histogram use `inside: true` +\n // `verticalAlign: 'bottom'` for their *vertical* y-axis where the\n // axis is the left wall — labels inside read like grid annotations.\n // A horizontal bar chart's value axis is the x-axis, and `inside`\n // there pushes the max label *behind* the bar (it visually\n // disappears once a bar reaches the right edge). Use the default\n // below-the-axis placement so the rounded extents stay readable.\n axisLabel: {\n fontSize: theme.typography.overlineDelicate?.fontSize,\n fontFamily: theme.typography.overlineDelicate?.fontFamily,\n margin: parseInt(theme.spacing(1)),\n showMaxLabel: true,\n showMinLabel: true,\n formatter: (value: number) => {\n if (value !== niceMaxVal && value !== niceMinVal) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n yAxis: {\n type: 'category',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n ...(labelFormatter && {\n formatter: (value: string | number) => String(labelFormatter(value)),\n }),\n },\n },\n // Mirrors the donut branch's `selected` reset above — `selectedMode:\n // false` blocks the native legend click that would otherwise undo an\n // ECharts-internal toggle, so without forcing every entry back to\n // `true` here a prior native toggle (from before `selectedMode` took\n // effect, or a stale `keepAlive` instance) would stay hidden forever\n // with no way to restore it.\n legend: {\n ...baseLegend,\n show: true,\n selectedMode: false,\n selected: Object.fromEntries(\n seriesArr.map((_, i) => [series?.[i]?.name ?? `Series ${i + 1}`, true]),\n ),\n },\n tooltip: {\n ...baseTooltip,\n trigger: 'axis',\n formatter: buildHorizontalBarTooltipFormatter(formatter, labelFormatter),\n },\n } as EChartsOption\n}\n\n/**\n * Tooltip formatter for the horizontal-bar fallback. Reads the value by\n * `encode.x` dimension index (v1 parity) so it stays robust to\n * downstream changes that rename dataset columns.\n */\nfunction buildHorizontalBarTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: string | number) => string | number) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const encodeIndex = item.encode?.x?.at(0)\n const dimName =\n encodeIndex !== undefined ? item.dimensionNames?.[encodeIndex] : undefined\n const row =\n item.value && typeof item.value === 'object' && !Array.isArray(item.value)\n ? (item.value as Record<string, string | number>)\n : undefined\n const raw = dimName && row ? row[dimName] : undefined\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n const name = labelFormatter\n ? String(labelFormatter(item.name ?? ''))\n : String(item.name ?? '')\n return { name, seriesName, marker, value: formattedValue }\n })\n}\n\n/**\n * Min/max bounds over every datum's `.value` across all series. Used by\n * the horizontal-bar fallback's x-axis label formatter so we only render\n * labels at the rounded extents (matches v1 + bar / histogram).\n */\nfunction computeNiceBounds(seriesArr: PieWidgetData): {\n niceMinVal: number\n niceMaxVal: number\n} {\n let min = 0\n let max = -Infinity\n for (const series of seriesArr) {\n for (const d of series) {\n if (typeof d?.value !== 'number' || !Number.isFinite(d.value)) continue\n if (d.value < min) min = d.value\n if (d.value > max) max = d.value\n }\n }\n return {\n niceMinVal: min < 0 ? niceNum(min) : 0,\n niceMaxVal: max <= 0 ? 1 : niceNum(max),\n }\n}\n\n/**\n * Tooltip formatter for pie slices. `item.value` is the dataset row\n * object (e.g. `{ name: 'A', value: 10 }`); we pull the value by\n * `encode.value`'s dimension index, formatted via the reactive `formatter`\n * if present. Slice name passes through `labelFormatter`.\n */\nfunction buildPieTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: string | number) => string | number) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const encodeIndex = item.encode?.value?.at(0) ?? 1\n const values =\n item.value && typeof item.value === 'object' && !Array.isArray(item.value)\n ? (Object.values(item.value) as (string | number)[])\n : []\n const raw = values[encodeIndex]\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n const name = labelFormatter\n ? String(labelFormatter(item.name ?? ''))\n : String(item.name ?? '')\n return { name, seriesName, marker, value: formattedValue }\n })\n}\n","import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst OUTER_SIZE = 160\nconst HOLE_SIZE = 96\n\nconst styles = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: 200,\n py: 1,\n gap: ({ spacing }) => spacing(2),\n },\n donut: {\n position: 'relative',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n },\n ring: {\n width: OUTER_SIZE,\n height: OUTER_SIZE,\n },\n hole: {\n position: 'absolute',\n zIndex: 1,\n width: HOLE_SIZE,\n height: HOLE_SIZE,\n borderRadius: '50%',\n bgcolor: 'background.paper',\n },\n label: {\n position: 'absolute',\n zIndex: 2,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: ({ spacing }) => spacing(0.5),\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\nexport interface PieSkeletonProps {\n count?: number\n}\n\n/**\n * Loading state for the Pie widget. Mirrors the donut silhouette — a ring\n * (gray circle with a background-coloured hole punched out), a stacked\n * value/name stub in the centre, and a centered legend stub below — so the\n * skeleton reads as \"a donut chart\" rather than a solid disc.\n *\n * Single donut only: multi-series pie loads as a horizontal bar chart, so\n * rendering one ring stays honest regardless of `count`.\n */\nexport function PieSkeleton({ count }: PieSkeletonProps) {\n // `count` is accepted for API compatibility but intentionally unused: the\n // skeleton always renders a single donut, since multi-series pie loads as a\n // horizontal bar chart rather than multiple donuts.\n void count\n return (\n <Box sx={styles.root}>\n <Box sx={styles.donut}>\n <Skeleton variant='circular' sx={styles.ring} />\n <Box sx={styles.hole} />\n <Box sx={styles.label}>\n <Skeleton width={56} height={18} />\n <Skeleton width={36} height={8} />\n </Box>\n </Box>\n <Box sx={styles.legend}>\n {[0, 1].map((i) => (\n <Box key={`legend-${i}`} sx={styles.legendItem}>\n <Skeleton variant='circular' width={8} height={8} />\n <Skeleton width={48} height={8} />\n </Box>\n ))}\n </Box>\n </Box>\n )\n}\n","import {\n buildCsvDownloadItem,\n buildPngDownloadItem,\n type DownloadContext,\n type DownloadItem,\n} from '../actions/download'\nimport type { PieWidgetData } from './types'\n\n/**\n * Download menu items for the Pie widget. Always includes a CSV item with\n * `series, name, value` columns (one row per slice; series labels come from\n * `seriesNames` if provided, else `series_<n>`). When `getCaptureEl` is\n * supplied, prepends a PNG item that rasterises the captured element via\n * `html2canvas`.\n */\nexport function createPieDownloadConfig(args: {\n filename: string\n getData: (ctx: DownloadContext) => PieWidgetData\n seriesNames?: readonly string[]\n getCaptureEl?: (ctx: DownloadContext) => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push(\n buildCsvDownloadItem({\n filename: args.filename,\n getRows: (ctx) => {\n const data = args.getData(ctx)\n const rows: unknown[][] = [['series', 'name', 'value']]\n for (const [i, series] of data.entries()) {\n const seriesName = args.seriesNames?.[i] ?? `series_${i + 1}`\n for (const slice of series) {\n rows.push([seriesName, slice.name, slice.value])\n }\n }\n return rows\n },\n }),\n )\n return items\n}\n"],"mappings":";;;;;;;;AAsBA,IAAMmB,IAA4C,CAAC,OAAO,KAAK;AAiB/D,SAAgBC,EAAW,EACzBC,UACAC,cACAC,qBACoC;CACpC,OAAO;EACLC,QAAQ;GACN,GAAGnB,EAAkB;IAAEoB,WAAW;IAAMF;GAAe,CAAC;GAIxDG,MAAM;GACNC,SAAS;GAOTC,cAAc;EAChB;EACAC,SAAS;GAKPC,SAAS;GACTC,iBAAiBV,EAAMW,QAAQC,KAAK;GACpCC,aAAa;GACbC,SAAS,CAACC,SAASf,EAAMgB,QAAQ,CAAC,CAAC,GAAGD,SAASf,EAAMgB,QAAQ,CAAC,CAAC,CAAC;GAChEC,WAAW;IACTC,OAAOlB,EAAMW,QAAQQ,OAAOC;IAC5BC,UAAU;IACVC,YAAYt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oB;GACZ,UAAA,CAAC,GAAG,CAAC,CAAC,CAAAe,IAAKC,CAKX;EANC,CAAA,CATF;KAiBET,EAAA,KAAAO,KAAAA,IAAAP,EAAA,IAjBNO;AAiBM;AAvBH,SAAAE,EAAAC,GAAA;CAAA,OAiBG,kBAAC,GAAD;EAA6B,IAAArC,EAAMqB;EAAnC,UAAA,CACE,kBAAC,GAAD;GAAkB,SAAA;GAAkB,OAAA;GAAW,QAAA;EAAC,CAAA,GAChD,kBAAC,GAAD;GAAiB,OAAA;GAAY,QAAA;EAAC,CAAA,CAF5B;CAAM,GAAA,UAAUgB,GAAhB;AAGE;;;ACzEhB,SAAgBM,EAAwBC,GAOrB;CACjB,IAAMS,IAAwB,CAAA;CA2B9B,OA1BIT,EAAKK,gBACPI,EAAMC,KACJf,EAAqB;EACnBM,UAAUD,EAAKC;EACfI,cAAcL,EAAKK;EACnBM,YAAYX,EAAKO;EACjBK,iBAAiBZ,EAAKQ;CACxB,CAAC,CACH,GAEFC,EAAMC,KACJhB,EAAqB;EACnBO,UAAUD,EAAKC;EACfY,UAAUV,MAAQ;GAChB,IAAMW,IAAOd,EAAKE,QAAQC,CAAG,GACvBY,IAAoB,CAAC;IAAC;IAAU;IAAQ;GAAO,CAAC;GACtD,KAAK,IAAM,CAACC,GAAGC,MAAWH,EAAKI,QAAQ,GAAG;IACxC,IAAMC,IAAanB,EAAKI,cAAcY,MAAM,UAAUA,IAAI;IAC1D,KAAK,IAAMI,KAASH,GAClBF,EAAKL,KAAK;KAACS;KAAYC,EAAMC;KAAMD,EAAME;IAAK,CAAC;GAEnD;GACA,OAAOP;EACT;CACF,CAAC,CACH,GACON;AACT"}
1
+ {"version":3,"file":"pie.js","names":["Theme","EChartsOption","echarts","CallbackDataParams","buildGridConfig","buildLegendConfig","buildSeriesLabelConfig","createTooltipFormatter","createTooltipPositioner","niceNum","OptionFactory","OptionFactoryContext","mergeOptions","resolveThemeColor","createItemColorResolver","WidgetSeries","PieEChartsOption","PieOptionFactoryInput","PieOptionsInput","PieWidgetData","DEFAULT_RADIUS","pieOptions","theme","formatter","labelFormatter","legend","hasLegend","type","itemGap","selectedMode","tooltip","trigger","backgroundColor","palette","grey","borderWidth","padding","parseInt","spacing","textStyle","color","common","white","fontSize","fontFamily","typography","caption","position","buildPieTooltipFormatter","Object","values","qualitative","bold","Record","series","colorBy","avoidLabelOverlap","selectedOffset","legendHoverLink","emphasis","disabled","itemStyle","borderColor","background","paper","label","show","rich","b","fontWeight","lineHeight","c","createPieOptionFactory","options","optionsOverride","radius","selection","selectionSet","undefined","length","Set","option","data","ctx","structural","Partial","seriesArr","Array","isArray","dataset","buildMultiSeriesBarFusion","buildSingleSeriesPieFusion","seriesTemplates","broadcastTemplate","baseTooltip","baseLegend","resolvePaletteColor","params","swatch","dataIndex","makeColorFn","datums","template","baseColor","fallback","base","datum","value","name","has","modifyAlpha","templateLabelPosition","isCenterLabel","centerData","centerMaxName","centerMaxValue","Infinity","d","labelTextFormatter","encodeIndex","encode","at","formattedValue","String","formattedName","separator","map","s","source","i","templateObj","templateLabel","templateItemStyle","const","datasetIndex","center","itemName","selected","fromEntries","baseGrid","grid","niceMinVal","niceMaxVal","computeNiceBounds","paletteColor","seriesIdx","seriesIndex","seriesSwatch","makeBarColorFn","right","containLabel","overrideColor","barMaxWidth","focus","xAxis","min","max","axisLine","axisTick","splitLine","lineStyle","black","divider","axisLabel","overlineDelicate","margin","showMaxLabel","showMinLabel","yAxis","_","buildHorizontalBarTooltipFormatter","item","x","dimName","dimensionNames","row","raw","marker","seriesName","Number","isFinite","Box","Skeleton","SxProps","Theme","OUTER_SIZE","HOLE_SIZE","styles","root","display","flexDirection","alignItems","justifyContent","minHeight","py","gap","spacing","donut","position","ring","width","height","hole","zIndex","borderRadius","bgcolor","label","legend","legendItem","Record","PieSkeletonProps","count","PieSkeleton","t0","$","_c","t1","t2","Symbol","for","t3","t4","map","_temp","i","buildCsvDownloadItem","buildPngDownloadItem","DownloadContext","DownloadItem","PieWidgetData","createPieDownloadConfig","args","filename","getData","ctx","seriesNames","getCaptureEl","HTMLElement","pngPixelRatio","pngBackgroundColor","items","push","pixelRatio","backgroundColor","getRows","data","rows","i","series","entries","seriesName","slice","name","value"],"sources":["../../src/widgets-v2/pie/options.ts","../../src/widgets-v2/pie/skeleton.tsx","../../src/widgets-v2/pie/download.ts"],"sourcesContent":["import type { Theme } from '@mui/material'\nimport type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildGridConfig,\n buildLegendConfig,\n buildSeriesLabelConfig,\n createTooltipFormatter,\n createTooltipPositioner,\n niceNum,\n} from '../../widgets/utils/chart-config'\nimport type { OptionFactory, OptionFactoryContext } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport { createItemColorResolver } from '../utils/item-color'\nimport type { WidgetSeries } from '../types'\nimport type {\n PieEChartsOption,\n PieOptionFactoryInput,\n PieOptionsInput,\n PieWidgetData,\n} from './types'\n\nconst DEFAULT_RADIUS: readonly [string, string] = ['58%', '74%']\n\n/**\n * Builds the **structural** ECharts option for a pie / donut widget.\n * Mirrors v1's pie look-and-feel: themed legend (`buildLegendConfig`),\n * themed tooltip via `createTooltipPositioner` / `createTooltipFormatter`,\n * `qualitative.bold` color palette, slice borders against the paper\n * background, hover-emphasis disabled, and a centered rich-text label.\n *\n * Layered like Bar / Histogram:\n * - **Theme-aware bits** live here on a series template (slice border,\n * center-label rich style sizes, emphasis-disabled).\n * - **Reactive bits** (tooltip value formatter, center-label text,\n * selection-driven dim) are re-emitted by\n * {@link createPieOptionFactory} at fusion time so RelativeData's\n * percent override flows through.\n */\nexport function pieOptions({\n theme,\n formatter,\n labelFormatter,\n}: PieOptionsInput): PieEChartsOption {\n return {\n legend: {\n ...buildLegendConfig({ hasLegend: true, labelFormatter }),\n // Bottom-left, same as every other widget — `buildLegendConfig`'s\n // `left: 0` is kept deliberately. The wider `itemGap` gives chips\n // breathing room in the typical 3–6 category case.\n type: 'scroll',\n itemGap: 16,\n // The legend is presentational only here — the pie has its own\n // click-to-select affordance on the slices themselves, so legend\n // clicks toggling series visibility would be a second, redundant/\n // conflicting interaction model. Hover-highlight is disabled per\n // series via `legendHoverLink` (ECharts has no legend-level knob\n // for it).\n selectedMode: false,\n },\n tooltip: {\n // Pie uses item-trigger (no axis); the rest of the styling mirrors\n // bar/histogram so the dashboard reads consistently — dark\n // grey[900] bg, white caption-font text, padded, with the shared\n // overflow-aware positioner.\n trigger: 'item',\n backgroundColor: theme.palette.grey[900],\n borderWidth: 0,\n padding: [parseInt(theme.spacing(1)), parseInt(theme.spacing(1))],\n textStyle: {\n color: theme.palette.common.white,\n fontSize: 11,\n fontFamily: theme.typography.caption.fontFamily,\n },\n position: createTooltipPositioner(theme),\n formatter: buildPieTooltipFormatter(formatter, labelFormatter),\n },\n // V1 used `qualitative.bold` only (no `secondary.main` prefix) because\n // pie slices are categorical — each slice deserves a distinct palette\n // entry from the start, not a primary highlight.\n color: Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n // Pie template. The merger spreads this into each per-data series it\n // emits — borderColor / borderWidth / emphasis-disabled / label rich\n // sizes all survive through.\n series: [\n {\n type: 'pie',\n colorBy: 'data',\n avoidLabelOverlap: true,\n selectedOffset: 0,\n legendHoverLink: false,\n emphasis: { disabled: true },\n itemStyle: {\n borderColor: theme.palette.background.paper,\n borderWidth: 1,\n },\n label: {\n show: true,\n position: 'center',\n rich: {\n b: { fontSize: 16, fontWeight: 'normal', lineHeight: 20 },\n c: { fontSize: 28, fontWeight: 'bold', lineHeight: 27 },\n },\n },\n },\n ],\n }\n}\n\n/**\n * Returns the pie widget's {@link OptionFactory} — one closure that owns\n * BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link pieOptions}, optionally merging the\n * consumer-supplied `optionsOverride` on top. Called once by Provider\n * to seed `rawOptions` in the store.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`PieWidgetData`) into the option via the dataset API. Single-series\n * → donut (one dataset, `series[i].encode = { itemName: 'name', value: 'value' }`).\n * Multi-series → horizontal-bar fallback (mirrors v1 pie). Reactive\n * formatters from `ctx` drive the tooltip + center label at fusion\n * time so RelativeData's percent formatter flows through without a\n * structural rebuild.\n */\nexport function createPieOptionFactory(\n options: PieOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, labelFormatter, optionsOverride, series } = options\n const radius = options.radius ?? DEFAULT_RADIUS\n const selection = options.selection\n // An explicit `[]` (deselected down to zero via chart clicks) is treated\n // the same as no selection: the pie has no bar/histogram-style \"nothing\n // selected\" affordance, so dimming every slice would just look broken —\n // it renders fully active, same as the no-interaction state.\n const selectionSet =\n selection === undefined || selection === null || selection.length === 0\n ? null\n : new Set<string | number>(selection)\n return (option, data, ctx) => {\n if (option == null) {\n const structural = pieOptions({ theme, formatter, labelFormatter })\n return optionsOverride\n ? (mergeOptions(\n structural as unknown as Record<string, unknown>,\n optionsOverride as Partial<Record<string, unknown>>,\n ) as EChartsOption)\n : structural\n }\n\n const seriesArr = Array.isArray(data) ? (data as PieWidgetData) : []\n if (seriesArr.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n if (seriesArr.length > 1) {\n return buildMultiSeriesBarFusion(\n option,\n seriesArr,\n theme,\n series,\n ctx,\n selectionSet,\n )\n }\n return buildSingleSeriesPieFusion(\n option,\n seriesArr,\n theme,\n radius,\n series,\n ctx,\n selectionSet,\n )\n }\n}\n\n/**\n * Single-series donut fusion. Spreads the structural pie series template\n * into per-data series with center/radius/encoding, wires the reactive\n * center-label / tooltip formatters and the per-data palette-aware\n * selection-dim callback.\n */\nfunction buildSingleSeriesPieFusion(\n option: EChartsOption,\n seriesArr: PieWidgetData,\n theme: Theme,\n radius: readonly [string, string],\n series: readonly WidgetSeries[] | undefined,\n ctx: OptionFactoryContext | undefined,\n selectionSet: Set<string | number> | null,\n): EChartsOption {\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n const formatter = ctx?.formatter\n const labelFormatter = ctx?.labelFormatter\n\n // Pie wants `colorBy: 'data'` — each slice draws from the option's\n // `color` palette by data index. But installing an `itemStyle.color`\n // callback disables ECharts' automatic per-data cycling, and\n // `params.color` collapses to the series color (so every slice goes\n // the same color). We re-implement the per-data palette resolution\n // here so the multicolor look survives selection-driven dimming.\n const palette = Array.isArray(option.color)\n ? (option.color as readonly (string | undefined)[])\n : []\n const resolvePaletteColor = (params: CallbackDataParams): string => {\n const swatch =\n palette.length > 0\n ? palette[params.dataIndex % palette.length]\n : undefined\n return swatch ?? (params.color as string)\n }\n\n // Always emit `itemStyle.color` (passthrough when nothing is selected),\n // not conditionally — same anti-stale-callback rationale as bar /\n // histogram. The slice border + width come from the structural\n // template's `itemStyle` and survive via the spread below.\n //\n // `selectionSet` is the *included* set, same direct semantics as\n // bar/histogram/timeseries (no ADR-014 exclusion inversion). Dim a slice\n // when its name is NOT in the set. `selectionSet` is never a non-null\n // empty Set — the collapse above (`selection.length === 0 → null`) rules\n // that out — so there's no \"dim everything\" case here, unlike a widget\n // that gives `[]` its own \"selected down to nothing\" meaning.\n //\n // The base colour is the slice's own `color`, else the template's\n // `itemStyle.color`, else the per-data palette swatch.\n const makeColorFn = (datums: readonly object[], template: unknown) => {\n const baseColor = createItemColorResolver({\n theme,\n datums,\n template,\n fallback: resolvePaletteColor,\n })\n return (params: CallbackDataParams): string => {\n const base = baseColor(params)\n if (!selectionSet) return base\n const datum = params.value as { name?: string | number } | undefined\n const name = datum?.name ?? params.name\n return name != null && selectionSet.has(name)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n }\n }\n\n // ECharts anchors EVERY slice's `position: 'center'` label at the same\n // point, so at most one of them can ever be legible — the donut design\n // leans into that (one KPI inside the ring) and picks a single slice\n // below. A consumer that moves the labels off the centre gives each\n // slice its own anchor (`'outside'` with leader lines is what the PDF\n // export uses, `'inside'` / `'insideTop'` … likewise), and there the\n // single-label rule is simply wrong: every slice must render its own\n // label. Read the position off the structural template, which already\n // carries the consumer's `optionsOverride`.\n const templateLabelPosition = (\n broadcastTemplate as { label?: { position?: unknown } }\n ).label?.position\n const isCenterLabel =\n templateLabelPosition === undefined || templateLabelPosition === 'center'\n\n // Which slice renders the centre value+name: the greatest value among\n // the *included* slices (all of them when there's no active\n // selection), computed locally — no query round-trip. Only that one\n // slice's formatter call returns text; every other slice returns ''\n // so exactly one label ever renders at the shared centre anchor. Only\n // `typeof value === 'number'` participates — if every included slice's\n // value is non-numeric, `centerMaxName` stays `undefined` and no slice\n // matches it in `labelTextFormatter` below, so the chart renders with no\n // centre label at all (graceful no-op, not a crash). Skipped entirely\n // for off-centre labels, where every slice labels itself.\n const centerData = seriesArr[0] ?? []\n let centerMaxName: string | number | undefined\n let centerMaxValue = -Infinity\n for (const d of centerData) {\n if (selectionSet && !selectionSet.has(d.name)) continue\n if (typeof d.value === 'number' && d.value > centerMaxValue) {\n centerMaxValue = d.value\n centerMaxName = d.name\n }\n }\n\n // Slice label formatter — lives in the merger because it reads\n // reactive `formatter` / `labelFormatter` from ctx. The rich tags\n // `{c|…}` and `{b|…}` reference the rich styles baked into the\n // structural label template.\n const labelTextFormatter = (params: CallbackDataParams): string => {\n const { name } = params\n if (name == null) return ''\n if (isCenterLabel && name !== centerMaxName) return ''\n const encodeIndex = params.encode?.value?.[0]\n if (encodeIndex === undefined) return ''\n const value = (Object.values(params.data ?? {}) as unknown[]).at(\n encodeIndex,\n )\n // `value` here is the resolved dataset cell — for pie data it's a\n // `string | number` primitive. Anything else is a misuse we won't\n // dress up with `String(...)` (would render \"[object Object]\").\n const formattedValue =\n typeof value === 'number'\n ? formatter\n ? formatter(value)\n : String(value)\n : typeof value === 'string'\n ? value\n : ''\n const formattedName = labelFormatter\n ? String(labelFormatter(name ?? ''))\n : String(name ?? '')\n // The blank line is what separates the big centre KPI from its\n // caption. Off-centre labels sit next to their own slice and are\n // laid out against their neighbours, so the spacer only inflates\n // each label's bounding box — enough, with a hidden `{b|…}` block,\n // to make ECharts drop colliding labels altogether.\n const separator = isCenterLabel ? '\\n\\n' : '\\n'\n return `{c|${formattedValue}}${separator}{b|${formattedName}}`\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n series: seriesArr.map((s, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n const templateObj = typeof template === 'object' ? template : {}\n const templateLabel = (templateObj as { label?: object }).label ?? {}\n const templateItemStyle =\n (templateObj as { itemStyle?: object }).itemStyle ?? {}\n return {\n ...templateObj,\n type: 'pie' as const,\n legendHoverLink: false,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n radius: [...radius],\n // Lift the donut up so the bottom-anchored legend has the\n // vertical real estate to wrap to multiple rows for long\n // category lists — at exactly `50%` the bottom slices crowd\n // the chips and `type: 'plain'` legends can't expand upward\n // without overlapping the donut.\n center: ['50%', '38%'] as [string, string],\n encode: { itemName: 'name', value: 'value' },\n label: {\n ...templateLabel,\n formatter: labelTextFormatter,\n },\n itemStyle: {\n ...templateItemStyle,\n color: makeColorFn(s, templateObj),\n },\n }\n }),\n // Legend always shows for pie (mirrors v1) — slice names drive the\n // entries, so even a single donut benefits from a category list.\n //\n // Exclusion is conveyed purely via `colorFn`/`labelTextFormatter`\n // dimming above, never via the legend's `selected` map: for a pie\n // series, ECharts treats `legend.selected[name] = false` as \"remove\n // this data point,\" which recomputes every remaining slice's angle —\n // the excluded slice disappears instead of rendering dimmed. Forcing\n // every name to `true` on every render also overrides ECharts' own\n // internal toggle state from a native legend click (which flips a\n // name to `false` and hides it before our `legendselectchanged`\n // handler gets a chance to react), so a legend click never leaves a\n // slice structurally removed — only the color/label dimming reflects\n // exclusion, and it stays in sync with the slice itself since both\n // read `selectionSet` on the same render.\n legend: {\n ...baseLegend,\n show: true,\n selectedMode: false,\n selected: Object.fromEntries(\n (seriesArr[0] ?? []).map((d) => [String(d.name), true]),\n ),\n },\n tooltip: {\n ...baseTooltip,\n formatter: buildPieTooltipFormatter(formatter, labelFormatter),\n },\n }\n}\n\n/**\n * Multi-series horizontal-bar fusion. Mirrors v1 pie's \"pie data with\n * >1 series collapses into a horizontal bar chart\" behavior — side-by-\n * side donuts don't read well when you're comparing the same categories\n * across cohorts, so swap to a value-on-x / category-on-y bar layout.\n *\n * Pie data shape is identical to bar's (`{ name, value }[][]`), so the\n * same dataset feeds either layout without transformation.\n */\nfunction buildMultiSeriesBarFusion(\n option: EChartsOption,\n seriesArr: PieWidgetData,\n theme: Theme,\n series: readonly WidgetSeries[] | undefined,\n ctx: OptionFactoryContext | undefined,\n selectionSet: Set<string | number> | null,\n): EChartsOption {\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n const baseGrid =\n typeof option.grid === 'object' && !Array.isArray(option.grid)\n ? option.grid\n : {}\n const formatter = ctx?.formatter\n const labelFormatter = ctx?.labelFormatter\n\n const { niceMinVal, niceMaxVal } = computeNiceBounds(seriesArr)\n\n // Per-series palette — multi-series bars take one color per series\n // (not per-data, unlike donut slices). Same anti-stale-callback rule:\n // always emit the callback so a transition to/from a selection\n // replaces the previous closure cleanly.\n const palette = Array.isArray(option.color)\n ? (option.color as readonly (string | undefined)[])\n : []\n // The base colour is the datum's own `color`, else the template's\n // `itemStyle.color`, else the per-series palette swatch.\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const paletteColor = (params: CallbackDataParams): string => {\n const seriesIdx = params.seriesIndex ?? 0\n const seriesSwatch =\n palette.length > 0 ? palette[seriesIdx % palette.length] : undefined\n return (seriesSwatch ?? params.color) as string\n }\n const makeBarColorFn = (datums: readonly object[], template: unknown) => {\n const baseColor = createItemColorResolver({\n theme,\n datums,\n template,\n fallback: paletteColor,\n })\n return (params: CallbackDataParams): string => {\n const base = baseColor(params)\n if (!selectionSet) return base\n const datum = params.value as { name?: string | number } | undefined\n const name = datum?.name ?? params.name\n return name != null && selectionSet.has(name)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n }\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n grid: {\n ...baseGrid,\n ...buildGridConfig(true, theme),\n right: parseInt(theme.spacing(4)),\n containLabel: true,\n },\n // Drop pie-specific structural keys that shouldn't render in the\n // bar fallback. ECharts ignores undefined keys, so this is a clean\n // override.\n series: seriesArr.map((s, i) => {\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n datasetIndex: i,\n type: 'bar' as const,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n barMaxWidth: 100,\n legendHoverLink: false,\n emphasis: { focus: 'series' },\n ...buildSeriesLabelConfig(formatter, 'x'),\n itemStyle: {\n color: makeBarColorFn(s, seriesTemplates[i] ?? seriesTemplates[0]),\n },\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n xAxis: {\n type: 'value',\n // Closures over the pre-computed nice bounds — ECharts calls them\n // once per render to resolve the axis extents.\n min: () => niceMinVal,\n max: () => niceMaxVal,\n axisLine: { show: false },\n axisTick: { show: false },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n // Value labels render BELOW the axis line (default placement),\n // NOT inside the plot. Bar/histogram use `inside: true` +\n // `verticalAlign: 'bottom'` for their *vertical* y-axis where the\n // axis is the left wall — labels inside read like grid annotations.\n // A horizontal bar chart's value axis is the x-axis, and `inside`\n // there pushes the max label *behind* the bar (it visually\n // disappears once a bar reaches the right edge). Use the default\n // below-the-axis placement so the rounded extents stay readable.\n axisLabel: {\n fontSize: theme.typography.overlineDelicate?.fontSize,\n fontFamily: theme.typography.overlineDelicate?.fontFamily,\n margin: parseInt(theme.spacing(1)),\n showMaxLabel: true,\n showMinLabel: true,\n formatter: (value: number) => {\n if (value !== niceMaxVal && value !== niceMinVal) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n yAxis: {\n type: 'category',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n ...(labelFormatter && {\n formatter: (value: string | number) => String(labelFormatter(value)),\n }),\n },\n },\n // Mirrors the donut branch's `selected` reset above — `selectedMode:\n // false` blocks the native legend click that would otherwise undo an\n // ECharts-internal toggle, so without forcing every entry back to\n // `true` here a prior native toggle (from before `selectedMode` took\n // effect, or a stale `keepAlive` instance) would stay hidden forever\n // with no way to restore it.\n legend: {\n ...baseLegend,\n show: true,\n selectedMode: false,\n selected: Object.fromEntries(\n seriesArr.map((_, i) => [series?.[i]?.name ?? `Series ${i + 1}`, true]),\n ),\n },\n tooltip: {\n ...baseTooltip,\n trigger: 'axis',\n formatter: buildHorizontalBarTooltipFormatter(formatter, labelFormatter),\n },\n } as EChartsOption\n}\n\n/**\n * Tooltip formatter for the horizontal-bar fallback. Reads the value by\n * `encode.x` dimension index (v1 parity) so it stays robust to\n * downstream changes that rename dataset columns.\n */\nfunction buildHorizontalBarTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: string | number) => string | number) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const encodeIndex = item.encode?.x?.at(0)\n const dimName =\n encodeIndex !== undefined ? item.dimensionNames?.[encodeIndex] : undefined\n const row =\n item.value && typeof item.value === 'object' && !Array.isArray(item.value)\n ? (item.value as Record<string, string | number>)\n : undefined\n const raw = dimName && row ? row[dimName] : undefined\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n const name = labelFormatter\n ? String(labelFormatter(item.name ?? ''))\n : String(item.name ?? '')\n return { name, seriesName, marker, value: formattedValue }\n })\n}\n\n/**\n * Min/max bounds over every datum's `.value` across all series. Used by\n * the horizontal-bar fallback's x-axis label formatter so we only render\n * labels at the rounded extents (matches v1 + bar / histogram).\n */\nfunction computeNiceBounds(seriesArr: PieWidgetData): {\n niceMinVal: number\n niceMaxVal: number\n} {\n let min = 0\n let max = -Infinity\n for (const series of seriesArr) {\n for (const d of series) {\n if (typeof d?.value !== 'number' || !Number.isFinite(d.value)) continue\n if (d.value < min) min = d.value\n if (d.value > max) max = d.value\n }\n }\n return {\n niceMinVal: min < 0 ? niceNum(min) : 0,\n niceMaxVal: max <= 0 ? 1 : niceNum(max),\n }\n}\n\n/**\n * Tooltip formatter for pie slices. `item.value` is the dataset row\n * object (e.g. `{ name: 'A', value: 10 }`); we pull the value by\n * `encode.value`'s dimension index, formatted via the reactive `formatter`\n * if present. Slice name passes through `labelFormatter`.\n */\nfunction buildPieTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: string | number) => string | number) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const encodeIndex = item.encode?.value?.at(0) ?? 1\n const values =\n item.value && typeof item.value === 'object' && !Array.isArray(item.value)\n ? (Object.values(item.value) as (string | number)[])\n : []\n const raw = values[encodeIndex]\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n const name = labelFormatter\n ? String(labelFormatter(item.name ?? ''))\n : String(item.name ?? '')\n return { name, seriesName, marker, value: formattedValue }\n })\n}\n","import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst OUTER_SIZE = 160\nconst HOLE_SIZE = 96\n\nconst styles = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: 200,\n py: 1,\n gap: ({ spacing }) => spacing(2),\n },\n donut: {\n position: 'relative',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n },\n ring: {\n width: OUTER_SIZE,\n height: OUTER_SIZE,\n },\n hole: {\n position: 'absolute',\n zIndex: 1,\n width: HOLE_SIZE,\n height: HOLE_SIZE,\n borderRadius: '50%',\n bgcolor: 'background.paper',\n },\n label: {\n position: 'absolute',\n zIndex: 2,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: ({ spacing }) => spacing(0.5),\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\nexport interface PieSkeletonProps {\n count?: number\n}\n\n/**\n * Loading state for the Pie widget. Mirrors the donut silhouette — a ring\n * (gray circle with a background-coloured hole punched out), a stacked\n * value/name stub in the centre, and a centered legend stub below — so the\n * skeleton reads as \"a donut chart\" rather than a solid disc.\n *\n * Single donut only: multi-series pie loads as a horizontal bar chart, so\n * rendering one ring stays honest regardless of `count`.\n */\nexport function PieSkeleton({ count }: PieSkeletonProps) {\n // `count` is accepted for API compatibility but intentionally unused: the\n // skeleton always renders a single donut, since multi-series pie loads as a\n // horizontal bar chart rather than multiple donuts.\n void count\n return (\n <Box sx={styles.root}>\n <Box sx={styles.donut}>\n <Skeleton variant='circular' sx={styles.ring} />\n <Box sx={styles.hole} />\n <Box sx={styles.label}>\n <Skeleton width={56} height={18} />\n <Skeleton width={36} height={8} />\n </Box>\n </Box>\n <Box sx={styles.legend}>\n {[0, 1].map((i) => (\n <Box key={`legend-${i}`} sx={styles.legendItem}>\n <Skeleton variant='circular' width={8} height={8} />\n <Skeleton width={48} height={8} />\n </Box>\n ))}\n </Box>\n </Box>\n )\n}\n","import {\n buildCsvDownloadItem,\n buildPngDownloadItem,\n type DownloadContext,\n type DownloadItem,\n} from '../actions/download'\nimport type { PieWidgetData } from './types'\n\n/**\n * Download menu items for the Pie widget. Always includes a CSV item with\n * `series, name, value` columns (one row per slice; series labels come from\n * `seriesNames` if provided, else `series_<n>`). When `getCaptureEl` is\n * supplied, prepends a PNG item that rasterises the captured element via\n * `html2canvas`.\n */\nexport function createPieDownloadConfig(args: {\n filename: string\n getData: (ctx: DownloadContext) => PieWidgetData\n seriesNames?: readonly string[]\n getCaptureEl?: (ctx: DownloadContext) => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push(\n buildCsvDownloadItem({\n filename: args.filename,\n getRows: (ctx) => {\n const data = args.getData(ctx)\n const rows: unknown[][] = [['series', 'name', 'value']]\n for (const [i, series] of data.entries()) {\n const seriesName = args.seriesNames?.[i] ?? `series_${i + 1}`\n for (const slice of series) {\n rows.push([seriesName, slice.name, slice.value])\n }\n }\n return rows\n },\n }),\n )\n return items\n}\n"],"mappings":";;;;;;;;;AAuBA,IAAMoB,IAA4C,CAAC,OAAO,KAAK;AAiB/D,SAAgBC,EAAW,EACzBC,UACAC,cACAC,qBACoC;CACpC,OAAO;EACLC,QAAQ;GACN,GAAGpB,EAAkB;IAAEqB,WAAW;IAAMF;GAAe,CAAC;GAIxDG,MAAM;GACNC,SAAS;GAOTC,cAAc;EAChB;EACAC,SAAS;GAKPC,SAAS;GACTC,iBAAiBV,EAAMW,QAAQC,KAAK;GACpCC,aAAa;GACbC,SAAS,CAACC,SAASf,EAAMgB,QAAQ,CAAC,CAAC,GAAGD,SAASf,EAAMgB,QAAQ,CAAC,CAAC,CAAC;GAChEC,WAAW;IACTC,OAAOlB,EAAMW,QA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