@astrato-io/visualizations 0.11.0 → 0.12.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 (135) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +129 -4
  3. package/VISUALIZATION_DEFINITIONS.md +3 -1
  4. package/chunks/{Button-CPG4WX8X.js → Button-CQdoKSXX.js} +3 -3
  5. package/chunks/{CircularProgress-PSLW8HmD.js → CircularProgress-DpT1lwWw.js} +18 -18
  6. package/chunks/FieldTypeIcon-Cg4F9Q5D.js +22 -0
  7. package/chunks/{LinearProgress-KQ2EQlGL.js → LinearProgress-B7S0Q26A.js} +8 -8
  8. package/chunks/{MenuOption-B-6K7kks.js → MenuOption-DpKFJxmo.js} +133 -133
  9. package/chunks/{Title-BmvwZYkh.js → Title-m5damhc0.js} +10 -10
  10. package/chunks/{_createAggregator-CFmH6gUN.js → _createAggregator-BA8_iU9q.js} +7 -7
  11. package/chunks/{app-filter-bar.compiler-BY5-T16I.js → app-filter-bar.compiler--T4Qz3Wu.js} +3 -3
  12. package/chunks/{bar-layout-BNou0dZF.js → bar-layout-OFhxn2Go.js} +2 -2
  13. package/chunks/{bar.compiler-BkhO7sDd.js → bar.compiler-hWZBYYvV.js} +62 -62
  14. package/chunks/{builder-CNjuqD2z.js → builder-7w_bgV_h.js} +31 -31
  15. package/chunks/{coloring-BOiP0rmn.js → coloring-Cd6p0GQJ.js} +88 -83
  16. package/chunks/{createSimplePaletteValueFilter-BkgQ7MFE.js → createSimplePaletteValueFilter-CiJT8s1s.js} +55 -55
  17. package/chunks/defaults-CMFqXvaJ.js +3 -0
  18. package/chunks/{definitions-AS9GcavE.js → definitions-DTauTjIX.js} +412 -406
  19. package/chunks/{escobar-cQ1eQ64G.js → escobar-CMvphKSK.js} +4787 -4717
  20. package/chunks/{extend-preset-BlCbcXKR.js → extend-preset-BpXttHFk.js} +371 -372
  21. package/chunks/{filter.compiler-CI7dDNM1.js → filter.compiler-DOGFweJz.js} +4 -4
  22. package/chunks/{filtering-Dwi7hDPZ.js → filtering-NOnDcGbo.js} +183 -183
  23. package/chunks/handlers-CyYFSfhM.js +15393 -0
  24. package/chunks/{icon-picker-styles-CBlxEu3s.js → icon-picker-styles-DuSERhBU.js} +2 -2
  25. package/chunks/{isEqual-BdHo6wqq.js → isEqual-4f8yUUtC.js} +1 -1
  26. package/chunks/{isFocusVisible-C1nlVUwL.js → isFocusVisible-Czm70MGc.js} +1 -1
  27. package/chunks/line.compiler-B-4H55_T.js +203 -0
  28. package/chunks/{logger-Bc-DqDM_.js → logger-Cioob-QV.js} +71 -70
  29. package/chunks/{map.compiler-CRO6XpdI.js → map.compiler-Cv5V6EhF.js} +13 -13
  30. package/chunks/measure-axis-label-format-COy8U_dd.js +27 -0
  31. package/chunks/{measure-format-default-B6ghxih7.js → measure-format-default-B_kuGSzi.js} +7 -3
  32. package/chunks/{metadata-CtkvZEhS.js → metadata-dGSe5UWy.js} +5 -5
  33. package/chunks/{number.compiler-kV4lobCZ.js → number.compiler-D7nMcEMv.js} +8 -8
  34. package/chunks/{operations-COl9wgqi.js → operations-CgfehCad.js} +11462 -11223
  35. package/chunks/{range-CMJ5yc5Z.js → range-Dmwp9kVB.js} +2 -2
  36. package/chunks/{react-dom-BjsCbYHq.js → react-dom-CfuL-m78.js} +24 -24
  37. package/chunks/{render-wrappers-DFHi3Wkr.js → render-wrappers--g-zPFBW.js} +1 -1
  38. package/chunks/{requirements-C5YLmHKe.js → requirements-DHayNJ2C.js} +83 -83
  39. package/chunks/{shared-DyqxOie0.js → shared-DoEN9nNM.js} +282 -277
  40. package/chunks/standalone-B3hRGgYi.js +773 -0
  41. package/chunks/{standalone-BYK2U0Vd.js → standalone-BPNXgFft.js} +380 -380
  42. package/chunks/standalone-BPTT8XEu.js +424 -0
  43. package/chunks/standalone-BgAeHROc.js +2 -0
  44. package/chunks/{standalone-I5kRIsp8.js → standalone-BkQxag7M.js} +81 -81
  45. package/chunks/{standalone-DYVYccmY.js → standalone-Bxa3x6dg.js} +913 -913
  46. package/chunks/standalone-C0If-V6O.js +773 -0
  47. package/chunks/standalone-C1TOyflX.js +287 -0
  48. package/chunks/{standalone-DaNxWIKn.js → standalone-CE5PwJN0.js} +21 -21
  49. package/chunks/{standalone-K2OvRAQM.js → standalone-CG7IFN6n.js} +121 -121
  50. package/chunks/{standalone-Db_HNuWx.js → standalone-CKlgGu80.js} +44 -44
  51. package/chunks/standalone-CNf-oA2U.js +355 -0
  52. package/chunks/{standalone-9jrQ3zJT.js → standalone-CXPdWFlw.js} +10 -10
  53. package/chunks/{standalone-c4CPN6ug.js → standalone-Cf0_5tbu.js} +5783 -5785
  54. package/chunks/{standalone-Bp4G3MDx.js → standalone-DMi4-Vp3.js} +118 -118
  55. package/chunks/{standalone-BrjtMIdd.js → standalone-DTEX67C8.js} +108 -108
  56. package/chunks/{standalone-iOnJhCvA.js → standalone-DU46-kYv.js} +181 -181
  57. package/chunks/standalone-Dbn3jSH6.js +690 -0
  58. package/chunks/{standalone-CS5VGoja.js → standalone-DdcAL_k_.js} +833 -837
  59. package/chunks/standalone-DwCIA0UG.js +1057 -0
  60. package/chunks/standalone-Dz13tl3P.js +357 -0
  61. package/chunks/{standalone-CIjNYyya.js → standalone-H9GFzFk_.js} +937 -938
  62. package/chunks/{standalone-ChfEHb28.js → standalone-MduR0qre.js} +1279 -1279
  63. package/chunks/standalone-ejTz66P3.js +2 -0
  64. package/chunks/{standalone-D9k5SCd8.js → standalone-keB-0wK3.js} +189 -189
  65. package/chunks/{standalone-Bsfz5vnJ.js → standalone-nnkuQd0K.js} +35 -35
  66. package/chunks/standalone-vGGR6Vcn.js +6 -0
  67. package/chunks/{table.compiler-CMH_dtYs.js → table.compiler-mS4UvhLT.js} +12 -12
  68. package/chunks/theme-MYp6Rj1J.js +232 -0
  69. package/chunks/{useFieldName-BfxBzhhH.js → useFieldName-AdSak4Ch.js} +1 -1
  70. package/chunks/{utils-BdJrEeIQ.js → utils-CUKgR7it.js} +3265 -3133
  71. package/chunks/{view-Q-_XIrWE.js → view-BeYwpcVD.js} +478 -478
  72. package/chunks/{visualization-filters-BwS0xUqs.js → visualization-filters-B9qik5_K.js} +2706 -2384
  73. package/chunks/{with-html-element-D_ooGNWI.js → with-html-element-1GSeLT59.js} +3888 -3870
  74. package/definitions.js +2 -2
  75. package/docs/operations/astrato-app-filter-bar.md +1 -1
  76. package/docs/operations/bar.md +115 -32
  77. package/docs/operations/combo.md +50 -17
  78. package/docs/operations/date-picker.md +4 -4
  79. package/docs/operations/distribution-gauge.md +18 -16
  80. package/docs/operations/dot.md +107 -24
  81. package/docs/operations/filter.md +10 -8
  82. package/docs/operations/gauge.md +20 -18
  83. package/docs/operations/heatMap.md +73 -21
  84. package/docs/operations/histogram.md +45 -12
  85. package/docs/operations/iframe.md +1 -1
  86. package/docs/operations/image.md +1 -1
  87. package/docs/operations/index.md +11 -11
  88. package/docs/operations/line.md +57 -24
  89. package/docs/operations/map.md +16 -16
  90. package/docs/operations/number.md +10 -9
  91. package/docs/operations/pie.md +23 -21
  92. package/docs/operations/radar.md +13 -11
  93. package/docs/operations/sankey.md +19 -17
  94. package/docs/operations/scatter.md +111 -28
  95. package/docs/operations/shape.md +5 -5
  96. package/docs/operations/simpleTextObject.md +4 -4
  97. package/docs/operations/slider.md +1 -1
  98. package/docs/operations/table.md +27 -25
  99. package/docs/operations/tree.md +5 -3
  100. package/docs/operations/treemap.md +70 -18
  101. package/docs/operations/waterfall.md +40 -7
  102. package/docs/operations/word-cloud.md +69 -17
  103. package/getters.js +2 -2
  104. package/index.js +474 -525
  105. package/metadata.js +2 -2
  106. package/operations.js +24 -17
  107. package/package.json +71 -72
  108. package/src/definitions/model/definitions/descriptors/descriptor-metadata.d.ts +1 -1
  109. package/src/definitions/model/definitions/schema-registry.d.ts +13 -12
  110. package/src/definitions/model/definitions/schemas/bar.schema.d.ts +2 -2
  111. package/src/definitions/model/definitions/schemas/common.schema.d.ts +5 -4
  112. package/src/definitions/model/definitions/schemas/line.schema.d.ts +3 -2
  113. package/src/definitions/model/definitions/schemas/number.schema.d.ts +1 -1
  114. package/src/definitions/model/definitions/schemas/table.schema.d.ts +14 -14
  115. package/src/index.d.ts +1 -1
  116. package/src/operations/index.d.ts +11 -1
  117. package/src/types.d.ts +166 -1
  118. package/chunks/FieldTypeIcon-5k2bkqd0.js +0 -22
  119. package/chunks/category-axis-D1OVyMrr.js +0 -20
  120. package/chunks/color-rules-DYJL4fIW.js +0 -15
  121. package/chunks/color-settings-DJFoFTip.js +0 -5
  122. package/chunks/defaults-B5_8S-J-.js +0 -3
  123. package/chunks/handlers-C63NVo7i.js +0 -15433
  124. package/chunks/line.compiler-DCv3h42f.js +0 -198
  125. package/chunks/standalone-06i1wmIX.js +0 -6
  126. package/chunks/standalone-B6zUvxNQ.js +0 -357
  127. package/chunks/standalone-Be5APcVv.js +0 -762
  128. package/chunks/standalone-BuXpKMnc.js +0 -2
  129. package/chunks/standalone-CUGt2FUF.js +0 -2
  130. package/chunks/standalone-CnF2OYLQ.js +0 -355
  131. package/chunks/standalone-CznEEiq3.js +0 -422
  132. package/chunks/standalone-DcuE8KBa.js +0 -287
  133. package/chunks/standalone-pCrzBiTy.js +0 -773
  134. package/chunks/standalone-qrZaimgC.js +0 -689
  135. package/chunks/standalone-yqDJ8h3K.js +0 -1012
@@ -1,689 +0,0 @@
1
- import { o as e } from "./rolldown-runtime-DleVn1XH.js";
2
- import { Bi as t, Cc as n, Ec as r, Hc as i, Lc as a, Lo as o, Na as s, Uo as c, Vo as l, Vr as u, Wa as d, Wo as f, cr as p, da as m, fa as h, mc as g, n as _, no as v, po as y, qt as b, ri as x } from "./visualization-filters-BwS0xUqs.js";
3
- import { Br as S, I as C, Mt as w, P as T, Wt as ee, f as E, li as D, s as O } from "./utils-BdJrEeIQ.js";
4
- import "./logger-Bc-DqDM_.js";
5
- import { $t as k, A, An as j, B as te, Bt as M, Cn as N, Ct as P, Dn as ne, E as F, En as re, Gt as ie, Ht as ae, It as oe, Jt as se, L as ce, Mt as I, P as le, Pt as ue, R as de, T as L, Tn as R, Wt as fe, Xt as pe, Yt as me, _ as he, _n as ge, an as z, bn as _e, i as ve, in as B, j as V, jn as H, k as ye, ln as be, n as xe, pn as Se, qt as Ce, tn as we, v as Te, vn as Ee, wn as U, xn as W, yn as De, yt as Oe, zt as ke } from "./escobar-cQ1eQ64G.js";
6
- import { t as Ae } from "./coloring-BOiP0rmn.js";
7
- import { t as je } from "./set-coloring-datafield-B3uIS1Pe.js";
8
- var Me = /* @__PURE__ */ e(D()), Ne = (e, t, n, r, i, a, o, s) => {
9
- let l = [], u = [], f = e.measures.filter((e) => x(e)), m = {
10
- ...t.axis.measure,
11
- ...t.fonts
12
- }, h = [];
13
- if (s) {
14
- let e = we(H.Text, s);
15
- h.push(e);
16
- }
17
- let g = f.filter((e) => e.role === d.SCATTER_HORIZONTAL), _ = f.filter((e) => e.role === d.SCATTER_VERTICAL), v = e.measures.filter((e) => e.role === d.SCATTER_HORIZONTAL), y = e.measures.filter((e) => e.role === d.SCATTER_VERTICAL), b = g[0], S = _[0], C = {};
18
- if (b) {
19
- let t = c.Bottom, n = e.axes?.primaryMeasure || C;
20
- if (l.push(B(W.XAxisScale, n, m, t, b.formatter)), e.axes?.primaryMeasure?.showAxisName) {
21
- let r = p(v, e.enableAlternate, a?.isPrintMode);
22
- u.push(z(g, r, t, m, n.colors?.title, n.axisTitle, n.titleFontSize));
23
- }
24
- }
25
- if (S) {
26
- let t = c.Left, n = e.axes?.secondaryMeasure || C;
27
- if (l.push(B(W.YAxisScale, n, m, t, S.formatter)), e.axes?.secondaryMeasure?.showAxisName) {
28
- let r = p(y, e.enableAlternate, a?.isPrintMode);
29
- u.push(z(_, r, t, m, n.colors?.title, n.axisTitle, n.titleFontSize));
30
- }
31
- }
32
- return {
33
- ...n,
34
- components: [
35
- ...n.components,
36
- ...l,
37
- ...u
38
- ],
39
- interactions: [...n.interactions ?? [], ...h]
40
- };
41
- }, Pe = (e, t) => {
42
- let n = e.dimensions.filter((e) => x(e)), a = e.measures.filter((e) => x(e)), o = n.filter((e) => e.role === v.SCATTER_DIMENSION), s = a.filter((e) => e.role === d.SCATTER_SIZE), c = o[0], l = s[0], { coloring: u } = e || {};
43
- switch (u?.type) {
44
- case r.Categorical: return M(e, t);
45
- case r.Gradient: return ae(e, l);
46
- case r.Single: return i(c.dataItem);
47
- default: return null;
48
- }
49
- }, Fe = (e, n, a, o, s, c, l) => {
50
- let u = e.dimensions.filter((e) => x(e)), f = e.measures.filter((e) => x(e)), p = u.filter((e) => e.role === v.SCATTER_DIMENSION), h = f.filter((e) => e.role === d.SCATTER_HORIZONTAL), g = f.filter((e) => e.role === d.SCATTER_VERTICAL), y = f.filter((e) => e.role === d.SCATTER_SIZE), S = p[0], C = h[0], w = g[0], T = y[0], E = {}, { coloring: D } = e || {}, O = u.length < 2 && e.scatterSettings?.spatialHeatmap?.show, k = O && !D?.fieldId ? null : Pe(e, l);
51
- switch (D?.type) {
52
- case r.Categorical:
53
- E = ke(je(e, k), n, E, void 0, l);
54
- break;
55
- case r.Gradient:
56
- E = ke(je(e, k), n, E, void 0, l);
57
- break;
58
- case r.Single: {
59
- let t = i(S.dataItem);
60
- E[r.Single] = {
61
- data: { extract: { field: t } },
62
- range: [e?.coloring?.color ?? n.colors.brandColors[0]],
63
- type: R.CategoricalColor,
64
- label: (e) => S?.formatter?.format ? ee(S.formatter, e.datum.value) : e.datum.label
65
- };
66
- break;
67
- }
68
- default: break;
69
- }
70
- if (O) {
71
- E[W.Density] = {
72
- data: k ? { field: k } : void 0,
73
- min: 0,
74
- max: (n) => (n.data?.fields?.[0] ? n.data.fields[0].max() : 1) * (b(e.scatterSettings?.spatialHeatmap?.maxDensity ?? t.heatmapMaxDensity) ?? 0),
75
- nice: !0
76
- }, E[W.DensityInverted] = {
77
- ...E[W.Density],
78
- invert: !0
79
- };
80
- let i = [..._(D?.type ?? r.Gradient, n), ...D?.customGradient ? [D.customGradient] : []].find((e) => e.id === (D?.palette ?? n.colors.defaultGradient ?? m.id))?.colors;
81
- E[W.DensityGradient] = {
82
- ...E[W.Density],
83
- range: i ?? m.colors,
84
- type: R.SequentialColor
85
- }, k && I(a, 0, { density: { field: k } });
86
- } else k && I(a, 0, { color: { field: k } });
87
- let j = i(C?.dataItem), te = i(w?.dataItem), M = i(T?.dataItem), N = ye(e?.axes?.primaryMeasure?.axisRange, !0), P = V(N);
88
- E[W.XAxisScale] = {
89
- type: R.Linear,
90
- data: { field: j },
91
- invert: A(!1, e?.axes?.primaryMeasure),
92
- nice: !P && ne.scale.nice,
93
- expandMax: .06,
94
- ...N
95
- };
96
- let F = ye(e?.axes?.secondaryMeasure?.axisRange, !0), re = V(F);
97
- return E[W.YAxisScale] = {
98
- type: R.Linear,
99
- data: { fields: [te] },
100
- invert: A(!0, e?.axes?.secondaryMeasure),
101
- nice: !re && ne.scale.nice,
102
- expandMax: .06,
103
- ...F
104
- }, T && (E[M] = {
105
- type: R.Linear,
106
- data: { field: M }
107
- }), {
108
- ...a,
109
- scales: E
110
- };
111
- }, G = "spatial-heatmap", Ie = "shape", K = (e) => {
112
- let t = e.scatterSettings?.shape ?? o.Circle;
113
- return `${H.Point}-${t}`;
114
- }, Le = (e, t, n, r, 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))), u = s.filter((e) => e.role === v.SCATTER_IMAGE), f = c.filter((e) => e.role === d.SCATTER_HORIZONTAL), p = c.filter((e) => e.role === d.SCATTER_VERTICAL), m = c.filter((e) => e.role === d.SCATTER_SIZE), h = u[0], g = f[0], _ = p[0], y = m[0], b = i(g?.dataItem), S = i(_?.dataItem);
116
- I(n, 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 = i(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(i(y.dataItem))(t.datum.size.value) * (r - n) + n;
129
- }, I(n, 0, {
130
- size: w,
131
- [t]: { field: t }
132
- });
133
- }
134
- let T;
135
- return h ? (I(n, 0, { imageUrl: { field: i(h.dataItem) } }), T = [Re(e, t, C, o, !0, a), Be(e, C, o)]) : T = e.scatterSettings?.spatialHeatmap?.show ? [ze(e, t, n, C, o, a)] : [Re(e, t, C, o, !1, a)], {
136
- ...n,
137
- components: [...n.components, ...T]
138
- };
139
- }, Re = (e, t, n, r, i, a) => {
140
- let s = new Ae(e, t, a?.[0]?.itemsNotAffectedByFiltering), c = e.scatterSettings?.shape ?? o.Circle, l = e.scatterSettings?.stroke;
141
- return {
142
- type: H.Point,
143
- layout: { displayOrder: k.VisualizationElement },
144
- key: K(e),
145
- data: { collection: W.Collection },
146
- animations: {
147
- enabled: !i,
148
- presetId: "scatter-chart"
149
- },
150
- settings: {
151
- x: {
152
- scale: W.XAxisScale,
153
- ref: "x"
154
- },
155
- y: {
156
- scale: W.YAxisScale,
157
- ref: "y"
158
- },
159
- opacity: i ? 0 : .8,
160
- stroke: l?.color ?? void 0,
161
- strokeWidth: l?.enabled ? l.width : 0,
162
- shape: c,
163
- size: n,
164
- fill: i ? "transparent" : s.getColorDefinition({
165
- overwriteSources: [s.MAIN_FIELD, "color"],
166
- ref: "color"
167
- }),
168
- tag: Ie
169
- },
170
- brush: i ? null : be([""], r, { valuePickerMode: r?.valuePickerMode })
171
- };
172
- }, ze = (e, t, n, r, i, a) => {
173
- let o = n.scales[W.Density]?.data, s = a?.[0]?.items?.length, c = n.collections?.[0]?.data?.extract?.[0]?.props?.density?.field && o?.field ? {
174
- scale: W.Density,
175
- ref: "density"
176
- } : {
177
- scale: W.Density,
178
- fn: ({ scale: e }) => {
179
- let t = e?.(1);
180
- return typeof t == "number" ? t : 1;
181
- }
182
- };
183
- return {
184
- type: H.Heatmap,
185
- layout: { displayOrder: k.VisualizationElement },
186
- key: "spatial-heatmap",
187
- animations: s !== void 0 && s < 1e3 ? { enabled: !0 } : void 0,
188
- data: { collection: W.Collection },
189
- settings: {
190
- point: {
191
- x: {
192
- scale: W.XAxisScale,
193
- ref: "x"
194
- },
195
- y: {
196
- scale: W.YAxisScale,
197
- ref: "y"
198
- },
199
- size: r,
200
- density: c
201
- },
202
- gradient: W.DensityGradient,
203
- blur: e.scatterSettings?.spatialHeatmap?.blur,
204
- minOpacity: 1e-4
205
- },
206
- brush: i?.disable?.brushing ? void 0 : { consume: [{
207
- context: U.Selection,
208
- data: [""],
209
- mode: j.And,
210
- style: { inactive: { opacity: .1 } }
211
- }] }
212
- };
213
- }, Be = (e, t, n) => ({
214
- type: H.DomPoint,
215
- layout: { displayOrder: k.VisualizationElement },
216
- key: H.DomPoint,
217
- data: { collection: W.Collection },
218
- settings: {
219
- x: {
220
- scale: W.XAxisScale,
221
- ref: "x"
222
- },
223
- y: {
224
- scale: W.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: be([""], n, { valuePickerMode: n?.valuePickerMode })
237
- }), Ve = (e, t, n) => {
238
- let { measures: r, grid: i = [] } = e, o = i.filter((e) => e.enabled).map((e) => {
239
- let n = a(r[0].dataItem, e.dataItem);
240
- return oe(e, n ? "x" : "y", n ? W.XAxisScale : W.YAxisScale, t);
241
- }).filter((e) => !!e);
242
- return {
243
- ...n,
244
- components: [...n.components, ...o]
245
- };
246
- }, He = (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) => P(e, W.XAxisScale, t));
251
- r.push(...n);
252
- }
253
- if (e.refLines.y) {
254
- let n = e.refLines.y.map((e) => P(e, W.YAxisScale, t));
255
- i.push(...n);
256
- }
257
- let a = {
258
- type: H.RefLine,
259
- layout: { displayOrder: k.RefLine },
260
- lines: {
261
- x: r,
262
- y: i
263
- }
264
- };
265
- return {
266
- ...n,
267
- components: [...n.components, a]
268
- };
269
- }, q = "scatter-reference-areas", J = "scatter-reference-area", Ue = u("scatter-reference-areas-stage", "#6B7280"), Y = (e) => {
270
- if (e == null) return null;
271
- let t = b(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 = b(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, n) => {
282
- if (e.enabled === !1) return;
283
- let r = Y(e.xMin), i = Y(e.xMax), a = Y(e.yMin), o = Y(e.yMax);
284
- if (r === null || i === null || a === null || o === null) {
285
- Ue.warn("Skipping reference area due to incomplete bounds", {
286
- id: e.id,
287
- index: n
288
- });
289
- return;
290
- }
291
- let s = We(e.label), c = e.fillColor ?? t.referenceArea.fillColor, l = e.border?.enabled ?? t.referenceArea.border?.enabled ?? !1, u = l ? e.border?.color ?? t.referenceArea.border?.color ?? void 0 : void 0, d = l ? e.border?.width ?? t.referenceArea.border?.width ?? 1 : void 0, [f, p] = r <= i ? [r, i] : [i, r], [m, h] = a <= o ? [a, o] : [o, a], g = e.labelMode ?? t.referenceArea.labelMode, _ = e.labelPlacement ?? t.referenceArea.labelPlacement, v = e.labelColor ?? t.referenceArea.labelColor, y = e.labelFontSize ?? t.referenceArea.labelFontSize;
292
- return {
293
- id: e.id,
294
- label: s,
295
- labelMode: g,
296
- labelPlacement: _,
297
- labelColor: v,
298
- labelFontSize: y,
299
- xMin: f,
300
- xMax: p,
301
- yMin: m,
302
- yMax: h,
303
- fillColor: c,
304
- borderColor: u,
305
- borderWidth: d
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 l.TopLeft: return {
328
- align: 0,
329
- justify: 0
330
- };
331
- case l.Top: return {
332
- align: .5,
333
- justify: 0
334
- };
335
- case l.TopRight: return {
336
- align: 1,
337
- justify: 0
338
- };
339
- case l.Left: return {
340
- align: 0,
341
- justify: .5
342
- };
343
- case l.Right: return {
344
- align: 1,
345
- justify: .5
346
- };
347
- case l.BottomLeft: return {
348
- align: 0,
349
- justify: 1
350
- };
351
- case l.Bottom: return {
352
- align: .5,
353
- justify: 1
354
- };
355
- case l.BottomRight: return {
356
- align: 1,
357
- justify: 1
358
- };
359
- case l.Center:
360
- default: return {
361
- align: .5,
362
- justify: .5
363
- };
364
- }
365
- }, Je = (e, n, r) => {
366
- if (e.labelMode !== y.Fixed || !e.label) return null;
367
- let { align: i, justify: a } = qe(e.labelPlacement), o = t.referenceArea.labelColor, s = t.referenceArea.labelFontSize, c = e.labelColor ?? o, l = e.labelFontSize ?? s;
368
- return {
369
- type: H.Labels,
370
- key: `${J}-${e.id}-label`,
371
- layout: { displayOrder: n },
372
- settings: { sources: [{
373
- component: `${J}-${e.id}`,
374
- selector: N.Rect,
375
- strategy: {
376
- type: "rows",
377
- settings: {
378
- align: i,
379
- justify: a,
380
- fontSize: l,
381
- fontFamily: r.fonts?.general?.fontFamily,
382
- padding: 2,
383
- labels: [{
384
- label: () => e.label ?? "",
385
- fill: c
386
- }]
387
- }
388
- }
389
- }] },
390
- animations: { enabled: !1 },
391
- brush: null
392
- };
393
- }, Ye = (e, n, r) => {
394
- let i = {
395
- orientation: f.Vertical,
396
- major: {
397
- scale: W.XAxisScale,
398
- ref: "binEnd",
399
- binStart: { ref: "binStart" },
400
- binEnd: { ref: "binEnd" }
401
- },
402
- minor: {
403
- scale: W.YAxisScale,
404
- ref: "end"
405
- },
406
- minor0: {
407
- scale: W.YAxisScale,
408
- ref: "start"
409
- },
410
- box: {
411
- fill: e.fillColor ?? t.referenceArea.fillColor,
412
- opacity: 1,
413
- stroke: e.borderColor ?? "transparent",
414
- strokeWidth: e.borderWidth ?? 0,
415
- ignoreOutOfBounds: !0
416
- }
417
- };
418
- return {
419
- type: H.Box,
420
- key: `${J}-${e.id}`,
421
- layout: { displayOrder: n },
422
- data: {
423
- collection: q,
424
- filter: (e, t) => t === r
425
- },
426
- settings: i,
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: q,
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 = k.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 === v.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
- K(e),
483
- L,
484
- G
485
- ];
486
- return t.filter((e) => e.key ? X(e.key) ? Z(e) !== y.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 !== y.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 = de(e, t, Oe, 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 !== y.Fixed) return $(t);
536
- }
537
- return n(e);
538
- };
539
- }
540
- return ce(e, t, n, r, "tooltip", void 0, {
541
- componentKeys: [K(e)],
542
- yieldToComponentKeys: [L, G]
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: Ee(e),
549
- key: ie.Measure,
550
- settings: { direction: Ce(e) }
551
- }, a = e?.measures[1], [o, s] = pe([i, {
552
- showAxisTooltip: e?.axes?.secondaryMeasure?.showAxisTooltip,
553
- formatter: a?.formatter,
554
- scale: De(e, a),
555
- key: ie.MeasureSec,
556
- settings: {
557
- direction: me(e),
558
- labelDock: se(_e(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) => le(e, t, n), tt = (e) => {
567
- try {
568
- return !!e && Se(e);
569
- } catch {
570
- return !1;
571
- }
572
- }, nt = (e, t, n, r, i, a) => {
573
- if (a?.disable?.brushing || a?.disable?.brushingLasso) return n;
574
- let o = tt(t?.colors?.sheetBackgroundColor) ? s.white : s.mainDarkNavy, c = e.scatterSettings?.lasso, l = c?.strokeColor ?? o, u = {
575
- type: H.Lasso,
576
- key: H.Lasso,
577
- layout: { displayOrder: k.VisualizationElement + 1 },
578
- settings: {
579
- brush: { components: [{
580
- key: K(e),
581
- contexts: [U.Selection],
582
- action: "toggle"
583
- }, {
584
- key: G,
585
- contexts: [U.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 ?? s.secondaryPurple,
597
- stroke: l
598
- }
599
- }
600
- }, d = {
601
- type: "native",
602
- key: `${H.Lasso}-interaction`,
603
- events: {
604
- mousedown(e) {
605
- this.chart.component(H.Lasso).emit("lassoStart", { center: {
606
- x: e.clientX,
607
- y: e.clientY
608
- } });
609
- },
610
- mousemove(e) {
611
- this.chart.component(H.Lasso).emit("lassoMove", { center: {
612
- x: e.clientX,
613
- y: e.clientY
614
- } });
615
- },
616
- mouseup(e) {
617
- this.chart.component(H.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 = F({
633
- targetComponentKeys: [K(e)],
634
- targetSelector: `.${Ie}`,
635
- offset: c,
636
- fontSize: ge(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 = ue(...e), n = t.components.find((e) => e.type === re.SequentialLegend), r = t.scales[W.Density];
644
- if (n && r) {
645
- n.settings.fill = W.DensityGradient;
646
- let e = n.layout?.dock;
647
- n.settings.major = e === c.Left || e === c.Right ? W.DensityInverted : W.Density;
648
- }
649
- return t;
650
- }, at = class extends he {
651
- constructor() {
652
- super([
653
- fe,
654
- Fe,
655
- Ve,
656
- Xe,
657
- Le,
658
- Ne,
659
- He,
660
- it,
661
- et,
662
- rt,
663
- Qe,
664
- nt,
665
- $e
666
- ]);
667
- }
668
- preCompile(e) {
669
- let t = e.dimensions.filter((e) => x(e)), n = e.measures.filter((e) => x(e)), r = t.filter((e) => e.role === v.SCATTER_DIMENSION), i = n.filter((e) => e.role === d.SCATTER_HORIZONTAL), a = n.filter((e) => e.role === d.SCATTER_VERTICAL), o = r[0], s = i[0], c = a[0];
670
- if (!o || !s || !c) throw Error("Scatter chart requires at least 1 scatter dimension, 1 horizontal measure, and 1 vertical measure.");
671
- }
672
- }, ot = S(), st = w(({ vSpec: e, vTheme: t, data: r, elementSize: i, vizProperties: a }) => {
673
- let o = T(), [s] = (0, Me.useState)(() => new at()), c = E(), { activeKey: l } = O(), u = C(), d = xe();
674
- if (!e || !r || !i || !g(e)) return null;
675
- let f = {
676
- ...a,
677
- valuePickerMode: !!l
678
- }, p = t || h, m = s.compile(e, p, r, i, {
679
- ...f,
680
- onRenderDone: c
681
- }, n.Scatter, o, u, d);
682
- return m ? /* @__PURE__ */ (0, ot.jsx)(ve, {
683
- config: f,
684
- definition: m,
685
- size: i,
686
- vSpec: e
687
- }) : null;
688
- });
689
- export { st as ScatterChart };