@astrato-io/visualizations 0.0.0-stage → 0.6.4

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 (145) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/LICENSE +93 -0
  3. package/README.md +843 -2
  4. package/THIRD_PARTY_NOTICES.md +8387 -0
  5. package/VISUALIZATION_DEFINITIONS.md +2378 -0
  6. package/chunks/LinearProgress-CUZ0D8_t.js +253 -0
  7. package/chunks/Radio-Ciu-F4CU.js +957 -0
  8. package/chunks/ToggleButton-BCJc3Jlc.js +153 -0
  9. package/chunks/_baseFlatten-DPXPOrea.js +7076 -0
  10. package/chunks/accessors-DemrDevR.js +128 -0
  11. package/chunks/app-filter-bar.compiler-j_CVoWTa.js +55 -0
  12. package/chunks/bar.compiler-oqaPzIut.js +370 -0
  13. package/chunks/color-settings-ZIvgNTq1.js +10 -0
  14. package/chunks/coloring-C16AUZEi.js +663 -0
  15. package/chunks/data-item-resolution-1lvYB5ln.js +53 -0
  16. package/chunks/debounce-fn-CUixuz45.js +7 -0
  17. package/chunks/escobar-BGqT1EsE.js +34580 -0
  18. package/chunks/event-bus-KiSiCJrC.js +2683 -0
  19. package/chunks/events-WZut5Ow6.js +4 -0
  20. package/chunks/extend-BKUkc4_i.js +37 -0
  21. package/chunks/filter.compiler-CuLtc_02.js +60 -0
  22. package/chunks/filtering-Yq4DEa0t.js +953 -0
  23. package/chunks/gauge-target-type-BkKXAqkX.js +4 -0
  24. package/chunks/grouping-type-BX_9Ix5q.js +3 -0
  25. package/chunks/interfaces-VUY4_yVO.js +8742 -0
  26. package/chunks/line-settings-DfYTUyPz.js +4 -0
  27. package/chunks/line.compiler-BpA_6Tc7.js +188 -0
  28. package/chunks/metadata-CPXdYoln.js +28 -0
  29. package/chunks/number.compiler-DbkWcG4S.js +44 -0
  30. package/chunks/pie-uv42Eqal.js +10 -0
  31. package/chunks/range-DrzdfBX4.js +22 -0
  32. package/chunks/registry-CExpGJ1N.js +920 -0
  33. package/chunks/requirements-DNhuShLS.js +6 -0
  34. package/chunks/rolldown-runtime-DleVn1XH.js +28 -0
  35. package/chunks/set-coloring-datafield-B3uIS1Pe.js +8 -0
  36. package/chunks/shared-CKDL4hx9.js +1171 -0
  37. package/chunks/src-BC7cGcJ-.js +2024 -0
  38. package/chunks/src-BOS6SqkZ.js +67 -0
  39. package/chunks/src-C0LgoUWY.js +26105 -0
  40. package/chunks/src-Cum_2NLV.js +12145 -0
  41. package/chunks/src-D9XogOrc.js +422 -0
  42. package/chunks/src-Dun_jXtz.js +10295 -0
  43. package/chunks/src-DvX5LU9T.js +14742 -0
  44. package/chunks/standalone-87YV_m9n.js +687 -0
  45. package/chunks/standalone-BDCwI6Hn.js +4619 -0
  46. package/chunks/standalone-BH5NqDwp.js +1763 -0
  47. package/chunks/standalone-BLVAWLNJ.js +385 -0
  48. package/chunks/standalone-BPomtAVs.js +2 -0
  49. package/chunks/standalone-BXyBcUOQ.js +2 -0
  50. package/chunks/standalone-BYm1UjLr.js +140 -0
  51. package/chunks/standalone-BllF4rDp.js +383 -0
  52. package/chunks/standalone-BmfMt74U.js +726 -0
  53. package/chunks/standalone-BqWyrnZI.js +281 -0
  54. package/chunks/standalone-C85u7U6I.js +340 -0
  55. package/chunks/standalone-CCNtaJ7s.js +741 -0
  56. package/chunks/standalone-CDQnr6qT.js +345 -0
  57. package/chunks/standalone-CNyNHKVx.js +674 -0
  58. package/chunks/standalone-CY57qwZ-.js +1129 -0
  59. package/chunks/standalone-CZynjFG7.js +12979 -0
  60. package/chunks/standalone-D5vnf-9y.js +3943 -0
  61. package/chunks/standalone-DFPva_ku.js +299 -0
  62. package/chunks/standalone-DQxxNwF8.js +675 -0
  63. package/chunks/standalone-DS9T0FZ-.js +830 -0
  64. package/chunks/standalone-Dx3MLlrO.js +512 -0
  65. package/chunks/standalone-DzixzZAL.js +411 -0
  66. package/chunks/standalone-QJ1kKMnO.js +6 -0
  67. package/chunks/standalone-jiz0L2Dg.js +3855 -0
  68. package/chunks/standalone-lBm9hQ-q.js +179 -0
  69. package/chunks/standalone-rJ45Zfl1.js +68 -0
  70. package/chunks/stroke-dash-UgMEcCS4.js +6 -0
  71. package/chunks/table.compiler-BrXkm4Fz.js +213 -0
  72. package/chunks/toInteger-DVZr-D1j.js +11 -0
  73. package/chunks/treemap-x_zmJoG7.js +23 -0
  74. package/chunks/typeof-CJDtcySz.js +13 -0
  75. package/chunks/types-dVVCsDWD.js +4 -0
  76. package/chunks/ui-D1HQNIBy.js +54039 -0
  77. package/chunks/url-utils-B17gj_mr.js +5501 -0
  78. package/chunks/useFieldName-oqQ3bvnO.js +7 -0
  79. package/chunks/utils-Ba9T0TqC.js +31097 -0
  80. package/chunks/view-CLqWMV7Z.js +156 -0
  81. package/definitions.js +3 -0
  82. package/docs/operations/astrato-app-filter-bar.md +161 -0
  83. package/docs/operations/bar.md +7050 -0
  84. package/docs/operations/combo.md +5825 -0
  85. package/docs/operations/date-picker.md +644 -0
  86. package/docs/operations/distribution-gauge.md +3218 -0
  87. package/docs/operations/dot.md +5662 -0
  88. package/docs/operations/filter.md +1507 -0
  89. package/docs/operations/gauge.md +3452 -0
  90. package/docs/operations/heatMap.md +6026 -0
  91. package/docs/operations/histogram.md +1870 -0
  92. package/docs/operations/iframe.md +56 -0
  93. package/docs/operations/image.md +177 -0
  94. package/docs/operations/index.md +46 -0
  95. package/docs/operations/line.md +6468 -0
  96. package/docs/operations/number.md +3969 -0
  97. package/docs/operations/pie.md +6089 -0
  98. package/docs/operations/radar.md +4646 -0
  99. package/docs/operations/sankey.md +3210 -0
  100. package/docs/operations/scatter.md +6075 -0
  101. package/docs/operations/shape.md +315 -0
  102. package/docs/operations/simpleTextObject.md +706 -0
  103. package/docs/operations/slider.md +230 -0
  104. package/docs/operations/table.md +8790 -0
  105. package/docs/operations/tree.md +2874 -0
  106. package/docs/operations/treemap.md +3619 -0
  107. package/docs/operations/waterfall.md +2938 -0
  108. package/docs/operations/word-cloud.md +3071 -0
  109. package/getters.js +18 -0
  110. package/index.js +1183 -0
  111. package/metadata.js +20 -0
  112. package/operations.js +64 -0
  113. package/package.json +191 -4
  114. package/src/definitions/index.d.ts +2 -0
  115. package/src/definitions/shared/index.d.ts +5 -0
  116. package/src/definitions/shared/lib/available-fields.d.ts +36 -0
  117. package/src/definitions/shared/lib/compilers/index.d.ts +7 -0
  118. package/src/definitions/shared/lib/registry/compile.d.ts +2 -0
  119. package/src/definitions/shared/lib/registry/descriptor-registry.d.ts +587 -0
  120. package/src/definitions/shared/lib/registry/index.d.ts +3 -0
  121. package/src/definitions/shared/lib/registry/validation.d.ts +3 -0
  122. package/src/definitions/shared/lib/schemas/app-filter-bar.schema.d.ts +22 -0
  123. package/src/definitions/shared/lib/schemas/bar.schema.d.ts +73 -0
  124. package/src/definitions/shared/lib/schemas/broad-chart.schema.d.ts +68 -0
  125. package/src/definitions/shared/lib/schemas/common.schema.d.ts +304 -0
  126. package/src/definitions/shared/lib/schemas/filter.schema.d.ts +22 -0
  127. package/src/definitions/shared/lib/schemas/index.d.ts +9 -0
  128. package/src/definitions/shared/lib/schemas/line.schema.d.ts +72 -0
  129. package/src/definitions/shared/lib/schemas/number.schema.d.ts +21 -0
  130. package/src/definitions/shared/lib/schemas/object.schema.d.ts +215 -0
  131. package/src/definitions/shared/lib/schemas/table.schema.d.ts +458 -0
  132. package/src/definitions/shared/lib/types/compilation.types.d.ts +36 -0
  133. package/src/definitions/shared/lib/types/definition.types.d.ts +2 -0
  134. package/src/definitions/shared/lib/types/descriptor.types.d.ts +39 -0
  135. package/src/definitions/shared/lib/types/index.d.ts +3 -0
  136. package/src/getters/index.d.ts +30 -0
  137. package/src/index.d.ts +4 -0
  138. package/src/metadata/index.d.ts +4 -0
  139. package/src/operations/index.d.ts +30 -0
  140. package/src/registry/index.d.ts +6 -0
  141. package/src/runtime/index.d.ts +2 -0
  142. package/src/types.d.ts +307 -0
  143. package/src/visualization-catalog.d.ts +82 -0
  144. package/src/web-components/index.d.ts +12 -0
  145. package/styles.css +2 -0
@@ -0,0 +1,281 @@
1
+ import { o as e } from "./rolldown-runtime-DleVn1XH.js";
2
+ import { Oa as t, On as n, Pn as r, Po as i, Ta as a, Ti as o, Xs as s, bo as c, hc as l, pc as u, qs as d, yo as f, zn as p } from "./interfaces-VUY4_yVO.js";
3
+ import { I as m, Ki as h, P as g, Zt as _, wi as v } from "./utils-Ba9T0TqC.js";
4
+ import { Hn as y, Rn as b } from "./event-bus-KiSiCJrC.js";
5
+ import { t as x } from "./stroke-dash-UgMEcCS4.js";
6
+ import { B as S, Et as C, Ft as w, G as T, I as E, Jt as D, L as O, M as k, N as ee, Pt as A, Rt as j, St as M, Wt as N, Xt as P, Y as F, Yt as I, Zt as L, at as R, dt as z, ft as B, gt as V, ht as H, i as U, j as W, kt as G, mt as K, n as q, nn as J, on as Y, st as te, un as X, ut as Z, vt as Q } from "./escobar-BGqT1EsE.js";
7
+ import { o as ne, t as re } from "./coloring-C16AUZEi.js";
8
+ import { t as ie } from "./set-coloring-datafield-B3uIS1Pe.js";
9
+ var ae = /* @__PURE__ */ e(h()), oe = (e, t, r) => {
10
+ let i = e.dimensions.filter((e) => o(e)), a = e.measures.filter((e) => o(e)), c = i[0], f = a[0], m = !1, h = {}, { coloring: g } = e || {}, _ = g?.fieldId;
11
+ if (g?.type === s.Categorical && (_ ||= u(c.dataItem)), g?.type === s.Gradient && (_ ||= u(f.dataItem)), _ && H(r, 0, { color: { field: _ } }), c && e?.axes?.dimension?.continuousAxis) {
12
+ let e = l(c.dataItem), t = !!c.datePart, r = n(e) || p(e);
13
+ m = !t && r;
14
+ }
15
+ if (h = M(ie(e, _), t, h), h = T(e, h, r.collections, m, !0), a.filter((e) => e.graphType === d.Bar).length > 1 && !e.barSettings?.grouped) {
16
+ let t = P(e, a.find((e) => e.graphType === d.Bar));
17
+ h[t].data = { collection: C.ComboChartCollection };
18
+ }
19
+ return {
20
+ ...r,
21
+ scales: h
22
+ };
23
+ }, $ = (e, t, n) => {
24
+ let r = e.measures.filter((e) => o(e)), i = e.dimensions.filter((e) => o(e)), a = (e.supportingMeasures ?? []).filter((e) => o(e)), s = r.reduce((e, t) => {
25
+ let n = u(t.dataItem);
26
+ return e[n] = { field: n }, e;
27
+ }, {}), c = k(a), l = i.reduce((e, t) => {
28
+ let n = u(t.dataItem);
29
+ return e[n] = { field: n }, e;
30
+ }, {}), f = i[0];
31
+ if (!f) return n;
32
+ let p = u(f.dataItem), m = {
33
+ key: C.ComboChartCollection,
34
+ data: { extract: [] }
35
+ };
36
+ if (m.data.extract = r.map((e, t) => {
37
+ let n = u(e.dataItem);
38
+ return {
39
+ field: p,
40
+ props: {
41
+ end: { field: n },
42
+ ...s,
43
+ ...c,
44
+ ...l,
45
+ start: 0,
46
+ graphType: e.graphType,
47
+ measureIndex: t,
48
+ fieldId: n
49
+ }
50
+ };
51
+ }), r.filter((e) => e.graphType === d.Bar).length > 1) {
52
+ let t = !!r.find((e) => e.graphType === d.Bar)?.secondaryAxis, n = new Map(r.map((e) => [u(e.dataItem), !!e.secondaryAxis]));
53
+ e.barSettings?.grouped || (m.data.stack = {
54
+ stackKey: (e) => e.graphType.value === d.Bar ? `${e.value}` : `${e.value}-${e.graphType.value}-${e.measureIndex.value}`,
55
+ value: (e) => {
56
+ let r = e.fieldId?.value;
57
+ return typeof r != "string" || n.get(r) !== t ? null : e.end.value;
58
+ },
59
+ offset: y.Diverging
60
+ });
61
+ }
62
+ return {
63
+ ...n,
64
+ collections: [...n.collections, m]
65
+ };
66
+ }, se = (e, t, n, r, i, a) => {
67
+ let s = [];
68
+ return e.measures.filter((e) => o(e)).forEach((r) => {
69
+ let o = u(r.dataItem), c = (e) => e.fieldId.value === o;
70
+ switch (r.graphType || e.type) {
71
+ case d.Bar:
72
+ s.push(le(e, t, i, n, r, a, c));
73
+ break;
74
+ case d.Point:
75
+ s.push(B(e, t, n, r, !1, C.ComboChartCollection, c));
76
+ break;
77
+ default: s.push(ce(e, t, n, r, c)), s.push(B(e, t, n, r, !r.showDataPoints, C.ComboChartCollection, c));
78
+ }
79
+ }), s.sort((e) => e.type === X.Box ? -1 : 0), {
80
+ ...n,
81
+ components: [...n.components, ...s]
82
+ };
83
+ };
84
+ function ce(e, t, n, r, a) {
85
+ let s = e.dimensions.filter((e) => o(e));
86
+ if (!s[0]) throw Error("Combo chart without dimension is not supported.");
87
+ if (s.length > 1) throw Error("Combo chart currently support only one dimension.");
88
+ let c = x(r.strokeDash), l = u(r.dataItem), f = ne(e, n, t, r, l);
89
+ return {
90
+ type: X.Line,
91
+ layout: { displayOrder: w.VisualizationElement },
92
+ key: K(e, r, d.Line),
93
+ data: {
94
+ collection: C.ComboChartCollection,
95
+ filter: a
96
+ },
97
+ settings: {
98
+ orientation: e.orientation === i.Horizontal ? i.Vertical : i.Horizontal,
99
+ coordinates: {
100
+ major: { scale: I(e) },
101
+ minor: {
102
+ scale: P(e, r),
103
+ ref: l
104
+ }
105
+ },
106
+ layers: {
107
+ curve: e.lineSettings?.lineCurve,
108
+ skipCollisions: !0,
109
+ line: {
110
+ stroke: f,
111
+ strokeWidth: r.strokeWidth,
112
+ strokeDasharray: c
113
+ }
114
+ }
115
+ },
116
+ animations: {
117
+ enabled: !0,
118
+ presetId: "simple-opacity"
119
+ }
120
+ };
121
+ }
122
+ function le(e, t, n, a, s, c, l) {
123
+ let f = e.dimensions.filter((e) => o(e)), p = e.measures.filter((e) => o(e) && e.graphType === d.Bar);
124
+ if (!f[0]) throw Error("Combo chart without dimension is not supported.");
125
+ let m = { scale: I(e) }, h = {
126
+ scale: P(e, s),
127
+ end: { ref: "end" }
128
+ }, g = {
129
+ minWidthPx: 2,
130
+ rx: r(e?.barSettings.barRadius, 0),
131
+ roundAllEdges: e?.barSettings?.roundAllEdges,
132
+ useCustomBoxRounding: !0,
133
+ boxPadding: e?.barSettings?.barPadding ?? Y.scale.padding
134
+ };
135
+ g.fill = new re(e, t, n?.[0]?.itemsNotAffectedByFiltering).getColorDefinition({ ref: "fieldId" });
136
+ let _ = {
137
+ enabled: !0,
138
+ presetId: "bar-chart"
139
+ }, v = s?.graphType !== d.Bar;
140
+ if (p.length > 1 && e.barSettings?.grouped) {
141
+ let t = 1 * (1 / p.length), n = (1 - (e.barSettings?.barPadding ?? 0)) * t, r = .5 / p.length, i = (1 + 0 * (p.length - 1)) * r, a = p.findIndex((e) => u(e.dataItem) === u(s.dataItem));
142
+ m.fn = (n) => {
143
+ let r = n.resources.scale(I(e));
144
+ return r(n.datum.value) + i * r.bandwidth?.() + a * r.bandwidth?.() * t;
145
+ }, g.width = n;
146
+ }
147
+ return {
148
+ type: X.Box,
149
+ layout: { displayOrder: w.VisualizationElement },
150
+ key: K(e, s, d.Bar),
151
+ data: {
152
+ collection: C.ComboChartCollection,
153
+ filter: l
154
+ },
155
+ settings: {
156
+ orientation: e.orientation ?? i.Vertical,
157
+ major: m,
158
+ minor: h,
159
+ box: g
160
+ },
161
+ animations: _,
162
+ brush: v ? null : N([""], c)
163
+ };
164
+ }
165
+ var ue = (e, t) => {
166
+ let n = t ? [b.Inside] : [
167
+ b.Inside,
168
+ b.Outside,
169
+ b.Opposite
170
+ ];
171
+ return (e || [
172
+ {
173
+ position: b.Inside,
174
+ justify: 1
175
+ },
176
+ { position: b.Outside },
177
+ { position: b.Opposite }
178
+ ]).map((e) => ({
179
+ ...e,
180
+ possible: n.includes(e.position)
181
+ }));
182
+ }, de = ({ data: e }) => e ? e.end.value > e.start.value ? "up" : "down" : null, fe = ({ data: e }) => e ? e.end.value > e.start.value ? "right" : "left" : null, pe = (e, n, r, i, a, s) => {
183
+ let l = e.measures.filter((e) => o(e)), p = l.filter((e) => e.graphType === d.Bar), m = p.filter((e) => e.dataLabels?.show), h = p.length >= 2 && !("barSettings" in e && e.barSettings?.grouped), g = L(e), _ = m.map((r) => {
184
+ let i = !!r.dataLabels?.barLabelPlacements, a = ue(r.dataLabels?.barLabelPlacements, h).filter((e) => e.possible).map((e) => ({
185
+ position: e.position,
186
+ fill: e.position === b.Inside ? t.white : "#242424",
187
+ ...e.justify === void 0 ? {} : { justify: e.justify },
188
+ ...i ? { overflow: [b.Outside, b.Opposite].includes(e.position) } : {}
189
+ }));
190
+ return r.dataLabels?.showBackdrop && !h && (a = a.map((e) => ee(e, n, g))), {
191
+ key: `combo-bar-labels-${r.dataItem.uniqueSignature}`,
192
+ type: X.Labels,
193
+ layout: { displayOrder: w.Labels },
194
+ settings: { sources: [{
195
+ component: K(e, r, d.Bar),
196
+ selector: J.Rect,
197
+ strategy: {
198
+ type: "bar",
199
+ settings: {
200
+ direction: g ? fe : de,
201
+ fontSize: D(r.dataLabels?.size),
202
+ fontFamily: n.fonts.general.fontFamily,
203
+ labels: [{
204
+ label: E(r),
205
+ placements: a
206
+ }]
207
+ }
208
+ }
209
+ }] },
210
+ animations: {
211
+ enabled: !0,
212
+ presetId: "chart-labels"
213
+ }
214
+ };
215
+ }), v = {}, y = {}, x = l.filter((e) => e.graphType !== d.Bar).map((t) => {
216
+ let n = u(t.dataItem), r = K(e, t, d.Point);
217
+ return y[r] = n, v[r] = {
218
+ enabled: t.dataLabels?.show || !1,
219
+ fontSize: D(t.dataLabels?.size),
220
+ backdropColor: t.dataLabels?.backdropColor,
221
+ textColor: t.dataLabels?.textColor,
222
+ isColored: t.dataLabels?.isColored,
223
+ colorType: t.dataLabels?.showBackdrop ? f.Backdrop : f.Text,
224
+ density: t.dataLabels?.density || c.Medium
225
+ }, r;
226
+ }).filter((e) => v[e].enabled), C = x.length ? [S({
227
+ targetComponentKeys: x,
228
+ targetSelector: `.${z}`,
229
+ label: ({ data: e, node: t }) => e[y[t.key]]?.label,
230
+ skipBrush: !0
231
+ }, v, s, n)] : [];
232
+ if (_.length && C.length) {
233
+ let e = {
234
+ ...C[0],
235
+ settings: {
236
+ ...C[0].settings,
237
+ sources: [..._.flatMap((e) => e.settings.sources), ...C[0].settings.sources]
238
+ }
239
+ };
240
+ return {
241
+ ...r,
242
+ components: [...r.components, e]
243
+ };
244
+ }
245
+ return {
246
+ ...r,
247
+ components: [
248
+ ...r.components,
249
+ ..._,
250
+ ...C
251
+ ]
252
+ };
253
+ }, me = class extends W {
254
+ constructor() {
255
+ super([
256
+ $,
257
+ oe,
258
+ j,
259
+ Q,
260
+ se,
261
+ te,
262
+ V,
263
+ pe,
264
+ R,
265
+ F,
266
+ G,
267
+ A,
268
+ Z,
269
+ O
270
+ ]);
271
+ }
272
+ }, he = v(), ge = _(({ vSpec: e, vTheme: t, data: n, elementSize: r, vizProperties: i }) => {
273
+ let o = g(), [s] = (0, ae.useState)(() => new me()), c = m(), l = t || a, u = s.compile(e, l, n, r, i, d.Combo, o, c, q());
274
+ return u ? /* @__PURE__ */ (0, he.jsx)(U, {
275
+ config: i,
276
+ definition: u,
277
+ size: r,
278
+ vSpec: e
279
+ }) : null;
280
+ });
281
+ export { ge as ComboChart };
@@ -0,0 +1,340 @@
1
+ import { o as e, r as t } from "./rolldown-runtime-DleVn1XH.js";
2
+ import { La as n, Oa as r, Po as i, Ta as a, Ti as o, Xa as s, Xs as c, pc as l, qs as u } from "./interfaces-VUY4_yVO.js";
3
+ import { Ki as d, P as f, Zt as p, fn as m, pn as h, wi as g } from "./utils-Ba9T0TqC.js";
4
+ import { Rn as _ } from "./event-bus-KiSiCJrC.js";
5
+ import { t as v } from "./gauge-target-type-BkKXAqkX.js";
6
+ import { Ct as y, Ft as b, Jt as x, K as S, M as C, St as w, Tt as T, Wt as E, X as D, gt as ee, i as te, in as ne, j as O, nn as k, on as A, un as j } from "./escobar-BGqT1EsE.js";
7
+ import { t as M } from "./coloring-C16AUZEi.js";
8
+ import { t as re } from "./set-coloring-datafield-B3uIS1Pe.js";
9
+ var ie = /* @__PURE__ */ e(d()), N = {
10
+ outerRadius: .95,
11
+ cornerRadius: 10,
12
+ additionalTextAnchorHeight: 50,
13
+ barMinWidth: 1,
14
+ barMaxWidth: 200,
15
+ minScaleValue: 0,
16
+ maxScaleValue: 100,
17
+ scalePadding: 1,
18
+ backgroundBarOpacity: .2,
19
+ barWidthRadiusPadding: .2,
20
+ maxBarWidthOfRadius: .15,
21
+ gaugeCollectionKey: "Gauge-Collection"
22
+ }, P = (e) => e.gaugeSettings?.barMode ?? !1, F = (e) => e.gaugeSettings?.comparisonMode ?? !1, ae = (e) => {
23
+ let { coloring: t } = e || {};
24
+ return t?.type === c.Categorical || t?.type === c.Single ? y(e, []) : T(e);
25
+ }, I = (e, t, r) => {
26
+ let a = { ...w(re(e, ae(e)), t, {}) }, s = e.gaugeSettings?.barPadding ?? A.scale.padding;
27
+ a = S(e, a, s);
28
+ let c = e.dimensions.filter(o), u = e.measures.filter(o).filter((e) => e.role === n.GAUGE_VALUE);
29
+ return !c.length && P(e) ? a.onlyMeasures = {
30
+ data: F(e) ? { extract: { field: u.length > 0 ? l(u[0].dataItem) : void 0 } } : u.map((e) => l(e.dataItem)),
31
+ type: ne.Band,
32
+ padding: s
33
+ } : F(e) || (a.onlyMeasures = {
34
+ data: { fields: u.map((e) => l(e.dataItem)) },
35
+ include: [0],
36
+ expand: .05
37
+ }), P(e) && (a.barScale = {
38
+ min: N.minScaleValue - N.scalePadding,
39
+ max: N.maxScaleValue + N.scalePadding,
40
+ invert: e.gaugeSettings?.orientation === i.Vertical
41
+ }), {
42
+ ...r,
43
+ scales: a
44
+ };
45
+ }, L = (e, t, r, i, a) => {
46
+ if (!a) return r;
47
+ let s = e.dimensions.filter(o), c = e.measures.filter(o), u = C((e.supportingMeasures ?? []).filter(o)), d = c.filter((e) => e.role === n.GAUGE_VALUE), f = s[0], p = d[0], { targetType: m } = e.gaugeSettings, h = P(e), g = f?.dataItem ?? p.dataItem, _ = [], y = N.minScaleValue;
48
+ if (F(e) ? _.push(...z(e, g, a, u)) : f ? _.push(...R(e, g, a, u)) : _.push(...B(e, a, u)), h) {
49
+ let t = l(p.dataItem), n = {
50
+ field: l(g),
51
+ props: {
52
+ actual: { field: t },
53
+ color: t,
54
+ start: y,
55
+ end: N.maxScaleValue,
56
+ background: !0,
57
+ ...u
58
+ }
59
+ };
60
+ (m === v.Data || m === v.Manual) && (n.props.target = U(e, a)), c.forEach((e) => {
61
+ let t = `measure-${l(e.dataItem)}`;
62
+ n.props[t] = { field: l(e.dataItem) };
63
+ }), _.push(n);
64
+ }
65
+ let b = [{
66
+ key: N.gaugeCollectionKey,
67
+ data: { extract: _ }
68
+ }];
69
+ return {
70
+ ...r,
71
+ collections: b
72
+ };
73
+ }, R = (e, t, r, i) => {
74
+ let a = e.measures.filter(o), s = a.filter((e) => e.role === n.GAUGE_VALUE), c = a.filter((e) => e.role === n.GAUGE_TARGET), u = s[0], d = c[0], { targetType: f } = e.gaugeSettings, p = P(e), m = [], h = l(u.dataItem);
75
+ return p || m.push({
76
+ field: l(t),
77
+ props: {
78
+ actual: { field: h },
79
+ [h]: { field: h },
80
+ color: h,
81
+ ...i
82
+ }
83
+ }), m.push({
84
+ field: l(t),
85
+ props: {
86
+ actual: { field: h },
87
+ start: p ? N.minScaleValue : void 0,
88
+ end: p ? { getValue: V(e, r) } : void 0,
89
+ [h]: { field: h },
90
+ color: h,
91
+ ...i
92
+ }
93
+ }), (f === v.Data || f === v.Manual) && m.forEach((t) => {
94
+ t.props.target = U(e, r), d && f === v.Data && (t.props[l(d.dataItem)] = { field: l(d.dataItem) });
95
+ }), m;
96
+ }, z = (e, t, r, i) => {
97
+ let a = P(e), s = e.measures.filter(o).filter((e) => e.role === n.GAUGE_VALUE), c = s.reduce((e, t) => {
98
+ let n = l(t.dataItem);
99
+ return e[n] = { field: n }, e;
100
+ }, {});
101
+ return s.map((n, o) => {
102
+ let s = l(n.dataItem);
103
+ return {
104
+ field: l(t),
105
+ props: {
106
+ measure: { field: s },
107
+ color: s,
108
+ start: a ? N.minScaleValue : void 0,
109
+ end: a ? { getValue: V(e, r, o) } : void 0,
110
+ ...c,
111
+ ...i
112
+ }
113
+ };
114
+ });
115
+ }, B = (e, t, r) => {
116
+ let i = P(e), a = [];
117
+ return e.measures.filter(o).filter((e) => e.role === n.GAUGE_VALUE).forEach((n) => {
118
+ let o = l(n.dataItem), s = t[0].items[0][o], c = U(e, t, n), u = [];
119
+ u.push({
120
+ field: o,
121
+ props: {
122
+ measureValue: o,
123
+ measure: { field: o },
124
+ actual: { field: o },
125
+ color: o,
126
+ start: i ? N.minScaleValue : void 0,
127
+ end: i && typeof s == "number" && typeof c == "number" ? H(s, c) : void 0,
128
+ [o]: { field: o },
129
+ ...r
130
+ }
131
+ }), u.push({
132
+ field: o,
133
+ props: {
134
+ measureValue: o,
135
+ measure: { field: o },
136
+ actual: { field: o },
137
+ color: o,
138
+ start: i ? N.minScaleValue : void 0,
139
+ end: i ? N.maxScaleValue : void 0,
140
+ background: !0,
141
+ [o]: { field: o },
142
+ ...r
143
+ }
144
+ }), (e.gaugeSettings?.targetType ?? v.Auto) !== v.Auto && u.forEach((e) => {
145
+ e.props.target = c;
146
+ }), a.push(...u);
147
+ }), a;
148
+ }, V = (e, t, r) => {
149
+ let i = e.measures.filter(o), a = i.filter((e) => e.role === n.GAUGE_VALUE), s = i.filter((e) => e.role === n.GAUGE_TARGET), c = a[0], u = s[0];
150
+ return (n, i, o) => {
151
+ let s = a.find((e, t) => t === r), d = s && o[l(s.dataItem)];
152
+ if (typeof d == "number" && d < 0) return N.minScaleValue;
153
+ let f = o[l(c.dataItem)], p;
154
+ if (p = e.gaugeSettings?.targetType === v.Data ? o[l(u?.dataItem)] : U(e, t), !o || typeof f != "number" || typeof p != "number") return N.minScaleValue;
155
+ if (!F(e) || r === void 0) return H(f, p);
156
+ let m = 0, h = 0;
157
+ return a.forEach((e, t) => {
158
+ let n = Math.max(0, o[l(e.dataItem)]);
159
+ m += n, t <= r && (h += n);
160
+ }), h / m * N.maxScaleValue;
161
+ };
162
+ }, H = (e, t) => {
163
+ let n = t ? Math.max(0, e) / t : 1;
164
+ return Math.min(n, 1) * N.maxScaleValue;
165
+ }, U = (e, t, r) => {
166
+ let { targetType: i, targetValue: a } = e.gaugeSettings, s = e.measures.filter(o), c = s.filter((e) => e.role === n.GAUGE_TARGET)[0];
167
+ return i === v.Auto ? t[0].items.map((e) => s.map((t) => e[l(t.dataItem)])).reduce((e, t) => Math.max(...t, e), 0) * (1 + A.scale.padding) : c && i === v.Data ? { field: l(c.dataItem) } : r && i === v.PerMeasure ? r.targetValue ?? 0 : i === v.Manual ? a ?? 0 : 0;
168
+ }, W = /* @__PURE__ */ function(e) {
169
+ return e.Foreground = "foreground", e.Background = "background", e;
170
+ }({}), G = (e, t, n = 0) => `${e}-${t}-${n}`, K = (e) => Math.min(N.maxBarWidthOfRadius, N.outerRadius / e), q = (e, t, r) => {
171
+ let i = e.measures.filter(o).filter((e) => e.role === n.GAUGE_VALUE);
172
+ return (e) => r !== void 0 && e.measure?.source?.field !== l(i[r]?.dataItem) ? !1 : e.background?.value ? t === W.Background : t === W.Foreground;
173
+ }, J = (e, t) => !t || e.coloring?.type === c.Single ? !1 : !F(e) || e.coloring?.type === c.Categorical, Y = (e, t, r, i, a, s, c, u) => {
174
+ let d = r.dimensions.filter(o)[0], f = new M(r, i, t?.[0]?.itemsNotAffectedByFiltering), p = f.getColorDefinition(J(r, d) ? { ref: f.MAIN_FIELD } : {}), m = (e, t) => !F(r) && t === 1 || s && F(r) ? "transparent" : typeof p == "function" ? p(e) : p, h = K(c), g = Number(r.gaugeSettings?.size), _ = Number(r.gaugeSettings?.startAngle), y = isNaN(g) ? 360 : g ?? 360, b = isNaN(_) ? 0 : _ ?? 0, x = b + y, S = b / 180 * Math.PI, C = x / 180 * Math.PI;
175
+ return {
176
+ key: G(j.Pie, s ? W.Background : W.Foreground, a),
177
+ type: j.Pie,
178
+ animations: {
179
+ enabled: !0,
180
+ presetId: "pie-chart"
181
+ },
182
+ data: {
183
+ collection: N.gaugeCollectionKey,
184
+ filter: (t) => {
185
+ if (!d) {
186
+ let e = r.measures.filter(o).filter((e) => e.role === n.GAUGE_VALUE);
187
+ return F(r) || e[a] && t.measure?.source?.field === l(e[a].dataItem);
188
+ }
189
+ return `${t.value}` == `${e[l(d.dataItem)]}`;
190
+ }
191
+ },
192
+ settings: {
193
+ startAngle: S,
194
+ endAngle: C,
195
+ slice: {
196
+ cornerRadius: r.gaugeSettings?.cornerRadius ?? 10,
197
+ outerRadius: N.outerRadius - a * h,
198
+ innerRadius: N.outerRadius - (a + (1 - N.barWidthRadiusPadding)) * h,
199
+ fill: m,
200
+ strokeWidth: .1,
201
+ opacity: s ? N.backgroundBarOpacity : 1,
202
+ arc: (e, t) => {
203
+ if (s) return +(t === 0);
204
+ if (F(r)) return e.datum.measure.value;
205
+ if ((r.gaugeSettings.targetType ?? v.Auto) !== v.Auto) return t === 0 ? e.datum.actual.value : Number(e.datum.target.value) - Number(e.datum.actual.value);
206
+ {
207
+ let n = e.resources.scale("onlyMeasures"), r = Number(n(e.datum.actual.value)) || 0;
208
+ return t === 0 ? r : 1 - r;
209
+ }
210
+ }
211
+ }
212
+ },
213
+ brush: E([""], u, { overwriteOpacity: s ? N.backgroundBarOpacity : null })
214
+ };
215
+ }, X = (e, t, n, a, s, c) => {
216
+ let u = e.dimensions.filter(o)[0], d = new M(e, t, n?.[0]?.itemsNotAffectedByFiltering), f;
217
+ f = a === W.Background && e.gaugeSettings?.backgroundBarColor ? e.gaugeSettings?.backgroundBarColor : d.getColorDefinition(J(e, u) ? { ref: d.MAIN_FIELD } : {}, !e.gaugeSettings?.backgroundBarColor && a === W.Background ? N.backgroundBarOpacity : null);
218
+ let p = u ? l(u.dataItem) : "onlyMeasures", m = !u && !F(e) ? "measureValue" : void 0, h = {
219
+ key: G(j.Box, a, s),
220
+ type: j.Box,
221
+ animations: { enabled: !0 },
222
+ data: {
223
+ collection: N.gaugeCollectionKey,
224
+ filter: q(e, a, s)
225
+ },
226
+ settings: {
227
+ orientation: e.gaugeSettings.orientation ?? i.Horizontal,
228
+ major: {
229
+ scale: p,
230
+ ref: m
231
+ },
232
+ minor: { scale: "barScale" },
233
+ box: {
234
+ minWidthPx: 2,
235
+ fill: f,
236
+ rx: e.gaugeSettings?.barRadius ?? 0
237
+ }
238
+ },
239
+ brush: E([""], c, { disable: { triggers: a === W.Foreground } })
240
+ };
241
+ return e.gaugeSettings?.strokeEnabled ? (h.settings.box.stroke = e.gaugeSettings?.strokeColor || t.colors.brandColors[0], h.settings.box.strokeWidth = e.gaugeSettings?.strokeWidth) : h.settings.box.stroke = r.transparent, h;
242
+ }, oe = (e, t, n, r, i, a) => {
243
+ if (!i) return n;
244
+ let o = [];
245
+ return o = P(e) ? ce(e, t, r, i, a) : se(e, t, r, i, a), {
246
+ ...n,
247
+ components: [...n.components, ...o]
248
+ };
249
+ }, se = (e, t, r, i, a) => {
250
+ let s = e.dimensions.filter(o), c = e.measures.filter(o).filter((e) => e.role === n.GAUGE_VALUE);
251
+ return !s[0] && !F(e) ? c.map((n, r) => [Y(i[0].items[0], i, e, t, r, !0, c.length), Y(i[0].items[0], i, e, t, r, !1, c.length)]).reduce((e, t) => e.concat(t), []) : i[0].items.map((n, r) => [Y(n, i, e, t, r, !0, i[0].items.length, a), Y(n, i, e, t, r, !1, i[0].items.length, a)]).reduce((e, t) => e.concat(t), []);
252
+ }, ce = (e, t, r, i, a) => {
253
+ let s = e.dimensions.filter(o), c = e.measures.filter(o).filter((e) => e.role === n.GAUGE_VALUE), l = s[0], u = [];
254
+ if (F(e)) for (let n = c.length - 1; n >= 0; n--) u.push(X(e, t, i, W.Foreground, n, a));
255
+ else if (l) u = [X(e, t, i, W.Background, void 0, a), X(e, t, i, W.Foreground, void 0, a)];
256
+ else for (let n = c.length - 1; n >= 0; n--) u.push(X(e, t, i, W.Background, n)), u.push(X(e, t, i, W.Foreground, n));
257
+ return u;
258
+ }, le = (e, t, r) => {
259
+ let i = e.dimensions.filter(o), a = e.measures.filter(o).filter((e) => e.role === n.GAUGE_VALUE);
260
+ if (!e.gaugeSettings?.barMode || !i.length && e.gaugeSettings?.comparisonMode) return r;
261
+ let s = [];
262
+ return i.length ? (e.gaugeSettings?.showDimensionLabels !== !1 && i[0] && s.push(Z(!1, t, i[0].formatter, "dimension", void 0, e.gaugeSettings)), !e.gaugeSettings?.comparisonMode && e.gaugeSettings?.showValueLabels !== !1 && a[0] && s.push(Z(!0, t, a[0].formatter, "value", void 0, e.gaugeSettings))) : e.gaugeSettings?.showValueLabels !== !1 && a.forEach((n, r) => {
263
+ s.push(Z(!0, t, n.formatter, String(r), r, e.gaugeSettings));
264
+ }), {
265
+ ...r,
266
+ components: [...r.components, ...s]
267
+ };
268
+ }, Z = (e, t, n, r, a, o) => {
269
+ let s = +!!e, c = {
270
+ type: "bar",
271
+ settings: {
272
+ direction: o?.orientation === i.Vertical ? "up" : "right",
273
+ fontSize: x(o?.labelFontSize),
274
+ fontFamily: t.fonts.general.fontFamily,
275
+ labels: [{
276
+ label: (t) => t.data ? e ? ue(t.data.actual.value, n, t) : `${h(n, t.data?.label)}` : "",
277
+ placements: e ? [{
278
+ position: _.Outside,
279
+ fill: "#000",
280
+ justify: 0
281
+ }, {
282
+ position: _.Inside,
283
+ fill: "#fff",
284
+ justify: s
285
+ }] : [{
286
+ position: _.Inside,
287
+ fill: "#fff",
288
+ justify: s
289
+ }]
290
+ }]
291
+ }
292
+ };
293
+ return {
294
+ type: j.Labels,
295
+ key: `gauge-bar-labels-${r}`,
296
+ layout: { displayOrder: b.Labels },
297
+ settings: { sources: [{
298
+ component: G(j.Box, W.Foreground, a),
299
+ selector: k.Rect,
300
+ strategy: c
301
+ }] },
302
+ animations: {
303
+ enabled: !0,
304
+ presetId: "chart-labels"
305
+ }
306
+ };
307
+ }, ue = (e, t, n) => e === null ? "-" : typeof t != "string" && s(t) ? m(t.format, t)(e, void 0, n.data) : `${h(t, e)}`, Q = (e, t, n, r) => ee(e, t, n, r), de = (e, t, r, i, a) => {
308
+ if (!a) return r;
309
+ let s = e.dimensions.filter(o), c = e.measures.filter(o).filter((e) => e.role === n.GAUGE_VALUE), l = s[0], u = P(e), d = F(e), f = u ? j.Box : j.Pie, p = u && !d ? W.Background : W.Foreground, m = ((u || !l ? c : a[0]?.items) || []).map((e, t) => G(f, p, t));
310
+ return D(e, t, r, {
311
+ filter: (e) => e.filter((e) => m.findIndex((t) => t === e.key) !== -1),
312
+ placement: {
313
+ type: u ? "bounds" : "slice",
314
+ area: "target"
315
+ }
316
+ });
317
+ }, fe = class extends O {
318
+ constructor() {
319
+ super([
320
+ L,
321
+ I,
322
+ oe,
323
+ le,
324
+ Q,
325
+ de
326
+ ]);
327
+ }
328
+ preCompile(e) {
329
+ if (!e.measures.filter(o).filter((e) => e.role === n.GAUGE_VALUE).length) throw Error("Charts w/o measures are not supported ATM.");
330
+ }
331
+ }, pe = g(), $ = p(({ vSpec: e, vTheme: t, data: n, elementSize: r, vizProperties: i }) => {
332
+ let o = f(), [s] = (0, ie.useState)(() => new fe()), c = t || a, l = s.compile(e, c, n, r, i, u.Gauge, o);
333
+ return l ? /* @__PURE__ */ (0, pe.jsx)(te, {
334
+ config: i,
335
+ definition: l,
336
+ size: r,
337
+ vSpec: e
338
+ }) : null;
339
+ }), me = /* @__PURE__ */ t({ GaugeChart: () => $ });
340
+ export { $ as n, me as t };