@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,357 +0,0 @@
1
- import { o as e } from "./rolldown-runtime-DleVn1XH.js";
2
- import { Fc as t, Io as n, Qr as r, gc as i, ic as a, in as o, ll as s, rr as c, sa as l, yc as u, za as d } from "./visualization-filters-D7i6oh1Z.js";
3
- import { N as f, ci as p, jt as m, s as h, zr as g } from "./utils-DganVptf.js";
4
- import { n_ as _, y_ as v } from "./handlers-C6CZ0XJA.js";
5
- import { t as y } from "./label-format-type-C46pzgx7.js";
6
- import "./logger-DdZpR7xZ.js";
7
- import { H as b, L as x, Qt as S, R as C, St as w, Ut as ee, V as T, Yt as E, _ as D, b as O, bn as k, dn as A, dt as te, fn as ne, i as re, kt as ie, n as ae, on as oe, un as j, ut as se, v as M, wt as N, x as P, z as F } from "./escobar-CvEV2ES1.js";
8
- import { _ as I } from "./MenuOption-Czc34u4q.js";
9
- import { t as L } from "./coloring-BtnPiQ_o.js";
10
- import { t as R } from "./set-coloring-datafield-B3uIS1Pe.js";
11
- var z = /* @__PURE__ */ e(p()), B = (e, n, i) => {
12
- let { coloring: a } = e || {}, o = a?.fieldId, s = e.dimensions.filter((e) => r(e)), c = e.measures.filter((e) => r(e)), l = c.filter((e) => e.role === d.PIE_CHART_SLICE), f = c.filter((e) => e.role === d.PIE_CHART_LENGTH);
13
- o || (e.coloring?.type === u.Gradient ? o = t(l[0]?.dataItem) : e.coloring?.type === u.Categorical && (o = t(s[0]?.dataItem))), w(i, 0, { color: { field: o } });
14
- let p = ie(R(e, o ?? null), n, {});
15
- if (f.length > 0) {
16
- let e = t(f[0]?.dataItem);
17
- p[e] = { data: { field: e } };
18
- }
19
- return {
20
- ...i,
21
- scales: p
22
- };
23
- }, V = {
24
- num: "num",
25
- rad: "rad",
26
- group: "group"
27
- }, H = (e, n, i) => {
28
- if (!e.dimensions[0]) return i;
29
- let a = e.measures.filter((e) => r(e)), o = M((e.supportingMeasures ?? []).filter((e) => r(e))), s = e.dimensions.filter((e) => r(e))?.[0], c = a.filter((e) => e.role === d.PIE_CHART_SLICE)?.[0], l = a.filter((e) => e.role === d.PIE_CHART_LENGTH)?.[0], u = t(c?.dataItem), f = t(l?.dataItem), p = t(s?.dataItem), m = {
30
- [V.num]: c?.dataItem?.name ? { field: u } : void 0,
31
- [V.rad]: l?.dataItem?.name ? { field: f } : void 0,
32
- ...o
33
- };
34
- u && (m[u] = { field: u }), f && (m[f] = { field: f });
35
- let h = [{
36
- key: j.Collection,
37
- data: { extract: [{
38
- field: p,
39
- props: m
40
- }] }
41
- }];
42
- return {
43
- ...i,
44
- collections: h
45
- };
46
- }, U = "pie-alternates-switcher", W = "pie-alternates-switcher", G = (e) => o(e) || e.label || e.dataItem?.name || "Field", K = (e, n, r, i) => {
47
- let a = r ? t(r.dataItem) : void 0;
48
- return {
49
- type: "native",
50
- key: `${W}-interaction`,
51
- events: { click(t) {
52
- let o = this.element.getBoundingClientRect(), c = {
53
- x: t.clientX - o.left,
54
- y: t.clientY - o.top
55
- }, l = this.chart.shapesAt(c, {
56
- components: [{
57
- key: W,
58
- propagation: "stop"
59
- }],
60
- propagation: "stop"
61
- }).find((e) => e.data?.target === "measure" || e.data?.target === "dimension");
62
- if (l?.data?.target === "measure" && r && a) {
63
- i(k.Text, "click", `text-${a}`, t, l, {
64
- dataItemType: s.Measure,
65
- dataItemRole: r.role
66
- });
67
- return;
68
- }
69
- l?.data?.target === "dimension" && e && i(k.Text, "click", `text-${e}`, t, l, {
70
- dataItemType: s.Dimension,
71
- dataItemRole: n
72
- });
73
- } }
74
- };
75
- }, ce = (e, i, a, o, l, u, f, p) => {
76
- let m = c(e.dimensions, e.enableAlternate, u?.isPrintMode), h = e.dimensions.filter((e) => r(e)), g = h[0], _ = g ? t(g.dataItem) : void 0, v = e.measures.filter((e) => e.role === d.PIE_CHART_SLICE), y = c(v, e.enableAlternate, u?.isPrintMode), b = v.filter((e) => r(e))[0], x = m && h.length ? h.map((e) => G(e)).join(", ") : void 0, S = y && b ? G(b) : void 0;
77
- if (!x && !S) return a;
78
- let C = {
79
- type: U,
80
- key: W,
81
- dimensionDataItemType: _ ? s.Dimension : void 0,
82
- dimensionDataItemRole: g?.role,
83
- measureDataItemType: b ? s.Measure : void 0,
84
- measureDataItemRole: b?.role,
85
- layout: {
86
- dock: n.Bottom,
87
- displayOrder: 0
88
- },
89
- settings: {
90
- dimensionLabel: x ? E(x) : void 0,
91
- measureLabel: S ? E(S) : void 0,
92
- fontFamily: i.fonts.general.fontFamily ?? void 0,
93
- fontSize: `${A.fieldTitle.fontSize}px`,
94
- color: i.fonts.general.color,
95
- paddingLeft: 5,
96
- paddingRight: 5,
97
- paddingVertical: 5,
98
- labelGap: 12
99
- }
100
- }, w = p ? [K(_, g?.role, b, p)] : [];
101
- return {
102
- ...a,
103
- components: [...a.components, C],
104
- interactions: a.interactions ? [...a.interactions, ...w] : w
105
- };
106
- }, q = {
107
- outerRadius: .8,
108
- outerRadiusWithoutLabels: .95,
109
- cornerRadius: _.pie,
110
- strokeWidth: 0,
111
- strokeEnabled: !1,
112
- strokeColor: "#C6C6C6",
113
- multiMeasureMinRadius: .3,
114
- donut: {
115
- innerRadius: .55,
116
- cornerRadius: _.donut,
117
- multiMeasureMinRadius: .6
118
- }
119
- };
120
- function J(e) {
121
- return e.pieSettings?.donut ?? !1;
122
- }
123
- var le = (e, n, i, a, o, s) => {
124
- let c = e.measures.filter((e) => r(e)), l = c.filter((e) => e.role === d.PIE_CHART_SLICE), u = c.filter((e) => e.role === d.PIE_CHART_LENGTH), f = l[0], p = u[0], m = new L(e, n, o?.[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 n = g, r = J(e) ? q.donut.multiMeasureMinRadius : q.multiMeasureMinRadius;
127
- g = (e) => e.resources.scale(t(p.dataItem))(e.datum.rad.value) * (n - r) + r;
128
- }
129
- let x = {
130
- type: k.Pie,
131
- key: `${k.Pie}`,
132
- data: { collection: j.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: S([""], s, { valuePickerMode: s?.valuePickerMode })
147
- };
148
- return {
149
- ...i,
150
- components: [...i.components, x]
151
- };
152
- }, ue = (e, t, n) => ({ data: i, formatter: a }) => {
153
- let o = e.dimensions.filter((e) => r(e))[0], s = i.value, c = i[V.num].value, l = o.formatter && s && a ? a(o.formatter)(s) : `${s}`, u = t.formatter && c && a ? a(t.formatter)(c, void 0, i) : `${c}`, d = c != null && n && a ? a(te)(c / n) : null, f = () => t.dataLabels?.measureLabelFormat === v.Percentage ? d === null ? [] : [d] : t.dataLabels?.measureLabelFormat === v.ValueAndPercentage ? d === null ? [u] : [u, d] : [u];
154
- switch (t.dataLabels?.labelFormat) {
155
- case y.Measure: {
156
- let e = f();
157
- return e.length <= 1 ? e[0] ?? null : e;
158
- }
159
- case y.DimensionAndMeasure: return [l, ...f()];
160
- default: return l;
161
- }
162
- }, de = (e, t, n, i, a, o) => {
163
- let s = e.dimensions.filter((e) => r(e)), c = e.measures.filter((e) => r(e)), l = s[0], u = c.find((e) => e.role === d.PIE_CHART_SLICE) ?? c[0];
164
- if (!l || !u || !u.dataLabels?.show) return n;
165
- let f = new I(t.fonts.general.color), p = u.dataLabels.showBackdrop ? O(u.dataLabels.backdropColor ? { fill: u.dataLabels.backdropColor } : void 0) : void 0, m = p ? P(f) : u.dataLabels.textColor || "#000", { strokeEnabled: h, strokeWidth: g = q.strokeWidth } = e.pieSettings, _ = h ? g / 2 : 0, v = {
166
- type: k.Labels,
167
- key: "pie-labels",
168
- animations: {
169
- enabled: !0,
170
- presetId: "chart-labels"
171
- },
172
- layout: { displayOrder: ee.Labels },
173
- settings: { sources: [{
174
- component: `${k.Pie}`,
175
- selector: ne.Path,
176
- strategy: {
177
- type: "slice",
178
- settings: {
179
- fontSize: oe(u.dataLabels.size),
180
- fontFamily: t.fonts.general.fontFamily,
181
- labels: [{
182
- label: ue(e, u, a?.[0]?.sum),
183
- placements: [{
184
- position: "outside",
185
- fill: m,
186
- backdrop: p
187
- }],
188
- strokeDelta: _,
189
- linkData: ({ data: e }) => e
190
- }]
191
- }
192
- }
193
- }] },
194
- brush: S([""], o, { valuePickerMode: o?.valuePickerMode })
195
- };
196
- return {
197
- ...n,
198
- components: [...n.components, v]
199
- };
200
- }, Y = (e, t, n, r, i) => {
201
- let a = n.data[t]?.value, s = o(e) || e.label || e.dataItem.name || "", c = a;
202
- return !i && e.formatter ? c = r.formatter(e.formatter)(a, void 0, n.data) : i && (c = r.formatter(se(e.formatter))(a, void 0, n.data)), {
203
- label: s,
204
- value: c
205
- };
206
- }, fe = (e, t, n, i, a) => {
207
- let o = !!e.measures.filter(r).filter((e) => e.role === d.PIE_CHART_LENGTH)?.[0], s = {
208
- filter: (e) => e.filter((e) => e.key === k.Pie),
209
- placement: {
210
- type: "slice",
211
- area: "target"
212
- }
213
- };
214
- if (o) return x(e, t, n, s, "tooltip", a);
215
- let c = b(e, a), l = C(e, t, pe, F, a?.[0]?.sum, c);
216
- return x(e, t, n, {
217
- ...s,
218
- extract: l
219
- }, "tooltip", a);
220
- }, pe = (e, n, i, a, o, s, c, l) => {
221
- let u = [], d = e.filter(r), f = T(i), p = d.filter((e) => !f.has(t(e.dataItem)))?.[0] ?? d?.[0], m = Object.keys(n.data).find((e) => n.data[e]?.source?.field === t(p?.dataItem));
222
- if (!m || !p ? u.push({
223
- label: "",
224
- value: ""
225
- }) : u.push(Y(p, m, n, i, l)), d.filter((e) => f.has(t(e.dataItem))).forEach((e) => {
226
- let r = t(e.dataItem), a = Object.keys(n.data).find((e) => n.data[e]?.source?.field === r);
227
- a && u.push(Y(e, a, n, i, l));
228
- }), c) return u;
229
- let h = Object.values(s ?? {}).reduce((e, t) => e + Number(t), 0);
230
- return u.push({
231
- label: "Total",
232
- value: p?.formatter ? i.formatter(p.formatter)(h) : h
233
- }), u;
234
- }, me = class extends D {
235
- constructor() {
236
- super([
237
- H,
238
- B,
239
- le,
240
- ce,
241
- de,
242
- N,
243
- fe
244
- ]);
245
- }
246
- preCompile(e) {
247
- let t = e.dimensions.filter((e) => r(e))?.[0], n = e.measures.filter((e) => r(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, he = (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
- }, ge = {
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 ? he(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) {
333
- e.component(U, ge);
334
- }
335
- var _e = (e, n) => {
336
- let i = e.find((e) => e.role === d.PIE_CHART_SLICE && r(e));
337
- if (!i) return;
338
- let a = t(i.dataItem);
339
- return n.reduce((e, t) => e + t[a], 0);
340
- }, ve = g(), ye = m(({ vSpec: e, vTheme: t, data: n, elementSize: r, vizProperties: o }) => {
341
- let s = f(), [c] = (0, z.useState)(() => new me()), { activeKey: u } = h(), d = ae();
342
- if (!e || !a(e) || !n || !r) return null;
343
- let p = {
344
- ...o,
345
- valuePickerMode: !!u
346
- }, m = t || l;
347
- n[0] && (n[0].sum = _e(e.measures, n[0].items));
348
- let g = c.compile(e, m, n, r, p, i.Pie, s, void 0, d);
349
- return g ? /* @__PURE__ */ (0, ve.jsx)(re, {
350
- config: p,
351
- definition: g,
352
- size: r,
353
- vSpec: e,
354
- escobarPlugins: [$]
355
- }) : null;
356
- });
357
- export { ye as PieChart };