@carto/ps-react-ui 4.11.1 → 4.11.2
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/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 +2 -2
- package/package.json +3 -3
- 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/dist/echart-CU0KmClP.js +0 -176
- package/dist/echart-CU0KmClP.js.map +0 -1
package/dist/widgets-v2/bar.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { n as y, d as
|
|
3
|
-
import { jsx as p, jsxs as
|
|
1
|
+
import * as E from "echarts";
|
|
2
|
+
import { n as y, d as G, g as N, c as V, f as H } from "../option-builders-F-c9ELi1.js";
|
|
3
|
+
import { jsx as p, jsxs as O } from "react/jsx-runtime";
|
|
4
4
|
import { c as R } from "react/compiler-runtime";
|
|
5
|
-
import { Box as g, Skeleton as
|
|
5
|
+
import { Box as g, Skeleton as L } from "@mui/material";
|
|
6
6
|
import "../widget-store-Bw5zRUGg.js";
|
|
7
7
|
import "zustand/shallow";
|
|
8
8
|
import "@mui/icons-material";
|
|
@@ -20,24 +20,24 @@ import "zustand";
|
|
|
20
20
|
import "zustand/vanilla";
|
|
21
21
|
import "zustand/middleware";
|
|
22
22
|
import "zustand/react/shallow";
|
|
23
|
-
import { Z as
|
|
23
|
+
import { Z as B } from "../transforms-Cdx4fkU5.js";
|
|
24
24
|
import { m as W, r as Y } from "../resolve-theme-color-BdojIw0K.js";
|
|
25
25
|
import { p as q } from "../data-zoom-layout-CkVnm6ej.js";
|
|
26
26
|
import { a as U } from "../exports-Cx-f6m6U.js";
|
|
27
27
|
import { b as J, C as K } from "../png-item-BE9uEqlD.js";
|
|
28
28
|
function Q({
|
|
29
29
|
theme: e,
|
|
30
|
-
formatter:
|
|
30
|
+
formatter: o,
|
|
31
31
|
labelFormatter: t
|
|
32
32
|
}) {
|
|
33
|
-
let
|
|
33
|
+
let s = 0, i = 1;
|
|
34
34
|
return {
|
|
35
35
|
grid: {
|
|
36
36
|
left: parseInt(e.spacing(1)),
|
|
37
37
|
top: parseInt(e.spacing(3)),
|
|
38
38
|
right: parseInt(e.spacing(1)),
|
|
39
39
|
// Default: no legend. Merger bumps this when there are >1 series.
|
|
40
|
-
...
|
|
40
|
+
...V(!1, e),
|
|
41
41
|
containLabel: !0
|
|
42
42
|
},
|
|
43
43
|
tooltip: {
|
|
@@ -53,13 +53,13 @@ function Q({
|
|
|
53
53
|
axisPointer: {
|
|
54
54
|
type: "line"
|
|
55
55
|
},
|
|
56
|
-
position:
|
|
57
|
-
formatter:
|
|
56
|
+
position: N(e),
|
|
57
|
+
formatter: _(o, t)
|
|
58
58
|
},
|
|
59
59
|
// Legend styling baked here; `show` is toggled by the merger based on
|
|
60
60
|
// series count.
|
|
61
61
|
legend: {
|
|
62
|
-
...
|
|
62
|
+
...G({
|
|
63
63
|
hasLegend: !1,
|
|
64
64
|
labelFormatter: t
|
|
65
65
|
})
|
|
@@ -83,14 +83,14 @@ function Q({
|
|
|
83
83
|
margin: 0,
|
|
84
84
|
hideOverlap: !0,
|
|
85
85
|
...t && {
|
|
86
|
-
formatter: (
|
|
86
|
+
formatter: (a) => String(t(a))
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
90
|
yAxis: {
|
|
91
91
|
type: "value",
|
|
92
|
-
min: (
|
|
93
|
-
max: (
|
|
92
|
+
min: (a) => (s = a.min < 0 ? y(a.min) : 0, s),
|
|
93
|
+
max: (a) => (i = a.max <= 0 ? 1 : y(a.max), i),
|
|
94
94
|
axisLine: {
|
|
95
95
|
show: !1
|
|
96
96
|
},
|
|
@@ -112,57 +112,56 @@ function Q({
|
|
|
112
112
|
showMinLabel: !0,
|
|
113
113
|
verticalAlign: "bottom",
|
|
114
114
|
inside: !0,
|
|
115
|
-
formatter: (
|
|
115
|
+
formatter: (a) => a !== i && a !== s || a === 0 ? "" : o ? o(a) : String(a)
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function Te(e) {
|
|
121
121
|
const {
|
|
122
|
-
theme:
|
|
122
|
+
theme: o,
|
|
123
123
|
formatter: t,
|
|
124
|
-
labelFormatter:
|
|
125
|
-
optionsOverride:
|
|
126
|
-
} = e,
|
|
127
|
-
return (n,
|
|
124
|
+
labelFormatter: s,
|
|
125
|
+
optionsOverride: i
|
|
126
|
+
} = e, a = e.series, c = e.selection, m = c && c.length > 0 ? new Set(c) : null;
|
|
127
|
+
return (n, I, C) => {
|
|
128
128
|
if (n == null) {
|
|
129
|
-
const
|
|
130
|
-
theme:
|
|
129
|
+
const r = Q({
|
|
130
|
+
theme: o,
|
|
131
131
|
formatter: t,
|
|
132
|
-
labelFormatter:
|
|
132
|
+
labelFormatter: s
|
|
133
133
|
});
|
|
134
|
-
return
|
|
134
|
+
return i ? W(r, i) : r;
|
|
135
135
|
}
|
|
136
|
-
const
|
|
137
|
-
if (
|
|
136
|
+
const u = Array.isArray(I) ? I : [];
|
|
137
|
+
if (u.length === 0)
|
|
138
138
|
return {
|
|
139
139
|
...n,
|
|
140
140
|
dataset: [],
|
|
141
141
|
series: []
|
|
142
142
|
};
|
|
143
|
-
const b =
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return u != null && m.has(u) ? c : $.color.modifyAlpha(c, 0.15);
|
|
143
|
+
const b = u.length > 1, F = typeof n.legend == "object" && !Array.isArray(n.legend) ? n.legend : {}, x = typeof n.grid == "object" && !Array.isArray(n.grid) ? n.grid : {}, M = typeof n.tooltip == "object" && !Array.isArray(n.tooltip) ? n.tooltip : {}, k = typeof n.yAxis == "object" && !Array.isArray(n.yAxis) ? n.yAxis : {}, T = Array.isArray(n.series) ? n.series : [], D = T[0] ?? {}, h = C?.formatter, P = C?.labelFormatter;
|
|
144
|
+
let S = 0, A = 1;
|
|
145
|
+
const w = q(n.dataZoom, b), Z = typeof x.bottom == "number" ? x.bottom : 24, j = b ? 56 : Z, $ = w ? j + B.sliderHeight + B.sliderGap : j, z = {
|
|
146
|
+
color: (r) => {
|
|
147
|
+
const l = r.color;
|
|
148
|
+
if (!m) return l;
|
|
149
|
+
const d = r.value?.name ?? r.name;
|
|
150
|
+
return d != null && m.has(d) ? l : E.color.modifyAlpha(l, 0.15);
|
|
152
151
|
}
|
|
153
152
|
};
|
|
154
153
|
return {
|
|
155
154
|
...n,
|
|
156
|
-
dataset:
|
|
157
|
-
source:
|
|
155
|
+
dataset: u.map((r) => ({
|
|
156
|
+
source: r
|
|
158
157
|
})),
|
|
159
|
-
series:
|
|
160
|
-
const
|
|
158
|
+
series: u.map((r, l) => {
|
|
159
|
+
const v = T[l] ?? D, d = Y(o, a?.[l]?.color);
|
|
161
160
|
return {
|
|
162
|
-
...typeof
|
|
161
|
+
...typeof v == "object" ? v : {},
|
|
163
162
|
type: "bar",
|
|
164
|
-
datasetIndex:
|
|
165
|
-
name:
|
|
163
|
+
datasetIndex: l,
|
|
164
|
+
name: a?.[l]?.name ?? `Series ${l + 1}`,
|
|
166
165
|
encode: {
|
|
167
166
|
x: "name",
|
|
168
167
|
y: "value"
|
|
@@ -171,62 +170,51 @@ function Be(e) {
|
|
|
171
170
|
emphasis: {
|
|
172
171
|
focus: "series"
|
|
173
172
|
},
|
|
174
|
-
itemStyle:
|
|
175
|
-
...
|
|
176
|
-
color:
|
|
173
|
+
itemStyle: z,
|
|
174
|
+
...d ? {
|
|
175
|
+
color: d
|
|
177
176
|
} : {}
|
|
178
177
|
};
|
|
179
178
|
}),
|
|
180
179
|
legend: {
|
|
181
|
-
...
|
|
180
|
+
...F,
|
|
182
181
|
show: b
|
|
183
182
|
},
|
|
184
183
|
grid: {
|
|
185
184
|
...x,
|
|
186
|
-
bottom:
|
|
185
|
+
bottom: $
|
|
187
186
|
},
|
|
188
|
-
...
|
|
189
|
-
dataZoom:
|
|
187
|
+
...w ? {
|
|
188
|
+
dataZoom: w
|
|
190
189
|
} : {},
|
|
191
190
|
yAxis: {
|
|
192
|
-
...
|
|
193
|
-
min:
|
|
194
|
-
max:
|
|
191
|
+
...k,
|
|
192
|
+
min: (r) => (S = r.min < 0 ? y(r.min) : 0, S),
|
|
193
|
+
max: (r) => (A = r.max <= 0 ? 1 : y(r.max), A),
|
|
195
194
|
axisLabel: {
|
|
196
|
-
...
|
|
197
|
-
formatter: (
|
|
195
|
+
...k.axisLabel ?? {},
|
|
196
|
+
formatter: (r) => r !== A && r !== S || r === 0 ? "" : h ? h(r) : String(r)
|
|
198
197
|
}
|
|
199
198
|
},
|
|
200
199
|
tooltip: {
|
|
201
|
-
...
|
|
202
|
-
formatter:
|
|
200
|
+
...M,
|
|
201
|
+
formatter: _(h, P)
|
|
203
202
|
}
|
|
204
203
|
};
|
|
205
204
|
};
|
|
206
205
|
}
|
|
207
|
-
function
|
|
206
|
+
function _(e, o) {
|
|
208
207
|
return H((t) => {
|
|
209
|
-
const
|
|
208
|
+
const i = t.value?.value, a = typeof i == "number" && e ? e(i) : i ?? "", c = typeof t.marker == "string" ? t.marker : "", m = t.seriesName ? `${t.seriesName}: ` : "", n = o ? String(o(t.name ?? "")) : t.name ?? "";
|
|
210
209
|
return {
|
|
211
210
|
name: String(n),
|
|
212
211
|
seriesName: m,
|
|
213
|
-
marker:
|
|
214
|
-
value:
|
|
212
|
+
marker: c,
|
|
213
|
+
value: a
|
|
215
214
|
};
|
|
216
215
|
});
|
|
217
216
|
}
|
|
218
|
-
|
|
219
|
-
let r = 0, t = -1 / 0;
|
|
220
|
-
for (const o of e)
|
|
221
|
-
for (const s of o)
|
|
222
|
-
typeof s?.value != "number" || !Number.isFinite(s.value) || (s.value < r && (r = s.value), s.value > t && (t = s.value));
|
|
223
|
-
const l = r < 0 ? y(r) : 0, a = t <= 0 ? 1 : y(t);
|
|
224
|
-
return {
|
|
225
|
-
niceMinVal: l,
|
|
226
|
-
niceMaxVal: a
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
const d = {
|
|
217
|
+
const f = {
|
|
230
218
|
container: {
|
|
231
219
|
display: "flex",
|
|
232
220
|
alignItems: "center",
|
|
@@ -274,56 +262,56 @@ const d = {
|
|
|
274
262
|
spacing: e
|
|
275
263
|
}) => e(1.5)
|
|
276
264
|
}
|
|
277
|
-
},
|
|
265
|
+
}, X = ["20%", "40%", "60%", "20%", "80%"];
|
|
278
266
|
function je() {
|
|
279
267
|
const e = R(2);
|
|
280
|
-
let
|
|
281
|
-
e[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (
|
|
268
|
+
let o;
|
|
269
|
+
e[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (o = /* @__PURE__ */ p(g, { sx: f.grid, children: X.map(te) }), e[0] = o) : o = e[0];
|
|
282
270
|
let t;
|
|
283
|
-
return e[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */
|
|
284
|
-
|
|
285
|
-
/* @__PURE__ */ p(g, { sx:
|
|
271
|
+
return e[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */ O(g, { sx: f.container, children: [
|
|
272
|
+
o,
|
|
273
|
+
/* @__PURE__ */ p(g, { sx: f.legend, children: [0, 1].map(ee) })
|
|
286
274
|
] }), e[1] = t) : t = e[1], t;
|
|
287
275
|
}
|
|
288
|
-
function
|
|
289
|
-
return /* @__PURE__ */
|
|
290
|
-
/* @__PURE__ */ p(
|
|
291
|
-
/* @__PURE__ */ p(
|
|
276
|
+
function ee(e) {
|
|
277
|
+
return /* @__PURE__ */ O(g, { sx: f.legendItem, children: [
|
|
278
|
+
/* @__PURE__ */ p(L, { variant: "circular", width: 8, height: 8 }),
|
|
279
|
+
/* @__PURE__ */ p(L, { width: 48, height: 8 })
|
|
292
280
|
] }, `legend-${e}`);
|
|
293
281
|
}
|
|
294
|
-
function
|
|
295
|
-
return /* @__PURE__ */ p(
|
|
282
|
+
function te(e, o) {
|
|
283
|
+
return /* @__PURE__ */ p(L, { sx: f.bar, variant: "rectangular", height: e }, `bar-${o}`);
|
|
296
284
|
}
|
|
297
|
-
function
|
|
298
|
-
const
|
|
299
|
-
return e.getCaptureEl &&
|
|
285
|
+
function Be(e) {
|
|
286
|
+
const o = [];
|
|
287
|
+
return e.getCaptureEl && o.push(J({
|
|
300
288
|
filename: e.filename,
|
|
301
289
|
getCaptureEl: e.getCaptureEl,
|
|
302
290
|
pixelRatio: e.pngPixelRatio,
|
|
303
291
|
backgroundColor: e.pngBackgroundColor
|
|
304
|
-
})),
|
|
292
|
+
})), o.push({
|
|
305
293
|
id: "csv",
|
|
306
294
|
label: "CSV",
|
|
307
295
|
icon: /* @__PURE__ */ p(K, { fontSize: "small" }),
|
|
308
296
|
resolve: () => {
|
|
309
|
-
const t = e.getData(),
|
|
310
|
-
for (const [
|
|
311
|
-
|
|
312
|
-
for (const m of
|
|
297
|
+
const t = e.getData(), s = [];
|
|
298
|
+
for (const [a, c] of t.entries()) {
|
|
299
|
+
a > 0 && s.push([]), s.push(["name", "value"]);
|
|
300
|
+
for (const m of c) s.push([m.name, m.value]);
|
|
313
301
|
}
|
|
314
|
-
const
|
|
302
|
+
const i = U(s);
|
|
315
303
|
return Promise.resolve({
|
|
316
|
-
url:
|
|
304
|
+
url: i.url,
|
|
317
305
|
filename: `${e.filename}.csv`,
|
|
318
|
-
revoke:
|
|
306
|
+
revoke: i.revoke
|
|
319
307
|
});
|
|
320
308
|
}
|
|
321
|
-
}),
|
|
309
|
+
}), o;
|
|
322
310
|
}
|
|
323
311
|
export {
|
|
324
312
|
je as BarSkeleton,
|
|
325
313
|
Q as barOptions,
|
|
326
|
-
|
|
327
|
-
|
|
314
|
+
Be as createBarDownloadConfig,
|
|
315
|
+
Te as createBarOptionFactory
|
|
328
316
|
};
|
|
329
317
|
//# sourceMappingURL=bar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bar.js","sources":["../../src/widgets-v2/bar/options.ts","../../src/widgets-v2/bar/skeleton.tsx","../../src/widgets-v2/bar/download.tsx"],"sourcesContent":["import type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildGridConfig,\n buildLegendConfig,\n createTooltipFormatter,\n createTooltipPositioner,\n niceNum,\n} from '../../widgets/utils/chart-config'\nimport { ZOOM_LAYOUT } from '../actions/zoom-toggle'\nimport type { OptionFactory } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport { positionDataZoomForLegend } from '../utils/data-zoom-layout'\nimport type {\n BarEChartsOption,\n BarOptionFactoryInput,\n BarOptionsInput,\n BarWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a bar widget — axes, grid,\n * tooltip styling, themed legend. Intentionally data-agnostic: no series,\n * no dataset, no `legend.show` (those depend on data and are added by the\n * option factory's merge phase). This separation is what lets data-side\n * pipeline transforms (Searcher, RelativeData) drive the rendered chart —\n * the merge happens at render time inside the Echart bridge.\n *\n * Styling matches the v1 `barConfig` look-and-feel: minimal axes (only\n * min/max y-labels rendered inside the plot via `niceNum`), themed tooltip,\n * scroll legend, and CARTO color palette. The y-axis min/max + label\n * formatter and the tooltip formatter are wired here for the no-data case;\n * {@link createBarOptionFactory} re-derives them at fusion time so reactive\n * formatter changes (RelativeData) and stack templates (StackToggle) flow\n * through to the chart.\n */\nexport function barOptions({\n theme,\n formatter,\n labelFormatter,\n}: BarOptionsInput): BarEChartsOption {\n // Closure shared between yAxis min/max callbacks and the label formatter,\n // so only the rounded extents are labelled (matches v1).\n let niceMin = 0\n let niceMax = 1\n\n return {\n grid: {\n left: parseInt(theme.spacing(1)),\n top: parseInt(theme.spacing(3)),\n right: parseInt(theme.spacing(1)),\n // Default: no legend. Merger bumps this when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n trigger: 'axis',\n backgroundColor: theme.palette.grey[900],\n borderWidth: 0,\n padding: [parseInt(theme.spacing(1)), parseInt(theme.spacing(1))],\n textStyle: {\n color: theme.palette.common.white,\n fontSize: 11,\n fontFamily: theme.typography.caption.fontFamily,\n },\n axisPointer: { type: 'line' },\n position: createTooltipPositioner(theme),\n formatter: buildBarTooltipFormatter(formatter, labelFormatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count.\n legend: {\n ...buildLegendConfig({ hasLegend: false, labelFormatter }),\n },\n axisPointer: { lineStyle: { color: theme.palette.grey[400] } },\n color: [\n theme.palette.secondary.main,\n ...Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n ],\n xAxis: {\n type: 'category',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n margin: 0,\n hideOverlap: true,\n ...(labelFormatter && {\n formatter: (v: string | number) => String(labelFormatter(v)),\n }),\n },\n },\n yAxis: {\n type: 'value',\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLine: { show: false },\n axisTick: { show: false },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n axisLabel: {\n fontSize: theme.typography.overlineDelicate?.fontSize,\n fontFamily: theme.typography.overlineDelicate?.fontFamily,\n margin: parseInt(theme.spacing(1)),\n show: true,\n showMaxLabel: true,\n showMinLabel: true,\n verticalAlign: 'bottom',\n inside: true,\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n } as BarEChartsOption\n}\n\n/**\n * Returns the bar widget's {@link OptionFactory} — a single closure that\n * handles BOTH option-construction phases:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link barOptions}, optionally merging the\n * consumer-supplied `optionsOverride` on top. Called once by Provider\n * to seed `rawOptions` in the store; configTransforms (StackToggle /\n * ZoomToggle / BrushToggle) then mutate it via the pipeline middleware.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`BarWidgetData`) into the option via the dataset API: one dataset\n * per series, each series referencing its dataset by index, encoded\n * by `name` (x) and `value` (y). Spreads any series-template fields\n * already on the incoming option (e.g. `{ stack: 'total' }` from\n * `addStack`) into every emitted series so configTransforms compose\n * end-to-end. Reactive `ctx.formatter` / `ctx.labelFormatter` drive\n * the y-axis min/max-only label and the tooltip formatter at fusion\n * time so RelativeData's percent formatter flows through without a\n * structural rebuild.\n *\n * Stable identity when the inputs don't change (consumers should wrap the\n * call in `useMemo` keyed on the same inputs).\n */\nexport function createBarOptionFactory(\n options: BarOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, labelFormatter, optionsOverride } = options\n const series = options.series\n const selection = options.selection\n const selectionSet =\n selection && selection.length > 0\n ? new Set<string | number>(selection)\n : null\n return (option, data, ctx) => {\n // Structural phase: Provider seeds rawOptions with this branch. No data\n // is read; we just emit the theme-aware base (optionally with override).\n if (option == null) {\n const structural = barOptions({ theme, formatter, labelFormatter })\n return optionsOverride\n ? (mergeOptions(\n structural as unknown as Record<string, unknown>,\n optionsOverride as Partial<Record<string, unknown>>,\n ) as EChartsOption)\n : structural\n }\n\n const seriesArr = Array.isArray(data) ? (data as BarWidgetData) : []\n if (seriesArr.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n const hasLegend = seriesArr.length > 1\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n const baseGrid =\n typeof option.grid === 'object' && !Array.isArray(option.grid)\n ? option.grid\n : {}\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n\n // Reactive (live store) formatters from ctx — distinct from the\n // closure-time `formatter` / `labelFormatter` captured for the\n // structural-build branch above. RelativeData can install a percent\n // formatter on the store after the factory was constructed; the merge\n // phase reads `ctx` to pick that up.\n const liveFormatter = ctx?.formatter\n const liveLabelFormatter = ctx?.labelFormatter\n\n const { niceMinVal, niceMaxVal } = computeNiceBounds(seriesArr)\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`, push the\n // slider above the legend (if any) and reserve room in the grid below.\n const dataZoomLayout = positionDataZoomForLegend(option.dataZoom, hasLegend)\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = dataZoomLayout\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n\n // When a selection is active, dim non-selected bars by routing the\n // resolved palette color through `modifyAlpha`. Per-row `itemStyle` on\n // dataset object-rows is silently ignored when `series.encode` is in\n // play — the callback approach is the standard ECharts pattern for\n // per-data styling derived from a dataset.\n //\n // We *always* emit `itemStyle.color` (a passthrough when nothing is\n // selected), not conditionally — dropping the key between renders\n // would let ECharts' default merge keep the previous callback alive\n // and bars would stay dimmed forever after an external clear. Always\n // emitting lets normal merge swap the callback in place, no\n // `replaceMerge` and no entry-animation flash on selection on/off.\n const dimItemStyle = {\n color: (params: CallbackDataParams) => {\n const base = params.color as string\n if (!selectionSet) return base\n const datum = params.value as { name?: string | number } | undefined\n const name = datum?.name ?? params.name\n return name != null && selectionSet.has(name)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n },\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n series: seriesArr.map((_, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n // Per-series `color` override: ECharts sets `params.color` from\n // `series[i].color` when resolving styles, so the dim callback\n // above keeps working — it just dims the user's colour rather\n // than the palette default.\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n ...(typeof template === 'object' ? template : {}),\n type: 'bar' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 'name', y: 'value' },\n barMaxWidth: 100,\n emphasis: { focus: 'series' },\n itemStyle: dimItemStyle,\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: {\n ...baseGrid,\n bottom: gridBottom,\n },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout } : {}),\n yAxis: {\n ...baseYAxis,\n min: niceMinVal,\n max: niceMaxVal,\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n formatter: (value: number) => {\n if (value !== niceMaxVal && value !== niceMinVal) return ''\n if (value === 0) return ''\n return liveFormatter ? liveFormatter(value) : String(value)\n },\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n formatter: buildBarTooltipFormatter(liveFormatter, liveLabelFormatter),\n },\n } as EChartsOption\n }\n}\n\nfunction buildBarTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: string | number) => string | number) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const row = item.value as { name?: string | number; value?: number }\n const raw = row?.value\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n const name = labelFormatter\n ? String(labelFormatter(item.name ?? ''))\n : (item.name ?? '')\n return { name: String(name), seriesName, marker, value: formattedValue }\n })\n}\n\nfunction computeNiceBounds(seriesArr: BarWidgetData): {\n niceMinVal: number\n niceMaxVal: number\n} {\n let min = 0\n let max = -Infinity\n for (const series of seriesArr) {\n for (const d of series) {\n if (typeof d?.value !== 'number' || !Number.isFinite(d.value)) continue\n if (d.value < min) min = d.value\n if (d.value > max) max = d.value\n }\n }\n const niceMinVal = min < 0 ? niceNum(min) : 0\n const niceMaxVal = max <= 0 ? 1 : niceNum(max)\n return { niceMinVal, niceMaxVal }\n}\n","import { Box, Skeleton, type SxProps, type Theme } from '@mui/material'\n\nconst styles = {\n container: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n flexDirection: 'column',\n gap: ({ spacing }) => spacing(1),\n height: ({ spacing }) => spacing(38),\n },\n grid: {\n display: 'flex',\n justifyContent: 'space-between',\n flex: '1 1 auto',\n alignItems: 'flex-end',\n width: '100%',\n },\n bar: {\n flex: 1,\n maxWidth: ({ spacing }) => spacing(12),\n '& + &': {\n marginLeft: ({ spacing }) => spacing(1),\n },\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n height: ({ spacing }) => spacing(5),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\nconst BAR_HEIGHTS = ['20%', '40%', '60%', '20%', '80%'] as const\n\n/**\n * Loading state for the Bar widget. Mirrors a bar chart's silhouette — five\n * vertical bars at staggered heights anchored to the bottom, plus a legend\n * stub — so the skeleton reads as \"a bar chart\" rather than a generic list.\n */\nexport function BarSkeleton() {\n return (\n <Box sx={styles.container}>\n <Box sx={styles.grid}>\n {BAR_HEIGHTS.map((height, i) => (\n <Skeleton\n key={`bar-${i}`}\n sx={styles.bar}\n variant='rectangular'\n height={height}\n />\n ))}\n </Box>\n <Box sx={styles.legend}>\n {[0, 1].map((i) => (\n <Box key={`legend-${i}`} sx={styles.legendItem}>\n <Skeleton variant='circular' width={8} height={8} />\n <Skeleton width={48} height={8} />\n </Box>\n ))}\n </Box>\n </Box>\n )\n}\n","import {\n CSVIcon,\n buildPngDownloadItem,\n downloadToCSV,\n type DownloadItem,\n} from '../actions/download'\nimport type { BarWidgetData } from './types'\n\nexport interface BarDownloadConfigArgs {\n filename: string\n getData: () => BarWidgetData\n /**\n * Optional getter for the widget's capture element (registered by\n * `Widget.State` on its success path). When provided, a PNG item is\n * prepended to the returned list. Wire it to\n * `() => getCaptureEl(id)`.\n */\n getCaptureEl?: () => HTMLElement | null\n /** PNG `pixelRatio` (default 2). */\n pngPixelRatio?: number\n /** PNG `backgroundColor` (default transparent). */\n pngBackgroundColor?: string | null\n}\n\n/**\n * Builds download items for the Bar widget. Always includes a CSV item\n * with one `name,value` block per series, separated by an empty row when\n * there are multiple. When `getCaptureEl` is supplied, also prepends a PNG\n * item that rasterises the captured element via `html2canvas`.\n */\nexport function createBarDownloadConfig(\n args: BarDownloadConfigArgs,\n): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push({\n id: 'csv',\n label: 'CSV',\n icon: <CSVIcon fontSize='small' />,\n resolve: () => {\n const data = args.getData()\n const rows: unknown[][] = []\n for (const [i, series] of data.entries()) {\n if (i > 0) rows.push([])\n rows.push(['name', 'value'])\n for (const d of series) rows.push([d.name, d.value])\n }\n const handle = downloadToCSV(rows)\n return Promise.resolve({\n url: handle.url,\n filename: `${args.filename}.csv`,\n revoke: handle.revoke,\n })\n },\n })\n return items\n}\n"],"names":["barOptions","theme","formatter","labelFormatter","niceMin","niceMax","grid","left","parseInt","spacing","top","right","buildGridConfig","containLabel","tooltip","trigger","backgroundColor","palette","grey","borderWidth","padding","textStyle","color","common","white","fontSize","fontFamily","typography","caption","axisPointer","type","position","createTooltipPositioner","buildBarTooltipFormatter","legend","buildLegendConfig","hasLegend","lineStyle","secondary","main","Object","values","qualitative","bold","xAxis","axisLine","show","axisTick","axisLabel","margin","hideOverlap","v","String","yAxis","min","extent","niceNum","max","splitLine","black","divider","overlineDelicate","showMaxLabel","showMinLabel","verticalAlign","inside","value","createBarOptionFactory","options","optionsOverride","series","selection","selectionSet","length","Set","option","data","ctx","structural","mergeOptions","seriesArr","Array","isArray","dataset","baseLegend","baseGrid","baseTooltip","baseYAxis","seriesTemplates","broadcastTemplate","liveFormatter","liveLabelFormatter","niceMinVal","niceMaxVal","computeNiceBounds","dataZoomLayout","positionDataZoomForLegend","dataZoom","fallbackBottom","bottom","baseBottom","gridBottom","ZOOM_LAYOUT","sliderHeight","sliderGap","dimItemStyle","params","base","name","has","echarts","modifyAlpha","map","s","source","_","i","template","overrideColor","resolveThemeColor","datasetIndex","encode","x","y","barMaxWidth","emphasis","focus","itemStyle","createTooltipFormatter","item","raw","formattedValue","marker","seriesName","d","Number","isFinite","styles","container","display","alignItems","justifyContent","flexDirection","gap","height","flex","width","bar","maxWidth","marginLeft","legendItem","BAR_HEIGHTS","BarSkeleton","$","_c","t0","Symbol","for","jsx","Box","_temp","t1","_temp2","i_0","jsxs","Skeleton","createBarDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","pngBackgroundColor","id","label","icon","CSVIcon","resolve","getData","rows","entries","handle","downloadToCSV","Promise","url","revoke"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCO,SAASA,EAAW;AAAA,EACzBC,OAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,gBAAAA;AACe,GAAqB;AAGpC,MAAIC,IAAU,GACVC,IAAU;AAEd,SAAO;AAAA,IACLC,MAAM;AAAA,MACJC,MAAMC,SAASP,EAAMQ,QAAQ,CAAC,CAAC;AAAA,MAC/BC,KAAKF,SAASP,EAAMQ,QAAQ,CAAC,CAAC;AAAA,MAC9BE,OAAOH,SAASP,EAAMQ,QAAQ,CAAC,CAAC;AAAA;AAAA,MAEhC,GAAGG,EAAgB,IAAOX,CAAK;AAAA,MAC/BY,cAAc;AAAA,IAAA;AAAA,IAEhBC,SAAS;AAAA,MACPC,SAAS;AAAA,MACTC,iBAAiBf,EAAMgB,QAAQC,KAAK,GAAG;AAAA,MACvCC,aAAa;AAAA,MACbC,SAAS,CAACZ,SAASP,EAAMQ,QAAQ,CAAC,CAAC,GAAGD,SAASP,EAAMQ,QAAQ,CAAC,CAAC,CAAC;AAAA,MAChEY,WAAW;AAAA,QACTC,OAAOrB,EAAMgB,QAAQM,OAAOC;AAAAA,QAC5BC,UAAU;AAAA,QACVC,YAAYzB,EAAM0B,WAAWC,QAAQF;AAAAA,MAAAA;AAAAA,MAEvCG,aAAa;AAAA,QAAEC,MAAM;AAAA,MAAA;AAAA,MACrBC,UAAUC,EAAwB/B,CAAK;AAAA,MACvCC,WAAW+B,EAAyB/B,GAAWC,CAAc;AAAA,IAAA;AAAA;AAAA;AAAA,IAI/D+B,QAAQ;AAAA,MACN,GAAGC,EAAkB;AAAA,QAAEC,WAAW;AAAA,QAAOj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CAAC,QAAQ,OAAO,CAAC;AAC3B,mBAAWpC,KAAKhE,EAAQgH,CAAAA,EAAKZ,KAAK,CAACpC,EAAE1B,MAAM0B,EAAEpE,KAAK,CAAC;AAAA,MACrD;AACA,YAAMsH,IAASC,EAAcH,CAAI;AACjC,aAAOI,QAAQN,QAAQ;AAAA,QACrBO,KAAKH,EAAOG;AAAAA,QACZf,UAAU,GAAGL,EAAKK,QAAQ;AAAA,QAC1BgB,QAAQJ,EAAOI;AAAAA,MAAAA,CAChB;AAAA,IACH;AAAA,EAAA,CACD,GACMpB;AACT;"}
|
|
1
|
+
{"version":3,"file":"bar.js","sources":["../../src/widgets-v2/bar/options.ts","../../src/widgets-v2/bar/skeleton.tsx","../../src/widgets-v2/bar/download.tsx"],"sourcesContent":["import type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildGridConfig,\n buildLegendConfig,\n createTooltipFormatter,\n createTooltipPositioner,\n niceNum,\n} from '../../widgets/utils/chart-config'\nimport { ZOOM_LAYOUT } from '../actions/zoom-toggle'\nimport type { OptionFactory } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport { positionDataZoomForLegend } from '../utils/data-zoom-layout'\nimport type {\n BarEChartsOption,\n BarOptionFactoryInput,\n BarOptionsInput,\n BarWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a bar widget — axes, grid,\n * tooltip styling, themed legend. Intentionally data-agnostic: no series,\n * no dataset, no `legend.show` (those depend on data and are added by the\n * option factory's merge phase). This separation is what lets data-side\n * pipeline transforms (Searcher, RelativeData) drive the rendered chart —\n * the merge happens at render time inside the Echart bridge.\n *\n * Styling matches the v1 `barConfig` look-and-feel: minimal axes (only\n * min/max y-labels rendered inside the plot via `niceNum`), themed tooltip,\n * scroll legend, and CARTO color palette. The y-axis min/max + label\n * formatter and the tooltip formatter are wired here for the no-data case;\n * {@link createBarOptionFactory} re-derives them at fusion time so reactive\n * formatter changes (RelativeData) and stack templates (StackToggle) flow\n * through to the chart.\n */\nexport function barOptions({\n theme,\n formatter,\n labelFormatter,\n}: BarOptionsInput): BarEChartsOption {\n // Closure shared between yAxis min/max callbacks and the label formatter,\n // so only the rounded extents are labelled (matches v1).\n let niceMin = 0\n let niceMax = 1\n\n return {\n grid: {\n left: parseInt(theme.spacing(1)),\n top: parseInt(theme.spacing(3)),\n right: parseInt(theme.spacing(1)),\n // Default: no legend. Merger bumps this when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n trigger: 'axis',\n backgroundColor: theme.palette.grey[900],\n borderWidth: 0,\n padding: [parseInt(theme.spacing(1)), parseInt(theme.spacing(1))],\n textStyle: {\n color: theme.palette.common.white,\n fontSize: 11,\n fontFamily: theme.typography.caption.fontFamily,\n },\n axisPointer: { type: 'line' },\n position: createTooltipPositioner(theme),\n formatter: buildBarTooltipFormatter(formatter, labelFormatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count.\n legend: {\n ...buildLegendConfig({ hasLegend: false, labelFormatter }),\n },\n axisPointer: { lineStyle: { color: theme.palette.grey[400] } },\n color: [\n theme.palette.secondary.main,\n ...Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n ],\n xAxis: {\n type: 'category',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n margin: 0,\n hideOverlap: true,\n ...(labelFormatter && {\n formatter: (v: string | number) => String(labelFormatter(v)),\n }),\n },\n },\n yAxis: {\n type: 'value',\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLine: { show: false },\n axisTick: { show: false },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n axisLabel: {\n fontSize: theme.typography.overlineDelicate?.fontSize,\n fontFamily: theme.typography.overlineDelicate?.fontFamily,\n margin: parseInt(theme.spacing(1)),\n show: true,\n showMaxLabel: true,\n showMinLabel: true,\n verticalAlign: 'bottom',\n inside: true,\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n } as BarEChartsOption\n}\n\n/**\n * Returns the bar widget's {@link OptionFactory} — a single closure that\n * handles BOTH option-construction phases:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link barOptions}, optionally merging the\n * consumer-supplied `optionsOverride` on top. Called once by Provider\n * to seed `rawOptions` in the store; configTransforms (StackToggle /\n * ZoomToggle / BrushToggle) then mutate it via the pipeline middleware.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`BarWidgetData`) into the option via the dataset API: one dataset\n * per series, each series referencing its dataset by index, encoded\n * by `name` (x) and `value` (y). Spreads any series-template fields\n * already on the incoming option (e.g. `{ stack: 'total' }` from\n * `addStack`) into every emitted series so configTransforms compose\n * end-to-end. Reactive `ctx.formatter` / `ctx.labelFormatter` drive\n * the y-axis min/max-only label and the tooltip formatter at fusion\n * time so RelativeData's percent formatter flows through without a\n * structural rebuild.\n *\n * Stable identity when the inputs don't change (consumers should wrap the\n * call in `useMemo` keyed on the same inputs).\n */\nexport function createBarOptionFactory(\n options: BarOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, labelFormatter, optionsOverride } = options\n const series = options.series\n const selection = options.selection\n const selectionSet =\n selection && selection.length > 0\n ? new Set<string | number>(selection)\n : null\n return (option, data, ctx) => {\n // Structural phase: Provider seeds rawOptions with this branch. No data\n // is read; we just emit the theme-aware base (optionally with override).\n if (option == null) {\n const structural = barOptions({ theme, formatter, labelFormatter })\n return optionsOverride\n ? (mergeOptions(\n structural as unknown as Record<string, unknown>,\n optionsOverride as Partial<Record<string, unknown>>,\n ) as EChartsOption)\n : structural\n }\n\n const seriesArr = Array.isArray(data) ? (data as BarWidgetData) : []\n if (seriesArr.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n const hasLegend = seriesArr.length > 1\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n const baseGrid =\n typeof option.grid === 'object' && !Array.isArray(option.grid)\n ? option.grid\n : {}\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n\n // Reactive (live store) formatters from ctx — distinct from the\n // closure-time `formatter` / `labelFormatter` captured for the\n // structural-build branch above. RelativeData can install a percent\n // formatter on the store after the factory was constructed; the merge\n // phase reads `ctx` to pick that up.\n const liveFormatter = ctx?.formatter\n const liveLabelFormatter = ctx?.labelFormatter\n\n // Closure shared between the yAxis min/max callbacks and the label\n // formatter, so only the rounded extents are labelled (matches v1).\n // Delegating the extent to ECharts (rather than precomputing scalars\n // from the raw data) is what keeps stacked bars inside the plot: when\n // StackToggle marks the series, ECharts feeds the *post-stack* extent\n // to these callbacks, so `niceNum` rounds the stacked total instead of\n // a single series.\n let niceMin = 0\n let niceMax = 1\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`, push the\n // slider above the legend (if any) and reserve room in the grid below.\n const dataZoomLayout = positionDataZoomForLegend(option.dataZoom, hasLegend)\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = dataZoomLayout\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n\n // When a selection is active, dim non-selected bars by routing the\n // resolved palette color through `modifyAlpha`. Per-row `itemStyle` on\n // dataset object-rows is silently ignored when `series.encode` is in\n // play — the callback approach is the standard ECharts pattern for\n // per-data styling derived from a dataset.\n //\n // We *always* emit `itemStyle.color` (a passthrough when nothing is\n // selected), not conditionally — dropping the key between renders\n // would let ECharts' default merge keep the previous callback alive\n // and bars would stay dimmed forever after an external clear. Always\n // emitting lets normal merge swap the callback in place, no\n // `replaceMerge` and no entry-animation flash on selection on/off.\n const dimItemStyle = {\n color: (params: CallbackDataParams) => {\n const base = params.color as string\n if (!selectionSet) return base\n const datum = params.value as { name?: string | number } | undefined\n const name = datum?.name ?? params.name\n return name != null && selectionSet.has(name)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n },\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n series: seriesArr.map((_, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n // Per-series `color` override: ECharts sets `params.color` from\n // `series[i].color` when resolving styles, so the dim callback\n // above keeps working — it just dims the user's colour rather\n // than the palette default.\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n ...(typeof template === 'object' ? template : {}),\n type: 'bar' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 'name', y: 'value' },\n barMaxWidth: 100,\n emphasis: { focus: 'series' },\n itemStyle: dimItemStyle,\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: {\n ...baseGrid,\n bottom: gridBottom,\n },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout } : {}),\n yAxis: {\n ...baseYAxis,\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return liveFormatter ? liveFormatter(value) : String(value)\n },\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n formatter: buildBarTooltipFormatter(liveFormatter, liveLabelFormatter),\n },\n } as EChartsOption\n }\n}\n\nfunction buildBarTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: string | number) => string | number) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const row = item.value as { name?: string | number; value?: number }\n const raw = row?.value\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n const name = labelFormatter\n ? String(labelFormatter(item.name ?? ''))\n : (item.name ?? '')\n return { name: String(name), seriesName, marker, value: formattedValue }\n })\n}\n","import { Box, Skeleton, type SxProps, type Theme } from '@mui/material'\n\nconst styles = {\n container: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n flexDirection: 'column',\n gap: ({ spacing }) => spacing(1),\n height: ({ spacing }) => spacing(38),\n },\n grid: {\n display: 'flex',\n justifyContent: 'space-between',\n flex: '1 1 auto',\n alignItems: 'flex-end',\n width: '100%',\n },\n bar: {\n flex: 1,\n maxWidth: ({ spacing }) => spacing(12),\n '& + &': {\n marginLeft: ({ spacing }) => spacing(1),\n },\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n height: ({ spacing }) => spacing(5),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\nconst BAR_HEIGHTS = ['20%', '40%', '60%', '20%', '80%'] as const\n\n/**\n * Loading state for the Bar widget. Mirrors a bar chart's silhouette — five\n * vertical bars at staggered heights anchored to the bottom, plus a legend\n * stub — so the skeleton reads as \"a bar chart\" rather than a generic list.\n */\nexport function BarSkeleton() {\n return (\n <Box sx={styles.container}>\n <Box sx={styles.grid}>\n {BAR_HEIGHTS.map((height, i) => (\n <Skeleton\n key={`bar-${i}`}\n sx={styles.bar}\n variant='rectangular'\n height={height}\n />\n ))}\n </Box>\n <Box sx={styles.legend}>\n {[0, 1].map((i) => (\n <Box key={`legend-${i}`} sx={styles.legendItem}>\n <Skeleton variant='circular' width={8} height={8} />\n <Skeleton width={48} height={8} />\n </Box>\n ))}\n </Box>\n </Box>\n )\n}\n","import {\n CSVIcon,\n buildPngDownloadItem,\n downloadToCSV,\n type DownloadItem,\n} from '../actions/download'\nimport type { BarWidgetData } from './types'\n\nexport interface BarDownloadConfigArgs {\n filename: string\n getData: () => BarWidgetData\n /**\n * Optional getter for the widget's capture element (registered by\n * `Widget.State` on its success path). When provided, a PNG item is\n * prepended to the returned list. Wire it to\n * `() => getCaptureEl(id)`.\n */\n getCaptureEl?: () => HTMLElement | null\n /** PNG `pixelRatio` (default 2). */\n pngPixelRatio?: number\n /** PNG `backgroundColor` (default transparent). */\n pngBackgroundColor?: string | null\n}\n\n/**\n * Builds download items for the Bar widget. Always includes a CSV item\n * with one `name,value` block per series, separated by an empty row when\n * there are multiple. When `getCaptureEl` is supplied, also prepends a PNG\n * item that rasterises the captured element via `html2canvas`.\n */\nexport function createBarDownloadConfig(\n args: BarDownloadConfigArgs,\n): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push({\n id: 'csv',\n label: 'CSV',\n icon: <CSVIcon fontSize='small' />,\n resolve: () => {\n const data = args.getData()\n const rows: unknown[][] = []\n for (const [i, series] of data.entries()) {\n if (i > 0) rows.push([])\n rows.push(['name', 'value'])\n for (const d of series) rows.push([d.name, d.value])\n }\n const handle = downloadToCSV(rows)\n return Promise.resolve({\n url: handle.url,\n filename: `${args.filename}.csv`,\n revoke: handle.revoke,\n })\n },\n })\n return items\n}\n"],"names":["barOptions","theme","formatter","labelFormatter","niceMin","niceMax","grid","left","parseInt","spacing","top","right","buildGridConfig","containLabel","tooltip","trigger","backgroundColor","palette","grey","borderWidth","padding","textStyle","color","common","white","fontSize","fontFamily","typography","caption","axisPointer","type","position","createTooltipPositioner","buildBarTooltipFormatter","legend","buildLegendConfig","hasLegend","lineStyle","secondary","main","Object","values","qualitative","bold","xAxis","axisLine","show","axisTick","axisLabel","margin","hideOverlap","v","String","yAxis","min","extent","niceNum","max","splitLine","black","divider","overlineDelicate","showMaxLabel","showMinLabel","verticalAlign","inside","value","createBarOptionFactory","options","optionsOverride","series","selection","selectionSet","length","Set","option","data","ctx","structural","mergeOptions","seriesArr","Array","isArray","dataset","baseLegend","baseGrid","baseTooltip","baseYAxis","seriesTemplates","broadcastTemplate","liveFormatter","liveLabelFormatter","dataZoomLayout","positionDataZoomForLegend","dataZoom","fallbackBottom","bottom","baseBottom","gridBottom","ZOOM_LAYOUT","sliderHeight","sliderGap","dimItemStyle","params","base","name","has","echarts","modifyAlpha","map","s","source","_","i","template","overrideColor","resolveThemeColor","datasetIndex","encode","x","y","barMaxWidth","emphasis","focus","itemStyle","createTooltipFormatter","item","raw","formattedValue","marker","seriesName","styles","container","display","alignItems","justifyContent","flexDirection","gap","height","flex","width","bar","maxWidth","marginLeft","legendItem","BAR_HEIGHTS","BarSkeleton","$","_c","t0","Symbol","for","jsx","Box","_temp","t1","_temp2","i_0","jsxs","Skeleton","createBarDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","pngBackgroundColor","id","label","icon","CSVIcon","resolve","getData","rows","entries","d","handle","downloadToCSV","Promise","url","revoke"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCO,SAASA,EAAW;AAAA,EACzBC,OAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,gBAAAA;AACe,GAAqB;AAG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