@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,1012 +0,0 @@
1
- import { o as e, r as t } from "./rolldown-runtime-DleVn1XH.js";
2
- import { $t as n, Bs as r, Cc as i, Ec as a, Hc as o, Na as s, Ts as c, Ua as l, Uo as u, Vt as d, Wc as f, Wo as p, Xs as m, ar as h, cr as g, fa as _, ic as v, ir as y, ln as b, pl as x, qo as S, qt as C, ri as w, ro as ee, tr as te, yl as ne } from "./visualization-filters-BwS0xUqs.js";
3
- import { Br as re, I as ie, Mt as ae, P as oe, f as se, li as ce, s as le } from "./utils-BdJrEeIQ.js";
4
- import { S_ as ue, v_ as T } from "./handlers-C63NVo7i.js";
5
- import { r as E } from "./label-format-type-C46pzgx7.js";
6
- import { s as de } from "./logger-Bc-DqDM_.js";
7
- import { $t as D, A as fe, An as O, Bt as pe, C as me, Cn as k, Dn as A, Dt as he, En as ge, Ft as _e, Gt as ve, H as ye, Ht as be, Jt as xe, L as Se, M as Ce, O as we, P as Te, Pt as Ee, Qt as De, R as j, Sn as Oe, St as ke, Tn as M, V as N, Xt as Ae, Yt as je, Zt as Me, _ as Ne, _n as P, an as Pe, bn as F, bt as I, i as Fe, in as L, jn as R, jt as z, ln as Ie, n as Le, qt as Re, rn as ze, sn as B, un as V, v as Be, vn as H, wn as Ve, wt as He, xn as U, y as Ue, yn as W, yt as We, z as Ge, zt as Ke } from "./escobar-cQ1eQ64G.js";
8
- import { _ as G } from "./MenuOption-B-6K7kks.js";
9
- import { t as qe } from "./coloring-BOiP0rmn.js";
10
- import { t as Je } from "./set-coloring-datafield-B3uIS1Pe.js";
11
- var Ye = /* @__PURE__ */ e(ce()), Xe = (e, t, n) => {
12
- let r = e.dimensions.filter((e) => w(e)), i = e.measures.filter((e) => w(e)), a = {
13
- showAxisTooltip: e?.axes?.dimension?.showAxisTooltip,
14
- formatter: r[0]?.formatter || {
15
- type: "string",
16
- format: ""
17
- },
18
- scale: H(e),
19
- key: `${ve.Dimension}-${e.orientation ?? p.Vertical}`,
20
- settings: { direction: Re(e) }
21
- }, o = i[0], [s, c] = Ae([a, {
22
- showAxisTooltip: e?.axes?.primaryMeasure?.showAxisTooltip,
23
- formatter: o?.formatter,
24
- scale: W(e, o),
25
- key: `${ve.Measure}-${e.orientation ?? p.Vertical}`,
26
- settings: {
27
- direction: je(e),
28
- labelDock: xe(F(e), o?.secondaryAxis)
29
- }
30
- }]);
31
- return {
32
- ...n,
33
- components: [...n.components ?? [], ...s],
34
- interactions: [...n.interactions ?? [], ...c]
35
- };
36
- }, Ze = de(), Qe = (e, t, n) => {
37
- let r = h(n, e, t);
38
- return {
39
- grouped: r === c.Groups,
40
- stacked: r === c.Stacked,
41
- offset: r === c.Offset,
42
- single: r === c.Bars,
43
- pyramid: r === c.Pyramid
44
- };
45
- }, $e = (e, t) => {
46
- let n = [
47
- T.Inside,
48
- T.Outside,
49
- T.Opposite
50
- ];
51
- return t && (n = [T.Inside]), (e || [
52
- {
53
- position: T.Inside,
54
- justify: 1
55
- },
56
- {
57
- position: T.Outside,
58
- justify: 0
59
- },
60
- {
61
- position: T.Opposite,
62
- justify: 0
63
- }
64
- ]).map((e) => ({
65
- ...e,
66
- possible: n.includes(e.position)
67
- }));
68
- }, K = (e) => {
69
- let t = e.measures.filter((e) => w(e)), n = e.dimensions.filter((e) => w(e)), r = t.length > 1, i = n.length > 1, o = t.length > 0 && n.length === 0, { grouped: s, stacked: c, pyramid: l, offset: u } = Qe(n.length, t.length, e.barSettings), d = {
70
- ...e.barSettings.offset,
71
- enabled: u
72
- }, f = s ? e.barSettings.groupPadding : e.barSettings.barPadding, p = e.barSettings.barPadding, m = e.coloring?.type !== a.Gradient && e.barSettings.translucentBars, h = C(e.barSettings.barRadius, 0);
73
- return {
74
- isMeasureOnly: o,
75
- isMultiMeasure: r,
76
- isMultiDimension: i,
77
- stacked: c,
78
- pyramid: l,
79
- stackedOffset: e.barSettings.stackedOffset,
80
- offset: d,
81
- barRadius: h,
82
- grouped: s,
83
- barPadding: f ?? A.scale.padding,
84
- groupPadding: p ?? A.scale.padding,
85
- translucentBars: m,
86
- roundAllEdges: e.barSettings.roundAllEdges,
87
- useCustomBoxRounding: !!h,
88
- ignoreOutOfBounds: e.barSettings.ignoreOutOfBounds
89
- };
90
- }, et = (e, t) => {
91
- let [, n] = e.dimensions.filter((e) => w(e)), r = K(e);
92
- return e.coloring?.type === a.Categorical ? r.isMultiDimension ? o(n?.dataItem) : pe(e, t) : be(e);
93
- }, tt = (e) => {
94
- let { stacked: t } = K(e);
95
- if (t && "barSettings" in e && e.barSettings?.stackedOffset === E.Expand) {
96
- let t = e.measures.map((e) => ({
97
- ...e,
98
- formatter: {
99
- type: "excel-format",
100
- format: { formatType: S.Percentage1Decimal }
101
- }
102
- }));
103
- return {
104
- ...e,
105
- measures: t
106
- };
107
- }
108
- return { ...e };
109
- }, nt = (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
- }, rt = (e) => {
116
- let t = F(e);
117
- return (x(e) ? e.measures.filter((e) => w(e) && !e.secondaryAxis) : []).length > 0 ? t ? U.XAxisScale : U.YAxisScale : t ? U.X2AxisScale : U.Y2AxisScale;
118
- }, q = (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
- }, it = (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
- }, J = (e) => String(it(e.stackKey) ?? it(e.value)), Y = (e, t) => {
128
- let n = q(e.start), r = q(e.end);
129
- return typeof n == "number" && typeof r == "number" ? r - n : t ? q(e[t]) : void 0;
130
- }, at = (e, t, n, i, a, o, s, c) => {
131
- let l = e.dimensions.filter((e) => w(e)), { stacked: d, isMeasureOnly: f } = K(e), p = e;
132
- d && !f && (p = tt(e), p.measures = p.measures.filter((e) => e.secondaryAxis !== !0)), n = ze(p, t, n, i, a, o, s, c);
133
- let m = [], h = [];
134
- if (!l.length && "axes" in e) {
135
- let n = e.axes?.dimension || {};
136
- if (!n.disabled) {
137
- let i;
138
- if (i = F(e) ? e.axes?.dimension?.secondaryAxis ? u.Right : u.Left : e.axes?.dimension?.secondaryAxis ? u.Top : u.Bottom, m.push(L("onlyMeasures", n, {
139
- ...t.axis.measure,
140
- ...t.fonts
141
- }, i)), n.showAxisName) {
142
- let a = g(e.dimensions, e.enableAlternate, o?.isPrintMode);
143
- h.push(Pe([{ dataItem: {
144
- internalKey: "Measures",
145
- uniqueSignature: r(),
146
- name: "Measures",
147
- schema: "",
148
- view: "",
149
- type: ne.Dimension,
150
- dataType: Ze.FieldType.FLOAT
151
- } }], a, i, {
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
- ...m,
163
- ...h
164
- ]
165
- };
166
- }, ot = .2, st = (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 = Y(n, t);
171
- if (typeof i == "number") {
172
- let e = J(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)) ? ot : 0;
176
- }, ct = (e, t, r, a, s, c, l) => {
177
- let u = e.dimensions.filter((e) => w(e)), p = e.measures.filter((e) => w(e)), m = K(e), h = et(e, l), g = u[0], _ = u.length, v = p.length, y = !1, x = {};
178
- if (g && "axes" in e && e?.axes?.dimension?.continuousAxis) {
179
- let e = f(g?.dataItem), t = !!g.datePart, r = d(e) || n(e);
180
- y = !t && r;
181
- }
182
- let S = y ? M.Linear : M.Band;
183
- if (x = Ke(Je(e, h), t, x, r.collections, l), x = Ce(e, x, r.collections, y), m.grouped) {
184
- let e, t;
185
- m.isMultiDimension ? (e = o(u[1]?.dataItem), t = { extract: { field: e } }) : m.isMultiMeasure && (e = "measures", t = p.map((e) => o(e.dataItem))), x[e] = {
186
- data: t,
187
- type: S,
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 = p[0].secondaryAxis ? e.axes?.secondaryMeasure : e.axes?.primaryMeasure, n = we(t);
195
- x[W(e, p[0])] = {
196
- invert: fe(!F(e), t),
197
- data: { collection: U.Collection },
198
- ...n,
199
- ...m.stacked && e.barSettings.showTotal && n.type !== M.Log ? {
200
- expandMin: st(!0, o(p[0]?.dataItem)),
201
- expandMax: st(!1, o(p[0]?.dataItem))
202
- } : {}
203
- };
204
- }
205
- return m.isMeasureOnly && (x.onlyMeasures = {
206
- data: { items: p.map((e) => {
207
- let t = b(e) || e.label || e.dataItem.name;
208
- return {
209
- value: o(e.dataItem),
210
- label: t
211
- };
212
- }) },
213
- padding: m.barPadding,
214
- type: S,
215
- value: (e) => `${e.datum.value.value}`,
216
- label: (e) => `${e.datum.value.label}`
217
- }, m.stacked && (x[W(e, p[0])].data = { collection: "collection-no-dimension" }, x.onlyMeasures.data = { items: [{
218
- value: "measures",
219
- label: "measures"
220
- }] })), e.type === i.Bar && p.forEach((t) => {
221
- let n = t.secondaryAxis ? e.axes?.secondaryMeasure : e.axes?.primaryMeasure;
222
- if (n?.axisRange || n?.scale === ue.Log) return;
223
- let r = x[W(e, t)];
224
- r && (r.include = [0]);
225
- }), {
226
- ...r,
227
- scales: x
228
- };
229
- }, lt = { outOfRangeTitle: "axis out range" }, X = {
230
- StackTotal: "stackTotal",
231
- StackTotalLabel: "stackTotalLabel",
232
- Ratio: "ratio"
233
- }, Z = { Share: "share" }, ut = (e, t, n, r, i, s, c) => {
234
- let l = e.dimensions.filter((e) => w(e)), u = K(e), d = e.measures.filter(w), f = Be((e.supportingMeasures ?? []).filter((e) => w(e))), [p, m] = l, h = d[0], g = o(p?.dataItem), _ = o(m?.dataItem), v = o(h?.dataItem), y = { [Z.Share]: {
235
- type: "excel-format",
236
- format: { formatType: S.Percentage1Decimal }
237
- } };
238
- if (d?.forEach((e, t) => {
239
- y[`measure-${t}`] = e.formatter || {
240
- type: "excel-format",
241
- format: { formatType: S.None }
242
- };
243
- }), u.isMeasureOnly) {
244
- let e = [];
245
- d.forEach((t) => {
246
- let n = o(t.dataItem);
247
- e.push({
248
- field: n,
249
- props: {
250
- stackKey: "measures",
251
- [n]: { field: n },
252
- ...f,
253
- series: n,
254
- [V.property]: B(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[V.property].source = {
268
- field: V.field,
269
- key: V.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: E.Diverging
277
- }), {
278
- ...n,
279
- collections: [t],
280
- formatters: y
281
- };
282
- }
283
- let b = {
284
- key: "collection",
285
- data: { extract: [] }
286
- };
287
- if (u.isMultiMeasure) {
288
- let e = d.reduce((e, t) => {
289
- let n = o(t.dataItem);
290
- return e[n] = { field: n }, e;
291
- }, {});
292
- b.data.extract = d.map((t) => {
293
- let n = o(t.dataItem);
294
- return {
295
- field: g,
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
- [V.property]: B(t)
306
- }
307
- };
308
- }), b.data.filter = (e) => (e[V.property].source = {
309
- field: V.field,
310
- key: V.sourceKey
311
- }, !0);
312
- } else {
313
- let t = et(e, c), n = "coloring" in e && e.coloring?.type === a.Single;
314
- b.data.extract.push({
315
- field: g,
316
- props: {
317
- ...u.isMultiDimension && { series: { field: _ } },
318
- start: 0,
319
- end: { field: v },
320
- color: n ? v : { field: t },
321
- [v]: { field: v },
322
- ...f,
323
- secondaryAxis: h.secondaryAxis,
324
- isMultipleMeasures: u.isMultiMeasure
325
- }
326
- });
327
- }
328
- if (u.stacked && "barSettings" in e) b.data.stack = {
329
- stackKey: (e) => `${e.value}`,
330
- value: (e) => e.end.value,
331
- offset: e.barSettings?.stackedOffset || E.Diverging
332
- };
333
- else if (u.offset?.enabled) {
334
- let e = u.offset?.totalLabel ?? "Total";
335
- b.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: [b],
343
- formatters: y
344
- };
345
- }, dt = (e, t) => t || e.colors.brandColors[0], ft = (e, t, n, r) => {
346
- let i = e.dimensions.filter((e) => w(e)), a = e.measures.filter((e) => w(e));
347
- if (!i?.[0] || !r.offset?.enabled || !r.offset?.showLine) return null;
348
- let o = H(e), s = W(e, a[0]), c = {
349
- scale: o,
350
- fn: n.scales[o]?.type === M.Linear ? void 0 : (e) => {
351
- let t = e.scale;
352
- return t(e.datum.value) + t.bandwidth();
353
- }
354
- }, l = {
355
- scale: o,
356
- fn: (e, t) => e.data.items[t + 1] ? e.scale(e.data.items[t + 1].value) : 1
357
- }, u = {
358
- scale: s,
359
- ref: "end"
360
- }, d = e.orientation === p.Horizontal ? {
361
- y0: c,
362
- y1: l,
363
- x0: u,
364
- x1: u
365
- } : {
366
- y0: u,
367
- y1: u,
368
- x0: c,
369
- x1: l
370
- };
371
- return {
372
- key: "bar-bridge",
373
- type: R.LineCoord,
374
- data: { collection: "collection" },
375
- settings: {
376
- ...d,
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
- }, pt = (e, t) => (n) => {
389
- if (typeof n.datum.end.value != "number") return null;
390
- let r = new G(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: F(e) ? 0 : 90,
402
- stops: i
403
- };
404
- }, mt = (e, t, n, r, i, s) => {
405
- let c = e.dimensions.filter((e) => w(e)), l = e.measures.filter((e) => w(e)), u = K(e), d = { scale: H(e) };
406
- u.isMeasureOnly && (d = {
407
- scale: "onlyMeasures",
408
- ref: u.stacked ? "stackKey" : "series"
409
- });
410
- let f = new qe(e, t, i?.[0]?.itemsNotAffectedByFiltering), p = c.reduce((e, t) => (e[o(t.dataItem)] = !0, e), {}), h = l.reduce((n, r, i) => {
411
- if (u.stacked && i !== 0) return n;
412
- let c = { collection: U.Collection };
413
- if (u.isMeasureOnly && (c = {
414
- collection: "collection-no-dimension",
415
- filter: (e) => u.stacked || e?.source?.field === o(r.dataItem)
416
- }), u.grouped) {
417
- let e = o(r.dataItem);
418
- c = {
419
- ...c,
420
- filter: (t) => t.series?.source?.field ? p[t.series?.source?.field] : t.series?.value === e
421
- };
422
- }
423
- let l = { overwriteSources: [f.MAIN_FIELD, "series"] };
424
- (e.coloring?.type === a.Categorical || e.coloring?.type === a.Gradient) && (l.ref = "color");
425
- let m = f.getColorDefinition(l);
426
- u?.translucentBars && (m = pt(e, m));
427
- let h = {
428
- scale: W(e, r),
429
- ref: "end"
430
- }, g = vt(e, t, d, h, m);
431
- return [...n, _t(e, r, g, c, s)];
432
- }, []);
433
- if (m(e)) {
434
- let r = ft(e, t, n, u);
435
- r && h.push(r);
436
- }
437
- return {
438
- ...n,
439
- components: [...n.components, ...h]
440
- };
441
- }, ht = (e) => {
442
- let t = [], n = e.dimensions.filter((e) => w(e)), r = e.measures.filter((e) => w(e));
443
- return n.length || t.push(V.property), n?.[0] && t.push(""), n?.[1] && t.push("series"), r.length > 1 && t.push(V.property), t;
444
- }, gt = (e) => {
445
- let t, n = K(e), r = e.measures.filter((e) => w(e));
446
- if (n.stacked && r.length > 0) {
447
- let e = o(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 = J(n), s = Y(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 = J(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[X.StackTotal] = { value: s }, a[X.StackTotalLabel] = { value: +(c === a) }, n.isMultiDimension) {
472
- let t = Y(a, e), n = typeof t == "number" && s !== 0 ? t / s : 0;
473
- a[X.Ratio] = { value: Number.isFinite(n) ? n : 0 };
474
- }
475
- });
476
- };
477
- }
478
- return t;
479
- }, _t = (e, t, n, r, a) => {
480
- let o = gt(e), s = K(e), c = s.isMultiMeasure || s.stacked && s.isMultiDimension, l = Ie(ht(e), a, { valuePickerMode: a?.valuePickerMode }, c ? O.AndSubset : void 0);
481
- return {
482
- type: R.Box,
483
- layout: { displayOrder: D.VisualizationElement },
484
- key: z(e, t, i.Bar),
485
- data: r,
486
- settings: n,
487
- animations: {
488
- enabled: !0,
489
- presetId: "bar-chart"
490
- },
491
- beforeRender: o,
492
- brush: l
493
- };
494
- }, vt = (e, t, n, r, i) => {
495
- let a = e.dimensions.filter((e) => w(e)), c = e.measures.filter((e) => w(e)), [, l] = a, u = K(e), d = {
496
- orientation: e.orientation ?? p.Vertical,
497
- major: n,
498
- minor: r,
499
- box: {
500
- minWidthPx: 2,
501
- ref: "",
502
- rx: C(u.barRadius, 0),
503
- fill: i,
504
- stacked: u.stacked,
505
- grouped: u.grouped,
506
- boxPadding: u.barPadding,
507
- groupPadding: u.groupPadding,
508
- itemsInStackCount: c?.length,
509
- roundAllEdges: u.roundAllEdges ?? !1,
510
- useCustomBoxRounding: u.useCustomBoxRounding ?? !1,
511
- ignoreOutOfBounds: u.ignoreOutOfBounds ?? !1
512
- }
513
- };
514
- if (e.barSettings?.strokeEnabled ? (d.box.stroke = dt(t, e.barSettings?.strokeColor), d.box.strokeWidth = e.barSettings?.strokeWidth) : d.box.stroke = s.transparent, !u.isMeasureOnly && u.grouped && !e?.axes?.dimension?.continuousAxis) {
515
- let t = u.isMultiDimension ? o(l?.dataItem) : "measures";
516
- d.major.fn = (n) => {
517
- let r = n.resources.scale(H(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
- }, d.box.width = (e) => e.resources.scale(t).bandwidth();
520
- }
521
- return d;
522
- }, yt = (e, t) => {
523
- let n = F(e), r = e.measures.filter(w), i;
524
- if (y(e)) {
525
- let n = e.dimensions.filter(w)[1], a = o(n.dataItem), s = t?.[0]?.items ?? [];
526
- i = [...new Set(s.map((e) => e[a]))].map((e) => ({
527
- measure: r[0],
528
- seriesValue: e
529
- }));
530
- } else i = r.map((e) => ({
531
- measure: e,
532
- seriesValue: o(e.dataItem)
533
- }));
534
- return i.slice(0, 2).map(({ measure: t, seriesValue: r }, i) => {
535
- let a = i === +!!e.barSettings.swapSides, o = n === a ? 0 : .5;
536
- return {
537
- measure: t,
538
- seriesValue: r,
539
- scale: n ? i === 0 ? U.XAxisScale : U.X2AxisScale : i === 0 ? U.YAxisScale : U.Y2AxisScale,
540
- region: {
541
- direction: n ? "horizontal" : "vertical",
542
- start: o,
543
- end: o + .5,
544
- dock: n ? "bottom" : "left"
545
- }
546
- };
547
- });
548
- }, bt = (e, t) => {
549
- let n = we(t, !1, !1);
550
- return {
551
- ...n,
552
- data: { collection: U.Collection },
553
- formatter: e.measure.formatter,
554
- type: M.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
- }, xt = new G(Oe.fontLight), St = new G(Oe.fontDark), Ct = (e) => {
567
- switch (!0) {
568
- case e.grouped: return "grouped";
569
- case e.stacked: return "stacked";
570
- default: return "normal";
571
- }
572
- }, wt = (e, t, n, r, a, s) => {
573
- let c = K(e), u = e.dimensions.filter(w), d = e.measures.filter(w), f = d[0], p = c.stacked && u.length > 1 && d.length === 1;
574
- if (!f?.dataLabels?.show) return n;
575
- let m = o(f.dataItem), h = new G(t.fonts.general.color), g = f.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 G(n ? r : "#ffffff").betterContrast(h, xt, St).rgb();
578
- }), _ = [], v = f.dataLabels.displayParts?.includes(l.Value), y = f.dataLabels.displayParts?.includes(l.Ratio);
579
- (v || !f.dataLabels.displayParts && c.stackedOffset !== E.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[m].value, void 0, e.data);
589
- },
590
- hideEllipsed: !0
591
- }), (y || !f.dataLabels.displayParts && c.stackedOffset === E.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(Z.Share)(e.data[X.Ratio].value);
601
- },
602
- hideEllipsed: !0
603
- });
604
- let b = {
605
- key: "bar-labels-stacked-0",
606
- type: R.Labels,
607
- layout: { displayOrder: D.Labels },
608
- settings: { sources: [{
609
- component: z(e, e.measures.filter(w)?.[0], i.Bar),
610
- selector: k.Rect,
611
- strategy: {
612
- type: "rows",
613
- settings: {
614
- justify: .5,
615
- align: .5,
616
- fontSize: P(f.dataLabels?.size),
617
- fontFamily: t.fonts.general.fontFamily,
618
- labels: _
619
- }
620
- }
621
- }] },
622
- ...s?.disable?.brushing ? {} : { brush: { consume: [{
623
- context: Ve.Selection,
624
- data: ["", "series"],
625
- mode: p ? O.AndSubset : O.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, b]
636
- };
637
- }, Tt = (e, t, n, r, a) => {
638
- let o = K(e), s = F(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(w), d = y(e);
643
- return (o.pyramid ? yt(e, a) : e.measures.map((e) => ({
644
- measure: e,
645
- region: void 0,
646
- scale: void 0
647
- }))).forEach(({ measure: n, region: r, scale: a }, f) => {
648
- if (n.dataLabels?.show) {
649
- let p = u.indexOf(n), m = z(e, o.stacked ? e.measures.filter(w)?.[0] : n, i.Bar), h = Ct(o), g = $e(n.dataLabels.barLabelPlacements, o.stacked).filter((e) => e.possible).map((e) => ({
650
- position: e.position,
651
- justify: e.justify,
652
- overflow: [T.Outside, T.Opposite].includes(e.position),
653
- fill: e.position === T.Inside ? "#fff" : "#242424"
654
- }));
655
- n.dataLabels?.showBackdrop && !o.stacked && (g = g.map((e) => Ue(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}-${f}`,
666
- type: R.Labels,
667
- layout: {
668
- displayOrder: D.Labels,
669
- ...r && { region: r }
670
- },
671
- settings: { sources: [{
672
- component: d && f === 1 ? `${m}-second` : m,
673
- selector: k.Rect,
674
- strategy: {
675
- type: "bar",
676
- settings: {
677
- direction: (e) => c(e, a),
678
- fontSize: P(n.dataLabels?.size),
679
- fontFamily: t.fonts.general.fontFamily,
680
- labels: [{
681
- label: me(n, p >= 0 ? `measure-${p}` : void 0),
682
- placements: g
683
- }]
684
- }
685
- }
686
- }] },
687
- animations: {
688
- enabled: !0,
689
- presetId: "chart-labels"
690
- }
691
- });
692
- }
693
- }), {
694
- ...n,
695
- components: [...n.components, ...l]
696
- };
697
- }, Et = (e, t, n, r, i, a) => {
698
- let o = K(e);
699
- return o.isMultiDimension && o.stacked ? wt(e, t, n, r, i, a) : Tt(e, t, n, r, i);
700
- }, Dt = (e) => {
701
- let t = e.measures.filter(w), n = t[t.length - 1];
702
- return !!n?.formatter && te(n.formatter);
703
- }, Ot = (e, t) => {
704
- let n = t.data[X.StackTotal]?.value;
705
- return typeof n == "number" ? n : e.measures.filter(w).reduce((e, n) => {
706
- let r = t.data[o(n.dataItem)]?.value;
707
- return e + (typeof r == "number" ? r : 0);
708
- }, 0) || void 0;
709
- }, kt = (e) => ({ node: t }) => {
710
- let n = Ot(e, t);
711
- if (typeof n != "number") return null;
712
- let r = n >= 0;
713
- return F(e) ? r ? "right" : "left" : r ? "up" : "down";
714
- }, At = (e, t, n) => {
715
- if (t.data[X.StackTotalLabel]) return Math.round(t.data[X.StackTotalLabel].value) === 1;
716
- let r = t.data.end?.value;
717
- if (typeof r != "number" || e.barSettings.stackedOffset === E.Expand) return !1;
718
- if (t.data[X.StackTotal]) return Math.round(r) === Math.round(n);
719
- let i = [...e.measures.filter(w)].reverse().find((e) => {
720
- let r = t.data[o(e.dataItem)]?.value;
721
- return typeof r == "number" && (n >= 0 ? r > 0 : r < 0);
722
- });
723
- return t.data.series?.value === o(i?.dataItem);
724
- }, jt = (e, t) => {
725
- if (!e.barSettings.showTotal || !K(e).stacked) return;
726
- let n = e.measures.filter(w), r = n[0], a = n.length - 1;
727
- if (!(!r || a < 0)) return {
728
- key: "bar-labels-stacked-total",
729
- type: R.Labels,
730
- layout: { displayOrder: D.Labels },
731
- settings: { sources: [{
732
- component: z(e, r, i.Bar),
733
- selector: k.Rect,
734
- strategy: {
735
- type: "bar",
736
- settings: {
737
- direction: kt(e),
738
- fontSize: P(r.dataLabels?.size),
739
- fontFamily: t.fonts.general.fontFamily,
740
- labels: [{
741
- label({ node: t, formatter: n }) {
742
- let r = Ot(e, t);
743
- if (r === void 0 || !At(e, t, r)) return "";
744
- if (e.barSettings.stackedOffset === E.Expand) {
745
- let t = r < 0 ? -1 : 1;
746
- return Dt(e) ? n(Z.Share)(t) : String(t);
747
- }
748
- return n(`measure-${a}`)(r);
749
- },
750
- placements: [{
751
- position: T.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
- }, Mt = (e, t, n) => {
766
- let r = jt(e, t);
767
- return r ? {
768
- ...n,
769
- components: [...n.components, r]
770
- } : n;
771
- }, Nt = (e, t, n, r, a) => {
772
- let o = e.measures.filter((e) => w(e)), s = K(e), c = y(e), l = o.flatMap((t) => {
773
- let n = z(e, t, i.Bar);
774
- return c ? [n, `${n}-second`] : [n];
775
- }), u = Pt(e), d = s.grouped && s.isMultiMeasure ? ye(e, a) : void 0, f = j(e, t, We, u, a && a[0] ? a[0].sum : void 0, d);
776
- if (s.stacked) {
777
- let n = ye(e, a), r = s?.stackedOffset === E.Expand, i = s.isMultiDimension ? It(n, r) : Lt(n, r);
778
- f = j(tt(e), t, i, u);
779
- }
780
- return s.isMeasureOnly && (f = j(e, t, Rt, u)), Se(e, t, n, {
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-${R.Box}`);
788
- }, Pt = (e) => (t, n, r) => [Ft(e, n, r), Ge(t, n, r)].filter((e) => e?.length > 0).join("\n"), Ft = (e, t, n) => {
789
- let r = rt(e);
790
- return nt(t, n.scale(r)) ? lt.outOfRangeTitle : "";
791
- }, Q = (e, t, n, r, i) => {
792
- let a = i && !ee(e.formatter) ? I(e.formatter) : e.formatter;
793
- return r.formatter(a)(t, void 0, n.data);
794
- }, It = (e, t = !1) => (n, r, i, a, s, c, l, u) => {
795
- let d = n.filter((e) => w(e)), f = N(i), p = d.filter((e) => !f.has(o(e.dataItem))), m = d.map((e) => {
796
- let t = o(e.dataItem), n = Object.keys(r.data).find((t) => r.data[t]?.source?.field === o(e.dataItem)), a;
797
- if (r.data.end?.value !== void 0 && r.data.start?.value !== void 0 && !f.has(t)) a = r.data.end.value - r.data.start.value;
798
- else if (n) a = r.data[n].value;
799
- else return {
800
- label: "",
801
- value: ""
802
- };
803
- let s = b(e), c = a;
804
- return (e.formatter || u) && (c = Q(e, a, r, i, 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, a = p[0]?.formatter?.format?.formatType;
811
- t && zt(a) ? n = "100%" : (n = e[r?.data?.value], !u && p[0]?.formatter ? n = i.formatter(p[0].formatter)(e[r?.data?.value]) : u && (n = i.formatter(I(p[0]?.formatter))(e[r?.data?.value]))), m.push({
812
- label: "Total",
813
- value: n
814
- });
815
- }
816
- return m;
817
- }, Lt = (e, t = !1) => (n, r, i, a, s, c, l, u) => {
818
- let d = n.filter((e) => w(e)), f = N(i), p = d.filter((e) => !f.has(o(e.dataItem))), m = p.reduce((e, t) => e + Number(r.data[o(t.dataItem)]?.value ?? 0), 0), h = d.map((e) => {
819
- let n = r.data.end?.value !== void 0 && r.data.start?.value !== void 0, a = o(e.dataItem), s = f.has(a), c = r.data.series?.value?.toString() === a, 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 === a);
823
- l = e ? r.data[e]?.value : void 0, t && !s && typeof l == "number" && m !== 0 && (l /= m);
824
- }
825
- if (l === void 0) return {
826
- label: "",
827
- value: ""
828
- };
829
- let d = b(e), h = l;
830
- return (e.formatter || u) && (h = Q(e, l, r, i, u)), {
831
- label: d || e.label || e.dataItem.name || "",
832
- value: h,
833
- ...p.length > 1 && c && !s && { isHighlighted: !0 }
834
- };
835
- });
836
- if (!l && e && e[r?.data?.value] !== void 0) {
837
- let n = p[p.length - 1], a, o = n?.formatter?.format?.formatType;
838
- t && zt(o) ? a = "100%" : (a = e[r?.data?.value], !u && n?.formatter ? a = i.formatter(n.formatter)(e[r?.data?.value]) : u && (a = i.formatter(I(n?.formatter))(e[r?.data?.value]))), h.push({
839
- label: "Total",
840
- value: a
841
- });
842
- }
843
- return h;
844
- }, Rt = (e, t, n) => {
845
- let r = e.filter((e) => w(e)), i = N(n), a = t.data.series?.value?.toString(), s = a ? t.data[a]?.value : void 0, c = r.find((e) => o(e.dataItem) === a), l = b(c) || c?.label || c?.dataItem?.name, u = [];
846
- return l && s !== void 0 && u.push({
847
- label: l,
848
- value: c?.formatter && n ? Q(c, s, t, n) : s
849
- }), r.filter((e) => i.has(o(e.dataItem))).forEach((e) => {
850
- let r = o(e.dataItem), i = Object.keys(t.data).find((e) => t.data[e]?.source?.field === r), a = i ? t.data[i]?.value : void 0;
851
- if (a === void 0) return;
852
- let s = b(e) || e.label || e.dataItem.name || "";
853
- u.push({
854
- label: s,
855
- value: e.formatter && n ? Q(e, a, t, n) : a
856
- });
857
- }), u;
858
- }, zt = (e) => e === S.PercentageNoDecimal || e === S.Percentage1Decimal || e === S.Percentage2Decimal, Bt = (e, t, n) => {
859
- let r = e.barSettings?.offset?.enabled ?? !1, i = e.dimensions.filter((e) => w(e)), a = e.measures.filter((e) => w(e));
860
- return i.length === 1 && a.length === 1 && !r ? Te(e, t, n) : n;
861
- }, Vt = (e, t, n, r, s, c) => {
862
- if (!K(e).pyramid) return n;
863
- let l = yt(e, s);
864
- if (!l.length) return n;
865
- let d = new Set(l.map(({ measure: e }) => o(e.dataItem))), f = H(e), p = e.axes?.primaryMeasure ?? {}, m = l[0].region.direction === "horizontal" ? u.Bottom : u.Left, h = {
866
- ...t.axis.measure,
867
- ...t.fonts
868
- }, g = c?.disable?.interactions ?? !1, _ = { ...n.scales }, v = [...n.interactions ?? []];
869
- l.forEach((e) => {
870
- _[e.scale] = bt(e, p);
871
- });
872
- let y = n.components.flatMap((t) => {
873
- if (t.type === ge.CategoricalLegend && (t.scale === a.PerEachMeasure || t.scale === a.Single)) return [{
874
- ...t,
875
- settings: {
876
- ...t.settings,
877
- item: {
878
- ...t.settings.item,
879
- show: ({ datum: e }) => d.has(String(e.value))
880
- }
881
- }
882
- }];
883
- if (t.type === R.Axis && t.scale !== f || t.type === R.Text && t.dataItemType === ne.Measure) return [];
884
- if (t.type === R.Box) {
885
- let n = l.filter(({ measure: n }) => z(e, n, i.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 === R.AxisTooltip && t.scale !== f) return l.map((e, n) => {
909
- let [r, i] = Me(n === 0 ? t.key : `${t.key}-second`, e.scale, e.measure.formatter, {
910
- ...t.settings,
911
- labelDock: m
912
- });
913
- return n > 0 && v.push(i), {
914
- ...r,
915
- layout: {
916
- ...r.layout,
917
- region: e.region
918
- }
919
- };
920
- });
921
- if (t.type === R.Grid) {
922
- let e = m === u.Bottom ? "x" : "y";
923
- if (t[e]?.scale && t[e]?.scale !== f) return l.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 p.disabled || (l.forEach((e, t) => {
936
- let n = L(e.scale, p, h, m, e.measure.formatter, c, g);
937
- n.settings = {
938
- ...n.settings,
939
- align: m
940
- }, y.push({
941
- ...n,
942
- layout: {
943
- ...n.layout,
944
- region: e.region,
945
- dock: t === 0 ? m : `@axis.${l[0].scale}`
946
- }
947
- });
948
- }), p.showAxisName !== !1 && l.forEach((e, t) => {
949
- let n = Pe([e.measure], !1, m, h, p.colors?.title, p.axisTitle, p.titleFontSize, `pyramid-${t}`);
950
- y.push({
951
- ...n,
952
- layout: {
953
- ...n.layout,
954
- region: e.region,
955
- dock: t === 0 ? m : "@text-pyramid-0"
956
- }
957
- });
958
- })), {
959
- ...n,
960
- scales: _,
961
- components: y,
962
- interactions: v
963
- };
964
- }, $ = class extends Ne {
965
- constructor() {
966
- super([
967
- ut,
968
- ct,
969
- at,
970
- _e,
971
- Ee,
972
- He,
973
- mt,
974
- Et,
975
- Mt,
976
- ke,
977
- Bt,
978
- Nt,
979
- Xe,
980
- De,
981
- Vt,
982
- he
983
- ]);
984
- }
985
- preCompile(e) {
986
- let t = e, { stacked: n } = K(t);
987
- n && (t.measures = t.measures.map((e) => ({
988
- ...e,
989
- secondaryAxis: !1
990
- })));
991
- }
992
- }, Ht = re(), Ut = ae(({ vSpec: e, vTheme: t, data: n, elementSize: r, vizProperties: a }) => {
993
- let o = oe(), [s] = (0, Ye.useState)(() => new $()), c = se(), { activeKey: l } = le(), u = ie(), d = Le();
994
- if (!e || !n || !r || !m(e) && !v(e)) return null;
995
- let f = {
996
- ...a,
997
- valuePickerMode: !!l
998
- }, p = t || _, h = s.compile(e, p, n, r, {
999
- ...f,
1000
- onRenderDone: c
1001
- }, i.Bar, o, u, d);
1002
- return h ? /* @__PURE__ */ (0, Ht.jsx)(Fe, {
1003
- config: f,
1004
- definition: h,
1005
- size: r,
1006
- vSpec: e
1007
- }) : null;
1008
- }), Wt = /* @__PURE__ */ t({
1009
- BarChart: () => Ut,
1010
- BarChartCompiler: () => $
1011
- });
1012
- export { Ut as n, $ as r, Wt as t };