@carto/ps-react-ui 4.11.1 → 4.11.3
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/echart-BMPpj7n_.js +250 -0
- package/dist/echart-BMPpj7n_.js.map +1 -0
- package/dist/types/widgets-v2/echart/edge-label-clamp.d.ts +57 -0
- package/dist/types/widgets-v2/echart/edge-label-clamp.test.d.ts +1 -0
- package/dist/types/widgets-v2/wrapper/style.d.ts +5 -12
- package/dist/widgets-v2/bar.js +87 -99
- package/dist/widgets-v2/bar.js.map +1 -1
- package/dist/widgets-v2/echart.js +1 -1
- package/dist/widgets-v2/histogram.js +96 -107
- package/dist/widgets-v2/histogram.js.map +1 -1
- package/dist/widgets-v2/timeseries.js +104 -116
- package/dist/widgets-v2/timeseries.js.map +1 -1
- package/dist/widgets-v2.js +248 -244
- package/dist/widgets-v2.js.map +1 -1
- package/package.json +1 -1
- package/src/widgets-v2/bar/options.test.ts +31 -4
- package/src/widgets-v2/bar/options.ts +18 -22
- package/src/widgets-v2/echart/echart-ui.test.tsx +70 -0
- package/src/widgets-v2/echart/echart-ui.tsx +28 -0
- package/src/widgets-v2/echart/edge-label-clamp.test.ts +198 -0
- package/src/widgets-v2/echart/edge-label-clamp.ts +216 -0
- package/src/widgets-v2/histogram/options.test.ts +11 -4
- package/src/widgets-v2/histogram/options.ts +17 -21
- package/src/widgets-v2/timeseries/options.test.ts +9 -4
- package/src/widgets-v2/timeseries/options.ts +17 -22
- package/src/widgets-v2/wrapper/style.ts +13 -18
- package/src/widgets-v2/wrapper/widget-wrapper.test.tsx +66 -0
- package/src/widgets-v2/wrapper/widget-wrapper.tsx +7 -4
- package/dist/echart-CU0KmClP.js +0 -176
- package/dist/echart-CU0KmClP.js.map +0 -1
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { jsx as P } from "react/jsx-runtime";
|
|
2
|
+
import { c as X } from "react/compiler-runtime";
|
|
3
|
+
import { useRef as z, useEffectEvent as U, useEffect as w } from "react";
|
|
4
|
+
import { u as W, a as C, m as G } from "./widget-store-registry-_W4Z4xp-.js";
|
|
5
|
+
import { u as K } from "./widget-context-DTGO0Yta.js";
|
|
6
|
+
import "zustand";
|
|
7
|
+
import { Box as Z } from "@mui/material";
|
|
8
|
+
import * as N from "echarts";
|
|
9
|
+
const k = {
|
|
10
|
+
alignMinLabel: null,
|
|
11
|
+
alignMaxLabel: null
|
|
12
|
+
}, D = 2;
|
|
13
|
+
function B(t) {
|
|
14
|
+
const e = N.format.getTextRect(t.firstLabel, t.font).width / 2, n = N.format.getTextRect(t.lastLabel, t.font).width / 2;
|
|
15
|
+
return {
|
|
16
|
+
alignMinLabel: e + D > t.firstTickX ? "left" : null,
|
|
17
|
+
alignMaxLabel: n + D > t.width - t.lastTickX ? "right" : null
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function $(t) {
|
|
21
|
+
return Array.isArray(t) ? t[0] : t;
|
|
22
|
+
}
|
|
23
|
+
function H(t) {
|
|
24
|
+
const e = $(t.xAxis);
|
|
25
|
+
return e && typeof e == "object" ? e : void 0;
|
|
26
|
+
}
|
|
27
|
+
function J(t) {
|
|
28
|
+
const e = t.dataZoom;
|
|
29
|
+
return Array.isArray(e) ? e.length > 0 : e != null;
|
|
30
|
+
}
|
|
31
|
+
function j(t, e) {
|
|
32
|
+
return typeof e == "function" ? String(e(t ?? "")) : t == null ? "" : String(t);
|
|
33
|
+
}
|
|
34
|
+
function Y(t) {
|
|
35
|
+
const e = H(t);
|
|
36
|
+
if (!e || e.type !== "category") return null;
|
|
37
|
+
const n = $(t.series), r = n?.encode?.x;
|
|
38
|
+
if (r == null) return null;
|
|
39
|
+
const i = n?.datasetIndex ?? 0, o = t.dataset, u = (Array.isArray(o) ? o[i] : o)?.source;
|
|
40
|
+
if (!Array.isArray(u) || u.length < 2) return null;
|
|
41
|
+
const l = u, c = e.axisLabel?.formatter, a = e.axisLabel ?? {}, f = typeof a.fontSize == "number" ? `${a.fontSize}px` : a.fontSize ?? "12px", A = a.fontFamily ?? "sans-serif", L = a.fontWeight != null ? `${a.fontWeight} ` : "";
|
|
42
|
+
return {
|
|
43
|
+
firstLabel: j(l[0]?.[r], c),
|
|
44
|
+
lastLabel: j(l[l.length - 1]?.[r], c),
|
|
45
|
+
font: `${L}${f} ${A}`,
|
|
46
|
+
count: u.length
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function q(t, e, n) {
|
|
50
|
+
const r = Q(t, e);
|
|
51
|
+
return r.alignMinLabel === n.alignMinLabel && r.alignMaxLabel === n.alignMaxLabel ? n : (t.setOption({
|
|
52
|
+
xAxis: {
|
|
53
|
+
axisLabel: {
|
|
54
|
+
...r
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}, {
|
|
58
|
+
lazyUpdate: !0
|
|
59
|
+
}), r);
|
|
60
|
+
}
|
|
61
|
+
function Q(t, e) {
|
|
62
|
+
if (J(e)) return k;
|
|
63
|
+
const n = Y(e);
|
|
64
|
+
if (!n) return k;
|
|
65
|
+
const r = t.convertToPixel({
|
|
66
|
+
xAxisIndex: 0
|
|
67
|
+
}, 0), i = t.convertToPixel({
|
|
68
|
+
xAxisIndex: 0
|
|
69
|
+
}, n.count - 1), o = t.getWidth();
|
|
70
|
+
return typeof r != "number" || typeof i != "number" || !Number.isFinite(r) || !Number.isFinite(i) || !o ? k : B({
|
|
71
|
+
firstLabel: n.firstLabel,
|
|
72
|
+
lastLabel: n.lastLabel,
|
|
73
|
+
font: n.font,
|
|
74
|
+
firstTickX: r,
|
|
75
|
+
lastTickX: i,
|
|
76
|
+
width: o
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const I = /* @__PURE__ */ new Map();
|
|
80
|
+
let h = null;
|
|
81
|
+
function V() {
|
|
82
|
+
return typeof ResizeObserver > "u" ? null : (h ??= new ResizeObserver((t) => {
|
|
83
|
+
for (const e of t)
|
|
84
|
+
I.get(e.target)?.();
|
|
85
|
+
}), h);
|
|
86
|
+
}
|
|
87
|
+
const ee = () => {
|
|
88
|
+
};
|
|
89
|
+
function te(t, e) {
|
|
90
|
+
const n = V();
|
|
91
|
+
return n ? (I.set(t, e), n.observe(t), () => {
|
|
92
|
+
I.delete(t), h && (h.unobserve(t), I.size === 0 && (h.disconnect(), h = null));
|
|
93
|
+
}) : ee;
|
|
94
|
+
}
|
|
95
|
+
function pe() {
|
|
96
|
+
h && h.disconnect(), I.clear(), h = null;
|
|
97
|
+
}
|
|
98
|
+
const ne = {
|
|
99
|
+
root: {
|
|
100
|
+
width: "100%",
|
|
101
|
+
minHeight: 0
|
|
102
|
+
}
|
|
103
|
+
}, re = {
|
|
104
|
+
renderer: "svg",
|
|
105
|
+
height: 304
|
|
106
|
+
};
|
|
107
|
+
function se(t) {
|
|
108
|
+
const e = X(21), {
|
|
109
|
+
option: n,
|
|
110
|
+
replaceMerge: r,
|
|
111
|
+
onEvents: i,
|
|
112
|
+
init: o,
|
|
113
|
+
onInstance: d,
|
|
114
|
+
className: u,
|
|
115
|
+
sx: l
|
|
116
|
+
} = t, c = z(null), a = z(null), f = z(null), A = z(null), L = z(n), _ = z(k);
|
|
117
|
+
let E;
|
|
118
|
+
e[0] !== d ? (E = (s) => {
|
|
119
|
+
d?.(s);
|
|
120
|
+
}, e[0] = d, e[1] = E) : E = e[1];
|
|
121
|
+
const m = U(E);
|
|
122
|
+
let F;
|
|
123
|
+
e[2] !== o || e[3] !== m ? (F = () => {
|
|
124
|
+
if (!c.current)
|
|
125
|
+
return;
|
|
126
|
+
const s = N.init(c.current, null, {
|
|
127
|
+
...re,
|
|
128
|
+
...o
|
|
129
|
+
});
|
|
130
|
+
a.current = s, m(s);
|
|
131
|
+
const y = () => {
|
|
132
|
+
_.current = q(s, L.current, _.current);
|
|
133
|
+
};
|
|
134
|
+
return s.on("finished", y), () => {
|
|
135
|
+
s.off("finished", y), m(null), s.dispose(), a.current = null;
|
|
136
|
+
};
|
|
137
|
+
}, e[2] = o, e[3] = m, e[4] = F) : F = e[4];
|
|
138
|
+
let b;
|
|
139
|
+
e[5] !== o ? (b = [o], e[5] = o, e[6] = b) : b = e[6], w(F, b);
|
|
140
|
+
let T, g;
|
|
141
|
+
e[7] !== n || e[8] !== r ? (T = () => {
|
|
142
|
+
const s = oe(n), y = ie(n), v = new Set(r ?? []);
|
|
143
|
+
s !== f.current && v.add("series"), y !== A.current && v.add("dataset"), f.current = s, A.current = y, L.current = n, a.current?.setOption(n, {
|
|
144
|
+
notMerge: !1,
|
|
145
|
+
lazyUpdate: !0,
|
|
146
|
+
replaceMerge: v.size > 0 ? Array.from(v) : void 0
|
|
147
|
+
});
|
|
148
|
+
}, g = [n, r], e[7] = n, e[8] = r, e[9] = T, e[10] = g) : (T = e[9], g = e[10]), w(T, g);
|
|
149
|
+
let M, p;
|
|
150
|
+
e[11] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (M = () => {
|
|
151
|
+
const s = c.current;
|
|
152
|
+
if (s)
|
|
153
|
+
return te(s, () => {
|
|
154
|
+
a.current?.resize();
|
|
155
|
+
});
|
|
156
|
+
}, p = [], e[11] = M, e[12] = p) : (M = e[11], p = e[12]), w(M, p);
|
|
157
|
+
let x, R;
|
|
158
|
+
e[13] !== i ? (x = () => {
|
|
159
|
+
const s = a.current;
|
|
160
|
+
if (!(!s || !i)) {
|
|
161
|
+
for (const [y, v] of Object.entries(i))
|
|
162
|
+
s.on(y, v);
|
|
163
|
+
return () => {
|
|
164
|
+
for (const [y, v] of Object.entries(i))
|
|
165
|
+
s.off(y, v);
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}, R = [i], e[13] = i, e[14] = x, e[15] = R) : (x = e[14], R = e[15]), w(x, R);
|
|
169
|
+
let S;
|
|
170
|
+
e[16] !== l ? (S = {
|
|
171
|
+
...ne.root,
|
|
172
|
+
...l
|
|
173
|
+
}, e[16] = l, e[17] = S) : S = e[17];
|
|
174
|
+
let O;
|
|
175
|
+
return e[18] !== u || e[19] !== S ? (O = /* @__PURE__ */ P(Z, { ref: c, className: u, sx: S }), e[18] = u, e[19] = S, e[20] = O) : O = e[20], O;
|
|
176
|
+
}
|
|
177
|
+
function oe(t) {
|
|
178
|
+
const e = t.series;
|
|
179
|
+
return Array.isArray(e) ? e.map((n) => {
|
|
180
|
+
if (n == null || typeof n != "object") return String(n);
|
|
181
|
+
const r = n;
|
|
182
|
+
return [
|
|
183
|
+
r.type,
|
|
184
|
+
r.datasetIndex,
|
|
185
|
+
r.name,
|
|
186
|
+
r.stack,
|
|
187
|
+
// `encode` is small; stringify is cheap and stable for plain objects.
|
|
188
|
+
JSON.stringify(r.encode ?? null)
|
|
189
|
+
].join("|");
|
|
190
|
+
}).join("||") : e ? "1" : "";
|
|
191
|
+
}
|
|
192
|
+
function ie(t) {
|
|
193
|
+
const e = t.dataset;
|
|
194
|
+
return Array.isArray(e) ? String(e.length) : e ? "1" : "";
|
|
195
|
+
}
|
|
196
|
+
const ae = ["toolbox"], le = (t) => ({
|
|
197
|
+
data: t.data,
|
|
198
|
+
configTransforms: t.configTransforms,
|
|
199
|
+
formatter: t.formatter,
|
|
200
|
+
labelFormatter: t.labelFormatter
|
|
201
|
+
});
|
|
202
|
+
function xe(t) {
|
|
203
|
+
const e = X(22), {
|
|
204
|
+
optionFactory: n,
|
|
205
|
+
onEvents: r,
|
|
206
|
+
init: i,
|
|
207
|
+
className: o
|
|
208
|
+
} = t, d = K(), u = W(d, le);
|
|
209
|
+
let l;
|
|
210
|
+
e[0] !== d ? (l = (x) => G(d, x), e[0] = d, e[1] = l) : l = e[1];
|
|
211
|
+
const c = l, {
|
|
212
|
+
data: a,
|
|
213
|
+
configTransforms: f,
|
|
214
|
+
formatter: A,
|
|
215
|
+
labelFormatter: L
|
|
216
|
+
} = u;
|
|
217
|
+
let _;
|
|
218
|
+
e[2] !== n ? (_ = n(void 0, void 0), e[2] = n, e[3] = _) : _ = e[3];
|
|
219
|
+
const E = _;
|
|
220
|
+
let m;
|
|
221
|
+
e[4] !== f || e[5] !== E ? (m = C(E, f), e[4] = f, e[5] = E, e[6] = m) : m = e[6];
|
|
222
|
+
const F = m;
|
|
223
|
+
let b;
|
|
224
|
+
if (e[7] !== f) {
|
|
225
|
+
const x = new Set(ae);
|
|
226
|
+
for (const R of f)
|
|
227
|
+
if (R.enabled && R.replaceMergeKeys?.length)
|
|
228
|
+
for (const S of R.replaceMergeKeys)
|
|
229
|
+
x.add(S);
|
|
230
|
+
b = Array.from(x).sort(), e[7] = f, e[8] = b;
|
|
231
|
+
} else
|
|
232
|
+
b = e[8];
|
|
233
|
+
const T = b;
|
|
234
|
+
let g;
|
|
235
|
+
e[9] !== n || e[10] !== a || e[11] !== A || e[12] !== L || e[13] !== F ? (g = n(F, a, {
|
|
236
|
+
formatter: A,
|
|
237
|
+
labelFormatter: L
|
|
238
|
+
}), e[9] = n, e[10] = a, e[11] = A, e[12] = L, e[13] = F, e[14] = g) : g = e[14];
|
|
239
|
+
const M = g;
|
|
240
|
+
let p;
|
|
241
|
+
return e[15] !== o || e[16] !== i || e[17] !== r || e[18] !== c || e[19] !== M || e[20] !== T ? (p = /* @__PURE__ */ P(se, { option: M, replaceMerge: T, onEvents: r, init: i, onInstance: c, className: o }), e[15] = o, e[16] = i, e[17] = r, e[18] = c, e[19] = M, e[20] = T, e[21] = p) : p = e[21], p;
|
|
242
|
+
}
|
|
243
|
+
export {
|
|
244
|
+
re as D,
|
|
245
|
+
xe as E,
|
|
246
|
+
pe as _,
|
|
247
|
+
se as a,
|
|
248
|
+
te as o
|
|
249
|
+
};
|
|
250
|
+
//# sourceMappingURL=echart-BMPpj7n_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"echart-BMPpj7n_.js","sources":["../src/widgets-v2/echart/edge-label-clamp.ts","../src/widgets-v2/echart/shared-resize-observer.ts","../src/widgets-v2/echart/style.ts","../src/widgets-v2/echart/echart-ui.tsx","../src/widgets-v2/echart/echart.tsx"],"sourcesContent":["import * as echarts from 'echarts'\nimport type { ECharts, EChartsOption } from 'echarts'\n\n/**\n * Render-time clamp that stops the first/last **category x-axis** labels from\n * clipping at the chart edges — *only when they actually overflow*.\n *\n * ECharts centers each category label on its tick; the first/last ticks sit at\n * the plot boundary, so a wide edge label spills past the chart and is cut off.\n * `grid.containLabel` does not contain this horizontal overflow and the v6\n * `outerBounds` shrink is unreliable, so we measure at render time and anchor\n * the overflowing edge label inward (`alignMinLabel: 'left'` /\n * `alignMaxLabel: 'right'`). Labels that fit stay centered.\n *\n * Lives in the generic bridge because the verdict needs the laid-out chart\n * (`convertToPixel`, `getWidth`); everything else is read from the `option`.\n * Auto-targets bar + histogram (category x-axis); pie's horizontal-bar fallback\n * (category *y*-axis), scatterplot (value) and timeseries (time) are skipped.\n */\n\nexport interface EdgeAlignment {\n alignMinLabel: 'left' | null\n alignMaxLabel: 'right' | null\n}\n\nexport const CENTERED: EdgeAlignment = {\n alignMinLabel: null,\n alignMaxLabel: null,\n}\n\n// Bias toward anchoring when borderline: clipping is worse than a hair of\n// off-centering, and the reconstructed font may differ slightly from what\n// ECharts actually renders.\nconst SAFETY_MARGIN_PX = 2\n\n/**\n * Pure overflow decision. Inputs are anchor-independent (tick centers and text\n * width don't depend on the label's current `text-anchor`), so feeding the\n * result back via `setOption` doesn't change them — the next pass yields the\n * same verdict, keeping the clamp loop-stable.\n */\nexport function decideEdgeAlignment(args: {\n firstLabel: string\n lastLabel: string\n font: string\n firstTickX: number\n lastTickX: number\n width: number\n}): EdgeAlignment {\n const halfFirst =\n echarts.format.getTextRect(args.firstLabel, args.font).width / 2\n const halfLast =\n echarts.format.getTextRect(args.lastLabel, args.font).width / 2\n return {\n alignMinLabel:\n halfFirst + SAFETY_MARGIN_PX > args.firstTickX ? 'left' : null,\n alignMaxLabel:\n halfLast + SAFETY_MARGIN_PX > args.width - args.lastTickX\n ? 'right'\n : null,\n }\n}\n\ninterface AxisLabel {\n formatter?: (value: string | number) => string | number\n fontSize?: number | string\n fontFamily?: string\n fontWeight?: number | string\n}\n\ninterface CategoryXAxis {\n type?: string\n axisLabel?: AxisLabel\n}\n\ninterface SeriesLike {\n encode?: { x?: string | number }\n datasetIndex?: number\n}\n\ntype Cell = string | number | null | undefined\n\nfunction firstOf<T>(value: T | T[] | undefined): T | undefined {\n if (Array.isArray(value)) return value[0]\n return value\n}\n\nfunction firstXAxis(option: EChartsOption): CategoryXAxis | undefined {\n const axis = firstOf(\n option.xAxis as CategoryXAxis | CategoryXAxis[] | undefined,\n )\n return axis && typeof axis === 'object' ? axis : undefined\n}\n\nfunction hasDataZoom(option: EChartsOption): boolean {\n const dz = option.dataZoom\n return Array.isArray(dz) ? dz.length > 0 : dz != null\n}\n\nfunction cellToText(value: Cell, fmt: AxisLabel['formatter']): string {\n if (typeof fmt === 'function') return String(fmt(value ?? ''))\n return value == null ? '' : String(value)\n}\n\n/**\n * Extracts the displayed first/last category strings and the label font from\n * the option, reading categories generically via `series[0].encode.x` into the\n * referenced dataset (`'name'` for bar, `0` for histogram). Returns `null` when\n * the option isn't a measurable category x-axis (fewer than 2 categories, no\n * dataset, etc.).\n */\nexport function resolveEdgeLabels(option: EChartsOption): {\n firstLabel: string\n lastLabel: string\n font: string\n count: number\n} | null {\n const xAxis = firstXAxis(option)\n if (!xAxis) return null\n if (xAxis.type !== 'category') return null\n\n const series0 = firstOf(\n option.series as SeriesLike | SeriesLike[] | undefined,\n )\n const encodeX = series0?.encode?.x\n if (encodeX == null) return null\n\n const datasetIndex = series0?.datasetIndex ?? 0\n const allDatasets = option.dataset as\n | { source?: unknown }\n | { source?: unknown }[]\n | undefined\n const dataset = Array.isArray(allDatasets)\n ? allDatasets[datasetIndex]\n : allDatasets\n const source = dataset?.source\n if (!Array.isArray(source) || source.length < 2) return null\n\n const rows = source as Record<string | number, Cell>[]\n const fmt = xAxis.axisLabel?.formatter\n const axisLabel = xAxis.axisLabel ?? {}\n const size =\n typeof axisLabel.fontSize === 'number'\n ? `${axisLabel.fontSize}px`\n : (axisLabel.fontSize ?? '12px')\n const family = axisLabel.fontFamily ?? 'sans-serif'\n const weight = axisLabel.fontWeight != null ? `${axisLabel.fontWeight} ` : ''\n\n return {\n firstLabel: cellToText(rows[0]?.[encodeX], fmt),\n lastLabel: cellToText(rows[rows.length - 1]?.[encodeX], fmt),\n font: `${weight}${size} ${family}`,\n count: source.length,\n }\n}\n\n/**\n * Measures the rendered chart and, when the edge labels would clip, applies\n * `alignMinLabel`/`alignMaxLabel` (or clears them) via an imperative merge\n * `setOption`. Returns the alignment now in effect so the caller can keep a\n * `prev` ref and skip redundant `setOption`s. Should be invoked from the\n * chart's `finished` event (layout is settled, so `convertToPixel` is valid).\n */\nexport function clampEdgeLabels(\n chart: ECharts,\n option: EChartsOption,\n prev: EdgeAlignment,\n): EdgeAlignment {\n const next = computeAlignment(chart, option)\n if (\n next.alignMinLabel === prev.alignMinLabel &&\n next.alignMaxLabel === prev.alignMaxLabel\n ) {\n return prev\n }\n chart.setOption({ xAxis: { axisLabel: { ...next } } } as EChartsOption, {\n lazyUpdate: true,\n })\n return next\n}\n\nfunction computeAlignment(\n chart: ECharts,\n option: EChartsOption,\n): EdgeAlignment {\n // Under dataZoom, convertToPixel on the absolute first/last index returns\n // off-plot pixels, so the overflow math is invalid — reset to centered.\n if (hasDataZoom(option)) return CENTERED\n\n const labels = resolveEdgeLabels(option)\n if (!labels) return CENTERED\n\n const firstTickX = chart.convertToPixel({ xAxisIndex: 0 }, 0)\n const lastTickX = chart.convertToPixel({ xAxisIndex: 0 }, labels.count - 1)\n const width = chart.getWidth()\n // Layout not measurable yet (defensive — `finished` normally fires after\n // layout). Fall back to centered; a later `finished` re-measures.\n if (\n typeof firstTickX !== 'number' ||\n typeof lastTickX !== 'number' ||\n !Number.isFinite(firstTickX) ||\n !Number.isFinite(lastTickX) ||\n !width\n ) {\n return CENTERED\n }\n\n return decideEdgeAlignment({\n firstLabel: labels.firstLabel,\n lastLabel: labels.lastLabel,\n font: labels.font,\n firstTickX,\n lastTickX,\n width,\n })\n}\n","type ResizeCallback = () => void\n\nconst callbacks = new Map<Element, ResizeCallback>()\nlet observer: ResizeObserver | null = null\n\n/**\n * Returns the singleton ResizeObserver, lazily constructing it on first use.\n * Returns `null` when `ResizeObserver` is not available in the global scope\n * (SSR, very old browsers, or tests that intentionally remove it).\n */\nfunction getObserver(): ResizeObserver | null {\n if (typeof ResizeObserver === 'undefined') return null\n observer ??= new ResizeObserver((entries) => {\n for (const entry of entries) {\n const callback = callbacks.get(entry.target)\n callback?.()\n }\n })\n return observer\n}\n\nconst NOOP_CLEANUP = (): void => undefined\n\nexport function observeResize(\n element: Element,\n callback: ResizeCallback,\n): () => void {\n const ro = getObserver()\n // Gracefully degrade when no ResizeObserver is available — consumers\n // still see one initial measure() pass via their own effect; we just\n // skip the subsequent resize-driven re-measures.\n if (!ro) return NOOP_CLEANUP\n callbacks.set(element, callback)\n ro.observe(element)\n return () => {\n callbacks.delete(element)\n if (observer) {\n observer.unobserve(element)\n // Disconnect the singleton once the last subscriber leaves so the\n // observer doesn't outlive its consumers in SSR teardown / micro-\n // frontend unmount scenarios. A subsequent observeResize() will\n // lazily re-create it via getObserver().\n if (callbacks.size === 0) {\n observer.disconnect()\n observer = null\n }\n }\n }\n}\n\n/** @internal — for tests only. */\nexport function __resetSharedResizeObserver(): void {\n if (observer) observer.disconnect()\n callbacks.clear()\n observer = null\n}\n","import type { SxProps, Theme } from '@mui/material'\n\nexport const styles = {\n root: {\n width: '100%',\n minHeight: 0,\n },\n} satisfies Record<string, SxProps<Theme>>\n","import { useEffect, useEffectEvent, useRef } from 'react'\nimport { Box, type SxProps, type Theme } from '@mui/material'\nimport * as echarts from 'echarts'\nimport {\n clampEdgeLabels,\n CENTERED,\n type EdgeAlignment,\n} from './edge-label-clamp'\nimport { observeResize } from './shared-resize-observer'\nimport { styles } from './style'\n\nexport const DEFAULT_INIT_OPTS = {\n renderer: 'svg',\n height: 304,\n} satisfies echarts.EChartsInitOpts\n\nexport type EchartsEventHandler = (event: unknown) => void\n\nexport interface EchartUIProps {\n option: echarts.EChartsOption\n /**\n * Keys to merge as arrays (replace by index) instead of by id. The middleware\n * memoizes this content-stably, so identical sets don't re-trigger setOption.\n */\n replaceMerge?: readonly string[]\n /**\n * Opaque ECharts event passthrough — handlers fire untransformed.\n *\n * **Must be referentially stable** (memoize it with `useMemo` /\n * `useCallback`, or hoist to module scope). The binding effect depends on\n * the `onEvents` object identity; an inline `{ click: handler }` literal\n * recreates the object on every render and causes every listener to be\n * detached and re-attached each commit.\n */\n onEvents?: Record<string, EchartsEventHandler>\n /**\n * Init options forwarded to echarts.init. Captured at mount only — to change\n * `renderer` or `height` after mount, unmount and remount the chart.\n * Defaults: `{ renderer: 'svg', height: 304 }`.\n */\n init?: echarts.EChartsInitOpts\n /**\n * Optional callback fired once after the ECharts instance is created\n * (`onInstance(chart)`) and once when it's about to be disposed\n * (`onInstance(null)`). Used by `Widget.Echart` to publish the live\n * instance to the per-widget registry so other actions (e.g.\n * `ZoomToggle`'s disable handler) can reach it without DOM lookups.\n * No need to memoize — the bridge wraps it in `useEffectEvent` so an\n * unstable reference does not re-init the chart.\n */\n onInstance?: (chart: echarts.ECharts | null) => void\n className?: string\n sx?: SxProps<Theme>\n}\n\nexport function EchartUI({\n option,\n replaceMerge,\n onEvents,\n init,\n onInstance,\n className,\n sx,\n}: EchartUIProps) {\n const containerRef = useRef<HTMLDivElement>(null)\n const chartRef = useRef<echarts.ECharts | null>(null)\n\n // Structural fingerprint of the last applied series / dataset arrays.\n // Used to decide whether the next `setOption` should *replace* those\n // components (when their shape changed) or *merge* them (when only\n // styling-level fields differ — e.g. a new `itemStyle.color` callback\n // from a selection update). Replacing wipes ECharts' per-series runtime\n // state (hover, animation cache, brush areas), so we want to do it only\n // when the structure actually moved.\n const seriesFingerprintRef = useRef<string | null>(null)\n const datasetFingerprintRef = useRef<string | null>(null)\n\n // Latest applied option (read by the `finished` clamp listener, which is\n // bound once and must see the current option) + the edge-label alignment\n // currently applied to the chart (so the clamp skips redundant setOptions).\n const optionRef = useRef<echarts.EChartsOption>(option)\n const edgeAlignRef = useRef<EdgeAlignment>(CENTERED)\n\n // Stable notify wrapper — always reads the latest `onInstance` prop\n // without forcing the init effect below to re-run when the parent\n // passes a fresh function reference. The init effect now only fires\n // when `init` actually changes (documented as mount-only anyway).\n const notifyInstance = useEffectEvent(\n (chart: echarts.ECharts | null): void => {\n onInstance?.(chart)\n },\n )\n\n // Init / dispose. `init` is captured once at mount.\n useEffect(() => {\n if (!containerRef.current) return undefined\n const chart = echarts.init(containerRef.current, null, {\n ...DEFAULT_INIT_OPTS,\n ...init,\n })\n chartRef.current = chart\n notifyInstance(chart)\n // Edge-label clamp: after each layout settles (option change OR resize both\n // end in a render → `finished`), measure the category x-axis edge labels\n // and anchor them inward only if they'd clip. `finished` (not rAF) so\n // `convertToPixel` sees the flushed `lazyUpdate` layout. Loop-safe: the\n // verdict is anchor-independent, so our own clamp setOption recomputes the\n // same result and the ref guard short-circuits.\n const onFinished = (): void => {\n edgeAlignRef.current = clampEdgeLabels(\n chart,\n optionRef.current,\n edgeAlignRef.current,\n )\n }\n chart.on('finished', onFinished)\n return () => {\n chart.off('finished', onFinished)\n // Notify observers *before* disposal so any queued imperative\n // dispatches (e.g. ZoomToggle's `setOption` cleanup) see the\n // instance disappear before its DOM is torn down.\n notifyInstance(null)\n chart.dispose()\n chartRef.current = null\n }\n }, [init])\n\n // Apply option / replaceMerge changes via merge mode (no remount required).\n useEffect(() => {\n const seriesFp = computeSeriesFingerprint(option)\n const datasetFp = computeDatasetFingerprint(option)\n const augmented = new Set<string>(replaceMerge ?? [])\n if (seriesFp !== seriesFingerprintRef.current) augmented.add('series')\n if (datasetFp !== datasetFingerprintRef.current) augmented.add('dataset')\n seriesFingerprintRef.current = seriesFp\n datasetFingerprintRef.current = datasetFp\n // Expose the latest option to the `finished` clamp listener (bound once).\n optionRef.current = option\n chartRef.current?.setOption(option, {\n notMerge: false,\n lazyUpdate: true,\n replaceMerge: augmented.size > 0 ? Array.from(augmented) : undefined,\n })\n }, [option, replaceMerge])\n\n // Resize via shared singleton observer.\n useEffect(() => {\n const node = containerRef.current\n if (!node) return undefined\n return observeResize(node, () => {\n chartRef.current?.resize()\n })\n }, [])\n\n // Bind / unbind opaque event handlers.\n useEffect(() => {\n const chart = chartRef.current\n if (!chart || !onEvents) return undefined\n for (const [event, handler] of Object.entries(onEvents)) {\n chart.on(event, handler)\n }\n return () => {\n for (const [event, handler] of Object.entries(onEvents)) {\n chart.off(event, handler)\n }\n }\n }, [onEvents])\n\n return (\n <Box\n ref={containerRef}\n className={className}\n sx={{ ...styles.root, ...sx }}\n />\n )\n}\n\n/**\n * Cheap structural digest of the option's `series` array — covers the fields\n * that actually demand a `replaceMerge` (length, type, datasetIndex, name,\n * stack, encode). Excludes runtime-style fields like `itemStyle` (callbacks\n * have unstable identity but don't change structure).\n */\nfunction computeSeriesFingerprint(option: echarts.EChartsOption): string {\n const series = option.series\n if (!Array.isArray(series)) return series ? '1' : ''\n return series\n .map((s) => {\n if (s == null || typeof s !== 'object') return String(s)\n const o = s as Record<string, unknown>\n return [\n o.type,\n o.datasetIndex,\n o.name,\n o.stack,\n // `encode` is small; stringify is cheap and stable for plain objects.\n JSON.stringify(o.encode ?? null),\n ].join('|')\n })\n .join('||')\n}\n\n/**\n * Structural digest of the option's `dataset` array — count is the only\n * thing that needs `replaceMerge` here. Row-level changes are picked up by\n * ECharts' default merge.\n */\nfunction computeDatasetFingerprint(option: echarts.EChartsOption): string {\n const dataset = option.dataset\n if (!Array.isArray(dataset)) return dataset ? '1' : ''\n return String(dataset.length)\n}\n","import { useCallback, useMemo } from 'react'\nimport type * as echarts from 'echarts'\nimport {\n applyTransforms,\n setEchartInstance,\n useWidgetId,\n useWidgetShallow,\n type Transform,\n} from '../stores'\nimport { EchartUI, type EchartsEventHandler } from './echart-ui'\n\n/**\n * Default ECharts `replaceMerge` keys for every widget. `dataZoom` and\n * `brush` are omitted so ZoomToggle / BrushToggle's user-driven runtime\n * state (slider range, brushed areas in `multiple` mode) survives unrelated\n * re-renders. `series` and `dataset` are also omitted: EchartUI fingerprints\n * them per-render and adds them to `replaceMerge` only when their shape\n * actually changes, keeping ECharts' per-series runtime state alive when\n * only callback-style fields differ.\n *\n * Lives in this module (not the generic store) because it's an ECharts\n * concept. Module-private — callers should not need it.\n */\nconst DEFAULT_REPLACE_MERGE: readonly string[] = ['toolbox']\n\n/**\n * Reactive context passed to every {@link OptionFactory} call so the\n * factory can rebuild render-time pieces (axis label / tooltip formatters)\n * from the live store. Drives RelativeData / consumer-formatter changes\n * through to the chart without rebuilding the structural option.\n */\nexport interface OptionFactoryContext {\n formatter?: (value: number) => string\n labelFormatter?: (value: string | number) => string | number\n}\n\n/**\n * The per-widget option factory — a single callable that owns BOTH phases\n * of option construction:\n *\n * - **Structural phase** — when `option == null`, return the theme-aware\n * structural option (tooltip / legend / color palette / series\n * template, optionally merged with a consumer-supplied `optionsOverride`).\n * No data is read. `<Widget.Echart>` calls the factory with\n * `(undefined, undefined)` synchronously during render to derive the\n * structural base; `configTransforms` (Stack/Zoom/Brush) then mutate it\n * in the same render pass.\n * - **Merge phase** — when `option` is defined, fuse `data` into the\n * post-configTransforms option at fusion time. `<Widget.Echart>` calls\n * the factory with `(transformed, data, ctx)` on every render.\n *\n * The two phases share a closure (the factory creator captures `theme`,\n * `formatter`, `labelFormatter`, `seriesNames`, `selection`, `optionsOverride`,\n * …), so structural and merge agree on the same widget configuration.\n *\n * The third arg `ctx` carries the **live** store-side formatters at the\n * call site — distinct from the closure-time formatters because actions\n * like RelativeData can install a percent formatter on the store after\n * the factory was constructed. The merge phase reads from `ctx`; the\n * structural phase typically uses the closure-time values.\n */\nexport type OptionFactory = (\n option: echarts.EChartsOption | undefined,\n data: unknown,\n ctx?: OptionFactoryContext,\n) => echarts.EChartsOption\n\nexport interface EchartProps {\n /**\n * The per-widget {@link OptionFactory}. Required — `<Widget.Echart>`\n * derives the structural option from it (so configTransforms have a base\n * to mutate) and fuses `state.data` into the post-pipeline option at\n * render time. Wrap the factory creator in `useMemo` so its identity is\n * stable across renders.\n */\n optionFactory: OptionFactory\n onEvents?: Record<string, EchartsEventHandler>\n init?: echarts.EChartsInitOpts\n className?: string\n}\n\ninterface EchartSlice {\n data: unknown\n configTransforms: readonly Transform[]\n formatter?: (value: number) => string\n labelFormatter?: (value: string | number) => string | number\n}\n\nconst echartSelector = (s: {\n data: unknown\n configTransforms: readonly Transform[]\n formatter?: (value: number) => string\n labelFormatter?: (value: string | number) => string | number\n}): EchartSlice => ({\n data: s.data,\n configTransforms: s.configTransforms,\n formatter: s.formatter,\n labelFormatter: s.labelFormatter,\n})\n\n/**\n * Stateful Echart bridge — owns the entire ECharts coupling. The whole\n * option pipeline lives here, not in the store:\n *\n * 1. **Structural** — `optionFactory(undefined, undefined)` produces the\n * theme-aware base. Memoized on the factory identity, so the consumer's\n * `useMemo` ID gates the rebuild.\n * 2. **Transformed** — `applyTransforms(structural, configTransforms)`\n * applies any registered configTransforms (Stack/Zoom/Brush) over the\n * structural base. Memoized on `[structural, configTransforms]`.\n * 3. **`replaceMerge`** — derived from the enabled configTransforms'\n * `replaceMergeKeys`, deduped and sorted, seeded with\n * {@link DEFAULT_REPLACE_MERGE}. Memoized on `[configTransforms]` so\n * ECharts sees a stable array reference across non-transform changes.\n * 4. **Merge** — `optionFactory(transformed, data, ctx)` fuses post-\n * pipeline data into the option. Reactive `ctx` carries the live store\n * formatters so RelativeData's percent formatter flows through without\n * a structural rebuild.\n *\n * The `<Widget.Provider>` doesn't know about the factory at all: it stays\n * a renderer-agnostic shell. The `ProviderProps` surface has no ECharts\n * coupling, so non-Echart widgets don't transitively import the type.\n */\nexport function Echart({\n optionFactory,\n onEvents,\n init,\n className,\n}: EchartProps) {\n const id = useWidgetId()\n const slice = useWidgetShallow(id, echartSelector)\n\n // Publish the live ECharts instance to the per-id registry so actions\n // (e.g. `ZoomToggle`'s disable handler) can reach it imperatively. The\n // callback identity is stable across renders (only `id` is in deps), so\n // EchartUI's init effect doesn't see a fresh `onInstance` and re-init.\n const onInstance = useCallback(\n (chart: echarts.ECharts | null) => setEchartInstance(id, chart),\n [id],\n )\n\n // Destructure so React Compiler sees specific deps instead of inferring\n // the whole `slice` object. `useWidgetShallow` already shallow-compares\n // the slice, so per-field deps drive each memo exactly when its inputs\n // change.\n const {\n data: sliceData,\n configTransforms,\n formatter: sliceFormatter,\n labelFormatter: sliceLabelFormatter,\n } = slice\n\n const structural = useMemo(\n () => optionFactory(undefined, undefined),\n [optionFactory],\n )\n\n const transformed = useMemo(\n () =>\n applyTransforms(structural, configTransforms) as echarts.EChartsOption,\n [structural, configTransforms],\n )\n\n const replaceMerge = useMemo(() => {\n const keys = new Set<string>(DEFAULT_REPLACE_MERGE)\n for (const xf of configTransforms) {\n if (xf.enabled && xf.replaceMergeKeys?.length) {\n for (const k of xf.replaceMergeKeys) keys.add(k)\n }\n }\n return Array.from(keys).sort()\n }, [configTransforms])\n\n const option = useMemo(\n () =>\n optionFactory(transformed, sliceData, {\n formatter: sliceFormatter,\n labelFormatter: sliceLabelFormatter,\n }),\n [\n optionFactory,\n transformed,\n sliceData,\n sliceFormatter,\n sliceLabelFormatter,\n ],\n )\n\n return (\n <EchartUI\n option={option}\n replaceMerge={replaceMerge}\n onEvents={onEvents}\n init={init}\n onInstance={onInstance}\n className={className}\n />\n )\n}\n"],"names":["CENTERED","alignMinLabel","alignMaxLabel","SAFETY_MARGIN_PX","decideEdgeAlignment","args","halfFirst","echarts","format","getTextRect","firstLabel","font","width","halfLast","lastLabel","firstTickX","lastTickX","firstOf","value","Array","isArray","firstXAxis","option","axis","xAxis","undefined","hasDataZoom","dz","dataZoom","length","cellToText","fmt","String","resolveEdgeLabels","type","series0","series","encodeX","encode","x","datasetIndex","allDatasets","dataset","source","rows","axisLabel","formatter","size","fontSize","family","fontFamily","weight","fontWeight","count","clampEdgeLabels","chart","prev","next","computeAlignment","setOption","lazyUpdate","labels","convertToPixel","xAxisIndex","getWidth","Number","isFinite","callbacks","Map","observer","getObserver","ResizeObserver","entries","entry","callback","get","target","NOOP_CLEANUP","observeResize","element","ro","set","observe","delete","unobserve","disconnect","__resetSharedResizeObserver","clear","styles","root","minHeight","DEFAULT_INIT_OPTS","renderer","height","EchartUI","t0","$","_c","replaceMerge","onEvents","init","onInstance","className","sx","containerRef","useRef","chartRef","seriesFingerprintRef","datasetFingerprintRef","optionRef","edgeAlignRef","t1","notifyInstance","useEffectEvent","t2","current","chart_0","onFinished","on","off","dispose","t3","useEffect","t4","t5","seriesFp","computeSeriesFingerprint","datasetFp","computeDatasetFingerprint","augmented","Set","add","notMerge","from","t6","t7","Symbol","for","node","resize","t8","t9","chart_1","event","handler","Object","event_0","handler_0","t10","t11","Box","map","s","o","name","stack","JSON","stringify","join","DEFAULT_REPLACE_MERGE","echartSelector","data","configTransforms","labelFormatter","Echart","optionFactory","id","useWidgetId","slice","useWidgetShallow","setEchartInstance","sliceData","sliceFormatter","sliceLabelFormatter","structural","applyTransforms","transformed","keys","xf","enabled","replaceMergeKeys","k","sort"],"mappings":";;;;;;;;AAyBO,MAAMA,IAA0B;AAAA,EACrCC,eAAe;AAAA,EACfC,eAAe;AACjB,GAKMC,IAAmB;AAQlB,SAASC,EAAoBC,GAOlB;AAChB,QAAMC,IACJC,EAAQC,OAAOC,YAAYJ,EAAKK,YAAYL,EAAKM,IAAI,EAAEC,QAAQ,GAC3DC,IACJN,EAAQC,OAAOC,YAAYJ,EAAKS,WAAWT,EAAKM,IAAI,EAAEC,QAAQ;AAChE,SAAO;AAAA,IACLX,eACEK,IAAYH,IAAmBE,EAAKU,aAAa,SAAS;AAAA,IAC5Db,eACEW,IAAWV,IAAmBE,EAAKO,QAAQP,EAAKW,YAC5C,UACA;AAAA,EAAA;AAEV;AAqBA,SAASC,EAAWC,GAA2C;AAC7D,SAAIC,MAAMC,QAAQF,CAAK,IAAUA,EAAM,CAAC,IACjCA;AACT;AAEA,SAASG,EAAWC,GAAkD;AACpE,QAAMC,IAAON,EACXK,EA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AAA,IAAAxG,MAAKkH,KAAM4C,CAAI,EAACK,KAAAA,GAAOtF,OAAAkE,GAAAlE,OAAA2B;AAAAA,EAAA;AAAAA,IAAAA,IAAA3B,EAAA,CAAA;AAPhC,QAAAE,IAOEyB;AACoB,MAAAC;AAAA,EAAA5B,EAAA,CAAA,MAAAqE,KAAArE,EAAA,EAAA,MAAA2E,KAAA3E,EAAA,EAAA,MAAA4E,KAAA5E,EAAA,EAAA,MAAA6E,KAAA7E,UAAAgF,KAIlBpD,IAAAyC,EAAcW,GAAaL,GAAW;AAAA,IAAA7H,WACzB8H;AAAAA,IAAcT,gBACTU;AAAAA,EAAAA,CACjB,GAAC7E,OAAAqE,GAAArE,QAAA2E,GAAA3E,QAAA4E,GAAA5E,QAAA6E,GAAA7E,QAAAgF,GAAAhF,QAAA4B,KAAAA,IAAA5B,EAAA,EAAA;AALN,QAAA1E,IAEIsG;AAWH,MAAAU;AAAA,SAAAtC,UAAAM,KAAAN,EAAA,EAAA,MAAAI,KAAAJ,EAAA,EAAA,MAAAG,KAAAH,EAAA,EAAA,MAAAK,KAAAL,UAAA1E,KAAA0E,EAAA,EAAA,MAAAE,KAGCoC,sBAACxC,IAAA,EACSxE,QAAAA,GACM4E,cAAAA,GACJC,UAAAA,GACJC,MAAAA,GACMC,YAAAA,GACDC,WAAAA,GAAS,GACpBN,QAAAM,GAAAN,QAAAI,GAAAJ,QAAAG,GAAAH,QAAAK,GAAAL,QAAA1E,GAAA0E,QAAAE,GAAAF,QAAAsC,KAAAA,IAAAtC,EAAA,EAAA,GAPFsC;AAOE;"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ECharts, EChartsOption } from 'echarts';
|
|
2
|
+
/**
|
|
3
|
+
* Render-time clamp that stops the first/last **category x-axis** labels from
|
|
4
|
+
* clipping at the chart edges — *only when they actually overflow*.
|
|
5
|
+
*
|
|
6
|
+
* ECharts centers each category label on its tick; the first/last ticks sit at
|
|
7
|
+
* the plot boundary, so a wide edge label spills past the chart and is cut off.
|
|
8
|
+
* `grid.containLabel` does not contain this horizontal overflow and the v6
|
|
9
|
+
* `outerBounds` shrink is unreliable, so we measure at render time and anchor
|
|
10
|
+
* the overflowing edge label inward (`alignMinLabel: 'left'` /
|
|
11
|
+
* `alignMaxLabel: 'right'`). Labels that fit stay centered.
|
|
12
|
+
*
|
|
13
|
+
* Lives in the generic bridge because the verdict needs the laid-out chart
|
|
14
|
+
* (`convertToPixel`, `getWidth`); everything else is read from the `option`.
|
|
15
|
+
* Auto-targets bar + histogram (category x-axis); pie's horizontal-bar fallback
|
|
16
|
+
* (category *y*-axis), scatterplot (value) and timeseries (time) are skipped.
|
|
17
|
+
*/
|
|
18
|
+
export interface EdgeAlignment {
|
|
19
|
+
alignMinLabel: 'left' | null;
|
|
20
|
+
alignMaxLabel: 'right' | null;
|
|
21
|
+
}
|
|
22
|
+
export declare const CENTERED: EdgeAlignment;
|
|
23
|
+
/**
|
|
24
|
+
* Pure overflow decision. Inputs are anchor-independent (tick centers and text
|
|
25
|
+
* width don't depend on the label's current `text-anchor`), so feeding the
|
|
26
|
+
* result back via `setOption` doesn't change them — the next pass yields the
|
|
27
|
+
* same verdict, keeping the clamp loop-stable.
|
|
28
|
+
*/
|
|
29
|
+
export declare function decideEdgeAlignment(args: {
|
|
30
|
+
firstLabel: string;
|
|
31
|
+
lastLabel: string;
|
|
32
|
+
font: string;
|
|
33
|
+
firstTickX: number;
|
|
34
|
+
lastTickX: number;
|
|
35
|
+
width: number;
|
|
36
|
+
}): EdgeAlignment;
|
|
37
|
+
/**
|
|
38
|
+
* Extracts the displayed first/last category strings and the label font from
|
|
39
|
+
* the option, reading categories generically via `series[0].encode.x` into the
|
|
40
|
+
* referenced dataset (`'name'` for bar, `0` for histogram). Returns `null` when
|
|
41
|
+
* the option isn't a measurable category x-axis (fewer than 2 categories, no
|
|
42
|
+
* dataset, etc.).
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveEdgeLabels(option: EChartsOption): {
|
|
45
|
+
firstLabel: string;
|
|
46
|
+
lastLabel: string;
|
|
47
|
+
font: string;
|
|
48
|
+
count: number;
|
|
49
|
+
} | null;
|
|
50
|
+
/**
|
|
51
|
+
* Measures the rendered chart and, when the edge labels would clip, applies
|
|
52
|
+
* `alignMinLabel`/`alignMaxLabel` (or clears them) via an imperative merge
|
|
53
|
+
* `setOption`. Returns the alignment now in effect so the caller can keep a
|
|
54
|
+
* `prev` ref and skip redundant `setOption`s. Should be invoked from the
|
|
55
|
+
* chart's `finished` event (layout is settled, so `convertToPixel` is valid).
|
|
56
|
+
*/
|
|
57
|
+
export declare function clampEdgeLabels(chart: ECharts, option: EChartsOption, prev: EdgeAlignment): EdgeAlignment;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -31,18 +31,6 @@ export declare const styles: {
|
|
|
31
31
|
opacity: number;
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
-
'&.Mui-disabled': {
|
|
35
|
-
pointerEvents: "none";
|
|
36
|
-
bgcolor: "background.paper";
|
|
37
|
-
'& .MuiAccordionSummary-root.Mui-disabled': {
|
|
38
|
-
opacity: number;
|
|
39
|
-
color: "inherit";
|
|
40
|
-
backgroundColor: "transparent";
|
|
41
|
-
};
|
|
42
|
-
'& .MuiAccordionSummary-expandIconWrapper': {
|
|
43
|
-
display: "none";
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
34
|
};
|
|
47
35
|
loading: {
|
|
48
36
|
position: "absolute";
|
|
@@ -60,6 +48,11 @@ export declare const styles: {
|
|
|
60
48
|
alignItems: "center";
|
|
61
49
|
};
|
|
62
50
|
};
|
|
51
|
+
summaryDisabled: {
|
|
52
|
+
'&, &:hover:not(.Mui-disabled)': {
|
|
53
|
+
cursor: "default";
|
|
54
|
+
};
|
|
55
|
+
};
|
|
63
56
|
titleCell: {
|
|
64
57
|
flexGrow: number;
|
|
65
58
|
flexShrink: number;
|