@carto/ps-react-ui 5.5.0 → 5.6.0
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/actions-5-dVhroJ.js +1289 -0
- package/dist/actions-5-dVhroJ.js.map +1 -0
- package/dist/{category-C6myUFUJ.js → category-DBUD2ZBo.js} +267 -250
- package/dist/category-DBUD2ZBo.js.map +1 -0
- package/dist/scale-0elCv3tk.js +29 -0
- package/dist/scale-0elCv3tk.js.map +1 -0
- package/dist/types/widgets-v2/actions/index.d.ts +1 -1
- package/dist/types/widgets-v2/actions/relative-data/index.d.ts +1 -0
- package/dist/types/widgets-v2/actions/relative-data/labels.d.ts +3 -0
- package/dist/types/widgets-v2/actions/relative-data/relative-data.d.ts +16 -2
- package/dist/types/widgets-v2/actions/relative-data/scale.d.ts +26 -0
- package/dist/types/widgets-v2/actions/relative-data/style.d.ts +12 -0
- package/dist/types/widgets-v2/category/category.d.ts +2 -1
- package/dist/types/widgets-v2/index.d.ts +1 -1
- package/dist/widgets-v2/actions.js +1 -1
- package/dist/widgets-v2/bar.js +84 -83
- package/dist/widgets-v2/bar.js.map +1 -1
- package/dist/widgets-v2/category.js +1 -1
- package/dist/widgets-v2/histogram.js +108 -107
- package/dist/widgets-v2/histogram.js.map +1 -1
- package/dist/widgets-v2/scatterplot.js +120 -119
- package/dist/widgets-v2/scatterplot.js.map +1 -1
- package/dist/widgets-v2/timeseries.js +90 -89
- package/dist/widgets-v2/timeseries.js.map +1 -1
- package/dist/widgets-v2.js +2 -2
- package/dist/widgets-v2.js.map +1 -1
- package/package.json +3 -3
- package/src/widgets-v2/actions/index.ts +1 -0
- package/src/widgets-v2/actions/relative-data/index.ts +1 -0
- package/src/widgets-v2/actions/relative-data/labels.ts +6 -0
- package/src/widgets-v2/actions/relative-data/relative-data.test.tsx +78 -1
- package/src/widgets-v2/actions/relative-data/relative-data.tsx +137 -20
- package/src/widgets-v2/actions/relative-data/scale.ts +48 -0
- package/src/widgets-v2/actions/relative-data/style.ts +10 -0
- package/src/widgets-v2/bar/options.test.ts +16 -0
- package/src/widgets-v2/bar/options.ts +6 -2
- package/src/widgets-v2/category/category.relative-data.test.tsx +51 -63
- package/src/widgets-v2/category/category.tsx +25 -11
- package/src/widgets-v2/histogram/options.ts +6 -2
- package/src/widgets-v2/index.ts +1 -0
- package/src/widgets-v2/scatterplot/options.test.ts +12 -0
- package/src/widgets-v2/scatterplot/options.ts +18 -4
- package/src/widgets-v2/timeseries/options.ts +6 -2
- package/dist/actions-CwjqEm8Y.js +0 -1177
- package/dist/actions-CwjqEm8Y.js.map +0 -1
- package/dist/category-C6myUFUJ.js.map +0 -1
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { r as e } from "../zoom-toggle-IsF8BnAp.js";
|
|
2
|
-
import { n as t
|
|
3
|
-
import { n
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
2
|
+
import { n as t } from "../scale-0elCv3tk.js";
|
|
3
|
+
import { n, t as r } from "../download-DGgFOaXj.js";
|
|
4
|
+
import { n as i, r as a, t as o } from "../utils-Dr6gf3vD.js";
|
|
5
|
+
import { a as s, d as c, f as l, i as u, s as d, u as f } from "../chart-config-B_fdIcD3.js";
|
|
6
|
+
import { t as p } from "../item-color-ZYxH3NM5.js";
|
|
7
|
+
import { c as m } from "react/compiler-runtime";
|
|
8
|
+
import { Box as h, Skeleton as g } from "@mui/material";
|
|
9
|
+
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
10
|
+
import * as y from "echarts";
|
|
10
11
|
//#region src/widgets-v2/timeseries/options.ts
|
|
11
|
-
function
|
|
12
|
+
function b({ theme: e, formatter: t, labelFormatter: n }) {
|
|
12
13
|
let r = 0, i = 1;
|
|
13
14
|
return {
|
|
14
15
|
grid: {
|
|
15
16
|
left: parseInt(e.spacing(1)),
|
|
16
17
|
top: parseInt(e.spacing(3)),
|
|
17
18
|
right: parseInt(e.spacing(1)),
|
|
18
|
-
...
|
|
19
|
+
...s(!1, e),
|
|
19
20
|
containLabel: !0
|
|
20
21
|
},
|
|
21
22
|
tooltip: {
|
|
@@ -29,10 +30,10 @@ function y({ theme: e, formatter: t, labelFormatter: n }) {
|
|
|
29
30
|
fontFamily: e.typography.caption.fontFamily
|
|
30
31
|
},
|
|
31
32
|
axisPointer: { type: "line" },
|
|
32
|
-
position:
|
|
33
|
-
formatter:
|
|
33
|
+
position: c(e),
|
|
34
|
+
formatter: S(t, n)
|
|
34
35
|
},
|
|
35
|
-
legend: { ...
|
|
36
|
+
legend: { ...d({ hasLegend: !1 }) },
|
|
36
37
|
axisPointer: { lineStyle: { color: e.palette.grey[400] } },
|
|
37
38
|
color: [e.palette.secondary.main, ...Object.values(e.palette.qualitative?.bold ?? {})],
|
|
38
39
|
xAxis: {
|
|
@@ -40,7 +41,7 @@ function y({ theme: e, formatter: t, labelFormatter: n }) {
|
|
|
40
41
|
axisLine: { show: !1 },
|
|
41
42
|
axisTick: { show: !1 },
|
|
42
43
|
axisLabel: {
|
|
43
|
-
...
|
|
44
|
+
...u(e),
|
|
44
45
|
padding: [
|
|
45
46
|
parseInt(e.spacing(.5)),
|
|
46
47
|
0,
|
|
@@ -54,8 +55,8 @@ function y({ theme: e, formatter: t, labelFormatter: n }) {
|
|
|
54
55
|
},
|
|
55
56
|
yAxis: {
|
|
56
57
|
type: "value",
|
|
57
|
-
min: (e) => (r = e.min < 0 ?
|
|
58
|
-
max: (e) => (i = e.max <= 0 ? 1 :
|
|
58
|
+
min: (e) => (r = e.min < 0 ? l(e.min) : 0, r),
|
|
59
|
+
max: (e) => (i = e.max <= 0 ? 1 : l(e.max), i),
|
|
59
60
|
axisLine: { show: !1 },
|
|
60
61
|
axisTick: { show: !1 },
|
|
61
62
|
splitLine: {
|
|
@@ -63,7 +64,7 @@ function y({ theme: e, formatter: t, labelFormatter: n }) {
|
|
|
63
64
|
lineStyle: { color: e.palette.black?.[4] ?? e.palette.divider }
|
|
64
65
|
},
|
|
65
66
|
axisLabel: {
|
|
66
|
-
...
|
|
67
|
+
...u(e),
|
|
67
68
|
margin: parseInt(e.spacing(1)),
|
|
68
69
|
show: !0,
|
|
69
70
|
showMaxLabel: !0,
|
|
@@ -75,54 +76,54 @@ function y({ theme: e, formatter: t, labelFormatter: n }) {
|
|
|
75
76
|
}
|
|
76
77
|
};
|
|
77
78
|
}
|
|
78
|
-
function
|
|
79
|
-
let { theme:
|
|
80
|
-
return (
|
|
81
|
-
if (
|
|
82
|
-
let e =
|
|
83
|
-
theme:
|
|
84
|
-
formatter:
|
|
85
|
-
labelFormatter:
|
|
79
|
+
function x(n) {
|
|
80
|
+
let { theme: r, formatter: s, labelFormatter: c, optionsOverride: u } = n, d = n.series, f = n.smooth ?? !0, m = n.area ?? !1, h = n.selection, g = h && h.length > 0 ? new Set(h) : null, _ = (e) => e instanceof Date ? e.getTime() : e;
|
|
81
|
+
return (n, h, v) => {
|
|
82
|
+
if (n == null) {
|
|
83
|
+
let e = b({
|
|
84
|
+
theme: r,
|
|
85
|
+
formatter: s,
|
|
86
|
+
labelFormatter: c
|
|
86
87
|
});
|
|
87
|
-
return
|
|
88
|
+
return u ? a(e, u) : e;
|
|
88
89
|
}
|
|
89
|
-
let
|
|
90
|
-
if (
|
|
91
|
-
...
|
|
90
|
+
let x = Array.isArray(h) ? h : [];
|
|
91
|
+
if (x.length === 0) return {
|
|
92
|
+
...n,
|
|
92
93
|
dataset: [],
|
|
93
94
|
series: []
|
|
94
95
|
};
|
|
95
|
-
let
|
|
96
|
-
let
|
|
97
|
-
theme:
|
|
96
|
+
let C = x.length > 1, w = Array.isArray(n.series) ? n.series : [], T = w[0] ?? {}, E = typeof n.yAxis == "object" && !Array.isArray(n.yAxis) ? n.yAxis : {}, D = t(E), O = typeof n.grid == "object" && !Array.isArray(n.grid) ? n.grid : {}, k = typeof n.tooltip == "object" && !Array.isArray(n.tooltip) ? n.tooltip : {}, A = typeof n.legend == "object" && !Array.isArray(n.legend) ? n.legend : {}, j = v?.formatter, M = 0, N = 1, P = i(n.dataZoom, C), F = typeof O.bottom == "number" ? O.bottom : 24, I = C ? 56 : F, L = P ? I + e.sliderHeight + e.sliderGap : I, R = (e, t) => {
|
|
97
|
+
let n = p({
|
|
98
|
+
theme: r,
|
|
98
99
|
datums: e,
|
|
99
100
|
template: t,
|
|
100
101
|
fallback: (e) => e.color
|
|
101
102
|
});
|
|
102
103
|
return { color: (e) => {
|
|
103
|
-
let t = e.value?.name,
|
|
104
|
-
return !
|
|
104
|
+
let t = e.value?.name, r = n(e);
|
|
105
|
+
return !g || t == null || g.has(_(t)) ? r : y.color.modifyAlpha(r, .15);
|
|
105
106
|
} };
|
|
106
|
-
},
|
|
107
|
+
}, z = x.some((e) => e.some((e) => typeof e?.color == "string" && e.color !== ""));
|
|
107
108
|
return {
|
|
108
|
-
...
|
|
109
|
-
dataset:
|
|
110
|
-
series:
|
|
111
|
-
let
|
|
109
|
+
...n,
|
|
110
|
+
dataset: x.map((e) => ({ source: e })),
|
|
111
|
+
series: x.map((e, t) => {
|
|
112
|
+
let n = w[t] ?? T, i = o(r, d?.[t]?.color);
|
|
112
113
|
return {
|
|
113
|
-
...typeof
|
|
114
|
+
...typeof n == "object" ? n : {},
|
|
114
115
|
type: "line",
|
|
115
116
|
datasetIndex: t,
|
|
116
|
-
name:
|
|
117
|
+
name: d?.[t]?.name ?? `Series ${t + 1}`,
|
|
117
118
|
encode: {
|
|
118
119
|
x: "name",
|
|
119
120
|
y: "value"
|
|
120
121
|
},
|
|
121
|
-
smooth:
|
|
122
|
-
showSymbol:
|
|
123
|
-
...
|
|
122
|
+
smooth: f,
|
|
123
|
+
showSymbol: g != null || z,
|
|
124
|
+
...m ? { areaStyle: {} } : {},
|
|
124
125
|
emphasis: { focus: "series" },
|
|
125
|
-
itemStyle:
|
|
126
|
+
itemStyle: R(e, n),
|
|
126
127
|
...i ? {
|
|
127
128
|
color: i,
|
|
128
129
|
lineStyle: { color: i }
|
|
@@ -130,32 +131,32 @@ function b(t) {
|
|
|
130
131
|
};
|
|
131
132
|
}),
|
|
132
133
|
legend: {
|
|
133
|
-
...
|
|
134
|
-
show:
|
|
134
|
+
...A,
|
|
135
|
+
show: C
|
|
135
136
|
},
|
|
136
137
|
grid: {
|
|
137
|
-
...
|
|
138
|
-
bottom:
|
|
138
|
+
...O,
|
|
139
|
+
bottom: L
|
|
139
140
|
},
|
|
140
|
-
...
|
|
141
|
+
...P ? { dataZoom: P } : {},
|
|
141
142
|
yAxis: {
|
|
142
|
-
...
|
|
143
|
-
min: (e) => (
|
|
144
|
-
max: (e) => (
|
|
143
|
+
...E,
|
|
144
|
+
min: (e) => (M = e.min < 0 ? D.min ?? l(e.min) : 0, M),
|
|
145
|
+
max: (e) => (N = e.max <= 0 ? 1 : D.max ?? l(e.max), N),
|
|
145
146
|
axisLabel: {
|
|
146
|
-
...
|
|
147
|
-
formatter: (e) => e !==
|
|
147
|
+
...E.axisLabel ?? {},
|
|
148
|
+
formatter: (e) => e !== N && e !== M || e === 0 ? "" : j ? j(e) : String(e)
|
|
148
149
|
}
|
|
149
150
|
},
|
|
150
151
|
tooltip: {
|
|
151
|
-
...
|
|
152
|
-
formatter:
|
|
152
|
+
...k,
|
|
153
|
+
formatter: S(j, c)
|
|
153
154
|
}
|
|
154
155
|
};
|
|
155
156
|
};
|
|
156
157
|
}
|
|
157
|
-
function
|
|
158
|
-
return
|
|
158
|
+
function S(e, t) {
|
|
159
|
+
return f((n) => {
|
|
159
160
|
let r = n.value, i = r?.value, a = typeof i == "number" && e ? e(i) : i ?? "", o = typeof n.marker == "string" ? n.marker : "", s = n.seriesName ? `${n.seriesName}: ` : "", c = r?.name ?? n.name, l = t && c != null ? t(c instanceof Date ? c : new Date(c)) : c ?? "";
|
|
160
161
|
return {
|
|
161
162
|
name: String(l),
|
|
@@ -167,7 +168,7 @@ function x(e, t) {
|
|
|
167
168
|
}
|
|
168
169
|
//#endregion
|
|
169
170
|
//#region src/widgets-v2/timeseries/skeleton.tsx
|
|
170
|
-
var
|
|
171
|
+
var C = {
|
|
171
172
|
container: {
|
|
172
173
|
display: "flex",
|
|
173
174
|
flexDirection: "column",
|
|
@@ -213,42 +214,42 @@ var S = {
|
|
|
213
214
|
gap: ({ spacing: e }) => e(1.5)
|
|
214
215
|
}
|
|
215
216
|
};
|
|
216
|
-
function
|
|
217
|
-
let e =
|
|
218
|
-
e[0] === Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */
|
|
219
|
-
sx:
|
|
217
|
+
function w() {
|
|
218
|
+
let e = m(2), t;
|
|
219
|
+
e[0] === Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */ v(h, {
|
|
220
|
+
sx: C.graph,
|
|
220
221
|
children: [
|
|
221
|
-
/* @__PURE__ */ g
|
|
222
|
+
/* @__PURE__ */ _(g, {
|
|
222
223
|
variant: "rectangular",
|
|
223
|
-
sx:
|
|
224
|
+
sx: C.segmentA
|
|
224
225
|
}),
|
|
225
|
-
/* @__PURE__ */ g
|
|
226
|
+
/* @__PURE__ */ _(g, {
|
|
226
227
|
variant: "rectangular",
|
|
227
|
-
sx:
|
|
228
|
+
sx: C.segmentB
|
|
228
229
|
}),
|
|
229
|
-
/* @__PURE__ */ g
|
|
230
|
+
/* @__PURE__ */ _(g, {
|
|
230
231
|
variant: "rectangular",
|
|
231
|
-
sx:
|
|
232
|
+
sx: C.segmentC
|
|
232
233
|
})
|
|
233
234
|
]
|
|
234
235
|
}), e[0] = t) : t = e[0];
|
|
235
236
|
let n;
|
|
236
|
-
return e[1] === Symbol.for("react.memo_cache_sentinel") ? (n = /* @__PURE__ */
|
|
237
|
-
sx:
|
|
238
|
-
children: [t, /* @__PURE__ */
|
|
239
|
-
sx:
|
|
240
|
-
children: [0, 1].map(
|
|
237
|
+
return e[1] === Symbol.for("react.memo_cache_sentinel") ? (n = /* @__PURE__ */ v(h, {
|
|
238
|
+
sx: C.container,
|
|
239
|
+
children: [t, /* @__PURE__ */ _(h, {
|
|
240
|
+
sx: C.legend,
|
|
241
|
+
children: [0, 1].map(T)
|
|
241
242
|
})]
|
|
242
243
|
}), e[1] = n) : n = e[1], n;
|
|
243
244
|
}
|
|
244
|
-
function
|
|
245
|
-
return /* @__PURE__ */
|
|
246
|
-
sx:
|
|
247
|
-
children: [/* @__PURE__ */ g
|
|
245
|
+
function T(e) {
|
|
246
|
+
return /* @__PURE__ */ v(h, {
|
|
247
|
+
sx: C.legendItem,
|
|
248
|
+
children: [/* @__PURE__ */ _(g, {
|
|
248
249
|
variant: "circular",
|
|
249
250
|
width: 8,
|
|
250
251
|
height: 8
|
|
251
|
-
}), /* @__PURE__ */ g
|
|
252
|
+
}), /* @__PURE__ */ _(g, {
|
|
252
253
|
width: 48,
|
|
253
254
|
height: 8
|
|
254
255
|
})]
|
|
@@ -256,14 +257,14 @@ function w(e) {
|
|
|
256
257
|
}
|
|
257
258
|
//#endregion
|
|
258
259
|
//#region src/widgets-v2/timeseries/download.ts
|
|
259
|
-
function
|
|
260
|
-
let
|
|
261
|
-
return e.getCaptureEl &&
|
|
260
|
+
function E(e) {
|
|
261
|
+
let t = [];
|
|
262
|
+
return e.getCaptureEl && t.push(n({
|
|
262
263
|
filename: e.filename,
|
|
263
264
|
getCaptureEl: e.getCaptureEl,
|
|
264
265
|
pixelRatio: e.pngPixelRatio,
|
|
265
266
|
backgroundColor: e.pngBackgroundColor
|
|
266
|
-
})),
|
|
267
|
+
})), t.push(r({
|
|
267
268
|
filename: e.filename,
|
|
268
269
|
getRows: (t) => {
|
|
269
270
|
let n = e.getData(t), r = n.length, i = [], a = /* @__PURE__ */ new Set();
|
|
@@ -275,20 +276,20 @@ function T(e) {
|
|
|
275
276
|
for (let t = 0; t < r; t++) s.push(e.seriesNames?.[t] ?? `series_${t + 1}`);
|
|
276
277
|
let c = [s];
|
|
277
278
|
for (let e of i) {
|
|
278
|
-
let t = [
|
|
279
|
+
let t = [D(e)], n = String(e);
|
|
279
280
|
for (let e of o) t.push(e.get(n) ?? "");
|
|
280
281
|
c.push(t);
|
|
281
282
|
}
|
|
282
283
|
return c;
|
|
283
284
|
}
|
|
284
|
-
})),
|
|
285
|
+
})), t;
|
|
285
286
|
}
|
|
286
|
-
function
|
|
287
|
+
function D(e) {
|
|
287
288
|
return e instanceof Date ? e.toISOString() : typeof e == "number" ? new Date(e).toISOString() : e;
|
|
288
289
|
}
|
|
289
290
|
//#endregion
|
|
290
291
|
//#region src/widgets-v2/timeseries/transforms.ts
|
|
291
|
-
function
|
|
292
|
+
function O(e, t) {
|
|
292
293
|
if (t.length === 0 || !Array.isArray(e)) return e;
|
|
293
294
|
let n = new Set(t);
|
|
294
295
|
return e.map((e) => Array.isArray(e) ? e.filter((e) => {
|
|
@@ -298,6 +299,6 @@ function D(e, t) {
|
|
|
298
299
|
}) : e);
|
|
299
300
|
}
|
|
300
301
|
//#endregion
|
|
301
|
-
export {
|
|
302
|
+
export { w as TimeseriesSkeleton, E as createTimeseriesDownloadConfig, x as createTimeseriesOptionFactory, O as filterTimeseriesByLockedItems, b as timeseriesOptions };
|
|
302
303
|
|
|
303
304
|
//# sourceMappingURL=timeseries.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeseries.js","names":["<Box sx={styles.graph}>\n <Skeleton variant='rectangular' sx={styles.segmentA} />\n <Skeleton variant='rectangular' sx={styles.segmentB} />\n <Skeleton variant='rectangular' sx={styles.segmentC} />\n </Box>","<Box sx={styles.container}>\n <Box sx={styles.graph}>\n <Skeleton variant='rectangular' sx={styles.segmentA} />\n <Skeleton variant='rectangular' sx={styles.segmentB} />\n <Skeleton variant='rectangular' sx={styles.segmentC} />\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>","(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 )"],"sources":["../../src/widgets-v2/timeseries/options.ts","../../src/widgets-v2/timeseries/skeleton.tsx","../../src/widgets-v2/timeseries/download.ts","../../src/widgets-v2/timeseries/transforms.ts"],"sourcesContent":["import type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildAxisLabelStyle,\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 { createItemColorResolver } from '../utils/item-color'\nimport { positionDataZoomForLegend } from '../utils/data-zoom-layout'\nimport type {\n TimeseriesEChartsOption,\n TimeseriesOptionFactoryInput,\n TimeseriesOptionsInput,\n TimeseriesWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a timeseries widget —\n * time x-axis, value y-axis, themed tooltip, themed legend, CARTO color\n * palette. Mirrors {@link import('../bar/options').barOptions} so all\n * four ECharts widgets share v1 look-and-feel.\n *\n * Intentional deviations from bar (timeseries-specific):\n * - **X-axis is `type: 'time'`** (not 'category'). ECharts handles\n * uneven sample spacing and zoom-level-aware label formatting.\n * `labelFormatter` is wrapped so the consumer sees a `Date`, not\n * a numeric timestamp.\n * - **Tooltip body reads `{ name, value }` rows**, same as bar, but\n * the `name` may arrive as `Date | number | string`. The\n * `labelFormatter` receives a `Date` regardless.\n *\n * Intentionally data-agnostic: no series, no dataset, no `legend.show`\n * (those depend on data and are added by the option factory's merge\n * phase via {@link createTimeseriesOptionFactory}).\n */\nexport function timeseriesOptions({\n theme,\n formatter,\n labelFormatter,\n}: TimeseriesOptionsInput): TimeseriesEChartsOption {\n // Closure shared between yAxis min/max callbacks and the label formatter,\n // so only the rounded extents are labelled (matches v1 + bar).\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: buildTimeseriesTooltipFormatter(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 }),\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: 'time',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n ...buildAxisLabelStyle(theme),\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n margin: 0,\n hideOverlap: true,\n ...(labelFormatter && {\n formatter: (value: number) => labelFormatter(new Date(value)),\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 ...buildAxisLabelStyle(theme),\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 TimeseriesEChartsOption\n}\n\n/**\n * Returns the timeseries widget's {@link OptionFactory} — one closure\n * that owns BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link timeseriesOptions}, optionally merging\n * the consumer-supplied `optionsOverride`. Called once by Provider to\n * seed `rawOptions` in the store.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`TimeseriesWidgetData`) into the option via the dataset API: one\n * dataset per series, each series referencing its dataset by index,\n * encoded by `name` (x — time) and `value` (y). Mirrors {@link import('../bar/options').createBarOptionFactory}:\n * series-template merge for `addStack`, reactive formatters from\n * `ctx`, `niceNum`-rounded y-axis bounds at fusion time, and\n * `positionDataZoomForLegend` layout for ZoomToggle sliders.\n */\nexport function createTimeseriesOptionFactory(\n options: TimeseriesOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, labelFormatter, optionsOverride } = options\n const series = options.series\n const smooth = options.smooth ?? true\n const area = options.area ?? false\n const selection = options.selection\n const selectionSet =\n selection && selection.length > 0\n ? new Set<string | number>(selection)\n : null\n // `name` may be Date | number | string. Normalize to the same type the\n // selection is keyed on (Date → ms) so Set lookups match.\n const normalizeName = (n: Date | number | string): string | number =>\n n instanceof Date ? n.getTime() : n\n return (option, data, ctx) => {\n if (option == null) {\n const structural = timeseriesOptions({ 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 TimeseriesWidgetData) : []\n if (seriesArr.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n const hasLegend = seriesArr.length > 1\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\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 baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n\n // Reactive (live store) formatter from ctx — distinct from the\n // closure-time `formatter` captured for the structural-build branch\n // above. RelativeData can install a percent formatter on the store\n // after the factory was constructed; the merge phase reads `ctx` to\n // pick that up. `labelFormatter` (Date → string) is structural-only —\n // not relativizable — so the merge branch reads the closure-time value.\n const liveFormatter = ctx?.formatter\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 // bar). Delegating the extent to ECharts (rather than precomputing\n // scalars from the raw data) keeps stacked lines 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.\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 // Dim non-selected points via `series.itemStyle.color`. Per-row\n // `itemStyle` on dataset object-rows is silently ignored when\n // `series.encode` is in play.\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 points would stay dimmed forever after an external clear.\n // Always emitting lets normal merge swap the callback in place, no\n // `replaceMerge` and no entry-animation flash on selection on/off.\n //\n // The base colour is the point's own `color`, else the template's\n // `itemStyle.color`, else the series colour / palette (`params.color`).\n const makeDimItemStyle = (datums: readonly object[], template: unknown) => {\n const baseColor = createItemColorResolver({\n theme,\n datums,\n template,\n fallback: (params) => params.color as string,\n })\n return {\n color: (params: CallbackDataParams) => {\n const datum = params.value as\n { name?: Date | number | string } | undefined\n const raw = datum?.name\n const base = baseColor(params)\n if (!selectionSet || raw == null) return base\n return selectionSet.has(normalizeName(raw))\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n },\n }\n }\n // Per-point colours only show on markers, so surface them whenever a\n // point carries its own `color` (same reason as the selection case).\n const hasDatumColor = seriesArr.some((s) =>\n s.some((d) => typeof d?.color === 'string' && d.color !== ''),\n )\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n series: seriesArr.map((s, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n // For line series, set BOTH `series[i].color` (legend swatch +\n // markers) AND `series[i].lineStyle.color` (the line itself) so\n // the override paints everywhere a series has a colour slot.\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n ...(typeof template === 'object' ? template : {}),\n type: 'line' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 'name', y: 'value' },\n smooth,\n // When a selection is active, surface markers so the per-point\n // color callback has something to dim — a continuous line would\n // hide the visual selection feedback.\n showSymbol: selectionSet != null || hasDatumColor,\n ...(area ? { areaStyle: {} } : {}),\n emphasis: { focus: 'series' },\n itemStyle: makeDimItemStyle(s, template),\n ...(overrideColor\n ? { color: overrideColor, lineStyle: { color: overrideColor } }\n : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: { ...baseGrid, bottom: gridBottom },\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: buildTimeseriesTooltipFormatter(\n liveFormatter,\n labelFormatter,\n ),\n },\n } as EChartsOption\n }\n}\n\n/**\n * Tooltip formatter for the timeseries `{ name, value }` row shape.\n * `name` arrives as `Date | number | string` (the time-axis stores the\n * raw value the consumer supplied). The consumer's `labelFormatter`\n * expects a `Date`, so we coerce non-Date values via `new Date(...)`\n * before invoking it.\n */\nfunction buildTimeseriesTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: Date) => string) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const row = item.value as\n { name?: Date | number | string; value?: number } | undefined\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 rawName = row?.name ?? item.name\n const name =\n labelFormatter && rawName != null\n ? labelFormatter(rawName instanceof Date ? rawName : new Date(rawName))\n : (rawName ?? '')\n return { name: String(name), seriesName, marker, value: formattedValue }\n })\n}\n","import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst styles = {\n container: {\n display: 'flex',\n flexDirection: 'column',\n justifyContent: 'space-between',\n gap: ({ spacing }) => spacing(1),\n height: ({ spacing }) => spacing(38),\n },\n graph: {\n position: 'relative',\n flex: '1 1 auto',\n width: '100%',\n },\n segmentA: {\n position: 'absolute',\n left: 0,\n right: '70%',\n top: '60%',\n height: 4,\n },\n segmentB: {\n position: 'absolute',\n left: '25%',\n right: '40%',\n top: '35%',\n height: 4,\n },\n segmentC: {\n position: 'absolute',\n left: '55%',\n right: 0,\n top: '50%',\n height: 4,\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\n/**\n * Loading state for the Timeseries widget. Mirrors a line chart's\n * silhouette — three thin horizontal segments at staggered offsets to\n * suggest a moving line, plus a 2-dot legend stub. Sibling-consistent\n * with Bar / Histogram / Scatter skeletons (column-flex container with\n * legend strip below).\n */\nexport function TimeseriesSkeleton() {\n return (\n <Box sx={styles.container}>\n <Box sx={styles.graph}>\n <Skeleton variant='rectangular' sx={styles.segmentA} />\n <Skeleton variant='rectangular' sx={styles.segmentB} />\n <Skeleton variant='rectangular' sx={styles.segmentC} />\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 buildCsvDownloadItem,\n buildPngDownloadItem,\n type DownloadContext,\n type DownloadItem,\n} from '../actions/download'\nimport type { TimeseriesWidgetData } from './types'\n\n/**\n * Download menu items for the Timeseries widget. Always includes a CSV\n * item with `time, series_1, series_2, …` columns (one row per unique time\n * across all series; ISO-8601 strings for `Date`/numeric times). When\n * `getCaptureEl` is supplied, prepends a PNG item that rasterises the\n * captured element via `html2canvas`.\n */\nexport function createTimeseriesDownloadConfig(args: {\n filename: string\n getData: (ctx: DownloadContext) => TimeseriesWidgetData\n seriesNames?: readonly string[]\n getCaptureEl?: (ctx: DownloadContext) => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\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 buildCsvDownloadItem({\n filename: args.filename,\n getRows: (ctx) => {\n const data = args.getData(ctx)\n const seriesCount = data.length\n\n // Collect every unique time, preserving insertion order.\n const timeKeys: (Date | number | string)[] = []\n const seenKeys = new Set<string>()\n for (const series of data) {\n for (const point of series) {\n const key = String(point.name)\n if (!seenKeys.has(key)) {\n seenKeys.add(key)\n timeKeys.push(point.name)\n }\n }\n }\n\n // Build a quick lookup per series for O(rows × series) emit.\n const lookups = data.map(\n (series) => new Map(series.map((p) => [String(p.name), p.value])),\n )\n\n const header: unknown[] = ['time']\n for (let i = 0; i < seriesCount; i++) {\n header.push(args.seriesNames?.[i] ?? `series_${i + 1}`)\n }\n const rows: unknown[][] = [header]\n for (const key of timeKeys) {\n const row: unknown[] = [formatTime(key)]\n const lookupKey = String(key)\n for (const lookup of lookups) row.push(lookup.get(lookupKey) ?? '')\n rows.push(row)\n }\n\n return rows\n },\n }),\n )\n return items\n}\n\nfunction formatTime(v: Date | number | string): string {\n if (v instanceof Date) return v.toISOString()\n if (typeof v === 'number') return new Date(v).toISOString()\n return v\n}\n","/**\n * `LockSelection` filter for Timeseries. Data is `{name, value}[][]` like\n * Bar/Pie/Category, but `name` may arrive as `Date | number | string` (the\n * time axis stores a `Date`). `lockedItems` is snapshotted from `selection`,\n * whose keys are already normalized to `Date → ms` (see `options.ts`'s\n * `normalizeName`) — so a raw `Date` name must be normalized the same way\n * before the membership check, or every point would compare a `Date` object\n * against a `number` and silently fail to match, filtering everything out.\n */\nexport function filterTimeseriesByLockedItems(\n input: unknown,\n lockedItems: readonly (string | number)[],\n): unknown {\n if (lockedItems.length === 0) return input\n if (!Array.isArray(input)) return input\n const locked = new Set<string | number>(lockedItems)\n return input.map((series: unknown): unknown => {\n if (!Array.isArray(series)) return series\n return series.filter((item: unknown) => {\n if (item == null || typeof item !== 'object' || !('name' in item)) {\n return false\n }\n const raw = (item as { name: unknown }).name\n const name = raw instanceof Date ? raw.getTime() : raw\n return (\n (typeof name === 'string' || typeof name === 'number') &&\n locked.has(name)\n )\n })\n })\n}\n"],"mappings":";;;;;;;;;;AA0CA,SAAgB,EAAkB,EAChC,UACA,cACA,qBACkD;CAGlD,IAAI,IAAU,GACV,IAAU;CAEd,OAAO;EACL,MAAM;GACJ,MAAM,SAAS,EAAM,QAAQ,CAAC,CAAC;GAC/B,KAAK,SAAS,EAAM,QAAQ,CAAC,CAAC;GAC9B,OAAO,SAAS,EAAM,QAAQ,CAAC,CAAC;GAEhC,GAAG,EAAgB,IAAO,CAAK;GAC/B,cAAc;EAChB;EACA,SAAS;GACP,SAAS;GACT,iBAAiB,EAAM,QAAQ,KAAK;GACpC,aAAa;GACb,SAAS,CAAC,SAAS,EAAM,QAAQ,CAAC,CAAC,GAAG,SAAS,EAAM,QAAQ,CAAC,CAAC,CAAC;GAChE,WAAW;IACT,OAAO,EAAM,QAAQ,OAAO;IAC5B,UAAU;IACV,YAAY,EAAM,WAAW,QAAQ;GACvC;GACA,aAAa,EAAE,MAAM,OAAO;GAC5B,UAAU,EAAwB,CAAK;GACvC,WAAW,EAAgC,GAAW,CAAc;EACtE;EAGA,QAAQ,EACN,GAAG,EAAkB,EAAE,WAAW,GAAM,CAAC,EAC3C;EACA,aAAa,EAAE,WAAW,EAAE,OAAO,EAAM,QAAQ,KAAK,KAAK,EAAE;EAC7D,OAAO,CACL,EAAM,QAAQ,UAAU,MACxB,GAAG,OAAO,OACP,EAAM,QACJ,aAAa,QAAQ,CAAC,CAC3B,CACF;EACA,OAAO;GACL,MAAM;GACN,UAAU,EAAE,MAAM,GAAM;GACxB,UAAU,EAAE,MAAM,GAAM;GACxB,WAAW;IACT,GAAG,EAAoB,CAAK;IAC5B,SAAS;KAAC,SAAS,EAAM,QAAQ,EAAG,CAAC;KAAG;KAAG;KAAG;IAAC;IAC/C,QAAQ;IACR,aAAa;IACb,GAAI,KAAkB,EACpB,YAAY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,CAAG;IAC5B,KAAK,IAAM,KAAU,GAAS,EAAI,KAAK,EAAO,IAAI,CAAS,KAAK,EAAE;IAClE,EAAK,KAAK,CAAG;GACf;GAEA,OAAO;EACT;CACF,CAAC,CACH,GACO;AACT;AAEA,SAAS,EAAW,GAAmC;CAGrD,OAFI,aAAa,OAAa,EAAE,YAAY,IACxC,OAAO,KAAM,WAAiB,IAAI,KAAK,CAAC,CAAC,CAAC,YAAY,IACnD;AACT;;;ACzEA,SAAgB,EACd,GACA,GACS;CAET,IADI,EAAY,WAAW,KACvB,CAAC,MAAM,QAAQ,CAAK,GAAG,OAAO;CAClC,IAAM,IAAS,IAAI,IAAqB,CAAW;CACnD,OAAO,EAAM,KAAK,MACX,MAAM,QAAQ,CAAM,IAClB,EAAO,QAAQ,MAAkB;EACtC,IAAoB,OAAO,KAAS,aAAhC,KAA4C,EAAE,UAAU,IAC1D,OAAO;EAET,IAAM,IAAO,EAA2B,MAClC,IAAO,aAAe,OAAO,EAAI,QAAQ,IAAI;EACnD,QACG,OAAO,KAAS,YAAY,OAAO,KAAS,aAC7C,EAAO,IAAI,CAAI;CAEnB,CAAC,IAXkC,CAYpC;AACH"}
|
|
1
|
+
{"version":3,"file":"timeseries.js","names":["<Box sx={styles.graph}>\n <Skeleton variant='rectangular' sx={styles.segmentA} />\n <Skeleton variant='rectangular' sx={styles.segmentB} />\n <Skeleton variant='rectangular' sx={styles.segmentC} />\n </Box>","<Box sx={styles.container}>\n <Box sx={styles.graph}>\n <Skeleton variant='rectangular' sx={styles.segmentA} />\n <Skeleton variant='rectangular' sx={styles.segmentB} />\n <Skeleton variant='rectangular' sx={styles.segmentC} />\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>","(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 )"],"sources":["../../src/widgets-v2/timeseries/options.ts","../../src/widgets-v2/timeseries/skeleton.tsx","../../src/widgets-v2/timeseries/download.ts","../../src/widgets-v2/timeseries/transforms.ts"],"sourcesContent":["import type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildAxisLabelStyle,\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 { createItemColorResolver } from '../utils/item-color'\nimport { positionDataZoomForLegend } from '../utils/data-zoom-layout'\nimport type {\n TimeseriesEChartsOption,\n TimeseriesOptionFactoryInput,\n TimeseriesOptionsInput,\n TimeseriesWidgetData,\n} from './types'\nimport { fixedAxisBounds } from '../actions/relative-data/scale'\n\n/**\n * Builds the **structural** ECharts option for a timeseries widget —\n * time x-axis, value y-axis, themed tooltip, themed legend, CARTO color\n * palette. Mirrors {@link import('../bar/options').barOptions} so all\n * four ECharts widgets share v1 look-and-feel.\n *\n * Intentional deviations from bar (timeseries-specific):\n * - **X-axis is `type: 'time'`** (not 'category'). ECharts handles\n * uneven sample spacing and zoom-level-aware label formatting.\n * `labelFormatter` is wrapped so the consumer sees a `Date`, not\n * a numeric timestamp.\n * - **Tooltip body reads `{ name, value }` rows**, same as bar, but\n * the `name` may arrive as `Date | number | string`. The\n * `labelFormatter` receives a `Date` regardless.\n *\n * Intentionally data-agnostic: no series, no dataset, no `legend.show`\n * (those depend on data and are added by the option factory's merge\n * phase via {@link createTimeseriesOptionFactory}).\n */\nexport function timeseriesOptions({\n theme,\n formatter,\n labelFormatter,\n}: TimeseriesOptionsInput): TimeseriesEChartsOption {\n // Closure shared between yAxis min/max callbacks and the label formatter,\n // so only the rounded extents are labelled (matches v1 + bar).\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: buildTimeseriesTooltipFormatter(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 }),\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: 'time',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n ...buildAxisLabelStyle(theme),\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n margin: 0,\n hideOverlap: true,\n ...(labelFormatter && {\n formatter: (value: number) => labelFormatter(new Date(value)),\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 ...buildAxisLabelStyle(theme),\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 TimeseriesEChartsOption\n}\n\n/**\n * Returns the timeseries widget's {@link OptionFactory} — one closure\n * that owns BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link timeseriesOptions}, optionally merging\n * the consumer-supplied `optionsOverride`. Called once by Provider to\n * seed `rawOptions` in the store.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`TimeseriesWidgetData`) into the option via the dataset API: one\n * dataset per series, each series referencing its dataset by index,\n * encoded by `name` (x — time) and `value` (y). Mirrors {@link import('../bar/options').createBarOptionFactory}:\n * series-template merge for `addStack`, reactive formatters from\n * `ctx`, `niceNum`-rounded y-axis bounds at fusion time, and\n * `positionDataZoomForLegend` layout for ZoomToggle sliders.\n */\nexport function createTimeseriesOptionFactory(\n options: TimeseriesOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, labelFormatter, optionsOverride } = options\n const series = options.series\n const smooth = options.smooth ?? true\n const area = options.area ?? false\n const selection = options.selection\n const selectionSet =\n selection && selection.length > 0\n ? new Set<string | number>(selection)\n : null\n // `name` may be Date | number | string. Normalize to the same type the\n // selection is keyed on (Date → ms) so Set lookups match.\n const normalizeName = (n: Date | number | string): string | number =>\n n instanceof Date ? n.getTime() : n\n return (option, data, ctx) => {\n if (option == null) {\n const structural = timeseriesOptions({ 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 TimeseriesWidgetData) : []\n if (seriesArr.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n const hasLegend = seriesArr.length > 1\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n const fixedY = fixedAxisBounds(baseYAxis)\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 baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n\n // Reactive (live store) formatter from ctx — distinct from the\n // closure-time `formatter` captured for the structural-build branch\n // above. RelativeData can install a percent formatter on the store\n // after the factory was constructed; the merge phase reads `ctx` to\n // pick that up. `labelFormatter` (Date → string) is structural-only —\n // not relativizable — so the merge branch reads the closure-time value.\n const liveFormatter = ctx?.formatter\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 // bar). Delegating the extent to ECharts (rather than precomputing\n // scalars from the raw data) keeps stacked lines 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.\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 // Dim non-selected points via `series.itemStyle.color`. Per-row\n // `itemStyle` on dataset object-rows is silently ignored when\n // `series.encode` is in play.\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 points would stay dimmed forever after an external clear.\n // Always emitting lets normal merge swap the callback in place, no\n // `replaceMerge` and no entry-animation flash on selection on/off.\n //\n // The base colour is the point's own `color`, else the template's\n // `itemStyle.color`, else the series colour / palette (`params.color`).\n const makeDimItemStyle = (datums: readonly object[], template: unknown) => {\n const baseColor = createItemColorResolver({\n theme,\n datums,\n template,\n fallback: (params) => params.color as string,\n })\n return {\n color: (params: CallbackDataParams) => {\n const datum = params.value as\n { name?: Date | number | string } | undefined\n const raw = datum?.name\n const base = baseColor(params)\n if (!selectionSet || raw == null) return base\n return selectionSet.has(normalizeName(raw))\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n },\n }\n }\n // Per-point colours only show on markers, so surface them whenever a\n // point carries its own `color` (same reason as the selection case).\n const hasDatumColor = seriesArr.some((s) =>\n s.some((d) => typeof d?.color === 'string' && d.color !== ''),\n )\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n series: seriesArr.map((s, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n // For line series, set BOTH `series[i].color` (legend swatch +\n // markers) AND `series[i].lineStyle.color` (the line itself) so\n // the override paints everywhere a series has a colour slot.\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n ...(typeof template === 'object' ? template : {}),\n type: 'line' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 'name', y: 'value' },\n smooth,\n // When a selection is active, surface markers so the per-point\n // color callback has something to dim — a continuous line would\n // hide the visual selection feedback.\n showSymbol: selectionSet != null || hasDatumColor,\n ...(area ? { areaStyle: {} } : {}),\n emphasis: { focus: 'series' },\n itemStyle: makeDimItemStyle(s, template),\n ...(overrideColor\n ? { color: overrideColor, lineStyle: { color: overrideColor } }\n : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: { ...baseGrid, bottom: gridBottom },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout } : {}),\n yAxis: {\n ...baseYAxis,\n // A config transform (RelativeData's `'total'` scale) may pin the\n // ends; each applies only on the side the data reaches.\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? (fixedY.min ?? niceNum(extent.min)) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : (fixedY.max ?? 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: buildTimeseriesTooltipFormatter(\n liveFormatter,\n labelFormatter,\n ),\n },\n } as EChartsOption\n }\n}\n\n/**\n * Tooltip formatter for the timeseries `{ name, value }` row shape.\n * `name` arrives as `Date | number | string` (the time-axis stores the\n * raw value the consumer supplied). The consumer's `labelFormatter`\n * expects a `Date`, so we coerce non-Date values via `new Date(...)`\n * before invoking it.\n */\nfunction buildTimeseriesTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: Date) => string) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const row = item.value as\n { name?: Date | number | string; value?: number } | undefined\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 rawName = row?.name ?? item.name\n const name =\n labelFormatter && rawName != null\n ? labelFormatter(rawName instanceof Date ? rawName : new Date(rawName))\n : (rawName ?? '')\n return { name: String(name), seriesName, marker, value: formattedValue }\n })\n}\n","import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst styles = {\n container: {\n display: 'flex',\n flexDirection: 'column',\n justifyContent: 'space-between',\n gap: ({ spacing }) => spacing(1),\n height: ({ spacing }) => spacing(38),\n },\n graph: {\n position: 'relative',\n flex: '1 1 auto',\n width: '100%',\n },\n segmentA: {\n position: 'absolute',\n left: 0,\n right: '70%',\n top: '60%',\n height: 4,\n },\n segmentB: {\n position: 'absolute',\n left: '25%',\n right: '40%',\n top: '35%',\n height: 4,\n },\n segmentC: {\n position: 'absolute',\n left: '55%',\n right: 0,\n top: '50%',\n height: 4,\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\n/**\n * Loading state for the Timeseries widget. Mirrors a line chart's\n * silhouette — three thin horizontal segments at staggered offsets to\n * suggest a moving line, plus a 2-dot legend stub. Sibling-consistent\n * with Bar / Histogram / Scatter skeletons (column-flex container with\n * legend strip below).\n */\nexport function TimeseriesSkeleton() {\n return (\n <Box sx={styles.container}>\n <Box sx={styles.graph}>\n <Skeleton variant='rectangular' sx={styles.segmentA} />\n <Skeleton variant='rectangular' sx={styles.segmentB} />\n <Skeleton variant='rectangular' sx={styles.segmentC} />\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 buildCsvDownloadItem,\n buildPngDownloadItem,\n type DownloadContext,\n type DownloadItem,\n} from '../actions/download'\nimport type { TimeseriesWidgetData } from './types'\n\n/**\n * Download menu items for the Timeseries widget. Always includes a CSV\n * item with `time, series_1, series_2, …` columns (one row per unique time\n * across all series; ISO-8601 strings for `Date`/numeric times). When\n * `getCaptureEl` is supplied, prepends a PNG item that rasterises the\n * captured element via `html2canvas`.\n */\nexport function createTimeseriesDownloadConfig(args: {\n filename: string\n getData: (ctx: DownloadContext) => TimeseriesWidgetData\n seriesNames?: readonly string[]\n getCaptureEl?: (ctx: DownloadContext) => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\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 buildCsvDownloadItem({\n filename: args.filename,\n getRows: (ctx) => {\n const data = args.getData(ctx)\n const seriesCount = data.length\n\n // Collect every unique time, preserving insertion order.\n const timeKeys: (Date | number | string)[] = []\n const seenKeys = new Set<string>()\n for (const series of data) {\n for (const point of series) {\n const key = String(point.name)\n if (!seenKeys.has(key)) {\n seenKeys.add(key)\n timeKeys.push(point.name)\n }\n }\n }\n\n // Build a quick lookup per series for O(rows × series) emit.\n const lookups = data.map(\n (series) => new Map(series.map((p) => [String(p.name), p.value])),\n )\n\n const header: unknown[] = ['time']\n for (let i = 0; i < seriesCount; i++) {\n header.push(args.seriesNames?.[i] ?? `series_${i + 1}`)\n }\n const rows: unknown[][] = [header]\n for (const key of timeKeys) {\n const row: unknown[] = [formatTime(key)]\n const lookupKey = String(key)\n for (const lookup of lookups) row.push(lookup.get(lookupKey) ?? '')\n rows.push(row)\n }\n\n return rows\n },\n }),\n )\n return items\n}\n\nfunction formatTime(v: Date | number | string): string {\n if (v instanceof Date) return v.toISOString()\n if (typeof v === 'number') return new Date(v).toISOString()\n return v\n}\n","/**\n * `LockSelection` filter for Timeseries. Data is `{name, value}[][]` like\n * Bar/Pie/Category, but `name` may arrive as `Date | number | string` (the\n * time axis stores a `Date`). `lockedItems` is snapshotted from `selection`,\n * whose keys are already normalized to `Date → ms` (see `options.ts`'s\n * `normalizeName`) — so a raw `Date` name must be normalized the same way\n * before the membership check, or every point would compare a `Date` object\n * against a `number` and silently fail to match, filtering everything out.\n */\nexport function filterTimeseriesByLockedItems(\n input: unknown,\n lockedItems: readonly (string | number)[],\n): unknown {\n if (lockedItems.length === 0) return input\n if (!Array.isArray(input)) return input\n const locked = new Set<string | number>(lockedItems)\n return input.map((series: unknown): unknown => {\n if (!Array.isArray(series)) return series\n return series.filter((item: unknown) => {\n if (item == null || typeof item !== 'object' || !('name' in item)) {\n return false\n }\n const raw = (item as { name: unknown }).name\n const name = raw instanceof Date ? raw.getTime() : raw\n return (\n (typeof name === 'string' || typeof name === 'number') &&\n locked.has(name)\n )\n })\n })\n}\n"],"mappings":";;;;;;;;;;;AA2CA,SAAgB,EAAkB,EAChC,UACA,cACA,qBACkD;CAGlD,IAAI,IAAU,GACV,IAAU;CAEd,OAAO;EACL,MAAM;GACJ,MAAM,SAAS,EAAM,QAAQ,CAAC,CAAC;GAC/B,KAAK,SAAS,EAAM,QAAQ,CAAC,CAAC;GAC9B,OAAO,SAAS,EAAM,QAAQ,CAAC,CAAC;GAEhC,GAAG,EAAgB,IAAO,CAAK;GAC/B,cAAc;EAChB;EACA,SAAS;GACP,SAAS;GACT,iBAAiB,EAAM,QAAQ,KAAK;GACpC,aAAa;GACb,SAAS,CAAC,SAAS,EAAM,QAAQ,CAAC,CAAC,GAAG,SAAS,EAAM,QAAQ,CAAC,CAAC,CAAC;GAChE,WAAW;IACT,OAAO,EAAM,QAAQ,OAAO;IAC5B,UAAU;IACV,YAAY,EAAM,WAAW,QAAQ;GACvC;GACA,aAAa,EAAE,MAAM,OAAO;GAC5B,UAAU,EAAwB,CAAK;GACvC,WAAW,EAAgC,GAAW,CAAc;EACtE;EAGA,QAAQ,EACN,GAAG,EAAkB,EAAE,WAAW,GAAM,CAAC,EAC3C;EACA,aAAa,EAAE,WAAW,EAAE,OAAO,EAAM,QAAQ,KAAK,KAAK,EAAE;EAC7D,OAAO,CACL,EAAM,QAAQ,UAAU,MACxB,GAAG,OAAO,OACP,EAAM,QACJ,aAAa,QAAQ,CAAC,CAC3B,CACF;EACA,OAAO;GACL,MAAM;GACN,UAAU,EAAE,MAAM,GAAM;GACxB,UAAU,EAAE,MAAM,GAAM;GACxB,WAAW;IACT,GAAG,EAAoB,CAAK;IAC5B,SAA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AO,KAAK,EAAK,cAAc,MAAM,UAAU,IAAI,GAAG;GAExD,IAAM,IAAoB,CAAC,CAAM;GACjC,KAAK,IAAM,KAAO,GAAU;IAC1B,IAAM,IAAiB,CAAC,EAAW,CAAG,CAAC,GACjC,IAAY,OAAO,CAAG;IAC5B,KAAK,IAAM,KAAU,GAAS,EAAI,KAAK,EAAO,IAAI,CAAS,KAAK,EAAE;IAClE,EAAK,KAAK,CAAG;GACf;GAEA,OAAO;EACT;CACF,CAAC,CACH,GACO;AACT;AAEA,SAAS,EAAW,GAAmC;CAGrD,OAFI,aAAa,OAAa,EAAE,YAAY,IACxC,OAAO,KAAM,WAAiB,IAAI,KAAK,CAAC,CAAC,CAAC,YAAY,IACnD;AACT;;;ACzEA,SAAgB,EACd,GACA,GACS;CAET,IADI,EAAY,WAAW,KACvB,CAAC,MAAM,QAAQ,CAAK,GAAG,OAAO;CAClC,IAAM,IAAS,IAAI,IAAqB,CAAW;CACnD,OAAO,EAAM,KAAK,MACX,MAAM,QAAQ,CAAM,IAClB,EAAO,QAAQ,MAAkB;EACtC,IAAoB,OAAO,KAAS,aAAhC,KAA4C,EAAE,UAAU,IAC1D,OAAO;EAET,IAAM,IAAO,EAA2B,MAClC,IAAO,aAAe,OAAO,EAAI,QAAQ,IAAI;EACnD,QACG,OAAO,KAAS,YAAY,OAAO,KAAS,aAC7C,EAAO,IAAI,CAAI;CAEnB,CAAC,IAXkC,CAYpC;AACH"}
|
package/dist/widgets-v2.js
CHANGED
|
@@ -2,7 +2,7 @@ import "./components-FED-ArwH.js";
|
|
|
2
2
|
import { t as e } from "./tooltip-DJUGNZxY.js";
|
|
3
3
|
import { t } from "./smart-tooltip-CwGHCqab.js";
|
|
4
4
|
import { C as n, S as r, T as i, _ as a } from "./stores-tiFePP0A.js";
|
|
5
|
-
import { C as o, D as s, S as c, c as l, f as u, g as d, o as f, r as p, t as m, y as h } from "./actions-
|
|
5
|
+
import { C as o, D as s, S as c, c as l, f as u, g as d, o as f, r as p, t as m, y as h } from "./actions-5-dVhroJ.js";
|
|
6
6
|
import { i as g, n as _, o as v, r as y } from "./echart-CwzbPElc.js";
|
|
7
7
|
import { t as b } from "./markdown-content-BWUqwx9F.js";
|
|
8
8
|
import { t as x } from "./zoom-toggle-IsF8BnAp.js";
|
|
@@ -11,7 +11,7 @@ import { i as ee, r as C } from "./formula-BIxJr1P3.js";
|
|
|
11
11
|
import { i as w, r as T } from "./markdown-oo9mnJun.js";
|
|
12
12
|
import { a as E, i as D } from "./spread-CgCTKPQD.js";
|
|
13
13
|
import { n as O, r as k } from "./range-BCMAl5xf.js";
|
|
14
|
-
import { i as A, r as te } from "./category-
|
|
14
|
+
import { i as A, r as te } from "./category-DBUD2ZBo.js";
|
|
15
15
|
import { d as j, i as M } from "./table-lb5momun.js";
|
|
16
16
|
import { c as N } from "react/compiler-runtime";
|
|
17
17
|
import { Children as ne, Component as P, isValidElement as F, useEffect as I, useLayoutEffect as re, useRef as L, useState as R } from "react";
|