@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,1012 +0,0 @@
1
- import { o as e, r as t } from "./rolldown-runtime-DleVn1XH.js";
2
- import { $n as n, Bo as r, Fc as i, Io as a, Jt as o, Lc as s, Lo as c, Lt as l, Ns as u, Oa as d, Qa as f, Qr as p, Ra as m, Us as h, Ut as g, Xn as _, Zs as v, er as y, gc as b, in as x, ll as S, rl as C, rr as ee, sa as te, vs as w, yc as T } from "./visualization-filters-D7i6oh1Z.js";
3
- import { F as ne, N as re, ci as ie, f as ae, jt as oe, s as se, zr as ce } from "./utils-DganVptf.js";
4
- import { b_ as le, g_ as E } from "./handlers-C6CZ0XJA.js";
5
- import { r as D } from "./label-format-type-C46pzgx7.js";
6
- import { s as ue } from "./logger-DdZpR7xZ.js";
7
- import { $t as O, A as de, At as fe, Bt as pe, C as me, Ft as k, H as he, Ht as ge, Jt as _e, Kt as ve, L as ye, Lt as be, M as xe, Mt as Se, O as Ce, P as we, Qt as Te, R as A, Rt as Ee, Tt as De, Ut as j, V as M, Vt as Oe, Xt as ke, _ as Ae, _t as je, bn as N, cn as P, dn as Me, fn as F, ft as Ne, gn as Pe, hn as Fe, i as Ie, kt as Le, ln as I, lt as Re, mn as L, mt as ze, n as Be, on as R, pn as Ve, qt as He, sn as z, un as B, ut as V, v as Ue, wt as We, xt as H, y as Ge, yn as U, z as Ke, zt as qe } from "./escobar-CvEV2ES1.js";
8
- import { _ as W } from "./MenuOption-Czc34u4q.js";
9
- import { t as Je } from "./coloring-BtnPiQ_o.js";
10
- import { t as Ye } from "./set-coloring-datafield-B3uIS1Pe.js";
11
- var Xe = /* @__PURE__ */ e(ie()), Ze = (e, t, n) => {
12
- let r = e.dimensions.filter((e) => p(e)), i = e.measures.filter((e) => p(e)), a = {
13
- showAxisTooltip: e?.axes?.dimension?.showAxisTooltip,
14
- formatter: r[0]?.formatter || {
15
- type: "string",
16
- format: ""
17
- },
18
- scale: z(e),
19
- key: `${k.Dimension}-${e.orientation ?? c.Vertical}`,
20
- settings: { direction: be(e) }
21
- }, o = i[0], [s, l] = pe([a, {
22
- showAxisTooltip: e?.axes?.primaryMeasure?.showAxisTooltip,
23
- formatter: o?.formatter,
24
- scale: P(e, o),
25
- key: `${k.Measure}-${e.orientation ?? c.Vertical}`,
26
- settings: {
27
- direction: qe(e),
28
- labelDock: Ee(I(e), o?.secondaryAxis)
29
- }
30
- }]);
31
- return {
32
- ...n,
33
- components: [...n.components ?? [], ...s],
34
- interactions: [...n.interactions ?? [], ...l]
35
- };
36
- }, Qe = ue(), $e = (e, t, n) => {
37
- let r = y(n, e, t);
38
- return {
39
- grouped: r === w.Groups,
40
- stacked: r === w.Stacked,
41
- offset: r === w.Offset,
42
- single: r === w.Bars,
43
- pyramid: r === w.Pyramid
44
- };
45
- }, et = (e, t) => {
46
- let n = [
47
- E.Inside,
48
- E.Outside,
49
- E.Opposite
50
- ];
51
- return t && (n = [E.Inside]), (e || [
52
- {
53
- position: E.Inside,
54
- justify: 1
55
- },
56
- {
57
- position: E.Outside,
58
- justify: 0
59
- },
60
- {
61
- position: E.Opposite,
62
- justify: 0
63
- }
64
- ]).map((e) => ({
65
- ...e,
66
- possible: n.includes(e.position)
67
- }));
68
- }, G = (e) => {
69
- let t = e.measures.filter((e) => p(e)), n = e.dimensions.filter((e) => p(e)), r = t.length > 1, i = n.length > 1, a = t.length > 0 && n.length === 0, { grouped: o, stacked: s, pyramid: c, offset: l } = $e(n.length, t.length, e.barSettings), u = {
70
- ...e.barSettings.offset,
71
- enabled: l
72
- }, d = o ? e.barSettings.groupPadding : e.barSettings.barPadding, f = e.barSettings.barPadding, m = e.coloring?.type !== T.Gradient && e.barSettings.translucentBars, h = g(e.barSettings.barRadius, 0);
73
- return {
74
- isMeasureOnly: a,
75
- isMultiMeasure: r,
76
- isMultiDimension: i,
77
- stacked: s,
78
- pyramid: c,
79
- stackedOffset: e.barSettings.stackedOffset,
80
- offset: u,
81
- barRadius: h,
82
- grouped: o,
83
- barPadding: d ?? Pe.scale.padding,
84
- groupPadding: f ?? Pe.scale.padding,
85
- translucentBars: m,
86
- roundAllEdges: e.barSettings.roundAllEdges,
87
- useCustomBoxRounding: !!h,
88
- ignoreOutOfBounds: e.barSettings.ignoreOutOfBounds
89
- };
90
- }, tt = (e, t) => {
91
- let [, n] = e.dimensions.filter((e) => p(e)), r = G(e);
92
- return e.coloring?.type === T.Categorical ? r.isMultiDimension ? i(n?.dataItem) : fe(e, t) : Se(e);
93
- }, nt = (e) => {
94
- let { stacked: t } = G(e);
95
- if (t && "barSettings" in e && e.barSettings?.stackedOffset === D.Expand) {
96
- let t = e.measures.map((e) => ({
97
- ...e,
98
- formatter: {
99
- type: "excel-format",
100
- format: { formatType: r.Percentage1Decimal }
101
- }
102
- }));
103
- return {
104
- ...e,
105
- measures: t
106
- };
107
- }
108
- return { ...e };
109
- }, rt = (e, t) => {
110
- if (t.min && t.max) {
111
- let n = t.min(), r = t.max(), i = e.data.start?.value, a = e.data.end?.value;
112
- return i < n && a < n || i > r && a > r;
113
- }
114
- return !1;
115
- }, it = (e) => {
116
- let t = I(e);
117
- return (C(e) ? e.measures.filter((e) => p(e) && !e.secondaryAxis) : []).length > 0 ? t ? B.XAxisScale : B.YAxisScale : t ? B.X2AxisScale : B.Y2AxisScale;
118
- }, K = (e) => {
119
- if (typeof e == "number") return e;
120
- if (e && typeof e == "object" && "value" in e && typeof e.value == "number") return e.value;
121
- }, at = (e) => {
122
- if (typeof e == "string" || typeof e == "number") return e;
123
- if (e && typeof e == "object" && "value" in e) {
124
- let t = e.value;
125
- return typeof t == "string" || typeof t == "number" ? t : void 0;
126
- }
127
- }, q = (e) => String(at(e.stackKey) ?? at(e.value)), J = (e, t) => {
128
- let n = K(e.start), r = K(e.end);
129
- return typeof n == "number" && typeof r == "number" ? r - n : t ? K(e[t]) : void 0;
130
- }, ot = (e, t, n, r, i, o, s, c) => {
131
- let l = e.dimensions.filter((e) => p(e)), { stacked: d, isMeasureOnly: f } = G(e), m = e;
132
- d && !f && (m = nt(e), m.measures = m.measures.filter((e) => e.secondaryAxis !== !0)), n = ve(m, t, n, r, i, o, s, c);
133
- let h = [], g = [];
134
- if (!l.length && "axes" in e) {
135
- let n = e.axes?.dimension || {};
136
- if (!n.disabled) {
137
- let r;
138
- if (r = I(e) ? e.axes?.dimension?.secondaryAxis ? a.Right : a.Left : e.axes?.dimension?.secondaryAxis ? a.Top : a.Bottom, h.push(He("onlyMeasures", n, {
139
- ...t.axis.measure,
140
- ...t.fonts
141
- }, r)), n.showAxisName) {
142
- let i = ee(e.dimensions, e.enableAlternate, o?.isPrintMode);
143
- g.push(_e([{ dataItem: {
144
- internalKey: "Measures",
145
- uniqueSignature: u(),
146
- name: "Measures",
147
- schema: "",
148
- view: "",
149
- type: S.Dimension,
150
- dataType: Qe.FieldType.FLOAT
151
- } }], i, r, {
152
- ...t.axis.measure,
153
- ...t.fonts
154
- }, void 0, void 0, n?.titleFontSize));
155
- }
156
- }
157
- }
158
- return {
159
- ...n,
160
- components: [
161
- ...n.components,
162
- ...h,
163
- ...g
164
- ]
165
- };
166
- }, st = .2, ct = (e, t) => ({ data: n }) => {
167
- let r = /* @__PURE__ */ new Map();
168
- return (n.items || []).forEach((e) => {
169
- if (!e || typeof e != "object") return;
170
- let n = e, i = J(n, t);
171
- if (typeof i == "number") {
172
- let e = q(n);
173
- r.set(e, (r.get(e) || 0) + i);
174
- }
175
- }), (r.size ? [...r.values()].some((t) => e ? t < 0 : t > 0) : (n.fields || []).some((t) => e ? t.min() < 0 : t.max() > 0)) ? st : 0;
176
- }, lt = (e, t, n, r, a, c, u) => {
177
- let d = e.dimensions.filter((e) => p(e)), f = e.measures.filter((e) => p(e)), m = G(e), h = tt(e, u), g = d[0], _ = d.length, v = f.length, y = !1, S = {};
178
- if (g && "axes" in e && e?.axes?.dimension?.continuousAxis) {
179
- let e = s(g?.dataItem), t = !!g.datePart, n = l(e) || o(e);
180
- y = !t && n;
181
- }
182
- let C = y ? L.Linear : L.Band;
183
- if (S = Le(Ye(e, h), t, S, n.collections, u), S = xe(e, S, n.collections, y), m.grouped) {
184
- let e, t;
185
- m.isMultiDimension ? (e = i(d[1]?.dataItem), t = { extract: { field: e } }) : m.isMultiMeasure && (e = "measures", t = f.map((e) => i(e.dataItem))), S[e] = {
186
- data: t,
187
- type: C,
188
- min: 0,
189
- max: 1,
190
- padding: m.groupPadding
191
- };
192
- }
193
- if (m.stacked || m.offset?.enabled && _ === 1 && v === 1) {
194
- let t = f[0].secondaryAxis ? e.axes?.secondaryMeasure : e.axes?.primaryMeasure, n = Ce(t);
195
- S[P(e, f[0])] = {
196
- invert: de(!I(e), t),
197
- data: { collection: B.Collection },
198
- ...n,
199
- ...m.stacked && e.barSettings.showTotal && n.type !== L.Log ? {
200
- expandMin: ct(!0, i(f[0]?.dataItem)),
201
- expandMax: ct(!1, i(f[0]?.dataItem))
202
- } : {}
203
- };
204
- }
205
- return m.isMeasureOnly && (S.onlyMeasures = {
206
- data: { items: f.map((e) => {
207
- let t = x(e) || e.label || e.dataItem.name;
208
- return {
209
- value: i(e.dataItem),
210
- label: t
211
- };
212
- }) },
213
- padding: m.barPadding,
214
- type: C,
215
- value: (e) => `${e.datum.value.value}`,
216
- label: (e) => `${e.datum.value.label}`
217
- }, m.stacked && (S[P(e, f[0])].data = { collection: "collection-no-dimension" }, S.onlyMeasures.data = { items: [{
218
- value: "measures",
219
- label: "measures"
220
- }] })), e.type === b.Bar && f.forEach((t) => {
221
- let n = t.secondaryAxis ? e.axes?.secondaryMeasure : e.axes?.primaryMeasure;
222
- if (n?.axisRange || n?.scale === le.Log) return;
223
- let r = S[P(e, t)];
224
- r && (r.include = [0]);
225
- }), {
226
- ...n,
227
- scales: S
228
- };
229
- }, ut = { outOfRangeTitle: "axis out range" }, Y = {
230
- StackTotal: "stackTotal",
231
- StackTotalLabel: "stackTotalLabel",
232
- Ratio: "ratio"
233
- }, X = { Share: "share" }, dt = (e, t, n, a, o, s, c) => {
234
- let l = e.dimensions.filter((e) => p(e)), u = G(e), d = e.measures.filter(p), f = Ue((e.supportingMeasures ?? []).filter((e) => p(e))), [m, h] = l, g = d[0], _ = i(m?.dataItem), v = i(h?.dataItem), y = i(g?.dataItem), b = { [X.Share]: {
235
- type: "excel-format",
236
- format: { formatType: r.Percentage1Decimal }
237
- } };
238
- if (d?.forEach((e, t) => {
239
- b[`measure-${t}`] = e.formatter || {
240
- type: "excel-format",
241
- format: { formatType: r.None }
242
- };
243
- }), u.isMeasureOnly) {
244
- let e = [];
245
- d.forEach((t) => {
246
- let n = i(t.dataItem);
247
- e.push({
248
- field: n,
249
- props: {
250
- stackKey: "measures",
251
- [n]: { field: n },
252
- ...f,
253
- series: n,
254
- [O.property]: ke(t),
255
- start: 0,
256
- color: n,
257
- end: { field: n },
258
- secondaryAxis: t.secondaryAxis,
259
- isMultipleMeasures: u.isMultiMeasure
260
- }
261
- });
262
- });
263
- let t = {
264
- key: "collection-no-dimension",
265
- data: {
266
- extract: e,
267
- filter: (e) => (e[O.property].source = {
268
- field: O.field,
269
- key: O.sourceKey
270
- }, !0)
271
- }
272
- };
273
- return u.stacked && (t.data.stack = {
274
- stackKey: (e) => `${e.stackKey.value}`,
275
- value: (e) => e.end.value,
276
- offset: D.Diverging
277
- }), {
278
- ...n,
279
- collections: [t],
280
- formatters: b
281
- };
282
- }
283
- let x = {
284
- key: "collection",
285
- data: { extract: [] }
286
- };
287
- if (u.isMultiMeasure) {
288
- let e = d.reduce((e, t) => {
289
- let n = i(t.dataItem);
290
- return e[n] = { field: n }, e;
291
- }, {});
292
- x.data.extract = d.map((t) => {
293
- let n = i(t.dataItem);
294
- return {
295
- field: _,
296
- props: {
297
- end: { field: n },
298
- series: n,
299
- color: n,
300
- ...e,
301
- ...f,
302
- start: 0,
303
- secondaryAxis: t.secondaryAxis,
304
- isMultipleMeasures: u.isMultiMeasure,
305
- [O.property]: ke(t)
306
- }
307
- };
308
- }), x.data.filter = (e) => (e[O.property].source = {
309
- field: O.field,
310
- key: O.sourceKey
311
- }, !0);
312
- } else {
313
- let t = tt(e, c), n = "coloring" in e && e.coloring?.type === T.Single;
314
- x.data.extract.push({
315
- field: _,
316
- props: {
317
- ...u.isMultiDimension && { series: { field: v } },
318
- start: 0,
319
- end: { field: y },
320
- color: n ? y : { field: t },
321
- [y]: { field: y },
322
- ...f,
323
- secondaryAxis: g.secondaryAxis,
324
- isMultipleMeasures: u.isMultiMeasure
325
- }
326
- });
327
- }
328
- if (u.stacked && "barSettings" in e) x.data.stack = {
329
- stackKey: (e) => `${e.value}`,
330
- value: (e) => e.end.value,
331
- offset: e.barSettings?.stackedOffset || D.Diverging
332
- };
333
- else if (u.offset?.enabled) {
334
- let e = u.offset?.totalLabel ?? "Total";
335
- x.data.stack = {
336
- stackKey: u.offset?.showTotal ? (t) => +(t.value === e) : () => 0,
337
- value: (e) => e.end.value
338
- };
339
- }
340
- return {
341
- ...n,
342
- collections: [x],
343
- formatters: b
344
- };
345
- }, ft = (e, t) => t || e.colors.brandColors[0], pt = (e, t, n, r) => {
346
- let i = e.dimensions.filter((e) => p(e)), a = e.measures.filter((e) => p(e));
347
- if (!i?.[0] || !r.offset?.enabled || !r.offset?.showLine) return null;
348
- let o = z(e), s = P(e, a[0]), l = {
349
- scale: o,
350
- fn: n.scales[o]?.type === L.Linear ? void 0 : (e) => {
351
- let t = e.scale;
352
- return t(e.datum.value) + t.bandwidth();
353
- }
354
- }, u = {
355
- scale: o,
356
- fn: (e, t) => e.data.items[t + 1] ? e.scale(e.data.items[t + 1].value) : 1
357
- }, d = {
358
- scale: s,
359
- ref: "end"
360
- }, f = e.orientation === c.Horizontal ? {
361
- y0: l,
362
- y1: u,
363
- x0: d,
364
- x1: d
365
- } : {
366
- y0: d,
367
- y1: d,
368
- x0: l,
369
- x1: u
370
- };
371
- return {
372
- key: "bar-bridge",
373
- type: N.LineCoord,
374
- data: { collection: "collection" },
375
- settings: {
376
- ...f,
377
- show: (e, t) => !!e.data.items[t + 1],
378
- stroke: r.offset.lineColor ?? t.axis.dimension.lineColor,
379
- strokeWidth: 1,
380
- strokeDasharray: "2 2",
381
- opacity: 1
382
- },
383
- animations: {
384
- enabled: !0,
385
- presetId: "simple-opacity"
386
- }
387
- };
388
- }, mt = (e, t) => (n) => {
389
- if (typeof n.datum.end.value != "number") return null;
390
- let r = new W(typeof t == "function" ? t(n) : t), i = [{
391
- color: r.rgb(),
392
- opacity: 1,
393
- offset: +(n.datum.end.value < 0)
394
- }, {
395
- color: r.rgb(),
396
- opacity: .65,
397
- offset: n.datum.end.value < 0 ? 0 : 1
398
- }];
399
- return n.datum.end.value < 0 && i.reverse(), {
400
- type: "gradient",
401
- degree: I(e) ? 0 : 90,
402
- stops: i
403
- };
404
- }, ht = (e, t, n, r, a, o) => {
405
- let s = e.dimensions.filter((e) => p(e)), c = e.measures.filter((e) => p(e)), l = G(e), u = { scale: z(e) };
406
- l.isMeasureOnly && (u = {
407
- scale: "onlyMeasures",
408
- ref: l.stacked ? "stackKey" : "series"
409
- });
410
- let d = new Je(e, t, a?.[0]?.itemsNotAffectedByFiltering), f = s.reduce((e, t) => (e[i(t.dataItem)] = !0, e), {}), m = c.reduce((n, r, a) => {
411
- if (l.stacked && a !== 0) return n;
412
- let s = { collection: B.Collection };
413
- if (l.isMeasureOnly && (s = {
414
- collection: "collection-no-dimension",
415
- filter: (e) => l.stacked || e?.source?.field === i(r.dataItem)
416
- }), l.grouped) {
417
- let e = i(r.dataItem);
418
- s = {
419
- ...s,
420
- filter: (t) => t.series?.source?.field ? f[t.series?.source?.field] : t.series?.value === e
421
- };
422
- }
423
- let c = { overwriteSources: [d.MAIN_FIELD, "series"] };
424
- (e.coloring?.type === T.Categorical || e.coloring?.type === T.Gradient) && (c.ref = "color");
425
- let p = d.getColorDefinition(c);
426
- l?.translucentBars && (p = mt(e, p));
427
- let m = {
428
- scale: P(e, r),
429
- ref: "end"
430
- }, h = yt(e, t, u, m, p);
431
- return [...n, vt(e, r, h, s, o)];
432
- }, []);
433
- if (h(e)) {
434
- let r = pt(e, t, n, l);
435
- r && m.push(r);
436
- }
437
- return {
438
- ...n,
439
- components: [...n.components, ...m]
440
- };
441
- }, gt = (e) => {
442
- let t = [], n = e.dimensions.filter((e) => p(e)), r = e.measures.filter((e) => p(e));
443
- return n.length || t.push(O.property), n?.[0] && t.push(""), n?.[1] && t.push("series"), r.length > 1 && t.push(O.property), t;
444
- }, _t = (e) => {
445
- let t, n = G(e), r = e.measures.filter((e) => p(e));
446
- if (n.stacked && r.length > 0) {
447
- let e = i(r[0].dataItem);
448
- t = function() {
449
- let t = {}, r = {}, i = {}, a = (e) => {
450
- let t = e.end?.value;
451
- return typeof t == "number" ? t : void 0;
452
- }, o = this.data.items;
453
- o.forEach((n) => {
454
- let o = q(n), s = J(n, e);
455
- if (r[o] || (r[o] = {
456
- positive: void 0,
457
- negative: void 0
458
- }), i[o] || (i[o] = {
459
- highest: void 0,
460
- lowest: void 0
461
- }), typeof s == "number") {
462
- t[o] = (t[o] || 0) + s, s > 0 ? r[o].positive = n : s < 0 && (r[o].negative = n);
463
- let e = a(n);
464
- if (typeof e == "number") {
465
- let { highest: t, lowest: r } = i[o];
466
- (!t || e > a(t)) && (i[o].highest = n), (!r || e < a(r)) && (i[o].lowest = n);
467
- }
468
- }
469
- }), o.forEach((a) => {
470
- let o = q(a), s = t[o] || 0, c = (s >= 0 ? i[o].highest : i[o].lowest) ?? (s >= 0 ? r[o].positive : r[o].negative);
471
- if (a[Y.StackTotal] = { value: s }, a[Y.StackTotalLabel] = { value: +(c === a) }, n.isMultiDimension) {
472
- let t = J(a, e), n = typeof t == "number" && s !== 0 ? t / s : 0;
473
- a[Y.Ratio] = { value: Number.isFinite(n) ? n : 0 };
474
- }
475
- });
476
- };
477
- }
478
- return t;
479
- }, vt = (e, t, n, r, i) => {
480
- let a = _t(e), o = G(e), s = o.stacked && (o.isMultiDimension || o.isMultiMeasure), c = Te(gt(e), i, { valuePickerMode: i?.valuePickerMode }, s ? U.AndSubset : void 0);
481
- return {
482
- type: N.Box,
483
- layout: { displayOrder: j.VisualizationElement },
484
- key: H(e, t, b.Bar),
485
- data: r,
486
- settings: n,
487
- animations: {
488
- enabled: !0,
489
- presetId: "bar-chart"
490
- },
491
- beforeRender: a,
492
- brush: c
493
- };
494
- }, yt = (e, t, n, r, a) => {
495
- let o = e.dimensions.filter((e) => p(e)), s = e.measures.filter((e) => p(e)), [, l] = o, u = G(e), f = {
496
- orientation: e.orientation ?? c.Vertical,
497
- major: n,
498
- minor: r,
499
- box: {
500
- minWidthPx: 2,
501
- ref: "",
502
- rx: g(u.barRadius, 0),
503
- fill: a,
504
- stacked: u.stacked,
505
- grouped: u.grouped,
506
- boxPadding: u.barPadding,
507
- groupPadding: u.groupPadding,
508
- itemsInStackCount: s?.length,
509
- roundAllEdges: u.roundAllEdges ?? !1,
510
- useCustomBoxRounding: u.useCustomBoxRounding ?? !1,
511
- ignoreOutOfBounds: u.ignoreOutOfBounds ?? !1
512
- }
513
- };
514
- if (e.barSettings?.strokeEnabled ? (f.box.stroke = ft(t, e.barSettings?.strokeColor), f.box.strokeWidth = e.barSettings?.strokeWidth) : f.box.stroke = d.transparent, !u.isMeasureOnly && u.grouped && !e?.axes?.dimension?.continuousAxis) {
515
- let t = u.isMultiDimension ? i(l?.dataItem) : "measures";
516
- f.major.fn = (n) => {
517
- let r = n.resources.scale(z(e)), i = n.resources.scale(t), a = r.bandwidth(), o = i.bandwidth();
518
- return Number(r(n.datum.value)) + .5 * a - .5 * (1 / o - 1) * o * a + a * Number(i(n.datum.series.value));
519
- }, f.box.width = (e) => e.resources.scale(t).bandwidth();
520
- }
521
- return f;
522
- }, bt = (e, t) => {
523
- let r = I(e), a = e.measures.filter(p), o;
524
- if (n(e)) {
525
- let n = e.dimensions.filter(p)[1], r = i(n.dataItem), s = t?.[0]?.items ?? [];
526
- o = [...new Set(s.map((e) => e[r]))].map((e) => ({
527
- measure: a[0],
528
- seriesValue: e
529
- }));
530
- } else o = a.map((e) => ({
531
- measure: e,
532
- seriesValue: i(e.dataItem)
533
- }));
534
- return o.slice(0, 2).map(({ measure: t, seriesValue: n }, i) => {
535
- let a = i === +!!e.barSettings.swapSides, o = r === a ? 0 : .5;
536
- return {
537
- measure: t,
538
- seriesValue: n,
539
- scale: r ? i === 0 ? B.XAxisScale : B.X2AxisScale : i === 0 ? B.YAxisScale : B.Y2AxisScale,
540
- region: {
541
- direction: r ? "horizontal" : "vertical",
542
- start: o,
543
- end: o + .5,
544
- dock: r ? "bottom" : "left"
545
- }
546
- };
547
- });
548
- }, xt = (e, t) => {
549
- let n = Ce(t, !1, !1);
550
- return {
551
- ...n,
552
- data: { collection: B.Collection },
553
- formatter: e.measure.formatter,
554
- type: L.Linear,
555
- invert: e.region.start === 0,
556
- min: 0,
557
- max: n.max ?? (({ data: t }) => (t.items ?? []).reduce((t, n) => {
558
- let r = n;
559
- if (r.series?.value !== e.seriesValue) return t;
560
- let i = r.end?.value;
561
- return typeof i != "number" || !Number.isFinite(i) ? t : Math.max(t, i);
562
- }, 0) || 1),
563
- expandMin: 0,
564
- expandMax: 0
565
- };
566
- }, St = new W(Me.fontLight), Ct = new W(Me.fontDark), wt = (e) => {
567
- switch (!0) {
568
- case e.grouped: return "grouped";
569
- case e.stacked: return "stacked";
570
- default: return "normal";
571
- }
572
- }, Tt = (e, t, n, r, a, o) => {
573
- let s = G(e), c = e.dimensions.filter(p), l = e.measures.filter(p), u = l[0], d = s.stacked && c.length > 1 && l.length === 1;
574
- if (!u?.dataLabels?.show) return n;
575
- let f = i(u.dataItem), h = new W(t.fonts.general.color), g = u.dataLabels.textColor || (({ node: e }) => {
576
- let t = e.attrs, n = t?.fill && t.fill !== "transparent", r = n && t.fill?.type === "gradient" ? t.fill?.stops?.[0]?.color : t?.fill;
577
- return new W(n ? r : "#ffffff").betterContrast(h, St, Ct).rgb();
578
- }), _ = [], v = u.dataLabels.displayParts?.includes(m.Value), y = u.dataLabels.displayParts?.includes(m.Ratio);
579
- (v || !u.dataLabels.displayParts && s.stackedOffset !== D.Expand) && _.push({
580
- id({ node: e }) {
581
- return `${e.data._ID}::value`;
582
- },
583
- linkData({ node: e }) {
584
- return e.data;
585
- },
586
- fill: g,
587
- label({ node: e, formatter: t }) {
588
- return t("measure-0")(e.data[f].value, void 0, e.data);
589
- },
590
- hideEllipsed: !0
591
- }), (y || !u.dataLabels.displayParts && s.stackedOffset === D.Expand) && _.push({
592
- id({ node: e }) {
593
- return `${e.data._ID}::ratio`;
594
- },
595
- linkData({ node: e }) {
596
- return e.data;
597
- },
598
- fill: g,
599
- label({ node: e, formatter: t }) {
600
- return t(X.Share)(e.data[Y.Ratio].value);
601
- },
602
- hideEllipsed: !0
603
- });
604
- let x = {
605
- key: "bar-labels-stacked-0",
606
- type: N.Labels,
607
- layout: { displayOrder: j.Labels },
608
- settings: { sources: [{
609
- component: H(e, e.measures.filter(p)?.[0], b.Bar),
610
- selector: F.Rect,
611
- strategy: {
612
- type: "rows",
613
- settings: {
614
- justify: .5,
615
- align: .5,
616
- fontSize: R(u.dataLabels?.size),
617
- fontFamily: t.fonts.general.fontFamily,
618
- labels: _
619
- }
620
- }
621
- }] },
622
- ...o?.disable?.brushing ? {} : { brush: { consume: [{
623
- context: Ve.Selection,
624
- data: ["", "series"],
625
- mode: d ? U.AndSubset : U.And,
626
- style: { inactive: { opacity: .3 } }
627
- }] } },
628
- animations: {
629
- presetId: "simple-opacity",
630
- enabled: !0
631
- }
632
- };
633
- return {
634
- ...n,
635
- components: [...n.components, x]
636
- };
637
- }, Et = (e, t, r, i, a) => {
638
- let o = G(e), s = I(e), c = ({ data: e, scale: t }, n) => {
639
- if (!e) return null;
640
- let r = n ? t(n) : void 0, i = e.end.value > e.start.value, a = r ? Number(r(e.end.value)) > Number(r(e.start.value)) : s === i;
641
- return s ? a ? "right" : "left" : a ? "down" : "up";
642
- }, l = [], u = e.measures.filter(p), d = n(e);
643
- return (o.pyramid ? bt(e, a) : e.measures.map((e) => ({
644
- measure: e,
645
- region: void 0,
646
- scale: void 0
647
- }))).forEach(({ measure: n, region: r, scale: i }, a) => {
648
- if (n.dataLabels?.show) {
649
- let f = u.indexOf(n), m = H(e, o.stacked ? e.measures.filter(p)?.[0] : n, b.Bar), h = wt(o), g = et(n.dataLabels.barLabelPlacements, o.stacked).filter((e) => e.possible).map((e) => ({
650
- position: e.position,
651
- justify: e.justify,
652
- overflow: [E.Outside, E.Opposite].includes(e.position),
653
- fill: e.position === E.Inside ? "#fff" : "#242424"
654
- }));
655
- n.dataLabels?.showBackdrop && !o.stacked && (g = g.map((e) => Ge(e, t, s, n.dataLabels?.backdropColor)));
656
- let _ = n.dataLabels.textColor;
657
- if (_) {
658
- let e = () => _;
659
- g = g.map((t) => ({
660
- ...t,
661
- fill: e
662
- }));
663
- }
664
- l.push({
665
- key: `bar-labels-${h}-${a}`,
666
- type: N.Labels,
667
- layout: {
668
- displayOrder: j.Labels,
669
- ...r && { region: r }
670
- },
671
- settings: { sources: [{
672
- component: d && a === 1 ? `${m}-second` : m,
673
- selector: F.Rect,
674
- strategy: {
675
- type: "bar",
676
- settings: {
677
- direction: (e) => c(e, i),
678
- fontSize: R(n.dataLabels?.size),
679
- fontFamily: t.fonts.general.fontFamily,
680
- labels: [{
681
- label: me(n, f >= 0 ? `measure-${f}` : void 0),
682
- placements: g
683
- }]
684
- }
685
- }
686
- }] },
687
- animations: {
688
- enabled: !0,
689
- presetId: "chart-labels"
690
- }
691
- });
692
- }
693
- }), {
694
- ...r,
695
- components: [...r.components, ...l]
696
- };
697
- }, Dt = (e, t, n, r, i, a) => {
698
- let o = G(e);
699
- return o.isMultiDimension && o.stacked ? Tt(e, t, n, r, i, a) : Et(e, t, n, r, i);
700
- }, Ot = (e) => {
701
- let t = e.measures.filter(p), n = t[t.length - 1];
702
- return !!n?.formatter && _(n.formatter);
703
- }, kt = (e, t) => {
704
- let n = t.data[Y.StackTotal]?.value;
705
- return typeof n == "number" ? n : e.measures.filter(p).reduce((e, n) => {
706
- let r = t.data[i(n.dataItem)]?.value;
707
- return e + (typeof r == "number" ? r : 0);
708
- }, 0) || void 0;
709
- }, At = (e) => ({ node: t }) => {
710
- let n = kt(e, t);
711
- if (typeof n != "number") return null;
712
- let r = n >= 0;
713
- return I(e) ? r ? "right" : "left" : r ? "up" : "down";
714
- }, jt = (e, t, n) => {
715
- if (t.data[Y.StackTotalLabel]) return Math.round(t.data[Y.StackTotalLabel].value) === 1;
716
- let r = t.data.end?.value;
717
- if (typeof r != "number" || e.barSettings.stackedOffset === D.Expand) return !1;
718
- if (t.data[Y.StackTotal]) return Math.round(r) === Math.round(n);
719
- let a = [...e.measures.filter(p)].reverse().find((e) => {
720
- let r = t.data[i(e.dataItem)]?.value;
721
- return typeof r == "number" && (n >= 0 ? r > 0 : r < 0);
722
- });
723
- return t.data.series?.value === i(a?.dataItem);
724
- }, Mt = (e, t) => {
725
- if (!e.barSettings.showTotal || !G(e).stacked) return;
726
- let n = e.measures.filter(p), r = n[0], i = n.length - 1;
727
- if (!(!r || i < 0)) return {
728
- key: "bar-labels-stacked-total",
729
- type: N.Labels,
730
- layout: { displayOrder: j.Labels },
731
- settings: { sources: [{
732
- component: H(e, r, b.Bar),
733
- selector: F.Rect,
734
- strategy: {
735
- type: "bar",
736
- settings: {
737
- direction: At(e),
738
- fontSize: R(r.dataLabels?.size),
739
- fontFamily: t.fonts.general.fontFamily,
740
- labels: [{
741
- label({ node: t, formatter: n }) {
742
- let r = kt(e, t);
743
- if (r === void 0 || !jt(e, t, r)) return "";
744
- if (e.barSettings.stackedOffset === D.Expand) {
745
- let t = r < 0 ? -1 : 1;
746
- return Ot(e) ? n(X.Share)(t) : String(t);
747
- }
748
- return n(`measure-${i}`)(r);
749
- },
750
- placements: [{
751
- position: E.Outside,
752
- fill: "#242424",
753
- justify: 0,
754
- overflow: !0
755
- }]
756
- }]
757
- }
758
- }
759
- }] },
760
- animations: {
761
- enabled: !0,
762
- presetId: "chart-labels"
763
- }
764
- };
765
- }, Nt = (e, t, n) => {
766
- let r = Mt(e, t);
767
- return r ? {
768
- ...n,
769
- components: [...n.components, r]
770
- } : n;
771
- }, Pt = (e, t, r, i, a) => {
772
- let o = e.measures.filter((e) => p(e)), s = G(e), c = n(e), l = o.flatMap((t) => {
773
- let n = H(e, t, b.Bar);
774
- return c ? [n, `${n}-second`] : [n];
775
- }), u = Ft(e), d = s.grouped && s.isMultiMeasure ? he(e, a) : void 0, f = A(e, t, Re, u, a && a[0] ? a[0].sum : void 0, d);
776
- if (s.stacked) {
777
- let n = he(e, a), r = s?.stackedOffset === D.Expand, i = s.isMultiDimension ? Lt(n, r) : Rt(n, r);
778
- f = A(nt(e), t, i, u);
779
- }
780
- return s.isMeasureOnly && (f = A(e, t, zt, u)), ye(e, t, r, {
781
- filter: (e) => e.filter((e) => l.findIndex((t) => t === e.key) !== -1),
782
- placement: {
783
- type: "bounds",
784
- area: "target"
785
- },
786
- extract: f
787
- }, `tooltip-${N.Box}`);
788
- }, Ft = (e) => (t, n, r) => [It(e, n, r), Ke(t, n, r)].filter((e) => e?.length > 0).join("\n"), It = (e, t, n) => {
789
- let r = it(e);
790
- return rt(t, n.scale(r)) ? ut.outOfRangeTitle : "";
791
- }, Z = (e, t, n, r, i) => {
792
- let a = i && !f(e.formatter) ? V(e.formatter) : e.formatter;
793
- return r.formatter(a)(t, void 0, n.data);
794
- }, Lt = (e, t = !1) => (n, r, a, o, s, c, l, u) => {
795
- let d = n.filter((e) => p(e)), f = M(a), m = d.filter((e) => !f.has(i(e.dataItem))), h = d.map((e) => {
796
- let t = i(e.dataItem), n = Object.keys(r.data).find((t) => r.data[t]?.source?.field === i(e.dataItem)), o;
797
- if (r.data.end?.value !== void 0 && r.data.start?.value !== void 0 && !f.has(t)) o = r.data.end.value - r.data.start.value;
798
- else if (n) o = r.data[n].value;
799
- else return {
800
- label: "",
801
- value: ""
802
- };
803
- let s = x(e), c = o;
804
- return (e.formatter || u) && (c = Z(e, o, r, a, u)), {
805
- label: s || e.label || e.dataItem.name || "",
806
- value: c
807
- };
808
- });
809
- if (!l && e && e[r?.data?.value]) {
810
- let n, i = m[0]?.formatter?.format?.formatType;
811
- t && Bt(i) ? n = "100%" : (n = e[r?.data?.value], !u && m[0]?.formatter ? n = a.formatter(m[0].formatter)(e[r?.data?.value]) : u && (n = a.formatter(V(m[0]?.formatter))(e[r?.data?.value]))), h.push({
812
- label: "Total",
813
- value: n
814
- });
815
- }
816
- return h;
817
- }, Rt = (e, t = !1) => (n, r, a, o, s, c, l, u) => {
818
- let d = n.filter((e) => p(e)), f = M(a), m = d.filter((e) => !f.has(i(e.dataItem))), h = m.reduce((e, t) => e + Number(r.data[i(t.dataItem)]?.value ?? 0), 0), g = d.map((e) => {
819
- let n = r.data.end?.value !== void 0 && r.data.start?.value !== void 0, o = i(e.dataItem), s = f.has(o), c = r.data.series?.value?.toString() === o, l;
820
- if (n && c && !s) l = r.data.end.value - r.data.start.value;
821
- else {
822
- let e = Object.keys(r.data).find((e) => r.data[e]?.source?.field === o);
823
- l = e ? r.data[e]?.value : void 0, t && !s && typeof l == "number" && h !== 0 && (l /= h);
824
- }
825
- if (l === void 0) return {
826
- label: "",
827
- value: ""
828
- };
829
- let d = x(e), p = l;
830
- return (e.formatter || u) && (p = Z(e, l, r, a, u)), {
831
- label: d || e.label || e.dataItem.name || "",
832
- value: p,
833
- ...m.length > 1 && c && !s && { isHighlighted: !0 }
834
- };
835
- });
836
- if (!l && e && e[r?.data?.value] !== void 0) {
837
- let n = m[m.length - 1], i, o = n?.formatter?.format?.formatType;
838
- t && Bt(o) ? i = "100%" : (i = e[r?.data?.value], !u && n?.formatter ? i = a.formatter(n.formatter)(e[r?.data?.value]) : u && (i = a.formatter(V(n?.formatter))(e[r?.data?.value]))), g.push({
839
- label: "Total",
840
- value: i
841
- });
842
- }
843
- return g;
844
- }, zt = (e, t, n) => {
845
- let r = e.filter((e) => p(e)), a = M(n), o = t.data.series?.value?.toString(), s = o ? t.data[o]?.value : void 0, c = r.find((e) => i(e.dataItem) === o), l = x(c) || c?.label || c?.dataItem?.name, u = [];
846
- return l && s !== void 0 && u.push({
847
- label: l,
848
- value: c?.formatter && n ? Z(c, s, t, n) : s
849
- }), r.filter((e) => a.has(i(e.dataItem))).forEach((e) => {
850
- let r = i(e.dataItem), a = Object.keys(t.data).find((e) => t.data[e]?.source?.field === r), o = a ? t.data[a]?.value : void 0;
851
- if (o === void 0) return;
852
- let s = x(e) || e.label || e.dataItem.name || "";
853
- u.push({
854
- label: s,
855
- value: e.formatter && n ? Z(e, o, t, n) : o
856
- });
857
- }), u;
858
- }, Bt = (e) => e === r.PercentageNoDecimal || e === r.Percentage1Decimal || e === r.Percentage2Decimal, Vt = (e, t, n) => {
859
- let r = e.barSettings?.offset?.enabled ?? !1, i = e.dimensions.filter((e) => p(e)), a = e.measures.filter((e) => p(e));
860
- return i.length === 1 && a.length === 1 && !r ? we(e, t, n) : n;
861
- }, Ht = (e, t, n, r, o, s) => {
862
- if (!G(e).pyramid) return n;
863
- let c = bt(e, o);
864
- if (!c.length) return n;
865
- let l = new Set(c.map(({ measure: e }) => i(e.dataItem))), u = z(e), d = e.axes?.primaryMeasure ?? {}, f = c[0].region.direction === "horizontal" ? a.Bottom : a.Left, p = {
866
- ...t.axis.measure,
867
- ...t.fonts
868
- }, m = s?.disable?.interactions ?? !1, h = { ...n.scales }, g = [...n.interactions ?? []];
869
- c.forEach((e) => {
870
- h[e.scale] = xt(e, d);
871
- });
872
- let _ = n.components.flatMap((t) => {
873
- if (t.type === Fe.CategoricalLegend && (t.scale === T.PerEachMeasure || t.scale === T.Single)) return [{
874
- ...t,
875
- settings: {
876
- ...t.settings,
877
- item: {
878
- ...t.settings.item,
879
- show: ({ datum: e }) => l.has(String(e.value))
880
- }
881
- }
882
- }];
883
- if (t.type === N.Axis && t.scale !== u || t.type === N.Text && t.dataItemType === S.Measure) return [];
884
- if (t.type === N.Box) {
885
- let n = c.filter(({ measure: n }) => H(e, n, b.Bar) === t.key);
886
- if (!t.settings) return [];
887
- let r = t.settings;
888
- return n.map((e, n) => ({
889
- ...t,
890
- key: n === 0 ? t.key : `${t.key}-second`,
891
- layout: {
892
- ...t.layout,
893
- region: e.region
894
- },
895
- data: {
896
- collection: "collection",
897
- filter: (t) => t.series?.value === e.seriesValue
898
- },
899
- settings: {
900
- ...r,
901
- minor: {
902
- scale: e.scale,
903
- ref: "end"
904
- }
905
- }
906
- }));
907
- }
908
- if (t.type === N.AxisTooltip && t.scale !== u) return c.map((e, n) => {
909
- let [r, i] = Oe(n === 0 ? t.key : `${t.key}-second`, e.scale, e.measure.formatter, {
910
- ...t.settings,
911
- labelDock: f
912
- });
913
- return n > 0 && g.push(i), {
914
- ...r,
915
- layout: {
916
- ...r.layout,
917
- region: e.region
918
- }
919
- };
920
- });
921
- if (t.type === N.Grid) {
922
- let e = f === a.Bottom ? "x" : "y";
923
- if (t[e]?.scale && t[e]?.scale !== u) return c.map((n, r) => ({
924
- ...t,
925
- key: `${t.key ?? "pyramid-grid"}-${r}`,
926
- layout: {
927
- ...t.layout,
928
- region: n.region
929
- },
930
- [e]: { scale: n.scale }
931
- }));
932
- }
933
- return [t];
934
- });
935
- return d.disabled || (c.forEach((e, t) => {
936
- let n = He(e.scale, d, p, f, e.measure.formatter, s, m);
937
- n.settings = {
938
- ...n.settings,
939
- align: f
940
- }, _.push({
941
- ...n,
942
- layout: {
943
- ...n.layout,
944
- region: e.region,
945
- dock: t === 0 ? f : `@axis.${c[0].scale}`
946
- }
947
- });
948
- }), d.showAxisName !== !1 && c.forEach((e, t) => {
949
- let n = _e([e.measure], !1, f, p, d.colors?.title, d.axisTitle, d.titleFontSize, `pyramid-${t}`);
950
- _.push({
951
- ...n,
952
- layout: {
953
- ...n.layout,
954
- region: e.region,
955
- dock: t === 0 ? f : "@text-pyramid-0"
956
- }
957
- });
958
- })), {
959
- ...n,
960
- scales: h,
961
- components: _,
962
- interactions: g
963
- };
964
- }, Q = class extends Ae {
965
- constructor() {
966
- super([
967
- dt,
968
- lt,
969
- ot,
970
- De,
971
- We,
972
- ze,
973
- ht,
974
- Dt,
975
- Nt,
976
- Ne,
977
- Vt,
978
- Pt,
979
- Ze,
980
- ge,
981
- Ht,
982
- je
983
- ]);
984
- }
985
- preCompile(e) {
986
- let t = e, { stacked: n } = G(t);
987
- n && (t.measures = t.measures.map((e) => ({
988
- ...e,
989
- secondaryAxis: !1
990
- })));
991
- }
992
- }, Ut = ce(), $ = oe(({ vSpec: e, vTheme: t, data: n, elementSize: r, vizProperties: i }) => {
993
- let a = re(), [o] = (0, Xe.useState)(() => new Q()), s = ae(), { activeKey: c } = se(), l = ne(), u = Be();
994
- if (!e || !n || !r || !h(e) && !v(e)) return null;
995
- let d = {
996
- ...i,
997
- valuePickerMode: !!c
998
- }, f = t || te, p = o.compile(e, f, n, r, {
999
- ...d,
1000
- onRenderDone: s
1001
- }, b.Bar, a, l, u);
1002
- return p ? /* @__PURE__ */ (0, Ut.jsx)(Ie, {
1003
- config: d,
1004
- definition: p,
1005
- size: r,
1006
- vSpec: e
1007
- }) : null;
1008
- }), Wt = /* @__PURE__ */ t({
1009
- BarChart: () => $,
1010
- BarChartCompiler: () => Q
1011
- });
1012
- export { $ as n, Q as r, Wt as t };