@astrato-io/visualizations 0.10.0 → 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 (138) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/README.md +22 -4
  3. package/THIRD_PARTY_NOTICES.md +494 -0
  4. package/VISUALIZATION_DEFINITIONS.md +59 -145
  5. package/chunks/{Button-CCF851ea.js → Button-CPG4WX8X.js} +3 -3
  6. package/chunks/{CircularProgress-yupH6YWs.js → CircularProgress-PSLW8HmD.js} +12 -12
  7. package/chunks/FieldTypeIcon-5k2bkqd0.js +22 -0
  8. package/chunks/{LinearProgress-CyFjN4px.js → LinearProgress-KQ2EQlGL.js} +16 -16
  9. package/chunks/{MenuOption-CQpT79AP.js → MenuOption-B-6K7kks.js} +151 -151
  10. package/chunks/{Title-C-p4ZarD.js → Title-BmvwZYkh.js} +32 -32
  11. package/chunks/{_createAggregator-BF4qG9XK.js → _createAggregator-CFmH6gUN.js} +11 -11
  12. package/chunks/{app-filter-bar.compiler-8fxCo2q7.js → app-filter-bar.compiler-BY5-T16I.js} +8 -8
  13. package/chunks/{bar-layout-DStC-GNV.js → bar-layout-BNou0dZF.js} +2 -2
  14. package/chunks/{bar.compiler-CQAu8KL8.js → bar.compiler-BkhO7sDd.js} +55 -53
  15. package/chunks/{builder-CScg1TOS.js → builder-CNjuqD2z.js} +107 -56
  16. package/chunks/category-axis-D1OVyMrr.js +20 -0
  17. package/chunks/{coloring-9jU3s_-p.js → coloring-BOiP0rmn.js} +54 -54
  18. package/chunks/{createSimplePaletteValueFilter-C4hZpCdn.js → createSimplePaletteValueFilter-BkgQ7MFE.js} +166 -166
  19. package/chunks/defaults-B5_8S-J-.js +3 -0
  20. package/chunks/{definitions-C4grxhye.js → definitions-AS9GcavE.js} +263 -242
  21. package/chunks/{escobar-CjirINHP.js → escobar-cQ1eQ64G.js} +8528 -8461
  22. package/chunks/{extend-preset-D-l9u_we.js → extend-preset-BlCbcXKR.js} +421 -421
  23. package/chunks/{filter.compiler-lji2Acgn.js → filter.compiler-CI7dDNM1.js} +12 -12
  24. package/chunks/{filtering-C1zakrrX.js → filtering-Dwi7hDPZ.js} +263 -263
  25. package/chunks/handlers-C63NVo7i.js +15433 -0
  26. package/chunks/{icon-picker-styles-Bj80ZUBK.js → icon-picker-styles-CBlxEu3s.js} +8 -8
  27. package/chunks/{isEqual-Ch9OEye3.js → isEqual-BdHo6wqq.js} +1 -1
  28. package/chunks/{isFocusVisible-CgMP0qkR.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-CKRjhSHQ.js → logger-Bc-DqDM_.js} +72 -72
  32. package/chunks/{lookup-BWllin0q.js → lookup-B3tWH2hX.js} +1 -0
  33. package/chunks/{map.compiler-CKzorLgK.js → map.compiler-CRO6XpdI.js} +43 -45
  34. package/chunks/measure-format-default-B6ghxih7.js +22 -0
  35. package/chunks/{metadata-Bb9pTXrq.js → metadata-CtkvZEhS.js} +1 -1
  36. package/chunks/number.compiler-kV4lobCZ.js +57 -0
  37. package/chunks/{operations-DZoY50VX.js → operations-COl9wgqi.js} +9893 -9831
  38. package/chunks/{range-D1BTmFMp.js → range-CMJ5yc5Z.js} +2 -2
  39. package/chunks/{react-dom-Dgv2azN2.js → react-dom-BjsCbYHq.js} +76 -76
  40. package/chunks/{render-wrappers-_P3xwu5A.js → render-wrappers-DFHi3Wkr.js} +1 -1
  41. package/chunks/{requirements-NHNrR8Ie.js → requirements-C5YLmHKe.js} +251 -227
  42. package/chunks/{shared-UitWpq1J.js → shared-DyqxOie0.js} +290 -278
  43. package/chunks/standalone-06i1wmIX.js +6 -0
  44. package/chunks/{standalone-DtBk_iUz.js → standalone-9jrQ3zJT.js} +10 -10
  45. package/chunks/standalone-B6zUvxNQ.js +357 -0
  46. package/chunks/{standalone-Bnnr87pc.js → standalone-BYK2U0Vd.js} +418 -679
  47. package/chunks/standalone-Be5APcVv.js +762 -0
  48. package/chunks/standalone-Bp4G3MDx.js +396 -0
  49. package/chunks/{standalone-CbPk8bKn.js → standalone-BrjtMIdd.js} +132 -132
  50. package/chunks/{standalone-BOzHA_d4.js → standalone-Bsfz5vnJ.js} +57 -57
  51. package/chunks/standalone-BuXpKMnc.js +2 -0
  52. package/chunks/standalone-CIjNYyya.js +8378 -0
  53. package/chunks/{standalone-B0U6c3su.js → standalone-CS5VGoja.js} +358 -358
  54. package/chunks/standalone-CUGt2FUF.js +2 -0
  55. package/chunks/{standalone-BapqaniK.js → standalone-ChfEHb28.js} +2299 -1072
  56. package/chunks/standalone-CnF2OYLQ.js +355 -0
  57. package/chunks/standalone-CznEEiq3.js +422 -0
  58. package/chunks/{standalone-Ck63MZzj.js → standalone-D9k5SCd8.js} +165 -165
  59. package/chunks/{standalone-CRdDZYeM.js → standalone-DYVYccmY.js} +855 -855
  60. package/chunks/{standalone-CVknVdUC.js → standalone-DaNxWIKn.js} +27 -27
  61. package/chunks/{standalone-swGs70tD.js → standalone-Db_HNuWx.js} +50 -50
  62. package/chunks/standalone-DcuE8KBa.js +287 -0
  63. package/chunks/{standalone-U0WJwFlG.js → standalone-I5kRIsp8.js} +97 -97
  64. package/chunks/{standalone-BBu90BhK.js → standalone-K2OvRAQM.js} +125 -125
  65. package/chunks/{standalone-DCFY1MAV.js → standalone-c4CPN6ug.js} +4634 -4633
  66. package/chunks/{standalone-ByKKqT5L.js → standalone-iOnJhCvA.js} +302 -302
  67. package/chunks/standalone-pCrzBiTy.js +773 -0
  68. package/chunks/standalone-qrZaimgC.js +689 -0
  69. package/chunks/standalone-yqDJ8h3K.js +1012 -0
  70. package/chunks/{table.compiler-OWSx5MOq.js → table.compiler-CMH_dtYs.js} +29 -29
  71. package/chunks/{useFieldName-B8iCYyw1.js → useFieldName-BfxBzhhH.js} +1 -1
  72. package/chunks/{utils-3Igg6xmO.js → utils-BdJrEeIQ.js} +4037 -4015
  73. package/chunks/{view-DdMLZySj.js → view-Q-_XIrWE.js} +1615 -1615
  74. package/chunks/{visualization-filters-CzvFHE6M.js → visualization-filters-BwS0xUqs.js} +1723 -1693
  75. package/chunks/{with-html-element-DOfkR3C1.js → with-html-element-D_ooGNWI.js} +4006 -3994
  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 +48 -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 +528 -504
  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 -1
  111. package/src/definitions/model/definitions/descriptors/descriptor-metadata.d.ts +34 -53
  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/definitions/model/definitions/types/compilation.types.d.ts +4 -1
  119. package/src/types.d.ts +28 -28
  120. package/src/visualization-catalog.d.ts +3 -0
  121. package/styles.css +1 -1
  122. package/chunks/FieldTypeIcon-D_MzsdfY.js +0 -22
  123. package/chunks/defaults-cyNhn37t.js +0 -3
  124. package/chunks/handlers-ZviIUC-j.js +0 -15387
  125. package/chunks/line.compiler-De5fiKuR.js +0 -198
  126. package/chunks/number.compiler-CaTmJkmi.js +0 -53
  127. package/chunks/standalone-BEekPuA12.js +0 -357
  128. package/chunks/standalone-BR2JuRIC.js +0 -422
  129. package/chunks/standalone-BwJqDj2Z.js +0 -396
  130. package/chunks/standalone-CRfDOO1x.js +0 -287
  131. package/chunks/standalone-DZDGX3aa.js +0 -518
  132. package/chunks/standalone-DhfgeJIk.js +0 -1012
  133. package/chunks/standalone-DibjA73M.js +0 -6
  134. package/chunks/standalone-DxBAyqAu.js +0 -772
  135. package/chunks/standalone-KMQPsNsq.js +0 -2
  136. package/chunks/standalone-MBLSvsrY.js +0 -2
  137. package/chunks/standalone-wgFAVnnm.js +0 -355
  138. package/chunks/standalone-xGV0dqPV.js +0 -689
@@ -1,198 +0,0 @@
1
- import { r as e } from "./visualization-filters-CzvFHE6M.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-UitWpq1J.js";
3
- import { Ap as T, bm as E } from "./handlers-ZviIUC-j.js";
4
- import { b as D, g as O, v as k, w as A } from "./operations-DZoY50VX.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-CzvFHE6M.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-UitWpq1J.js";
3
- import { Ap as f, vm as p } from "./handlers-ZviIUC-j.js";
4
- import { h as m } from "./operations-DZoY50VX.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,357 +0,0 @@
1
- import { o as e } from "./rolldown-runtime-DleVn1XH.js";
2
- import { Fo as t, Pc as n, Qr as r, Ra as i, cl as a, hc as o, in as s, oa as c, rc as l, rr as u, vc as d } from "./visualization-filters-CzvFHE6M.js";
3
- import { N as f, ci as p, jt as m, s as h, zr as g } from "./utils-3Igg6xmO.js";
4
- import { t_ as _, v_ as v } from "./handlers-ZviIUC-j.js";
5
- import { t as y } from "./label-format-type-C46pzgx7.js";
6
- import "./logger-CKRjhSHQ.js";
7
- import { B as b, Dt as x, I as S, L as C, St as w, Vt as T, Xt as E, at as ee, bt as te, cn as D, ct as O, i as k, in as A, ln as j, lt as ne, n as re, nt as ie, ot as ae, qt as M, rt as oe, tt as N, un as se, vn as P, z as F } from "./escobar-CjirINHP.js";
8
- import { _ as I } from "./MenuOption-CQpT79AP.js";
9
- import { t as L } from "./coloring-9jU3s_-p.js";
10
- import { t as R } from "./set-coloring-datafield-B3uIS1Pe.js";
11
- var z = /* @__PURE__ */ e(p()), B = (e, t, a) => {
12
- let { coloring: o } = e || {}, s = o?.fieldId, c = e.dimensions.filter((e) => r(e)), l = e.measures.filter((e) => r(e)), u = l.filter((e) => e.role === i.PIE_CHART_SLICE), f = l.filter((e) => e.role === i.PIE_CHART_LENGTH);
13
- s || (e.coloring?.type === d.Gradient ? s = n(u[0]?.dataItem) : e.coloring?.type === d.Categorical && (s = n(c[0]?.dataItem))), te(a, 0, { color: { field: s } });
14
- let p = x(R(e, s ?? null), t, {});
15
- if (f.length > 0) {
16
- let e = n(f[0]?.dataItem);
17
- p[e] = { data: { field: e } };
18
- }
19
- return {
20
- ...a,
21
- scales: p
22
- };
23
- }, V = {
24
- num: "num",
25
- rad: "rad",
26
- group: "group"
27
- }, H = (e, t, a) => {
28
- if (!e.dimensions[0]) return a;
29
- let o = e.measures.filter((e) => r(e)), s = C((e.supportingMeasures ?? []).filter((e) => r(e))), c = e.dimensions.filter((e) => r(e))?.[0], l = o.filter((e) => e.role === i.PIE_CHART_SLICE)?.[0], u = o.filter((e) => e.role === i.PIE_CHART_LENGTH)?.[0], d = n(l?.dataItem), f = n(u?.dataItem), p = n(c?.dataItem), m = {
30
- [V.num]: l?.dataItem?.name ? { field: d } : void 0,
31
- [V.rad]: u?.dataItem?.name ? { field: f } : void 0,
32
- ...s
33
- };
34
- d && (m[d] = { field: d }), f && (m[f] = { field: f });
35
- let h = [{
36
- key: D.Collection,
37
- data: { extract: [{
38
- field: p,
39
- props: m
40
- }] }
41
- }];
42
- return {
43
- ...a,
44
- collections: h
45
- };
46
- }, U = "pie-alternates-switcher", W = "pie-alternates-switcher", G = (e) => s(e) || e.label || e.dataItem?.name || "Field", K = (e, t, r, i) => {
47
- let o = r ? n(r.dataItem) : void 0;
48
- return {
49
- type: "native",
50
- key: `${W}-interaction`,
51
- events: { click(n) {
52
- let s = this.element.getBoundingClientRect(), c = {
53
- x: n.clientX - s.left,
54
- y: n.clientY - s.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 && o) {
63
- i(P.Text, "click", `text-${o}`, n, l, {
64
- dataItemType: a.Measure,
65
- dataItemRole: r.role
66
- });
67
- return;
68
- }
69
- l?.data?.target === "dimension" && e && i(P.Text, "click", `text-${e}`, n, l, {
70
- dataItemType: a.Dimension,
71
- dataItemRole: t
72
- });
73
- } }
74
- };
75
- }, ce = (e, o, s, c, l, d, f, p) => {
76
- let m = u(e.dimensions, e.enableAlternate, d?.isPrintMode), h = e.dimensions.filter((e) => r(e)), g = h[0], _ = g ? n(g.dataItem) : void 0, v = e.measures.filter((e) => e.role === i.PIE_CHART_SLICE), y = u(v, e.enableAlternate, d?.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 s;
78
- let C = {
79
- type: U,
80
- key: W,
81
- dimensionDataItemType: _ ? a.Dimension : void 0,
82
- dimensionDataItemRole: g?.role,
83
- measureDataItemType: b ? a.Measure : void 0,
84
- measureDataItemRole: b?.role,
85
- layout: {
86
- dock: t.Bottom,
87
- displayOrder: 0
88
- },
89
- settings: {
90
- dimensionLabel: x ? M(x) : void 0,
91
- measureLabel: S ? M(S) : void 0,
92
- fontFamily: o.fonts.general.fontFamily ?? void 0,
93
- fontSize: `${j.fieldTitle.fontSize}px`,
94
- color: o.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
- ...s,
103
- components: [...s.components, C],
104
- interactions: s.interactions ? [...s.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, t, a, o, s, c) => {
124
- let l = e.measures.filter((e) => r(e)), u = l.filter((e) => e.role === i.PIE_CHART_SLICE), d = l.filter((e) => e.role === i.PIE_CHART_LENGTH), f = u[0], p = d[0], m = new L(e, t, s?.[0]?.itemsNotAffectedByFiltering), h = J(e) ? q.donut.innerRadius : 0, g = f?.dataLabels?.show === !1 ? q.outerRadiusWithoutLabels : q.outerRadius, _ = e.pieSettings?.cornerRadius ?? (J(e) ? q.donut.cornerRadius : q.cornerRadius), v = e.pieSettings?.strokeEnabled ?? q.strokeEnabled, y = e.pieSettings?.strokeWidth ?? q.strokeWidth, b = e.pieSettings?.strokeColor ?? q.strokeColor;
125
- if (p) {
126
- let t = g, r = J(e) ? q.donut.multiMeasureMinRadius : q.multiMeasureMinRadius;
127
- g = (e) => e.resources.scale(n(p.dataItem))(e.datum.rad.value) * (t - r) + r;
128
- }
129
- let x = {
130
- type: P.Pie,
131
- key: `${P.Pie}`,
132
- data: { collection: D.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: E([""], c, { valuePickerMode: c?.valuePickerMode })
147
- };
148
- return {
149
- ...a,
150
- components: [...a.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(ne)(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, a, o, s) => {
163
- let c = e.dimensions.filter((e) => r(e)), l = e.measures.filter((e) => r(e)), u = c[0], d = l.find((e) => e.role === i.PIE_CHART_SLICE) ?? l[0];
164
- if (!u || !d || !d.dataLabels?.show) return n;
165
- let f = new I(t.fonts.general.color), p = d.dataLabels.showBackdrop ? F(d.dataLabels.backdropColor ? { fill: d.dataLabels.backdropColor } : void 0) : void 0, m = p ? b(f) : d.dataLabels.textColor || "#000", { strokeEnabled: h, strokeWidth: g = q.strokeWidth } = e.pieSettings, _ = h ? g / 2 : 0, v = {
166
- type: P.Labels,
167
- key: "pie-labels",
168
- animations: {
169
- enabled: !0,
170
- presetId: "chart-labels"
171
- },
172
- layout: { displayOrder: T.Labels },
173
- settings: { sources: [{
174
- component: `${P.Pie}`,
175
- selector: se.Path,
176
- strategy: {
177
- type: "slice",
178
- settings: {
179
- fontSize: A(d.dataLabels.size),
180
- fontFamily: t.fonts.general.fontFamily,
181
- labels: [{
182
- label: ue(e, d, o?.[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: E([""], s, { valuePickerMode: s?.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, o = s(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(O(e.formatter))(a, void 0, n.data)), {
203
- label: o,
204
- value: c
205
- };
206
- }, fe = (e, t, n, a, o) => {
207
- let s = !!e.measures.filter(r).filter((e) => e.role === i.PIE_CHART_LENGTH)?.[0], c = {
208
- filter: (e) => e.filter((e) => e.key === P.Pie),
209
- placement: {
210
- type: "slice",
211
- area: "target"
212
- }
213
- };
214
- if (s) return N(e, t, n, c, "tooltip", o);
215
- let l = ae(e, o), u = ie(e, t, pe, oe, o?.[0]?.sum, l);
216
- return N(e, t, n, {
217
- ...c,
218
- extract: u
219
- }, "tooltip", o);
220
- }, pe = (e, t, i, a, o, s, c, l) => {
221
- let u = [], d = e.filter(r), f = ee(i), p = d.filter((e) => !f.has(n(e.dataItem)))?.[0] ?? d?.[0], m = Object.keys(t.data).find((e) => t.data[e]?.source?.field === n(p?.dataItem));
222
- if (!m || !p ? u.push({
223
- label: "",
224
- value: ""
225
- }) : u.push(Y(p, m, t, i, l)), d.filter((e) => f.has(n(e.dataItem))).forEach((e) => {
226
- let r = n(e.dataItem), a = Object.keys(t.data).find((e) => t.data[e]?.source?.field === r);
227
- a && u.push(Y(e, a, t, 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 S {
235
- constructor() {
236
- super([
237
- H,
238
- B,
239
- le,
240
- ce,
241
- de,
242
- w,
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, t) => {
336
- let a = e.find((e) => e.role === i.PIE_CHART_SLICE && r(e));
337
- if (!a) return;
338
- let o = n(a.dataItem);
339
- return t.reduce((e, t) => e + t[o], 0);
340
- }, ve = g(), ye = m(({ vSpec: e, vTheme: t, data: n, elementSize: r, vizProperties: i }) => {
341
- let a = f(), [s] = (0, z.useState)(() => new me()), { activeKey: u } = h(), d = re();
342
- if (!e || !l(e) || !n || !r) return null;
343
- let p = {
344
- ...i,
345
- valuePickerMode: !!u
346
- }, m = t || c;
347
- n[0] && (n[0].sum = _e(e.measures, n[0].items));
348
- let g = s.compile(e, m, n, r, p, o.Pie, a, void 0, d);
349
- return g ? /* @__PURE__ */ (0, ve.jsx)(k, {
350
- config: p,
351
- definition: g,
352
- size: r,
353
- vSpec: e,
354
- escobarPlugins: [$]
355
- }) : null;
356
- });
357
- export { ye as PieChart };