@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
@@ -0,0 +1,357 @@
1
+ import { o as e } from "./rolldown-runtime-DleVn1XH.js";
2
+ import { $c as t, Rc as n, Sa as r, Xc as i, _n as a, di as o, gr as s, hl as c, ms as l, po as u, ql as d, u as f } from "./visualization-filters-B9qik5_K.js";
3
+ import { Mt as p, P as m, Ur as h, fi as g, s as _ } from "./utils-CUKgR7it.js";
4
+ import { l_ as v, w_ as y } from "./handlers-CyYFSfhM.js";
5
+ import { t as b } from "./label-format-type-C46pzgx7.js";
6
+ import "./logger-Cioob-QV.js";
7
+ import { Cn as x, F as S, I as C, It as w, Mn as T, P as E, Qt as ee, R as te, Zt as ne, _ as D, _t as O, en as k, i as A, jt as re, kt as ie, mn as ae, n as oe, sn as j, un as M, v as se, vn as N, vt as P, wn as F, z as I } from "./escobar-CMvphKSK.js";
8
+ import { _ as L } from "./MenuOption-DpKFJxmo.js";
9
+ import { t as R } from "./coloring-Cd6p0GQJ.js";
10
+ import { t as z } from "./set-coloring-datafield-B3uIS1Pe.js";
11
+ var B = /* @__PURE__ */ e(g()), V = (e, n, r) => {
12
+ let { coloring: i } = e || {}, a = i?.fieldId, s = e.dimensions.filter((e) => o(e)), l = e.measures.filter((e) => o(e)), d = l.filter((e) => e.role === u.PIE_CHART_SLICE), f = l.filter((e) => e.role === u.PIE_CHART_LENGTH);
13
+ a || (e.coloring?.type === t.Gradient ? a = c(d[0]?.dataItem) : e.coloring?.type === t.Categorical && (a = c(s[0]?.dataItem))), ie(r, 0, { color: { field: a } });
14
+ let p = w(z(e, a ?? null), n, {});
15
+ if (f.length > 0) {
16
+ let e = c(f[0]?.dataItem);
17
+ p[e] = { data: { field: e } };
18
+ }
19
+ return {
20
+ ...r,
21
+ scales: p
22
+ };
23
+ }, H = {
24
+ num: "num",
25
+ rad: "rad",
26
+ group: "group"
27
+ }, U = (e, t, n) => {
28
+ if (!e.dimensions[0]) return n;
29
+ let r = e.measures.filter((e) => o(e)), i = se((e.supportingMeasures ?? []).filter((e) => o(e))), a = e.dimensions.filter((e) => o(e))?.[0], s = r.filter((e) => e.role === u.PIE_CHART_SLICE)?.[0], l = r.filter((e) => e.role === u.PIE_CHART_LENGTH)?.[0], d = c(s?.dataItem), f = c(l?.dataItem), p = c(a?.dataItem), m = {
30
+ [H.num]: s?.dataItem?.name ? { field: d } : void 0,
31
+ [H.rad]: l?.dataItem?.name ? { field: f } : void 0,
32
+ ...i
33
+ };
34
+ d && (m[d] = { field: d }), f && (m[f] = { field: f });
35
+ let h = [{
36
+ key: N.Collection,
37
+ data: { extract: [{
38
+ field: p,
39
+ props: m
40
+ }] }
41
+ }];
42
+ return {
43
+ ...n,
44
+ collections: h
45
+ };
46
+ }, W = "pie-alternates-switcher", G = "pie-alternates-switcher", K = (e) => a(e) || e.label || e.dataItem?.name || "Field", ce = (e, t, n, r) => {
47
+ let i = n ? c(n.dataItem) : void 0;
48
+ return {
49
+ type: "native",
50
+ key: `${G}-interaction`,
51
+ events: { click(a) {
52
+ let o = this.element.getBoundingClientRect(), s = {
53
+ x: a.clientX - o.left,
54
+ y: a.clientY - o.top
55
+ }, c = this.chart.shapesAt(s, {
56
+ components: [{
57
+ key: G,
58
+ propagation: "stop"
59
+ }],
60
+ propagation: "stop"
61
+ }).find((e) => e.data?.target === "measure" || e.data?.target === "dimension");
62
+ if (c?.data?.target === "measure" && n && i) {
63
+ r(T.Text, "click", `text-${i}`, a, c, {
64
+ dataItemType: d.Measure,
65
+ dataItemRole: n.role
66
+ });
67
+ return;
68
+ }
69
+ c?.data?.target === "dimension" && e && r(T.Text, "click", `text-${e}`, a, c, {
70
+ dataItemType: d.Dimension,
71
+ dataItemRole: t
72
+ });
73
+ } }
74
+ };
75
+ }, le = (e, t, n, r, i, a, f, p) => {
76
+ let m = s(e.dimensions, e.enableAlternate, a?.isPrintMode), h = e.dimensions.filter((e) => o(e)), g = h[0], _ = g ? c(g.dataItem) : void 0, v = e.measures.filter((e) => e.role === u.PIE_CHART_SLICE), y = s(v, e.enableAlternate, a?.isPrintMode), b = v.filter((e) => o(e))[0], S = m && h.length ? h.map((e) => K(e)).join(", ") : void 0, C = y && b ? K(b) : void 0;
77
+ if (!S && !C) return n;
78
+ let w = {
79
+ type: W,
80
+ key: G,
81
+ dimensionDataItemType: _ ? d.Dimension : void 0,
82
+ dimensionDataItemRole: g?.role,
83
+ measureDataItemType: b ? d.Measure : void 0,
84
+ measureDataItemRole: b?.role,
85
+ layout: {
86
+ dock: l.Bottom,
87
+ displayOrder: 0
88
+ },
89
+ settings: {
90
+ dimensionLabel: S ? j(S) : void 0,
91
+ measureLabel: C ? j(C) : void 0,
92
+ fontFamily: t.fonts.general.fontFamily ?? void 0,
93
+ fontSize: `${x.fieldTitle.fontSize}px`,
94
+ color: t.fonts.general.color,
95
+ paddingLeft: 5,
96
+ paddingRight: 5,
97
+ paddingVertical: 5,
98
+ labelGap: 12
99
+ }
100
+ }, T = p ? [ce(_, g?.role, b, p)] : [];
101
+ return {
102
+ ...n,
103
+ components: [...n.components, w],
104
+ interactions: n.interactions ? [...n.interactions, ...T] : T
105
+ };
106
+ }, q = {
107
+ outerRadius: .8,
108
+ outerRadiusWithoutLabels: .95,
109
+ cornerRadius: v.pie,
110
+ strokeWidth: 0,
111
+ strokeEnabled: !1,
112
+ strokeColor: "#C6C6C6",
113
+ multiMeasureMinRadius: .3,
114
+ donut: {
115
+ innerRadius: .55,
116
+ cornerRadius: v.donut,
117
+ multiMeasureMinRadius: .6
118
+ }
119
+ };
120
+ function J(e) {
121
+ return e.pieSettings?.donut ?? !1;
122
+ }
123
+ var ue = (e, t, n, r, i, a) => {
124
+ let s = e.measures.filter((e) => o(e)), l = s.filter((e) => e.role === u.PIE_CHART_SLICE), d = s.filter((e) => e.role === u.PIE_CHART_LENGTH), f = l[0], p = d[0], m = new R(e, t, i?.[0]?.itemsNotAffectedByFiltering), h = J(e) ? q.donut.innerRadius : 0, g = f?.dataLabels?.show === !1 ? q.outerRadiusWithoutLabels : q.outerRadius, _ = e.pieSettings?.cornerRadius ?? (J(e) ? q.donut.cornerRadius : q.cornerRadius), v = e.pieSettings?.strokeEnabled ?? q.strokeEnabled, y = e.pieSettings?.strokeWidth ?? q.strokeWidth, b = e.pieSettings?.strokeColor ?? q.strokeColor;
125
+ if (p) {
126
+ let t = g, n = J(e) ? q.donut.multiMeasureMinRadius : q.multiMeasureMinRadius;
127
+ g = (e) => e.resources.scale(c(p.dataItem))(e.datum.rad.value) * (t - n) + n;
128
+ }
129
+ let x = {
130
+ type: T.Pie,
131
+ key: `${T.Pie}`,
132
+ data: { collection: N.Collection },
133
+ animations: {
134
+ enabled: !0,
135
+ presetId: "pie-chart"
136
+ },
137
+ settings: { slice: {
138
+ arc: { ref: "num" },
139
+ stroke: b,
140
+ strokeWidth: v ? y : 0,
141
+ cornerRadius: _,
142
+ innerRadius: h,
143
+ outerRadius: g,
144
+ fill: m.getColorDefinition({ ref: "color" })
145
+ } },
146
+ brush: M([""], a, { valuePickerMode: a?.valuePickerMode })
147
+ };
148
+ return {
149
+ ...n,
150
+ components: [...n.components, x]
151
+ };
152
+ }, de = (e, t, n) => ({ data: r, formatter: i }) => {
153
+ let a = e.dimensions.filter((e) => o(e))[0], s = r.value, c = r[H.num].value, l = a.formatter && s && i ? i(a.formatter)(s) : `${s}`, u = t.formatter && c && i ? i(t.formatter)(c, void 0, r) : `${c}`, d = c != null && n && i ? i(P)(c / n) : null, f = () => t.dataLabels?.measureLabelFormat === y.Percentage ? d === null ? [] : [d] : t.dataLabels?.measureLabelFormat === y.ValueAndPercentage ? d === null ? [u] : [u, d] : [u];
154
+ switch (t.dataLabels?.labelFormat) {
155
+ case b.Measure: {
156
+ let e = f();
157
+ return e.length <= 1 ? e[0] ?? null : e;
158
+ }
159
+ case b.DimensionAndMeasure: return [l, ...f()];
160
+ default: return l;
161
+ }
162
+ }, fe = (e, t, n, r, i, a) => {
163
+ let s = e.dimensions.filter((e) => o(e)), c = e.measures.filter((e) => o(e)), l = s[0], d = c.find((e) => e.role === u.PIE_CHART_SLICE) ?? c[0];
164
+ if (!l || !d || !d.dataLabels?.show) return n;
165
+ let p = new L(t.fonts.general.color), m = d.dataLabels.showBackdrop ? ne(d.dataLabels.backdropColor ? { fill: d.dataLabels.backdropColor } : void 0) : void 0, h = m ? ee(p, t) : d.dataLabels.textColor || t.fonts.general.color || "#000", { strokeEnabled: g, strokeWidth: _ = q.strokeWidth } = e.pieSettings, v = g ? _ / 2 : 0, y = {
166
+ type: T.Labels,
167
+ key: "pie-labels",
168
+ animations: {
169
+ enabled: !0,
170
+ presetId: "chart-labels"
171
+ },
172
+ layout: { displayOrder: k.Labels },
173
+ settings: { sources: [{
174
+ component: `${T.Pie}`,
175
+ selector: F.Path,
176
+ strategy: {
177
+ type: "slice",
178
+ settings: {
179
+ fontSize: ae(d.dataLabels.size, f(t).fontSizes.dataLabel),
180
+ fontFamily: t.fonts.general.fontFamily,
181
+ labels: [{
182
+ label: de(e, d, i?.[0]?.sum),
183
+ placements: [{
184
+ position: "outside",
185
+ fill: h,
186
+ backdrop: m
187
+ }],
188
+ strokeDelta: v,
189
+ linkData: ({ data: e }) => e
190
+ }]
191
+ }
192
+ }
193
+ }] },
194
+ brush: M([""], a, { valuePickerMode: a?.valuePickerMode })
195
+ };
196
+ return {
197
+ ...n,
198
+ components: [...n.components, y]
199
+ };
200
+ }, Y = (e, t, n, r, i) => {
201
+ let o = n.data[t]?.value, s = a(e) || e.label || e.dataItem.name || "", c = o;
202
+ return !i && e.formatter ? c = r.formatter(e.formatter)(o, void 0, n.data) : i && (c = r.formatter(O(e.formatter))(o, void 0, n.data)), {
203
+ label: s,
204
+ value: c
205
+ };
206
+ }, pe = (e, t, n, r, i) => {
207
+ let a = !!e.measures.filter(o).filter((e) => e.role === u.PIE_CHART_LENGTH)?.[0], s = {
208
+ filter: (e) => e.filter((e) => e.key === T.Pie),
209
+ placement: {
210
+ type: "slice",
211
+ area: "target"
212
+ }
213
+ };
214
+ if (a) return E(e, t, n, s, "tooltip", i);
215
+ let c = I(e, i), l = S(e, t, me, C, i?.[0]?.sum, c);
216
+ return E(e, t, n, {
217
+ ...s,
218
+ extract: l
219
+ }, "tooltip", i);
220
+ }, me = (e, t, n, r, i, a, s, l) => {
221
+ let u = [], d = e.filter(o), f = te(n), p = d.filter((e) => !f.has(c(e.dataItem)))?.[0] ?? d?.[0], m = Object.keys(t.data).find((e) => t.data[e]?.source?.field === c(p?.dataItem));
222
+ if (!m || !p ? u.push({
223
+ label: "",
224
+ value: ""
225
+ }) : u.push(Y(p, m, t, n, l)), d.filter((e) => f.has(c(e.dataItem))).forEach((e) => {
226
+ let r = c(e.dataItem), i = Object.keys(t.data).find((e) => t.data[e]?.source?.field === r);
227
+ i && u.push(Y(e, i, t, n, l));
228
+ }), s) return u;
229
+ let h = Object.values(a ?? {}).reduce((e, t) => e + Number(t), 0);
230
+ return u.push({
231
+ label: "Total",
232
+ value: p?.formatter ? n.formatter(p.formatter)(h) : h
233
+ }), u;
234
+ }, he = class extends D {
235
+ constructor() {
236
+ super([
237
+ U,
238
+ V,
239
+ ue,
240
+ le,
241
+ fe,
242
+ re,
243
+ pe
244
+ ]);
245
+ }
246
+ preCompile(e) {
247
+ let t = e.dimensions.filter((e) => o(e))?.[0], n = e.measures.filter((e) => o(e))?.[0];
248
+ if (!t || !n) throw Error("Charts w/o dimensions or measures are not supported ATM.");
249
+ }
250
+ }, X = " ▼", Z = "...", Q = (e, t, n, r) => e.measureText({
251
+ text: t,
252
+ fontFamily: n,
253
+ fontSize: r
254
+ }).width, ge = (e, t, n, r, i) => {
255
+ if (t <= 0 || Q(n, e, r, i) <= t) return e;
256
+ let a = e.endsWith(X), o = a ? X : "", s = a ? e.slice(0, -2) : e;
257
+ if (Q(n, `${Z}${o}`, r, i) > t) return Z;
258
+ let c = 0, l = s.length;
259
+ for (; c < l;) {
260
+ let e = Math.ceil((c + l) / 2);
261
+ Q(n, `${s.slice(0, e)}${Z}${o}`, r, i) <= t ? c = e : l = e - 1;
262
+ }
263
+ return `${s.slice(0, c)}${Z}${o}`;
264
+ }, $ = {
265
+ require: ["renderer"],
266
+ defaultSettings: { settings: {
267
+ dimensionLabel: "",
268
+ measureLabel: "",
269
+ fontSize: "12px",
270
+ color: "#000",
271
+ paddingLeft: 5,
272
+ paddingRight: 5,
273
+ paddingVertical: 5,
274
+ labelGap: 12
275
+ } },
276
+ preferredSize() {
277
+ if (!this.renderer) return 0;
278
+ let { fontFamily: e = "Arial", fontSize: t, paddingVertical: n } = this.settings.settings;
279
+ return this.renderer.measureText({
280
+ fontFamily: e,
281
+ fontSize: t
282
+ }).height + n * 2;
283
+ },
284
+ render() {
285
+ let { renderer: e } = this;
286
+ if (!e) return [];
287
+ let { dimensionLabel: t, measureLabel: n, fontFamily: r = "Arial", fontSize: i, color: a, paddingLeft: o, paddingRight: s, labelGap: c } = this.settings.settings, l = n ? Q(e, n, r, i) : 0, u = this.rect.width - s, d = u - l, f = Math.max(Math.min(n ? d - c - o : this.rect.width - o - s, this.rect.width / 2), 0), p = t ? ge(t, f, e, r, i) : "", m = p ? Q(e, p, r, i) : 0, h = [];
288
+ return n && h.push({
289
+ type: "rect",
290
+ x: Math.max(d, 0),
291
+ y: 0,
292
+ width: Math.min(l, this.rect.width),
293
+ height: this.rect.height,
294
+ fill: "rgba(0, 0, 0, 0)",
295
+ strokeWidth: 0,
296
+ data: { target: "measure" }
297
+ }), t && (h.push({
298
+ type: "rect",
299
+ x: o,
300
+ y: 0,
301
+ width: m,
302
+ height: this.rect.height,
303
+ fill: "rgba(0, 0, 0, 0)",
304
+ strokeWidth: 0,
305
+ data: { target: "dimension" }
306
+ }), h.push({
307
+ type: "text",
308
+ text: p,
309
+ x: o,
310
+ y: this.rect.height / 2,
311
+ anchor: "start",
312
+ baseline: "central",
313
+ fontFamily: r,
314
+ fontSize: i,
315
+ fill: a,
316
+ maxWidth: f,
317
+ data: { target: "dimension" }
318
+ })), n && h.push({
319
+ type: "text",
320
+ text: n,
321
+ x: u,
322
+ y: this.rect.height / 2,
323
+ anchor: "end",
324
+ baseline: "central",
325
+ fontFamily: r,
326
+ fontSize: i,
327
+ fill: a,
328
+ data: { target: "measure" }
329
+ }), h;
330
+ }
331
+ };
332
+ function _e(e) {
333
+ e.component(W, $);
334
+ }
335
+ var ve = (e, t) => {
336
+ let n = e.find((e) => e.role === u.PIE_CHART_SLICE && o(e));
337
+ if (!n) return;
338
+ let r = c(n.dataItem);
339
+ return t.reduce((e, t) => e + t[r], 0);
340
+ }, ye = h(), be = p(({ vSpec: e, vTheme: t, data: a, elementSize: o, vizProperties: s }) => {
341
+ let c = m(), [l] = (0, B.useState)(() => new he()), { activeKey: u } = _(), d = oe();
342
+ if (!e || !n(e) || !a || !o) return null;
343
+ let f = {
344
+ ...s,
345
+ valuePickerMode: !!u
346
+ }, p = t || r;
347
+ a[0] && (a[0].sum = ve(e.measures, a[0].items));
348
+ let h = l.compile(e, p, a, o, f, i.Pie, c, void 0, d);
349
+ return h ? /* @__PURE__ */ (0, ye.jsx)(A, {
350
+ config: f,
351
+ definition: h,
352
+ size: o,
353
+ vSpec: e,
354
+ escobarPlugins: [_e]
355
+ }) : null;
356
+ });
357
+ export { be as PieChart };