@carto/ps-react-ui 6.4.0 → 6.5.1

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 (93) hide show
  1. package/dist/{actions-DyWNwvLu.js → actions-D_PVFZaM.js} +4 -4
  2. package/dist/{actions-DyWNwvLu.js.map → actions-D_PVFZaM.js.map} +1 -1
  3. package/dist/{category-BHBd5Pcc.js → category-UIGvFN3D.js} +4 -4
  4. package/dist/{category-BHBd5Pcc.js.map → category-UIGvFN3D.js.map} +1 -1
  5. package/dist/chat.js +472 -470
  6. package/dist/chat.js.map +1 -1
  7. package/dist/{components-CTUpdQuj.js → components-DDJU4m0t.js} +8 -8
  8. package/dist/components-DDJU4m0t.js.map +1 -0
  9. package/dist/components.js +2 -2
  10. package/dist/{download-B4sykOFm.js → download-DIj1Iz0t.js} +2 -2
  11. package/dist/{download-B4sykOFm.js.map → download-DIj1Iz0t.js.map} +1 -1
  12. package/dist/{formula-DJS-JLpk.js → formula-CSHhAoyW.js} +4 -4
  13. package/dist/{formula-DJS-JLpk.js.map → formula-CSHhAoyW.js.map} +1 -1
  14. package/dist/{item-color-B7xkIpDZ.js → item-color-7o7pFBR2.js} +26 -18
  15. package/dist/item-color-7o7pFBR2.js.map +1 -0
  16. package/dist/markdown-B8lLR-NY.js +106 -0
  17. package/dist/markdown-B8lLR-NY.js.map +1 -0
  18. package/dist/{spread-CQwFIwuz.js → spread-BRfPPIep.js} +3 -3
  19. package/dist/{spread-CQwFIwuz.js.map → spread-BRfPPIep.js.map} +1 -1
  20. package/dist/style-DTLuIo84.js +87 -0
  21. package/dist/style-DTLuIo84.js.map +1 -0
  22. package/dist/{styles-BCEBm7xh.js → styles-yKcpfyNV.js} +5 -5
  23. package/dist/styles-yKcpfyNV.js.map +1 -0
  24. package/dist/{table-DEdW_fDj.js → table-Col_FRvb.js} +2 -2
  25. package/dist/{table-DEdW_fDj.js.map → table-Col_FRvb.js.map} +1 -1
  26. package/dist/theme/tailwind.css +373 -0
  27. package/dist/theme.js +123 -0
  28. package/dist/theme.js.map +1 -0
  29. package/dist/types/components/lasso-tool/styles.d.ts +4 -4
  30. package/dist/types/theme/create-carto-theme.d.ts +7 -0
  31. package/dist/types/theme/deep-merge.d.ts +6 -0
  32. package/dist/types/theme/generate-tailwind-css.d.ts +8 -0
  33. package/dist/types/theme/index.d.ts +2 -0
  34. package/dist/types/widgets/markdown/style.d.ts +74 -0
  35. package/dist/types/widgets/utils/spacing-px.d.ts +13 -0
  36. package/dist/types/widgets/wrapper/collapsed-context.d.ts +7 -0
  37. package/dist/{utils-C-eWwOhE.js → utils-Dw4y8tiq.js} +2 -2
  38. package/dist/{utils-C-eWwOhE.js.map → utils-Dw4y8tiq.js.map} +1 -1
  39. package/dist/widgets/actions.js +3 -3
  40. package/dist/widgets/bar.js +54 -54
  41. package/dist/widgets/bar.js.map +1 -1
  42. package/dist/widgets/category.js +1 -1
  43. package/dist/widgets/formula.js +1 -1
  44. package/dist/widgets/histogram.js +70 -70
  45. package/dist/widgets/histogram.js.map +1 -1
  46. package/dist/widgets/markdown.js +1 -1
  47. package/dist/widgets/pie.js +78 -78
  48. package/dist/widgets/pie.js.map +1 -1
  49. package/dist/widgets/scatterplot.js +82 -82
  50. package/dist/widgets/scatterplot.js.map +1 -1
  51. package/dist/widgets/spread.js +1 -1
  52. package/dist/widgets/table.js +1 -1
  53. package/dist/widgets/timeseries.js +62 -62
  54. package/dist/widgets/timeseries.js.map +1 -1
  55. package/dist/widgets/utils.js +1 -1
  56. package/dist/widgets.js +309 -299
  57. package/dist/widgets.js.map +1 -1
  58. package/dist/{zoom-toggle-MmLjMTEw.js → zoom-toggle-DqrV_0Ji.js} +2 -2
  59. package/dist/{zoom-toggle-MmLjMTEw.js.map → zoom-toggle-DqrV_0Ji.js.map} +1 -1
  60. package/package.json +10 -3
  61. package/src/chat/bubbles/styles.ts +2 -0
  62. package/src/components/lasso-tool/lasso-tool-inline.test.tsx +4 -4
  63. package/src/components/lasso-tool/lasso-tool-inline.tsx +6 -6
  64. package/src/components/lasso-tool/styles.ts +4 -4
  65. package/src/theme/create-carto-theme.test.ts +53 -0
  66. package/src/theme/create-carto-theme.ts +21 -0
  67. package/src/theme/deep-merge.test.ts +25 -0
  68. package/src/theme/deep-merge.ts +22 -0
  69. package/src/theme/generate-tailwind-css.test.ts +87 -0
  70. package/src/theme/generate-tailwind-css.ts +178 -0
  71. package/src/theme/index.ts +2 -0
  72. package/src/theme/tailwind-compile.test.ts +71 -0
  73. package/src/theme/tailwind.css +373 -0
  74. package/src/widgets/bar/options.ts +7 -6
  75. package/src/widgets/histogram/options.ts +7 -6
  76. package/src/widgets/markdown/style.ts +40 -0
  77. package/src/widgets/note/widget-note.tsx +4 -1
  78. package/src/widgets/pie/options.ts +5 -4
  79. package/src/widgets/scatterplot/options.ts +7 -6
  80. package/src/widgets/timeseries/options.ts +7 -6
  81. package/src/widgets/toolbox/toolbox.test.tsx +28 -0
  82. package/src/widgets/toolbox/toolbox.tsx +9 -0
  83. package/src/widgets/utils/css-variables-theme.test.ts +32 -0
  84. package/src/widgets/utils/option-builders.ts +4 -6
  85. package/src/widgets/utils/spacing-px.test.ts +42 -0
  86. package/src/widgets/utils/spacing-px.ts +24 -0
  87. package/src/widgets/wrapper/collapsed-context.ts +12 -0
  88. package/src/widgets/wrapper/widget-wrapper.tsx +6 -1
  89. package/dist/components-CTUpdQuj.js.map +0 -1
  90. package/dist/item-color-B7xkIpDZ.js.map +0 -1
  91. package/dist/markdown-DmvLi3vx.js +0 -159
  92. package/dist/markdown-DmvLi3vx.js.map +0 -1
  93. package/dist/styles-BCEBm7xh.js.map +0 -1
@@ -1,13 +1,13 @@
1
- import { n as e, t } from "../download-B4sykOFm.js";
2
- import { r as n, t as r } from "../utils-C-eWwOhE.js";
3
- import { a as i, c as a, i as o, o as s, r as c, s as l, t as u } from "../item-color-B7xkIpDZ.js";
4
- import { c as d } from "react/compiler-runtime";
5
- import { Box as f, Skeleton as p } from "@mui/material";
6
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
7
- import * as g from "echarts";
1
+ import { n as e, t } from "../download-DIj1Iz0t.js";
2
+ import { r as n, t as r } from "../utils-Dw4y8tiq.js";
3
+ import { a as i, c as a, i as o, l as s, o as c, r as l, s as u, t as d } from "../item-color-7o7pFBR2.js";
4
+ import { c as f } from "react/compiler-runtime";
5
+ import { Box as p, Skeleton as m } from "@mui/material";
6
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
7
+ import * as _ from "echarts";
8
8
  //#region src/widgets/pie/options.ts
9
- var _ = ["58%", "74%"];
10
- function v({ theme: e, formatter: t, labelFormatter: n }) {
9
+ var v = ["58%", "74%"];
10
+ function y({ theme: e, formatter: t, labelFormatter: n }) {
11
11
  return {
12
12
  legend: {
13
13
  ...o({
@@ -22,14 +22,14 @@ function v({ theme: e, formatter: t, labelFormatter: n }) {
22
22
  trigger: "item",
23
23
  backgroundColor: e.palette.grey[900],
24
24
  borderWidth: 0,
25
- padding: [parseInt(e.spacing(1)), parseInt(e.spacing(1))],
25
+ padding: [s(e, 1), s(e, 1)],
26
26
  textStyle: {
27
27
  color: e.palette.common.white,
28
28
  fontSize: 11,
29
29
  fontFamily: e.typography.caption.fontFamily
30
30
  },
31
- position: l(e),
32
- formatter: w(t, n)
31
+ position: u(e),
32
+ formatter: T(t, n)
33
33
  },
34
34
  color: Object.values(e.palette.qualitative?.bold ?? {}),
35
35
  series: [{
@@ -62,11 +62,11 @@ function v({ theme: e, formatter: t, labelFormatter: n }) {
62
62
  }]
63
63
  };
64
64
  }
65
- function y(e) {
66
- 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);
65
+ function b(e) {
66
+ let { theme: t, formatter: r, labelFormatter: i, optionsOverride: a, series: o } = e, s = e.radius ?? v, c = e.selection, l = c == null || c.length === 0 ? null : new Set(c);
67
67
  return (e, c, u) => {
68
68
  if (e == null) {
69
- let e = v({
69
+ let e = y({
70
70
  theme: t,
71
71
  formatter: r,
72
72
  labelFormatter: i
@@ -78,12 +78,12 @@ function y(e) {
78
78
  ...e,
79
79
  dataset: [],
80
80
  series: []
81
- } : d.length > 1 ? x(e, d, t, o, u, l) : b(e, d, t, s, o, u, l);
81
+ } : d.length > 1 ? S(e, d, t, o, u, l) : x(e, d, t, s, o, u, l);
82
82
  };
83
83
  }
84
- function b(e, t, n, r, i, a, o) {
85
- 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) => {
86
- let r = u({
84
+ function x(e, t, n, r, i, a, o) {
85
+ let s = Array.isArray(e.series) ? e.series : [], c = s[0] ?? {}, l = typeof e.tooltip == "object" && !Array.isArray(e.tooltip) ? e.tooltip : {}, u = 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, g = (e, t) => {
86
+ let r = d({
87
87
  theme: n,
88
88
  datums: e,
89
89
  template: t,
@@ -93,7 +93,7 @@ function b(e, t, n, r, i, a, o) {
93
93
  let t = r(e);
94
94
  if (!o) return t;
95
95
  let n = e.value?.name ?? e.name;
96
- return n != null && o.has(n) ? t : g.color.modifyAlpha(t, .15);
96
+ return n != null && o.has(n) ? t : _.color.modifyAlpha(t, .15);
97
97
  };
98
98
  }, v = c.label?.position, y = v === void 0 || v === "center", b = t[0] ?? [], x, S = -Infinity;
99
99
  for (let e of b) (!o || o.has(e.name)) && typeof e.value == "number" && e.value > S && (S = e.value, x = e.name);
@@ -128,47 +128,47 @@ function b(e, t, n, r, i, a, o) {
128
128
  },
129
129
  itemStyle: {
130
130
  ...l,
131
- color: _(e, a)
131
+ color: g(e, a)
132
132
  }
133
133
  };
134
134
  }),
135
135
  legend: {
136
- ...d,
136
+ ...u,
137
137
  show: !0,
138
138
  selectedMode: !1,
139
139
  selected: Object.fromEntries((t[0] ?? []).map((e) => [String(e.name), !0]))
140
140
  },
141
141
  tooltip: {
142
142
  ...l,
143
- formatter: w(f, p)
143
+ formatter: T(f, p)
144
144
  }
145
145
  };
146
146
  }
147
- function x(e, t, n, a, o, s) {
148
- 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 = o?.formatter, m = o?.labelFormatter, { niceMinVal: h, niceMaxVal: _ } = C(t), v = Array.isArray(e.color) ? e.color : [], y = Array.isArray(e.series) ? e.series : [], b = (e) => {
147
+ function S(e, t, n, a, o, c) {
148
+ let u = typeof e.tooltip == "object" && !Array.isArray(e.tooltip) ? e.tooltip : {}, f = typeof e.legend == "object" && !Array.isArray(e.legend) ? e.legend : {}, p = typeof e.grid == "object" && !Array.isArray(e.grid) ? e.grid : {}, m = o?.formatter, h = o?.labelFormatter, { niceMinVal: g, niceMaxVal: v } = w(t), y = Array.isArray(e.color) ? e.color : [], b = Array.isArray(e.series) ? e.series : [], x = (e) => {
149
149
  let t = e.seriesIndex ?? 0;
150
- return (v.length > 0 ? v[t % v.length] : void 0) ?? e.color;
151
- }, x = (e, t) => {
152
- let r = u({
150
+ return (y.length > 0 ? y[t % y.length] : void 0) ?? e.color;
151
+ }, S = (e, t) => {
152
+ let r = d({
153
153
  theme: n,
154
154
  datums: e,
155
155
  template: t,
156
- fallback: b
156
+ fallback: x
157
157
  });
158
158
  return (e) => {
159
159
  let t = r(e);
160
- if (!s) return t;
160
+ if (!c) return t;
161
161
  let n = e.value?.name ?? e.name;
162
- return n != null && s.has(n) ? t : g.color.modifyAlpha(t, .15);
162
+ return n != null && c.has(n) ? t : _.color.modifyAlpha(t, .15);
163
163
  };
164
164
  };
165
165
  return {
166
166
  ...e,
167
167
  dataset: t.map((e) => ({ source: e })),
168
168
  grid: {
169
- ...f,
170
- ...c(!0, n),
171
- right: parseInt(n.spacing(4)),
169
+ ...p,
170
+ ...l(!0, n),
171
+ right: s(n, 4),
172
172
  containLabel: !0
173
173
  },
174
174
  series: t.map((e, t) => {
@@ -180,15 +180,15 @@ function x(e, t, n, a, o, s) {
180
180
  barMaxWidth: 100,
181
181
  legendHoverLink: !1,
182
182
  emphasis: { focus: "series" },
183
- ...i(p, "x"),
184
- itemStyle: { color: x(e, y[t] ?? y[0]) },
183
+ ...i(m, "x"),
184
+ itemStyle: { color: S(e, b[t] ?? b[0]) },
185
185
  ...o ? { color: o } : {}
186
186
  };
187
187
  }),
188
188
  xAxis: {
189
189
  type: "value",
190
- min: () => h,
191
- max: () => _,
190
+ min: () => g,
191
+ max: () => v,
192
192
  axisLine: { show: !1 },
193
193
  axisTick: { show: !1 },
194
194
  splitLine: {
@@ -198,10 +198,10 @@ function x(e, t, n, a, o, s) {
198
198
  axisLabel: {
199
199
  fontSize: n.typography.overlineDelicate?.fontSize,
200
200
  fontFamily: n.typography.overlineDelicate?.fontFamily,
201
- margin: parseInt(n.spacing(1)),
201
+ margin: s(n, 1),
202
202
  showMaxLabel: !0,
203
203
  showMinLabel: !0,
204
- formatter: (e) => e !== _ && e !== h || e === 0 ? "" : p ? p(e) : String(e)
204
+ formatter: (e) => e !== v && e !== g || e === 0 ? "" : m ? m(e) : String(e)
205
205
  }
206
206
  },
207
207
  yAxis: {
@@ -210,29 +210,29 @@ function x(e, t, n, a, o, s) {
210
210
  axisTick: { show: !1 },
211
211
  axisLabel: {
212
212
  padding: [
213
- parseInt(n.spacing(.5)),
213
+ s(n, .5),
214
214
  0,
215
215
  0,
216
216
  0
217
217
  ],
218
- ...m && { formatter: (e) => String(m(e)) }
218
+ ...h && { formatter: (e) => String(h(e)) }
219
219
  }
220
220
  },
221
221
  legend: {
222
- ...d,
222
+ ...f,
223
223
  show: !0,
224
224
  selectedMode: !1,
225
225
  selected: Object.fromEntries(t.map((e, t) => [a?.[t]?.name ?? `Series ${t + 1}`, !0]))
226
226
  },
227
227
  tooltip: {
228
- ...l,
228
+ ...u,
229
229
  trigger: "axis",
230
- formatter: S(p, m)
230
+ formatter: C(m, h)
231
231
  }
232
232
  };
233
233
  }
234
- function S(e, t) {
235
- return s((n) => {
234
+ function C(e, t) {
235
+ return c((n) => {
236
236
  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}: ` : "";
237
237
  return {
238
238
  name: String(t ? t(n.name ?? "") : n.name ?? ""),
@@ -242,7 +242,7 @@ function S(e, t) {
242
242
  };
243
243
  });
244
244
  }
245
- function C(e) {
245
+ function w(e) {
246
246
  let t = 0, n = -Infinity;
247
247
  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));
248
248
  return {
@@ -250,8 +250,8 @@ function C(e) {
250
250
  niceMaxVal: n <= 0 ? 1 : a(n)
251
251
  };
252
252
  }
253
- function w(e, t) {
254
- return s((n) => {
253
+ function T(e, t) {
254
+ return c((n) => {
255
255
  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}: ` : "";
256
256
  return {
257
257
  name: String(t ? t(n.name ?? "") : n.name ?? ""),
@@ -263,7 +263,7 @@ function w(e, t) {
263
263
  }
264
264
  //#endregion
265
265
  //#region src/widgets/pie/skeleton.tsx
266
- var T = 160, E = 96, D = {
266
+ var E = 160, D = 96, O = {
267
267
  root: {
268
268
  display: "flex",
269
269
  flexDirection: "column",
@@ -280,14 +280,14 @@ var T = 160, E = 96, D = {
280
280
  justifyContent: "center"
281
281
  },
282
282
  ring: {
283
- width: T,
284
- height: T
283
+ width: E,
284
+ height: E
285
285
  },
286
286
  hole: {
287
287
  position: "absolute",
288
288
  zIndex: 1,
289
- width: E,
290
- height: E,
289
+ width: D,
290
+ height: D,
291
291
  borderRadius: "50%",
292
292
  bgcolor: "background.paper"
293
293
  },
@@ -311,24 +311,24 @@ var T = 160, E = 96, D = {
311
311
  gap: ({ spacing: e }) => e(1.5)
312
312
  }
313
313
  };
314
- function O(e) {
315
- let t = d(4), n, r;
316
- t[0] === Symbol.for("react.memo_cache_sentinel") ? (n = /* @__PURE__ */ m(p, {
314
+ function k(e) {
315
+ let t = f(4), n, r;
316
+ t[0] === Symbol.for("react.memo_cache_sentinel") ? (n = /* @__PURE__ */ h(m, {
317
317
  variant: "circular",
318
- sx: D.ring
319
- }), r = /* @__PURE__ */ m(f, { sx: D.hole }), t[0] = n, t[1] = r) : (n = t[0], r = t[1]);
318
+ sx: O.ring
319
+ }), r = /* @__PURE__ */ h(p, { sx: O.hole }), t[0] = n, t[1] = r) : (n = t[0], r = t[1]);
320
320
  let i;
321
- t[2] === Symbol.for("react.memo_cache_sentinel") ? (i = /* @__PURE__ */ h(f, {
322
- sx: D.donut,
321
+ t[2] === Symbol.for("react.memo_cache_sentinel") ? (i = /* @__PURE__ */ g(p, {
322
+ sx: O.donut,
323
323
  children: [
324
324
  n,
325
325
  r,
326
- /* @__PURE__ */ h(f, {
327
- sx: D.label,
328
- children: [/* @__PURE__ */ m(p, {
326
+ /* @__PURE__ */ g(p, {
327
+ sx: O.label,
328
+ children: [/* @__PURE__ */ h(m, {
329
329
  width: 56,
330
330
  height: 18
331
- }), /* @__PURE__ */ m(p, {
331
+ }), /* @__PURE__ */ h(m, {
332
332
  width: 36,
333
333
  height: 8
334
334
  })]
@@ -336,22 +336,22 @@ function O(e) {
336
336
  ]
337
337
  }), t[2] = i) : i = t[2];
338
338
  let a;
339
- return t[3] === Symbol.for("react.memo_cache_sentinel") ? (a = /* @__PURE__ */ h(f, {
340
- sx: D.root,
341
- children: [i, /* @__PURE__ */ m(f, {
342
- sx: D.legend,
343
- children: [0, 1].map(k)
339
+ return t[3] === Symbol.for("react.memo_cache_sentinel") ? (a = /* @__PURE__ */ g(p, {
340
+ sx: O.root,
341
+ children: [i, /* @__PURE__ */ h(p, {
342
+ sx: O.legend,
343
+ children: [0, 1].map(A)
344
344
  })]
345
345
  }), t[3] = a) : a = t[3], a;
346
346
  }
347
- function k(e) {
348
- return /* @__PURE__ */ h(f, {
349
- sx: D.legendItem,
350
- children: [/* @__PURE__ */ m(p, {
347
+ function A(e) {
348
+ return /* @__PURE__ */ g(p, {
349
+ sx: O.legendItem,
350
+ children: [/* @__PURE__ */ h(m, {
351
351
  variant: "circular",
352
352
  width: 8,
353
353
  height: 8
354
- }), /* @__PURE__ */ m(p, {
354
+ }), /* @__PURE__ */ h(m, {
355
355
  width: 48,
356
356
  height: 8
357
357
  })]
@@ -359,7 +359,7 @@ function k(e) {
359
359
  }
360
360
  //#endregion
361
361
  //#region src/widgets/pie/download.ts
362
- function A(n) {
362
+ function j(n) {
363
363
  return t(n, e({
364
364
  filename: n.filename,
365
365
  getRows: (e) => {
@@ -381,6 +381,6 @@ function A(n) {
381
381
  }));
382
382
  }
383
383
  //#endregion
384
- export { O as PieSkeleton, A as createPieDownloadConfig, y as createPieOptionFactory, v as pieOptions };
384
+ export { k as PieSkeleton, j as createPieDownloadConfig, b as createPieOptionFactory, y as pieOptions };
385
385
 
386
386
  //# sourceMappingURL=pie.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pie.js","names":["<Skeleton variant='circular' sx={styles.ring} />","<Box sx={styles.hole} />","<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>","<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>","(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 )","_c","buildCsvDownloadItem","mergeOptions","resolveThemeColor","buildSeriesLabelConfig","niceNum","buildLegendConfig","createTooltipFormatter","buildGridConfig","createTooltipPositioner","createItemColorResolver","echarts","DEFAULT_RADIUS","pieOptions","theme","buildPieTooltipFormatter","formatter","labelFormatter","createPieOptionFactory","options","radius","selection","selectionSet","option","structural","optionsOverride","seriesArr","data","buildMultiSeriesBarFusion","series","ctx","buildSingleSeriesPieFusion","seriesTemplates","broadcastTemplate","baseTooltip","baseLegend","palette","resolvePaletteColor","params","makeColorFn","baseColor","base","name","templateLabelPosition","isCenterLabel","centerData","centerMaxName","centerMaxValue","d","labelTextFormatter","encodeIndex","value","formattedValue","formattedName","s","template","i","templateObj","templateLabel","templateItemStyle","baseGrid","computeNiceBounds","paletteColor","seriesIdx","makeBarColorFn","overrideColor","niceMinVal","niceMaxVal","buildHorizontalBarTooltipFormatter","item","dimName","row","raw","marker","seriesName","min","max","OUTER_SIZE","HOLE_SIZE","styles","spacing","PieSkeleton","$","c","t1","t2","Skeleton","Box","t3","t4","_temp","createPieDownloadConfig","withPngItem","args","rows","slice"],"sources":["../../src/widgets/pie/options.ts","../../src/widgets/pie/skeleton.tsx","../../src/widgets/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 '../utils/option-builders'\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 withPngItem,\n type DownloadItem,\n type WidgetDownloadArgs,\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 * given, prepends a PNG item that rasterises the captured element via\n * `html2canvas`.\n */\nexport function createPieDownloadConfig(\n args: WidgetDownloadArgs<PieWidgetData> & {\n seriesNames?: readonly string[]\n },\n): DownloadItem[] {\n return withPngItem(\n args,\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}\n"],"mappings":";;;;;;;;AAuBA,IAAMiB,IAA4C,CAAC,OAAO,KAAK;AAiB/D,SAAgBC,EAAW,EACzB,UACA,cACA,qBACoC;CACpC,OAAO;EACL,QAAQ;GACN,GAAGP,EAAkB;IAAE,WAAW;IAAM;GAAe,CAAC;GAIxD,MAAM;GACN,SAAS;GAOT,cAAc;EAChB;EACA,SAAS;GAKP,SAAS;GACT,iBAAiBQ,EAAM,QAAQ,KAAK;GACpC,aAAa;GACb,SAAS,CAAC,SAASA,EAAM,QAAQ,CAAC,CAAC,GAAG,SAASA,EAAM,QAAQ,CAAC,CAAC,CAAC;GAChE,WAAW;IACT,OAAOA,EAAM,QAAQ,OAAO;IAC5B,UAAU;IACV,YAAYA,EAAM,WAAW,QAAQ;GACvC;GACA,UAAUL,EAAwBK,CAAK;GACvC,WAAWC,EAAyBC,GAAWC,CAAc;EAC/D;EAIA,OAAO,OAAO,OACXH,EAAM,QACJ,aAAa,QAAQ,CAAC,CAC3B;EAIA,QAAQ,CACN;GACE,MAAM;GACN,SAAS;GACT,mBAAmB;GACnB,gBAAgB;GAChB,iBAAiB;GACjB,UAAU,EAAE,UAAU,GAAK;GAC3B,WAAW;IACT,aAAaA,EAAM,QAAQ,WAAW;IACtC,aAAa;GACf;GACA,OAAO;IACL,MAAM;IACN,UAAU;IACV,MAAM;KACJ,GAAG;MAAE,UAAU;MAAI,YAAY;M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AAO;KAAI,QAAQ;IAAI,CAAA,CAC9B;;EACF;;CARPxF,IAAAA;CADF,2DACG,IAAA,kBAAAyF,GAAD;EAAK,IAAIR,EAAO;EAAhB,UAAA,CACElF,GAQA,kBAAC0F,GAAD;GAAK,IAAIR,EAAO;GACb,UAAA,CAAC,GAAG,CAAC,CAAC,CAAC,IAAIhF,CAKX;EACE,CAAA,CACF;2BAjBLD;AAmBJ;AAToB,SAAA4F,EAAC,GAAA;CACX,OAAA,kBAACH,GAAD;EAAyB,IAAIR,EAAO;EAApC,UAAA,CACE,kBAACO,GAAD;GAAU,SAAQ;GAAW,OAAO;GAAG,QAAQ;EAAI,CAAA,GACnD,kBAACA,GAAD;GAAU,OAAO;GAAI,QAAQ;EAAI,CAAA,CAC9B;CAHK,GAAA,UAAU9B,GAGf;;;;ACzEf,SAAgBmC,EACd,GAGgB;CAChB,OAAOC,EACLC,GACA5F,EAAqB;EACnB,UAAU4F,EAAK;EACf,UAAU,MAAQ;GAChB,IAAMlE,IAAOkE,EAAK,QAAQ/D,CAAG,GACvBgE,IAAoB,CAAC;IAAC;IAAU;IAAQ;GAAO,CAAC;GACtD,KAAK,IAAM,CAACtC,GAAG3B,MAAWF,EAAK,QAAQ,GAAG;IACxC,IAAM+C,IAAamB,EAAK,cAAcrC,MAAM,UAAUA,IAAI;IAC1D,KAAK,IAAMuC,KAASlE,GAClB,EAAK,KAAK;KAAC6C;KAAYqB,EAAM;KAAMA,EAAM;IAAK,CAAC;GAEnD;GACA,OAAOD;EACT;CACF,CAAC,CACH;AACF"}
1
+ {"version":3,"file":"pie.js","names":["<Skeleton variant='circular' sx={styles.ring} />","<Box sx={styles.hole} />","<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>","<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>","(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 )","_c","buildCsvDownloadItem","mergeOptions","resolveThemeColor","buildSeriesLabelConfig","niceNum","buildLegendConfig","spacingPx","createTooltipFormatter","buildGridConfig","createTooltipPositioner","createItemColorResolver","echarts","DEFAULT_RADIUS","pieOptions","theme","buildPieTooltipFormatter","formatter","labelFormatter","createPieOptionFactory","options","radius","selection","selectionSet","option","structural","optionsOverride","seriesArr","data","buildMultiSeriesBarFusion","series","ctx","buildSingleSeriesPieFusion","seriesTemplates","broadcastTemplate","baseTooltip","baseLegend","palette","resolvePaletteColor","params","makeColorFn","baseColor","base","name","templateLabelPosition","isCenterLabel","centerData","centerMaxName","centerMaxValue","d","labelTextFormatter","encodeIndex","value","formattedValue","formattedName","s","template","i","templateObj","templateLabel","templateItemStyle","baseGrid","computeNiceBounds","paletteColor","seriesIdx","makeBarColorFn","overrideColor","niceMinVal","niceMaxVal","buildHorizontalBarTooltipFormatter","item","dimName","row","raw","marker","seriesName","min","max","OUTER_SIZE","HOLE_SIZE","styles","spacing","PieSkeleton","$","c","t1","t2","Skeleton","Box","t3","t4","_temp","createPieDownloadConfig","withPngItem","args","rows","slice"],"sources":["../../src/widgets/pie/options.ts","../../src/widgets/pie/skeleton.tsx","../../src/widgets/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 '../utils/option-builders'\nimport type { OptionFactory, OptionFactoryContext } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport { spacingPx } from '../utils/spacing-px'\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: [spacingPx(theme, 1), spacingPx(theme, 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: spacingPx(theme, 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: spacingPx(theme, 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: [spacingPx(theme, 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 withPngItem,\n type DownloadItem,\n type WidgetDownloadArgs,\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 * given, prepends a PNG item that rasterises the captured element via\n * `html2canvas`.\n */\nexport function createPieDownloadConfig(\n args: WidgetDownloadArgs<PieWidgetData> & {\n seriesNames?: readonly string[]\n },\n): DownloadItem[] {\n return withPngItem(\n args,\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}\n"],"mappings":";;;;;;;;AAwBA,IAAMkB,IAA4C,CAAC,OAAO,KAAK;AAiB/D,SAAgBC,EAAW,EACzB,UACA,cACA,qBACoC;CACpC,OAAO;EACL,QAAQ;GACN,GAAGR,EAAkB;IAAE,WAAW;IAAM;GAAe,CAAC;GAIxD,MAAM;GACN,SAAS;GAOT,cAAc;EAChB;EACA,SAAS;GAKP,SAAS;GACT,iBAAiBS,EAAM,QAAQ,KAAK;GACpC,aAAa;GACb,SAAS,CAACR,EAAUQ,GAAO,CAAC,GAAGR,EAAUQ,GAAO,CAAC,CAAC;GAClD,WAAW;IACT,OAAOA,EAAM,QAAQ,OAAO;IAC5B,UAAU;IACV,YAAYA,EAAM,WAAW,QAAQ;GACvC;GACA,UAAUL,EAAwBK,CAAK;GACvC,WAAWC,EAAyBC,GAAWC,CAAc;EAC/D;EAIA,OAAO,OAAO,OACXH,EAAM,QACJ,aAAa,QAAQ,CAAC,CAC3B;EAIA,QAAQ,CACN;GACE,MAAM;GACN,SAAS;GACT,mBAAmB;GACnB,gBAAgB;GAChB,iBAAiB;GACjB,UAAU,EAAE,UAAU,GAAK;GAC3B,WAAW;IACT,aAAaA,EAAM,QAAQ,WAAW;IACtC,aAAa;GACf;GACA,OAAO;IACL,MAAM;IACN,UAAU;IACV,MAAM;KACJ,GAAG;MAAE,UAAU;MAAI,YAAY;MAAU,YAAY;KAAG;KACxD,GAAG;MAAE,UAAU;MAAI,YAAY;MAAQ,YAAY;KAAG;IACxD;GACF;EACF,CACF;CACF;AACF;AAkBA,SAAgBI,EACd,GACe;CACf,IAAM,EAAE,UAAO,cAAW,mBAAgB,oBAAiB,cAAWC,GAChEC,I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