@astrato-io/visualizations 0.9.0 → 0.10.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 (144) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +7 -3
  3. package/THIRD_PARTY_NOTICES.md +163 -14
  4. package/VISUALIZATION_DEFINITIONS.md +376 -36
  5. package/chunks/{Button-5CxPEACP.js → Button-Dn3rJrYf.js} +4 -4
  6. package/chunks/{CircularProgress-DFS-LQb7.js → CircularProgress-BFeu06Yb.js} +39 -39
  7. package/chunks/FieldTypeIcon-DrMoGpHJ.js +22 -0
  8. package/chunks/{LinearProgress-CjIQfkNA.js → LinearProgress-ClO6GUjN.js} +9 -9
  9. package/chunks/{MenuOption-Cb7B7x6z.js → MenuOption-Czc34u4q.js} +143 -142
  10. package/chunks/{Title-CtFw1bVg.js → Title-BgYnaVTR.js} +22 -22
  11. package/chunks/_createAggregator-BMu9uRax.js +50 -0
  12. package/chunks/{app-filter-bar.compiler-B9775gLJ.js → app-filter-bar.compiler-CVir0wkl.js} +10 -10
  13. package/chunks/bar-layout-C_UgRlVl.js +9 -0
  14. package/chunks/{bar.compiler-B7wlH_Ro.js → bar.compiler-DYuFdi9J.js} +100 -82
  15. package/chunks/{builder-Dxo7D7c6.js → builder-C-TKA-My.js} +70 -37
  16. package/chunks/color-rules-DYJL4fIW.js +15 -0
  17. package/chunks/color-settings-DJFoFTip.js +5 -0
  18. package/chunks/{coloring-B-Wa8D5P.js → coloring-BtnPiQ_o.js} +37 -37
  19. package/chunks/createSimplePaletteValueFilter--zrZxRV9.js +2005 -0
  20. package/chunks/defaults-Dtk7fg3C.js +3 -0
  21. package/chunks/{definitions-DNpzD9tY.js → definitions-CT304NDn.js} +655 -417
  22. package/chunks/{escobar-C4Nm3eJ7.js → escobar-CvEV2ES1.js} +7441 -7127
  23. package/chunks/{extend-preset-BVKFtoe-.js → extend-preset-D9-JP92b.js} +998 -933
  24. package/chunks/{filter.compiler-BlS3zoy_.js → filter.compiler-CXeZznks.js} +7 -7
  25. package/chunks/{filtering-CGuLpg7u.js → filtering-8_bFv-jb.js} +333 -377
  26. package/chunks/handlers-C6CZ0XJA.js +15399 -0
  27. package/chunks/{icon-picker-styles-DYQgVEKG.js → icon-picker-styles-BXiJ1SZS.js} +11 -11
  28. package/chunks/isEqual-D8Ay63xR.js +16 -0
  29. package/chunks/{isFocusVisible-B1_z03UT.js → isFocusVisible-Bu8gGZu5.js} +1 -1
  30. package/chunks/label-format-type-C46pzgx7.js +17 -0
  31. package/chunks/{line.compiler-Bo9i9qag.js → line.compiler-DmHpmQCC.js} +9 -9
  32. package/chunks/{logger-3lng-wOw.js → logger-DdZpR7xZ.js} +79 -72
  33. package/chunks/map.compiler-Q_Y1Pvat.js +343 -0
  34. package/chunks/{metadata-Fmx1swpK.js → metadata-BQm_TXI1.js} +1 -1
  35. package/chunks/{number.compiler-CdLd5aGW.js → number.compiler-DQdg6zTy.js} +7 -7
  36. package/chunks/operations-DKQWuLL7.js +31315 -0
  37. package/chunks/{range-CzO4isKK.js → range-BdhzvYQ_.js} +2 -2
  38. package/chunks/{react-dom-BwZT0N3F.js → react-dom-BGP4tbXV.js} +70 -70
  39. package/chunks/{render-wrappers-CAuvgMxi.js → render-wrappers-BZpyDnJy.js} +1 -1
  40. package/chunks/{requirements-CYpVh65U.js → requirements-e8Fe96ag.js} +60 -58
  41. package/chunks/shared-C_2F90xq.js +1337 -0
  42. package/chunks/standalone-4MsKiqs0.js +355 -0
  43. package/chunks/standalone-B794g9pE.js +1012 -0
  44. package/chunks/{standalone-C6XDHYAM.js → standalone-B8ZSqauS.js} +110 -110
  45. package/chunks/{standalone-5DnapeHH.js → standalone-BA2YXyJS.js} +126 -124
  46. package/chunks/{standalone-CXniic5x.js → standalone-BDrXVxlP.js} +6 -5
  47. package/chunks/{standalone-B6s_xG2u.js → standalone-BE_ONgiG.js} +116 -116
  48. package/chunks/{standalone-CPUiiWNP.js → standalone-BTY3w_JA.js} +37 -37
  49. package/chunks/standalone-BgumbdaJ2.js +357 -0
  50. package/chunks/{standalone-DWPfdP0A.js → standalone-BkbiH-o8.js} +482 -482
  51. package/chunks/standalone-Blh4qejk.js +689 -0
  52. package/chunks/standalone-CXY4FpF7.js +773 -0
  53. package/chunks/{standalone-BvWdpUL3.js → standalone-CY_kjarf.js} +34 -31
  54. package/chunks/{standalone-DuwTOBXH.js → standalone-CaTxAydz.js} +587 -587
  55. package/chunks/{standalone-BDrQMxLi.js → standalone-Cc98Pdr6.js} +1799 -1015
  56. package/chunks/{standalone-DMCwtebn.js → standalone-Cl0TSfqC.js} +125 -125
  57. package/chunks/{standalone-CoQxJ6ov.js → standalone-CsoMmE9T.js} +778 -778
  58. package/chunks/standalone-DH0xTEes.js +2 -0
  59. package/chunks/{standalone-LFVgLhia.js → standalone-DHRalbVO.js} +311 -303
  60. package/chunks/standalone-DNh9NcMa.js +580 -0
  61. package/chunks/standalone-DcnHjNnC.js +2 -0
  62. package/chunks/{standalone-r4ObFvys.js → standalone-DflyWtuR.js} +217 -215
  63. package/chunks/standalone-DrHdGkY7.js +762 -0
  64. package/chunks/standalone-c_rROMtx.js +287 -0
  65. package/chunks/standalone-drcFLeN6.js +6 -0
  66. package/chunks/{standalone-CNkHsynO.js → standalone-wOWRCpdn.js} +54 -56
  67. package/chunks/{standalone-Cu73fzSr.js → standalone-z0o52o5t.js} +5128 -4908
  68. package/chunks/{table.compiler-C1qjqXaT.js → table.compiler-COaHE9VD.js} +18 -18
  69. package/chunks/{useFieldName-mWrD_uk_.js → useFieldName-CdnCWzhd.js} +1 -1
  70. package/chunks/{utils-DYYD4Zzf.js → utils-DganVptf.js} +4758 -4747
  71. package/chunks/{view-7fH6mGmY.js → view-Bzlros43.js} +2021 -1665
  72. package/chunks/{visualization-filters-mVnsnvLP.js → visualization-filters-D7i6oh1Z.js} +3177 -2425
  73. package/chunks/{with-html-element-B0Clt4jY.js → with-html-element-CiIhFEa5.js} +3740 -3547
  74. package/definitions.js +2 -2
  75. package/docs/operations/astrato-app-filter-bar.md +1 -1
  76. package/docs/operations/bar.md +303 -2
  77. package/docs/operations/combo.md +262 -1
  78. package/docs/operations/date-picker.md +1 -1
  79. package/docs/operations/distribution-gauge.md +1 -1
  80. package/docs/operations/dot.md +148 -1
  81. package/docs/operations/filter.md +1 -1
  82. package/docs/operations/gauge.md +1 -1
  83. package/docs/operations/heatMap.md +1 -1
  84. package/docs/operations/histogram.md +262 -1
  85. package/docs/operations/iframe.md +1 -1
  86. package/docs/operations/image.md +1 -1
  87. package/docs/operations/index.md +7 -7
  88. package/docs/operations/line.md +280 -1
  89. package/docs/operations/number.md +1 -1
  90. package/docs/operations/pie.md +1 -1
  91. package/docs/operations/radar.md +1 -1
  92. package/docs/operations/sankey.md +1 -1
  93. package/docs/operations/scatter.md +148 -1
  94. package/docs/operations/shape.md +1 -1
  95. package/docs/operations/simpleTextObject.md +1 -1
  96. package/docs/operations/slider.md +1 -1
  97. package/docs/operations/table.md +374 -157
  98. package/docs/operations/tree.md +1 -1
  99. package/docs/operations/treemap.md +1 -1
  100. package/docs/operations/waterfall.md +1 -1
  101. package/docs/operations/word-cloud.md +1 -1
  102. package/getters.js +2 -2
  103. package/index.js +482 -434
  104. package/metadata.js +2 -2
  105. package/operations.js +5 -5
  106. package/package.json +72 -67
  107. package/src/definitions/index.d.ts +7 -1
  108. package/src/definitions/model/definitions/available-fields.d.ts +2 -2
  109. package/src/definitions/model/definitions/compilers/compile.d.ts +1 -0
  110. package/src/definitions/model/definitions/data-item-resolution.d.ts +3 -3
  111. package/src/definitions/model/definitions/descriptors/descriptor-metadata.d.ts +219 -7
  112. package/src/definitions/model/definitions/index.d.ts +2 -1
  113. package/src/definitions/model/definitions/schema-registry.d.ts +305 -0
  114. package/src/definitions/model/definitions/schemas/bar.schema.d.ts +2 -0
  115. package/src/definitions/model/definitions/schemas/common.schema.d.ts +4 -3
  116. package/src/definitions/model/definitions/schemas/index.d.ts +1 -0
  117. package/src/definitions/model/definitions/schemas/map.schema.d.ts +590 -0
  118. package/src/definitions/model/definitions/types/compilation.types.d.ts +9 -1
  119. package/src/definitions/model/definitions/types/definition.types.d.ts +2 -2
  120. package/src/definitions/model/definitions/types/index.d.ts +1 -1
  121. package/src/index.d.ts +1 -1
  122. package/src/operations/index.d.ts +1 -1
  123. package/src/types.d.ts +17 -13
  124. package/chunks/FieldTypeIcon-pSVQFemC.js +0 -22
  125. package/chunks/ToggleButton-Br9HCPCv.js +0 -150
  126. package/chunks/color-rules-CN7TcGrC.js +0 -6
  127. package/chunks/color-settings-3VRlf_Vw.js +0 -6
  128. package/chunks/handlers-CMbyj5y1.js +0 -12930
  129. package/chunks/isEqual-DBg_b35N.js +0 -12
  130. package/chunks/label-format-type-weq1XfcX.js +0 -8
  131. package/chunks/operations-HSqnCRvv.js +0 -26324
  132. package/chunks/shared-DFoJxjVN.js +0 -1218
  133. package/chunks/standalone-530a5lvf.js +0 -1003
  134. package/chunks/standalone-B4jrf4KE.js +0 -354
  135. package/chunks/standalone-BMoJXGYe.js +0 -2
  136. package/chunks/standalone-BfvGggeM2.js +0 -355
  137. package/chunks/standalone-CMJJIi9v.js +0 -2
  138. package/chunks/standalone-C_Jd4gkj.js +0 -6
  139. package/chunks/standalone-CiaaibTa.js +0 -518
  140. package/chunks/standalone-DBeXQrwH.js +0 -468
  141. package/chunks/standalone-DpSRmAWx.js +0 -287
  142. package/chunks/standalone-kzAhwH19.js +0 -689
  143. package/chunks/standalone-mb7LwEiq.js +0 -3874
  144. /package/chunks/{src-BOS6SqkZ2.js → src-BOS6SqkZ.js} +0 -0
@@ -1,689 +0,0 @@
1
- import { o as e } from "./rolldown-runtime-DleVn1XH.js";
2
- import { $i as t, Cr as n, Ds as r, Gn as i, Hi as a, Ja as o, Ri as s, Rs as c, Sa as l, Us as u, Wa as d, Xa as f, Za as p, da as m, hs as h, jt as g, n as _, ws as v, xi as y, zi as b, zr as x } from "./visualization-filters-mVnsnvLP.js";
3
- import { Bt as S, F as C, N as w, Ot as T, ei as E, f as D, jr as O, s as k } from "./utils-DYYD4Zzf.js";
4
- import "./logger-3lng-wOw.js";
5
- import { $t as A, Bt as j, Ct as ee, Dt as M, Et as N, F as P, Ft as F, Gt as I, H as L, I as te, It as ne, J as re, K as ie, Lt as ae, Mt as oe, Pt as se, U as ce, Vt as le, Wt as R, Yt as ue, Z as de, _n as z, an as fe, dn as B, et as pe, fn as me, gn as he, i as ge, in as _e, jt as ve, kt as ye, ln as be, n as xe, on as Se, ot as Ce, pn as V, q as H, rn as we, rt as Te, sn as U, tt as Ee, un as W, ut as De, xt as Oe, yt as G } from "./escobar-C4Nm3eJ7.js";
6
- import { t as ke } from "./coloring-B-Wa8D5P.js";
7
- import { t as Ae } from "./set-coloring-datafield-B3uIS1Pe.js";
8
- var je = /* @__PURE__ */ e(E()), Me = (e, n, r, a, o, s, c, l) => {
9
- let u = [], d = [], p = e.measures.filter((e) => x(e)), m = {
10
- ...n.axis.measure,
11
- ...n.fonts
12
- }, h = [];
13
- if (l) {
14
- let e = le(z.Text, l);
15
- h.push(e);
16
- }
17
- let g = p.filter((e) => e.role === t.SCATTER_HORIZONTAL), _ = p.filter((e) => e.role === t.SCATTER_VERTICAL), v = e.measures.filter((e) => e.role === t.SCATTER_HORIZONTAL), y = e.measures.filter((e) => e.role === t.SCATTER_VERTICAL), b = g[0], S = _[0], C = {};
18
- if (b) {
19
- let t = f.Bottom, n = e.axes?.primaryMeasure || C;
20
- if (u.push(R(U.XAxisScale, n, m, t, b.formatter)), e.axes?.primaryMeasure?.showAxisName) {
21
- let r = i(v, e.enableAlternate, s?.isPrintMode);
22
- d.push(I(g, r, t, m, n.colors?.title, n.axisTitle, n.titleFontSize));
23
- }
24
- }
25
- if (S) {
26
- let t = f.Left, n = e.axes?.secondaryMeasure || C;
27
- if (u.push(R(U.YAxisScale, n, m, t, S.formatter)), e.axes?.secondaryMeasure?.showAxisName) {
28
- let r = i(y, e.enableAlternate, s?.isPrintMode);
29
- d.push(I(_, r, t, m, n.colors?.title, n.axisTitle, n.titleFontSize));
30
- }
31
- }
32
- return {
33
- ...r,
34
- components: [
35
- ...r.components,
36
- ...u,
37
- ...d
38
- ],
39
- interactions: [...r.interactions ?? [], ...h]
40
- };
41
- }, Ne = (e, n) => {
42
- let i = e.dimensions.filter((e) => x(e)), a = e.measures.filter((e) => x(e)), o = i.filter((e) => e.role === m.SCATTER_DIMENSION), s = a.filter((e) => e.role === t.SCATTER_SIZE), c = o[0], l = s[0], { coloring: d } = e || {};
43
- switch (d?.type) {
44
- case r.Categorical: return M(e, n);
45
- case r.Gradient: return ye(e, l);
46
- case r.Single: return u(c.dataItem);
47
- default: return null;
48
- }
49
- }, Pe = (e, n, i, a, o, c, l) => {
50
- let d = e.dimensions.filter((e) => x(e)), f = e.measures.filter((e) => x(e)), p = d.filter((e) => e.role === m.SCATTER_DIMENSION), h = f.filter((e) => e.role === t.SCATTER_HORIZONTAL), v = f.filter((e) => e.role === t.SCATTER_VERTICAL), b = f.filter((e) => e.role === t.SCATTER_SIZE), C = p[0], w = h[0], T = v[0], E = b[0], D = {}, { coloring: O } = e || {}, k = d.length < 2 && e.scatterSettings?.spatialHeatmap?.show, A = k && !O?.fieldId ? null : Ne(e, l);
51
- switch (O?.type) {
52
- case r.Categorical:
53
- D = N(Ae(e, A), n, D, void 0, l);
54
- break;
55
- case r.Gradient:
56
- D = N(Ae(e, A), n, D, void 0, l);
57
- break;
58
- case r.Single: {
59
- let t = u(C.dataItem);
60
- D[r.Single] = {
61
- data: { extract: { field: t } },
62
- range: [e?.coloring?.color ?? n.colors.brandColors[0]],
63
- type: B.CategoricalColor,
64
- label: (e) => C?.formatter?.format ? S(C.formatter, e.datum.value) : e.datum.label
65
- };
66
- break;
67
- }
68
- default: break;
69
- }
70
- if (k) {
71
- D[U.Density] = {
72
- data: A ? { field: A } : void 0,
73
- min: 0,
74
- max: (t) => (t.data?.fields?.[0] ? t.data.fields[0].max() : 1) * (g(e.scatterSettings?.spatialHeatmap?.maxDensity ?? y.heatmapMaxDensity) ?? 0),
75
- nice: !0
76
- }, D[U.DensityInverted] = {
77
- ...D[U.Density],
78
- invert: !0
79
- };
80
- let t = [..._(O?.type ?? r.Gradient, n), ...O?.customGradient ? [O.customGradient] : []].find((e) => e.id === (O?.palette ?? n.colors.defaultGradient ?? s.id))?.colors;
81
- D[U.DensityGradient] = {
82
- ...D[U.Density],
83
- range: t ?? s.colors,
84
- type: B.SequentialColor
85
- }, A && G(i, 0, { density: { field: A } });
86
- } else A && G(i, 0, { color: { field: A } });
87
- let j = u(w?.dataItem), ee = u(T?.dataItem), M = u(E?.dataItem), P = ie(e?.axes?.primaryMeasure?.axisRange, !0), F = re(P);
88
- D[U.XAxisScale] = {
89
- type: B.Linear,
90
- data: { field: j },
91
- invert: H(!1, e?.axes?.primaryMeasure),
92
- nice: !F && V.scale.nice,
93
- expandMax: .06,
94
- ...P
95
- };
96
- let I = ie(e?.axes?.secondaryMeasure?.axisRange, !0), L = re(I);
97
- return D[U.YAxisScale] = {
98
- type: B.Linear,
99
- data: { fields: [ee] },
100
- invert: H(!0, e?.axes?.secondaryMeasure),
101
- nice: !L && V.scale.nice,
102
- expandMax: .06,
103
- ...I
104
- }, E && (D[M] = {
105
- type: B.Linear,
106
- data: { field: M }
107
- }), {
108
- ...i,
109
- scales: D
110
- };
111
- }, K = "spatial-heatmap", Fe = "shape", q = (e) => {
112
- let t = e.scatterSettings?.shape ?? d.Circle;
113
- return `${z.Point}-${t}`;
114
- }, Ie = (e, n, r, i, a, o) => {
115
- let s = e.dimensions.filter((e) => x(e)), c = e.measures.filter((e) => x(e)), l = te((e.supportingMeasures ?? []).filter((e) => x(e))), d = s.filter((e) => e.role === m.SCATTER_IMAGE), f = c.filter((e) => e.role === t.SCATTER_HORIZONTAL), p = c.filter((e) => e.role === t.SCATTER_VERTICAL), h = c.filter((e) => e.role === t.SCATTER_SIZE), g = d[0], _ = f[0], v = p[0], y = h[0], b = u(_?.dataItem), S = u(v?.dataItem);
116
- G(r, 0, {
117
- x: { field: b },
118
- y: { field: S },
119
- [b]: { field: b },
120
- [S]: { field: S },
121
- ...l
122
- });
123
- let C = e.scatterSettings?.pointSize ?? .1, w = {};
124
- if (y) {
125
- let t = u(y.dataItem);
126
- w = { field: t }, C = (t) => {
127
- let n = e.scatterSettings?.pointSize ?? 0, r = e.scatterSettings?.maxPointSize ?? Math.max(n, 1);
128
- return t.resources.scale(u(y.dataItem))(t.datum.size.value) * (r - n) + n;
129
- }, G(r, 0, {
130
- size: w,
131
- [t]: { field: t }
132
- });
133
- }
134
- let T;
135
- return g ? (G(r, 0, { imageUrl: { field: u(g.dataItem) } }), T = [Le(e, n, C, o, !0, a), ze(e, C, o)]) : T = e.scatterSettings?.spatialHeatmap?.show ? [Re(e, n, r, C, o, a)] : [Le(e, n, C, o, !1, a)], {
136
- ...r,
137
- components: [...r.components, ...T]
138
- };
139
- }, Le = (e, t, n, r, i, a) => {
140
- let o = new ke(e, t, a?.[0]?.itemsNotAffectedByFiltering), s = e.scatterSettings?.shape ?? d.Circle, c = e.scatterSettings?.stroke;
141
- return {
142
- type: z.Point,
143
- layout: { displayOrder: j.VisualizationElement },
144
- key: q(e),
145
- data: { collection: U.Collection },
146
- animations: {
147
- enabled: !i,
148
- presetId: "scatter-chart"
149
- },
150
- settings: {
151
- x: {
152
- scale: U.XAxisScale,
153
- ref: "x"
154
- },
155
- y: {
156
- scale: U.YAxisScale,
157
- ref: "y"
158
- },
159
- opacity: i ? 0 : .8,
160
- stroke: c?.color ?? void 0,
161
- strokeWidth: c?.enabled ? c.width : 0,
162
- shape: s,
163
- size: n,
164
- fill: i ? "transparent" : o.getColorDefinition({
165
- overwriteSources: [o.MAIN_FIELD, "color"],
166
- ref: "color"
167
- }),
168
- tag: Fe
169
- },
170
- brush: i ? null : ue([""], r, { valuePickerMode: r?.valuePickerMode })
171
- };
172
- }, Re = (e, t, n, r, i, a) => {
173
- let o = n.scales[U.Density]?.data, s = a?.[0]?.items?.length, c = n.collections?.[0]?.data?.extract?.[0]?.props?.density?.field && o?.field ? {
174
- scale: U.Density,
175
- ref: "density"
176
- } : {
177
- scale: U.Density,
178
- fn: ({ scale: e }) => {
179
- let t = e?.(1);
180
- return typeof t == "number" ? t : 1;
181
- }
182
- };
183
- return {
184
- type: z.Heatmap,
185
- layout: { displayOrder: j.VisualizationElement },
186
- key: "spatial-heatmap",
187
- animations: s !== void 0 && s < 1e3 ? { enabled: !0 } : void 0,
188
- data: { collection: U.Collection },
189
- settings: {
190
- point: {
191
- x: {
192
- scale: U.XAxisScale,
193
- ref: "x"
194
- },
195
- y: {
196
- scale: U.YAxisScale,
197
- ref: "y"
198
- },
199
- size: r,
200
- density: c
201
- },
202
- gradient: U.DensityGradient,
203
- blur: e.scatterSettings?.spatialHeatmap?.blur,
204
- minOpacity: 1e-4
205
- },
206
- brush: i?.disable?.brushing ? void 0 : { consume: [{
207
- context: W.Selection,
208
- data: [""],
209
- mode: he.And,
210
- style: { inactive: { opacity: .1 } }
211
- }] }
212
- };
213
- }, ze = (e, t, n) => ({
214
- type: z.DomPoint,
215
- layout: { displayOrder: j.VisualizationElement },
216
- key: z.DomPoint,
217
- data: { collection: U.Collection },
218
- settings: {
219
- x: {
220
- scale: U.XAxisScale,
221
- ref: "x"
222
- },
223
- y: {
224
- scale: U.YAxisScale,
225
- ref: "y"
226
- },
227
- opacity: .8,
228
- size: t,
229
- url: { ref: "imageUrl" },
230
- renderCallback: (...e) => {
231
- e.length === 0 && n?.onRenderDone?.();
232
- },
233
- borderWidth: e.scatterSettings?.borderWidth,
234
- borderColor: e.scatterSettings?.borderColor ?? void 0
235
- },
236
- brush: ue([""], n, { valuePickerMode: n?.valuePickerMode })
237
- }), Be = (e, t, n) => {
238
- let { measures: r, grid: i = [] } = e, a = i.filter((e) => e.enabled).map((e) => {
239
- let n = c(r[0].dataItem, e.dataItem);
240
- return ee(e, n ? "x" : "y", n ? U.XAxisScale : U.YAxisScale, t);
241
- }).filter((e) => !!e);
242
- return {
243
- ...n,
244
- components: [...n.components, ...a]
245
- };
246
- }, Ve = (e, t, n) => {
247
- let r = [], i = [];
248
- if (!e.refLines?.x && !e.refLines?.y) return n;
249
- if (e.refLines.x) {
250
- let n = e.refLines.x.map((e) => De(e, U.XAxisScale, t));
251
- r.push(...n);
252
- }
253
- if (e.refLines.y) {
254
- let n = e.refLines.y.map((e) => De(e, U.YAxisScale, t));
255
- i.push(...n);
256
- }
257
- let a = {
258
- type: z.RefLine,
259
- layout: { displayOrder: j.RefLine },
260
- lines: {
261
- x: r,
262
- y: i
263
- }
264
- };
265
- return {
266
- ...n,
267
- components: [...n.components, a]
268
- };
269
- }, He = "scatter-reference-areas", J = "scatter-reference-area", Ue = n("scatter-reference-areas-stage", "#6B7280"), Y = (e) => {
270
- if (e == null) return null;
271
- let t = g(e);
272
- if (t === null) return null;
273
- let n = typeof t == "number" ? t : Number(t);
274
- return Number.isNaN(n) ? null : n;
275
- }, We = (e) => {
276
- if (e == null) return;
277
- let t = g(e);
278
- if (t === null || typeof t != "string") return;
279
- let n = t.trim();
280
- return n.length > 0 ? n : void 0;
281
- }, Ge = (e, t) => {
282
- if (e.enabled === !1) return;
283
- let n = Y(e.xMin), r = Y(e.xMax), i = Y(e.yMin), a = Y(e.yMax);
284
- if (n === null || r === null || i === null || a === null) {
285
- Ue.warn("Skipping reference area due to incomplete bounds", {
286
- id: e.id,
287
- index: t
288
- });
289
- return;
290
- }
291
- let o = We(e.label), s = e.fillColor ?? y.referenceArea.fillColor, c = e.border?.enabled ?? y.referenceArea.border?.enabled ?? !1, l = c ? e.border?.color ?? y.referenceArea.border?.color ?? void 0 : void 0, u = c ? e.border?.width ?? y.referenceArea.border?.width ?? 1 : void 0, [d, f] = n <= r ? [n, r] : [r, n], [p, m] = i <= a ? [i, a] : [a, i], h = e.labelMode ?? y.referenceArea.labelMode, g = e.labelPlacement ?? y.referenceArea.labelPlacement, _ = e.labelColor ?? y.referenceArea.labelColor, v = e.labelFontSize ?? y.referenceArea.labelFontSize;
292
- return {
293
- id: e.id,
294
- label: o,
295
- labelMode: h,
296
- labelPlacement: g,
297
- labelColor: _,
298
- labelFontSize: v,
299
- xMin: d,
300
- xMax: f,
301
- yMin: p,
302
- yMax: m,
303
- fillColor: s,
304
- borderColor: l,
305
- borderWidth: u
306
- };
307
- }, Ke = (e) => {
308
- let t = {
309
- id: { value: e.id },
310
- labelMode: { value: e.labelMode },
311
- labelPlacement: { value: e.labelPlacement },
312
- labelColor: { value: e.labelColor },
313
- labelFontSize: { value: e.labelFontSize },
314
- start: { value: e.yMin },
315
- end: { value: e.yMax },
316
- binStart: { value: e.xMin },
317
- binEnd: { value: e.xMax },
318
- xMin: { value: e.xMin },
319
- xMax: { value: e.xMax },
320
- yMin: { value: e.yMin },
321
- yMax: { value: e.yMax },
322
- fillColor: { value: e.fillColor }
323
- };
324
- return e.label && (t.label = { value: e.label }), e.borderColor && (t.borderColor = { value: e.borderColor }), typeof e.borderWidth == "number" && (t.borderWidth = { value: e.borderWidth }), t;
325
- }, qe = (e) => {
326
- switch (e) {
327
- case o.TopLeft: return {
328
- align: 0,
329
- justify: 0
330
- };
331
- case o.Top: return {
332
- align: .5,
333
- justify: 0
334
- };
335
- case o.TopRight: return {
336
- align: 1,
337
- justify: 0
338
- };
339
- case o.Left: return {
340
- align: 0,
341
- justify: .5
342
- };
343
- case o.Right: return {
344
- align: 1,
345
- justify: .5
346
- };
347
- case o.BottomLeft: return {
348
- align: 0,
349
- justify: 1
350
- };
351
- case o.Bottom: return {
352
- align: .5,
353
- justify: 1
354
- };
355
- case o.BottomRight: return {
356
- align: 1,
357
- justify: 1
358
- };
359
- case o.Center:
360
- default: return {
361
- align: .5,
362
- justify: .5
363
- };
364
- }
365
- }, Je = (e, t, n) => {
366
- if (e.labelMode !== l.Fixed || !e.label) return null;
367
- let { align: r, justify: i } = qe(e.labelPlacement), a = y.referenceArea.labelColor, o = y.referenceArea.labelFontSize, s = e.labelColor ?? a, c = e.labelFontSize ?? o;
368
- return {
369
- type: z.Labels,
370
- key: `${J}-${e.id}-label`,
371
- layout: { displayOrder: t },
372
- settings: { sources: [{
373
- component: `${J}-${e.id}`,
374
- selector: be.Rect,
375
- strategy: {
376
- type: "rows",
377
- settings: {
378
- align: r,
379
- justify: i,
380
- fontSize: c,
381
- fontFamily: n.fonts?.general?.fontFamily,
382
- padding: 2,
383
- labels: [{
384
- label: () => e.label ?? "",
385
- fill: s
386
- }]
387
- }
388
- }
389
- }] },
390
- animations: { enabled: !1 },
391
- brush: null
392
- };
393
- }, Ye = (e, t, n) => {
394
- let r = {
395
- orientation: p.Vertical,
396
- major: {
397
- scale: U.XAxisScale,
398
- ref: "binEnd",
399
- binStart: { ref: "binStart" },
400
- binEnd: { ref: "binEnd" }
401
- },
402
- minor: {
403
- scale: U.YAxisScale,
404
- ref: "end"
405
- },
406
- minor0: {
407
- scale: U.YAxisScale,
408
- ref: "start"
409
- },
410
- box: {
411
- fill: e.fillColor ?? y.referenceArea.fillColor,
412
- opacity: 1,
413
- stroke: e.borderColor ?? "transparent",
414
- strokeWidth: e.borderWidth ?? 0,
415
- ignoreOutOfBounds: !0
416
- }
417
- };
418
- return {
419
- type: z.Box,
420
- key: `${J}-${e.id}`,
421
- layout: { displayOrder: t },
422
- data: {
423
- collection: He,
424
- filter: (e, t) => t === n
425
- },
426
- settings: r,
427
- animations: { enabled: !1 },
428
- brush: null
429
- };
430
- }, Xe = (e, t, n) => {
431
- let r = e.referenceAreas ?? [];
432
- if (!r.length) return n;
433
- let i = r.map(Ge).filter((e) => e !== void 0);
434
- if (!i.length) return n;
435
- let a = i.map(Ke), o = n.collections ? [...n.collections] : [];
436
- o.push({
437
- key: He,
438
- data: {
439
- items: a,
440
- map: ({ value: e }) => e,
441
- extract: []
442
- }
443
- });
444
- let s = n.components ? [...n.components] : [], c = i.length;
445
- return i.forEach((e, n) => {
446
- let r = j.ReferenceArea + (c - n) * .001, i = Ye(e, r, n);
447
- s.push(i);
448
- let a = Je(e, r + 5e-4, t);
449
- a && s.push(a);
450
- }), {
451
- ...n,
452
- collections: o,
453
- components: s
454
- };
455
- }, Ze = (e, t, n) => {
456
- let r = t.data.value, i = e.filter((e) => x(e)).filter((e) => e.role === m.SCATTER_DIMENSION)[0];
457
- return i?.formatter && (r = n.formatter(i.formatter)(r)), `${r}`;
458
- }, X = (e) => typeof e == "string" && e.startsWith("scatter-reference-area") && !e.endsWith("-label"), Z = (e) => {
459
- let t = e.data?.labelMode;
460
- if (typeof t == "string") return t;
461
- if (t && typeof t == "object" && "value" in t) {
462
- let e = t.value;
463
- if (typeof e == "string") return e;
464
- }
465
- }, Q = (e) => {
466
- let t = e.data?.label, n;
467
- if (typeof t == "string") n = t;
468
- else if (t && typeof t == "object" && t && "value" in t) {
469
- let e = t.value;
470
- n = typeof e == "string" ? e : void 0;
471
- }
472
- if (!n) return;
473
- let r = n.trim();
474
- return r.length > 0 ? r : void 0;
475
- }, $ = (e) => ({
476
- title: e,
477
- props: []
478
- }), Qe = (e, t, n) => {
479
- let r = {
480
- filter: (t) => {
481
- let n = [
482
- q(e),
483
- L,
484
- K
485
- ];
486
- return t.filter((e) => e.key ? X(e.key) ? Z(e) !== l.Fixed && !!Q(e) : n.includes(e.key) : !1);
487
- },
488
- placement: {
489
- type: "pointer",
490
- area: "target"
491
- }
492
- };
493
- if (n.components.find((e) => e.key === "spatial-heatmap")) {
494
- let e = ({ node: e, resources: t }) => ({
495
- title: e.data.label,
496
- props: [
497
- "x",
498
- "y",
499
- "size",
500
- "density"
501
- ].flatMap((n) => {
502
- let r = e.data[n], i = r?.source?.field;
503
- return i ? [{
504
- label: t.dataset("").field(i)?.title() ?? "",
505
- value: r.label ?? ""
506
- }] : [];
507
- })
508
- });
509
- r.extract = (t) => {
510
- if (X(t.node.key)) {
511
- let e = Q(t.node), n = Z(t.node);
512
- if (e && n !== l.Fixed) return $(e);
513
- }
514
- return e(t);
515
- };
516
- let t = Te();
517
- r.content = ({ h: e, data: n }) => {
518
- if (n.length > 8) {
519
- let e = n.length;
520
- n = n.slice(0, 5), n.push({
521
- title: `+ ${e - n.length} more`,
522
- props: []
523
- });
524
- }
525
- return t({
526
- h: e,
527
- data: n
528
- });
529
- };
530
- } else {
531
- let n = Ee(e, t, Ce, Ze);
532
- r.extract = (e) => {
533
- if (X(e.node.key)) {
534
- let t = Q(e.node), n = Z(e.node);
535
- if (t && n !== l.Fixed) return $(t);
536
- }
537
- return n(e);
538
- };
539
- }
540
- return pe(e, t, n, r, "tooltip", void 0, {
541
- componentKeys: [q(e)],
542
- yieldToComponentKeys: [L, K]
543
- });
544
- }, $e = (e, t, n) => {
545
- let r = e?.measures[0], i = {
546
- showAxisTooltip: e?.axes?.primaryMeasure?.showAxisTooltip,
547
- formatter: r?.formatter,
548
- scale: _e(e),
549
- key: oe.Measure,
550
- settings: { direction: se(e) }
551
- }, a = e?.measures[1], [o, s] = ae([i, {
552
- showAxisTooltip: e?.axes?.secondaryMeasure?.showAxisTooltip,
553
- formatter: a?.formatter,
554
- scale: fe(e, a),
555
- key: oe.MeasureSec,
556
- settings: {
557
- direction: ne(e),
558
- labelDock: F(Se(e), a?.secondaryAxis)
559
- }
560
- }]);
561
- return {
562
- ...n,
563
- components: [...n.components ?? [], ...o],
564
- interactions: [...n.interactions ?? [], ...s]
565
- };
566
- }, et = (e, t, n) => de(e, t, n), tt = (e) => {
567
- try {
568
- return !!e && A(e);
569
- } catch {
570
- return !1;
571
- }
572
- }, nt = (e, t, n, r, i, o) => {
573
- if (o?.disable?.brushing || o?.disable?.brushingLasso) return n;
574
- let s = tt(t?.colors?.sheetBackgroundColor) ? a.white : a.mainDarkNavy, c = e.scatterSettings?.lasso, l = c?.strokeColor ?? s, u = {
575
- type: z.Lasso,
576
- key: z.Lasso,
577
- layout: { displayOrder: j.VisualizationElement + 1 },
578
- settings: {
579
- brush: { components: [{
580
- key: q(e),
581
- contexts: [W.Selection],
582
- action: "toggle"
583
- }, {
584
- key: K,
585
- contexts: [W.Selection],
586
- action: "toggle"
587
- }] },
588
- lasso: {
589
- strokeWidth: 2,
590
- strokeDasharray: "4",
591
- stroke: l
592
- },
593
- snapIndicator: { stroke: l },
594
- startPoint: {
595
- r: 3,
596
- fill: c?.startPointColor ?? a.secondaryPurple,
597
- stroke: l
598
- }
599
- }
600
- }, d = {
601
- type: "native",
602
- key: `${z.Lasso}-interaction`,
603
- events: {
604
- mousedown(e) {
605
- this.chart.component(z.Lasso).emit("lassoStart", { center: {
606
- x: e.clientX,
607
- y: e.clientY
608
- } });
609
- },
610
- mousemove(e) {
611
- this.chart.component(z.Lasso).emit("lassoMove", { center: {
612
- x: e.clientX,
613
- y: e.clientY
614
- } });
615
- },
616
- mouseup(e) {
617
- this.chart.component(z.Lasso).emit("lassoEnd", { center: {
618
- x: e.clientX,
619
- y: e.clientY
620
- } });
621
- }
622
- }
623
- };
624
- return {
625
- ...n,
626
- components: [...n.components, u],
627
- interactions: [...n.interactions ?? [], d]
628
- };
629
- }, rt = (e, t, n, r, i, a) => {
630
- let o = e.scatterSettings?.spatialHeatmap?.show && e.dimensions.length < 2;
631
- if (!e.pointLabeling?.enabled || o) return n;
632
- let s = e.pointLabeling, c = 4 + (e.scatterSettings?.stroke?.enabled ? e.scatterSettings.stroke.width / 2 : 0), l = ce({
633
- targetComponentKeys: [q(e)],
634
- targetSelector: `.${Fe}`,
635
- offset: c,
636
- fontSize: we(e.pointLabeling?.fontSize)
637
- }, s, a, t);
638
- return l ? {
639
- ...n,
640
- components: [...n.components, l]
641
- } : n;
642
- }, it = (...e) => {
643
- let t = Oe(...e), n = t.components.find((e) => e.type === me.SequentialLegend), r = t.scales[U.Density];
644
- if (n && r) {
645
- n.settings.fill = U.DensityGradient;
646
- let e = n.layout?.dock;
647
- n.settings.major = e === f.Left || e === f.Right ? U.DensityInverted : U.Density;
648
- }
649
- return t;
650
- }, at = class extends P {
651
- constructor() {
652
- super([
653
- ve,
654
- Pe,
655
- Be,
656
- Xe,
657
- Ie,
658
- Me,
659
- Ve,
660
- it,
661
- et,
662
- rt,
663
- Qe,
664
- nt,
665
- $e
666
- ]);
667
- }
668
- preCompile(e) {
669
- let n = e.dimensions.filter((e) => x(e)), r = e.measures.filter((e) => x(e)), i = n.filter((e) => e.role === m.SCATTER_DIMENSION), a = r.filter((e) => e.role === t.SCATTER_HORIZONTAL), o = r.filter((e) => e.role === t.SCATTER_VERTICAL), s = i[0], c = a[0], l = o[0];
670
- if (!s || !c || !l) throw Error("Scatter chart requires at least 1 scatter dimension, 1 horizontal measure, and 1 vertical measure.");
671
- }
672
- }, ot = O(), st = T(({ vSpec: e, vTheme: t, data: n, elementSize: r, vizProperties: i }) => {
673
- let a = w(), [o] = (0, je.useState)(() => new at()), s = D(), { activeKey: c } = k(), l = C(), u = xe();
674
- if (!e || !n || !r || !h(e)) return null;
675
- let d = {
676
- ...i,
677
- valuePickerMode: !!c
678
- }, f = t || b, p = o.compile(e, f, n, r, {
679
- ...d,
680
- onRenderDone: s
681
- }, v.Scatter, a, l, u);
682
- return p ? /* @__PURE__ */ (0, ot.jsx)(ge, {
683
- config: d,
684
- definition: p,
685
- size: r,
686
- vSpec: e
687
- }) : null;
688
- });
689
- export { st as ScatterChart };