@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,762 +0,0 @@
1
- import "./rolldown-runtime-DleVn1XH.js";
2
- import { Cc as e, Hc as t, Na as n, Sc as r, Uo as i, Wo as a, cr as o, cs as s, fa as c, li as l, ln as u, qt as d, ri as f, vs as p } from "./visualization-filters-BwS0xUqs.js";
3
- import { Br as m, I as h, Mt as g, P as ee, Qt as _, li as v, s as te } from "./utils-BdJrEeIQ.js";
4
- import { v_ as y } from "./handlers-C63NVo7i.js";
5
- import { t as b } from "./stroke-dash-UgMEcCS4.js";
6
- import "./logger-Bc-DqDM_.js";
7
- import { r as x } from "./extend-preset-BlCbcXKR.js";
8
- import { $t as S, Cn as ne, Ft as re, L as ie, M as ae, Qt as oe, R as se, S as C, Sn as w, Tn as ce, V as T, _ as E, _n as le, an as ue, bn as D, bt as O, i as de, in as fe, jn as k, jt as A, ln as pe, n as me, rn as he, v as ge, vn as _e, xn as j, y as ve, yn as M } from "./escobar-cQ1eQ64G.js";
9
- import { p as ye } from "./with-html-element-D_ooGNWI.js";
10
- import "./builder-CNjuqD2z.js";
11
- v();
12
- function N(e) {
13
- let { measureProps: t, index: n, items: r, vSpec: i } = e, { positive: a, negative: o } = be(t, i), s;
14
- return s = n === 0 ? r[0] > 0 ? a : o : r[n] > r[n - 1] ? a : o, s;
15
- }
16
- function be(e, t) {
17
- let n = t.colors;
18
- if (!e?.customColorEnabled) return P({ ...n }, t);
19
- let { customColor: r } = e;
20
- return P({
21
- positive: r.positive ?? n.positive,
22
- negative: r.negative ?? n.negative,
23
- subTotal: r.subTotal ?? n.subTotal
24
- }, t);
25
- }
26
- function xe(e, t) {
27
- let n = e.measureProps[t];
28
- return n?.customColorEnabled && n?.customColor.subTotal ? n?.customColor.subTotal : e.colors.subTotal;
29
- }
30
- function P(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: D(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 = (t) => `${e.Waterfall}.subTotal.${t}`, R = `${e.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, n) {
77
- let r = H(I(n)), i = {
78
- scale: e.orientation === a.Horizontal ? j.XAxisScale : j.YAxisScale,
79
- ref: "end"
80
- }, o = xe(e, n);
81
- return {
82
- type: k.Box,
83
- layout: { displayOrder: S.VisualizationElement },
84
- key: Ee(n),
85
- data: r,
86
- settings: U(e, t, V, i, o),
87
- animations: {
88
- enabled: !0,
89
- presetId: B
90
- }
91
- };
92
- }
93
- function Oe(e, t) {
94
- let n = H(L), r = {
95
- scale: e.orientation === a.Horizontal ? j.XAxisScale : j.YAxisScale,
96
- ref: "end"
97
- }, i = e.total.color;
98
- return {
99
- type: k.Box,
100
- layout: { displayOrder: S.VisualizationElement },
101
- key: R,
102
- data: n,
103
- settings: U(e, t, V, r, i),
104
- animations: {
105
- enabled: !0,
106
- presetId: B
107
- }
108
- };
109
- }
110
- var ke = (t, n, r, i) => ({
111
- type: k.Box,
112
- layout: { displayOrder: S.VisualizationElement },
113
- key: A(t, n, e.Waterfall),
114
- data: i,
115
- settings: r,
116
- animations: {
117
- enabled: !0,
118
- presetId: B
119
- }
120
- }), U = (e, t, r, i, o) => {
121
- let s = {
122
- orientation: e.orientation ?? a.Vertical,
123
- major: r,
124
- minor: i,
125
- box: {
126
- minWidthPx: 2,
127
- ref: "",
128
- rx: d(e.barSettings.barRadius, 0),
129
- fill: o,
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 ? (s.box.stroke = we(t, e.barSettings?.strokeColor ?? ""), s.box.strokeWidth = e.barSettings?.strokeWidth) : s.box.stroke = n.transparent, s;
141
- }, Ae = "collection-no-dimension", je = "onlyMeasures";
142
- y.Inside, y.Outside, y.Opposite;
143
- function W(e, n) {
144
- let r = e.measures.filter((e) => f(e));
145
- return r.filter((i, a) => {
146
- let o = t(i.dataItem), s = n[0].items[0][o], c = e.measureProps[o];
147
- if (a === 0) return !!s || !c?.hideIfEmpty;
148
- let l = t(r[a - 1].dataItem);
149
- return s !== n[0].items[0][l] || !c?.hideIfEmpty;
150
- });
151
- }
152
- var Me = (e, t, n, r, a, s, c, l) => {
153
- n = he(e, t, n, r, a, s, c, l);
154
- let u = [], d = [];
155
- if ("axes" in e) {
156
- let n = e.axes?.dimension || {};
157
- if (!n.disabled) {
158
- let r = D(e) ? i.Left : i.Bottom;
159
- if (u.push(fe(je, n, {
160
- ...t.axis.measure,
161
- ...t.fonts
162
- }, r)), n.showAxisName) {
163
- let i = e.measures.filter((e) => f(e)), a = i.length ? i : e.measures;
164
- if (a.length) {
165
- let i = o(e.measures, !!e.enableAlternate, s?.isPrintMode);
166
- d.push(ue(a, i, r, {
167
- ...t.axis.measure,
168
- ...t.fonts
169
- }, void 0, n.axisTitle ?? "Measures", n.titleFontSize, "waterfall-measures-axis-label"));
170
- }
171
- }
172
- }
173
- }
174
- return {
175
- ...n,
176
- components: [
177
- ...n.components,
178
- ...u,
179
- ...d
180
- ]
181
- };
182
- }, Ne = (e, n, r, i, a) => {
183
- if (!a) return r;
184
- let o = ae(e, {});
185
- (e.axes?.primaryMeasure?.axisRange?.axisRangeOption ?? p.Auto) === p.Auto && (D(e) ? o[j.XAxisScale].expand = .3 : o[j.YAxisScale].expand = .3);
186
- let s = [];
187
- return W(e, a).forEach((n, r) => {
188
- let i = t(n.dataItem), a = u(n);
189
- s.push({
190
- value: i,
191
- label: a || n.label || n.dataItem.name
192
- });
193
- let o = e.measureProps[i];
194
- o?.subTotalEnabled && s.push({
195
- value: I(r),
196
- label: o?.subTotalLabel || "Sub-Total"
197
- });
198
- }), e.total.enabled && s.push({
199
- value: L,
200
- label: e.total.label || "Total"
201
- }), o.onlyMeasures = {
202
- data: { items: s },
203
- padding: e.barSettings.barPadding ?? 0,
204
- type: ce.Band,
205
- value: (e) => `${e.datum.value.value}`,
206
- label: (e) => `${e.datum.value.label}`
207
- }, {
208
- ...r,
209
- scales: o
210
- };
211
- }, G = "measures", Pe = (e, n, r, i, a) => {
212
- if (!a) return r;
213
- let o = [], s, c = W(e, a), l = ge((e.supportingMeasures ?? []).filter((e) => f(e)));
214
- if (c.forEach((n, r) => {
215
- let i = t(n.dataItem), a, u;
216
- if (r === 0) a = 0, u = { field: i }, s = "end";
217
- else if (s === "start") a = { field: t(c[r - 1].dataItem) }, u = { field: i }, s = "end";
218
- else {
219
- let e = t(c[r - 1].dataItem);
220
- a = { field: i }, u = { field: e }, s = "start";
221
- }
222
- o.push({
223
- field: i,
224
- props: {
225
- stackKey: G,
226
- [i]: { field: i },
227
- ...l,
228
- series: i,
229
- start: a,
230
- color: i,
231
- end: u,
232
- secondaryAxis: n.secondaryAxis,
233
- isMultipleMeasures: !0,
234
- subTotal: !1,
235
- reverted: s === "start"
236
- }
237
- });
238
- let d = e.measureProps[i];
239
- if (d?.subTotalEnabled) {
240
- let e = I(r), t, n;
241
- s === "end" ? (t = 0, n = { field: i }) : (t = { field: i }, n = 0), o.push({
242
- field: e,
243
- props: {
244
- stackKey: G,
245
- ...l,
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: s === "start"
255
- }
256
- });
257
- }
258
- }), e.total.enabled) {
259
- let n = t(c[c.length - 1].dataItem), r, i;
260
- s === "end" ? (r = 0, i = { field: n }) : (r = { field: n }, i = 0), o.push({
261
- field: L,
262
- props: {
263
- stackKey: G,
264
- ...l,
265
- series: L,
266
- start: r,
267
- color: L,
268
- end: i,
269
- secondaryAxis: !1,
270
- isMultipleMeasures: !0,
271
- label: e.total.label || "Total",
272
- subTotal: !0,
273
- reverted: s === "start"
274
- }
275
- });
276
- }
277
- let u = {
278
- key: Ae,
279
- data: { extract: o }
280
- };
281
- return {
282
- ...r,
283
- collections: [u]
284
- };
285
- }, Fe = (e, n, r, i, a) => {
286
- if (!a) return r;
287
- let o = Object.values(a[0].items[0]), s = W(e, a).reduce((r, i, a) => {
288
- let s = t(i.dataItem), c = H(s), l = {
289
- scale: M(e, i),
290
- ref: "end"
291
- }, u = N({
292
- measureProps: e.measureProps[s],
293
- index: a,
294
- items: o,
295
- vSpec: e
296
- }), d = [...r], f = U(e, n, V, l, u);
297
- return d.push(ke(e, i, f, c)), e.measureProps[s]?.subTotalEnabled && d.push(De(e, n, a)), d;
298
- }, []);
299
- return e.total.enabled && s.push(Oe(e, n)), {
300
- ...r,
301
- components: [...r.components, ...s]
302
- };
303
- }, Ie = [{ position: y.Outside }, {
304
- position: y.Inside,
305
- justify: 1
306
- }], Le = (e, n, r, i, a) => {
307
- if (!a) return r;
308
- let o = [], s = W(e, a);
309
- return s.forEach((r, i) => {
310
- if (!r.dataLabels?.show) return;
311
- o.push(Be(e, n, r, i));
312
- let a = t(r.dataItem);
313
- e.measureProps[a]?.subTotalEnabled && o.push(ze(e, n, r, i));
314
- }), e.total.enabled && e.total.showDataLabel && o.push(Re(e, n, s)), {
315
- ...r,
316
- components: [...r.components, ...o]
317
- };
318
- }, K = {
319
- layout: { displayOrder: S.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: k.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: k.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(t, n, r, i) {
343
- let a = A(t, r, e.Waterfall);
344
- return {
345
- ...K,
346
- type: k.Labels,
347
- key: `bar-labels-normal-${i}`,
348
- settings: q(t, n, a, z(r), r.dataLabels?.showBackdrop, r.dataLabels?.size)
349
- };
350
- }
351
- function q(e, t, n, r, i = !1, a = w.dataPoint.valueFontSize) {
352
- return { sources: [{
353
- component: n,
354
- selector: ne.Rect,
355
- strategy: {
356
- type: "bar",
357
- settings: {
358
- direction: Ve(e),
359
- fontSize: le(a),
360
- fontFamily: t.fonts.general.fontFamily,
361
- labels: [{
362
- label: r,
363
- placements: i ? Ie.map((n) => ve(n, t, D(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) ? D(e) ? "right" : "up" : D(e) ? "left" : "down";
374
- };
375
- }
376
- var He = {
377
- curve: s.Linear,
378
- line: {
379
- stroke: n.grey1,
380
- strokeWidth: 2,
381
- strokeDasharray: b({
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 = (t, n, r) => {
394
- if (!t.showLines || !r.collections) return r;
395
- let i = r.collections[0].data.extract, a = "end", o = i.slice(0, -1).map((n, r) => {
396
- let o = a;
397
- return i[r + 1].props?.subTotal || (a = a === "start" ? "end" : "start"), {
398
- type: k.Line,
399
- layout: { displayOrder: S.VisualizationElement },
400
- key: `${e.Line}.${r}`,
401
- data: {
402
- collection: Ae,
403
- filter: (e, t) => [r, r + 1].includes(t)
404
- },
405
- settings: Ke(t, o),
406
- animations: We
407
- };
408
- });
409
- return {
410
- ...r,
411
- components: [...r.components, ...o]
412
- };
413
- };
414
- function Ke(e, t) {
415
- let n = D(e);
416
- return {
417
- layers: He,
418
- coordinates: {
419
- major: Ue,
420
- minor: {
421
- scale: n ? j.XAxisScale : j.YAxisScale,
422
- ref: t
423
- }
424
- },
425
- orientation: n ? a.Vertical : a.Horizontal
426
- };
427
- }
428
- var qe = (t, n, r) => {
429
- let i = t.measures.filter(f), a = i.map((n) => A(t, n, e.Waterfall));
430
- return ie(t, n, r, {
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
- ...t,
438
- measures: i
439
- }, n, Je, () => "")
440
- }, `tooltip-${k.Box}`);
441
- }, Je = (e, n, r, i, a, o, s, c) => {
442
- let { formatter: l } = r, d = n.data, f = T(r), p = e.filter((e) => !f.has(t(e.dataItem))), m = e.filter((e) => f.has(t(e.dataItem))).flatMap((e) => {
443
- let r = t(e.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 && e?.formatter && l ? o = l(e.formatter)(a) : c && l && (o = l(O(e?.formatter))(a)), [{
447
- label: u(e) || e.label || e.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 = e.find((e) => t(e.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(O(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(f).length === 1 && e.measures.filter(f).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(e, n) {
489
- if (!n.items.length) return n;
490
- let [r, i] = e.measures.filter(f), a = t(r.dataItem), o = t(i.dataItem), s = n.items.reduce((e, t) => e + X(t[a]), 0), c = n.items.reduce((e, t) => e + X(t[o]), 0), l = e.measureProps?.[o]?.hideIfEmpty ?? !1, u = /* @__PURE__ */ new Set([...n.fields.map((e) => e.dataItemId), ...n.items.flatMap((e) => Object.keys(e))]), d = Object.fromEntries([...u].map((e) => [e, null])), p = (e, n, r) => ({
491
- ...d,
492
- [t(e.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(e)
499
- }), m = s, h = n.items.flatMap((e, t) => {
500
- let n = X(e[o]) - X(e[a]), r = m;
501
- return m += n, l && 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", s),
515
- ...h,
516
- p(i, "closing", c)
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 = (e, n, r, i, a, o, s, c) => {
526
- let u = {
527
- ...e,
528
- barSettings: {
529
- ...l.barSettings,
530
- ...e.barSettings
531
- },
532
- colors: {
533
- ...l.colors,
534
- ...e.colors
535
- },
536
- measures: e.measures.map((e) => ({
537
- ...e,
538
- secondaryAxis: !1
539
- }))
540
- }, [d, m] = u.measures.filter(f), [h] = u.dimensions.filter(f), g = t(h.dataItem), ee = (u.supportingMeasures ?? []).filter(f), _ = _e(u), v = M(u, d);
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([d, m].map((e) => {
556
- let n = t(e.dataItem);
557
- return [n, { field: n }];
558
- })),
559
- ...ge(ee)
560
- }
561
- }] }
562
- }],
563
- scales: ae(u, {})
564
- };
565
- let te = {
566
- type: ce.Band,
567
- data: { items: (a?.[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: u.barSettings.barPadding,
574
- invert: u.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[_] = te, r.scales[v].data = { fields: [J.start, J.end] }, (u.axes?.primaryMeasure?.axisRange?.axisRangeOption ?? p.Auto) === p.Auto && (r.scales[v].expand = .3), r = he({
579
- ...u,
580
- dimensions: u.dimensions.map((e) => ({
581
- ...e,
582
- formatter: void 0
583
- }))
584
- }, n, r, i, a, o, s, c), r.components = r.components.map((e) => e.type === k.Axis && e.scale === _ ? {
585
- ...e,
586
- key: "axis.waterfall.comparison.dimension",
587
- brush: void 0
588
- } : e), r = re(u, n, r, i, a);
589
- let y = [], b = [], x = { scale: _ }, ne = {
590
- scale: v,
591
- ref: "end"
592
- }, C = u.measureProps?.[t(m.dataItem)], w = C && {
593
- ...C,
594
- customColor: {
595
- ...u.colors,
596
- ...C.customColor
597
- }
598
- }, T = (e, t, r, i, a) => {
599
- y.push({
600
- key: e,
601
- type: k.Box,
602
- layout: { displayOrder: S.VisualizationElement },
603
- data: {
604
- collection: Z,
605
- filter: r
606
- },
607
- settings: U(u, n, x, ne, i),
608
- brush: a ? pe(["category"], o, { valuePickerMode: o?.valuePickerMode }) : void 0,
609
- animations: {
610
- enabled: !0,
611
- presetId: "simple-opacity"
612
- }
613
- }), t.dataLabels?.show && b.push({
614
- key: `${e}.labels`,
615
- type: k.Labels,
616
- layout: { displayOrder: S.Labels },
617
- settings: q(u, 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
- }, E = (e) => {
624
- let n = u.measureProps?.[t(e.dataItem)];
625
- return n?.customColorEnabled && n.customColor?.subTotal || u.colors.subTotal;
626
- };
627
- return T(Q.opening, d, (e) => e.kind.value === "opening", E(d), !1), T(Q.positive, m, (e) => e.kind.value === "change" && Number(e.change.value) >= 0, N({
628
- measureProps: w,
629
- index: 0,
630
- items: [1],
631
- vSpec: u
632
- }), !0), T(Q.negative, m, (e) => e.kind.value === "change" && Number(e.change.value) < 0, N({
633
- measureProps: w,
634
- index: 0,
635
- items: [-1],
636
- vSpec: u
637
- }), !0), T(Q.closing, m, (e) => e.kind.value === "closing", E(m), !1), r = {
638
- ...r,
639
- components: [
640
- ...r.components,
641
- ...y,
642
- ...b
643
- ]
644
- }, u.showLines && r.components.push(Qe(u, n.axis.dimension.lineColor)), r = ie(u, 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(u, n, $e, (e, t) => String(t.data.kind.value === "change" ? t.data.category.label : t.data.endpointLabel.value))
651
- }), oe(u, n, r, i, a);
652
- };
653
- function Qe(e, t) {
654
- let n = _e(e), r = M(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: k.LineCoord,
667
- layout: { displayOrder: S.VisualizationElement },
668
- data: { collection: Z },
669
- settings: {
670
- ...D(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 = (e, n, r, i, a, o, s, c) => {
693
- let l = n.data.kind.value, u = l === "opening" ? e[0] : e[1], d = l === "change" ? e : [u], f = (e, t) => {
694
- let n = c ? O(e?.formatter) : e?.formatter;
695
- return n && r.formatter ? r.formatter(n)(t) : t ?? "";
696
- }, p = d.map((e) => ({
697
- label: Ye(e),
698
- value: f(e, n.data[t(e.dataItem)]?.value)
699
- }));
700
- return l === "change" && p.push({
701
- label: "Change",
702
- value: f(e[1], n.data.change.value)
703
- }), p;
704
- }, et = class extends E {
705
- constructor() {
706
- let e = [
707
- Pe,
708
- Ne,
709
- Me,
710
- re,
711
- Fe,
712
- Le,
713
- Ge,
714
- qe,
715
- oe
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 = x);
736
- }
737
- };
738
- function tt(e) {
739
- return e.measures.filter((e) => f(e)).every((e) => e.dataItem.internalKey.startsWith("internalKeyMeasure"));
740
- }
741
- var $ = m(), nt = new et(), rt = g(({ vSpec: t, vTheme: n, data: i, elementSize: a, vizProperties: o }) => {
742
- let s = ee(), { activeKey: l } = te(), u = h(), d = _(), p = me();
743
- if (!i || !t || !r(t)) return null;
744
- let m = t.dimensions.some(f), g = m ? !i[0]?.items.length : it(i);
745
- if (!o.isFetchingData && g) return /* @__PURE__ */ (0, $.jsx)(ye, { vBackendAPI: d });
746
- if (g || !a) return null;
747
- let v = {
748
- ...o,
749
- valuePickerMode: !!l
750
- }, y = n || c, b = nt.compile(t, y, structuredClone(i), a, v, e.Waterfall, s, u, p);
751
- return b ? /* @__PURE__ */ (0, $.jsx)(de, {
752
- config: v,
753
- definition: b,
754
- size: a,
755
- vSpec: t,
756
- selectionData: m ? i[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 };