@astrato-io/visualizations 0.6.4 → 0.7.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 (220) hide show
  1. package/CHANGELOG.md +0 -0
  2. package/README.md +32 -2
  3. package/THIRD_PARTY_NOTICES.md +68 -205
  4. package/VISUALIZATION_DEFINITIONS.md +68 -114
  5. package/chunks/Button-BrGKp9Nm.js +110 -0
  6. package/chunks/DefaultPropsProvider-BsfB7QTn.js +257 -0
  7. package/chunks/FieldTypeIcon-Drs6hSJF.js +22 -0
  8. package/chunks/{LinearProgress-CUZ0D8_t.js → LinearProgress-VtfFx2vJ.js} +51 -51
  9. package/chunks/MenuOption-ByRqhRdX.js +3934 -0
  10. package/chunks/Title-CO5dP1ma.js +1691 -0
  11. package/chunks/ToggleButton-KOBAimC1.js +112 -0
  12. package/chunks/app-filter-bar.compiler-TwVTeoj5.js +64 -0
  13. package/chunks/bar.compiler-DuQg8EUb.js +374 -0
  14. package/chunks/builder-DEDvNq1k.js +201 -0
  15. package/chunks/{color-settings-ZIvgNTq1.js → color-rules-CN7TcGrC.js} +2 -6
  16. package/chunks/color-settings-3VRlf_Vw.js +6 -0
  17. package/chunks/colorManipulator-D8Pjy1pf.js +45 -0
  18. package/chunks/coloring-CncX_JRX.js +278 -0
  19. package/chunks/{src-BC7cGcJ-.js → definitions-BPJQTx16.js} +650 -464
  20. package/chunks/{escobar-BGqT1EsE.js → escobar-DRhRMYRE.js} +6282 -4931
  21. package/chunks/event-bus-CrLB-Y8z.js +3 -0
  22. package/chunks/extend-preset-CUFNpmPe.js +4398 -0
  23. package/chunks/filter.compiler-w27dlv0C.js +70 -0
  24. package/chunks/filtering-cc7WqWpg.js +1153 -0
  25. package/chunks/handlers-TOT-7INo.js +12871 -0
  26. package/chunks/icon-picker-styles-CoJmwTRi.js +2246 -0
  27. package/chunks/isEqual-B8loyPsC.js +12 -0
  28. package/chunks/label-format-type-weq1XfcX.js +8 -0
  29. package/chunks/line.compiler-Ct1WhN2p.js +198 -0
  30. package/chunks/logger-DpQtYQnX.js +1163 -0
  31. package/chunks/lookup-BWllin0q.js +36 -0
  32. package/chunks/{metadata-CPXdYoln.js → metadata-WABZrt7Y.js} +1 -1
  33. package/chunks/number.compiler-D8TPly-4.js +53 -0
  34. package/chunks/{src-C0LgoUWY.js → operations-Dh4v1Ovt.js} +7716 -7541
  35. package/chunks/{range-DrzdfBX4.js → range-Bi-7zT0k.js} +2 -2
  36. package/chunks/registry-KervaxqJ.js +31 -0
  37. package/chunks/render-wrappers-OEmtaM8g.js +2 -0
  38. package/chunks/{registry-CExpGJ1N.js → requirements-PAoRaJyb.js} +294 -326
  39. package/chunks/responsive.styles-DSiOGD7u.js +82 -0
  40. package/chunks/shared-Bn4N5QcZ.js +1218 -0
  41. package/chunks/src-77e3mC7i.js +391 -0
  42. package/chunks/standalone-B55oyW6c.js +689 -0
  43. package/chunks/{standalone-CY57qwZ-.js → standalone-BDhPQtzQ.js} +386 -352
  44. package/chunks/{standalone-BDCwI6Hn.js → standalone-BGkmozIb.js} +1108 -953
  45. package/chunks/standalone-BMTCb10X.js +179 -0
  46. package/chunks/standalone-BXKRE_Se.js +468 -0
  47. package/chunks/standalone-Bes8srx1.js +354 -0
  48. package/chunks/standalone-BjZp0QMe.js +2 -0
  49. package/chunks/{standalone-BH5NqDwp.js → standalone-BlMIwpEe.js} +687 -573
  50. package/chunks/{standalone-CCNtaJ7s.js → standalone-C8ZAEutO.js} +44 -43
  51. package/chunks/standalone-C8qAelL4.js +2 -0
  52. package/chunks/standalone-CJvIXsQE.js +743 -0
  53. package/chunks/standalone-CLmGb7nn2.js +355 -0
  54. package/chunks/{ui-D1HQNIBy.js → standalone-CM5XcAN5.js} +15946 -17658
  55. package/chunks/standalone-CXNP6-xD.js +420 -0
  56. package/chunks/{standalone-BYm1UjLr.js → standalone-D5Q5ngsD.js} +59 -57
  57. package/chunks/standalone-DLlyRIE6.js +287 -0
  58. package/chunks/standalone-DMcI1afI.js +396 -0
  59. package/chunks/{standalone-jiz0L2Dg.js → standalone-DN4S1MjT.js} +1113 -1094
  60. package/chunks/{standalone-QJ1kKMnO.js → standalone-DT0wKji7.js} +2 -2
  61. package/chunks/{standalone-D5vnf-9y.js → standalone-DVTJwsTY.js} +1110 -1035
  62. package/chunks/standalone-DW6NT205.js +518 -0
  63. package/chunks/standalone-DYQIQH4c.js +2095 -0
  64. package/chunks/standalone-D__XCp-h.js +1003 -0
  65. package/chunks/standalone-XTgSsTAa.js +354 -0
  66. package/chunks/standalone-XuGksArp.js +68 -0
  67. package/chunks/{standalone-CNyNHKVx.js → standalone-we5D5MIn.js} +176 -172
  68. package/chunks/table.compiler-DMeeHxb6.js +222 -0
  69. package/chunks/useFieldName-Cjn9KCVp.js +7 -0
  70. package/chunks/useSlotProps-DLbQp4lc.js +166 -0
  71. package/chunks/{utils-Ba9T0TqC.js → utils-vdmi_2PK.js} +6266 -6517
  72. package/chunks/{src-DvX5LU9T.js → view-BuwQugKb.js} +2893 -5956
  73. package/chunks/visualization-filters-Cc4KU-l-.js +7455 -0
  74. package/chunks/web-components-DqClFkgO.js +1185 -0
  75. package/chunks/with-html-element-D0uY2zjI.js +7328 -0
  76. package/definitions.js +3 -3
  77. package/docs/operations/astrato-app-filter-bar.md +17 -17
  78. package/docs/operations/bar.md +1006 -1071
  79. package/docs/operations/combo.md +717 -738
  80. package/docs/operations/date-picker.md +27 -27
  81. package/docs/operations/distribution-gauge.md +471 -607
  82. package/docs/operations/dot.md +787 -879
  83. package/docs/operations/filter.md +139 -163
  84. package/docs/operations/gauge.md +491 -627
  85. package/docs/operations/heatMap.md +834 -916
  86. package/docs/operations/histogram.md +166 -180
  87. package/docs/operations/iframe.md +5 -5
  88. package/docs/operations/image.md +16 -16
  89. package/docs/operations/index.md +12 -12
  90. package/docs/operations/line.md +811 -888
  91. package/docs/operations/number.md +470 -536
  92. package/docs/operations/pie.md +825 -958
  93. package/docs/operations/radar.md +599 -679
  94. package/docs/operations/sankey.md +462 -584
  95. package/docs/operations/scatter.md +823 -929
  96. package/docs/operations/shape.md +34 -34
  97. package/docs/operations/simpleTextObject.md +18 -25
  98. package/docs/operations/slider.md +33 -43
  99. package/docs/operations/table.md +1177 -1150
  100. package/docs/operations/tree.md +404 -397
  101. package/docs/operations/treemap.md +595 -673
  102. package/docs/operations/waterfall.md +369 -379
  103. package/docs/operations/word-cloud.md +512 -583
  104. package/getters.js +7 -7
  105. package/index.js +3 -1183
  106. package/metadata.js +18 -18
  107. package/operations.js +13 -13
  108. package/package.json +133 -88
  109. package/render.js +10 -0
  110. package/src/charts/bar.d.ts +1 -0
  111. package/src/charts/combo.d.ts +1 -0
  112. package/src/charts/dot.d.ts +1 -0
  113. package/src/charts/gauge-distribution.d.ts +1 -0
  114. package/src/charts/gauge.d.ts +1 -0
  115. package/src/charts/heat-map.d.ts +1 -0
  116. package/src/charts/histogram.d.ts +1 -0
  117. package/src/charts/line.d.ts +1 -0
  118. package/src/charts/pie.d.ts +1 -0
  119. package/src/charts/radar.d.ts +1 -0
  120. package/src/charts/sankey.d.ts +1 -0
  121. package/src/charts/scatter.d.ts +1 -0
  122. package/src/charts/table.d.ts +1 -0
  123. package/src/charts/tree.d.ts +1 -0
  124. package/src/charts/treemap.d.ts +1 -0
  125. package/src/charts/waterfall.d.ts +1 -0
  126. package/src/charts/word-cloud.d.ts +1 -0
  127. package/src/definitions/index.d.ts +2 -2
  128. package/src/definitions/{shared/lib → model/definitions}/available-fields.d.ts +0 -1
  129. package/src/definitions/{shared/lib/compilers/index.d.ts → model/definitions/compilers/compile.d.ts} +1 -1
  130. package/src/definitions/model/definitions/data-item-resolution.d.ts +19 -0
  131. package/src/definitions/model/definitions/descriptors/descriptor-metadata.d.ts +1364 -0
  132. package/src/definitions/model/definitions/descriptors/json-schema.d.ts +2 -0
  133. package/src/definitions/model/definitions/diagnostics.d.ts +5 -0
  134. package/src/definitions/model/definitions/field-suggestions.d.ts +2 -0
  135. package/src/definitions/model/definitions/index.d.ts +23 -0
  136. package/src/definitions/{shared/lib → model/definitions}/registry/compile.d.ts +1 -1
  137. package/src/definitions/model/definitions/registry/descriptor-registry.d.ts +3 -0
  138. package/src/definitions/model/definitions/schema-registry.d.ts +660 -0
  139. package/src/definitions/{shared/lib → model/definitions}/schemas/broad-chart.schema.d.ts +1 -1
  140. package/src/definitions/{shared/lib → model/definitions}/schemas/common.schema.d.ts +0 -1
  141. package/src/definitions/model/definitions/schemas/index.d.ts +9 -0
  142. package/src/definitions/{shared/lib → model/definitions}/schemas/object.schema.d.ts +8 -8
  143. package/src/definitions/{shared/lib → model/definitions}/types/compilation.types.d.ts +10 -0
  144. package/src/definitions/{shared/lib → model/definitions}/types/definition.types.d.ts +1 -1
  145. package/src/definitions/model/definitions/types/index.d.ts +3 -0
  146. package/src/definitions/{shared/lib/registry → model/definitions}/validation.d.ts +1 -1
  147. package/src/getters/index.d.ts +3 -3
  148. package/src/index.d.ts +1 -1
  149. package/src/objects/app-filter-bar.d.ts +1 -0
  150. package/src/objects/date-picker.d.ts +1 -0
  151. package/src/objects/filter.d.ts +1 -0
  152. package/src/objects/iframe.d.ts +1 -0
  153. package/src/objects/image.d.ts +1 -0
  154. package/src/objects/number.d.ts +1 -0
  155. package/src/objects/shape.d.ts +1 -0
  156. package/src/objects/slider.d.ts +1 -0
  157. package/src/objects/text.d.ts +1 -0
  158. package/src/operations/index.d.ts +3 -3
  159. package/src/registry/create-visualization-registry.d.ts +5 -0
  160. package/src/render/index.d.ts +34 -0
  161. package/src/runtime/index.d.ts +2 -2
  162. package/src/types.d.ts +9 -4
  163. package/src/web-components/index.d.ts +3 -3
  164. package/chunks/Radio-Ciu-F4CU.js +0 -957
  165. package/chunks/ToggleButton-BCJc3Jlc.js +0 -153
  166. package/chunks/_baseFlatten-DPXPOrea.js +0 -7076
  167. package/chunks/app-filter-bar.compiler-j_CVoWTa.js +0 -55
  168. package/chunks/bar.compiler-oqaPzIut.js +0 -370
  169. package/chunks/coloring-C16AUZEi.js +0 -663
  170. package/chunks/data-item-resolution-1lvYB5ln.js +0 -53
  171. package/chunks/event-bus-KiSiCJrC.js +0 -2683
  172. package/chunks/events-WZut5Ow6.js +0 -4
  173. package/chunks/filter.compiler-CuLtc_02.js +0 -60
  174. package/chunks/filtering-Yq4DEa0t.js +0 -953
  175. package/chunks/gauge-target-type-BkKXAqkX.js +0 -4
  176. package/chunks/grouping-type-BX_9Ix5q.js +0 -3
  177. package/chunks/interfaces-VUY4_yVO.js +0 -8742
  178. package/chunks/line-settings-DfYTUyPz.js +0 -4
  179. package/chunks/line.compiler-BpA_6Tc7.js +0 -188
  180. package/chunks/number.compiler-DbkWcG4S.js +0 -44
  181. package/chunks/pie-uv42Eqal.js +0 -10
  182. package/chunks/requirements-DNhuShLS.js +0 -6
  183. package/chunks/shared-CKDL4hx9.js +0 -1171
  184. package/chunks/src-Cum_2NLV.js +0 -12145
  185. package/chunks/src-Dun_jXtz.js +0 -10295
  186. package/chunks/standalone-87YV_m9n.js +0 -687
  187. package/chunks/standalone-BLVAWLNJ.js +0 -385
  188. package/chunks/standalone-BPomtAVs.js +0 -2
  189. package/chunks/standalone-BXyBcUOQ.js +0 -2
  190. package/chunks/standalone-BllF4rDp.js +0 -383
  191. package/chunks/standalone-BmfMt74U.js +0 -726
  192. package/chunks/standalone-BqWyrnZI.js +0 -281
  193. package/chunks/standalone-C85u7U6I.js +0 -340
  194. package/chunks/standalone-CDQnr6qT.js +0 -345
  195. package/chunks/standalone-CZynjFG7.js +0 -12979
  196. package/chunks/standalone-DFPva_ku.js +0 -299
  197. package/chunks/standalone-DQxxNwF8.js +0 -675
  198. package/chunks/standalone-DS9T0FZ-.js +0 -830
  199. package/chunks/standalone-Dx3MLlrO.js +0 -512
  200. package/chunks/standalone-DzixzZAL.js +0 -411
  201. package/chunks/standalone-lBm9hQ-q.js +0 -179
  202. package/chunks/standalone-rJ45Zfl1.js +0 -68
  203. package/chunks/table.compiler-BrXkm4Fz.js +0 -213
  204. package/chunks/toInteger-DVZr-D1j.js +0 -11
  205. package/chunks/treemap-x_zmJoG7.js +0 -23
  206. package/chunks/types-dVVCsDWD.js +0 -4
  207. package/chunks/useFieldName-oqQ3bvnO.js +0 -7
  208. package/chunks/view-CLqWMV7Z.js +0 -156
  209. package/src/definitions/shared/index.d.ts +0 -5
  210. package/src/definitions/shared/lib/registry/descriptor-registry.d.ts +0 -587
  211. package/src/definitions/shared/lib/registry/index.d.ts +0 -3
  212. package/src/definitions/shared/lib/schemas/index.d.ts +0 -9
  213. package/src/definitions/shared/lib/types/index.d.ts +0 -3
  214. package/src/definitions/{shared/lib → model/definitions}/schemas/app-filter-bar.schema.d.ts +0 -0
  215. package/src/definitions/{shared/lib → model/definitions}/schemas/bar.schema.d.ts +0 -0
  216. package/src/definitions/{shared/lib → model/definitions}/schemas/filter.schema.d.ts +0 -0
  217. package/src/definitions/{shared/lib → model/definitions}/schemas/line.schema.d.ts +0 -0
  218. package/src/definitions/{shared/lib → model/definitions}/schemas/number.schema.d.ts +0 -0
  219. package/src/definitions/{shared/lib → model/definitions}/schemas/table.schema.d.ts +4 -4
  220. /package/src/definitions/{shared/lib → model/definitions}/types/descriptor.types.d.ts +0 -0
@@ -1,345 +0,0 @@
1
- import { o as e } from "./rolldown-runtime-DleVn1XH.js";
2
- import { La as t, No as n, Ta as r, Ti as i, Wc as a, Xs as o, Yn as s, pc as c, qs as l, ti as u } from "./interfaces-VUY4_yVO.js";
3
- import { Ki as d, P as f, Zt as p, o as m, wi as h } from "./utils-Ba9T0TqC.js";
4
- import { Bn as g, Vn as _ } from "./event-bus-KiSiCJrC.js";
5
- import { n as v } from "./pie-uv42Eqal.js";
6
- import { F as y, Ft as b, Jt as x, M as S, P as C, Q as w, Qt as T, St as E, Vt as D, Wt as O, X as k, Z as A, _t as j, et as M, ht as ee, i as te, it as ne, j as re, n as ie, nn as ae, rt as oe, tt as N, un as P } from "./escobar-BGqT1EsE.js";
7
- import { l as F, vt as I } from "./_baseFlatten-DPXPOrea.js";
8
- import { t as L } from "./coloring-C16AUZEi.js";
9
- import { t as R } from "./set-coloring-datafield-B3uIS1Pe.js";
10
- var z = /* @__PURE__ */ e(d()), B = (e, n, r) => {
11
- let { coloring: a } = e || {}, s = a?.fieldId, l = e.dimensions.filter((e) => i(e)), u = e.measures.filter((e) => i(e)), d = u.filter((e) => e.role === t.PIE_CHART_SLICE), f = u.filter((e) => e.role === t.PIE_CHART_LENGTH);
12
- s || (e.coloring?.type === o.Gradient ? s = c(d[0]?.dataItem) : e.coloring?.type === o.Categorical && (s = c(l[0]?.dataItem))), ee(r, 0, { color: { field: s } });
13
- let p = E(R(e, s), n, {});
14
- if (f.length > 0) {
15
- let e = c(f[0]?.dataItem);
16
- p[e] = { data: { field: e } };
17
- }
18
- return {
19
- ...r,
20
- scales: p
21
- };
22
- }, V = /* @__PURE__ */ function(e) {
23
- return e.num = "num", e.rad = "rad", e.group = "group", e;
24
- }({}), H = (e, n, r) => {
25
- if (!e.dimensions[0]) return r;
26
- let a = e.measures.filter((e) => i(e)), o = S((e.supportingMeasures ?? []).filter((e) => i(e))), s = e.dimensions.filter((e) => i(e))?.[0], l = a.filter((e) => e.role === t.PIE_CHART_SLICE)?.[0], u = a.filter((e) => e.role === t.PIE_CHART_LENGTH)?.[0], d = c(l?.dataItem), f = c(u?.dataItem), p = c(s?.dataItem), m = [{
27
- key: T.Collection,
28
- data: { extract: [{
29
- field: p,
30
- props: {
31
- num: l?.dataItem?.name ? { field: d } : void 0,
32
- rad: u?.dataItem?.name ? { field: f } : void 0,
33
- ...o
34
- }
35
- }] }
36
- }];
37
- return d && (m[0].data.extract[0].props[d] = { field: d }), f && (m[0].data.extract[0].props[f] = { field: f }), {
38
- ...r,
39
- collections: m
40
- };
41
- }, U = "pie-alternates-switcher", W = "pie-alternates-switcher", G = (e) => s(e) || e.label || e.dataItem?.name || "Field", K = (e, t, n, r) => {
42
- let i = n ? c(n.dataItem) : void 0;
43
- return {
44
- type: "native",
45
- key: `${W}-interaction`,
46
- events: { click(o) {
47
- let s = this.element.getBoundingClientRect(), c = {
48
- x: o.clientX - s.left,
49
- y: o.clientY - s.top
50
- }, l = this.chart.shapesAt(c, {
51
- components: [{
52
- key: W,
53
- propagation: "stop"
54
- }],
55
- propagation: "stop"
56
- }).find((e) => e.data?.target === "measure" || e.data?.target === "dimension");
57
- if (l?.data?.target === "measure" && n && i) {
58
- r(P.Text, "click", `text-${i}`, o, l, {
59
- dataItemType: a.Measure,
60
- dataItemRole: n.role
61
- });
62
- return;
63
- }
64
- l?.data?.target === "dimension" && e && r(P.Text, "click", `text-${e}`, o, l, {
65
- dataItemType: a.Dimension,
66
- dataItemRole: t
67
- });
68
- } }
69
- };
70
- }, se = (e, r, o, s, l, d, f, p) => {
71
- let m = u(e.dimensions, e.enableAlternate, d?.isPrintMode), h = e.dimensions.filter((e) => i(e)), g = h[0], _ = g ? c(g.dataItem) : void 0, v = e.measures.filter((e) => e.role === t.PIE_CHART_SLICE), y = u(v, e.enableAlternate, d?.isPrintMode), b = v.filter((e) => i(e))[0], x = m && h.length ? h.map((e) => G(e)).join(", ") : void 0, S = y && b ? G(b) : void 0;
72
- if (!x && !S) return o;
73
- let C = {
74
- type: U,
75
- key: W,
76
- dimensionDataItemType: _ ? a.Dimension : void 0,
77
- dimensionDataItemRole: g?.role,
78
- measureDataItemType: b ? a.Measure : void 0,
79
- measureDataItemRole: b?.role,
80
- layout: {
81
- dock: n.Bottom,
82
- displayOrder: 0
83
- },
84
- settings: {
85
- dimensionLabel: x ? D(x) : void 0,
86
- measureLabel: S ? D(S) : void 0,
87
- fontFamily: r.fonts.general.fontFamily,
88
- fontSize: `${I.fieldTitle.fontSize}px`,
89
- color: r.fonts.general.color,
90
- paddingLeft: 5,
91
- paddingRight: 5,
92
- paddingVertical: 5,
93
- labelGap: 12
94
- }
95
- }, w = p ? [K(_, g?.role, b, p)] : [];
96
- return {
97
- ...o,
98
- components: [...o.components, C],
99
- interactions: o.interactions ? [...o.interactions, ...w] : w
100
- };
101
- }, q = {
102
- outerRadius: .8,
103
- outerRadiusWithoutLabels: .95,
104
- cornerRadius: v.pie,
105
- strokeWidth: 0,
106
- strokeEnabled: !1,
107
- strokeColor: "#C6C6C6",
108
- multiMeasureMinRadius: .3,
109
- donut: {
110
- innerRadius: .55,
111
- cornerRadius: v.donut,
112
- multiMeasureMinRadius: .6
113
- }
114
- };
115
- function J(e) {
116
- return e.pieSettings?.donut ?? !1;
117
- }
118
- var ce = (e, n, r, a, o, s) => {
119
- let l = e.measures.filter((e) => i(e)), u = l.filter((e) => e.role === t.PIE_CHART_SLICE), d = l.filter((e) => e.role === t.PIE_CHART_LENGTH), f = u[0], p = d[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;
120
- if (p) {
121
- let t = g, n = J(e) ? q.donut.multiMeasureMinRadius : q.multiMeasureMinRadius;
122
- g = (e) => e.resources.scale(c(p.dataItem))(e.datum.rad.value) * (t - n) + n;
123
- }
124
- let x = {
125
- type: P.Pie,
126
- key: `${P.Pie}`,
127
- data: { collection: T.Collection },
128
- animations: {
129
- enabled: !0,
130
- presetId: "pie-chart"
131
- },
132
- settings: { slice: {
133
- arc: { ref: "num" },
134
- stroke: b,
135
- strokeWidth: v ? y : 0,
136
- cornerRadius: _,
137
- innerRadius: h,
138
- outerRadius: g,
139
- fill: m.getColorDefinition({ ref: "color" })
140
- } },
141
- brush: O([""], s, { valuePickerMode: s?.valuePickerMode })
142
- };
143
- return {
144
- ...r,
145
- components: [...r.components, x]
146
- };
147
- }, le = (e, t, n) => ({ data: r, formatter: a }) => {
148
- let o = e.dimensions.filter((e) => i(e))[0], s = r.value, c = r[V.num].value, l = o.formatter && s && a ? a(o.formatter)(s) : `${s}`, u = t.formatter && c && a ? a(t.formatter)(c, void 0, r) : `${c}`, d = c != null && n && a ? a(ne)(c / n) : null, f = () => t.dataLabels?.measureLabelFormat === g.Percentage ? [d] : t.dataLabels?.measureLabelFormat === g.ValueAndPercentage ? [u, d] : [u];
149
- switch (t.dataLabels?.labelFormat) {
150
- case _.Measure: {
151
- let e = f();
152
- return e.length === 1 ? e[0] : e;
153
- }
154
- case _.DimensionAndMeasure: return [l, ...f()];
155
- default: return l;
156
- }
157
- }, ue = (e, n, r, a, o, s) => {
158
- let c = e.dimensions.filter((e) => i(e)), l = e.measures.filter((e) => i(e)), u = c[0], d = l.find((e) => e.role === t.PIE_CHART_SLICE) ?? l[0];
159
- if (!u || !d || !d.dataLabels?.show) return r;
160
- let f = new F(n.fonts.general.color), p = d.dataLabels.showBackdrop ? C(d.dataLabels.backdropColor ? { fill: d.dataLabels.backdropColor } : void 0) : void 0, m = p ? y(f) : d.dataLabels.textColor || "#000", { strokeEnabled: h, strokeWidth: g = q.strokeWidth } = e.pieSettings, _ = h ? g / 2 : 0, v = {
161
- type: P.Labels,
162
- key: "pie-labels",
163
- animations: {
164
- enabled: !0,
165
- presetId: "chart-labels"
166
- },
167
- layout: { displayOrder: b.Labels },
168
- settings: { sources: [{
169
- component: `${P.Pie}`,
170
- selector: ae.Path,
171
- strategy: {
172
- type: "slice",
173
- settings: {
174
- fontSize: x(d.dataLabels.size),
175
- fontFamily: n.fonts.general.fontFamily,
176
- labels: [{
177
- label: le(e, d, o[0].sum),
178
- placements: [{
179
- position: "outside",
180
- fill: m,
181
- backdrop: p
182
- }],
183
- strokeDelta: _,
184
- linkData: ({ data: e }) => e
185
- }]
186
- }
187
- }
188
- }] },
189
- brush: O([""], s, { valuePickerMode: s?.valuePickerMode })
190
- };
191
- return {
192
- ...r,
193
- components: [...r.components, v]
194
- };
195
- }, Y = (e, t, n, r, i) => {
196
- let a = n.data[t]?.value, o = s(e) || e.label || e.dataItem.name || "", c = a;
197
- return !i && e.formatter ? c = r.formatter(e.formatter)(a, void 0, n.data) : i && (c = r.formatter(oe(e.formatter))(a, void 0, n.data)), {
198
- label: o,
199
- value: c
200
- };
201
- }, de = (e, n, r, a, o) => {
202
- let s = !!e.measures.filter(i).filter((e) => e.role === t.PIE_CHART_LENGTH)?.[0], c = {
203
- filter: (e) => e.filter((e) => e.key === P.Pie),
204
- placement: {
205
- type: "slice",
206
- area: "target"
207
- }
208
- };
209
- if (s) return k(e, n, r, c, "tooltip", o);
210
- let l = N(e, o), u = A(e, n, fe, w, o?.[0]?.sum, l);
211
- return k(e, n, r, {
212
- ...c,
213
- extract: u
214
- }, "tooltip", o);
215
- }, fe = (e, t, n, r, a, o, s, l) => {
216
- let u = [], d = e.filter(i), f = M(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));
217
- if (!m || !p ? u.push({
218
- label: "",
219
- value: ""
220
- }) : u.push(Y(p, m, t, n, l)), d.filter((e) => f.has(c(e.dataItem))).forEach((e) => {
221
- let r = c(e.dataItem), i = Object.keys(t.data).find((e) => t.data[e]?.source?.field === r);
222
- i && u.push(Y(e, i, t, n, l));
223
- }), s) return u;
224
- let h = Object.values(o ?? {}).reduce((e, t) => e + Number(t), 0);
225
- return u.push({
226
- label: "Total",
227
- value: p?.formatter ? n.formatter(p.formatter)(h) : h
228
- }), u;
229
- }, pe = class extends re {
230
- constructor() {
231
- super([
232
- H,
233
- B,
234
- ce,
235
- se,
236
- ue,
237
- j,
238
- de
239
- ]);
240
- }
241
- preCompile(e) {
242
- let t = e.dimensions.filter((e) => i(e))?.[0], n = e.measures.filter((e) => i(e))?.[0];
243
- if (!t || !n) throw Error("Charts w/o dimensions or measures are not supported ATM.");
244
- }
245
- }, X = " ▼", Z = "...", Q = (e, t, n, r) => e.measureText({
246
- text: t,
247
- fontFamily: n,
248
- fontSize: r
249
- }).width, $ = (e, t, n, r, i) => {
250
- if (t <= 0 || Q(n, e, r, i) <= t) return e;
251
- let a = e.endsWith(X), o = a ? X : "", s = a ? e.slice(0, -2) : e;
252
- if (Q(n, `${Z}${o}`, r, i) > t) return Z;
253
- let c = 0, l = s.length;
254
- for (; c < l;) {
255
- let e = Math.ceil((c + l) / 2);
256
- Q(n, `${s.slice(0, e)}${Z}${o}`, r, i) <= t ? c = e : l = e - 1;
257
- }
258
- return `${s.slice(0, c)}${Z}${o}`;
259
- }, me = {
260
- require: ["renderer"],
261
- defaultSettings: { settings: {
262
- dimensionLabel: "",
263
- measureLabel: "",
264
- fontSize: "12px",
265
- color: "#000",
266
- paddingLeft: 5,
267
- paddingRight: 5,
268
- paddingVertical: 5,
269
- labelGap: 12
270
- } },
271
- preferredSize() {
272
- let { fontFamily: e = "Arial", fontSize: t, paddingVertical: n } = this.settings.settings;
273
- return this.renderer.measureText({
274
- fontFamily: e,
275
- fontSize: t
276
- }).height + n * 2;
277
- },
278
- render() {
279
- let { dimensionLabel: e, measureLabel: t, fontFamily: n = "Arial", fontSize: r, color: i, paddingLeft: a, paddingRight: o, labelGap: s } = this.settings.settings, c = t ? Q(this.renderer, t, n, r) : 0, l = this.rect.width - o, u = l - c, d = Math.max(Math.min(t ? u - s - a : this.rect.width - a - o, this.rect.width / 2), 0), f = e ? $(e, d, this.renderer, n, r) : "", p = f ? Q(this.renderer, f, n, r) : 0, m = [];
280
- return t && m.push({
281
- type: "rect",
282
- x: Math.max(u, 0),
283
- y: 0,
284
- width: Math.min(c, this.rect.width),
285
- height: this.rect.height,
286
- fill: "rgba(0, 0, 0, 0)",
287
- strokeWidth: 0,
288
- data: { target: "measure" }
289
- }), e && (m.push({
290
- type: "rect",
291
- x: a,
292
- y: 0,
293
- width: p,
294
- height: this.rect.height,
295
- fill: "rgba(0, 0, 0, 0)",
296
- strokeWidth: 0,
297
- data: { target: "dimension" }
298
- }), m.push({
299
- type: "text",
300
- text: f,
301
- x: a,
302
- y: this.rect.height / 2,
303
- anchor: "start",
304
- baseline: "central",
305
- fontFamily: n,
306
- fontSize: r,
307
- fill: i,
308
- maxWidth: d,
309
- data: { target: "dimension" }
310
- })), t && m.push({
311
- type: "text",
312
- text: t,
313
- x: l,
314
- y: this.rect.height / 2,
315
- anchor: "end",
316
- baseline: "central",
317
- fontFamily: n,
318
- fontSize: r,
319
- fill: i,
320
- data: { target: "measure" }
321
- }), m;
322
- }
323
- };
324
- function he(e) {
325
- e.component(U, me);
326
- }
327
- var ge = h(), _e = p(({ vSpec: e, vTheme: t, data: n, elementSize: i, vizProperties: a }) => {
328
- let o = f(), [s] = (0, z.useState)(() => new pe()), { activeKey: u } = m(), d = {
329
- ...a,
330
- valuePickerMode: !!u
331
- }, p = t || r;
332
- if (n?.[0]?.items && e?.measures?.length) {
333
- let t = n[0].items.reduce((t, n) => t + n[c(e.measures[0].dataItem)], 0);
334
- n[0].sum = t;
335
- }
336
- let h = s.compile(e, p, n, i, d, l.Pie, o, void 0, ie());
337
- return h ? /* @__PURE__ */ (0, ge.jsx)(te, {
338
- config: d,
339
- definition: h,
340
- size: i,
341
- vSpec: e,
342
- escobarPlugins: [he]
343
- }) : null;
344
- });
345
- export { _e as PieChart };