@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.
- package/CHANGELOG.md +23 -0
- package/LICENSE +93 -0
- package/README.md +843 -2
- package/THIRD_PARTY_NOTICES.md +8387 -0
- package/VISUALIZATION_DEFINITIONS.md +2378 -0
- package/chunks/LinearProgress-CUZ0D8_t.js +253 -0
- package/chunks/Radio-Ciu-F4CU.js +957 -0
- package/chunks/ToggleButton-BCJc3Jlc.js +153 -0
- package/chunks/_baseFlatten-DPXPOrea.js +7076 -0
- package/chunks/accessors-DemrDevR.js +128 -0
- package/chunks/app-filter-bar.compiler-j_CVoWTa.js +55 -0
- package/chunks/bar.compiler-oqaPzIut.js +370 -0
- package/chunks/color-settings-ZIvgNTq1.js +10 -0
- package/chunks/coloring-C16AUZEi.js +663 -0
- package/chunks/data-item-resolution-1lvYB5ln.js +53 -0
- package/chunks/debounce-fn-CUixuz45.js +7 -0
- package/chunks/escobar-BGqT1EsE.js +34580 -0
- package/chunks/event-bus-KiSiCJrC.js +2683 -0
- package/chunks/events-WZut5Ow6.js +4 -0
- package/chunks/extend-BKUkc4_i.js +37 -0
- package/chunks/filter.compiler-CuLtc_02.js +60 -0
- package/chunks/filtering-Yq4DEa0t.js +953 -0
- package/chunks/gauge-target-type-BkKXAqkX.js +4 -0
- package/chunks/grouping-type-BX_9Ix5q.js +3 -0
- package/chunks/interfaces-VUY4_yVO.js +8742 -0
- package/chunks/line-settings-DfYTUyPz.js +4 -0
- package/chunks/line.compiler-BpA_6Tc7.js +188 -0
- package/chunks/metadata-CPXdYoln.js +28 -0
- package/chunks/number.compiler-DbkWcG4S.js +44 -0
- package/chunks/pie-uv42Eqal.js +10 -0
- package/chunks/range-DrzdfBX4.js +22 -0
- package/chunks/registry-CExpGJ1N.js +920 -0
- package/chunks/requirements-DNhuShLS.js +6 -0
- package/chunks/rolldown-runtime-DleVn1XH.js +28 -0
- package/chunks/set-coloring-datafield-B3uIS1Pe.js +8 -0
- package/chunks/shared-CKDL4hx9.js +1171 -0
- package/chunks/src-BC7cGcJ-.js +2024 -0
- package/chunks/src-BOS6SqkZ.js +67 -0
- package/chunks/src-C0LgoUWY.js +26105 -0
- package/chunks/src-Cum_2NLV.js +12145 -0
- package/chunks/src-D9XogOrc.js +422 -0
- package/chunks/src-Dun_jXtz.js +10295 -0
- package/chunks/src-DvX5LU9T.js +14742 -0
- package/chunks/standalone-87YV_m9n.js +687 -0
- package/chunks/standalone-BDCwI6Hn.js +4619 -0
- package/chunks/standalone-BH5NqDwp.js +1763 -0
- package/chunks/standalone-BLVAWLNJ.js +385 -0
- package/chunks/standalone-BPomtAVs.js +2 -0
- package/chunks/standalone-BXyBcUOQ.js +2 -0
- package/chunks/standalone-BYm1UjLr.js +140 -0
- package/chunks/standalone-BllF4rDp.js +383 -0
- package/chunks/standalone-BmfMt74U.js +726 -0
- package/chunks/standalone-BqWyrnZI.js +281 -0
- package/chunks/standalone-C85u7U6I.js +340 -0
- package/chunks/standalone-CCNtaJ7s.js +741 -0
- package/chunks/standalone-CDQnr6qT.js +345 -0
- package/chunks/standalone-CNyNHKVx.js +674 -0
- package/chunks/standalone-CY57qwZ-.js +1129 -0
- package/chunks/standalone-CZynjFG7.js +12979 -0
- package/chunks/standalone-D5vnf-9y.js +3943 -0
- package/chunks/standalone-DFPva_ku.js +299 -0
- package/chunks/standalone-DQxxNwF8.js +675 -0
- package/chunks/standalone-DS9T0FZ-.js +830 -0
- package/chunks/standalone-Dx3MLlrO.js +512 -0
- package/chunks/standalone-DzixzZAL.js +411 -0
- package/chunks/standalone-QJ1kKMnO.js +6 -0
- package/chunks/standalone-jiz0L2Dg.js +3855 -0
- package/chunks/standalone-lBm9hQ-q.js +179 -0
- package/chunks/standalone-rJ45Zfl1.js +68 -0
- package/chunks/stroke-dash-UgMEcCS4.js +6 -0
- package/chunks/table.compiler-BrXkm4Fz.js +213 -0
- package/chunks/toInteger-DVZr-D1j.js +11 -0
- package/chunks/treemap-x_zmJoG7.js +23 -0
- package/chunks/typeof-CJDtcySz.js +13 -0
- package/chunks/types-dVVCsDWD.js +4 -0
- package/chunks/ui-D1HQNIBy.js +54039 -0
- package/chunks/url-utils-B17gj_mr.js +5501 -0
- package/chunks/useFieldName-oqQ3bvnO.js +7 -0
- package/chunks/utils-Ba9T0TqC.js +31097 -0
- package/chunks/view-CLqWMV7Z.js +156 -0
- package/definitions.js +3 -0
- package/docs/operations/astrato-app-filter-bar.md +161 -0
- package/docs/operations/bar.md +7050 -0
- package/docs/operations/combo.md +5825 -0
- package/docs/operations/date-picker.md +644 -0
- package/docs/operations/distribution-gauge.md +3218 -0
- package/docs/operations/dot.md +5662 -0
- package/docs/operations/filter.md +1507 -0
- package/docs/operations/gauge.md +3452 -0
- package/docs/operations/heatMap.md +6026 -0
- package/docs/operations/histogram.md +1870 -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 +6468 -0
- package/docs/operations/number.md +3969 -0
- package/docs/operations/pie.md +6089 -0
- package/docs/operations/radar.md +4646 -0
- package/docs/operations/sankey.md +3210 -0
- package/docs/operations/scatter.md +6075 -0
- package/docs/operations/shape.md +315 -0
- package/docs/operations/simpleTextObject.md +706 -0
- package/docs/operations/slider.md +230 -0
- package/docs/operations/table.md +8790 -0
- package/docs/operations/tree.md +2874 -0
- package/docs/operations/treemap.md +3619 -0
- package/docs/operations/waterfall.md +2938 -0
- package/docs/operations/word-cloud.md +3071 -0
- package/getters.js +18 -0
- package/index.js +1183 -0
- package/metadata.js +20 -0
- package/operations.js +64 -0
- package/package.json +191 -4
- package/src/definitions/index.d.ts +2 -0
- package/src/definitions/shared/index.d.ts +5 -0
- package/src/definitions/shared/lib/available-fields.d.ts +36 -0
- package/src/definitions/shared/lib/compilers/index.d.ts +7 -0
- package/src/definitions/shared/lib/registry/compile.d.ts +2 -0
- package/src/definitions/shared/lib/registry/descriptor-registry.d.ts +587 -0
- package/src/definitions/shared/lib/registry/index.d.ts +3 -0
- package/src/definitions/shared/lib/registry/validation.d.ts +3 -0
- package/src/definitions/shared/lib/schemas/app-filter-bar.schema.d.ts +22 -0
- package/src/definitions/shared/lib/schemas/bar.schema.d.ts +73 -0
- package/src/definitions/shared/lib/schemas/broad-chart.schema.d.ts +68 -0
- package/src/definitions/shared/lib/schemas/common.schema.d.ts +304 -0
- package/src/definitions/shared/lib/schemas/filter.schema.d.ts +22 -0
- package/src/definitions/shared/lib/schemas/index.d.ts +9 -0
- package/src/definitions/shared/lib/schemas/line.schema.d.ts +72 -0
- package/src/definitions/shared/lib/schemas/number.schema.d.ts +21 -0
- package/src/definitions/shared/lib/schemas/object.schema.d.ts +215 -0
- package/src/definitions/shared/lib/schemas/table.schema.d.ts +458 -0
- package/src/definitions/shared/lib/types/compilation.types.d.ts +36 -0
- package/src/definitions/shared/lib/types/definition.types.d.ts +2 -0
- package/src/definitions/shared/lib/types/descriptor.types.d.ts +39 -0
- package/src/definitions/shared/lib/types/index.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,345 @@
|
|
|
1
|
+
import { o as e } from "./rolldown-runtime-DleVn1XH.js";
|
|
2
|
+
import { La as t, No as n, Ta as r, Ti as i, Wc as a, Xs as o, Yn as s, pc as c, qs as l, ti as u } from "./interfaces-VUY4_yVO.js";
|
|
3
|
+
import { Ki as d, P as f, Zt as p, o as m, wi as h } from "./utils-Ba9T0TqC.js";
|
|
4
|
+
import { Bn as g, Vn as _ } from "./event-bus-KiSiCJrC.js";
|
|
5
|
+
import { n as v } from "./pie-uv42Eqal.js";
|
|
6
|
+
import { F as y, Ft as b, Jt as x, M as S, P as C, Q as w, Qt as T, St as E, Vt as D, Wt as O, X as k, Z as A, _t as j, et as M, ht as ee, i as te, it as ne, j as re, n as ie, nn as ae, rt as oe, tt as N, un as P } from "./escobar-BGqT1EsE.js";
|
|
7
|
+
import { l as F, vt as I } from "./_baseFlatten-DPXPOrea.js";
|
|
8
|
+
import { t as L } from "./coloring-C16AUZEi.js";
|
|
9
|
+
import { t as R } from "./set-coloring-datafield-B3uIS1Pe.js";
|
|
10
|
+
var z = /* @__PURE__ */ e(d()), B = (e, n, r) => {
|
|
11
|
+
let { coloring: a } = e || {}, s = a?.fieldId, l = e.dimensions.filter((e) => i(e)), u = e.measures.filter((e) => i(e)), d = u.filter((e) => e.role === t.PIE_CHART_SLICE), f = u.filter((e) => e.role === t.PIE_CHART_LENGTH);
|
|
12
|
+
s || (e.coloring?.type === o.Gradient ? s = c(d[0]?.dataItem) : e.coloring?.type === o.Categorical && (s = c(l[0]?.dataItem))), ee(r, 0, { color: { field: s } });
|
|
13
|
+
let p = E(R(e, s), n, {});
|
|
14
|
+
if (f.length > 0) {
|
|
15
|
+
let e = c(f[0]?.dataItem);
|
|
16
|
+
p[e] = { data: { field: e } };
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
...r,
|
|
20
|
+
scales: p
|
|
21
|
+
};
|
|
22
|
+
}, V = /* @__PURE__ */ function(e) {
|
|
23
|
+
return e.num = "num", e.rad = "rad", e.group = "group", e;
|
|
24
|
+
}({}), H = (e, n, r) => {
|
|
25
|
+
if (!e.dimensions[0]) return r;
|
|
26
|
+
let a = e.measures.filter((e) => i(e)), o = S((e.supportingMeasures ?? []).filter((e) => i(e))), s = e.dimensions.filter((e) => i(e))?.[0], l = a.filter((e) => e.role === t.PIE_CHART_SLICE)?.[0], u = a.filter((e) => e.role === t.PIE_CHART_LENGTH)?.[0], d = c(l?.dataItem), f = c(u?.dataItem), p = c(s?.dataItem), m = [{
|
|
27
|
+
key: T.Collection,
|
|
28
|
+
data: { extract: [{
|
|
29
|
+
field: p,
|
|
30
|
+
props: {
|
|
31
|
+
num: l?.dataItem?.name ? { field: d } : void 0,
|
|
32
|
+
rad: u?.dataItem?.name ? { field: f } : void 0,
|
|
33
|
+
...o
|
|
34
|
+
}
|
|
35
|
+
}] }
|
|
36
|
+
}];
|
|
37
|
+
return d && (m[0].data.extract[0].props[d] = { field: d }), f && (m[0].data.extract[0].props[f] = { field: f }), {
|
|
38
|
+
...r,
|
|
39
|
+
collections: m
|
|
40
|
+
};
|
|
41
|
+
}, U = "pie-alternates-switcher", W = "pie-alternates-switcher", G = (e) => s(e) || e.label || e.dataItem?.name || "Field", K = (e, t, n, r) => {
|
|
42
|
+
let i = n ? c(n.dataItem) : void 0;
|
|
43
|
+
return {
|
|
44
|
+
type: "native",
|
|
45
|
+
key: `${W}-interaction`,
|
|
46
|
+
events: { click(o) {
|
|
47
|
+
let s = this.element.getBoundingClientRect(), c = {
|
|
48
|
+
x: o.clientX - s.left,
|
|
49
|
+
y: o.clientY - s.top
|
|
50
|
+
}, l = this.chart.shapesAt(c, {
|
|
51
|
+
components: [{
|
|
52
|
+
key: W,
|
|
53
|
+
propagation: "stop"
|
|
54
|
+
}],
|
|
55
|
+
propagation: "stop"
|
|
56
|
+
}).find((e) => e.data?.target === "measure" || e.data?.target === "dimension");
|
|
57
|
+
if (l?.data?.target === "measure" && n && i) {
|
|
58
|
+
r(P.Text, "click", `text-${i}`, o, l, {
|
|
59
|
+
dataItemType: a.Measure,
|
|
60
|
+
dataItemRole: n.role
|
|
61
|
+
});
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
l?.data?.target === "dimension" && e && r(P.Text, "click", `text-${e}`, o, l, {
|
|
65
|
+
dataItemType: a.Dimension,
|
|
66
|
+
dataItemRole: t
|
|
67
|
+
});
|
|
68
|
+
} }
|
|
69
|
+
};
|
|
70
|
+
}, se = (e, r, o, s, l, d, f, p) => {
|
|
71
|
+
let m = u(e.dimensions, e.enableAlternate, d?.isPrintMode), h = e.dimensions.filter((e) => i(e)), g = h[0], _ = g ? c(g.dataItem) : void 0, v = e.measures.filter((e) => e.role === t.PIE_CHART_SLICE), y = u(v, e.enableAlternate, d?.isPrintMode), b = v.filter((e) => i(e))[0], x = m && h.length ? h.map((e) => G(e)).join(", ") : void 0, S = y && b ? G(b) : void 0;
|
|
72
|
+
if (!x && !S) return o;
|
|
73
|
+
let C = {
|
|
74
|
+
type: U,
|
|
75
|
+
key: W,
|
|
76
|
+
dimensionDataItemType: _ ? a.Dimension : void 0,
|
|
77
|
+
dimensionDataItemRole: g?.role,
|
|
78
|
+
measureDataItemType: b ? a.Measure : void 0,
|
|
79
|
+
measureDataItemRole: b?.role,
|
|
80
|
+
layout: {
|
|
81
|
+
dock: n.Bottom,
|
|
82
|
+
displayOrder: 0
|
|
83
|
+
},
|
|
84
|
+
settings: {
|
|
85
|
+
dimensionLabel: x ? D(x) : void 0,
|
|
86
|
+
measureLabel: S ? D(S) : void 0,
|
|
87
|
+
fontFamily: r.fonts.general.fontFamily,
|
|
88
|
+
fontSize: `${I.fieldTitle.fontSize}px`,
|
|
89
|
+
color: r.fonts.general.color,
|
|
90
|
+
paddingLeft: 5,
|
|
91
|
+
paddingRight: 5,
|
|
92
|
+
paddingVertical: 5,
|
|
93
|
+
labelGap: 12
|
|
94
|
+
}
|
|
95
|
+
}, w = p ? [K(_, g?.role, b, p)] : [];
|
|
96
|
+
return {
|
|
97
|
+
...o,
|
|
98
|
+
components: [...o.components, C],
|
|
99
|
+
interactions: o.interactions ? [...o.interactions, ...w] : w
|
|
100
|
+
};
|
|
101
|
+
}, q = {
|
|
102
|
+
outerRadius: .8,
|
|
103
|
+
outerRadiusWithoutLabels: .95,
|
|
104
|
+
cornerRadius: v.pie,
|
|
105
|
+
strokeWidth: 0,
|
|
106
|
+
strokeEnabled: !1,
|
|
107
|
+
strokeColor: "#C6C6C6",
|
|
108
|
+
multiMeasureMinRadius: .3,
|
|
109
|
+
donut: {
|
|
110
|
+
innerRadius: .55,
|
|
111
|
+
cornerRadius: v.donut,
|
|
112
|
+
multiMeasureMinRadius: .6
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
function J(e) {
|
|
116
|
+
return e.pieSettings?.donut ?? !1;
|
|
117
|
+
}
|
|
118
|
+
var ce = (e, n, r, a, o, s) => {
|
|
119
|
+
let l = e.measures.filter((e) => i(e)), u = l.filter((e) => e.role === t.PIE_CHART_SLICE), d = l.filter((e) => e.role === t.PIE_CHART_LENGTH), f = u[0], p = d[0], m = new L(e, n, o?.[0]?.itemsNotAffectedByFiltering), h = J(e) ? q.donut.innerRadius : 0, g = f?.dataLabels?.show === !1 ? q.outerRadiusWithoutLabels : q.outerRadius, _ = e.pieSettings?.cornerRadius ?? (J(e) ? q.donut.cornerRadius : q.cornerRadius), v = e.pieSettings?.strokeEnabled ?? q.strokeEnabled, y = e.pieSettings?.strokeWidth ?? q.strokeWidth, b = e.pieSettings?.strokeColor ?? q.strokeColor;
|
|
120
|
+
if (p) {
|
|
121
|
+
let t = g, n = J(e) ? q.donut.multiMeasureMinRadius : q.multiMeasureMinRadius;
|
|
122
|
+
g = (e) => e.resources.scale(c(p.dataItem))(e.datum.rad.value) * (t - n) + n;
|
|
123
|
+
}
|
|
124
|
+
let x = {
|
|
125
|
+
type: P.Pie,
|
|
126
|
+
key: `${P.Pie}`,
|
|
127
|
+
data: { collection: T.Collection },
|
|
128
|
+
animations: {
|
|
129
|
+
enabled: !0,
|
|
130
|
+
presetId: "pie-chart"
|
|
131
|
+
},
|
|
132
|
+
settings: { slice: {
|
|
133
|
+
arc: { ref: "num" },
|
|
134
|
+
stroke: b,
|
|
135
|
+
strokeWidth: v ? y : 0,
|
|
136
|
+
cornerRadius: _,
|
|
137
|
+
innerRadius: h,
|
|
138
|
+
outerRadius: g,
|
|
139
|
+
fill: m.getColorDefinition({ ref: "color" })
|
|
140
|
+
} },
|
|
141
|
+
brush: O([""], s, { valuePickerMode: s?.valuePickerMode })
|
|
142
|
+
};
|
|
143
|
+
return {
|
|
144
|
+
...r,
|
|
145
|
+
components: [...r.components, x]
|
|
146
|
+
};
|
|
147
|
+
}, le = (e, t, n) => ({ data: r, formatter: a }) => {
|
|
148
|
+
let o = e.dimensions.filter((e) => i(e))[0], s = r.value, c = r[V.num].value, l = o.formatter && s && a ? a(o.formatter)(s) : `${s}`, u = t.formatter && c && a ? a(t.formatter)(c, void 0, r) : `${c}`, d = c != null && n && a ? a(ne)(c / n) : null, f = () => t.dataLabels?.measureLabelFormat === g.Percentage ? [d] : t.dataLabels?.measureLabelFormat === g.ValueAndPercentage ? [u, d] : [u];
|
|
149
|
+
switch (t.dataLabels?.labelFormat) {
|
|
150
|
+
case _.Measure: {
|
|
151
|
+
let e = f();
|
|
152
|
+
return e.length === 1 ? e[0] : e;
|
|
153
|
+
}
|
|
154
|
+
case _.DimensionAndMeasure: return [l, ...f()];
|
|
155
|
+
default: return l;
|
|
156
|
+
}
|
|
157
|
+
}, ue = (e, n, r, a, o, s) => {
|
|
158
|
+
let c = e.dimensions.filter((e) => i(e)), l = e.measures.filter((e) => i(e)), u = c[0], d = l.find((e) => e.role === t.PIE_CHART_SLICE) ?? l[0];
|
|
159
|
+
if (!u || !d || !d.dataLabels?.show) return r;
|
|
160
|
+
let f = new F(n.fonts.general.color), p = d.dataLabels.showBackdrop ? C(d.dataLabels.backdropColor ? { fill: d.dataLabels.backdropColor } : void 0) : void 0, m = p ? y(f) : d.dataLabels.textColor || "#000", { strokeEnabled: h, strokeWidth: g = q.strokeWidth } = e.pieSettings, _ = h ? g / 2 : 0, v = {
|
|
161
|
+
type: P.Labels,
|
|
162
|
+
key: "pie-labels",
|
|
163
|
+
animations: {
|
|
164
|
+
enabled: !0,
|
|
165
|
+
presetId: "chart-labels"
|
|
166
|
+
},
|
|
167
|
+
layout: { displayOrder: b.Labels },
|
|
168
|
+
settings: { sources: [{
|
|
169
|
+
component: `${P.Pie}`,
|
|
170
|
+
selector: ae.Path,
|
|
171
|
+
strategy: {
|
|
172
|
+
type: "slice",
|
|
173
|
+
settings: {
|
|
174
|
+
fontSize: x(d.dataLabels.size),
|
|
175
|
+
fontFamily: n.fonts.general.fontFamily,
|
|
176
|
+
labels: [{
|
|
177
|
+
label: le(e, d, o[0].sum),
|
|
178
|
+
placements: [{
|
|
179
|
+
position: "outside",
|
|
180
|
+
fill: m,
|
|
181
|
+
backdrop: p
|
|
182
|
+
}],
|
|
183
|
+
strokeDelta: _,
|
|
184
|
+
linkData: ({ data: e }) => e
|
|
185
|
+
}]
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}] },
|
|
189
|
+
brush: O([""], s, { valuePickerMode: s?.valuePickerMode })
|
|
190
|
+
};
|
|
191
|
+
return {
|
|
192
|
+
...r,
|
|
193
|
+
components: [...r.components, v]
|
|
194
|
+
};
|
|
195
|
+
}, Y = (e, t, n, r, i) => {
|
|
196
|
+
let a = n.data[t]?.value, o = s(e) || e.label || e.dataItem.name || "", c = a;
|
|
197
|
+
return !i && e.formatter ? c = r.formatter(e.formatter)(a, void 0, n.data) : i && (c = r.formatter(oe(e.formatter))(a, void 0, n.data)), {
|
|
198
|
+
label: o,
|
|
199
|
+
value: c
|
|
200
|
+
};
|
|
201
|
+
}, de = (e, n, r, a, o) => {
|
|
202
|
+
let s = !!e.measures.filter(i).filter((e) => e.role === t.PIE_CHART_LENGTH)?.[0], c = {
|
|
203
|
+
filter: (e) => e.filter((e) => e.key === P.Pie),
|
|
204
|
+
placement: {
|
|
205
|
+
type: "slice",
|
|
206
|
+
area: "target"
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
if (s) return k(e, n, r, c, "tooltip", o);
|
|
210
|
+
let l = N(e, o), u = A(e, n, fe, w, o?.[0]?.sum, l);
|
|
211
|
+
return k(e, n, r, {
|
|
212
|
+
...c,
|
|
213
|
+
extract: u
|
|
214
|
+
}, "tooltip", o);
|
|
215
|
+
}, fe = (e, t, n, r, a, o, s, l) => {
|
|
216
|
+
let u = [], d = e.filter(i), f = M(n), p = d.filter((e) => !f.has(c(e.dataItem)))?.[0] ?? d?.[0], m = Object.keys(t.data).find((e) => t.data[e]?.source?.field === c(p?.dataItem));
|
|
217
|
+
if (!m || !p ? u.push({
|
|
218
|
+
label: "",
|
|
219
|
+
value: ""
|
|
220
|
+
}) : u.push(Y(p, m, t, n, l)), d.filter((e) => f.has(c(e.dataItem))).forEach((e) => {
|
|
221
|
+
let r = c(e.dataItem), i = Object.keys(t.data).find((e) => t.data[e]?.source?.field === r);
|
|
222
|
+
i && u.push(Y(e, i, t, n, l));
|
|
223
|
+
}), s) return u;
|
|
224
|
+
let h = Object.values(o ?? {}).reduce((e, t) => e + Number(t), 0);
|
|
225
|
+
return u.push({
|
|
226
|
+
label: "Total",
|
|
227
|
+
value: p?.formatter ? n.formatter(p.formatter)(h) : h
|
|
228
|
+
}), u;
|
|
229
|
+
}, pe = class extends re {
|
|
230
|
+
constructor() {
|
|
231
|
+
super([
|
|
232
|
+
H,
|
|
233
|
+
B,
|
|
234
|
+
ce,
|
|
235
|
+
se,
|
|
236
|
+
ue,
|
|
237
|
+
j,
|
|
238
|
+
de
|
|
239
|
+
]);
|
|
240
|
+
}
|
|
241
|
+
preCompile(e) {
|
|
242
|
+
let t = e.dimensions.filter((e) => i(e))?.[0], n = e.measures.filter((e) => i(e))?.[0];
|
|
243
|
+
if (!t || !n) throw Error("Charts w/o dimensions or measures are not supported ATM.");
|
|
244
|
+
}
|
|
245
|
+
}, X = " ▼", Z = "...", Q = (e, t, n, r) => e.measureText({
|
|
246
|
+
text: t,
|
|
247
|
+
fontFamily: n,
|
|
248
|
+
fontSize: r
|
|
249
|
+
}).width, $ = (e, t, n, r, i) => {
|
|
250
|
+
if (t <= 0 || Q(n, e, r, i) <= t) return e;
|
|
251
|
+
let a = e.endsWith(X), o = a ? X : "", s = a ? e.slice(0, -2) : e;
|
|
252
|
+
if (Q(n, `${Z}${o}`, r, i) > t) return Z;
|
|
253
|
+
let c = 0, l = s.length;
|
|
254
|
+
for (; c < l;) {
|
|
255
|
+
let e = Math.ceil((c + l) / 2);
|
|
256
|
+
Q(n, `${s.slice(0, e)}${Z}${o}`, r, i) <= t ? c = e : l = e - 1;
|
|
257
|
+
}
|
|
258
|
+
return `${s.slice(0, c)}${Z}${o}`;
|
|
259
|
+
}, me = {
|
|
260
|
+
require: ["renderer"],
|
|
261
|
+
defaultSettings: { settings: {
|
|
262
|
+
dimensionLabel: "",
|
|
263
|
+
measureLabel: "",
|
|
264
|
+
fontSize: "12px",
|
|
265
|
+
color: "#000",
|
|
266
|
+
paddingLeft: 5,
|
|
267
|
+
paddingRight: 5,
|
|
268
|
+
paddingVertical: 5,
|
|
269
|
+
labelGap: 12
|
|
270
|
+
} },
|
|
271
|
+
preferredSize() {
|
|
272
|
+
let { fontFamily: e = "Arial", fontSize: t, paddingVertical: n } = this.settings.settings;
|
|
273
|
+
return this.renderer.measureText({
|
|
274
|
+
fontFamily: e,
|
|
275
|
+
fontSize: t
|
|
276
|
+
}).height + n * 2;
|
|
277
|
+
},
|
|
278
|
+
render() {
|
|
279
|
+
let { dimensionLabel: e, measureLabel: t, fontFamily: n = "Arial", fontSize: r, color: i, paddingLeft: a, paddingRight: o, labelGap: s } = this.settings.settings, c = t ? Q(this.renderer, t, n, r) : 0, l = this.rect.width - o, u = l - c, d = Math.max(Math.min(t ? u - s - a : this.rect.width - a - o, this.rect.width / 2), 0), f = e ? $(e, d, this.renderer, n, r) : "", p = f ? Q(this.renderer, f, n, r) : 0, m = [];
|
|
280
|
+
return t && m.push({
|
|
281
|
+
type: "rect",
|
|
282
|
+
x: Math.max(u, 0),
|
|
283
|
+
y: 0,
|
|
284
|
+
width: Math.min(c, this.rect.width),
|
|
285
|
+
height: this.rect.height,
|
|
286
|
+
fill: "rgba(0, 0, 0, 0)",
|
|
287
|
+
strokeWidth: 0,
|
|
288
|
+
data: { target: "measure" }
|
|
289
|
+
}), e && (m.push({
|
|
290
|
+
type: "rect",
|
|
291
|
+
x: a,
|
|
292
|
+
y: 0,
|
|
293
|
+
width: p,
|
|
294
|
+
height: this.rect.height,
|
|
295
|
+
fill: "rgba(0, 0, 0, 0)",
|
|
296
|
+
strokeWidth: 0,
|
|
297
|
+
data: { target: "dimension" }
|
|
298
|
+
}), m.push({
|
|
299
|
+
type: "text",
|
|
300
|
+
text: f,
|
|
301
|
+
x: a,
|
|
302
|
+
y: this.rect.height / 2,
|
|
303
|
+
anchor: "start",
|
|
304
|
+
baseline: "central",
|
|
305
|
+
fontFamily: n,
|
|
306
|
+
fontSize: r,
|
|
307
|
+
fill: i,
|
|
308
|
+
maxWidth: d,
|
|
309
|
+
data: { target: "dimension" }
|
|
310
|
+
})), t && m.push({
|
|
311
|
+
type: "text",
|
|
312
|
+
text: t,
|
|
313
|
+
x: l,
|
|
314
|
+
y: this.rect.height / 2,
|
|
315
|
+
anchor: "end",
|
|
316
|
+
baseline: "central",
|
|
317
|
+
fontFamily: n,
|
|
318
|
+
fontSize: r,
|
|
319
|
+
fill: i,
|
|
320
|
+
data: { target: "measure" }
|
|
321
|
+
}), m;
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
function he(e) {
|
|
325
|
+
e.component(U, me);
|
|
326
|
+
}
|
|
327
|
+
var ge = h(), _e = p(({ vSpec: e, vTheme: t, data: n, elementSize: i, vizProperties: a }) => {
|
|
328
|
+
let o = f(), [s] = (0, z.useState)(() => new pe()), { activeKey: u } = m(), d = {
|
|
329
|
+
...a,
|
|
330
|
+
valuePickerMode: !!u
|
|
331
|
+
}, p = t || r;
|
|
332
|
+
if (n?.[0]?.items && e?.measures?.length) {
|
|
333
|
+
let t = n[0].items.reduce((t, n) => t + n[c(e.measures[0].dataItem)], 0);
|
|
334
|
+
n[0].sum = t;
|
|
335
|
+
}
|
|
336
|
+
let h = s.compile(e, p, n, i, d, l.Pie, o, void 0, ie());
|
|
337
|
+
return h ? /* @__PURE__ */ (0, ge.jsx)(te, {
|
|
338
|
+
config: d,
|
|
339
|
+
definition: h,
|
|
340
|
+
size: i,
|
|
341
|
+
vSpec: e,
|
|
342
|
+
escobarPlugins: [he]
|
|
343
|
+
}) : null;
|
|
344
|
+
});
|
|
345
|
+
export { _e as PieChart };
|