@carto/ps-react-ui 6.2.0 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/{actions-CueYrfVr.js → actions-CkxKe8-J.js} +56 -46
  2. package/dist/actions-CkxKe8-J.js.map +1 -0
  3. package/dist/{option-builders-DQivvvbb.js → item-color-B7xkIpDZ.js} +26 -9
  4. package/dist/item-color-B7xkIpDZ.js.map +1 -0
  5. package/dist/types/widgets/bar/types.d.ts +6 -0
  6. package/dist/types/widgets/histogram/bins.d.ts +7 -0
  7. package/dist/types/widgets/histogram/download.d.ts +2 -2
  8. package/dist/types/widgets/histogram/index.d.ts +2 -1
  9. package/dist/types/widgets/histogram/options.d.ts +1 -1
  10. package/dist/types/widgets/histogram/transforms.d.ts +5 -4
  11. package/dist/types/widgets/histogram/types.d.ts +22 -5
  12. package/dist/types/widgets/index.d.ts +1 -1
  13. package/dist/types/widgets/pie/types.d.ts +6 -0
  14. package/dist/types/widgets/scatterplot/download.d.ts +2 -2
  15. package/dist/types/widgets/scatterplot/index.d.ts +2 -1
  16. package/dist/types/widgets/scatterplot/points.d.ts +7 -0
  17. package/dist/types/widgets/scatterplot/transforms.d.ts +4 -3
  18. package/dist/types/widgets/scatterplot/types.d.ts +21 -2
  19. package/dist/types/widgets/timeseries/types.d.ts +6 -0
  20. package/dist/types/widgets/utils/item-color.d.ts +26 -0
  21. package/dist/widgets/actions.js +1 -1
  22. package/dist/widgets/bar.js +78 -70
  23. package/dist/widgets/bar.js.map +1 -1
  24. package/dist/widgets/histogram.js +116 -85
  25. package/dist/widgets/histogram.js.map +1 -1
  26. package/dist/widgets/pie.js +108 -89
  27. package/dist/widgets/pie.js.map +1 -1
  28. package/dist/widgets/scatterplot.js +131 -92
  29. package/dist/widgets/scatterplot.js.map +1 -1
  30. package/dist/widgets/timeseries.js +82 -74
  31. package/dist/widgets/timeseries.js.map +1 -1
  32. package/dist/widgets.js +1 -1
  33. package/dist/widgets.js.map +1 -1
  34. package/package.json +1 -1
  35. package/src/widgets/actions/fullscreen/fullscreen-store.test.tsx +77 -13
  36. package/src/widgets/actions/fullscreen/fullscreen.tsx +48 -5
  37. package/src/widgets/bar/options.test.ts +106 -0
  38. package/src/widgets/bar/options.ts +25 -14
  39. package/src/widgets/bar/types.ts +6 -0
  40. package/src/widgets/histogram/bins.ts +22 -0
  41. package/src/widgets/histogram/download.test.ts +10 -0
  42. package/src/widgets/histogram/download.ts +7 -3
  43. package/src/widgets/histogram/index.ts +3 -0
  44. package/src/widgets/histogram/options.test.ts +62 -0
  45. package/src/widgets/histogram/options.ts +38 -17
  46. package/src/widgets/histogram/transforms.test.ts +21 -7
  47. package/src/widgets/histogram/transforms.ts +26 -12
  48. package/src/widgets/histogram/types.ts +25 -5
  49. package/src/widgets/index.ts +6 -1
  50. package/src/widgets/pie/options.test.ts +91 -0
  51. package/src/widgets/pie/options.ts +50 -20
  52. package/src/widgets/pie/types.ts +6 -0
  53. package/src/widgets/scatterplot/download.test.ts +9 -0
  54. package/src/widgets/scatterplot/download.ts +5 -3
  55. package/src/widgets/scatterplot/index.ts +3 -0
  56. package/src/widgets/scatterplot/options.test.ts +78 -0
  57. package/src/widgets/scatterplot/options.ts +35 -11
  58. package/src/widgets/scatterplot/points.ts +35 -0
  59. package/src/widgets/scatterplot/transforms.test.ts +19 -0
  60. package/src/widgets/scatterplot/transforms.ts +23 -18
  61. package/src/widgets/scatterplot/types.ts +25 -2
  62. package/src/widgets/timeseries/options.test.ts +65 -0
  63. package/src/widgets/timeseries/options.ts +31 -14
  64. package/src/widgets/timeseries/types.ts +6 -0
  65. package/src/widgets/utils/item-color.test.ts +74 -0
  66. package/src/widgets/utils/item-color.ts +55 -0
  67. package/dist/actions-CueYrfVr.js.map +0 -1
  68. package/dist/option-builders-DQivvvbb.js.map +0 -1
@@ -1,19 +1,43 @@
1
1
  import { r as e } from "../zoom-toggle-MmLjMTEw.js";
2
2
  import { n as t, t as n } from "../download-B4sykOFm.js";
3
3
  import { r, t as i } from "../utils-C-eWwOhE.js";
4
- import { a, n as o, o as s, r as c, s as l, t as u } from "../option-builders-DQivvvbb.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";
4
+ import { c as a, i as o, n as s, o as c, r as l, s as u, t as d } from "../item-color-B7xkIpDZ.js";
5
+ import { c as f } from "react/compiler-runtime";
6
+ import { Box as p, Skeleton as m } from "@mui/material";
7
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
8
+ import * as _ from "echarts";
9
+ //#region src/widgets/scatterplot/points.ts
10
+ function v(e) {
11
+ return x(e) ? e : [e.x, e.y];
12
+ }
13
+ function y(e) {
14
+ if (Array.isArray(e)) return e.length === 2 && S(e[0]) && S(e[1]);
15
+ if (typeof e != "object" || !e) return !1;
16
+ let { x: t, y: n } = e;
17
+ return S(t) && S(n);
18
+ }
19
+ function b(e, t, n) {
20
+ return x(e) ? [t, n] : {
21
+ ...e,
22
+ x: t,
23
+ y: n
24
+ };
25
+ }
26
+ function x(e) {
27
+ return Array.isArray(e);
28
+ }
29
+ function S(e) {
30
+ return typeof e == "number" && Number.isFinite(e);
31
+ }
32
+ //#endregion
9
33
  //#region src/widgets/scatterplot/options.ts
10
- function _({ theme: e, xFormatter: t, yFormatter: n }) {
34
+ function C({ theme: e, xFormatter: t, yFormatter: n }) {
11
35
  return {
12
36
  grid: {
13
37
  left: parseInt(e.spacing(1)),
14
38
  top: parseInt(e.spacing(3)),
15
39
  right: parseInt(e.spacing(1)),
16
- ...o(!1, e),
40
+ ...l(!1, e),
17
41
  containLabel: !0
18
42
  },
19
43
  tooltip: {
@@ -26,10 +50,10 @@ function _({ theme: e, xFormatter: t, yFormatter: n }) {
26
50
  fontSize: 11,
27
51
  fontFamily: e.typography.caption.fontFamily
28
52
  },
29
- position: s(e),
30
- formatter: x(t, n)
53
+ position: u(e),
54
+ formatter: D(t, n)
31
55
  },
32
- legend: { ...c({
56
+ legend: { ...o({
33
57
  hasLegend: !1,
34
58
  labelFormatter: void 0
35
59
  }) },
@@ -40,7 +64,7 @@ function _({ theme: e, xFormatter: t, yFormatter: n }) {
40
64
  axisLine: { show: !1 },
41
65
  axisTick: { show: !1 },
42
66
  axisLabel: {
43
- ...u(e),
67
+ ...s(e),
44
68
  margin: parseInt(e.spacing(1)),
45
69
  hideOverlap: !0,
46
70
  showMinLabel: !0,
@@ -57,7 +81,7 @@ function _({ theme: e, xFormatter: t, yFormatter: n }) {
57
81
  axisLine: { show: !1 },
58
82
  axisTick: { show: !1 },
59
83
  axisLabel: {
60
- ...u(e),
84
+ ...s(e),
61
85
  margin: parseInt(e.spacing(1)),
62
86
  hideOverlap: !0,
63
87
  showMinLabel: !0,
@@ -71,33 +95,41 @@ function _({ theme: e, xFormatter: t, yFormatter: n }) {
71
95
  }
72
96
  };
73
97
  }
74
- function v(t) {
75
- let { theme: n, xFormatter: a, yFormatter: o, optionsOverride: s } = t, c = t.series, l = t.symbolSize ?? 8, u = t.selection, d = u && u.length > 0 ? new Set(u) : null;
76
- return (t, u, f) => {
98
+ function w(t) {
99
+ let { theme: n, xFormatter: a, yFormatter: o, optionsOverride: s } = t, c = t.series, l = t.symbolSize ?? 8, u = t.selection, f = u && u.length > 0 ? new Set(u) : null;
100
+ return (t, u, p) => {
77
101
  if (t == null) {
78
- let e = _({
102
+ let e = C({
79
103
  theme: n,
80
104
  xFormatter: a,
81
105
  yFormatter: o
82
106
  });
83
107
  return s ? r(e, s) : e;
84
108
  }
85
- let p = Array.isArray(u) ? u : [];
86
- if (p.length === 0) return {
109
+ let m = Array.isArray(u) ? u : [];
110
+ if (m.length === 0) return {
87
111
  ...t,
88
112
  dataset: [],
89
113
  series: []
90
114
  };
91
- let m = p.length > 1, h = typeof t.legend == "object" && !Array.isArray(t.legend) ? t.legend : {}, v = typeof t.grid == "object" && !Array.isArray(t.grid) ? t.grid : {}, x = typeof t.tooltip == "object" && !Array.isArray(t.tooltip) ? t.tooltip : {}, C = typeof t.xAxis == "object" && !Array.isArray(t.xAxis) ? t.xAxis : {}, w = typeof t.yAxis == "object" && !Array.isArray(t.yAxis) ? t.yAxis : {}, T = f?.formatter, { niceMinX: E, niceMaxX: D, niceMinY: O, niceMaxY: k } = S(p), A = (e) => (t) => {
92
- let n = t.color;
93
- if (!d) return n;
94
- let r = `${e}:${t.dataIndex}`;
95
- return d.has(r) ? n : g.color.modifyAlpha(n, .15);
96
- }, j = y(t.dataZoom, m), M = j?.hasXSlider ?? !1, N = j?.hasYSlider ?? !1, P = typeof v.bottom == "number" ? v.bottom : 24, F = m ? 56 : P, I = M ? F + e.sliderHeight + e.sliderGap : F, L = typeof v.right == "number" ? v.right : 8, R = N ? L + e.sliderHeight + e.sliderGap : L;
115
+ let h = m.length > 1, g = typeof t.legend == "object" && !Array.isArray(t.legend) ? t.legend : {}, y = typeof t.grid == "object" && !Array.isArray(t.grid) ? t.grid : {}, b = typeof t.tooltip == "object" && !Array.isArray(t.tooltip) ? t.tooltip : {}, x = typeof t.xAxis == "object" && !Array.isArray(t.xAxis) ? t.xAxis : {}, S = typeof t.yAxis == "object" && !Array.isArray(t.yAxis) ? t.yAxis : {}, w = p?.formatter, { niceMinX: D, niceMaxX: k, niceMinY: A, niceMaxY: j } = O(m), M = Array.isArray(t.series) ? t.series : [], N = (e, t) => {
116
+ let r = d({
117
+ theme: n,
118
+ datums: t,
119
+ template: M[e] ?? M[0],
120
+ fallback: (e) => e.color
121
+ });
122
+ return (t) => {
123
+ let n = r(t);
124
+ if (!f) return n;
125
+ let i = `${e}:${t.dataIndex}`;
126
+ return f.has(i) ? n : _.color.modifyAlpha(n, .15);
127
+ };
128
+ }, P = T(t.dataZoom, h), F = P?.hasXSlider ?? !1, I = P?.hasYSlider ?? !1, L = typeof y.bottom == "number" ? y.bottom : 24, R = h ? 56 : L, z = F ? R + e.sliderHeight + e.sliderGap : R, B = typeof y.right == "number" ? y.right : 8, V = I ? B + e.sliderHeight + e.sliderGap : B;
97
129
  return {
98
130
  ...t,
99
- dataset: p.map((e) => ({ source: e })),
100
- series: p.map((e, t) => {
131
+ dataset: m.map((e) => ({ source: e.every(Array.isArray) ? e : e.map(v) })),
132
+ series: m.map((e, t) => {
101
133
  let r = i(n, c?.[t]?.color);
102
134
  return {
103
135
  type: "scatter",
@@ -109,42 +141,42 @@ function v(t) {
109
141
  },
110
142
  symbolSize: l,
111
143
  emphasis: { focus: "series" },
112
- itemStyle: { color: A(t) },
144
+ itemStyle: { color: N(t, e) },
113
145
  ...r ? { color: r } : {}
114
146
  };
115
147
  }),
116
148
  legend: {
117
- ...h,
118
- show: m
149
+ ...g,
150
+ show: h
119
151
  },
120
152
  grid: {
121
- ...v,
122
- bottom: I,
123
- right: R
153
+ ...y,
154
+ bottom: z,
155
+ right: V
124
156
  },
125
- ...j ? { dataZoom: j.entries } : {},
157
+ ...P ? { dataZoom: P.entries } : {},
126
158
  xAxis: {
127
- ...C,
128
- min: E,
129
- max: D
159
+ ...x,
160
+ min: D,
161
+ max: k
130
162
  },
131
163
  yAxis: {
132
- ...w,
133
- min: O,
134
- max: k,
164
+ ...S,
165
+ min: A,
166
+ max: j,
135
167
  axisLabel: {
136
- ...w.axisLabel ?? {},
137
- ...T ? { formatter: T } : {}
168
+ ...S.axisLabel ?? {},
169
+ ...w ? { formatter: w } : {}
138
170
  }
139
171
  },
140
172
  tooltip: {
141
- ...x,
142
- formatter: b(x.formatter, T, a)
173
+ ...b,
174
+ formatter: E(b.formatter, w, a)
143
175
  }
144
176
  };
145
177
  };
146
178
  }
147
- function y(t, n) {
179
+ function T(t, n) {
148
180
  if (!Array.isArray(t) || t.length === 0) return null;
149
181
  let r = !1, i = !1;
150
182
  return {
@@ -160,8 +192,8 @@ function y(t, n) {
160
192
  hasYSlider: i
161
193
  };
162
194
  }
163
- function b(e, t, n) {
164
- return t ? a((e) => {
195
+ function E(e, t, n) {
196
+ return t ? c((e) => {
165
197
  let r = e.value, i = r?.[0], a = r?.[1], o = typeof i == "number" ? n ? n(i) : String(i) : "", s = typeof a == "number" ? t(a) : String(a ?? ""), c = typeof e.marker == "string" ? e.marker : "", l = e.seriesName ? `${e.seriesName}: ` : "";
166
198
  return {
167
199
  name: `(${o}, ${s})`,
@@ -171,8 +203,8 @@ function b(e, t, n) {
171
203
  };
172
204
  }) : e;
173
205
  }
174
- function x(e, t) {
175
- return a((n) => {
206
+ function D(e, t) {
207
+ return c((n) => {
176
208
  let r = n.value, i = r?.[0], a = r?.[1], o = typeof i == "number" ? e ? e(i) : String(i) : "", s = typeof a == "number" ? t ? t(a) : String(a) : "", c = typeof n.marker == "string" ? n.marker : "", l = n.seriesName ? `${n.seriesName}: ` : "";
177
209
  return {
178
210
  name: `(${o}, ${s})`,
@@ -182,23 +214,24 @@ function x(e, t) {
182
214
  };
183
215
  });
184
216
  }
185
- function S(e) {
217
+ function O(e) {
186
218
  let t = Infinity, n = -Infinity, r = Infinity, i = -Infinity;
187
219
  for (let a of e) for (let e of a) {
188
- let a = e?.[0], o = e?.[1];
220
+ if (e == null) continue;
221
+ let [a, o] = v(e);
189
222
  typeof a == "number" && Number.isFinite(a) && (a < t && (t = a), a > n && (n = a)), typeof o == "number" && Number.isFinite(o) && (o < r && (r = o), o > i && (i = o));
190
223
  }
191
- let a = Number.isFinite(n) ? n <= 0 ? 1 : l(n) : 1, o = Number.isFinite(i) ? i <= 0 ? 1 : l(i) : 1;
224
+ let o = Number.isFinite(n) ? n <= 0 ? 1 : a(n) : 1, s = Number.isFinite(i) ? i <= 0 ? 1 : a(i) : 1;
192
225
  return {
193
- niceMinX: Number.isFinite(t) && t < 0 ? l(t) : 0,
194
- niceMaxX: a,
195
- niceMinY: Number.isFinite(r) && r < 0 ? l(r) : 0,
196
- niceMaxY: o
226
+ niceMinX: Number.isFinite(t) && t < 0 ? a(t) : 0,
227
+ niceMaxX: o,
228
+ niceMinY: Number.isFinite(r) && r < 0 ? a(r) : 0,
229
+ niceMaxY: s
197
230
  };
198
231
  }
199
232
  //#endregion
200
233
  //#region src/widgets/scatterplot/skeleton.tsx
201
- var C = {
234
+ var k = {
202
235
  container: {
203
236
  display: "flex",
204
237
  alignItems: "center",
@@ -223,7 +256,7 @@ var C = {
223
256
  alignItems: "center",
224
257
  gap: ({ spacing: e }) => e(1.5)
225
258
  }
226
- }, w = (e, t, n) => ({
259
+ }, A = (e, t, n) => ({
227
260
  position: "absolute",
228
261
  top: e,
229
262
  left: t,
@@ -231,48 +264,48 @@ var C = {
231
264
  height: n,
232
265
  borderRadius: "50%"
233
266
  });
234
- function T(e) {
235
- let t = d(15), { count: n } = e, r = n === void 0 ? 24 : n, i, a, o, s, c;
267
+ function j(e) {
268
+ let t = f(15), { count: n } = e, r = n === void 0 ? 24 : n, i, a, o, s, c;
236
269
  if (t[0] !== r) {
237
- let e = Array.from({ length: r }, O);
238
- a = f, c = C.container, i = f, o = C.grid, s = e.map(D), t[0] = r, t[1] = i, t[2] = a, t[3] = o, t[4] = s, t[5] = c;
270
+ let e = Array.from({ length: r }, P);
271
+ a = p, c = k.container, i = p, o = k.grid, s = e.map(N), t[0] = r, t[1] = i, t[2] = a, t[3] = o, t[4] = s, t[5] = c;
239
272
  } else i = t[1], a = t[2], o = t[3], s = t[4], c = t[5];
240
273
  let l;
241
- t[6] !== i || t[7] !== o || t[8] !== s ? (l = /* @__PURE__ */ m(i, {
274
+ t[6] !== i || t[7] !== o || t[8] !== s ? (l = /* @__PURE__ */ h(i, {
242
275
  sx: o,
243
276
  children: s
244
277
  }), t[6] = i, t[7] = o, t[8] = s, t[9] = l) : l = t[9];
245
278
  let u;
246
- t[10] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ m(f, {
247
- sx: C.legend,
248
- children: [0, 1].map(E)
279
+ t[10] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ h(p, {
280
+ sx: k.legend,
281
+ children: [0, 1].map(M)
249
282
  }), t[10] = u) : u = t[10];
250
- let p;
251
- return t[11] !== a || t[12] !== c || t[13] !== l ? (p = /* @__PURE__ */ h(a, {
283
+ let d;
284
+ return t[11] !== a || t[12] !== c || t[13] !== l ? (d = /* @__PURE__ */ g(a, {
252
285
  sx: c,
253
286
  children: [l, u]
254
- }), t[11] = a, t[12] = c, t[13] = l, t[14] = p) : p = t[14], p;
287
+ }), t[11] = a, t[12] = c, t[13] = l, t[14] = d) : d = t[14], d;
255
288
  }
256
- function E(e) {
257
- return /* @__PURE__ */ h(f, {
258
- sx: C.legendItem,
259
- children: [/* @__PURE__ */ m(p, {
289
+ function M(e) {
290
+ return /* @__PURE__ */ g(p, {
291
+ sx: k.legendItem,
292
+ children: [/* @__PURE__ */ h(m, {
260
293
  variant: "circular",
261
294
  width: 8,
262
295
  height: 8
263
- }), /* @__PURE__ */ m(p, {
296
+ }), /* @__PURE__ */ h(m, {
264
297
  width: 48,
265
298
  height: 8
266
299
  })]
267
300
  }, `legend-${e}`);
268
301
  }
269
- function D(e, t) {
270
- return /* @__PURE__ */ m(p, {
302
+ function N(e, t) {
303
+ return /* @__PURE__ */ h(m, {
271
304
  variant: "circular",
272
- sx: w(e.top, e.left, e.size)
305
+ sx: A(e.top, e.left, e.size)
273
306
  }, `dot-${t}`);
274
307
  }
275
- function O(e, t) {
308
+ function P(e, t) {
276
309
  let n = 10 + t * 37 % 80, r = 5 + t * 53 % 90, i = 8 + t * 7 % 6;
277
310
  return {
278
311
  top: `${n}%`,
@@ -282,7 +315,7 @@ function O(e, t) {
282
315
  }
283
316
  //#endregion
284
317
  //#region src/widgets/scatterplot/download.ts
285
- function k(e) {
318
+ function F(e) {
286
319
  return n(e, t({
287
320
  filename: e.filename,
288
321
  getRows: (t) => {
@@ -293,11 +326,14 @@ function k(e) {
293
326
  ]];
294
327
  for (let [t, i] of n.entries()) {
295
328
  let n = e.seriesNames?.[t] ?? `series_${t + 1}`;
296
- for (let [e, t] of i) r.push([
297
- n,
298
- e,
299
- t
300
- ]);
329
+ for (let e of i) {
330
+ let [t, i] = v(e);
331
+ r.push([
332
+ n,
333
+ t,
334
+ i
335
+ ]);
336
+ }
301
337
  }
302
338
  return r;
303
339
  }
@@ -305,20 +341,23 @@ function k(e) {
305
341
  }
306
342
  //#endregion
307
343
  //#region src/widgets/scatterplot/transforms.ts
308
- var A = (e) => Array.isArray(e) ? e.map((e) => {
309
- if (!j(e)) return e;
310
- let t = e.reduce((e, [, t]) => e + Math.abs(t), 0);
311
- return t <= 0 ? e : e.map(([e, n]) => [e, n / t * 100]);
344
+ var I = (e) => Array.isArray(e) ? e.map((e) => {
345
+ if (!L(e)) return e;
346
+ let t = e.reduce((e, t) => e + Math.abs(v(t)[1]), 0);
347
+ return t <= 0 ? e : e.map((e) => {
348
+ let [n, r] = v(e);
349
+ return b(e, n, r / t * 100);
350
+ });
312
351
  }) : e;
313
- function j(e) {
314
- return Array.isArray(e) ? e.every((e) => Array.isArray(e) && e.length === 2 && typeof e[0] == "number" && Number.isFinite(e[0]) && typeof e[1] == "number" && Number.isFinite(e[1])) : !1;
352
+ function L(e) {
353
+ return Array.isArray(e) && e.every(y);
315
354
  }
316
- function M(e, t) {
355
+ function R(e, t) {
317
356
  if (t.length === 0 || !Array.isArray(e)) return e;
318
357
  let n = new Set(t.map(String));
319
- return e.map((e, t) => j(e) ? e.filter((e, r) => n.has(`${t}:${r}`)) : e);
358
+ return e.map((e, t) => L(e) ? e.filter((e, r) => n.has(`${t}:${r}`)) : e);
320
359
  }
321
360
  //#endregion
322
- export { T as ScatterplotSkeleton, k as createScatterplotDownloadConfig, v as createScatterplotOptionFactory, M as filterScatterplotByLockedPoints, _ as scatterplotOptions, A as toRelativeScatterplotData };
361
+ export { j as ScatterplotSkeleton, F as createScatterplotDownloadConfig, w as createScatterplotOptionFactory, R as filterScatterplotByLockedPoints, v as getScatterplotXY, C as scatterplotOptions, I as toRelativeScatterplotData };
323
362
 
324
363
  //# sourceMappingURL=scatterplot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scatterplot.js","names":["{ count = 24 }: ScatterplotSkeletonProps","count = 24","Box","styles.grid","dots.map((d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\n />\n ))","styles.container","(_, i) => {\n const top = 10 + ((i * 37) % 80)\n const left = 5 + ((i * 53) % 90)\n const size = 8 + ((i * 7) % 6)\n return { top: `${top}%`, left: `${left}%`, size }\n }","(d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\n />\n )","<Box sx={styles.grid}>\n {dots.map((d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\n />\n ))}\n </Box>","<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>","(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 )","<Box sx={styles.container}>\n <Box sx={styles.grid}>\n {dots.map((d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\n />\n ))}\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","_c","ZOOM_LAYOUT","buildCsvDownloadItem","withPngItem","resolveThemeColor","buildGridConfig","createTooltipPositioner","buildLegendConfig","niceNum","buildAxisLabelStyle","echarts","scatterplotOptions","theme","buildScatterTooltipFormatter","xFormatter","yFormatter","createScatterplotOptionFactory","options","series","symbolSize","selection","selectionSet","option","structural","optionsOverride","mergeOptions","seriesArr","data","hasLegend","baseLegend","baseGrid","baseTooltip","baseXAxis","baseYAxis","reactiveFormatter","ctx","computeScatterBounds","makeDimColor","base","params","key","seriesIdx","dataZoomLayout","layoutDataZoomForScatter","hasXSlider","hasYSlider","fallbackBottom","baseBottom","gridBottom","fallbackRight","gridRight","s","overrideColor","i","niceMinX","niceMaxX","niceMinY","niceMaxY","buildReactiveScatterTooltipFormatter","dataZoom","entry","dz","reactiveYFormatter","createTooltipFormatter","value","item","x","y","formattedX","formattedY","marker","seriesName","structuralFormatter","minX","maxX","minY","maxY","point","styles","spacing","dotSx","size","ScatterplotSkeleton","$","c","t1","t0","count","T0","T1","t2","t3","t4","dots","_temp","Box","_temp2","t5","t6","_temp3","t7","Skeleton","i_1","d","i_0","top","left","createScatterplotDownloadConfig","args","rows","toRelativeScatterplotData","input","isXyTupleArray","total","acc","v","filterScatterplotByLockedPoints","lockedItems","locked","seriesIndex","dataIndex"],"sources":["../../src/widgets/scatterplot/options.ts","../../src/widgets/scatterplot/skeleton.tsx","../../src/widgets/scatterplot/download.ts","../../src/widgets/scatterplot/transforms.ts"],"sourcesContent":["import type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildAxisLabelStyle,\n buildGridConfig,\n buildLegendConfig,\n createTooltipFormatter,\n createTooltipPositioner,\n niceNum,\n} from '../utils/option-builders'\nimport { ZOOM_LAYOUT } from '../actions/zoom-toggle'\nimport type { OptionFactory } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport type {\n ScatterplotEChartsOption,\n ScatterplotOptionFactoryInput,\n ScatterplotOptionsInput,\n ScatterplotWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a scatterplot widget — both\n * axes `type: 'value'` (not category, unlike Bar/Histogram), grid, tooltip\n * triggered per-item rather than per-axis. Intentionally data-agnostic: no\n * series, no dataset, no `legend.show` (those depend on data and are added\n * by {@link createScatterplotOptionFactory}).\n *\n * Styling parity with v1: dark themed tooltip via `createTooltipFormatter`\n * + `createTooltipPositioner`, `buildGridConfig`-based grid, polished\n * axisLine/Tick/splitLine, `overlineDelicate` axis labels, structural\n * legend wired via `buildLegendConfig` (toggled by the merger), and the\n * CARTO `qualitative.bold + secondary` palette — same pattern bar /\n * histogram / pie already use. {@link createScatterplotOptionFactory}\n * wraps this builder in its structural-phase branch.\n */\nexport function scatterplotOptions({\n theme,\n xFormatter,\n yFormatter,\n}: ScatterplotOptionsInput): ScatterplotEChartsOption {\n return {\n grid: {\n left: parseInt(theme.spacing(1)),\n top: parseInt(theme.spacing(3)),\n right: parseInt(theme.spacing(1)),\n // Default: no legend. Merger bumps `bottom` when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n // Per-point trigger — different from Bar's 'axis' trigger because\n // points don't share an x-coordinate.\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: buildScatterTooltipFormatter(xFormatter, yFormatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count.\n legend: {\n ...buildLegendConfig({ hasLegend: false, labelFormatter: undefined }),\n },\n axisPointer: { lineStyle: { color: theme.palette.grey[400] } },\n color: [\n theme.palette.secondary.main,\n ...Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n ],\n xAxis: {\n type: 'value',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n ...buildAxisLabelStyle(theme),\n margin: parseInt(theme.spacing(1)),\n hideOverlap: true,\n showMinLabel: true,\n showMaxLabel: true,\n ...(xFormatter && { formatter: xFormatter }),\n },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n },\n yAxis: {\n type: 'value',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n ...buildAxisLabelStyle(theme),\n margin: parseInt(theme.spacing(1)),\n hideOverlap: true,\n showMinLabel: true,\n showMaxLabel: true,\n ...(yFormatter && { formatter: yFormatter }),\n },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n },\n } as ScatterplotEChartsOption\n}\n\n/**\n * Returns the scatterplot widget's {@link OptionFactory} — one closure\n * that owns BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link scatterplotOptions}, optionally merging\n * the consumer-supplied `optionsOverride`. Called once by Provider to\n * seed `rawOptions` in the store.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`ScatterplotWidgetData`) into the option via the dataset API. Each\n * series's `[x, y]` tuples land in `dataset[i].source` as 2-column\n * rows; the series uses positional encoding (`encode: { x: 0, y: 1 }`)\n * and `type: 'scatter'`. niceMin/niceMax are computed over both axes\n * so the chart frames data on rounded extents and numeric jitters\n * don't shift gridlines per render. Reactive `ctx.formatter` (driven\n * by RelativeData) re-derives the y-axis label and tooltip at fusion\n * time; `xFormatter` stays baked at structural-build time (relative\n * is a values-axis concept; x is coordinate-space).\n *\n * When `ZoomToggle` installs a `dataZoom` slider, grid bottom is\n * extended and the slider is positioned above the legend row (if any) —\n * same layout dance bar / histogram / timeseries do.\n */\nexport function createScatterplotOptionFactory(\n options: ScatterplotOptionFactoryInput,\n): OptionFactory {\n const { theme, xFormatter, yFormatter, optionsOverride } = options\n const series = options.series\n const symbolSize = options.symbolSize ?? 8\n const selection = options.selection\n const selectionSet =\n selection && selection.length > 0 ? new Set<string>(selection) : null\n return (option, data, ctx) => {\n if (option == null) {\n const structural = scatterplotOptions({ theme, xFormatter, yFormatter })\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 ScatterplotWidgetData) : []\n if (seriesArr.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n const hasLegend = seriesArr.length > 1\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 baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseXAxis =\n typeof option.xAxis === 'object' && !Array.isArray(option.xAxis)\n ? option.xAxis\n : {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n\n const reactiveFormatter = ctx?.formatter\n\n const { niceMinX, niceMaxX, niceMinY, niceMaxY } =\n computeScatterBounds(seriesArr)\n\n // Dim non-selected points via `series.itemStyle.color`. The selection\n // key is `${seriesIndex}:${dataIndex}`; we read those off the params\n // ECharts hands to the callback per-data.\n //\n // We *always* emit `itemStyle.color` (a passthrough when nothing is\n // selected), not conditionally — dropping the key between renders\n // would let ECharts' default merge keep the previous callback alive\n // and items would stay dimmed forever after an external clear.\n // Keeping the key always-present means a plain setOption merge swaps\n // the callback in place, no `replaceMerge` and no entry-animation\n // flash on selection on/off.\n const makeDimColor =\n (seriesIdx: number) => (params: CallbackDataParams) => {\n const base = params.color as string\n if (!selectionSet) return base\n const key = `${seriesIdx}:${params.dataIndex}`\n return selectionSet.has(key)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n }\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`,\n // reserve grid space and lift any x-slider above the legend (if\n // present). Scatter supports 2D zoom via `axes: ['x', 'y']` — in\n // that case there's also a vertical y-slider on the right edge, so\n // we reserve `grid.right` separately. Inside-only dataZoom entries\n // (no `type: 'slider'`) take no grid space.\n const dataZoomLayout = layoutDataZoomForScatter(option.dataZoom, hasLegend)\n const hasXSlider = dataZoomLayout?.hasXSlider ?? false\n const hasYSlider = dataZoomLayout?.hasYSlider ?? false\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = hasXSlider\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n const fallbackRight =\n typeof baseGrid.right === 'number' ? baseGrid.right : 8\n const gridRight = hasYSlider\n ? fallbackRight + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : fallbackRight\n\n return {\n ...option,\n // ECharts dataset.source wants a mutable [number, number][] shape; we\n // hold readonly tuples internally, so cast at the boundary.\n dataset: seriesArr.map((s) => ({ source: s as unknown as number[][] })),\n series: seriesArr.map((_, i) => {\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n type: 'scatter' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 0, y: 1 },\n symbolSize,\n emphasis: { focus: 'series' },\n itemStyle: { color: makeDimColor(i) },\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: { ...baseGrid, bottom: gridBottom, right: gridRight },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout.entries } : {}),\n xAxis: {\n ...baseXAxis,\n min: niceMinX,\n max: niceMaxX,\n } as EChartsOption['xAxis'],\n yAxis: {\n ...baseYAxis,\n min: niceMinY,\n max: niceMaxY,\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n // Re-derive the y-axis formatter at fusion time so RelativeData's\n // percent formatter (written to `state.formatter`) flows through\n // without rebuilding the structural option. Falls back to the\n // structural `yFormatter` already baked in `baseYAxis.axisLabel`\n // (which `String(value)` if neither is set).\n ...(reactiveFormatter ? { formatter: reactiveFormatter } : {}),\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n // Rebuild the tooltip formatter so the live y-axis formatter is\n // applied to the y-coordinate in the (x, y) label. xFormatter is\n // structural — relative is a values-axis concept, so xFormatter\n // doesn't change under RelativeData.\n formatter: buildReactiveScatterTooltipFormatter(\n (baseTooltip as { formatter?: unknown }).formatter,\n reactiveFormatter,\n xFormatter,\n ),\n },\n } as EChartsOption\n }\n}\n\n/**\n * Lay out the `dataZoom` array for the scatter chart:\n * - Detect whether any horizontal (x-axis) slider is present — if so\n * lift it above the legend row when a legend is shown.\n * - Detect whether any vertical (y-axis) slider is present — the\n * caller reserves `grid.right` so the slider doesn't overlap the\n * plot area.\n *\n * Returns `null` when there's no `dataZoom` so callers can skip the\n * layout adjustment entirely. An entry is considered an \"x-slider\" if\n * it has `xAxisIndex` set (or no axis index — defaults to x in ECharts).\n * A \"y-slider\" has `yAxisIndex` set.\n */\nfunction layoutDataZoomForScatter(\n dataZoom: unknown,\n hasLegend: boolean,\n): { entries: unknown[]; hasXSlider: boolean; hasYSlider: boolean } | null {\n if (!Array.isArray(dataZoom) || dataZoom.length === 0) return null\n let hasXSlider = false\n let hasYSlider = false\n const entries = dataZoom.map((entry: unknown) => {\n if (entry == null || typeof entry !== 'object') return entry\n const dz = entry as {\n type?: string\n xAxisIndex?: unknown\n yAxisIndex?: unknown\n bottom?: number\n }\n if (dz.type !== 'slider') return dz\n const targetsY = dz.yAxisIndex !== undefined\n if (targetsY) {\n hasYSlider = true\n return dz\n }\n // Either explicit x or defaulted (ECharts defaults sliders to xAxis\n // when no axis index is provided).\n hasXSlider = true\n if (hasLegend) {\n return { ...dz, bottom: ZOOM_LAYOUT.sliderBottomWithLegend }\n }\n return dz\n })\n return { entries, hasXSlider, hasYSlider }\n}\n\n/**\n * If a reactive (store-driven) y formatter is provided, re-build the\n * scatter tooltip formatter using it. Otherwise, return the structural\n * formatter unchanged so the original `xFormatter` / `yFormatter`\n * baked into `scatterplotOptions` still applies. The structural\n * formatter has stable identity per `scatterplotOptions` call, so this\n * path doesn't churn ECharts on every render.\n */\nfunction buildReactiveScatterTooltipFormatter(\n structuralFormatter: unknown,\n reactiveYFormatter: ((value: number) => string) | undefined,\n xFormatter: ((value: number) => string) | undefined,\n) {\n if (!reactiveYFormatter) return structuralFormatter\n return createTooltipFormatter((item) => {\n const value = item.value as readonly [number, number] | undefined\n const x = value?.[0]\n const y = value?.[1]\n const formattedX =\n typeof x === 'number' ? (xFormatter ? xFormatter(x) : String(x)) : ''\n const formattedY =\n typeof y === 'number' ? reactiveYFormatter(y) : String(y ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n return {\n name: `(${formattedX}, ${formattedY})`,\n seriesName,\n marker,\n value: '',\n }\n })\n}\n\nfunction buildScatterTooltipFormatter(\n xFormatter: ((value: number) => string) | undefined,\n yFormatter: ((value: number) => string) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const value = item.value as readonly [number, number] | undefined\n const x = value?.[0]\n const y = value?.[1]\n const formattedX =\n typeof x === 'number' ? (xFormatter ? xFormatter(x) : String(x)) : ''\n const formattedY =\n typeof y === 'number' ? (yFormatter ? yFormatter(y) : String(y)) : ''\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n return {\n name: `(${formattedX}, ${formattedY})`,\n seriesName,\n marker,\n value: '',\n }\n })\n}\n\nfunction computeScatterBounds(seriesArr: ScatterplotWidgetData): {\n niceMinX: number\n niceMaxX: number\n niceMinY: number\n niceMaxY: number\n} {\n let minX = Infinity\n let maxX = -Infinity\n let minY = Infinity\n let maxY = -Infinity\n for (const series of seriesArr) {\n for (const point of series) {\n const x = point?.[0]\n const y = point?.[1]\n if (typeof x === 'number' && Number.isFinite(x)) {\n if (x < minX) minX = x\n if (x > maxX) maxX = x\n }\n if (typeof y === 'number' && Number.isFinite(y)) {\n if (y < minY) minY = y\n if (y > maxY) maxY = y\n }\n }\n }\n // Mirror bar's `computeNiceBounds`: clamp min to 0 when data is\n // non-negative (gridline reads cleanly from zero), apply `niceNum` to\n // negative mins, and floor max=0 to 1 so the chart always has range.\n // Scatter can have free coordinates so we apply this per-axis.\n const niceMaxX = Number.isFinite(maxX) ? (maxX <= 0 ? 1 : niceNum(maxX)) : 1\n const niceMaxY = Number.isFinite(maxY) ? (maxY <= 0 ? 1 : niceNum(maxY)) : 1\n const niceMinX = Number.isFinite(minX) ? (minX < 0 ? niceNum(minX) : 0) : 0\n const niceMinY = Number.isFinite(minY) ? (minY < 0 ? niceNum(minY) : 0) : 0\n return { niceMinX, niceMaxX, niceMinY, niceMaxY }\n}\n","import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst styles = {\n container: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n flexDirection: 'column',\n gap: ({ spacing }) => spacing(1),\n height: ({ spacing }) => spacing(38),\n },\n grid: {\n position: 'relative',\n flex: '1 1 auto',\n width: '100%',\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n height: ({ spacing }) => spacing(5),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\n// `sx` callback that needs runtime args — extracted at module scope so the\n// `styles` object can satisfy `Record<string, SxProps<Theme>>` cleanly\n// (function `sx`-with-args isn't assignable to plain `SxProps<Theme>`).\nconst dotSx = (top: string, left: string, size: number): SxProps<Theme> => ({\n position: 'absolute',\n top,\n left,\n width: size,\n height: size,\n borderRadius: '50%',\n})\n\nexport interface ScatterplotSkeletonProps {\n /** Number of dots to render. */\n count?: number\n}\n\n/**\n * Loading state for the Scatterplot widget. Mirrors a scatter chart's\n * silhouette — a deterministic spread of small circular dots in the plot\n * area plus a legend stub — so the skeleton reads as \"a scatter chart\"\n * rather than a generic list. Matches bar/histogram/pie skeleton structure\n * (grid stub + legend stub in a flex column).\n */\nexport function ScatterplotSkeleton({ count = 24 }: ScatterplotSkeletonProps) {\n // Deterministic pseudo-scatter positions so the skeleton doesn't flicker.\n const dots = Array.from({ length: count }, (_, i) => {\n const top = 10 + ((i * 37) % 80)\n const left = 5 + ((i * 53) % 90)\n const size = 8 + ((i * 7) % 6)\n return { top: `${top}%`, left: `${left}%`, size }\n })\n return (\n <Box sx={styles.container}>\n <Box sx={styles.grid}>\n {dots.map((d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\n />\n ))}\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 { ScatterplotWidgetData } from './types'\n\n/**\n * Download menu items for the Scatterplot widget. Always includes a CSV item\n * with `series, x, y` columns (one row per point). When `getCaptureEl` is\n * given, prepends a PNG item that rasterises the captured element via\n * `html2canvas`.\n */\nexport function createScatterplotDownloadConfig(\n args: WidgetDownloadArgs<ScatterplotWidgetData> & {\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', 'x', 'y']]\n for (const [i, series] of data.entries()) {\n const seriesName = args.seriesNames?.[i] ?? `series_${i + 1}`\n for (const [x, y] of series) {\n rows.push([seriesName, x, y])\n }\n }\n return rows\n },\n }),\n )\n}\n","/**\n * Scatterplot-specific `RelativeData` transform. Scatter data is\n * `[number, number][]` — each series is a list of `[x, y]` tuples.\n * Relative is a values-axis concept, so this rewrites `y` to its\n * share of the series's total `y` (0–100) and leaves `x` raw — x is\n * coordinate space, not part of the cohort total.\n *\n * Pass to `<Widget.RelativeData transform={toRelativeScatterplotData} />`.\n *\n * The denominator is the sum of |y| across the series so mixed-sign\n * y values produce sane signed shares-of-magnitude. A series whose\n * total y-magnitude is zero (all-zero or empty input) is returned\n * unchanged so a stalled or empty data set doesn't show misleading 0%\n * values. Inputs whose shape isn't `[number, number][]` fall through\n * untouched.\n */\nexport const toRelativeScatterplotData = (input: unknown): unknown => {\n if (!Array.isArray(input)) return input\n return input.map((series: unknown): unknown => {\n if (!isXyTupleArray(series)) return series\n const total = series.reduce((acc, [, y]) => acc + Math.abs(y), 0)\n if (total <= 0) return series\n return series.map(([x, y]) => [x, (y / total) * 100] as [number, number])\n })\n}\n\nfunction isXyTupleArray(v: unknown): v is [number, number][] {\n if (!Array.isArray(v)) return false\n return v.every(\n (item) =>\n Array.isArray(item) &&\n item.length === 2 &&\n typeof item[0] === 'number' &&\n Number.isFinite(item[0]) &&\n typeof item[1] === 'number' &&\n Number.isFinite(item[1]),\n )\n}\n\n/**\n * `LockSelection` filter for Scatterplot. Data is `[number, number][][]` —\n * points have no `name`, so selection (and locking) is keyed on a synthetic\n * `${seriesIndex}:${dataIndex}` string (same format `useChartSelection`'s\n * `keyFromClick`/`keysFromBrush` produce for this widget). Unlike Histogram,\n * a point's position carries no external meaning (no `ticks` to desync from),\n * so non-locked points are removed outright rather than zeroed.\n */\nexport function filterScatterplotByLockedPoints(\n input: unknown,\n lockedItems: readonly (string | number)[],\n): unknown {\n if (lockedItems.length === 0) return input\n if (!Array.isArray(input)) return input\n const locked = new Set<string>(lockedItems.map(String))\n return input.map((series: unknown, seriesIndex: number): unknown => {\n if (!isXyTupleArray(series)) return series\n return series.filter((_, dataIndex) =>\n locked.has(`${seriesIndex}:${dataIndex}`),\n )\n })\n}\n"],"mappings":";;;;;;;;;AAoCA,SAAgBwB,EAAmB,EACjC,UACA,eACA,iBACoD;CACpD,OAAO;EACL,MAAM;GACJ,MAAM,SAASC,EAAM,QAAQ,CAAC,CAAC;GAC/B,KAAK,SAASA,EAAM,QAAQ,CAAC,CAAC;GAC9B,OAAO,SAASA,EAAM,QAAQ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ACqD;KAAYL;KAAGC;IAAC,CAAC;GAEhC;GACA,OAAO0C;EACT;CACF,CAAC,CACH;AACF;;;ACpBA,IAAaC,KAA6B,MACnC,MAAM,QAAQC,CAAK,IACjBA,EAAM,KAAK,MAA6B;CAC7C,IAAI,CAACC,EAAe9F,CAAM,GAAG,OAAOA;CACpC,IAAM+F,IAAQ/F,EAAO,QAAQ,GAAK,GAAGiD,OAAO+C,IAAM,KAAK,IAAI/C,CAAC,GAAG,CAAC;CAEhE,OADI8C,KAAS,IAAU/F,IAChBA,EAAO,KAAK,CAACgD,GAAGC,OAAO,CAACD,GAAIC,IAAI8C,IAAS,GAAG,CAAqB;AAC1E,CAAC,IANiCF;AASpC,SAASC,EAAe,GAAqC;CAE3D,OADK,MAAM,QAAQG,CAAC,IACbA,EAAE,OACN,MACC,MAAM,QAAQlD,CAAI,KAClBA,EAAK,WAAW,KAChB,OAAOA,EAAK,MAAO,YACnB,OAAO,SAASA,EAAK,EAAE,KACvB,OAAOA,EAAK,MAAO,YACnB,OAAO,SAASA,EAAK,EAAE,CAC3B,IAT8B;AAUhC;AAUA,SAAgBmD,EACd,GACA,GACS;CAET,IADIC,EAAY,WAAW,KACvB,CAAC,MAAM,QAAQN,CAAK,GAAG,OAAOA;CAClC,IAAMO,IAAS,IAAI,IAAYD,EAAY,IAAI,MAAM,CAAC;CACtD,OAAON,EAAM,KAAK,GAAiB,MAC5BC,EAAe9F,CAAM,IACnBA,EAAO,QAAQ,GAAG,MACvBoG,EAAO,IAAI,GAAGC,EAAY,GAAGC,GAAW,CAC1C,IAHoCtG,CAIrC;AACH"}
1
+ {"version":3,"file":"scatterplot.js","names":["{ count = 24 }: ScatterplotSkeletonProps","count = 24","Box","styles.grid","dots.map((d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\n />\n ))","styles.container","(_, i) => {\n const top = 10 + ((i * 37) % 80)\n const left = 5 + ((i * 53) % 90)\n const size = 8 + ((i * 7) % 6)\n return { top: `${top}%`, left: `${left}%`, size }\n }","(d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\n />\n )","<Box sx={styles.grid}>\n {dots.map((d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\n />\n ))}\n </Box>","<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>","(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 )","<Box sx={styles.container}>\n <Box sx={styles.grid}>\n {dots.map((d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\n />\n ))}\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","_c","ZOOM_LAYOUT","buildCsvDownloadItem","withPngItem","resolveThemeColor","niceNum","buildLegendConfig","buildAxisLabelStyle","createTooltipFormatter","buildGridConfig","createTooltipPositioner","createItemColorResolver","echarts","getScatterplotXY","isTuple","point","isScatterplotDatum","v","isFiniteNumber","x","y","withScatterplotXY","scatterplotOptions","theme","buildScatterTooltipFormatter","xFormatter","yFormatter","createScatterplotOptionFactory","options","series","symbolSize","selection","selectionSet","option","structural","optionsOverride","mergeOptions","seriesArr","data","hasLegend","baseLegend","baseGrid","baseTooltip","baseXAxis","baseYAxis","reactiveFormatter","ctx","computeScatterBounds","seriesTemplates","makeDimColor","baseColor","seriesIdx","params","base","key","dataZoomLayout","layoutDataZoomForScatter","hasXSlider","hasYSlider","fallbackBottom","baseBottom","gridBottom","fallbackRight","gridRight","s","overrideColor","i","niceMinX","niceMaxX","niceMinY","niceMaxY","buildReactiveScatterTooltipFormatter","dataZoom","entry","dz","reactiveYFormatter","value","item","formattedX","formattedY","marker","seriesName","structuralFormatter","minX","maxX","minY","maxY","styles","spacing","dotSx","size","ScatterplotSkeleton","$","c","t1","t0","count","T0","T1","t2","t3","t4","dots","_temp","Box","_temp2","t5","t6","_temp3","t7","Skeleton","i_1","d","i_0","top","left","createScatterplotDownloadConfig","args","rows","toRelativeScatterplotData","input","isPointArray","total","acc","p","filterScatterplotByLockedPoints","lockedItems","locked","seriesIndex","dataIndex"],"sources":["../../src/widgets/scatterplot/points.ts","../../src/widgets/scatterplot/options.ts","../../src/widgets/scatterplot/skeleton.tsx","../../src/widgets/scatterplot/download.ts","../../src/widgets/scatterplot/transforms.ts"],"sourcesContent":["import type { ScatterplotItem } from './types'\n\n/** `[x, y]` of a {@link ScatterplotItem}, whichever form it takes. */\nexport function getScatterplotXY(\n point: ScatterplotItem,\n): readonly [number, number] {\n return isTuple(point) ? point : [point.x, point.y]\n}\n\n/** Whether `v` is a valid {@link ScatterplotItem} with finite coordinates. */\nexport function isScatterplotDatum(v: unknown): v is ScatterplotItem {\n if (Array.isArray(v)) {\n return v.length === 2 && isFiniteNumber(v[0]) && isFiniteNumber(v[1])\n }\n if (v == null || typeof v !== 'object') return false\n const { x, y } = v as { x?: unknown; y?: unknown }\n return isFiniteNumber(x) && isFiniteNumber(y)\n}\n\n/** Same point with new coordinates; keeps the object form (and `color`). */\nexport function withScatterplotXY(\n point: ScatterplotItem,\n x: number,\n y: number,\n): ScatterplotItem {\n return isTuple(point) ? [x, y] : { ...point, x, y }\n}\n\nfunction isTuple(point: ScatterplotItem): point is readonly [number, number] {\n return Array.isArray(point)\n}\n\nfunction isFiniteNumber(v: unknown): v is number {\n return typeof v === 'number' && Number.isFinite(v)\n}\n","import type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildAxisLabelStyle,\n buildGridConfig,\n buildLegendConfig,\n createTooltipFormatter,\n createTooltipPositioner,\n niceNum,\n} from '../utils/option-builders'\nimport { ZOOM_LAYOUT } from '../actions/zoom-toggle'\nimport type { OptionFactory } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport { createItemColorResolver } from '../utils/item-color'\nimport { getScatterplotXY } from './points'\nimport type {\n ScatterplotEChartsOption,\n ScatterplotOptionFactoryInput,\n ScatterplotOptionsInput,\n ScatterplotItem,\n ScatterplotWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a scatterplot widget — both\n * axes `type: 'value'` (not category, unlike Bar/Histogram), grid, tooltip\n * triggered per-item rather than per-axis. Intentionally data-agnostic: no\n * series, no dataset, no `legend.show` (those depend on data and are added\n * by {@link createScatterplotOptionFactory}).\n *\n * Styling parity with v1: dark themed tooltip via `createTooltipFormatter`\n * + `createTooltipPositioner`, `buildGridConfig`-based grid, polished\n * axisLine/Tick/splitLine, `overlineDelicate` axis labels, structural\n * legend wired via `buildLegendConfig` (toggled by the merger), and the\n * CARTO `qualitative.bold + secondary` palette — same pattern bar /\n * histogram / pie already use. {@link createScatterplotOptionFactory}\n * wraps this builder in its structural-phase branch.\n */\nexport function scatterplotOptions({\n theme,\n xFormatter,\n yFormatter,\n}: ScatterplotOptionsInput): ScatterplotEChartsOption {\n return {\n grid: {\n left: parseInt(theme.spacing(1)),\n top: parseInt(theme.spacing(3)),\n right: parseInt(theme.spacing(1)),\n // Default: no legend. Merger bumps `bottom` when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n // Per-point trigger — different from Bar's 'axis' trigger because\n // points don't share an x-coordinate.\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: buildScatterTooltipFormatter(xFormatter, yFormatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count.\n legend: {\n ...buildLegendConfig({ hasLegend: false, labelFormatter: undefined }),\n },\n axisPointer: { lineStyle: { color: theme.palette.grey[400] } },\n color: [\n theme.palette.secondary.main,\n ...Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n ],\n xAxis: {\n type: 'value',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n ...buildAxisLabelStyle(theme),\n margin: parseInt(theme.spacing(1)),\n hideOverlap: true,\n showMinLabel: true,\n showMaxLabel: true,\n ...(xFormatter && { formatter: xFormatter }),\n },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n },\n yAxis: {\n type: 'value',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n ...buildAxisLabelStyle(theme),\n margin: parseInt(theme.spacing(1)),\n hideOverlap: true,\n showMinLabel: true,\n showMaxLabel: true,\n ...(yFormatter && { formatter: yFormatter }),\n },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n },\n } as ScatterplotEChartsOption\n}\n\n/**\n * Returns the scatterplot widget's {@link OptionFactory} — one closure\n * that owns BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link scatterplotOptions}, optionally merging\n * the consumer-supplied `optionsOverride`. Called once by Provider to\n * seed `rawOptions` in the store.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`ScatterplotWidgetData`) into the option via the dataset API. Each\n * series's `[x, y]` tuples land in `dataset[i].source` as 2-column\n * rows; the series uses positional encoding (`encode: { x: 0, y: 1 }`)\n * and `type: 'scatter'`. niceMin/niceMax are computed over both axes\n * so the chart frames data on rounded extents and numeric jitters\n * don't shift gridlines per render. Reactive `ctx.formatter` (driven\n * by RelativeData) re-derives the y-axis label and tooltip at fusion\n * time; `xFormatter` stays baked at structural-build time (relative\n * is a values-axis concept; x is coordinate-space).\n *\n * When `ZoomToggle` installs a `dataZoom` slider, grid bottom is\n * extended and the slider is positioned above the legend row (if any) —\n * same layout dance bar / histogram / timeseries do.\n */\nexport function createScatterplotOptionFactory(\n options: ScatterplotOptionFactoryInput,\n): OptionFactory {\n const { theme, xFormatter, yFormatter, optionsOverride } = options\n const series = options.series\n const symbolSize = options.symbolSize ?? 8\n const selection = options.selection\n const selectionSet =\n selection && selection.length > 0 ? new Set<string>(selection) : null\n return (option, data, ctx) => {\n if (option == null) {\n const structural = scatterplotOptions({ theme, xFormatter, yFormatter })\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)\n ? (data as ScatterplotWidgetData<ScatterplotItem>)\n : []\n if (seriesArr.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n const hasLegend = seriesArr.length > 1\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 baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseXAxis =\n typeof option.xAxis === 'object' && !Array.isArray(option.xAxis)\n ? option.xAxis\n : {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n\n const reactiveFormatter = ctx?.formatter\n\n const { niceMinX, niceMaxX, niceMinY, niceMaxY } =\n computeScatterBounds(seriesArr)\n\n // Dim non-selected points via `series.itemStyle.color`. The selection\n // key is `${seriesIndex}:${dataIndex}`; we read those off the params\n // ECharts hands to the callback per-data.\n //\n // We *always* emit `itemStyle.color` (a passthrough when nothing is\n // selected), not conditionally — dropping the key between renders\n // would let ECharts' default merge keep the previous callback alive\n // and items would stay dimmed forever after an external clear.\n // Keeping the key always-present means a plain setOption merge swaps\n // the callback in place, no `replaceMerge` and no entry-animation\n // flash on selection on/off.\n //\n // The base colour is the point's own `color` (object points), else the\n // template's `itemStyle.color`, else the series colour / palette.\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const makeDimColor = (seriesIdx: number, datums: readonly unknown[]) => {\n const baseColor = createItemColorResolver({\n theme,\n datums,\n template: seriesTemplates[seriesIdx] ?? seriesTemplates[0],\n fallback: (params) => params.color as string,\n })\n return (params: CallbackDataParams) => {\n const base = baseColor(params)\n if (!selectionSet) return base\n const key = `${seriesIdx}:${params.dataIndex}`\n return selectionSet.has(key)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n }\n }\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`,\n // reserve grid space and lift any x-slider above the legend (if\n // present). Scatter supports 2D zoom via `axes: ['x', 'y']` — in\n // that case there's also a vertical y-slider on the right edge, so\n // we reserve `grid.right` separately. Inside-only dataZoom entries\n // (no `type: 'slider'`) take no grid space.\n const dataZoomLayout = layoutDataZoomForScatter(option.dataZoom, hasLegend)\n const hasXSlider = dataZoomLayout?.hasXSlider ?? false\n const hasYSlider = dataZoomLayout?.hasYSlider ?? false\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = hasXSlider\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n const fallbackRight =\n typeof baseGrid.right === 'number' ? baseGrid.right : 8\n const gridRight = hasYSlider\n ? fallbackRight + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : fallbackRight\n\n return {\n ...option,\n // ECharts dataset.source wants a mutable [number, number][] shape; we\n // hold readonly tuples internally, so cast at the boundary. Object\n // points are flattened to `[x, y]` so the positional encode and the\n // tooltip keep reading tuples.\n dataset: seriesArr.map((s) => ({\n source: (s.every(Array.isArray)\n ? s\n : s.map(getScatterplotXY)) as unknown as number[][],\n })),\n series: seriesArr.map((s, i) => {\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n type: 'scatter' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 0, y: 1 },\n symbolSize,\n emphasis: { focus: 'series' },\n itemStyle: { color: makeDimColor(i, s) },\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: { ...baseGrid, bottom: gridBottom, right: gridRight },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout.entries } : {}),\n xAxis: {\n ...baseXAxis,\n min: niceMinX,\n max: niceMaxX,\n } as EChartsOption['xAxis'],\n yAxis: {\n ...baseYAxis,\n min: niceMinY,\n max: niceMaxY,\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n // Re-derive the y-axis formatter at fusion time so RelativeData's\n // percent formatter (written to `state.formatter`) flows through\n // without rebuilding the structural option. Falls back to the\n // structural `yFormatter` already baked in `baseYAxis.axisLabel`\n // (which `String(value)` if neither is set).\n ...(reactiveFormatter ? { formatter: reactiveFormatter } : {}),\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n // Rebuild the tooltip formatter so the live y-axis formatter is\n // applied to the y-coordinate in the (x, y) label. xFormatter is\n // structural — relative is a values-axis concept, so xFormatter\n // doesn't change under RelativeData.\n formatter: buildReactiveScatterTooltipFormatter(\n (baseTooltip as { formatter?: unknown }).formatter,\n reactiveFormatter,\n xFormatter,\n ),\n },\n } as EChartsOption\n }\n}\n\n/**\n * Lay out the `dataZoom` array for the scatter chart:\n * - Detect whether any horizontal (x-axis) slider is present — if so\n * lift it above the legend row when a legend is shown.\n * - Detect whether any vertical (y-axis) slider is present — the\n * caller reserves `grid.right` so the slider doesn't overlap the\n * plot area.\n *\n * Returns `null` when there's no `dataZoom` so callers can skip the\n * layout adjustment entirely. An entry is considered an \"x-slider\" if\n * it has `xAxisIndex` set (or no axis index — defaults to x in ECharts).\n * A \"y-slider\" has `yAxisIndex` set.\n */\nfunction layoutDataZoomForScatter(\n dataZoom: unknown,\n hasLegend: boolean,\n): { entries: unknown[]; hasXSlider: boolean; hasYSlider: boolean } | null {\n if (!Array.isArray(dataZoom) || dataZoom.length === 0) return null\n let hasXSlider = false\n let hasYSlider = false\n const entries = dataZoom.map((entry: unknown) => {\n if (entry == null || typeof entry !== 'object') return entry\n const dz = entry as {\n type?: string\n xAxisIndex?: unknown\n yAxisIndex?: unknown\n bottom?: number\n }\n if (dz.type !== 'slider') return dz\n const targetsY = dz.yAxisIndex !== undefined\n if (targetsY) {\n hasYSlider = true\n return dz\n }\n // Either explicit x or defaulted (ECharts defaults sliders to xAxis\n // when no axis index is provided).\n hasXSlider = true\n if (hasLegend) {\n return { ...dz, bottom: ZOOM_LAYOUT.sliderBottomWithLegend }\n }\n return dz\n })\n return { entries, hasXSlider, hasYSlider }\n}\n\n/**\n * If a reactive (store-driven) y formatter is provided, re-build the\n * scatter tooltip formatter using it. Otherwise, return the structural\n * formatter unchanged so the original `xFormatter` / `yFormatter`\n * baked into `scatterplotOptions` still applies. The structural\n * formatter has stable identity per `scatterplotOptions` call, so this\n * path doesn't churn ECharts on every render.\n */\nfunction buildReactiveScatterTooltipFormatter(\n structuralFormatter: unknown,\n reactiveYFormatter: ((value: number) => string) | undefined,\n xFormatter: ((value: number) => string) | undefined,\n) {\n if (!reactiveYFormatter) return structuralFormatter\n return createTooltipFormatter((item) => {\n const value = item.value as readonly [number, number] | undefined\n const x = value?.[0]\n const y = value?.[1]\n const formattedX =\n typeof x === 'number' ? (xFormatter ? xFormatter(x) : String(x)) : ''\n const formattedY =\n typeof y === 'number' ? reactiveYFormatter(y) : String(y ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n return {\n name: `(${formattedX}, ${formattedY})`,\n seriesName,\n marker,\n value: '',\n }\n })\n}\n\nfunction buildScatterTooltipFormatter(\n xFormatter: ((value: number) => string) | undefined,\n yFormatter: ((value: number) => string) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const value = item.value as readonly [number, number] | undefined\n const x = value?.[0]\n const y = value?.[1]\n const formattedX =\n typeof x === 'number' ? (xFormatter ? xFormatter(x) : String(x)) : ''\n const formattedY =\n typeof y === 'number' ? (yFormatter ? yFormatter(y) : String(y)) : ''\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n return {\n name: `(${formattedX}, ${formattedY})`,\n seriesName,\n marker,\n value: '',\n }\n })\n}\n\nfunction computeScatterBounds(\n seriesArr: ScatterplotWidgetData<ScatterplotItem>,\n): {\n niceMinX: number\n niceMaxX: number\n niceMinY: number\n niceMaxY: number\n} {\n let minX = Infinity\n let maxX = -Infinity\n let minY = Infinity\n let maxY = -Infinity\n for (const series of seriesArr) {\n for (const point of series) {\n if (point == null) continue\n const [x, y] = getScatterplotXY(point)\n if (typeof x === 'number' && Number.isFinite(x)) {\n if (x < minX) minX = x\n if (x > maxX) maxX = x\n }\n if (typeof y === 'number' && Number.isFinite(y)) {\n if (y < minY) minY = y\n if (y > maxY) maxY = y\n }\n }\n }\n // Mirror bar's `computeNiceBounds`: clamp min to 0 when data is\n // non-negative (gridline reads cleanly from zero), apply `niceNum` to\n // negative mins, and floor max=0 to 1 so the chart always has range.\n // Scatter can have free coordinates so we apply this per-axis.\n const niceMaxX = Number.isFinite(maxX) ? (maxX <= 0 ? 1 : niceNum(maxX)) : 1\n const niceMaxY = Number.isFinite(maxY) ? (maxY <= 0 ? 1 : niceNum(maxY)) : 1\n const niceMinX = Number.isFinite(minX) ? (minX < 0 ? niceNum(minX) : 0) : 0\n const niceMinY = Number.isFinite(minY) ? (minY < 0 ? niceNum(minY) : 0) : 0\n return { niceMinX, niceMaxX, niceMinY, niceMaxY }\n}\n","import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst styles = {\n container: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n flexDirection: 'column',\n gap: ({ spacing }) => spacing(1),\n height: ({ spacing }) => spacing(38),\n },\n grid: {\n position: 'relative',\n flex: '1 1 auto',\n width: '100%',\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n height: ({ spacing }) => spacing(5),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\n// `sx` callback that needs runtime args — extracted at module scope so the\n// `styles` object can satisfy `Record<string, SxProps<Theme>>` cleanly\n// (function `sx`-with-args isn't assignable to plain `SxProps<Theme>`).\nconst dotSx = (top: string, left: string, size: number): SxProps<Theme> => ({\n position: 'absolute',\n top,\n left,\n width: size,\n height: size,\n borderRadius: '50%',\n})\n\nexport interface ScatterplotSkeletonProps {\n /** Number of dots to render. */\n count?: number\n}\n\n/**\n * Loading state for the Scatterplot widget. Mirrors a scatter chart's\n * silhouette — a deterministic spread of small circular dots in the plot\n * area plus a legend stub — so the skeleton reads as \"a scatter chart\"\n * rather than a generic list. Matches bar/histogram/pie skeleton structure\n * (grid stub + legend stub in a flex column).\n */\nexport function ScatterplotSkeleton({ count = 24 }: ScatterplotSkeletonProps) {\n // Deterministic pseudo-scatter positions so the skeleton doesn't flicker.\n const dots = Array.from({ length: count }, (_, i) => {\n const top = 10 + ((i * 37) % 80)\n const left = 5 + ((i * 53) % 90)\n const size = 8 + ((i * 7) % 6)\n return { top: `${top}%`, left: `${left}%`, size }\n })\n return (\n <Box sx={styles.container}>\n <Box sx={styles.grid}>\n {dots.map((d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\n />\n ))}\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 { getScatterplotXY } from './points'\nimport type { ScatterplotItem, ScatterplotWidgetData } from './types'\n\n/**\n * Download menu items for the Scatterplot widget. Always includes a CSV item\n * with `series, x, y` columns (one row per point). When `getCaptureEl` is\n * given, prepends a PNG item that rasterises the captured element via\n * `html2canvas`.\n */\nexport function createScatterplotDownloadConfig(\n args: WidgetDownloadArgs<ScatterplotWidgetData<ScatterplotItem>> & {\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', 'x', 'y']]\n for (const [i, series] of data.entries()) {\n const seriesName = args.seriesNames?.[i] ?? `series_${i + 1}`\n for (const point of series) {\n const [x, y] = getScatterplotXY(point)\n rows.push([seriesName, x, y])\n }\n }\n return rows\n },\n }),\n )\n}\n","import {\n getScatterplotXY,\n isScatterplotDatum,\n withScatterplotXY,\n} from './points'\nimport type { ScatterplotItem } from './types'\n\n/**\n * Scatterplot-specific `RelativeData` transform. Scatter data is\n * `ScatterplotItem[][]` — each series is a list of `[x, y]` tuples or\n * `{ x, y, color? }` points (whose shape is kept).\n * Relative is a values-axis concept, so this rewrites `y` to its\n * share of the series's total `y` (0–100) and leaves `x` raw — x is\n * coordinate space, not part of the cohort total.\n *\n * Pass to `<Widget.RelativeData transform={toRelativeScatterplotData} />`.\n *\n * The denominator is the sum of |y| across the series so mixed-sign\n * y values produce sane signed shares-of-magnitude. A series whose\n * total y-magnitude is zero (all-zero or empty input) is returned\n * unchanged so a stalled or empty data set doesn't show misleading 0%\n * values. Inputs whose shape isn't `ScatterplotItem[]` fall through\n * untouched.\n */\nexport const toRelativeScatterplotData = (input: unknown): unknown => {\n if (!Array.isArray(input)) return input\n return input.map((series: unknown): unknown => {\n if (!isPointArray(series)) return series\n const total = series.reduce(\n (acc, p) => acc + Math.abs(getScatterplotXY(p)[1]),\n 0,\n )\n if (total <= 0) return series\n return series.map((p) => {\n const [x, y] = getScatterplotXY(p)\n return withScatterplotXY(p, x, (y / total) * 100)\n })\n })\n}\n\nfunction isPointArray(v: unknown): v is ScatterplotItem[] {\n return Array.isArray(v) && v.every(isScatterplotDatum)\n}\n\n/**\n * `LockSelection` filter for Scatterplot. Data is `ScatterplotItem[][]` —\n * points have no `name`, so selection (and locking) is keyed on a synthetic\n * `${seriesIndex}:${dataIndex}` string (same format `useChartSelection`'s\n * `keyFromClick`/`keysFromBrush` produce for this widget). Unlike Histogram,\n * a point's position carries no external meaning (no `ticks` to desync from),\n * so non-locked points are removed outright rather than zeroed.\n */\nexport function filterScatterplotByLockedPoints(\n input: unknown,\n lockedItems: readonly (string | number)[],\n): unknown {\n if (lockedItems.length === 0) return input\n if (!Array.isArray(input)) return input\n const locked = new Set<string>(lockedItems.map(String))\n return input.map((series: unknown, seriesIndex: number): unknown => {\n if (!isPointArray(series)) return series\n return series.filter((_, dataIndex) =>\n locked.has(`${seriesIndex}:${dataIndex}`),\n )\n })\n}\n"],"mappings":";;;;;;;;;AAGA,SAAgB0B,EACd,GAC2B;CAC3B,OAAOC,EAAQC,CAAK,IAAIA,IAAQ,CAACA,EAAM,GAAGA,EAAM,CAAC;AACnD;AAGA,SAAgBC,EAAmB,GAAkC;CACnE,IAAI,MAAM,QAAQC,CAAC,GACjB,OAAOA,EAAE,WAAW,KAAKC,EAAeD,EAAE,EAAE,KAAKC,EAAeD,EAAE,EAAE;CAEtE,IAAiB,OAAOA,KAAM,aAA1BA,GAAoC,OAAO;CAC/C,IAAM,EAAE,MAAG,SAAMA;CACjB,OAAOC,EAAeC,CAAC,KAAKD,EAAeE,CAAC;AAC9C;AA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