@iota-uz/sdk 0.5.4 → 0.5.6
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/dist/client-host/identity.d.ts +4 -4
- package/dist/client-host/identity.js +2 -2
- package/dist/lens/{CascadePanel-CdeeYZsY.js → CascadePanel-8eBL6DV0.js} +1 -1
- package/dist/lens/{ChartHost-DLcWF7pC.js → ChartHost-rxIhps-d.js} +2 -2
- package/dist/lens/ChartPanel-DCQW-AER.js +729 -0
- package/dist/lens/{CoveragePanel-C5Y50Ja8.js → CoveragePanel-CxzKUDi7.js} +1 -1
- package/dist/lens/DashboardPanels.d.ts.map +1 -1
- package/dist/lens/{GaugePanel-QdD8-G_m.js → GaugePanel-DxugJaW9.js} +1 -1
- package/dist/lens/{MapPanel-BYrx4srW.js → MapPanel-CSaipUVx.js} +2 -2
- package/dist/lens/{MetricFlowPanel-LreyGLdP.js → MetricFlowPanel-DboMsdRV.js} +2 -2
- package/dist/lens/{MetricHierarchyPanel-DvIh-llg.js → MetricHierarchyPanel-CB4VzfzW.js} +2 -2
- package/dist/lens/{MetricRelationshipPanel-C-aL3I9t.js → MetricRelationshipPanel-Cc5q2404.js} +2 -2
- package/dist/lens/{PrintReport-QqzDAR7K.js → PrintReport-B1Sz9tpp.js} +5 -5
- package/dist/lens/{TablePanel-DFfsYjWR.js → TablePanel-DmexOyme.js} +1 -1
- package/dist/lens/{adapter-BoXhQplf.js → adapter-D1rmM8ve.js} +143 -124
- package/dist/lens/charts/echarts/options.d.ts.map +1 -1
- package/dist/lens/contract/schemas.d.ts +1 -0
- package/dist/lens/contract/schemas.d.ts.map +1 -1
- package/dist/lens/contract/types.d.ts +5 -0
- package/dist/lens/contract/types.d.ts.map +1 -1
- package/dist/lens/controls/FilterBar.d.ts +5 -0
- package/dist/lens/controls/FilterBar.d.ts.map +1 -1
- package/dist/lens/{index-C3g4ib1H.js → index-BVG-TPw8.js} +2422 -2405
- package/dist/lens/{index-D16WayLn.js → index-DNVZzuf-.js} +1 -1
- package/dist/lens/index.js +1 -1
- package/dist/lens/{install-DiwRwFDZ.js → install-B84coHbE.js} +1 -1
- package/dist/lens/{install-Cw9b8dcU.js → install-BBDdlL7p.js} +1 -1
- package/dist/lens/{install-4afWuWQV.js → install-D185mcsK.js} +1 -1
- package/dist/lens/{install-DCnlqrJl.js → install-DEcc_o1k.js} +1 -1
- package/dist/lens/{metricViews-qsMUANFL.js → metricViews-CeM9-z5k.js} +1 -1
- package/dist/lens/panels/ChartPanel.d.ts.map +1 -1
- package/dist/lens/{prefetch-3fl1oLRK.js → prefetch-B-dQcQXC.js} +2 -2
- package/dist/lens/{prefetchPanels-DjyNoBKV.js → prefetchPanels-E12FEaLx.js} +1 -1
- package/dist/lens/{print-D6eDEk5V.js → print-UTQOLwVp.js} +1 -1
- package/dist/lens/{scales-CuZBfqCM.js → scales-DvqEigLb.js} +2 -2
- package/dist/lens/style.css +1 -1
- package/dist/sdk-identity.cjs +3 -3
- package/dist/sdk-identity.js +3 -3
- package/dist/sdk-identity.json +2 -2
- package/package.json +1 -1
- package/dist/lens/ChartPanel-DBX4StoU.js +0 -720
|
@@ -0,0 +1,729 @@
|
|
|
1
|
+
import { jsxs as R, jsx as l, Fragment as Ee } from "react/jsx-runtime";
|
|
2
|
+
import { useState as ae, useRef as Pe, useCallback as Ae, useEffect as xe, useMemo as T, memo as bt, useLayoutEffect as kt, Fragment as Rt } from "react";
|
|
3
|
+
import { r as Kt, f as Tt } from "./keys-DenV5HsJ.js";
|
|
4
|
+
import { s as Ft, o as ze, c as Et, a as Mt, b as Bt, d as Ht, f as _t } from "./scales-DvqEigLb.js";
|
|
5
|
+
import { o as zt, u as Re, a as pt, t as Ot, x as ut, y as mt, l as Ut, z as Vt, A as Dt, B as $t, C as Pt, k as qt, D as jt, E as Wt, F as ht, h as xt, s as St, G as It, H as Qt, I as Zt, g as Gt, J as Jt, K as Yt, P as Xt, W as eo, L as H, M as ft, N as to, O as Oe, Q as oo, R as no, S as ro, T as so } from "./index-BVG-TPw8.js";
|
|
6
|
+
import "@iota-uz/sdk/client-host";
|
|
7
|
+
import { c as io, C as ao } from "./ChartDataEquivalent-BFDdHoQn.js";
|
|
8
|
+
import { C as co } from "./ChartHost-rxIhps-d.js";
|
|
9
|
+
const lo = 0.02, go = so, uo = 4;
|
|
10
|
+
function mo(e) {
|
|
11
|
+
const n = H(), t = H(e.encoding.label ? e.format[e.encoding.label] : void 0), r = H(e.encoding.value ? e.format[e.encoding.value] : void 0), c = H(e.encoding.previous ? e.format[e.encoding.previous] : void 0), a = H(e.encoding.lower ? e.format[e.encoding.lower] : void 0), m = H(e.encoding.q1 ? e.format[e.encoding.q1] : void 0), y = H(e.encoding.median ? e.format[e.encoding.median] : void 0), f = H(e.encoding.q3 ? e.format[e.encoding.q3] : void 0), b = H(e.encoding.upper ? e.format[e.encoding.upper] : void 0), v = H(e.encoding.id ? e.format[e.encoding.id] : void 0), F = H(e.encoding.series ? e.format[e.encoding.series] : void 0), h = H(e.encoding.category ? e.format[e.encoding.category] : void 0), u = H(e.encoding.cut ? e.format[e.encoding.cut] : void 0), N = H(e.encoding.cutLabel ? e.format[e.encoding.cutLabel] : void 0), ce = H(e.encoding.final ? e.format[e.encoding.final] : void 0), D = ft(e.encoding.value ? e.format[e.encoding.value] : void 0), ee = ft(e.encoding.median ? e.format[e.encoding.median] : void 0), _ = T(() => {
|
|
12
|
+
const B = { label: t, value: r, previous: c, lower: a, q1: m, median: y, q3: f, upper: b, id: v, series: F, category: h, cut: u, cutLabel: N, final: ce }, A = /* @__PURE__ */ new Map();
|
|
13
|
+
for (const C of to) {
|
|
14
|
+
const te = e.encoding[C], K = B[C];
|
|
15
|
+
te && K && A.set(te, K);
|
|
16
|
+
}
|
|
17
|
+
return (C, te) => (A.get(C) ?? n)(te);
|
|
18
|
+
}, [h, u, N, n, ce, v, t, a, y, e.encoding, c, m, f, F, b, r]), se = T(() => {
|
|
19
|
+
const B = e.encoding.value, A = e.encoding.median;
|
|
20
|
+
return (C, te) => B && C === B ? D(te) : A && C === A ? ee(te) : _(C, te);
|
|
21
|
+
}, [ee, _, e.encoding.median, e.encoding.value, D]);
|
|
22
|
+
return T(() => ({ format: _, formatAxis: se }), [_, se]);
|
|
23
|
+
}
|
|
24
|
+
function Ue(e, n, t) {
|
|
25
|
+
var y, f;
|
|
26
|
+
const r = n.encoding.id ? e.columns.findIndex((b) => b.name === n.encoding.id) : -1, c = [n.encoding.category, n.encoding.label].find((b) => !!b && e.columns.some((v) => v.name === b)), a = e.columns.findIndex((b) => b.name === c), m = r >= 0 ? (y = e.rows[t]) == null ? void 0 : y[r] : (f = e.rows[t]) == null ? void 0 : f[a];
|
|
27
|
+
return String(typeof m == "string" || typeof m == "number" || typeof m == "bigint" ? m : t);
|
|
28
|
+
}
|
|
29
|
+
function vt(e, n, t) {
|
|
30
|
+
var y;
|
|
31
|
+
if (((y = n.radial) == null ? void 0 : y.mode) === "partition" && n.encoding.series) {
|
|
32
|
+
const f = e.columns.findIndex((b) => b.name === n.encoding.series);
|
|
33
|
+
if (f >= 0) {
|
|
34
|
+
const b = e.rows.findIndex((v, F) => {
|
|
35
|
+
const h = v[f], u = typeof h == "string" || typeof h == "number" || typeof h == "bigint" ? String(h) : "";
|
|
36
|
+
return Kt(u, Ue(e, n, F)) === t;
|
|
37
|
+
});
|
|
38
|
+
if (b >= 0) return b;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const r = e.rows.findIndex((f, b) => Ue(e, n, b) === t);
|
|
42
|
+
if (r >= 0) return r;
|
|
43
|
+
const c = n.encoding.category ?? n.encoding.label, a = e.columns.findIndex((f) => f.name === c), m = e.columns.findIndex((f) => f.name === n.encoding.series);
|
|
44
|
+
return a < 0 ? -1 : e.rows.findIndex((f) => Tt(
|
|
45
|
+
ke(f[a]),
|
|
46
|
+
m >= 0 ? ke(f[m]) : ""
|
|
47
|
+
) === t);
|
|
48
|
+
}
|
|
49
|
+
function Nt(e, n) {
|
|
50
|
+
return n.semantics !== "series" || !n.encoding.series ? -1 : e.columns.findIndex((t) => t.name === n.encoding.series);
|
|
51
|
+
}
|
|
52
|
+
function ho(e, n) {
|
|
53
|
+
const t = /* @__PURE__ */ new Map();
|
|
54
|
+
if (!e) return t;
|
|
55
|
+
const r = e.columns.findIndex((c) => c.name === n.encoding.series);
|
|
56
|
+
if (r < 0) return t;
|
|
57
|
+
for (const c of e.rows) {
|
|
58
|
+
const a = c[r];
|
|
59
|
+
if (typeof a != "string" && typeof a != "number" && typeof a != "bigint") continue;
|
|
60
|
+
const m = String(a);
|
|
61
|
+
t.has(m) || t.set(m, t.size);
|
|
62
|
+
}
|
|
63
|
+
return t;
|
|
64
|
+
}
|
|
65
|
+
function fo(e, n, t) {
|
|
66
|
+
var a;
|
|
67
|
+
const r = Nt(e, n);
|
|
68
|
+
if (r < 0) return Ue(e, n, t);
|
|
69
|
+
const c = (a = e.rows[t]) == null ? void 0 : a[r];
|
|
70
|
+
return String(typeof c == "string" || typeof c == "number" || typeof c == "bigint" ? c : t);
|
|
71
|
+
}
|
|
72
|
+
function he(e) {
|
|
73
|
+
if (typeof e == "number" && Number.isFinite(e)) return e;
|
|
74
|
+
if (typeof e == "string" && e.trim() !== "") {
|
|
75
|
+
const n = Number(e);
|
|
76
|
+
if (Number.isFinite(n)) return n;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function ke(e) {
|
|
80
|
+
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "bigint" ? String(e) : "";
|
|
81
|
+
}
|
|
82
|
+
function vo(e, n) {
|
|
83
|
+
const c = (n.kind === "pie" || n.kind === "donut" || n.kind === "radial" ? [n.encoding.label, n.encoding.category] : [n.encoding.category, n.encoding.label]).reduce((a, m) => a >= 0 || !m ? a : e.columns.findIndex((y) => y.name === m), -1);
|
|
84
|
+
return c < 0 ? 0 : new Set(e.rows.map((a) => a[c]).filter((a) => a != null).map(String)).size;
|
|
85
|
+
}
|
|
86
|
+
function wo(e, n) {
|
|
87
|
+
const t = e.columns.findIndex((r) => r.name === n.encoding.series);
|
|
88
|
+
return t < 0 ? 1 : new Set(e.rows.map((r) => r[t]).filter((r) => r != null).map(String)).size;
|
|
89
|
+
}
|
|
90
|
+
const Ct = "__lens_other__", yo = "__lens_topn_group";
|
|
91
|
+
function wt(e, n) {
|
|
92
|
+
var v, F;
|
|
93
|
+
const t = e.columns.findIndex((h) => h.name === yo), r = e.columns.findIndex((h) => h.name === (n.encoding.label ?? n.encoding.category)), c = e.columns.findIndex((h) => h.name === n.encoding.id), a = e.columns.findIndex((h) => h.name === n.encoding.value);
|
|
94
|
+
if (t < 0 || r < 0 || a < 0) return { frame: e, collapsed: !1 };
|
|
95
|
+
const m = e.rows.filter((h) => typeof h[t] == "string" && String(h[t]).trim() !== "");
|
|
96
|
+
if (m.length === 0) return { frame: e, collapsed: !1 };
|
|
97
|
+
const y = e.rows.filter((h) => !m.includes(h)).map((h) => [...h]), f = new Array(e.columns.length).fill(null);
|
|
98
|
+
f[t] = (v = m[0]) == null ? void 0 : v[t], f[r] = (F = m[0]) == null ? void 0 : F[t], c >= 0 && (f[c] = Ct), f[a] = m.reduce((h, u) => h + (he(u[a]) ?? 0), 0), y.push(f);
|
|
99
|
+
const b = e.colors ? [...e.colors.filter((h, u) => !m.includes(e.rows[u])), Oe()] : [...y.slice(0, -1).map(() => ""), Oe()];
|
|
100
|
+
return { frame: { ...e, rows: y, colors: b }, collapsed: !0 };
|
|
101
|
+
}
|
|
102
|
+
function yt(e, n, t) {
|
|
103
|
+
if (n.kind !== "donut" || e.rows.length < 2) return { frame: e, collapsed: !1 };
|
|
104
|
+
const r = e.columns.findIndex((u) => u.name === (n.encoding.label ?? n.encoding.category)), c = e.columns.findIndex((u) => u.name === n.encoding.id), a = e.columns.findIndex((u) => u.name === n.encoding.value);
|
|
105
|
+
if (r < 0 || a < 0) return { frame: e, collapsed: !1 };
|
|
106
|
+
const m = e.total ?? e.rows.reduce((u, N) => u + (he(N[a]) ?? 0), 0);
|
|
107
|
+
if (!Number.isFinite(m) || m <= 0) return { frame: e, collapsed: !1 };
|
|
108
|
+
const y = e.rows.map((u, N) => ({ index: N, value: he(u[a]) ?? 0 })).filter(({ value: u }) => u / m < lo);
|
|
109
|
+
if (y.length === 0) return { frame: e, collapsed: !1 };
|
|
110
|
+
const f = new Set(y.map(({ index: u }) => u)), b = e.rows.filter((u, N) => !f.has(N)).map((u) => [...u]), v = new Array(e.columns.length).fill(null);
|
|
111
|
+
v[r] = t, c >= 0 && (v[c] = Ct), v[a] = y.reduce((u, N) => u + N.value, 0), b.push(v);
|
|
112
|
+
const F = e.rows.map((u, N) => N).filter((u) => !f.has(u)), h = e.colors ? [...e.colors.filter((u, N) => !f.has(N)), Oe()] : [...F.map(() => ""), Oe()];
|
|
113
|
+
return { frame: { ...e, rows: b, colors: h }, collapsed: !0 };
|
|
114
|
+
}
|
|
115
|
+
function Fo({ panel: e, adapter: n }) {
|
|
116
|
+
var Ze, Ge, Je, Ye, Xe, et, tt, ot, nt, rt, st, it, at, ct, lt;
|
|
117
|
+
const t = zt(e.id), r = Re(), { document: c, navigation: a } = pt(), { drillInto: m } = Ot(), { format: y, formatAxis: f } = mo(e), [b, v] = ae(), [F, h] = ae(!1), [u, N] = ae(0), ce = typeof window > "u" ? { regression: !1 } : ut(new URL(window.location.href), e.id), [D, ee] = ae(ce.regression), [_, se] = ae(ce.movingAverage), [B, A] = ae(() => /* @__PURE__ */ new Set()), [C, te] = ae(() => typeof window > "u" ? /* @__PURE__ */ new Set() : mt(new URL(window.location.href), e.id)), K = C, oe = a.panelId === e.id && a.path.length > 0, W = oe ? Ut(c, a.path) : e.drillRoot ? c.drill.edges[e.drillRoot] : void 0, Me = W ? W.children.some(({ target: o }) => o) : !!e.drillRoot, ne = !!e.drillRoot || !!W, z = Vt(e), le = Pe(), de = Ae((o) => {
|
|
118
|
+
if (ne || !z.action || !t.data) return;
|
|
119
|
+
const i = vt(t.data, e, o);
|
|
120
|
+
return z.urlForRow(t.data, i >= 0 ? t.data.rows[i] : void 0);
|
|
121
|
+
}, [t.data, ne, z, e]), fe = Ae((o) => {
|
|
122
|
+
var i;
|
|
123
|
+
(i = le.current) == null || i.call(le), le.current = void 0, !(o === null || ne) && (le.current = z.prefetch(de(o)));
|
|
124
|
+
}, [ne, de, z]);
|
|
125
|
+
xe(() => () => {
|
|
126
|
+
var o;
|
|
127
|
+
return (o = le.current) == null ? void 0 : o.call(le);
|
|
128
|
+
}, []);
|
|
129
|
+
const J = T(() => {
|
|
130
|
+
var o;
|
|
131
|
+
return ne || ((o = z.action) == null ? void 0 : o.kind) !== "open_drawer" || !t.data ? [] : t.data.rows.length === 0 || t.data.rows.length > 4 ? [] : [...new Set(t.data.rows.flatMap((i) => {
|
|
132
|
+
const d = z.urlForRow(t.data, i);
|
|
133
|
+
return d ? [d] : [];
|
|
134
|
+
}))];
|
|
135
|
+
}, [t.data, ne, z]);
|
|
136
|
+
xe(() => {
|
|
137
|
+
if (J.length !== 0)
|
|
138
|
+
return z.prefetchIdle(J);
|
|
139
|
+
}, [J, z]);
|
|
140
|
+
const I = Dt(), Y = ((Ze = z.action) == null ? void 0 : Ze.kind) === "cross_filter" || ((Ge = z.action) == null ? void 0 : Ge.kind) === "cube_drill" ? z.action.filter : void 0, be = T(() => {
|
|
141
|
+
if (!(Y != null && Y.dimension)) return;
|
|
142
|
+
const o = I.values[$t], i = Array.isArray(o) ? o : o ? [o] : [], d = `${Y.dimension}:`, w = new Set(i.filter((k) => k.startsWith(d)).map((k) => k.slice(d.length)));
|
|
143
|
+
return w.size > 0 ? w : void 0;
|
|
144
|
+
}, [Y == null ? void 0 : Y.dimension, I.values]), Ke = T(() => {
|
|
145
|
+
if (!be || !Y || !t.data) return;
|
|
146
|
+
new URL(globalThis.location.href);
|
|
147
|
+
const o = t.data;
|
|
148
|
+
for (let i = 0; i < o.rows.length; i += 1) {
|
|
149
|
+
const d = Pt(Y.value, {
|
|
150
|
+
fields: qt(o, o.rows[i]),
|
|
151
|
+
variables: {}
|
|
152
|
+
}), w = ke(d);
|
|
153
|
+
if (w !== "" && be.has(w)) return Ue(o, e, i);
|
|
154
|
+
}
|
|
155
|
+
}, [be, Y, t.data, e]), X = e.kind, Te = t.data ? vo(t.data, e) <= 1 && wo(t.data, e) <= 1 : !1, Se = `${a.panelId === e.id ? a.path.join("|") : ""}:${a.perspectiveId ?? ""}`, Ie = Pe(Se);
|
|
156
|
+
xe(() => {
|
|
157
|
+
Ie.current !== Se && (Ie.current = Se, v(void 0));
|
|
158
|
+
}, [Se]);
|
|
159
|
+
const ve = Ae((o) => te(new Set(o)), []);
|
|
160
|
+
xe(() => {
|
|
161
|
+
if (typeof window > "u") return;
|
|
162
|
+
const o = () => ve(mt(new URL(window.location.href), e.id));
|
|
163
|
+
return window.addEventListener("popstate", o), () => window.removeEventListener("popstate", o);
|
|
164
|
+
}, [e.id, ve]), xe(() => {
|
|
165
|
+
if (typeof window > "u") return;
|
|
166
|
+
const o = new URL(window.location.href), i = jt(o, e.id, K);
|
|
167
|
+
i.search !== o.search && window.history.replaceState(window.history.state, "", i);
|
|
168
|
+
}, [K, e.id]), xe(() => {
|
|
169
|
+
if (typeof window > "u") return;
|
|
170
|
+
const o = () => {
|
|
171
|
+
const i = ut(new URL(window.location.href), e.id);
|
|
172
|
+
ee(i.regression), se(i.movingAverage);
|
|
173
|
+
};
|
|
174
|
+
return window.addEventListener("popstate", o), () => window.removeEventListener("popstate", o);
|
|
175
|
+
}, [e.id]), xe(() => {
|
|
176
|
+
if (typeof window > "u") return;
|
|
177
|
+
const o = new URL(window.location.href), i = Wt(o, e.id, { regression: D, movingAverage: _ });
|
|
178
|
+
i.search !== o.search && window.history.replaceState(window.history.state, "", i);
|
|
179
|
+
}, [_, e.id, D]);
|
|
180
|
+
const $ = T(() => {
|
|
181
|
+
var O, me;
|
|
182
|
+
if (!t.data || K.size === 0) return t.data;
|
|
183
|
+
const o = t.data.rows.map((G, ie) => !K.has(fo(t.data, e, ie))), i = t.data.rows.filter((G, ie) => o[ie]), d = (O = t.data.colors) == null ? void 0 : O.filter((G, ie) => o[ie]), w = t.data.columns.findIndex((G) => G.name === e.encoding.value), k = ((me = e.radial) == null ? void 0 : me.mode) === "partition" || w < 0 ? t.data.total : i.reduce((G, ie) => G + (he(ie[w]) ?? 0), 0);
|
|
184
|
+
return { ...t.data, rows: i, total: k, ...d ? { colors: d } : {} };
|
|
185
|
+
}, [t.data, K, e]), E = T(() => $ ? (() => {
|
|
186
|
+
const o = wt($, e);
|
|
187
|
+
return o.collapsed ? o : yt($, e, r("chart.other", "Other"));
|
|
188
|
+
})() : { frame: $, collapsed: !1 }, [e, r, $]), Fe = E.collapsed && E.frame ? io(E.frame, e, E.frame.rows.length - 1) : void 0, U = F || !E.collapsed ? $ : E.frame, s = U ? Ft(U, e.encoding, e.valueAxis, (Je = e.presentation) == null ? void 0 : Je.valueSpreadThreshold) : !1, L = T(() => {
|
|
189
|
+
if (!t.data || F) return t.data;
|
|
190
|
+
const o = wt(t.data, e);
|
|
191
|
+
return o.collapsed ? o.frame : yt(t.data, e, r("chart.other", "Other")).frame;
|
|
192
|
+
}, [t.data, e, F, r]), S = T(() => {
|
|
193
|
+
var i;
|
|
194
|
+
if (!t.data || K.size === 0 || !e.encoding.value || ((i = e.radial) == null ? void 0 : i.mode) === "partition") return;
|
|
195
|
+
const o = t.data.columns.findIndex((d) => d.name === e.encoding.value);
|
|
196
|
+
if (!(o < 0))
|
|
197
|
+
return (($ == null ? void 0 : $.rows) ?? []).reduce((d, w) => d + (he(w[o]) ?? 0), 0);
|
|
198
|
+
}, [t.data, K.size, e.encoding.value, (Ye = e.radial) == null ? void 0 : Ye.mode, $]), re = T(() => {
|
|
199
|
+
var i;
|
|
200
|
+
if (!t.data || !e.encoding.value || ((i = e.radial) == null ? void 0 : i.mode) === "partition") return;
|
|
201
|
+
const o = t.data.columns.findIndex((d) => d.name === e.encoding.value);
|
|
202
|
+
if (!(o < 0))
|
|
203
|
+
return t.data.rows.reduce((d, w) => d + (he(w[o]) ?? 0), 0);
|
|
204
|
+
}, [t.data, e.encoding.value, (Xe = e.radial) == null ? void 0 : Xe.mode]), Q = K.size > 0 && (($ == null ? void 0 : $.rows.length) ?? 0) === 0, P = t.data && t.data.rows.length > 0 ? t.data.total ?? (oe || e.kind === "pie" || e.kind === "donut" || e.kind === "radial" ? re : void 0) ?? e.total : void 0, V = P === void 0 || Q ? null : K.size > 0 ? S ?? null : P, M = ((et = t.data) == null ? void 0 : et.presentation) ?? e.presentation, Z = U == null ? void 0 : U.colors, pe = Ae((o) => {
|
|
205
|
+
const i = new Set(K);
|
|
206
|
+
i.has(o) ? i.delete(o) : i.add(o), ve(i);
|
|
207
|
+
}, [K, ve]), ue = T(() => {
|
|
208
|
+
if (W)
|
|
209
|
+
return (o) => {
|
|
210
|
+
var i;
|
|
211
|
+
return !!((i = ht(W, o)) != null && i.target);
|
|
212
|
+
};
|
|
213
|
+
}, [W]), ge = T(() => xt(t.data, e), [t.data, e]), we = T(() => {
|
|
214
|
+
var k, O, me;
|
|
215
|
+
const o = St(c.theme, e, { positional: !oe, labels: ge }), i = ho(t.data, e), d = /* @__PURE__ */ new Map(), w = ((k = t.data) == null ? void 0 : k.columns.findIndex((G) => G.name === e.encoding.series)) ?? -1;
|
|
216
|
+
if (w >= 0)
|
|
217
|
+
for (const [G, ie] of (((O = t.data) == null ? void 0 : O.rows) ?? []).entries()) {
|
|
218
|
+
const _e = ie[w], dt = (me = Z == null ? void 0 : Z[G]) == null ? void 0 : me.trim();
|
|
219
|
+
if ((typeof _e == "string" || typeof _e == "number" || typeof _e == "bigint") && dt) {
|
|
220
|
+
const gt = String(_e);
|
|
221
|
+
d.has(gt) || d.set(gt, dt);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return i.size === 0 && d.size === 0 ? o : (G, ie) => d.get(G) ?? o(G, i.get(G) ?? ie);
|
|
225
|
+
}, [oe, c.theme, t.data, Z, ge, e]), ye = T(
|
|
226
|
+
() => It(c.theme, e, { colors: Z, positional: !oe, labels: ge }),
|
|
227
|
+
[oe, c.theme, Z, ge, e]
|
|
228
|
+
), g = T(() => {
|
|
229
|
+
var i;
|
|
230
|
+
const o = new Set(B);
|
|
231
|
+
D || o.add(ze.trend);
|
|
232
|
+
for (const { window: d } of ((i = e.temporal) == null ? void 0 : i.movingAverages) ?? [])
|
|
233
|
+
d !== _ && o.add(ze.average(d));
|
|
234
|
+
return o;
|
|
235
|
+
}, [B, _, (tt = e.temporal) == null ? void 0 : tt.movingAverages, D]), p = Ae((o) => {
|
|
236
|
+
var d, w;
|
|
237
|
+
if (o === ze.trend) {
|
|
238
|
+
ee((k) => !k);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
const i = (w = (d = e.temporal) == null ? void 0 : d.movingAverages) == null ? void 0 : w.find(({ window: k }) => ze.average(k) === o);
|
|
242
|
+
if (i) {
|
|
243
|
+
se((k) => k === i.window ? void 0 : i.window);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
A((k) => {
|
|
247
|
+
const O = new Set(k);
|
|
248
|
+
return O.has(o) ? O.delete(o) : O.add(o), O;
|
|
249
|
+
});
|
|
250
|
+
}, [(ot = e.temporal) == null ? void 0 : ot.movingAverages]), x = (X === "line" || X === "area") && e.temporal && (e.temporal.regression || (nt = e.temporal.movingAverages) != null && nt.length) ? /* @__PURE__ */ R("div", { className: "lens-temporal-controls", children: [
|
|
251
|
+
e.temporal.regression && /* @__PURE__ */ l(
|
|
252
|
+
"button",
|
|
253
|
+
{
|
|
254
|
+
"aria-pressed": D,
|
|
255
|
+
className: "lens-temporal-toggle",
|
|
256
|
+
onClick: () => ee((o) => !o),
|
|
257
|
+
type: "button",
|
|
258
|
+
children: r("chart.regression", "Trend")
|
|
259
|
+
}
|
|
260
|
+
),
|
|
261
|
+
!!((rt = e.temporal.movingAverages) != null && rt.length) && /* @__PURE__ */ R(
|
|
262
|
+
"select",
|
|
263
|
+
{
|
|
264
|
+
"aria-label": r("chart.movingAverage", "Moving average"),
|
|
265
|
+
className: "lens-temporal-select",
|
|
266
|
+
onChange: (o) => se(o.target.value ? Number(o.target.value) : void 0),
|
|
267
|
+
value: _ ?? "",
|
|
268
|
+
children: [
|
|
269
|
+
/* @__PURE__ */ l("option", { value: "", children: r("chart.movingAverage", "Moving average") }),
|
|
270
|
+
(st = e.temporal.movingAverages) == null ? void 0 : st.map(({ window: o, label: i }) => /* @__PURE__ */ l("option", { value: o, children: i || `SMA ${o}` }, o))
|
|
271
|
+
]
|
|
272
|
+
}
|
|
273
|
+
)
|
|
274
|
+
] }) : void 0, q = T(() => ({
|
|
275
|
+
previous: r("chart.series.previous", "Previous"),
|
|
276
|
+
trend: r("chart.series.trend", "Trend"),
|
|
277
|
+
movingAverage: (o) => r("chart.series.movingAverage", "SMA {window}", { window: String(o) }),
|
|
278
|
+
estimate: r("chart.series.estimate", "Estimate"),
|
|
279
|
+
ytd: r("chart.series.ytd", "YTD"),
|
|
280
|
+
forecast: r("chart.series.forecast", "Forecast"),
|
|
281
|
+
forecastLower: (o) => r("chart.series.forecastLower", "{forecast} lower", { forecast: o }),
|
|
282
|
+
forecastConfidence: (o) => r("chart.series.forecastConfidence", "{forecast} confidence", { forecast: o }),
|
|
283
|
+
boxplot: [
|
|
284
|
+
r("chart.boxplot.min", "Min"),
|
|
285
|
+
r("chart.boxplot.q1", "Q1"),
|
|
286
|
+
r("chart.boxplot.median", "Median"),
|
|
287
|
+
r("chart.boxplot.q3", "Q3"),
|
|
288
|
+
r("chart.boxplot.max", "Max")
|
|
289
|
+
],
|
|
290
|
+
noData: r("panel.empty", "No data"),
|
|
291
|
+
copyValue: r("explore.copyValue", "Copy value"),
|
|
292
|
+
copied: r("explore.copied", "Copied")
|
|
293
|
+
}), [r]), j = T(() => {
|
|
294
|
+
var o, i;
|
|
295
|
+
return U ? {
|
|
296
|
+
kind: X,
|
|
297
|
+
frame: U,
|
|
298
|
+
encoding: e.encoding,
|
|
299
|
+
format: y,
|
|
300
|
+
formatAxis: f,
|
|
301
|
+
formatTooltip: (d, w, k) => Jt(w, k, e.format[d], c.meta.locale),
|
|
302
|
+
// The plot abbreviates because a label has to fit beside a mark; the
|
|
303
|
+
// tooltip is where a reader who stopped to point gets the whole number, and
|
|
304
|
+
// the clipboard gets the machine value behind it.
|
|
305
|
+
formatExact: (d, w) => {
|
|
306
|
+
var k;
|
|
307
|
+
return Gt(w, e.format[d], ((k = c.meta) == null ? void 0 : k.locale) ?? "en");
|
|
308
|
+
},
|
|
309
|
+
rawValue: (d, w) => Zt(w, e.format[d]),
|
|
310
|
+
categoryFormatDefined: !!(e.encoding.category && e.format[e.encoding.category]),
|
|
311
|
+
locale: (o = c.meta) == null ? void 0 : o.locale,
|
|
312
|
+
shareDecimalSeparator: e.encoding.value ? (i = e.format[e.encoding.value]) == null ? void 0 : i.decimalSeparator : void 0,
|
|
313
|
+
tooltipTotalLabel: r("panel.total", "Total"),
|
|
314
|
+
labels: q,
|
|
315
|
+
theme: c.theme,
|
|
316
|
+
// An explicit pick wins; otherwise the mark the page is currently filtered
|
|
317
|
+
// by carries the same outline, so the source panel states its own selection
|
|
318
|
+
// across a reload or a shared URL, not only in the click that made it.
|
|
319
|
+
selectedKey: b ?? Ke,
|
|
320
|
+
presentation: M,
|
|
321
|
+
seriesColor: we,
|
|
322
|
+
rowColor: ye,
|
|
323
|
+
radial: e.radial,
|
|
324
|
+
temporal: e.temporal,
|
|
325
|
+
hiddenOverlays: g,
|
|
326
|
+
valueAxis: e.valueAxis,
|
|
327
|
+
valueUnit: Qt(e.encoding.value ? e.format[e.encoding.value] : void 0),
|
|
328
|
+
expandable: ue
|
|
329
|
+
} : void 0;
|
|
330
|
+
}, [q, (it = c.meta) == null ? void 0 : it.locale, c.theme, ue, y, f, Ke, g, X, e.encoding, e.format, e.radial, e.temporal, e.valueAxis, M, U, ye, b, we, r]), Ne = T(() => {
|
|
331
|
+
var i, d;
|
|
332
|
+
if (!e.temporal && !e.encoding.previous) return [];
|
|
333
|
+
const o = e.encoding.category ?? e.encoding.label;
|
|
334
|
+
return Et({
|
|
335
|
+
temporal: e.temporal,
|
|
336
|
+
hasComparison: !!e.encoding.previous,
|
|
337
|
+
labels: q,
|
|
338
|
+
formatValue: (w) => y(e.encoding.value ?? "", w),
|
|
339
|
+
formatCategory: Mt({
|
|
340
|
+
format: (w) => y(o ?? "", w),
|
|
341
|
+
isTime: ((i = t.data) == null ? void 0 : i.columns.some((w) => w.name === o && w.type === "time")) === !0,
|
|
342
|
+
hasDeclaredFormat: !!(o && e.format[o]),
|
|
343
|
+
locale: (d = c.meta) == null ? void 0 : d.locale
|
|
344
|
+
}),
|
|
345
|
+
hidden: g
|
|
346
|
+
});
|
|
347
|
+
}, [q, (at = c.meta) == null ? void 0 : at.locale, y, (ct = t.data) == null ? void 0 : ct.columns, g, e.encoding, e.format, e.temporal]), Be = Yt(), Ve = ne ? Be ? !!((W == null ? void 0 : W.children.length) ?? e.drillRoot) : Me : !!z.action, qe = X === "histogram" || X === "boxplot" || X === "heatmap", De = Te && !qe, $e = Ae((o, i, d) => {
|
|
348
|
+
const w = E.frame ? E.frame.rows.length - 1 : -1;
|
|
349
|
+
if (E.collapsed && !!(o === Fe || E.frame && vt(E.frame, e, o) === w)) {
|
|
350
|
+
h((me) => !me);
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
if (!ne) {
|
|
354
|
+
const me = de(o);
|
|
355
|
+
z.activate(me, void 0, { newTab: d == null ? void 0 : d.newTab });
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
if (Be) {
|
|
359
|
+
v(o), Be(o, i);
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
const O = ht(W, o);
|
|
363
|
+
W && !(O != null && O.target) || (v(o), m((O == null ? void 0 : O.key) ?? o, e.id));
|
|
364
|
+
}, [E.collapsed, E.frame, Fe, m, ne, W, de, Be, e, z]), je = !De && (M == null ? void 0 : M.legend) === "below" && !!U, Lt = !De && Ne.length > 0 && !!U, Ce = Ve || E.collapsed, At = e.encoding.category ?? e.encoding.label, We = (X === "line" || X === "area") && (U == null ? void 0 : U.columns.some((o) => o.name === At && o.type === "time")) === !0, He = Ne.find((o) => o.kind === "incomplete" && o.active), Qe = Y ? r("chart.filterHint", "Select to filter the page") : r("chart.drillHint", "Select to explore"), Le = T(
|
|
365
|
+
() => j && Ve ? { ...j, actionHint: Qe } : j,
|
|
366
|
+
[Qe, j, Ve]
|
|
367
|
+
);
|
|
368
|
+
return /* @__PURE__ */ l(Xt, { allowEmptyContent: !qe, panel: e, frame: t, headerActions: x, total: V, children: /* @__PURE__ */ R("div", { className: `lens-chart-layout${je ? " lens-chart-layout-legend" : ""}`, children: [
|
|
369
|
+
/* @__PURE__ */ R("div", { className: "lens-chart-area", children: [
|
|
370
|
+
(M == null ? void 0 : M.totalBadge) === "plot" && X !== "donut" && ((lt = e.radial) == null ? void 0 : lt.mode) !== "partition" && V !== null && /* @__PURE__ */ l(xo, { panel: e, total: V }),
|
|
371
|
+
(s || He || We || be || F && E.collapsed) && /* @__PURE__ */ R("div", { className: "lens-chart-notes", children: [
|
|
372
|
+
be && /* @__PURE__ */ l("span", { className: "lens-chart-source-note", role: "note", children: r("chart.crossFilterSource", "All categories shown — the filter applies to the other panels") }),
|
|
373
|
+
s && /* @__PURE__ */ R(
|
|
374
|
+
"span",
|
|
375
|
+
{
|
|
376
|
+
className: "lens-chart-log-scale",
|
|
377
|
+
role: "note",
|
|
378
|
+
title: r("chart.logScaleHint", "Values are shown on a logarithmic scale"),
|
|
379
|
+
children: [
|
|
380
|
+
/* @__PURE__ */ l(eo, { "aria-hidden": "true" }),
|
|
381
|
+
/* @__PURE__ */ l("span", { children: r("chart.logScale", "Logarithmic scale") })
|
|
382
|
+
]
|
|
383
|
+
}
|
|
384
|
+
),
|
|
385
|
+
He && /* @__PURE__ */ l("span", { className: "lens-chart-period-note", role: "note", children: [He.detail, He.label].filter(Boolean).join(" · ") }),
|
|
386
|
+
/* @__PURE__ */ R("span", { className: "lens-chart-notes-actions", children: [
|
|
387
|
+
F && E.collapsed && /* @__PURE__ */ l("button", { className: "lens-chart-collapse-other", onClick: () => h(!1), type: "button", children: r("chart.collapseOther", "Collapse Other") }),
|
|
388
|
+
We && /* @__PURE__ */ l("button", { className: "lens-chart-reset-zoom", onClick: () => N((o) => o + 1), type: "button", children: r("chart.resetZoom", "Reset zoom") })
|
|
389
|
+
] })
|
|
390
|
+
] }),
|
|
391
|
+
Q ? /* @__PURE__ */ l(bo, { onShowAll: () => ve(/* @__PURE__ */ new Set()) }) : Le && De ? /* @__PURE__ */ l(
|
|
392
|
+
po,
|
|
393
|
+
{
|
|
394
|
+
actionable: Ce,
|
|
395
|
+
frame: Le.frame,
|
|
396
|
+
onSelect: Ce ? $e : void 0,
|
|
397
|
+
panel: e
|
|
398
|
+
}
|
|
399
|
+
) : Le && /* @__PURE__ */ R(Ee, { children: [
|
|
400
|
+
/* @__PURE__ */ l(
|
|
401
|
+
ao,
|
|
402
|
+
{
|
|
403
|
+
actionable: Ce,
|
|
404
|
+
format: Le.format,
|
|
405
|
+
frame: Le.frame,
|
|
406
|
+
label: r("chart.data", "Chart data for {name}", { name: e.title }),
|
|
407
|
+
onHover: fe,
|
|
408
|
+
onSelect: $e,
|
|
409
|
+
panel: e,
|
|
410
|
+
translate: r
|
|
411
|
+
}
|
|
412
|
+
),
|
|
413
|
+
/* @__PURE__ */ l(
|
|
414
|
+
co,
|
|
415
|
+
{
|
|
416
|
+
input: Le,
|
|
417
|
+
panelId: e.id,
|
|
418
|
+
adapter: n,
|
|
419
|
+
label: r("chart.label", "{name} chart", { name: e.title }),
|
|
420
|
+
drillable: Ce,
|
|
421
|
+
onHover: Ce ? fe : void 0,
|
|
422
|
+
onSelect: Ce ? $e : void 0,
|
|
423
|
+
resetZoomKey: u
|
|
424
|
+
}
|
|
425
|
+
)
|
|
426
|
+
] }),
|
|
427
|
+
Lt && /* @__PURE__ */ l(Io, { onToggle: p, overlays: Ne })
|
|
428
|
+
] }),
|
|
429
|
+
je && L && /* @__PURE__ */ l(
|
|
430
|
+
So,
|
|
431
|
+
{
|
|
432
|
+
frame: L,
|
|
433
|
+
hidden: K,
|
|
434
|
+
onSetHidden: ve,
|
|
435
|
+
onToggle: pe,
|
|
436
|
+
panel: e,
|
|
437
|
+
presentation: M,
|
|
438
|
+
total: V ?? void 0
|
|
439
|
+
}
|
|
440
|
+
)
|
|
441
|
+
] }) });
|
|
442
|
+
}
|
|
443
|
+
function bo({ onShowAll: e }) {
|
|
444
|
+
const n = Re();
|
|
445
|
+
return /* @__PURE__ */ R("div", { className: "lens-chart-empty", role: "status", children: [
|
|
446
|
+
/* @__PURE__ */ l("span", { className: "lens-chart-empty-note", children: n("chart.allSeriesHidden", "All series are hidden") }),
|
|
447
|
+
/* @__PURE__ */ l("button", { className: "lens-chart-empty-action", onClick: e, type: "button", children: n("chart.showAllSeries", "Show all series") })
|
|
448
|
+
] });
|
|
449
|
+
}
|
|
450
|
+
function po({ actionable: e, frame: n, onSelect: t, panel: r }) {
|
|
451
|
+
var se, B;
|
|
452
|
+
const c = Re(), a = [r.encoding.category, r.encoding.label].find((A) => A !== void 0 && n.columns.some((C) => C.name === A)), m = r.encoding.value, y = n.columns.findIndex((A) => A.name === a), f = n.columns.findIndex((A) => A.name === m), b = H(m ? r.format[m] : void 0), v = f < 0 ? void 0 : n.rows.reduce((A, C) => A + (he(C[f]) ?? 0), 0), F = y < 0 || (se = n.rows[0]) == null ? void 0 : se[y], h = ke(F), u = b(v), N = r.encoding.id ?? a, ce = n.columns.findIndex((A) => A.name === N), D = ke(ce < 0 || (B = n.rows[0]) == null ? void 0 : B[ce]), ee = /* @__PURE__ */ l(Ee, { children: n.rows.length === 0 ? /* @__PURE__ */ l("span", { className: "lens-chart-compact-empty", children: c("panel.empty", "No data") }) : /* @__PURE__ */ R(Ee, { children: [
|
|
453
|
+
h && /* @__PURE__ */ l("span", { className: "lens-chart-compact-label", title: h, children: h }),
|
|
454
|
+
/* @__PURE__ */ l("strong", { className: "lens-chart-compact-value", children: u })
|
|
455
|
+
] }) }), _ = n.rows.length === 0 ? c("panel.empty", "No data") : [h, u].filter(Boolean).join(" / ");
|
|
456
|
+
return e && D && n.rows.length > 0 ? /* @__PURE__ */ l(
|
|
457
|
+
"button",
|
|
458
|
+
{
|
|
459
|
+
"aria-label": `${_}. ${c("chart.openMark", "Open {name}", { name: h ?? D })}`,
|
|
460
|
+
className: "lens-chart-compact lens-chart-compact-action",
|
|
461
|
+
onClick: () => t == null ? void 0 : t(D),
|
|
462
|
+
type: "button",
|
|
463
|
+
children: ee
|
|
464
|
+
}
|
|
465
|
+
) : /* @__PURE__ */ l("div", { "aria-label": _, className: "lens-chart-compact", role: "img", children: ee });
|
|
466
|
+
}
|
|
467
|
+
function xo({ panel: e, total: n }) {
|
|
468
|
+
const t = Re(), r = H(e.encoding.value ? e.format[e.encoding.value] : void 0);
|
|
469
|
+
return /* @__PURE__ */ R("span", { className: "lens-plot-total", children: [
|
|
470
|
+
/* @__PURE__ */ R("span", { className: "lens-panel-total-label", children: [
|
|
471
|
+
t("panel.total", "Total"),
|
|
472
|
+
":"
|
|
473
|
+
] }),
|
|
474
|
+
" ",
|
|
475
|
+
r(n)
|
|
476
|
+
] });
|
|
477
|
+
}
|
|
478
|
+
const So = bt(function({
|
|
479
|
+
panel: n,
|
|
480
|
+
frame: t,
|
|
481
|
+
hidden: r,
|
|
482
|
+
onSetHidden: c,
|
|
483
|
+
onToggle: a,
|
|
484
|
+
total: m,
|
|
485
|
+
presentation: y
|
|
486
|
+
}) {
|
|
487
|
+
var Fe, U;
|
|
488
|
+
const { document: f, navigation: b } = pt(), v = Re(), [F, h] = ae(""), u = Pe(null), [N, ce] = ae({ top: !1, bottom: !1 }), [D, ee] = ae(0), [_, se] = ae(!1), B = Nt(t, n), A = B >= 0 ? n.encoding.series : n.encoding.label ?? n.encoding.category, C = n.encoding.value, te = H(C ? n.format[C] : void 0), K = t.columns.findIndex((s) => s.name === A), oe = t.columns.findIndex((s) => s.name === C), W = H(A ? n.format[A] : void 0), Me = b.panelId === n.id && b.path.length > 0, ne = xt(t, n), z = St(f.theme, n, { positional: !Me, labels: ne }), le = It(f.theme, n, {
|
|
489
|
+
colors: t.colors,
|
|
490
|
+
positional: !Me,
|
|
491
|
+
labels: ne
|
|
492
|
+
}), de = n.encoding.id ? t.columns.findIndex((s) => s.name === n.encoding.id) : -1, fe = n.encoding.series ? t.columns.findIndex((s) => s.name === n.encoding.series) : -1, J = ((Fe = n.radial) == null ? void 0 : Fe.mode) === "partition", I = T(() => {
|
|
493
|
+
var we, ye;
|
|
494
|
+
const s = t.rows.map((g, p) => {
|
|
495
|
+
const x = de >= 0 ? g[de] : g[K];
|
|
496
|
+
return String(typeof x == "string" || typeof x == "number" || typeof x == "bigint" ? x : p);
|
|
497
|
+
}), L = t.rows.map((g, p) => {
|
|
498
|
+
if (B < 0) return s[p];
|
|
499
|
+
const x = g[B];
|
|
500
|
+
return String(typeof x == "string" || typeof x == "number" || typeof x == "bigint" ? x : p);
|
|
501
|
+
});
|
|
502
|
+
let S = t.rows.map((g, p) => p);
|
|
503
|
+
if (B >= 0 || J) {
|
|
504
|
+
const g = /* @__PURE__ */ new Set();
|
|
505
|
+
S = [];
|
|
506
|
+
for (let p = 0; p < t.rows.length; p += 1) {
|
|
507
|
+
const x = L[p];
|
|
508
|
+
g.has(x) || (g.add(x), S.push(p));
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
const re = S.map((g) => L[g]), Q = new Map(S.map((g, p) => [g, p])), P = /* @__PURE__ */ new Map();
|
|
512
|
+
J && s.forEach((g) => {
|
|
513
|
+
P.has(g) || P.set(g, P.size);
|
|
514
|
+
});
|
|
515
|
+
const V = new Map((((we = n.radial) == null ? void 0 : we.rings) ?? []).map((g) => [g.key, g.total])), M = /* @__PURE__ */ new Map();
|
|
516
|
+
for (let g = 0; g < t.rows.length; g += 1) {
|
|
517
|
+
const p = fe >= 0 ? (ye = t.rows[g]) == null ? void 0 : ye[fe] : void 0, x = J && typeof p == "string" ? p : "", q = J ? V.get(x) ?? m : m, j = J ? x : String(q), Ne = M.get(j) ?? { denominator: q, indices: [] };
|
|
518
|
+
Ne.indices.push(g), M.set(j, Ne);
|
|
519
|
+
}
|
|
520
|
+
const Z = /* @__PURE__ */ new Map();
|
|
521
|
+
for (const { denominator: g, indices: p } of M.values()) {
|
|
522
|
+
const x = p.map((q) => {
|
|
523
|
+
var j;
|
|
524
|
+
return oe >= 0 ? he((j = t.rows[q]) == null ? void 0 : j[oe]) : void 0;
|
|
525
|
+
});
|
|
526
|
+
Ht(x, g).forEach((q, j) => Z.set(p[j], q));
|
|
527
|
+
}
|
|
528
|
+
const pe = /* @__PURE__ */ new Map();
|
|
529
|
+
J && s.forEach((g) => pe.set(g, (pe.get(g) ?? 0) + 1));
|
|
530
|
+
const ue = /* @__PURE__ */ new Map();
|
|
531
|
+
oe >= 0 && t.rows.forEach((g, p) => {
|
|
532
|
+
var j;
|
|
533
|
+
const x = he(g[oe]);
|
|
534
|
+
if (x === void 0) return;
|
|
535
|
+
const q = L[p];
|
|
536
|
+
B >= 0 && C && ((j = n.format[C]) == null ? void 0 : j.kind) !== "percent" ? ue.set(q, (ue.get(q) ?? 0) + x) : ue.set(q, x);
|
|
537
|
+
});
|
|
538
|
+
const ge = /* @__PURE__ */ new Map();
|
|
539
|
+
return J && fe >= 0 && S.forEach((g) => {
|
|
540
|
+
var x;
|
|
541
|
+
const p = (x = t.rows[g]) == null ? void 0 : x[fe];
|
|
542
|
+
typeof p == "string" && ge.set(g, p);
|
|
543
|
+
}), { allKeys: re, categoryOrder: P, entries: S, entryKeys: L, entryPositions: Q, ringByIndex: ge, rowKeys: s, rowsPerKey: pe, shares: Z, valueByKey: ue };
|
|
544
|
+
}, [t, de, K, n.format, (U = n.radial) == null ? void 0 : U.rings, J, fe, B, m, C, oe]), Y = (s, L, S) => {
|
|
545
|
+
var P;
|
|
546
|
+
if (B >= 0) return z(s, S);
|
|
547
|
+
const re = de >= 0 ? (P = t.rows[L]) == null ? void 0 : P[de] : void 0, Q = typeof re == "string" && re.trim() !== "" ? re : void 0;
|
|
548
|
+
return le(s, I.categoryOrder.get(I.rowKeys[L]) ?? L, Q);
|
|
549
|
+
}, be = (y == null ? void 0 : y.legendValue) === "percent", Ke = (s) => B >= 0 ? "value" : be ? "percent" : J ? I.rowsPerKey.get(I.rowKeys[s]) === 1 ? "percent" : "none" : "value", X = F.trim().toLocaleLowerCase(), Te = X === "" ? I.entries : I.entries.filter((s) => {
|
|
550
|
+
var S;
|
|
551
|
+
const L = (S = t.rows[s]) == null ? void 0 : S[K];
|
|
552
|
+
return ke(L).toLocaleLowerCase().includes(X);
|
|
553
|
+
});
|
|
554
|
+
if (kt(() => {
|
|
555
|
+
const s = u.current;
|
|
556
|
+
if (!s) return;
|
|
557
|
+
const L = () => {
|
|
558
|
+
const re = s.scrollTop + s.clientHeight, Q = s.scrollHeight > s.clientHeight + 1;
|
|
559
|
+
if (ce({
|
|
560
|
+
top: Q && s.scrollTop > 1,
|
|
561
|
+
bottom: Q && re < s.scrollHeight - 1
|
|
562
|
+
}), !Q) {
|
|
563
|
+
ee(0);
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
const P = s.querySelectorAll(".lens-chart-legend-item");
|
|
567
|
+
let V = 0;
|
|
568
|
+
for (const M of P) M.offsetTop + M.offsetHeight > re + 1 && (V += 1);
|
|
569
|
+
ee(V);
|
|
570
|
+
};
|
|
571
|
+
L(), s.addEventListener("scroll", L, { passive: !0 });
|
|
572
|
+
const S = typeof ResizeObserver > "u" ? void 0 : new ResizeObserver(L);
|
|
573
|
+
return S == null || S.observe(s), () => {
|
|
574
|
+
s.removeEventListener("scroll", L), S == null || S.disconnect();
|
|
575
|
+
};
|
|
576
|
+
}, [_, Te.length]), K < 0) return null;
|
|
577
|
+
const Se = (s) => {
|
|
578
|
+
const L = !r.has(s) && I.allKeys.every((S) => S === s || r.has(S));
|
|
579
|
+
c(L ? /* @__PURE__ */ new Set() : new Set(I.allKeys.filter((S) => S !== s)));
|
|
580
|
+
}, Ie = I.allKeys.length > 0 && I.allKeys.every((s) => r.has(s)), ve = I.allKeys.every((s) => !r.has(s)), $ = I.allKeys.length > uo, E = I.entries.length >= go;
|
|
581
|
+
return /* @__PURE__ */ R("div", { className: "lens-chart-legend-shell", style: _ ? { "--lens-chart-legend-max": "none" } : void 0, children: [
|
|
582
|
+
$ && /* @__PURE__ */ R("div", { className: "lens-chart-legend-controls", children: [
|
|
583
|
+
/* @__PURE__ */ l(
|
|
584
|
+
"div",
|
|
585
|
+
{
|
|
586
|
+
"aria-label": v("chart.legendControls", "Legend controls"),
|
|
587
|
+
className: "lens-chart-legend-tools",
|
|
588
|
+
"data-members": E ? "many" : "one",
|
|
589
|
+
role: "group",
|
|
590
|
+
children: E ? /* @__PURE__ */ R(Ee, { children: [
|
|
591
|
+
/* @__PURE__ */ l(
|
|
592
|
+
"button",
|
|
593
|
+
{
|
|
594
|
+
"aria-pressed": Ie,
|
|
595
|
+
onClick: () => c(new Set(I.allKeys)),
|
|
596
|
+
type: "button",
|
|
597
|
+
children: v("chart.legendHideAll", "Hide all")
|
|
598
|
+
}
|
|
599
|
+
),
|
|
600
|
+
/* @__PURE__ */ l(
|
|
601
|
+
"button",
|
|
602
|
+
{
|
|
603
|
+
"aria-pressed": ve,
|
|
604
|
+
onClick: () => c(/* @__PURE__ */ new Set()),
|
|
605
|
+
type: "button",
|
|
606
|
+
children: v("chart.legendShowAll", "Show all")
|
|
607
|
+
}
|
|
608
|
+
),
|
|
609
|
+
/* @__PURE__ */ l(
|
|
610
|
+
"button",
|
|
611
|
+
{
|
|
612
|
+
"aria-label": v("chart.legendInvert", "Invert"),
|
|
613
|
+
className: "lens-chart-legend-invert",
|
|
614
|
+
onClick: () => c(new Set(I.allKeys.filter((s) => !r.has(s)))),
|
|
615
|
+
title: v("chart.legendInvert", "Invert"),
|
|
616
|
+
type: "button",
|
|
617
|
+
children: /* @__PURE__ */ l(oo, {})
|
|
618
|
+
}
|
|
619
|
+
)
|
|
620
|
+
] }) : /* @__PURE__ */ l(
|
|
621
|
+
"button",
|
|
622
|
+
{
|
|
623
|
+
onClick: () => c(Ie ? /* @__PURE__ */ new Set() : new Set(I.allKeys)),
|
|
624
|
+
type: "button",
|
|
625
|
+
children: Ie ? v("chart.legendShowAll", "Show all") : v("chart.legendHideAll", "Hide all")
|
|
626
|
+
}
|
|
627
|
+
)
|
|
628
|
+
}
|
|
629
|
+
),
|
|
630
|
+
E && /* @__PURE__ */ R("label", { className: "lens-chart-legend-search", children: [
|
|
631
|
+
/* @__PURE__ */ l("span", { className: "lens-sr-only", children: v("chart.legendSearch", "Search legend") }),
|
|
632
|
+
/* @__PURE__ */ l(
|
|
633
|
+
"input",
|
|
634
|
+
{
|
|
635
|
+
className: "lens-facet-search",
|
|
636
|
+
onChange: (s) => h(s.currentTarget.value),
|
|
637
|
+
placeholder: v("chart.legendSearch", "Search legend"),
|
|
638
|
+
type: "search",
|
|
639
|
+
value: F
|
|
640
|
+
}
|
|
641
|
+
)
|
|
642
|
+
] })
|
|
643
|
+
] }),
|
|
644
|
+
/* @__PURE__ */ R(
|
|
645
|
+
"div",
|
|
646
|
+
{
|
|
647
|
+
className: "lens-chart-legend-scroll-frame",
|
|
648
|
+
"data-overflow-bottom": N.bottom || void 0,
|
|
649
|
+
"data-overflow-top": N.top || void 0,
|
|
650
|
+
children: [
|
|
651
|
+
/* @__PURE__ */ l("ul", { "aria-label": v("chart.legendControls", "Legend controls"), className: "lens-chart-legend", ref: u, role: "region", tabIndex: N.top || N.bottom ? 0 : void 0, children: Te.map((s, L) => {
|
|
652
|
+
var ge, we, ye, g, p;
|
|
653
|
+
const S = t.rows[s], re = I.entryPositions.get(s) ?? s, Q = S[K], P = Q == null ? "" : W(Q), V = I.entryKeys[s], M = r.has(V), Z = I.ringByIndex.get(s), pe = L > 0 ? I.ringByIndex.get(Te[L - 1]) : void 0, ue = ((ye = (we = (ge = n.radial) == null ? void 0 : ge.rings) == null ? void 0 : we.find((x) => x.key === Z)) == null ? void 0 : ye.label) ?? Z;
|
|
654
|
+
return /* @__PURE__ */ R(Rt, { children: [
|
|
655
|
+
Z && Z !== pe && /* @__PURE__ */ l("li", { className: "lens-chart-legend-heading", children: ue }),
|
|
656
|
+
/* @__PURE__ */ l("li", { className: "lens-chart-legend-item", children: /* @__PURE__ */ R(
|
|
657
|
+
"button",
|
|
658
|
+
{
|
|
659
|
+
"aria-pressed": !M,
|
|
660
|
+
className: `lens-chart-legend-toggle${M ? " lens-chart-legend-hidden" : ""}`,
|
|
661
|
+
onClick: () => a(V),
|
|
662
|
+
onDoubleClick: () => Se(V),
|
|
663
|
+
title: v("chart.legendToggleHint", "Click to toggle · double-click to isolate"),
|
|
664
|
+
type: "button",
|
|
665
|
+
children: [
|
|
666
|
+
/* @__PURE__ */ l(
|
|
667
|
+
"span",
|
|
668
|
+
{
|
|
669
|
+
"aria-hidden": "true",
|
|
670
|
+
className: "lens-chart-legend-mark",
|
|
671
|
+
style: { background: Y(P, s, re) }
|
|
672
|
+
}
|
|
673
|
+
),
|
|
674
|
+
/* @__PURE__ */ l("span", { className: "lens-chart-legend-label", children: P }),
|
|
675
|
+
Ke(s) !== "none" && /* @__PURE__ */ l("span", { className: "lens-chart-legend-value", children: Ke(s) === "percent" ? _t(I.shares.get(s), (g = f.meta) == null ? void 0 : g.locale, C ? (p = n.format[C]) == null ? void 0 : p.decimalSeparator : void 0) : te(I.valueByKey.get(V)) }),
|
|
676
|
+
/* @__PURE__ */ l("span", { "aria-hidden": "true", className: "lens-chart-legend-visibility", children: M ? /* @__PURE__ */ l(no, {}) : /* @__PURE__ */ l(ro, {}) })
|
|
677
|
+
]
|
|
678
|
+
}
|
|
679
|
+
) }, `${V}-${s}`)
|
|
680
|
+
] }, `${V}-${s}`);
|
|
681
|
+
}) }),
|
|
682
|
+
/* @__PURE__ */ l("span", { "aria-hidden": "true", className: "lens-chart-legend-edge lens-chart-legend-edge-top" }),
|
|
683
|
+
/* @__PURE__ */ l("span", { "aria-hidden": "true", className: "lens-chart-legend-edge lens-chart-legend-edge-bottom" })
|
|
684
|
+
]
|
|
685
|
+
}
|
|
686
|
+
),
|
|
687
|
+
(D > 0 || _) && /* @__PURE__ */ l("button", { className: "lens-chart-legend-overflow", onClick: () => se((s) => !s), type: "button", children: _ ? v("chart.legendCollapse", "Show fewer") : v("chart.legendMore", "{count} more", { count: String(D) }) })
|
|
688
|
+
] });
|
|
689
|
+
}), Io = bt(function({ overlays: n, onToggle: t }) {
|
|
690
|
+
const r = Re(), c = r("chart.legendOverlays", "Chart marks");
|
|
691
|
+
return /* @__PURE__ */ R("ul", { "aria-label": c, className: "lens-chart-legend lens-chart-overlay-legend", children: [
|
|
692
|
+
/* @__PURE__ */ l("li", { className: "lens-chart-legend-heading", children: c }),
|
|
693
|
+
n.map((a) => /* @__PURE__ */ l("li", { className: "lens-chart-legend-item", children: /* @__PURE__ */ R(
|
|
694
|
+
"button",
|
|
695
|
+
{
|
|
696
|
+
"aria-pressed": a.active,
|
|
697
|
+
className: `lens-chart-legend-toggle${a.active ? "" : " lens-chart-legend-hidden"}`,
|
|
698
|
+
onClick: () => t(a.id),
|
|
699
|
+
title: r("chart.legendToggleOverlay", "Show or hide this mark"),
|
|
700
|
+
type: "button",
|
|
701
|
+
children: [
|
|
702
|
+
/* @__PURE__ */ l(
|
|
703
|
+
"span",
|
|
704
|
+
{
|
|
705
|
+
"aria-hidden": "true",
|
|
706
|
+
className: "lens-chart-overlay-mark",
|
|
707
|
+
"data-stroke": a.stroke,
|
|
708
|
+
style: { "--lens-overlay-ink": `var(${Bt(a.tone)})` }
|
|
709
|
+
}
|
|
710
|
+
),
|
|
711
|
+
/* @__PURE__ */ l("span", { className: "lens-chart-legend-label", children: a.label }),
|
|
712
|
+
a.detail && /* @__PURE__ */ R(Ee, { children: [
|
|
713
|
+
/* @__PURE__ */ l("span", { "aria-hidden": "true", className: "lens-chart-legend-separator", children: "·" }),
|
|
714
|
+
/* @__PURE__ */ l("span", { className: "lens-chart-legend-value", children: a.detail })
|
|
715
|
+
] })
|
|
716
|
+
]
|
|
717
|
+
}
|
|
718
|
+
) }, a.id))
|
|
719
|
+
] });
|
|
720
|
+
});
|
|
721
|
+
export {
|
|
722
|
+
Fo as ChartPanel,
|
|
723
|
+
wt as collapseExpandableTopN,
|
|
724
|
+
yt as collapseMinorDonutSlices,
|
|
725
|
+
Ct as donutRemainderKey,
|
|
726
|
+
Ue as legendKey,
|
|
727
|
+
vt as rowIndexForKey,
|
|
728
|
+
yo as topNGroupField
|
|
729
|
+
};
|