@astrato-io/visualizations 0.10.1 → 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 (143) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/README.md +148 -5
  3. package/THIRD_PARTY_NOTICES.md +494 -0
  4. package/VISUALIZATION_DEFINITIONS.md +9 -146
  5. package/chunks/{Button-Dn3rJrYf.js → Button-CQdoKSXX.js} +3 -3
  6. package/chunks/{CircularProgress-BFeu06Yb.js → CircularProgress-DpT1lwWw.js} +20 -20
  7. package/chunks/FieldTypeIcon-Cg4F9Q5D.js +22 -0
  8. package/chunks/{LinearProgress-ClO6GUjN.js → LinearProgress-B7S0Q26A.js} +14 -14
  9. package/chunks/{MenuOption-Czc34u4q.js → MenuOption-DpKFJxmo.js} +167 -167
  10. package/chunks/{Title-BgYnaVTR.js → Title-m5damhc0.js} +37 -37
  11. package/chunks/{_createAggregator-BMu9uRax.js → _createAggregator-BA8_iU9q.js} +17 -17
  12. package/chunks/{app-filter-bar.compiler-CVir0wkl.js → app-filter-bar.compiler--T4Qz3Wu.js} +8 -8
  13. package/chunks/{bar-layout-C_UgRlVl.js → bar-layout-OFhxn2Go.js} +2 -2
  14. package/chunks/{bar.compiler-DYuFdi9J.js → bar.compiler-hWZBYYvV.js} +71 -69
  15. package/chunks/{builder-C-TKA-My.js → builder-7w_bgV_h.js} +106 -55
  16. package/chunks/{coloring-BtnPiQ_o.js → coloring-Cd6p0GQJ.js} +93 -88
  17. package/chunks/{createSimplePaletteValueFilter--zrZxRV9.js → createSimplePaletteValueFilter-CiJT8s1s.js} +169 -169
  18. package/chunks/defaults-CMFqXvaJ.js +3 -0
  19. package/chunks/{definitions-CT304NDn.js → definitions-DTauTjIX.js} +399 -398
  20. package/chunks/{escobar-CvEV2ES1.js → escobar-CMvphKSK.js} +4949 -4879
  21. package/chunks/{extend-preset-D9-JP92b.js → extend-preset-BpXttHFk.js} +449 -450
  22. package/chunks/{filter.compiler-CXeZznks.js → filter.compiler-DOGFweJz.js} +10 -10
  23. package/chunks/{filtering-8_bFv-jb.js → filtering-NOnDcGbo.js} +241 -241
  24. package/chunks/handlers-CyYFSfhM.js +15393 -0
  25. package/chunks/{icon-picker-styles-BXiJ1SZS.js → icon-picker-styles-DuSERhBU.js} +8 -8
  26. package/chunks/{isEqual-D8Ay63xR.js → isEqual-4f8yUUtC.js} +1 -1
  27. package/chunks/{isFocusVisible-Bu8gGZu5.js → isFocusVisible-Czm70MGc.js} +9 -9
  28. package/chunks/line.compiler-B-4H55_T.js +203 -0
  29. package/chunks/linear-Bq_r9l5S.js +264 -0
  30. package/chunks/{logger-DdZpR7xZ.js → logger-Cioob-QV.js} +74 -73
  31. package/chunks/{lookup-BWllin0q.js → lookup-B3tWH2hX.js} +1 -0
  32. package/chunks/{map.compiler-Q_Y1Pvat.js → map.compiler-Cv5V6EhF.js} +40 -40
  33. package/chunks/measure-axis-label-format-COy8U_dd.js +27 -0
  34. package/chunks/measure-format-default-B_kuGSzi.js +26 -0
  35. package/chunks/{metadata-BQm_TXI1.js → metadata-dGSe5UWy.js} +5 -5
  36. package/chunks/number.compiler-D7nMcEMv.js +57 -0
  37. package/chunks/{operations-DKQWuLL7.js → operations-CgfehCad.js} +11397 -11114
  38. package/chunks/{range-BdhzvYQ_.js → range-Dmwp9kVB.js} +2 -2
  39. package/chunks/{react-dom-BGP4tbXV.js → react-dom-CfuL-m78.js} +82 -82
  40. package/chunks/{render-wrappers-BZpyDnJy.js → render-wrappers--g-zPFBW.js} +1 -1
  41. package/chunks/{requirements-e8Fe96ag.js → requirements-DHayNJ2C.js} +245 -221
  42. package/chunks/{shared-C_2F90xq.js → shared-DoEN9nNM.js} +505 -494
  43. package/chunks/standalone-B3hRGgYi.js +773 -0
  44. package/chunks/{standalone-BkbiH-o8.js → standalone-BPNXgFft.js} +498 -759
  45. package/chunks/standalone-BPTT8XEu.js +424 -0
  46. package/chunks/standalone-BgAeHROc.js +2 -0
  47. package/chunks/{standalone-BE_ONgiG.js → standalone-BkQxag7M.js} +102 -102
  48. package/chunks/{standalone-Cc98Pdr6.js → standalone-Bxa3x6dg.js} +872 -872
  49. package/chunks/standalone-C0If-V6O.js +773 -0
  50. package/chunks/standalone-C1TOyflX.js +287 -0
  51. package/chunks/{standalone-CY_kjarf.js → standalone-CE5PwJN0.js} +18 -18
  52. package/chunks/{standalone-B8ZSqauS.js → standalone-CG7IFN6n.js} +120 -120
  53. package/chunks/{standalone-wOWRCpdn.js → standalone-CKlgGu80.js} +49 -49
  54. package/chunks/standalone-CNf-oA2U.js +355 -0
  55. package/chunks/{standalone-BDrXVxlP.js → standalone-CXPdWFlw.js} +14 -14
  56. package/chunks/{standalone-z0o52o5t.js → standalone-Cf0_5tbu.js} +5567 -5568
  57. package/chunks/{standalone-Cl0TSfqC.js → standalone-DMi4-Vp3.js} +122 -122
  58. package/chunks/{standalone-DNh9NcMa.js → standalone-DTEX67C8.js} +154 -154
  59. package/chunks/{standalone-DHRalbVO.js → standalone-DU46-kYv.js} +279 -279
  60. package/chunks/standalone-Dbn3jSH6.js +690 -0
  61. package/chunks/{standalone-CsoMmE9T.js → standalone-DdcAL_k_.js} +839 -843
  62. package/chunks/standalone-DwCIA0UG.js +1057 -0
  63. package/chunks/standalone-Dz13tl3P.js +357 -0
  64. package/chunks/standalone-H9GFzFk_.js +8377 -0
  65. package/chunks/{standalone-CaTxAydz.js → standalone-MduR0qre.js} +2227 -1000
  66. package/chunks/standalone-ejTz66P3.js +2 -0
  67. package/chunks/{standalone-DflyWtuR.js → standalone-keB-0wK3.js} +216 -216
  68. package/chunks/{standalone-BTY3w_JA.js → standalone-nnkuQd0K.js} +28 -28
  69. package/chunks/standalone-vGGR6Vcn.js +6 -0
  70. package/chunks/{table.compiler-COaHE9VD.js → table.compiler-mS4UvhLT.js} +31 -31
  71. package/chunks/theme-MYp6Rj1J.js +232 -0
  72. package/chunks/{useFieldName-CdnCWzhd.js → useFieldName-AdSak4Ch.js} +1 -1
  73. package/chunks/{utils-DganVptf.js → utils-CUKgR7it.js} +4216 -4070
  74. package/chunks/{view-Bzlros43.js → view-BeYwpcVD.js} +1561 -1561
  75. package/chunks/{visualization-filters-D7i6oh1Z.js → visualization-filters-B9qik5_K.js} +2683 -2342
  76. package/chunks/{with-html-element-CiIhFEa5.js → with-html-element-1GSeLT59.js} +3712 -3682
  77. package/definitions.js +2 -2
  78. package/docs/operations/astrato-app-filter-bar.md +1 -1
  79. package/docs/operations/bar.md +144 -32
  80. package/docs/operations/combo.md +79 -17
  81. package/docs/operations/date-picker.md +4 -4
  82. package/docs/operations/distribution-gauge.md +18 -16
  83. package/docs/operations/dot.md +107 -24
  84. package/docs/operations/filter.md +10 -8
  85. package/docs/operations/gauge.md +20 -18
  86. package/docs/operations/heatMap.md +73 -21
  87. package/docs/operations/histogram.md +45 -12
  88. package/docs/operations/iframe.md +1 -1
  89. package/docs/operations/image.md +1 -1
  90. package/docs/operations/index.md +12 -11
  91. package/docs/operations/line.md +86 -24
  92. package/docs/operations/map.md +5274 -0
  93. package/docs/operations/number.md +10 -9
  94. package/docs/operations/pie.md +23 -21
  95. package/docs/operations/radar.md +13 -11
  96. package/docs/operations/sankey.md +19 -17
  97. package/docs/operations/scatter.md +111 -28
  98. package/docs/operations/shape.md +5 -5
  99. package/docs/operations/simpleTextObject.md +4 -4
  100. package/docs/operations/slider.md +1 -1
  101. package/docs/operations/table.md +27 -25
  102. package/docs/operations/tree.md +5 -3
  103. package/docs/operations/treemap.md +70 -18
  104. package/docs/operations/waterfall.md +40 -7
  105. package/docs/operations/word-cloud.md +69 -17
  106. package/getters.js +3 -3
  107. package/index.js +585 -612
  108. package/metadata.js +2 -2
  109. package/operations.js +25 -18
  110. package/package.json +74 -70
  111. package/src/definitions/index.d.ts +1 -7
  112. package/src/definitions/model/definitions/descriptors/descriptor-metadata.d.ts +3 -48
  113. package/src/definitions/model/definitions/schema-registry.d.ts +15 -14
  114. package/src/definitions/model/definitions/schemas/bar.schema.d.ts +3 -3
  115. package/src/definitions/model/definitions/schemas/broad-chart.schema.d.ts +2 -2
  116. package/src/definitions/model/definitions/schemas/common.schema.d.ts +19 -6
  117. package/src/definitions/model/definitions/schemas/index.d.ts +1 -1
  118. package/src/definitions/model/definitions/schemas/line.schema.d.ts +4 -3
  119. package/src/definitions/model/definitions/schemas/number.schema.d.ts +1 -1
  120. package/src/definitions/model/definitions/schemas/table.schema.d.ts +14 -14
  121. package/src/index.d.ts +1 -1
  122. package/src/operations/index.d.ts +11 -1
  123. package/src/types.d.ts +166 -1
  124. package/src/visualization-catalog.d.ts +3 -0
  125. package/styles.css +1 -1
  126. package/chunks/FieldTypeIcon-DrMoGpHJ.js +0 -22
  127. package/chunks/color-rules-DYJL4fIW.js +0 -15
  128. package/chunks/color-settings-DJFoFTip.js +0 -5
  129. package/chunks/defaults-Dtk7fg3C.js +0 -3
  130. package/chunks/handlers-C6CZ0XJA.js +0 -15399
  131. package/chunks/line.compiler-DmHpmQCC.js +0 -198
  132. package/chunks/number.compiler-DQdg6zTy.js +0 -53
  133. package/chunks/standalone-4MsKiqs0.js +0 -355
  134. package/chunks/standalone-B794g9pE.js +0 -1012
  135. package/chunks/standalone-BA2YXyJS.js +0 -422
  136. package/chunks/standalone-BgumbdaJ2.js +0 -357
  137. package/chunks/standalone-Blh4qejk.js +0 -689
  138. package/chunks/standalone-CXY4FpF7.js +0 -773
  139. package/chunks/standalone-DH0xTEes.js +0 -2
  140. package/chunks/standalone-DcnHjNnC.js +0 -2
  141. package/chunks/standalone-DrHdGkY7.js +0 -762
  142. package/chunks/standalone-c_rROMtx.js +0 -287
  143. package/chunks/standalone-drcFLeN6.js +0 -6
@@ -1,762 +0,0 @@
1
- import "./rolldown-runtime-DleVn1XH.js";
2
- import { Fc as e, Io as t, Lo as n, Oa as r, Qr as i, Ut as a, ds as o, gc as s, hc as c, ii as l, in as u, rr as d, sa as f, ts as p } from "./visualization-filters-D7i6oh1Z.js";
3
- import { F as m, N as h, Zt as g, ci as _, jt as v, s as y, zr as b } from "./utils-DganVptf.js";
4
- import { g_ as x } from "./handlers-C6CZ0XJA.js";
5
- import { t as S } from "./stroke-dash-UgMEcCS4.js";
6
- import "./logger-DdZpR7xZ.js";
7
- import { r as ee } from "./extend-preset-D9-JP92b.js";
8
- import { Ht as te, Jt as ne, Kt as re, L as ie, M as ae, Qt as oe, R as se, S as C, Tt as ce, Ut as w, V as T, _ as E, bn as D, cn as O, dn as k, fn as le, i as ue, ln as A, mn as de, n as fe, on as pe, qt as me, sn as he, un as j, ut as M, v as ge, xt as N, y as _e } from "./escobar-CvEV2ES1.js";
9
- import { p as ve } from "./with-html-element-CiIhFEa5.js";
10
- import "./builder-C-TKA-My.js";
11
- _();
12
- function P(e) {
13
- let { measureProps: t, index: n, items: r, vSpec: i } = e, { positive: a, negative: o } = ye(t, i), s;
14
- return s = n === 0 ? r[0] > 0 ? a : o : r[n] > r[n - 1] ? a : o, s;
15
- }
16
- function ye(e, t) {
17
- let n = t.colors;
18
- if (!e?.customColorEnabled) return xe({ ...n }, t);
19
- let { customColor: r } = e;
20
- return xe({
21
- positive: r.positive ?? n.positive,
22
- negative: r.negative ?? n.negative,
23
- subTotal: r.subTotal ?? n.subTotal
24
- }, t);
25
- }
26
- function be(e, t) {
27
- let n = e.measureProps[t];
28
- return n?.customColorEnabled && n?.customColor.subTotal ? n?.customColor.subTotal : e.colors.subTotal;
29
- }
30
- function xe(e, t) {
31
- return t.barSettings.translucentBars ? {
32
- positive: F(e.positive, t),
33
- negative: F(e.negative, t),
34
- subTotal: F(e.subTotal, t)
35
- } : e;
36
- }
37
- var Se = .65, Ce = 1;
38
- function F(e, t) {
39
- return (n) => {
40
- if (typeof n.datum.end.value != "number" || typeof n.datum.start.value != "number") return null;
41
- let r = n.datum.end.value - n.datum.start.value;
42
- n.datum.reverted.value && (r *= -1);
43
- let i = [{
44
- color: e,
45
- opacity: Ce,
46
- offset: +(r < 0)
47
- }, {
48
- color: e,
49
- opacity: Se,
50
- offset: r < 0 ? 0 : 1
51
- }];
52
- return r < 0 && i.reverse(), {
53
- type: "gradient",
54
- degree: A(t) ? 0 : 90,
55
- stops: i
56
- };
57
- };
58
- }
59
- var we = (e, t) => t || e.colors.brandColors[0], Te = "subTotal-measure", I = (e) => `${Te}-${e}`, L = "total-measure", Ee = (e) => `${s.Waterfall}.subTotal.${e}`, R = `${s.Waterfall}.total`;
60
- function z(e) {
61
- return ({ data: t, formatter: n }) => {
62
- let r = t?.end.value - t?.start.value;
63
- return t?.reverted?.value && (r *= -1), e.formatter && r && n ? n(e.formatter)(`${r}`) : `${r}`;
64
- };
65
- }
66
- var B = "waterfall-chart", V = {
67
- scale: "onlyMeasures",
68
- ref: "series"
69
- };
70
- function H(e) {
71
- return {
72
- collection: "collection-no-dimension",
73
- filter: (t) => t?.source?.field === e
74
- };
75
- }
76
- function De(e, t, r) {
77
- let i = H(I(r)), a = {
78
- scale: e.orientation === n.Horizontal ? j.XAxisScale : j.YAxisScale,
79
- ref: "end"
80
- }, o = be(e, r);
81
- return {
82
- type: D.Box,
83
- layout: { displayOrder: w.VisualizationElement },
84
- key: Ee(r),
85
- data: i,
86
- settings: U(e, t, V, a, o),
87
- animations: {
88
- enabled: !0,
89
- presetId: B
90
- }
91
- };
92
- }
93
- function Oe(e, t) {
94
- let r = H(L), i = {
95
- scale: e.orientation === n.Horizontal ? j.XAxisScale : j.YAxisScale,
96
- ref: "end"
97
- }, a = e.total.color;
98
- return {
99
- type: D.Box,
100
- layout: { displayOrder: w.VisualizationElement },
101
- key: R,
102
- data: r,
103
- settings: U(e, t, V, i, a),
104
- animations: {
105
- enabled: !0,
106
- presetId: B
107
- }
108
- };
109
- }
110
- var ke = (e, t, n, r) => ({
111
- type: D.Box,
112
- layout: { displayOrder: w.VisualizationElement },
113
- key: N(e, t, s.Waterfall),
114
- data: r,
115
- settings: n,
116
- animations: {
117
- enabled: !0,
118
- presetId: B
119
- }
120
- }), U = (e, t, i, o, s) => {
121
- let c = {
122
- orientation: e.orientation ?? n.Vertical,
123
- major: i,
124
- minor: o,
125
- box: {
126
- minWidthPx: 2,
127
- ref: "",
128
- rx: a(e.barSettings.barRadius, 0),
129
- fill: s,
130
- stacked: !1,
131
- grouped: !1,
132
- boxPadding: e.barSettings.barPadding ?? 0,
133
- groupPadding: 0,
134
- itemsInStackCount: 0,
135
- roundAllEdges: e.barSettings.roundAllEdges ?? !1,
136
- useCustomBoxRounding: e.barSettings.useCustomBoxRounding ?? !1,
137
- ignoreOutOfBounds: e.barSettings.ignoreOutOfBounds ?? !1
138
- }
139
- };
140
- return e.barSettings?.strokeEnabled ? (c.box.stroke = we(t, e.barSettings?.strokeColor ?? ""), c.box.strokeWidth = e.barSettings?.strokeWidth) : c.box.stroke = r.transparent, c;
141
- }, Ae = "collection-no-dimension", je = "onlyMeasures";
142
- x.Inside, x.Outside, x.Opposite;
143
- function W(t, n) {
144
- let r = t.measures.filter((e) => i(e));
145
- return r.filter((i, a) => {
146
- let o = e(i.dataItem), s = n[0].items[0][o], c = t.measureProps[o];
147
- if (a === 0) return !!s || !c?.hideIfEmpty;
148
- let l = e(r[a - 1].dataItem);
149
- return s !== n[0].items[0][l] || !c?.hideIfEmpty;
150
- });
151
- }
152
- var Me = (e, n, r, a, o, s, c, l) => {
153
- r = re(e, n, r, a, o, s, c, l);
154
- let u = [], f = [];
155
- if ("axes" in e) {
156
- let r = e.axes?.dimension || {};
157
- if (!r.disabled) {
158
- let a = A(e) ? t.Left : t.Bottom;
159
- if (u.push(me(je, r, {
160
- ...n.axis.measure,
161
- ...n.fonts
162
- }, a)), r.showAxisName) {
163
- let t = e.measures.filter((e) => i(e)), o = t.length ? t : e.measures;
164
- if (o.length) {
165
- let t = d(e.measures, !!e.enableAlternate, s?.isPrintMode);
166
- f.push(ne(o, t, a, {
167
- ...n.axis.measure,
168
- ...n.fonts
169
- }, void 0, r.axisTitle ?? "Measures", r.titleFontSize, "waterfall-measures-axis-label"));
170
- }
171
- }
172
- }
173
- }
174
- return {
175
- ...r,
176
- components: [
177
- ...r.components,
178
- ...u,
179
- ...f
180
- ]
181
- };
182
- }, Ne = (t, n, r, i, a) => {
183
- if (!a) return r;
184
- let s = ae(t, {});
185
- (t.axes?.primaryMeasure?.axisRange?.axisRangeOption ?? o.Auto) === o.Auto && (A(t) ? s[j.XAxisScale].expand = .3 : s[j.YAxisScale].expand = .3);
186
- let c = [];
187
- return W(t, a).forEach((n, r) => {
188
- let i = e(n.dataItem), a = u(n);
189
- c.push({
190
- value: i,
191
- label: a || n.label || n.dataItem.name
192
- });
193
- let o = t.measureProps[i];
194
- o?.subTotalEnabled && c.push({
195
- value: I(r),
196
- label: o?.subTotalLabel || "Sub-Total"
197
- });
198
- }), t.total.enabled && c.push({
199
- value: L,
200
- label: t.total.label || "Total"
201
- }), s.onlyMeasures = {
202
- data: { items: c },
203
- padding: t.barSettings.barPadding ?? 0,
204
- type: de.Band,
205
- value: (e) => `${e.datum.value.value}`,
206
- label: (e) => `${e.datum.value.label}`
207
- }, {
208
- ...r,
209
- scales: s
210
- };
211
- }, G = "measures", Pe = (t, n, r, a, o) => {
212
- if (!o) return r;
213
- let s = [], c, l = W(t, o), u = ge((t.supportingMeasures ?? []).filter((e) => i(e)));
214
- if (l.forEach((n, r) => {
215
- let i = e(n.dataItem), a, o;
216
- if (r === 0) a = 0, o = { field: i }, c = "end";
217
- else if (c === "start") a = { field: e(l[r - 1].dataItem) }, o = { field: i }, c = "end";
218
- else {
219
- let t = e(l[r - 1].dataItem);
220
- a = { field: i }, o = { field: t }, c = "start";
221
- }
222
- s.push({
223
- field: i,
224
- props: {
225
- stackKey: G,
226
- [i]: { field: i },
227
- ...u,
228
- series: i,
229
- start: a,
230
- color: i,
231
- end: o,
232
- secondaryAxis: n.secondaryAxis,
233
- isMultipleMeasures: !0,
234
- subTotal: !1,
235
- reverted: c === "start"
236
- }
237
- });
238
- let d = t.measureProps[i];
239
- if (d?.subTotalEnabled) {
240
- let e = I(r), t, n;
241
- c === "end" ? (t = 0, n = { field: i }) : (t = { field: i }, n = 0), s.push({
242
- field: e,
243
- props: {
244
- stackKey: G,
245
- ...u,
246
- series: e,
247
- start: t,
248
- color: e,
249
- end: n,
250
- secondaryAxis: !1,
251
- isMultipleMeasures: !0,
252
- label: d?.subTotalLabel || "Sub-Total",
253
- subTotal: !0,
254
- reverted: c === "start"
255
- }
256
- });
257
- }
258
- }), t.total.enabled) {
259
- let n = e(l[l.length - 1].dataItem), r, i;
260
- c === "end" ? (r = 0, i = { field: n }) : (r = { field: n }, i = 0), s.push({
261
- field: L,
262
- props: {
263
- stackKey: G,
264
- ...u,
265
- series: L,
266
- start: r,
267
- color: L,
268
- end: i,
269
- secondaryAxis: !1,
270
- isMultipleMeasures: !0,
271
- label: t.total.label || "Total",
272
- subTotal: !0,
273
- reverted: c === "start"
274
- }
275
- });
276
- }
277
- let d = {
278
- key: Ae,
279
- data: { extract: s }
280
- };
281
- return {
282
- ...r,
283
- collections: [d]
284
- };
285
- }, Fe = (t, n, r, i, a) => {
286
- if (!a) return r;
287
- let o = Object.values(a[0].items[0]), s = W(t, a).reduce((r, i, a) => {
288
- let s = e(i.dataItem), c = H(s), l = {
289
- scale: O(t, i),
290
- ref: "end"
291
- }, u = P({
292
- measureProps: t.measureProps[s],
293
- index: a,
294
- items: o,
295
- vSpec: t
296
- }), d = [...r], f = U(t, n, V, l, u);
297
- return d.push(ke(t, i, f, c)), t.measureProps[s]?.subTotalEnabled && d.push(De(t, n, a)), d;
298
- }, []);
299
- return t.total.enabled && s.push(Oe(t, n)), {
300
- ...r,
301
- components: [...r.components, ...s]
302
- };
303
- }, Ie = [{ position: x.Outside }, {
304
- position: x.Inside,
305
- justify: 1
306
- }], Le = (t, n, r, i, a) => {
307
- if (!a) return r;
308
- let o = [], s = W(t, a);
309
- return s.forEach((r, i) => {
310
- if (!r.dataLabels?.show) return;
311
- o.push(Be(t, n, r, i));
312
- let a = e(r.dataItem);
313
- t.measureProps[a]?.subTotalEnabled && o.push(ze(t, n, r, i));
314
- }), t.total.enabled && t.total.showDataLabel && o.push(Re(t, n, s)), {
315
- ...r,
316
- components: [...r.components, ...o]
317
- };
318
- }, K = {
319
- layout: { displayOrder: w.Labels },
320
- animations: {
321
- enabled: !0,
322
- presetId: "chart-labels"
323
- }
324
- };
325
- function Re(e, t, n) {
326
- let r = n[n.length - 1], i = z(r);
327
- return {
328
- ...K,
329
- type: D.Labels,
330
- key: "bar-labels-normal-total",
331
- settings: q(e, t, R, i, e.total?.showLabelBackdrop, e.total?.labelFontSize)
332
- };
333
- }
334
- function ze(e, t, n, r) {
335
- return {
336
- ...K,
337
- type: D.Labels,
338
- key: `bar-labels-normal-${r}-sub`,
339
- settings: q(e, t, Ee(r), z(n), n.dataLabels?.showBackdrop, n.dataLabels?.size)
340
- };
341
- }
342
- function Be(e, t, n, r) {
343
- let i = N(e, n, s.Waterfall);
344
- return {
345
- ...K,
346
- type: D.Labels,
347
- key: `bar-labels-normal-${r}`,
348
- settings: q(e, t, i, z(n), n.dataLabels?.showBackdrop, n.dataLabels?.size)
349
- };
350
- }
351
- function q(e, t, n, r, i = !1, a = k.dataPoint.valueFontSize) {
352
- return { sources: [{
353
- component: n,
354
- selector: le.Rect,
355
- strategy: {
356
- type: "bar",
357
- settings: {
358
- direction: Ve(e),
359
- fontSize: pe(a),
360
- fontFamily: t.fonts.general.fontFamily,
361
- labels: [{
362
- label: r,
363
- placements: i ? Ie.map((n) => _e(n, t, A(e))) : Ie
364
- }]
365
- }
366
- }
367
- }] };
368
- }
369
- function Ve(e) {
370
- return ({ data: t }) => {
371
- if (!t) return null;
372
- let n = t.end.value > t.start.value;
373
- return (t.reverted?.value ? !n : n) ? A(e) ? "right" : "up" : A(e) ? "left" : "down";
374
- };
375
- }
376
- var He = {
377
- curve: p.Linear,
378
- line: {
379
- stroke: r.grey1,
380
- strokeWidth: 2,
381
- strokeDasharray: S({
382
- space: 1,
383
- width: 4
384
- }),
385
- show: !0
386
- }
387
- }, Ue = {
388
- scale: je,
389
- ref: "series"
390
- }, We = {
391
- enabled: !0,
392
- presetId: "simple-opacity"
393
- }, Ge = (e, t, n) => {
394
- if (!e.showLines || !n.collections) return n;
395
- let r = n.collections[0].data.extract, i = "end", a = r.slice(0, -1).map((t, n) => {
396
- let a = i;
397
- return r[n + 1].props?.subTotal || (i = i === "start" ? "end" : "start"), {
398
- type: D.Line,
399
- layout: { displayOrder: w.VisualizationElement },
400
- key: `${s.Line}.${n}`,
401
- data: {
402
- collection: Ae,
403
- filter: (e, t) => [n, n + 1].includes(t)
404
- },
405
- settings: Ke(e, a),
406
- animations: We
407
- };
408
- });
409
- return {
410
- ...n,
411
- components: [...n.components, ...a]
412
- };
413
- };
414
- function Ke(e, t) {
415
- let r = A(e);
416
- return {
417
- layers: He,
418
- coordinates: {
419
- major: Ue,
420
- minor: {
421
- scale: r ? j.XAxisScale : j.YAxisScale,
422
- ref: t
423
- }
424
- },
425
- orientation: r ? n.Vertical : n.Horizontal
426
- };
427
- }
428
- var qe = (e, t, n) => {
429
- let r = e.measures.filter(i), a = r.map((t) => N(e, t, s.Waterfall));
430
- return ie(e, t, n, {
431
- filter: (e) => e.filter((e) => e.data?.subTotal?.value || a.findIndex((t) => t === e.key) !== -1),
432
- placement: {
433
- type: "bounds",
434
- area: "target"
435
- },
436
- extract: se({
437
- ...e,
438
- measures: r
439
- }, t, Je, () => "")
440
- }, `tooltip-${D.Box}`);
441
- }, Je = (t, n, r, i, a, o, s, c) => {
442
- let { formatter: l } = r, d = n.data, f = T(r), p = t.filter((t) => !f.has(e(t.dataItem))), m = t.filter((t) => f.has(e(t.dataItem))).flatMap((t) => {
443
- let r = e(t.dataItem), i = Object.keys(n.data).find((e) => n.data[e]?.source?.field === r);
444
- if (!i) return [];
445
- let a = n.data[i]?.value, o = a;
446
- return !c && t?.formatter && l ? o = l(t.formatter)(a) : c && l && (o = l(M(t?.formatter))(a)), [{
447
- label: u(t) || t.label || t.dataItem.name || "",
448
- value: o
449
- }];
450
- });
451
- if (d.subTotal.value) {
452
- let e = d.label, t = d.reverted.value ? d.start.value : d.end.value, r;
453
- if (n.key === R) {
454
- let e = p[p.length - 1];
455
- r = !c && e?.formatter && l ? l(e.formatter)(t) : t;
456
- } else {
457
- let e = parseInt(n.data._configOrder, 10), i = e > 0 ? p[e - 1] : void 0;
458
- r = !c && i?.formatter && l ? l(i.formatter)(t) : t;
459
- }
460
- return [{
461
- label: e.value.toString(),
462
- value: r
463
- }, ...m];
464
- } else {
465
- let n = d.series.value.toString(), r = t.find((t) => e(t.dataItem) === n), i = (d.reverted.value ? -1 : 1) * (d.end.value - d.start.value), a = i;
466
- return !c && r?.formatter && l ? a = l(r.formatter)(i) : c && l && (a = l(M(r?.formatter))(i)), [{
467
- label: (r ? u(r) : "") || r?.label || r?.dataItem.name || "",
468
- value: a
469
- }, ...m];
470
- }
471
- }, J = {
472
- id: "__waterfall_comparison_id",
473
- kind: "__waterfall_comparison_kind",
474
- start: "__waterfall_comparison_start",
475
- end: "__waterfall_comparison_end",
476
- change: "__waterfall_comparison_change",
477
- label: "__waterfall_comparison_label"
478
- };
479
- function Y(e) {
480
- return e.dimensions?.filter(i).length === 1 && e.measures.filter(i).length === 2;
481
- }
482
- function Ye(e) {
483
- return u(e) || e.label || e.dataItem.name || "";
484
- }
485
- function X(e) {
486
- return typeof e == "number" && Number.isFinite(e) ? e : 0;
487
- }
488
- function Xe(t, n) {
489
- if (!n.items.length) return n;
490
- let [r, a] = t.measures.filter(i), o = e(r.dataItem), s = e(a.dataItem), c = n.items.reduce((e, t) => e + X(t[o]), 0), l = n.items.reduce((e, t) => e + X(t[s]), 0), u = t.measureProps?.[s]?.hideIfEmpty ?? !1, d = /* @__PURE__ */ new Set([...n.fields.map((e) => e.dataItemId), ...n.items.flatMap((e) => Object.keys(e))]), f = Object.fromEntries([...d].map((e) => [e, null])), p = (t, n, r) => ({
491
- ...f,
492
- [e(t.dataItem)]: r,
493
- [J.id]: n,
494
- [J.kind]: n,
495
- [J.start]: 0,
496
- [J.end]: r,
497
- [J.change]: r,
498
- [J.label]: Ye(t)
499
- }), m = c, h = n.items.flatMap((e, t) => {
500
- let n = X(e[s]) - X(e[o]), r = m;
501
- return m += n, u && n === 0 ? [] : [{
502
- ...e,
503
- [J.id]: `category-${t}`,
504
- [J.kind]: "change",
505
- [J.start]: r,
506
- [J.end]: m,
507
- [J.change]: n,
508
- [J.label]: ""
509
- }];
510
- });
511
- return {
512
- ...n,
513
- items: [
514
- p(r, "opening", c),
515
- ...h,
516
- p(a, "closing", l)
517
- ]
518
- };
519
- }
520
- var Z = "waterfall-comparison", Q = {
521
- opening: "waterfall.comparison.opening",
522
- positive: "waterfall.comparison.positive",
523
- negative: "waterfall.comparison.negative",
524
- closing: "waterfall.comparison.closing"
525
- }, Ze = (t, n, r, a, s, c, u, d) => {
526
- let f = {
527
- ...t,
528
- barSettings: {
529
- ...l.barSettings,
530
- ...t.barSettings
531
- },
532
- colors: {
533
- ...l.colors,
534
- ...t.colors
535
- },
536
- measures: t.measures.map((e) => ({
537
- ...e,
538
- secondaryAxis: !1
539
- }))
540
- }, [p, m] = f.measures.filter(i), [h] = f.dimensions.filter(i), g = e(h.dataItem), _ = (f.supportingMeasures ?? []).filter(i), v = he(f), y = O(f, p);
541
- r = {
542
- ...r,
543
- collections: [{
544
- key: Z,
545
- data: { extract: [{
546
- field: J.id,
547
- props: {
548
- kind: { field: J.kind },
549
- category: { field: g },
550
- start: { field: J.start },
551
- end: { field: J.end },
552
- change: { field: J.change },
553
- endpointLabel: { field: J.label },
554
- reverted: !1,
555
- ...Object.fromEntries([p, m].map((t) => {
556
- let n = e(t.dataItem);
557
- return [n, { field: n }];
558
- })),
559
- ...ge(_)
560
- }
561
- }] }
562
- }],
563
- scales: ae(f, {})
564
- };
565
- let b = {
566
- type: de.Band,
567
- data: { items: (s?.[0]?.items ?? []).map((e) => ({
568
- value: String(e[J.id]),
569
- label: e[J.label],
570
- kind: e[J.kind],
571
- category: e[g]
572
- })) },
573
- padding: f.barSettings.barPadding,
574
- invert: f.axes?.dimension?.invertAxis,
575
- value: ({ datum: e }) => e.value.value,
576
- label: ({ datum: e, resources: t }) => e.value.kind === "change" ? t.chart.dataset("0").field(g).formatter()(e.value.category) : e.value.label
577
- };
578
- r.scales[v] = b, r.scales[y].data = { fields: [J.start, J.end] }, (f.axes?.primaryMeasure?.axisRange?.axisRangeOption ?? o.Auto) === o.Auto && (r.scales[y].expand = .3), r = re({
579
- ...f,
580
- dimensions: f.dimensions.map((e) => ({
581
- ...e,
582
- formatter: void 0
583
- }))
584
- }, n, r, a, s, c, u, d), r.components = r.components.map((e) => e.type === D.Axis && e.scale === v ? {
585
- ...e,
586
- key: "axis.waterfall.comparison.dimension",
587
- brush: void 0
588
- } : e), r = ce(f, n, r, a, s);
589
- let x = [], S = [], ee = { scale: v }, ne = {
590
- scale: y,
591
- ref: "end"
592
- }, C = f.measureProps?.[e(m.dataItem)], T = C && {
593
- ...C,
594
- customColor: {
595
- ...f.colors,
596
- ...C.customColor
597
- }
598
- }, E = (e, t, r, i, a) => {
599
- x.push({
600
- key: e,
601
- type: D.Box,
602
- layout: { displayOrder: w.VisualizationElement },
603
- data: {
604
- collection: Z,
605
- filter: r
606
- },
607
- settings: U(f, n, ee, ne, i),
608
- brush: a ? oe(["category"], c, { valuePickerMode: c?.valuePickerMode }) : void 0,
609
- animations: {
610
- enabled: !0,
611
- presetId: "simple-opacity"
612
- }
613
- }), t.dataLabels?.show && S.push({
614
- key: `${e}.labels`,
615
- type: D.Labels,
616
- layout: { displayOrder: w.Labels },
617
- settings: q(f, n, e, ({ data: e, formatter: n }) => t.formatter && n ? n(t.formatter)(e.change.value) : String(e.change.value), t.dataLabels.showBackdrop, t.dataLabels.size),
618
- animations: {
619
- enabled: !0,
620
- presetId: "chart-labels"
621
- }
622
- });
623
- }, k = (t) => {
624
- let n = f.measureProps?.[e(t.dataItem)];
625
- return n?.customColorEnabled && n.customColor?.subTotal || f.colors.subTotal;
626
- };
627
- return E(Q.opening, p, (e) => e.kind.value === "opening", k(p), !1), E(Q.positive, m, (e) => e.kind.value === "change" && Number(e.change.value) >= 0, P({
628
- measureProps: T,
629
- index: 0,
630
- items: [1],
631
- vSpec: f
632
- }), !0), E(Q.negative, m, (e) => e.kind.value === "change" && Number(e.change.value) < 0, P({
633
- measureProps: T,
634
- index: 0,
635
- items: [-1],
636
- vSpec: f
637
- }), !0), E(Q.closing, m, (e) => e.kind.value === "closing", k(m), !1), r = {
638
- ...r,
639
- components: [
640
- ...r.components,
641
- ...x,
642
- ...S
643
- ]
644
- }, f.showLines && r.components.push(Qe(f, n.axis.dimension.lineColor)), r = ie(f, n, r, {
645
- filter: (e) => e.filter((e) => Object.values(Q).includes(e.key)),
646
- placement: {
647
- type: "bounds",
648
- area: "target"
649
- },
650
- extract: se(f, n, $e, (e, t) => String(t.data.kind.value === "change" ? t.data.category.label : t.data.endpointLabel.value))
651
- }), te(f, n, r, a, s);
652
- };
653
- function Qe(e, t) {
654
- let n = he(e), r = O(e, void 0), i = !!e.axes?.dimension?.invertAxis, a = {
655
- scale: n,
656
- fn: (e) => Number(e.scale(e.datum.value)) + (i ? 0 : e.scale.bandwidth())
657
- }, o = {
658
- scale: n,
659
- fn: (e, t) => e.data.items[t + 1] ? Number(e.scale(e.data.items[t + 1].value)) + (i ? e.scale.bandwidth() : 0) : 1
660
- }, s = {
661
- scale: r,
662
- ref: "end"
663
- };
664
- return {
665
- key: "waterfall.comparison.connectors",
666
- type: D.LineCoord,
667
- layout: { displayOrder: w.VisualizationElement },
668
- data: { collection: Z },
669
- settings: {
670
- ...A(e) ? {
671
- x0: s,
672
- x1: s,
673
- y0: a,
674
- y1: o
675
- } : {
676
- x0: a,
677
- x1: o,
678
- y0: s,
679
- y1: s
680
- },
681
- show: (e, t) => !!e.data.items[t + 1],
682
- stroke: t,
683
- strokeWidth: 1,
684
- strokeDasharray: "2 2"
685
- },
686
- animations: {
687
- enabled: !0,
688
- presetId: "simple-opacity"
689
- }
690
- };
691
- }
692
- var $e = (t, n, r, i, a, o, s, c) => {
693
- let l = n.data.kind.value, u = l === "opening" ? t[0] : t[1], d = l === "change" ? t : [u], f = (e, t) => {
694
- let n = c ? M(e?.formatter) : e?.formatter;
695
- return n && r.formatter ? r.formatter(n)(t) : t ?? "";
696
- }, p = d.map((t) => ({
697
- label: Ye(t),
698
- value: f(t, n.data[e(t.dataItem)]?.value)
699
- }));
700
- return l === "change" && p.push({
701
- label: "Change",
702
- value: f(t[1], n.data.change.value)
703
- }), p;
704
- }, et = class extends E {
705
- constructor() {
706
- let e = [
707
- Pe,
708
- Ne,
709
- Me,
710
- ce,
711
- Fe,
712
- Le,
713
- Ge,
714
- qe,
715
- te
716
- ];
717
- super([(t, ...n) => {
718
- if (Y(t)) return Ze(t, ...n);
719
- let [r, i, ...a] = n;
720
- return e.reduce((e, n) => n(t, r, e, ...a), i);
721
- }]);
722
- }
723
- preCompile(e, t) {
724
- if (Y(e)) {
725
- t[0] = Xe(e, C(e, t)[0]);
726
- return;
727
- }
728
- let n = [];
729
- Object.entries(t[0].items[0]).forEach(([e, t]) => {
730
- if (n.length === 0) n.push([e, t]);
731
- else {
732
- let r = t + n[n.length - 1][1];
733
- n.push([e, r]);
734
- }
735
- }), t[0].items[0] = Object.fromEntries(n), tt(e) && (e.measureProps = ee);
736
- }
737
- };
738
- function tt(e) {
739
- return e.measures.filter((e) => i(e)).every((e) => e.dataItem.internalKey.startsWith("internalKeyMeasure"));
740
- }
741
- var $ = b(), nt = new et(), rt = v(({ vSpec: e, vTheme: t, data: n, elementSize: r, vizProperties: a }) => {
742
- let o = h(), { activeKey: l } = y(), u = m(), d = g(), p = fe();
743
- if (!n || !e || !c(e)) return null;
744
- let _ = e.dimensions.some(i), v = _ ? !n[0]?.items.length : it(n);
745
- if (!a.isFetchingData && v) return /* @__PURE__ */ (0, $.jsx)(ve, { vBackendAPI: d });
746
- if (v || !r) return null;
747
- let b = {
748
- ...a,
749
- valuePickerMode: !!l
750
- }, x = t || f, S = nt.compile(e, x, structuredClone(n), r, b, s.Waterfall, o, u, p);
751
- return S ? /* @__PURE__ */ (0, $.jsx)(ue, {
752
- config: b,
753
- definition: S,
754
- size: r,
755
- vSpec: e,
756
- selectionData: _ ? n[0].items : void 0
757
- }) : null;
758
- });
759
- function it(e) {
760
- return e?.[0].items.length === 0 || !Object.values(e[0].items[0]).some(Boolean);
761
- }
762
- export { rt as WaterfallChart };