@astrato-io/visualizations 0.0.0-stage → 0.6.5
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.
- package/CHANGELOG.md +23 -0
- package/LICENSE +93 -0
- package/README.md +843 -2
- package/THIRD_PARTY_NOTICES.md +8477 -0
- package/VISUALIZATION_DEFINITIONS.md +2378 -0
- package/chunks/ClickAwayListener-BbeNMAvj.js +52 -0
- package/chunks/LinearProgress-B1FeWaen.js +253 -0
- package/chunks/accessors-DemrDevR.js +128 -0
- package/chunks/app-filter-bar.compiler-BGJ7HAbr.js +64 -0
- package/chunks/bar.compiler-CT0ZbQKc.js +374 -0
- package/chunks/builder-B6dWSIdD.js +12289 -0
- package/chunks/color-settings-ZIvgNTq1.js +10 -0
- package/chunks/coloring-B1XAfg6b.js +664 -0
- package/chunks/debounce-fn-CUixuz45.js +7 -0
- package/chunks/definitions-D3OVqmXl.js +2102 -0
- package/chunks/escobar-eDjtGpkC.js +34606 -0
- package/chunks/events-WZut5Ow6.js +4 -0
- package/chunks/extend-BKUkc4_i.js +37 -0
- package/chunks/filter.compiler-DBsyRBJt.js +70 -0
- package/chunks/filtering-tqjAyJH5.js +1072 -0
- package/chunks/grouping-type-On4s9Thj.js +3 -0
- package/chunks/handlers-VTBfIZYZ.js +13072 -0
- package/chunks/isEqual-BDxAhUo8.js +7514 -0
- package/chunks/line.compiler-CzdM5Ld0.js +198 -0
- package/chunks/metadata-BGElBy5Z.js +28 -0
- package/chunks/number.compiler-G-R7y16P.js +53 -0
- package/chunks/operations-CTNUX6Sy.js +26249 -0
- package/chunks/range-CiwTbMig.js +22 -0
- package/chunks/registry-CsQQzukD.js +920 -0
- package/chunks/requirements-DYjZCFyf.js +6 -0
- package/chunks/rolldown-runtime-DleVn1XH.js +28 -0
- package/chunks/set-coloring-datafield-B3uIS1Pe.js +8 -0
- package/chunks/shared-CBvcC5YV.js +1218 -0
- package/chunks/src-BOS6SqkZ.js +67 -0
- package/chunks/src-D9XogOrc.js +422 -0
- package/chunks/standalone-0M4HlmDW2.js +3944 -0
- package/chunks/standalone-0ashe9w1.js +411 -0
- package/chunks/standalone-B7jax8wa.js +339 -0
- package/chunks/standalone-BK0VYU-l.js +463 -0
- package/chunks/standalone-BMIbT1b2.js +4619 -0
- package/chunks/standalone-BZV5vOwA.js +6 -0
- package/chunks/standalone-BhDrWj4p.js +1980 -0
- package/chunks/standalone-BtSHCp2U2.js +673 -0
- package/chunks/standalone-BvaKdky9.js +344 -0
- package/chunks/standalone-BwtM31-f.js +2 -0
- package/chunks/standalone-C3gg736V.js +1129 -0
- package/chunks/standalone-CC1VUjO32.js +299 -0
- package/chunks/standalone-C_rYnZ0N.js +741 -0
- package/chunks/standalone-CoLrAxRV.js +13198 -0
- package/chunks/standalone-DC-aUgXC.js +3855 -0
- package/chunks/standalone-DCtRoTWg.js +675 -0
- package/chunks/standalone-DUDFTBqL.js +833 -0
- package/chunks/standalone-DhZkX9Td.js +2 -0
- package/chunks/standalone-DtLElfuM.js +512 -0
- package/chunks/standalone-G9Q4Uczu.js +726 -0
- package/chunks/standalone-JuLF-OoH.js +1762 -0
- package/chunks/standalone-_DeX21JJ.js +383 -0
- package/chunks/standalone-gFhKZh8m.js +179 -0
- package/chunks/standalone-tDNy-SFH.js +281 -0
- package/chunks/standalone-v1oxfU20.js +68 -0
- package/chunks/standalone-vzBY6q0I2.js +140 -0
- package/chunks/stroke-dash-UgMEcCS4.js +6 -0
- package/chunks/table.compiler-tb914oj3.js +222 -0
- package/chunks/typeof-CJDtcySz.js +13 -0
- package/chunks/ui-DQWtv2iM.js +63551 -0
- package/chunks/url-utils-B17gj_mr.js +5501 -0
- package/chunks/useFieldName-BvdcoJRl.js +7 -0
- package/chunks/utils-Bg7K-t6K.js +32379 -0
- package/chunks/view-Bn83C8d9.js +12466 -0
- package/definitions.js +3 -0
- package/docs/operations/astrato-app-filter-bar.md +161 -0
- package/docs/operations/bar.md +6968 -0
- package/docs/operations/combo.md +5804 -0
- package/docs/operations/date-picker.md +644 -0
- package/docs/operations/distribution-gauge.md +3082 -0
- package/docs/operations/dot.md +5570 -0
- package/docs/operations/filter.md +1483 -0
- package/docs/operations/gauge.md +3316 -0
- package/docs/operations/heatMap.md +5944 -0
- package/docs/operations/histogram.md +1856 -0
- package/docs/operations/iframe.md +56 -0
- package/docs/operations/image.md +177 -0
- package/docs/operations/index.md +46 -0
- package/docs/operations/line.md +6391 -0
- package/docs/operations/number.md +3903 -0
- package/docs/operations/pie.md +5956 -0
- package/docs/operations/radar.md +4566 -0
- package/docs/operations/sankey.md +3088 -0
- package/docs/operations/scatter.md +5969 -0
- package/docs/operations/shape.md +315 -0
- package/docs/operations/simpleTextObject.md +699 -0
- package/docs/operations/slider.md +220 -0
- package/docs/operations/table.md +8800 -0
- package/docs/operations/tree.md +2867 -0
- package/docs/operations/treemap.md +3527 -0
- package/docs/operations/waterfall.md +2928 -0
- package/docs/operations/word-cloud.md +3000 -0
- package/getters.js +18 -0
- package/index.js +1183 -0
- package/metadata.js +20 -0
- package/operations.js +64 -0
- package/package.json +185 -4
- package/src/definitions/index.d.ts +2 -0
- package/src/definitions/model/definitions/available-fields.d.ts +35 -0
- package/src/definitions/model/definitions/compilers/compile.d.ts +7 -0
- package/src/definitions/model/definitions/data-item-resolution.d.ts +19 -0
- package/src/definitions/model/definitions/descriptors/descriptor-metadata.d.ts +1341 -0
- package/src/definitions/model/definitions/descriptors/json-schema.d.ts +2 -0
- package/src/definitions/model/definitions/diagnostics.d.ts +5 -0
- package/src/definitions/model/definitions/field-suggestions.d.ts +2 -0
- package/src/definitions/model/definitions/index.d.ts +23 -0
- package/src/definitions/model/definitions/registry/compile.d.ts +2 -0
- package/src/definitions/model/definitions/registry/descriptor-registry.d.ts +3 -0
- package/src/definitions/model/definitions/schema-registry.d.ts +660 -0
- package/src/definitions/model/definitions/schemas/app-filter-bar.schema.d.ts +22 -0
- package/src/definitions/model/definitions/schemas/bar.schema.d.ts +73 -0
- package/src/definitions/model/definitions/schemas/broad-chart.schema.d.ts +68 -0
- package/src/definitions/model/definitions/schemas/common.schema.d.ts +303 -0
- package/src/definitions/model/definitions/schemas/filter.schema.d.ts +22 -0
- package/src/definitions/model/definitions/schemas/index.d.ts +9 -0
- package/src/definitions/model/definitions/schemas/line.schema.d.ts +72 -0
- package/src/definitions/model/definitions/schemas/number.schema.d.ts +21 -0
- package/src/definitions/model/definitions/schemas/object.schema.d.ts +215 -0
- package/src/definitions/model/definitions/schemas/table.schema.d.ts +458 -0
- package/src/definitions/model/definitions/types/compilation.types.d.ts +36 -0
- package/src/definitions/model/definitions/types/definition.types.d.ts +2 -0
- package/src/definitions/model/definitions/types/descriptor.types.d.ts +39 -0
- package/src/definitions/model/definitions/types/index.d.ts +3 -0
- package/src/definitions/model/definitions/validation.d.ts +3 -0
- package/src/getters/index.d.ts +30 -0
- package/src/index.d.ts +4 -0
- package/src/metadata/index.d.ts +4 -0
- package/src/operations/index.d.ts +30 -0
- package/src/registry/index.d.ts +6 -0
- package/src/runtime/index.d.ts +2 -0
- package/src/types.d.ts +307 -0
- package/src/visualization-catalog.d.ts +82 -0
- package/src/web-components/index.d.ts +12 -0
- package/styles.css +2 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { o as e } from "./rolldown-runtime-DleVn1XH.js";
|
|
2
|
+
import { Fa as t, Gn as n, Ks as r, Mo as i, Sa as a, Si as o, Uc as s, Ys as c, Zr as l, fc as u } from "./isEqual-BDxAhUo8.js";
|
|
3
|
+
import { $t as d, Ei as f, P as p, Yi as m, o as h } from "./utils-Bg7K-t6K.js";
|
|
4
|
+
import { Lm as g, Rm as _, bm as v } from "./handlers-VTBfIZYZ.js";
|
|
5
|
+
import { Vt as y, mt as b } from "./ui-DQWtv2iM.js";
|
|
6
|
+
import { F as x, Ft as S, Jt as C, M as w, P as T, Q as E, Qt as D, St as ee, Vt as O, Wt as k, X as A, Z as j, _t as M, dn as N, et as te, ht as ne, i as re, it as ie, j as ae, n as oe, rn as P, rt as F, tt as I } from "./escobar-eDjtGpkC.js";
|
|
7
|
+
import { t as L } from "./coloring-B1XAfg6b.js";
|
|
8
|
+
import { t as R } from "./set-coloring-datafield-B3uIS1Pe.js";
|
|
9
|
+
var z = /* @__PURE__ */ e(m()), B = (e, n, r) => {
|
|
10
|
+
let { coloring: i } = e || {}, a = i?.fieldId, s = e.dimensions.filter((e) => o(e)), l = e.measures.filter((e) => o(e)), d = l.filter((e) => e.role === t.PIE_CHART_SLICE), f = l.filter((e) => e.role === t.PIE_CHART_LENGTH);
|
|
11
|
+
a || (e.coloring?.type === c.Gradient ? a = u(d[0]?.dataItem) : e.coloring?.type === c.Categorical && (a = u(s[0]?.dataItem))), ne(r, 0, { color: { field: a } });
|
|
12
|
+
let p = ee(R(e, a), n, {});
|
|
13
|
+
if (f.length > 0) {
|
|
14
|
+
let e = u(f[0]?.dataItem);
|
|
15
|
+
p[e] = { data: { field: e } };
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
...r,
|
|
19
|
+
scales: p
|
|
20
|
+
};
|
|
21
|
+
}, V = /* @__PURE__ */ function(e) {
|
|
22
|
+
return e.num = "num", e.rad = "rad", e.group = "group", e;
|
|
23
|
+
}({}), H = (e, n, r) => {
|
|
24
|
+
if (!e.dimensions[0]) return r;
|
|
25
|
+
let i = e.measures.filter((e) => o(e)), a = w((e.supportingMeasures ?? []).filter((e) => o(e))), s = e.dimensions.filter((e) => o(e))?.[0], c = i.filter((e) => e.role === t.PIE_CHART_SLICE)?.[0], l = i.filter((e) => e.role === t.PIE_CHART_LENGTH)?.[0], d = u(c?.dataItem), f = u(l?.dataItem), p = u(s?.dataItem), m = [{
|
|
26
|
+
key: D.Collection,
|
|
27
|
+
data: { extract: [{
|
|
28
|
+
field: p,
|
|
29
|
+
props: {
|
|
30
|
+
num: c?.dataItem?.name ? { field: d } : void 0,
|
|
31
|
+
rad: l?.dataItem?.name ? { field: f } : void 0,
|
|
32
|
+
...a
|
|
33
|
+
}
|
|
34
|
+
}] }
|
|
35
|
+
}];
|
|
36
|
+
return d && (m[0].data.extract[0].props[d] = { field: d }), f && (m[0].data.extract[0].props[f] = { field: f }), {
|
|
37
|
+
...r,
|
|
38
|
+
collections: m
|
|
39
|
+
};
|
|
40
|
+
}, U = "pie-alternates-switcher", W = "pie-alternates-switcher", G = (e) => n(e) || e.label || e.dataItem?.name || "Field", K = (e, t, n, r) => {
|
|
41
|
+
let i = n ? u(n.dataItem) : void 0;
|
|
42
|
+
return {
|
|
43
|
+
type: "native",
|
|
44
|
+
key: `${W}-interaction`,
|
|
45
|
+
events: { click(a) {
|
|
46
|
+
let o = this.element.getBoundingClientRect(), c = {
|
|
47
|
+
x: a.clientX - o.left,
|
|
48
|
+
y: a.clientY - o.top
|
|
49
|
+
}, l = this.chart.shapesAt(c, {
|
|
50
|
+
components: [{
|
|
51
|
+
key: W,
|
|
52
|
+
propagation: "stop"
|
|
53
|
+
}],
|
|
54
|
+
propagation: "stop"
|
|
55
|
+
}).find((e) => e.data?.target === "measure" || e.data?.target === "dimension");
|
|
56
|
+
if (l?.data?.target === "measure" && n && i) {
|
|
57
|
+
r(N.Text, "click", `text-${i}`, a, l, {
|
|
58
|
+
dataItemType: s.Measure,
|
|
59
|
+
dataItemRole: n.role
|
|
60
|
+
});
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
l?.data?.target === "dimension" && e && r(N.Text, "click", `text-${e}`, a, l, {
|
|
64
|
+
dataItemType: s.Dimension,
|
|
65
|
+
dataItemRole: t
|
|
66
|
+
});
|
|
67
|
+
} }
|
|
68
|
+
};
|
|
69
|
+
}, se = (e, n, r, a, c, d, f, p) => {
|
|
70
|
+
let m = l(e.dimensions, e.enableAlternate, d?.isPrintMode), h = e.dimensions.filter((e) => o(e)), g = h[0], _ = g ? u(g.dataItem) : void 0, v = e.measures.filter((e) => e.role === t.PIE_CHART_SLICE), b = l(v, e.enableAlternate, d?.isPrintMode), x = v.filter((e) => o(e))[0], S = m && h.length ? h.map((e) => G(e)).join(", ") : void 0, C = b && x ? G(x) : void 0;
|
|
71
|
+
if (!S && !C) return r;
|
|
72
|
+
let w = {
|
|
73
|
+
type: U,
|
|
74
|
+
key: W,
|
|
75
|
+
dimensionDataItemType: _ ? s.Dimension : void 0,
|
|
76
|
+
dimensionDataItemRole: g?.role,
|
|
77
|
+
measureDataItemType: x ? s.Measure : void 0,
|
|
78
|
+
measureDataItemRole: x?.role,
|
|
79
|
+
layout: {
|
|
80
|
+
dock: i.Bottom,
|
|
81
|
+
displayOrder: 0
|
|
82
|
+
},
|
|
83
|
+
settings: {
|
|
84
|
+
dimensionLabel: S ? O(S) : void 0,
|
|
85
|
+
measureLabel: C ? O(C) : void 0,
|
|
86
|
+
fontFamily: n.fonts.general.fontFamily,
|
|
87
|
+
fontSize: `${y.fieldTitle.fontSize}px`,
|
|
88
|
+
color: n.fonts.general.color,
|
|
89
|
+
paddingLeft: 5,
|
|
90
|
+
paddingRight: 5,
|
|
91
|
+
paddingVertical: 5,
|
|
92
|
+
labelGap: 12
|
|
93
|
+
}
|
|
94
|
+
}, T = p ? [K(_, g?.role, x, p)] : [];
|
|
95
|
+
return {
|
|
96
|
+
...r,
|
|
97
|
+
components: [...r.components, w],
|
|
98
|
+
interactions: r.interactions ? [...r.interactions, ...T] : T
|
|
99
|
+
};
|
|
100
|
+
}, q = {
|
|
101
|
+
outerRadius: .8,
|
|
102
|
+
outerRadiusWithoutLabels: .95,
|
|
103
|
+
cornerRadius: v.pie,
|
|
104
|
+
strokeWidth: 0,
|
|
105
|
+
strokeEnabled: !1,
|
|
106
|
+
strokeColor: "#C6C6C6",
|
|
107
|
+
multiMeasureMinRadius: .3,
|
|
108
|
+
donut: {
|
|
109
|
+
innerRadius: .55,
|
|
110
|
+
cornerRadius: v.donut,
|
|
111
|
+
multiMeasureMinRadius: .6
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
function J(e) {
|
|
115
|
+
return e.pieSettings?.donut ?? !1;
|
|
116
|
+
}
|
|
117
|
+
var ce = (e, n, r, i, a, s) => {
|
|
118
|
+
let c = e.measures.filter((e) => o(e)), l = c.filter((e) => e.role === t.PIE_CHART_SLICE), d = c.filter((e) => e.role === t.PIE_CHART_LENGTH), f = l[0], p = d[0], m = new L(e, n, a?.[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;
|
|
119
|
+
if (p) {
|
|
120
|
+
let t = g, n = J(e) ? q.donut.multiMeasureMinRadius : q.multiMeasureMinRadius;
|
|
121
|
+
g = (e) => e.resources.scale(u(p.dataItem))(e.datum.rad.value) * (t - n) + n;
|
|
122
|
+
}
|
|
123
|
+
let x = {
|
|
124
|
+
type: N.Pie,
|
|
125
|
+
key: `${N.Pie}`,
|
|
126
|
+
data: { collection: D.Collection },
|
|
127
|
+
animations: {
|
|
128
|
+
enabled: !0,
|
|
129
|
+
presetId: "pie-chart"
|
|
130
|
+
},
|
|
131
|
+
settings: { slice: {
|
|
132
|
+
arc: { ref: "num" },
|
|
133
|
+
stroke: b,
|
|
134
|
+
strokeWidth: v ? y : 0,
|
|
135
|
+
cornerRadius: _,
|
|
136
|
+
innerRadius: h,
|
|
137
|
+
outerRadius: g,
|
|
138
|
+
fill: m.getColorDefinition({ ref: "color" })
|
|
139
|
+
} },
|
|
140
|
+
brush: k([""], s, { valuePickerMode: s?.valuePickerMode })
|
|
141
|
+
};
|
|
142
|
+
return {
|
|
143
|
+
...r,
|
|
144
|
+
components: [...r.components, x]
|
|
145
|
+
};
|
|
146
|
+
}, le = (e, t, n) => ({ data: r, formatter: i }) => {
|
|
147
|
+
let a = e.dimensions.filter((e) => o(e))[0], s = r.value, c = r[V.num].value, l = a.formatter && s && i ? i(a.formatter)(s) : `${s}`, u = t.formatter && c && i ? i(t.formatter)(c, void 0, r) : `${c}`, d = c != null && n && i ? i(ie)(c / n) : null, f = () => t.dataLabels?.measureLabelFormat === g.Percentage ? [d] : t.dataLabels?.measureLabelFormat === g.ValueAndPercentage ? [u, d] : [u];
|
|
148
|
+
switch (t.dataLabels?.labelFormat) {
|
|
149
|
+
case _.Measure: {
|
|
150
|
+
let e = f();
|
|
151
|
+
return e.length === 1 ? e[0] : e;
|
|
152
|
+
}
|
|
153
|
+
case _.DimensionAndMeasure: return [l, ...f()];
|
|
154
|
+
default: return l;
|
|
155
|
+
}
|
|
156
|
+
}, ue = (e, n, r, i, a, s) => {
|
|
157
|
+
let c = e.dimensions.filter((e) => o(e)), l = e.measures.filter((e) => o(e)), u = c[0], d = l.find((e) => e.role === t.PIE_CHART_SLICE) ?? l[0];
|
|
158
|
+
if (!u || !d || !d.dataLabels?.show) return r;
|
|
159
|
+
let f = new b(n.fonts.general.color), p = d.dataLabels.showBackdrop ? T(d.dataLabels.backdropColor ? { fill: d.dataLabels.backdropColor } : void 0) : void 0, m = p ? x(f) : d.dataLabels.textColor || "#000", { strokeEnabled: h, strokeWidth: g = q.strokeWidth } = e.pieSettings, _ = h ? g / 2 : 0, v = {
|
|
160
|
+
type: N.Labels,
|
|
161
|
+
key: "pie-labels",
|
|
162
|
+
animations: {
|
|
163
|
+
enabled: !0,
|
|
164
|
+
presetId: "chart-labels"
|
|
165
|
+
},
|
|
166
|
+
layout: { displayOrder: S.Labels },
|
|
167
|
+
settings: { sources: [{
|
|
168
|
+
component: `${N.Pie}`,
|
|
169
|
+
selector: P.Path,
|
|
170
|
+
strategy: {
|
|
171
|
+
type: "slice",
|
|
172
|
+
settings: {
|
|
173
|
+
fontSize: C(d.dataLabels.size),
|
|
174
|
+
fontFamily: n.fonts.general.fontFamily,
|
|
175
|
+
labels: [{
|
|
176
|
+
label: le(e, d, a[0].sum),
|
|
177
|
+
placements: [{
|
|
178
|
+
position: "outside",
|
|
179
|
+
fill: m,
|
|
180
|
+
backdrop: p
|
|
181
|
+
}],
|
|
182
|
+
strokeDelta: _,
|
|
183
|
+
linkData: ({ data: e }) => e
|
|
184
|
+
}]
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}] },
|
|
188
|
+
brush: k([""], s, { valuePickerMode: s?.valuePickerMode })
|
|
189
|
+
};
|
|
190
|
+
return {
|
|
191
|
+
...r,
|
|
192
|
+
components: [...r.components, v]
|
|
193
|
+
};
|
|
194
|
+
}, Y = (e, t, r, i, a) => {
|
|
195
|
+
let o = r.data[t]?.value, s = n(e) || e.label || e.dataItem.name || "", c = o;
|
|
196
|
+
return !a && e.formatter ? c = i.formatter(e.formatter)(o, void 0, r.data) : a && (c = i.formatter(F(e.formatter))(o, void 0, r.data)), {
|
|
197
|
+
label: s,
|
|
198
|
+
value: c
|
|
199
|
+
};
|
|
200
|
+
}, de = (e, n, r, i, a) => {
|
|
201
|
+
let s = !!e.measures.filter(o).filter((e) => e.role === t.PIE_CHART_LENGTH)?.[0], c = {
|
|
202
|
+
filter: (e) => e.filter((e) => e.key === N.Pie),
|
|
203
|
+
placement: {
|
|
204
|
+
type: "slice",
|
|
205
|
+
area: "target"
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
if (s) return A(e, n, r, c, "tooltip", a);
|
|
209
|
+
let l = I(e, a), u = j(e, n, fe, E, a?.[0]?.sum, l);
|
|
210
|
+
return A(e, n, r, {
|
|
211
|
+
...c,
|
|
212
|
+
extract: u
|
|
213
|
+
}, "tooltip", a);
|
|
214
|
+
}, fe = (e, t, n, r, i, a, s, c) => {
|
|
215
|
+
let l = [], d = e.filter(o), f = te(n), p = d.filter((e) => !f.has(u(e.dataItem)))?.[0] ?? d?.[0], m = Object.keys(t.data).find((e) => t.data[e]?.source?.field === u(p?.dataItem));
|
|
216
|
+
if (!m || !p ? l.push({
|
|
217
|
+
label: "",
|
|
218
|
+
value: ""
|
|
219
|
+
}) : l.push(Y(p, m, t, n, c)), d.filter((e) => f.has(u(e.dataItem))).forEach((e) => {
|
|
220
|
+
let r = u(e.dataItem), i = Object.keys(t.data).find((e) => t.data[e]?.source?.field === r);
|
|
221
|
+
i && l.push(Y(e, i, t, n, c));
|
|
222
|
+
}), s) return l;
|
|
223
|
+
let h = Object.values(a ?? {}).reduce((e, t) => e + Number(t), 0);
|
|
224
|
+
return l.push({
|
|
225
|
+
label: "Total",
|
|
226
|
+
value: p?.formatter ? n.formatter(p.formatter)(h) : h
|
|
227
|
+
}), l;
|
|
228
|
+
}, pe = class extends ae {
|
|
229
|
+
constructor() {
|
|
230
|
+
super([
|
|
231
|
+
H,
|
|
232
|
+
B,
|
|
233
|
+
ce,
|
|
234
|
+
se,
|
|
235
|
+
ue,
|
|
236
|
+
M,
|
|
237
|
+
de
|
|
238
|
+
]);
|
|
239
|
+
}
|
|
240
|
+
preCompile(e) {
|
|
241
|
+
let t = e.dimensions.filter((e) => o(e))?.[0], n = e.measures.filter((e) => o(e))?.[0];
|
|
242
|
+
if (!t || !n) throw Error("Charts w/o dimensions or measures are not supported ATM.");
|
|
243
|
+
}
|
|
244
|
+
}, X = " ▼", Z = "...", Q = (e, t, n, r) => e.measureText({
|
|
245
|
+
text: t,
|
|
246
|
+
fontFamily: n,
|
|
247
|
+
fontSize: r
|
|
248
|
+
}).width, $ = (e, t, n, r, i) => {
|
|
249
|
+
if (t <= 0 || Q(n, e, r, i) <= t) return e;
|
|
250
|
+
let a = e.endsWith(X), o = a ? X : "", s = a ? e.slice(0, -2) : e;
|
|
251
|
+
if (Q(n, `${Z}${o}`, r, i) > t) return Z;
|
|
252
|
+
let c = 0, l = s.length;
|
|
253
|
+
for (; c < l;) {
|
|
254
|
+
let e = Math.ceil((c + l) / 2);
|
|
255
|
+
Q(n, `${s.slice(0, e)}${Z}${o}`, r, i) <= t ? c = e : l = e - 1;
|
|
256
|
+
}
|
|
257
|
+
return `${s.slice(0, c)}${Z}${o}`;
|
|
258
|
+
}, me = {
|
|
259
|
+
require: ["renderer"],
|
|
260
|
+
defaultSettings: { settings: {
|
|
261
|
+
dimensionLabel: "",
|
|
262
|
+
measureLabel: "",
|
|
263
|
+
fontSize: "12px",
|
|
264
|
+
color: "#000",
|
|
265
|
+
paddingLeft: 5,
|
|
266
|
+
paddingRight: 5,
|
|
267
|
+
paddingVertical: 5,
|
|
268
|
+
labelGap: 12
|
|
269
|
+
} },
|
|
270
|
+
preferredSize() {
|
|
271
|
+
let { fontFamily: e = "Arial", fontSize: t, paddingVertical: n } = this.settings.settings;
|
|
272
|
+
return this.renderer.measureText({
|
|
273
|
+
fontFamily: e,
|
|
274
|
+
fontSize: t
|
|
275
|
+
}).height + n * 2;
|
|
276
|
+
},
|
|
277
|
+
render() {
|
|
278
|
+
let { dimensionLabel: e, measureLabel: t, fontFamily: n = "Arial", fontSize: r, color: i, paddingLeft: a, paddingRight: o, labelGap: s } = this.settings.settings, c = t ? Q(this.renderer, t, n, r) : 0, l = this.rect.width - o, u = l - c, d = Math.max(Math.min(t ? u - s - a : this.rect.width - a - o, this.rect.width / 2), 0), f = e ? $(e, d, this.renderer, n, r) : "", p = f ? Q(this.renderer, f, n, r) : 0, m = [];
|
|
279
|
+
return t && m.push({
|
|
280
|
+
type: "rect",
|
|
281
|
+
x: Math.max(u, 0),
|
|
282
|
+
y: 0,
|
|
283
|
+
width: Math.min(c, this.rect.width),
|
|
284
|
+
height: this.rect.height,
|
|
285
|
+
fill: "rgba(0, 0, 0, 0)",
|
|
286
|
+
strokeWidth: 0,
|
|
287
|
+
data: { target: "measure" }
|
|
288
|
+
}), e && (m.push({
|
|
289
|
+
type: "rect",
|
|
290
|
+
x: a,
|
|
291
|
+
y: 0,
|
|
292
|
+
width: p,
|
|
293
|
+
height: this.rect.height,
|
|
294
|
+
fill: "rgba(0, 0, 0, 0)",
|
|
295
|
+
strokeWidth: 0,
|
|
296
|
+
data: { target: "dimension" }
|
|
297
|
+
}), m.push({
|
|
298
|
+
type: "text",
|
|
299
|
+
text: f,
|
|
300
|
+
x: a,
|
|
301
|
+
y: this.rect.height / 2,
|
|
302
|
+
anchor: "start",
|
|
303
|
+
baseline: "central",
|
|
304
|
+
fontFamily: n,
|
|
305
|
+
fontSize: r,
|
|
306
|
+
fill: i,
|
|
307
|
+
maxWidth: d,
|
|
308
|
+
data: { target: "dimension" }
|
|
309
|
+
})), t && m.push({
|
|
310
|
+
type: "text",
|
|
311
|
+
text: t,
|
|
312
|
+
x: l,
|
|
313
|
+
y: this.rect.height / 2,
|
|
314
|
+
anchor: "end",
|
|
315
|
+
baseline: "central",
|
|
316
|
+
fontFamily: n,
|
|
317
|
+
fontSize: r,
|
|
318
|
+
fill: i,
|
|
319
|
+
data: { target: "measure" }
|
|
320
|
+
}), m;
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
function he(e) {
|
|
324
|
+
e.component(U, me);
|
|
325
|
+
}
|
|
326
|
+
var ge = f(), _e = d(({ vSpec: e, vTheme: t, data: n, elementSize: i, vizProperties: o }) => {
|
|
327
|
+
let s = p(), [c] = (0, z.useState)(() => new pe()), { activeKey: l } = h(), d = {
|
|
328
|
+
...o,
|
|
329
|
+
valuePickerMode: !!l
|
|
330
|
+
}, f = t || a;
|
|
331
|
+
if (n?.[0]?.items && e?.measures?.length) {
|
|
332
|
+
let t = n[0].items.reduce((t, n) => t + n[u(e.measures[0].dataItem)], 0);
|
|
333
|
+
n[0].sum = t;
|
|
334
|
+
}
|
|
335
|
+
let m = c.compile(e, f, n, i, d, r.Pie, s, void 0, oe());
|
|
336
|
+
return m ? /* @__PURE__ */ (0, ge.jsx)(re, {
|
|
337
|
+
config: d,
|
|
338
|
+
definition: m,
|
|
339
|
+
size: i,
|
|
340
|
+
vSpec: e,
|
|
341
|
+
escobarPlugins: [he]
|
|
342
|
+
}) : null;
|
|
343
|
+
});
|
|
344
|
+
export { _e as PieChart };
|