@astrato-io/visualizations 0.10.1 → 0.11.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 (133) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/README.md +19 -1
  3. package/THIRD_PARTY_NOTICES.md +494 -0
  4. package/VISUALIZATION_DEFINITIONS.md +6 -145
  5. package/chunks/{Button-Dn3rJrYf.js → Button-CPG4WX8X.js} +3 -3
  6. package/chunks/{CircularProgress-BFeu06Yb.js → CircularProgress-PSLW8HmD.js} +12 -12
  7. package/chunks/FieldTypeIcon-5k2bkqd0.js +22 -0
  8. package/chunks/{LinearProgress-ClO6GUjN.js → LinearProgress-KQ2EQlGL.js} +16 -16
  9. package/chunks/{MenuOption-Czc34u4q.js → MenuOption-B-6K7kks.js} +151 -151
  10. package/chunks/{Title-BgYnaVTR.js → Title-BmvwZYkh.js} +32 -32
  11. package/chunks/{_createAggregator-BMu9uRax.js → _createAggregator-CFmH6gUN.js} +16 -16
  12. package/chunks/{app-filter-bar.compiler-CVir0wkl.js → app-filter-bar.compiler-BY5-T16I.js} +8 -8
  13. package/chunks/{bar-layout-C_UgRlVl.js → bar-layout-BNou0dZF.js} +2 -2
  14. package/chunks/{bar.compiler-DYuFdi9J.js → bar.compiler-BkhO7sDd.js} +58 -56
  15. package/chunks/{builder-C-TKA-My.js → builder-CNjuqD2z.js} +107 -56
  16. package/chunks/category-axis-D1OVyMrr.js +20 -0
  17. package/chunks/{coloring-BtnPiQ_o.js → coloring-BOiP0rmn.js} +51 -51
  18. package/chunks/{createSimplePaletteValueFilter--zrZxRV9.js → createSimplePaletteValueFilter-BkgQ7MFE.js} +166 -166
  19. package/chunks/defaults-B5_8S-J-.js +3 -0
  20. package/chunks/{definitions-CT304NDn.js → definitions-AS9GcavE.js} +228 -233
  21. package/chunks/{escobar-CvEV2ES1.js → escobar-cQ1eQ64G.js} +4183 -4183
  22. package/chunks/{extend-preset-D9-JP92b.js → extend-preset-BlCbcXKR.js} +427 -427
  23. package/chunks/{filter.compiler-CXeZznks.js → filter.compiler-CI7dDNM1.js} +10 -10
  24. package/chunks/{filtering-8_bFv-jb.js → filtering-Dwi7hDPZ.js} +308 -308
  25. package/chunks/{handlers-C6CZ0XJA.js → handlers-C63NVo7i.js} +4593 -4559
  26. package/chunks/{icon-picker-styles-BXiJ1SZS.js → icon-picker-styles-CBlxEu3s.js} +8 -8
  27. package/chunks/{isEqual-D8Ay63xR.js → isEqual-BdHo6wqq.js} +1 -1
  28. package/chunks/{isFocusVisible-Bu8gGZu5.js → isFocusVisible-C1nlVUwL.js} +9 -9
  29. package/chunks/line.compiler-DCv3h42f.js +198 -0
  30. package/chunks/linear-Bq_r9l5S.js +264 -0
  31. package/chunks/{logger-DdZpR7xZ.js → logger-Bc-DqDM_.js} +64 -64
  32. package/chunks/{lookup-BWllin0q.js → lookup-B3tWH2hX.js} +1 -0
  33. package/chunks/{map.compiler-Q_Y1Pvat.js → map.compiler-CRO6XpdI.js} +43 -43
  34. package/chunks/measure-format-default-B6ghxih7.js +22 -0
  35. package/chunks/{metadata-BQm_TXI1.js → metadata-CtkvZEhS.js} +1 -1
  36. package/chunks/number.compiler-kV4lobCZ.js +57 -0
  37. package/chunks/{operations-DKQWuLL7.js → operations-COl9wgqi.js} +8524 -8480
  38. package/chunks/{range-BdhzvYQ_.js → range-CMJ5yc5Z.js} +2 -2
  39. package/chunks/{react-dom-BGP4tbXV.js → react-dom-BjsCbYHq.js} +76 -76
  40. package/chunks/{render-wrappers-BZpyDnJy.js → render-wrappers-DFHi3Wkr.js} +1 -1
  41. package/chunks/{requirements-e8Fe96ag.js → requirements-C5YLmHKe.js} +250 -226
  42. package/chunks/{shared-C_2F90xq.js → shared-DyqxOie0.js} +504 -498
  43. package/chunks/standalone-06i1wmIX.js +6 -0
  44. package/chunks/{standalone-BDrXVxlP.js → standalone-9jrQ3zJT.js} +10 -10
  45. package/chunks/standalone-B6zUvxNQ.js +357 -0
  46. package/chunks/{standalone-BkbiH-o8.js → standalone-BYK2U0Vd.js} +418 -679
  47. package/chunks/standalone-Be5APcVv.js +762 -0
  48. package/chunks/{standalone-Cl0TSfqC.js → standalone-Bp4G3MDx.js} +123 -123
  49. package/chunks/{standalone-DNh9NcMa.js → standalone-BrjtMIdd.js} +145 -145
  50. package/chunks/{standalone-BTY3w_JA.js → standalone-Bsfz5vnJ.js} +53 -53
  51. package/chunks/standalone-BuXpKMnc.js +2 -0
  52. package/chunks/standalone-CIjNYyya.js +8378 -0
  53. package/chunks/{standalone-CsoMmE9T.js → standalone-CS5VGoja.js} +347 -347
  54. package/chunks/standalone-CUGt2FUF.js +2 -0
  55. package/chunks/{standalone-CaTxAydz.js → standalone-ChfEHb28.js} +2296 -1069
  56. package/chunks/standalone-CnF2OYLQ.js +355 -0
  57. package/chunks/standalone-CznEEiq3.js +422 -0
  58. package/chunks/{standalone-DflyWtuR.js → standalone-D9k5SCd8.js} +169 -169
  59. package/chunks/{standalone-Cc98Pdr6.js → standalone-DYVYccmY.js} +829 -829
  60. package/chunks/{standalone-CY_kjarf.js → standalone-DaNxWIKn.js} +22 -22
  61. package/chunks/{standalone-wOWRCpdn.js → standalone-Db_HNuWx.js} +48 -48
  62. package/chunks/standalone-DcuE8KBa.js +287 -0
  63. package/chunks/{standalone-BE_ONgiG.js → standalone-I5kRIsp8.js} +76 -76
  64. package/chunks/{standalone-B8ZSqauS.js → standalone-K2OvRAQM.js} +113 -113
  65. package/chunks/{standalone-z0o52o5t.js → standalone-c4CPN6ug.js} +1719 -1718
  66. package/chunks/{standalone-DHRalbVO.js → standalone-iOnJhCvA.js} +312 -312
  67. package/chunks/{standalone-CXY4FpF7.js → standalone-pCrzBiTy.js} +222 -222
  68. package/chunks/standalone-qrZaimgC.js +689 -0
  69. package/chunks/standalone-yqDJ8h3K.js +1012 -0
  70. package/chunks/{table.compiler-COaHE9VD.js → table.compiler-CMH_dtYs.js} +35 -35
  71. package/chunks/{useFieldName-CdnCWzhd.js → useFieldName-BfxBzhhH.js} +1 -1
  72. package/chunks/{utils-DganVptf.js → utils-BdJrEeIQ.js} +3924 -3910
  73. package/chunks/{view-Bzlros43.js → view-Q-_XIrWE.js} +1680 -1680
  74. package/chunks/{visualization-filters-D7i6oh1Z.js → visualization-filters-BwS0xUqs.js} +1705 -1686
  75. package/chunks/{with-html-element-CiIhFEa5.js → with-html-element-D_ooGNWI.js} +3962 -3950
  76. package/definitions.js +2 -2
  77. package/docs/operations/astrato-app-filter-bar.md +1 -1
  78. package/docs/operations/bar.md +30 -1
  79. package/docs/operations/combo.md +30 -1
  80. package/docs/operations/date-picker.md +1 -1
  81. package/docs/operations/distribution-gauge.md +1 -1
  82. package/docs/operations/dot.md +1 -1
  83. package/docs/operations/filter.md +1 -1
  84. package/docs/operations/gauge.md +1 -1
  85. package/docs/operations/heatMap.md +1 -1
  86. package/docs/operations/histogram.md +1 -1
  87. package/docs/operations/iframe.md +1 -1
  88. package/docs/operations/image.md +1 -1
  89. package/docs/operations/index.md +5 -4
  90. package/docs/operations/line.md +30 -1
  91. package/docs/operations/map.md +5274 -0
  92. package/docs/operations/number.md +1 -1
  93. package/docs/operations/pie.md +1 -1
  94. package/docs/operations/radar.md +1 -1
  95. package/docs/operations/sankey.md +1 -1
  96. package/docs/operations/scatter.md +1 -1
  97. package/docs/operations/shape.md +1 -1
  98. package/docs/operations/simpleTextObject.md +1 -1
  99. package/docs/operations/slider.md +1 -1
  100. package/docs/operations/table.md +1 -1
  101. package/docs/operations/tree.md +1 -1
  102. package/docs/operations/treemap.md +1 -1
  103. package/docs/operations/waterfall.md +1 -1
  104. package/docs/operations/word-cloud.md +1 -1
  105. package/getters.js +3 -3
  106. package/index.js +524 -500
  107. package/metadata.js +2 -2
  108. package/operations.js +6 -6
  109. package/package.json +73 -68
  110. package/src/definitions/index.d.ts +1 -7
  111. package/src/definitions/model/definitions/descriptors/descriptor-metadata.d.ts +3 -48
  112. package/src/definitions/model/definitions/schema-registry.d.ts +2 -2
  113. package/src/definitions/model/definitions/schemas/bar.schema.d.ts +1 -1
  114. package/src/definitions/model/definitions/schemas/broad-chart.schema.d.ts +2 -2
  115. package/src/definitions/model/definitions/schemas/common.schema.d.ts +14 -2
  116. package/src/definitions/model/definitions/schemas/index.d.ts +1 -1
  117. package/src/definitions/model/definitions/schemas/line.schema.d.ts +1 -1
  118. package/src/visualization-catalog.d.ts +3 -0
  119. package/styles.css +1 -1
  120. package/chunks/FieldTypeIcon-DrMoGpHJ.js +0 -22
  121. package/chunks/defaults-Dtk7fg3C.js +0 -3
  122. package/chunks/line.compiler-DmHpmQCC.js +0 -198
  123. package/chunks/number.compiler-DQdg6zTy.js +0 -53
  124. package/chunks/standalone-4MsKiqs0.js +0 -355
  125. package/chunks/standalone-B794g9pE.js +0 -1012
  126. package/chunks/standalone-BA2YXyJS.js +0 -422
  127. package/chunks/standalone-BgumbdaJ2.js +0 -357
  128. package/chunks/standalone-Blh4qejk.js +0 -689
  129. package/chunks/standalone-DH0xTEes.js +0 -2
  130. package/chunks/standalone-DcnHjNnC.js +0 -2
  131. package/chunks/standalone-DrHdGkY7.js +0 -762
  132. package/chunks/standalone-c_rROMtx.js +0 -287
  133. package/chunks/standalone-drcFLeN6.js +0 -6
@@ -1,3 +0,0 @@
1
- import { zn as e } from "./visualization-filters-D7i6oh1Z.js";
2
- var t = e;
3
- export { t };
@@ -1,198 +0,0 @@
1
- import { r as e } from "./visualization-filters-D7i6oh1Z.js";
2
- import { A as t, C as n, E as r, S as i, T as a, W as o, _ as s, a as c, c as l, d as u, f as d, g as f, h as p, i as m, k as h, n as g, o as _, r as v, s as y, t as b, u as x, v as S, x as C, y as w } from "./shared-C_2F90xq.js";
3
- import { jp as T, xm as E } from "./handlers-C6CZ0XJA.js";
4
- import { b as D, g as O, v as k, w as A } from "./operations-DKQWuLL7.js";
5
- e();
6
- var j = async (e) => {
7
- let j = T(e);
8
- if (j) return {
9
- issues: [{
10
- code: "invalid_structure",
11
- message: j,
12
- path: []
13
- }],
14
- success: !1
15
- };
16
- let M = o.safeParse(e.definition);
17
- if (!M.success) return {
18
- issues: a(M.error, e.definition),
19
- success: !1
20
- };
21
- let N = E.safeParse(e.baseVSpec);
22
- if (!N.success) return {
23
- issues: [u("invalid_structure", ["baseVSpec"], "Base line vSpec is invalid.")],
24
- success: !1
25
- };
26
- let P = N.data;
27
- if (!S(P, [
28
- "dimensions",
29
- "measures",
30
- "supportingMeasures",
31
- "sortingMeasures"
32
- ])) return {
33
- issues: [u("non_fresh_base_vspec", ["baseVSpec"], "Line definitions require a fresh base vSpec.")],
34
- success: !1
35
- };
36
- let F = M.data, I = [...F.data.dimensions, ...F.data.measures], L = [
37
- ...h(F.data.dimensions, e.availableFields, ["data", "dimensions"], "dimension"),
38
- ...h(F.data.measures, e.availableFields, ["data", "measures"], "measure"),
39
- ...n([{
40
- items: F.data.dimensions,
41
- path: ["data", "dimensions"]
42
- }, {
43
- items: F.data.measures,
44
- path: ["data", "measures"]
45
- }]),
46
- ...t(F.filterGroup, e.availableFields),
47
- ...C(F.sorting, I.map((e) => e.ref)),
48
- ...i(F.presentation?.coloring, F.data.dimensions.map((e) => e.ref), F.data.measures.map((e) => e.ref))
49
- ];
50
- if (L.length) return {
51
- issues: L,
52
- success: !1
53
- };
54
- let R = {
55
- state: x(e, P),
56
- success: !0
57
- };
58
- for (let [e, t] of F.data.dimensions.entries()) {
59
- if ("issue" in R) return {
60
- issues: [R.issue],
61
- success: !1
62
- };
63
- R = await b(R.state, t, "dimension", O.ADD_DIMENSION, { key: t.fieldKey }, [
64
- "data",
65
- "dimensions",
66
- e
67
- ]);
68
- }
69
- for (let [t, n] of F.data.measures.entries()) {
70
- if ("issue" in R) return {
71
- issues: [R.issue],
72
- success: !1
73
- };
74
- R = await b(R.state, n, "measure", O.ADD_MEASURE, r(n, e.availableFields), [
75
- "data",
76
- "measures",
77
- t
78
- ]);
79
- }
80
- if ("issue" in R || (R = await v(R.state, F.data.dimensions, O.UPDATE_DIMENSION, ["data", "dimensions"]), "issue" in R) || (R = await y(R.state, F.data.dimensions, "setDimensionTemporalGrouping", ["data", "dimensions"]), "issue" in R) || (R = await c(R.state, F.data.dimensions, {
81
- formatString: "setDimensionFormatString",
82
- formatType: "setDimensionFormatType"
83
- }, ["data", "dimensions"]), "issue" in R) || (R = await c(R.state, F.data.measures, {
84
- currency: "setMeasureCurrency",
85
- currencyIsPrefix: "setMeasureCurrencyIsPrefix",
86
- formatString: "setMeasureFormatString",
87
- formatType: "setMeasureFormatType",
88
- negativeType: "setMeasureNegativeType"
89
- }, ["data", "measures"]), "issue" in R)) return {
90
- issues: [R.issue],
91
- success: !1
92
- };
93
- let z = R.state, B = F.data.measures.flatMap((e) => e.axis ? [{
94
- name: O.CHANGE_MEASURE_AXIS,
95
- payload: {
96
- ...w(z.resolvedRefs[e.ref]),
97
- secondaryAxis: e.axis === "secondary"
98
- }
99
- }] : []);
100
- if (R = await p(R.state, B, ["data", "measures"]), "issue" in R) return {
101
- issues: [R.issue],
102
- success: !1
103
- };
104
- let V = R.state;
105
- if (R = await p(V, F.data.measures.flatMap((e) => e.dataPointShape === void 0 ? [] : [{
106
- name: O.SET_MEASURE_SHAPE,
107
- payload: {
108
- ...w(V.resolvedRefs[e.ref]),
109
- shape: e.dataPointShape
110
- }
111
- }]), ["data", "measures"]), "issue" in R || (R = await m(R.state, F.filterGroup), "issue" in R) || (R = await _(R.state, F.sorting, O.CHANGE_SORT_ORDER_AND_DIRECTION, O.TOGGLE_SORTING_ITEM), "issue" in R)) return {
112
- issues: [R.issue],
113
- success: !1
114
- };
115
- let H = [];
116
- F.limiting?.queryLimit !== void 0 && H.push({
117
- name: O.SET_QUERY_LIMIT,
118
- payload: F.limiting.queryLimit
119
- });
120
- let U = F.presentation, W = s(U?.axes);
121
- if (W) return {
122
- issues: [W],
123
- success: !1
124
- };
125
- if (U?.orientation !== void 0 && H.push({
126
- name: O.SET_ORIENTATION,
127
- payload: U.orientation
128
- }), U?.legend && H.push(...d(R.state.vSpec, U.legend)), U?.dataLabels) {
129
- let e = U.dataLabels, t = R.state;
130
- F.data.measures.forEach((n) => {
131
- let r = w(t.resolvedRefs[n.ref]);
132
- H.push({
133
- name: A.SET_MEASURE_DATA_LABELS_SHOW,
134
- payload: {
135
- ...r,
136
- show: e.visible
137
- }
138
- }), e.density && H.push({
139
- name: A.SET_MEASURE_DATA_LABEL_DENSITY,
140
- payload: {
141
- ...r,
142
- density: e.density
143
- }
144
- });
145
- });
146
- }
147
- Object.entries(U?.axes ?? {}).forEach(([e, t]) => {
148
- t && (t.titleVisible !== void 0 && H.push({
149
- name: O.SET_SHOW_AXIS_TITLE,
150
- payload: {
151
- axisName: e,
152
- showAxisName: t.titleVisible
153
- }
154
- }), t.title !== void 0 && H.push({
155
- name: O.SET_AXIS_TITLE,
156
- payload: {
157
- axisName: e,
158
- axisTitle: t.title
159
- }
160
- }), t.labelsVisible !== void 0 && H.push({
161
- name: O.SET_SHOW_AXIS_LABELS,
162
- payload: {
163
- axisName: e,
164
- showLabels: t.labelsVisible
165
- }
166
- }), t.ticksVisible !== void 0 && H.push({
167
- name: O.SET_SHOW_AXIS_TICKS,
168
- payload: {
169
- axisName: e,
170
- showAxisTicks: t.ticksVisible
171
- }
172
- }), t.lineVisible !== void 0 && H.push({
173
- name: O.SET_SHOW_AXIS_LINE,
174
- payload: {
175
- axisName: e,
176
- showAxisLine: t.lineVisible
177
- }
178
- }), H.push(...l(e, t)), "scale" in t && t.scale !== void 0 && H.push({
179
- name: k.SET_AXIS_SCALE,
180
- payload: {
181
- axisName: e,
182
- scale: t.scale
183
- }
184
- }));
185
- });
186
- let G = U?.axes?.primaryMeasure?.bands;
187
- return G && H.push({
188
- name: D.SET_MEASURE_AXIS_BANDS,
189
- payload: { bands: G }
190
- }), R = await p(R.state, H, ["presentation"]), "issue" in R ? {
191
- issues: [R.issue],
192
- success: !1
193
- } : (R = await g(R.state, F.presentation?.coloring), "issue" in R ? {
194
- issues: [R.issue],
195
- success: !1
196
- } : f(R.state, E));
197
- };
198
- export { j as compileLineVisualizationDefinition };
@@ -1,53 +0,0 @@
1
- import "./visualization-filters-D7i6oh1Z.js";
2
- import { A as e, E as t, H as n, O as r, T as i, a, d as o, g as s, i as c, t as l, u, v as d } from "./shared-C_2F90xq.js";
3
- import { jp as f, ym as p } from "./handlers-C6CZ0XJA.js";
4
- import { h as m } from "./operations-DKQWuLL7.js";
5
- var h = async (h) => {
6
- let g = f(h);
7
- if (g) return {
8
- issues: [{
9
- code: "invalid_structure",
10
- message: g,
11
- path: []
12
- }],
13
- success: !1
14
- };
15
- let _ = n.safeParse(h.definition);
16
- if (!_.success) return {
17
- issues: i(_.error, h.definition),
18
- success: !1
19
- };
20
- let v = p.safeParse(h.baseVSpec);
21
- if (!v.success) return {
22
- issues: [o("invalid_structure", ["baseVSpec"], "Base number vSpec is invalid.")],
23
- success: !1
24
- };
25
- let y = v.data;
26
- if (!d(y, ["measures", "supportingMeasures"])) return {
27
- issues: [o("non_fresh_base_vspec", ["baseVSpec"], "Number definitions require a fresh base vSpec.")],
28
- success: !1
29
- };
30
- let b = _.data, x = [...r(b.data.measure, h.availableFields, ["data", "measure"], "measure"), ...e(b.filterGroup, h.availableFields)];
31
- if (x.length) return {
32
- issues: x,
33
- success: !1
34
- };
35
- let S = await l(u(h, y), b.data.measure, "measure", m.ADD_MEASURE, t(b.data.measure, h.availableFields, { role: "number-measure" }), ["data", "measure"]);
36
- return "issue" in S || (S = await a(S.state, [{
37
- ...b.data.measure,
38
- path: ["data", "measure"]
39
- }], {
40
- currency: "setMeasureCurrency",
41
- currencyIsPrefix: "setMeasureCurrencyIsPrefix",
42
- formatString: "setMeasureFormatString",
43
- formatType: "setMeasureFormatType",
44
- negativeType: "setMeasureNegativeType"
45
- }, ["data", "measure"]), "issue" in S) ? {
46
- issues: [S.issue],
47
- success: !1
48
- } : (S = await c(S.state, b.filterGroup), "issue" in S ? {
49
- issues: [S.issue],
50
- success: !1
51
- } : s(S.state, p));
52
- };
53
- export { h as compileNumberVisualizationDefinition };
@@ -1,355 +0,0 @@
1
- import { o as e, r as t } from "./rolldown-runtime-DleVn1XH.js";
2
- import { Fc as n, Ks as r, Lo as i, Oa as a, Qa as o, Qr as s, Ys as c, sa as l, yc as u, za as d } from "./visualization-filters-D7i6oh1Z.js";
3
- import { Ht as f, N as p, Ut as m, ci as h, jt as g, zr as _ } from "./utils-DganVptf.js";
4
- import { g_ as v } from "./handlers-C6CZ0XJA.js";
5
- import { n as y } from "./label-format-type-C46pzgx7.js";
6
- import "./logger-DdZpR7xZ.js";
7
- import { At as b, Ct as x, L as S, Mt as C, N as ee, Qt as w, Ut as T, _ as E, bn as D, fn as te, gn as O, i as ne, kt as re, mn as k, on as ie, v as A } from "./escobar-CvEV2ES1.js";
8
- import { t as j } from "./coloring-BtnPiQ_o.js";
9
- import { t as M } from "./set-coloring-datafield-B3uIS1Pe.js";
10
- var N = /* @__PURE__ */ e(h()), P = {
11
- outerRadius: .95,
12
- cornerRadius: 10,
13
- additionalTextAnchorHeight: 50,
14
- barMinWidth: 1,
15
- barMaxWidth: 200,
16
- minScaleValue: 0,
17
- maxScaleValue: 100,
18
- scalePadding: 1,
19
- backgroundBarOpacity: .2,
20
- barWidthRadiusPadding: .2,
21
- maxBarWidthOfRadius: .15,
22
- gaugeCollectionKey: "Gauge-Collection"
23
- }, F = (e) => e.gaugeSettings?.barMode ?? !1, I = (e) => e.gaugeSettings?.comparisonMode ?? !1, ae = (e) => {
24
- let { coloring: t } = e || {};
25
- return t?.type === u.Categorical || t?.type === u.Single ? b(e, []) ?? "" : C(e) ?? "";
26
- }, L = (e, t, r) => {
27
- let a = { ...re(M(e, ae(e) ?? ""), t, {}) }, o = e.gaugeSettings?.barPadding ?? O.scale.padding;
28
- a = ee(e, a, o);
29
- let c = e.dimensions.filter(s), l = e.measures.filter(s).filter((e) => e.role === d.GAUGE_VALUE);
30
- return !c.length && F(e) ? a.onlyMeasures = {
31
- data: I(e) ? { extract: { field: l[0] ? n(l[0].dataItem) : "" } } : l.map((e) => n(e.dataItem)),
32
- type: k.Band,
33
- padding: o
34
- } : I(e) || (a.onlyMeasures = {
35
- data: { fields: l.map((e) => n(e.dataItem)) },
36
- include: [0],
37
- expand: .05
38
- }), F(e) && (a.barScale = {
39
- min: P.minScaleValue - P.scalePadding,
40
- max: P.maxScaleValue + P.scalePadding,
41
- invert: e.gaugeSettings?.orientation === i.Vertical
42
- }), {
43
- ...r,
44
- scales: a
45
- };
46
- }, R = (e, t, r, i, a) => {
47
- if (!a) return r;
48
- let o = e.dimensions.filter(s), c = e.measures.filter(s), l = A((e.supportingMeasures ?? []).filter(s)), u = c.filter((e) => e.role === d.GAUGE_VALUE), f = o[0], p = u[0], { targetType: m } = e.gaugeSettings ?? {}, h = F(e), g = f?.dataItem ?? p?.dataItem;
49
- if (!g) return r;
50
- let _ = [], v = P.minScaleValue;
51
- if (I(e) ? _.push(...B(e, g, a, l)) : f ? _.push(...z(e, g, a, l)) : _.push(...V(e, a, l)), h) {
52
- let t = n(p.dataItem), r = {
53
- field: n(g),
54
- props: {
55
- actual: { field: t },
56
- color: t,
57
- start: v,
58
- end: P.maxScaleValue,
59
- background: !0,
60
- ...l
61
- }
62
- };
63
- (m === y.Data || m === y.Manual) && (r.props ??= {}, r.props.target = W(e, a)), c.forEach((e) => {
64
- r.props ??= {};
65
- let t = `measure-${n(e.dataItem)}`;
66
- r.props[t] = { field: n(e.dataItem) };
67
- }), _.push(r);
68
- }
69
- let b = [{
70
- key: P.gaugeCollectionKey,
71
- data: { extract: _ }
72
- }];
73
- return {
74
- ...r,
75
- collections: b
76
- };
77
- }, z = (e, t, r, i) => {
78
- let a = e.measures.filter(s), o = a.filter((e) => e.role === d.GAUGE_VALUE), c = a.filter((e) => e.role === d.GAUGE_TARGET), l = o[0], u = c[0], { targetType: f } = e.gaugeSettings, p = F(e), m = [], h = n(l.dataItem);
79
- return p || m.push({
80
- field: n(t),
81
- props: {
82
- actual: { field: h },
83
- [h]: { field: h },
84
- color: h,
85
- ...i
86
- }
87
- }), m.push({
88
- field: n(t),
89
- props: {
90
- actual: { field: h },
91
- start: p ? P.minScaleValue : void 0,
92
- end: p ? { getValue: H(e, r) } : void 0,
93
- [h]: { field: h },
94
- color: h,
95
- ...i
96
- }
97
- }), (f === y.Data || f === y.Manual) && m.forEach((t) => {
98
- t.props ??= {}, t.props.target = W(e, r), u && f === y.Data && (t.props[n(u.dataItem)] = { field: n(u.dataItem) });
99
- }), m;
100
- }, B = (e, t, r, i) => {
101
- let a = F(e), o = e.measures.filter(s).filter((e) => e.role === d.GAUGE_VALUE), c = o.reduce((e, t) => {
102
- let r = n(t.dataItem);
103
- return e[r] = { field: r }, e;
104
- }, {});
105
- return o.map((o, s) => {
106
- let l = n(o.dataItem);
107
- return {
108
- field: n(t),
109
- props: {
110
- measure: { field: l },
111
- color: l,
112
- start: a ? P.minScaleValue : void 0,
113
- end: a ? { getValue: H(e, r, s) } : void 0,
114
- ...c,
115
- ...i
116
- }
117
- };
118
- });
119
- }, V = (e, t, r) => {
120
- let i = F(e), a = [];
121
- return e.measures.filter(s).filter((e) => e.role === d.GAUGE_VALUE).forEach((o) => {
122
- let s = n(o.dataItem), c = t[0].items[0][s], l = W(e, t, o), u = [];
123
- u.push({
124
- field: s,
125
- props: {
126
- measureValue: s,
127
- measure: { field: s },
128
- actual: { field: s },
129
- color: s,
130
- start: i ? P.minScaleValue : void 0,
131
- end: i && typeof c == "number" && typeof l == "number" ? U(c, l) : void 0,
132
- [s]: { field: s },
133
- ...r
134
- }
135
- }), u.push({
136
- field: s,
137
- props: {
138
- measureValue: s,
139
- measure: { field: s },
140
- actual: { field: s },
141
- color: s,
142
- start: i ? P.minScaleValue : void 0,
143
- end: i ? P.maxScaleValue : void 0,
144
- background: !0,
145
- [s]: { field: s },
146
- ...r
147
- }
148
- }), (e.gaugeSettings?.targetType ?? y.Auto) !== y.Auto && u.forEach((e) => {
149
- e.props ??= {}, e.props.target = l;
150
- }), a.push(...u);
151
- }), a;
152
- }, H = (e, t, r) => {
153
- let i = e.measures.filter(s), a = i.filter((e) => e.role === d.GAUGE_VALUE), o = i.filter((e) => e.role === d.GAUGE_TARGET), c = a[0], l = o[0];
154
- return (i, o, s) => {
155
- if (!s) return P.minScaleValue;
156
- let u = a.find((e, t) => t === r), d = u && s[n(u.dataItem)];
157
- if (typeof d == "number" && d < 0) return P.minScaleValue;
158
- let f = s[n(c.dataItem)], p;
159
- if (p = e.gaugeSettings?.targetType === y.Data ? s[n(l?.dataItem)] : W(e, t), typeof f != "number" || typeof p != "number") return P.minScaleValue;
160
- if (!I(e) || r === void 0) return U(f, p);
161
- let m = 0, h = 0;
162
- return a.forEach((e, t) => {
163
- let i = Math.max(0, s[n(e.dataItem)]);
164
- m += i, t <= r && (h += i);
165
- }), h / m * P.maxScaleValue;
166
- };
167
- }, U = (e, t) => {
168
- let n = t ? Math.max(0, e) / t : 1;
169
- return Math.min(n, 1) * P.maxScaleValue;
170
- }, W = (e, t, r) => {
171
- let { targetType: i, targetValue: a } = e.gaugeSettings, o = e.measures.filter(s), c = o.filter((e) => e.role === d.GAUGE_TARGET)[0];
172
- return i === y.Auto ? t[0].items.map((e) => o.map((t) => e[n(t.dataItem)])).reduce((e, t) => Math.max(...t, e), 0) * (1 + O.scale.padding) : c && i === y.Data ? { field: n(c.dataItem) } : r && i === y.PerMeasure ? r.targetValue ?? 0 : i === y.Manual ? a ?? 0 : 0;
173
- }, G = {
174
- Foreground: "foreground",
175
- Background: "background"
176
- }, K = (e, t, n = 0) => `${e}-${t}-${n}`, q = (e) => Math.min(P.maxBarWidthOfRadius, P.outerRadius / e), oe = (e, t, r) => {
177
- let i = e.measures.filter(s).filter((e) => e.role === d.GAUGE_VALUE);
178
- return (e) => r !== void 0 && e.measure?.source?.field !== n(i[r]?.dataItem) ? !1 : e.background?.value ? t === G.Background : t === G.Foreground;
179
- }, J = (e, t) => !t || e.coloring?.type === u.Single ? !1 : !I(e) || e.coloring?.type === u.Categorical, Y = (e, t, r, i, a, o, c, l) => {
180
- let u = r.dimensions.filter(s)[0], f = new j(r, i, t?.[0]?.itemsNotAffectedByFiltering), p = f.getColorDefinition(J(r, u) ? { ref: f.MAIN_FIELD } : {}), m = (e, t = 0) => !I(r) && t === 1 || o && I(r) ? "transparent" : typeof p == "function" ? p(e) : p, h = q(c), g = Number(r.gaugeSettings?.size), _ = Number(r.gaugeSettings?.startAngle), v = isNaN(g) ? 360 : g ?? 360, b = isNaN(_) ? 0 : _ ?? 0, x = b + v, S = b / 180 * Math.PI, C = x / 180 * Math.PI;
181
- return {
182
- key: K(D.Pie, o ? G.Background : G.Foreground, a),
183
- type: D.Pie,
184
- animations: {
185
- enabled: !0,
186
- presetId: "pie-chart"
187
- },
188
- data: {
189
- collection: P.gaugeCollectionKey,
190
- filter: (t) => {
191
- if (!u) {
192
- let e = r.measures.filter(s).filter((e) => e.role === d.GAUGE_VALUE);
193
- return I(r) || e[a] && t.measure?.source?.field === n(e[a].dataItem);
194
- }
195
- return `${t.value}` == `${e[n(u.dataItem)]}`;
196
- }
197
- },
198
- settings: {
199
- startAngle: S,
200
- endAngle: C,
201
- slice: {
202
- cornerRadius: r.gaugeSettings?.cornerRadius ?? 10,
203
- outerRadius: P.outerRadius - a * h,
204
- innerRadius: P.outerRadius - (a + (1 - P.barWidthRadiusPadding)) * h,
205
- fill: m,
206
- strokeWidth: .1,
207
- opacity: o ? P.backgroundBarOpacity : 1,
208
- arc: (e, t = 0) => {
209
- if (o) return +(t === 0);
210
- if (I(r)) return e.datum.measure.value;
211
- if ((r.gaugeSettings.targetType ?? y.Auto) !== y.Auto) return t === 0 ? e.datum.actual.value : Number(e.datum.target.value) - Number(e.datum.actual.value);
212
- {
213
- let n = e.resources.scale("onlyMeasures"), r = Number(n(e.datum.actual.value)) || 0;
214
- return t === 0 ? r : 1 - r;
215
- }
216
- }
217
- }
218
- },
219
- brush: w([""], l, { overwriteOpacity: o ? P.backgroundBarOpacity : void 0 })
220
- };
221
- }, X = (e, t, r, o, c, l) => {
222
- let u = e.dimensions.filter(s)[0], d = new j(e, t, r?.[0]?.itemsNotAffectedByFiltering), f;
223
- f = o === G.Background && e.gaugeSettings?.backgroundBarColor ? e.gaugeSettings?.backgroundBarColor : d.getColorDefinition(J(e, u) ? { ref: d.MAIN_FIELD } : {}, !e.gaugeSettings?.backgroundBarColor && o === G.Background ? P.backgroundBarOpacity : void 0);
224
- let p = u ? n(u.dataItem) : "onlyMeasures", m = !u && !I(e) ? "measureValue" : void 0, h = {
225
- key: K(D.Box, o, c),
226
- type: D.Box,
227
- animations: { enabled: !0 },
228
- data: {
229
- collection: P.gaugeCollectionKey,
230
- filter: oe(e, o, c)
231
- },
232
- settings: {
233
- orientation: e.gaugeSettings.orientation ?? i.Horizontal,
234
- major: {
235
- scale: p,
236
- ref: m
237
- },
238
- minor: { scale: "barScale" },
239
- box: {
240
- minWidthPx: 2,
241
- fill: f,
242
- rx: e.gaugeSettings?.barRadius ?? 0
243
- }
244
- },
245
- brush: w([""], l, { disable: { triggers: o === G.Foreground } })
246
- };
247
- if (e.gaugeSettings?.strokeEnabled) {
248
- let n = h.settings;
249
- n && (n.box.stroke = e.gaugeSettings?.strokeColor || t.colors.brandColors[0], n.box.strokeWidth = e.gaugeSettings?.strokeWidth);
250
- } else {
251
- let e = h.settings;
252
- e && (e.box.stroke = a.transparent);
253
- }
254
- return h;
255
- }, se = (e, t, n, r, i, a) => {
256
- if (!i) return n;
257
- let o = [];
258
- return o = F(e) ? Z(e, t, r, i, a) : ce(e, t, r, i, a), {
259
- ...n,
260
- components: [...n.components, ...o]
261
- };
262
- }, ce = (e, t, n, r, i) => {
263
- let a = e.dimensions.filter(s), o = e.measures.filter(s).filter((e) => e.role === d.GAUGE_VALUE);
264
- return !a[0] && !I(e) ? o.map((n, i) => [Y(r[0].items[0], r, e, t, i, !0, o.length), Y(r[0].items[0], r, e, t, i, !1, o.length)]).reduce((e, t) => e.concat(t), []) : r[0].items.map((n, a) => [Y(n, r, e, t, a, !0, r[0].items.length, i), Y(n, r, e, t, a, !1, r[0].items.length, i)]).reduce((e, t) => e.concat(t), []);
265
- }, Z = (e, t, n, r, i) => {
266
- let a = e.dimensions.filter(s), o = e.measures.filter(s).filter((e) => e.role === d.GAUGE_VALUE), c = a[0], l = [];
267
- if (I(e)) for (let n = o.length - 1; n >= 0; n--) l.push(X(e, t, r, G.Foreground, n, i));
268
- else if (c) l = [X(e, t, r, G.Background, void 0, i), X(e, t, r, G.Foreground, void 0, i)];
269
- else for (let n = o.length - 1; n >= 0; n--) l.push(X(e, t, r, G.Background, n)), l.push(X(e, t, r, G.Foreground, n));
270
- return l;
271
- }, le = (e, t, n) => {
272
- let r = e.dimensions.filter(s), i = e.measures.filter(s).filter((e) => e.role === d.GAUGE_VALUE);
273
- if (!e.gaugeSettings?.barMode || !r.length && e.gaugeSettings?.comparisonMode) return n;
274
- let a = [];
275
- return r.length ? (e.gaugeSettings?.showDimensionLabels !== !1 && r[0] && a.push(Q(!1, t, r[0].formatter, "dimension", void 0, e.gaugeSettings)), !e.gaugeSettings?.comparisonMode && e.gaugeSettings?.showValueLabels !== !1 && i[0] && a.push(Q(!0, t, i[0].formatter, "value", void 0, e.gaugeSettings))) : e.gaugeSettings?.showValueLabels !== !1 && i.forEach((n, r) => {
276
- a.push(Q(!0, t, n.formatter, String(r), r, e.gaugeSettings));
277
- }), {
278
- ...n,
279
- components: [...n.components, ...a]
280
- };
281
- }, Q = (e, t, n, r, a, o) => {
282
- let s = +!!e, c = {
283
- type: "bar",
284
- settings: {
285
- direction: o?.orientation === i.Vertical ? "up" : "right",
286
- fontSize: ie(o?.labelFontSize),
287
- fontFamily: t.fonts.general.fontFamily,
288
- labels: [{
289
- label: (t) => t.data ? e ? ue(t.data.actual.value, n, t) : `${m(n, t.data?.label)}` : "",
290
- placements: e ? [{
291
- position: v.Outside,
292
- fill: "#000",
293
- justify: 0
294
- }, {
295
- position: v.Inside,
296
- fill: "#fff",
297
- justify: s
298
- }] : [{
299
- position: v.Inside,
300
- fill: "#fff",
301
- justify: s
302
- }]
303
- }]
304
- }
305
- };
306
- return {
307
- type: D.Labels,
308
- key: `gauge-bar-labels-${r}`,
309
- layout: { displayOrder: T.Labels },
310
- settings: { sources: [{
311
- component: K(D.Box, G.Foreground, a),
312
- selector: te.Rect,
313
- strategy: c
314
- }] },
315
- animations: {
316
- enabled: !0,
317
- presetId: "chart-labels"
318
- }
319
- };
320
- }, ue = (e, t, n) => e === null ? "-" : typeof t != "string" && o(t) ? f(t.format, t)(e, void 0, n.data) : `${m(t, e)}`, de = (e, t, n, r) => x(e, t, n, r), fe = (e, t, n, r, i) => {
321
- if (!i) return n;
322
- let a = e.dimensions.filter(s), o = e.measures.filter(s).filter((e) => e.role === d.GAUGE_VALUE), c = a[0], l = F(e), u = I(e), f = l ? D.Box : D.Pie, p = l && !u ? G.Background : G.Foreground, m = ((l || !c ? o : i[0]?.items) || []).map((e, t) => K(f, p, t));
323
- return S(e, t, n, {
324
- filter: (e) => e.filter((e) => m.findIndex((t) => t === e.key) !== -1),
325
- placement: {
326
- type: l ? "bounds" : "slice",
327
- area: "target"
328
- }
329
- });
330
- }, pe = class extends E {
331
- constructor() {
332
- super([
333
- R,
334
- L,
335
- se,
336
- le,
337
- de,
338
- fe
339
- ]);
340
- }
341
- preCompile(e) {
342
- if (!(e.measures ?? []).filter(s).filter((e) => e.role === d.GAUGE_VALUE).length) throw Error("Charts w/o measures are not supported ATM.");
343
- }
344
- }, me = _(), $ = g(({ vSpec: e, vTheme: t, data: n, elementSize: i, vizProperties: a }) => {
345
- let o = p(), [s] = (0, N.useState)(() => new pe());
346
- if (!e || !(c(e) || r(e)) || !i) return null;
347
- let u = t || l, d = s.compile(e, u, n, i, a, e.type, o);
348
- return d ? /* @__PURE__ */ (0, me.jsx)(ne, {
349
- config: a,
350
- definition: d,
351
- size: i,
352
- vSpec: e
353
- }) : null;
354
- }), he = /* @__PURE__ */ t({ GaugeChart: () => $ });
355
- export { $ as n, he as t };