x-next 1.7.0 → 1.8.1
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/AI_USAGE.md +129 -4
- package/CHANGELOG.md +47 -0
- package/dist/_hooks/use-chart-size.d.ts +25 -0
- package/dist/_utils/chart/index.d.ts +6 -0
- package/dist/_utils/chart/padding.d.ts +15 -0
- package/dist/_utils/chart/path.d.ts +34 -0
- package/dist/_utils/chart/scale.d.ts +55 -0
- package/dist/components/_components/chart/ChartAxis.d.ts +85 -0
- package/dist/components/_components/chart/ChartLegend.d.ts +26 -0
- package/dist/components/_components/chart/ChartTooltip.d.ts +76 -0
- package/dist/components/_components/chart/colors.d.ts +10 -0
- package/dist/components/_components/chart/interface.d.ts +38 -0
- package/dist/components/bar-chart/BarChart.d.ts +278 -0
- package/dist/components/bar-chart/helpers/layout.d.ts +55 -0
- package/dist/components/bar-chart/index.d.ts +600 -0
- package/dist/components/bar-chart/interface.d.ts +74 -0
- package/dist/components/bar-chart/props.d.ts +145 -0
- package/dist/components/heatmap/Heatmap.d.ts +10 -1
- package/dist/components/heatmap/index.d.ts +30 -3
- package/dist/components/index.d.ts +3 -0
- package/dist/components/line-chart/LineChart.d.ts +295 -0
- package/dist/components/line-chart/helpers/layout.d.ts +74 -0
- package/dist/components/line-chart/index.d.ts +614 -0
- package/dist/components/line-chart/interface.d.ts +76 -0
- package/dist/components/line-chart/props.d.ts +173 -0
- package/dist/components/pie-chart/PieChart.d.ts +219 -0
- package/dist/components/pie-chart/index.d.ts +470 -0
- package/dist/components/pie-chart/interface.d.ts +58 -0
- package/dist/components/pie-chart/props.d.ts +107 -0
- package/dist/components/trend-chart/components/TrendChart.d.ts +19 -96
- package/dist/components/trend-chart/index.d.ts +33 -187
- package/dist/components/trend-chart/props.d.ts +9 -78
- package/dist/components/trend-chart/themes.d.ts +0 -1
- package/dist/es/_hooks/use-chart-size.js +25 -0
- package/dist/es/_styles/palette-aliases.js +5 -0
- package/dist/es/_utils/chart/padding.js +22 -0
- package/dist/es/_utils/chart/path.js +69 -0
- package/dist/es/_utils/chart/scale.js +77 -0
- package/dist/es/components/_components/chart/ChartAxis.js +79 -0
- package/dist/es/components/_components/chart/ChartLegend.js +53 -0
- package/dist/es/components/_components/chart/ChartTooltip.js +64 -0
- package/dist/es/components/_components/chart/colors.js +12 -0
- package/dist/es/components/bar-chart/BarChart.js +470 -0
- package/dist/es/components/bar-chart/helpers/layout.js +53 -0
- package/dist/es/components/bar-chart/index.js +8 -0
- package/dist/es/components/bar-chart/props.js +148 -0
- package/dist/es/components/heatmap/Heatmap.js +249 -172
- package/dist/es/components/index.js +132 -126
- package/dist/es/components/line-chart/LineChart.js +532 -0
- package/dist/es/components/line-chart/helpers/layout.js +80 -0
- package/dist/es/components/line-chart/index.js +8 -0
- package/dist/es/components/line-chart/props.js +178 -0
- package/dist/es/components/pie-chart/PieChart.js +397 -0
- package/dist/es/components/pie-chart/index.js +8 -0
- package/dist/es/components/pie-chart/props.js +104 -0
- package/dist/es/components/trend-chart/components/TrendChart.js +143 -183
- package/dist/es/components/trend-chart/components/trend-chart-curve.js +85 -81
- package/dist/es/components/trend-chart/props.js +28 -74
- package/dist/es/components/trend-chart/themes.js +30 -31
- package/dist/es/index.js +193 -187
- package/dist/es/locale/en-US.js +8 -1
- package/dist/es/locale/zh-CN.js +8 -1
- package/dist/es/style.css +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.umd.js +4 -4
- package/dist/locale/interface.d.ts +13 -0
- package/dist/style/bar-chart.css +1 -0
- package/dist/style/bar-chart.js +2 -0
- package/dist/style/base.css +1 -1
- package/dist/style/heatmap.css +1 -1
- package/dist/style/line-chart.css +1 -0
- package/dist/style/line-chart.js +2 -0
- package/dist/style/pie-chart.css +1 -0
- package/dist/style/pie-chart.js +2 -0
- package/dist/style.css +1 -1
- package/dist/types.d.ts +3 -0
- package/package.json +1 -1
- package/volar.d.ts +3 -0
- package/dist/components/trend-chart/components/trend-chart-grid.d.ts +0 -55
- package/dist/components/trend-chart/components/trend-chart-labels.d.ts +0 -26
- package/dist/components/trend-chart/helpers/genPath.d.ts +0 -8
- package/dist/components/trend-chart/helpers/getPadding.d.ts +0 -8
- package/dist/components/trend-chart/helpers/validatePadding.d.ts +0 -2
- package/dist/es/components/trend-chart/components/trend-chart-grid.js +0 -62
- package/dist/es/components/trend-chart/components/trend-chart-labels.js +0 -75
- package/dist/es/components/trend-chart/helpers/genPath.js +0 -22
- package/dist/es/components/trend-chart/helpers/getPadding.js +0 -21
- package/dist/es/components/trend-chart/helpers/validatePadding.js +0 -7
|
@@ -1,250 +1,210 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const we = /* @__PURE__ */ Z({
|
|
12
|
-
name: re("TrendChart"),
|
|
1
|
+
import { defineComponent as B, useId as U, reactive as _, computed as l, ref as j, onMounted as H, onUnmounted as q, watch as N, nextTick as J, createVNode as m, h as K, Fragment as Q, mergeProps as Z } from "vue";
|
|
2
|
+
import p from "../helpers/genPoints.js";
|
|
3
|
+
import { useLocale as ee } from "../../../locale/index.js";
|
|
4
|
+
import R from "./trend-chart-curve.js";
|
|
5
|
+
import { getComponentPrefix as te } from "../../../_utils/config.js";
|
|
6
|
+
import { trendChartProps as ne } from "../props.js";
|
|
7
|
+
import { TrendChartTheme as d } from "../themes.js";
|
|
8
|
+
import { getPadding as ae } from "../../../_utils/chart/padding.js";
|
|
9
|
+
const ce = /* @__PURE__ */ B({
|
|
10
|
+
name: te("TrendChart"),
|
|
13
11
|
components: {
|
|
14
|
-
|
|
15
|
-
TrendChartLabels: E,
|
|
16
|
-
TrendChartCurve: $
|
|
12
|
+
TrendChartCurve: R
|
|
17
13
|
},
|
|
18
|
-
props:
|
|
14
|
+
props: ne,
|
|
19
15
|
emits: {
|
|
20
16
|
"mouse-move": (t) => !0
|
|
21
17
|
},
|
|
22
18
|
setup(t, {
|
|
23
|
-
emit:
|
|
19
|
+
emit: y
|
|
24
20
|
}) {
|
|
25
21
|
const {
|
|
26
|
-
t:
|
|
27
|
-
} =
|
|
22
|
+
t: T
|
|
23
|
+
} = ee(), C = `x-trend-chart-clip-${U()}`, i = _({
|
|
28
24
|
width: null,
|
|
29
25
|
height: null,
|
|
30
|
-
labelsOverflowObject: {
|
|
31
|
-
top: 0,
|
|
32
|
-
right: 0,
|
|
33
|
-
bottom: 0,
|
|
34
|
-
left: 0
|
|
35
|
-
},
|
|
36
26
|
activeIndex: null
|
|
37
|
-
}),
|
|
27
|
+
}), k = (e, n = {}) => ({
|
|
38
28
|
...e,
|
|
39
|
-
...
|
|
29
|
+
...n,
|
|
40
30
|
stroke: {
|
|
41
31
|
...e.stroke,
|
|
42
|
-
...
|
|
43
|
-
color:
|
|
32
|
+
...n.color ? {
|
|
33
|
+
color: n.color
|
|
44
34
|
} : {},
|
|
45
|
-
...
|
|
35
|
+
...n.stroke
|
|
46
36
|
},
|
|
47
37
|
fill: {
|
|
48
38
|
...e.fill,
|
|
49
|
-
...
|
|
50
|
-
color:
|
|
39
|
+
...n.color ? {
|
|
40
|
+
color: n.color
|
|
51
41
|
} : {},
|
|
52
|
-
...
|
|
42
|
+
...n.fill
|
|
53
43
|
},
|
|
54
44
|
point: {
|
|
55
45
|
...e.point,
|
|
56
|
-
...
|
|
57
|
-
color:
|
|
46
|
+
...n.color ? {
|
|
47
|
+
color: n.color
|
|
58
48
|
} : {},
|
|
59
|
-
...
|
|
49
|
+
...n.point
|
|
60
50
|
},
|
|
61
51
|
axisLine: {
|
|
62
52
|
...e.axisLine,
|
|
63
|
-
...
|
|
64
|
-
color:
|
|
53
|
+
...n.color ? {
|
|
54
|
+
color: n.color
|
|
65
55
|
} : {},
|
|
66
|
-
...
|
|
56
|
+
...n.axisLine
|
|
67
57
|
}
|
|
68
|
-
}),
|
|
69
|
-
let e =
|
|
70
|
-
return t.status === "success" ? e =
|
|
71
|
-
}),
|
|
72
|
-
const e = Number(
|
|
58
|
+
}), x = l(() => {
|
|
59
|
+
let e = d.PRIMARY;
|
|
60
|
+
return t.status === "success" ? e = d.SUCCESS : t.status === "danger" ? e = d.DANGER : t.status === "warning" ? e = d.WARNING : t.status === "strong" ? e = d.STRONG : t.status === "info" && (e = d.INFO), k(e, t.theme);
|
|
61
|
+
}), c = l(() => t.dataset.filter((e) => Number.isFinite(e))), V = l(() => c.value.length > 0), g = l(() => ae(t.padding)), a = l(() => {
|
|
62
|
+
const e = Number(g.value.left), n = Number(g.value.top), u = Math.max(e, (i.width ?? 0) - Number(g.value.right)), o = Math.max(n, (i.height ?? 0) - Number(g.value.bottom));
|
|
73
63
|
return {
|
|
74
64
|
minX: e,
|
|
75
|
-
minY:
|
|
76
|
-
maxX:
|
|
65
|
+
minY: n,
|
|
66
|
+
maxX: u,
|
|
77
67
|
maxY: o
|
|
78
68
|
};
|
|
79
|
-
}), r =
|
|
80
|
-
const e =
|
|
81
|
-
let o = Number.isFinite(t.max) ? t.max :
|
|
82
|
-
return
|
|
69
|
+
}), r = l(() => {
|
|
70
|
+
const e = c.value, n = e.length ? Math.max(...e) : 0, u = e.length ? Math.min(...e) : 0;
|
|
71
|
+
let o = Number.isFinite(t.max) ? t.max : n, v = Number.isFinite(t.min) ? t.min : u;
|
|
72
|
+
return v > o && ([v, o] = [o, v]), {
|
|
83
73
|
maxValue: o,
|
|
84
|
-
minValue:
|
|
74
|
+
minValue: v,
|
|
85
75
|
maxAmount: e.length
|
|
86
76
|
};
|
|
87
|
-
}),
|
|
77
|
+
}), F = l(() => ({
|
|
88
78
|
width: typeof t.width == "number" ? `${t.width}px` : t.width,
|
|
89
79
|
height: typeof t.height == "number" ? `${t.height}px` : t.height
|
|
90
|
-
})),
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
80
|
+
})), f = l(() => a.value.maxX - a.value.minX), b = l(() => a.value.maxY - a.value.minY), S = l(() => {
|
|
81
|
+
var n, u;
|
|
82
|
+
if (t.showPoints === !1) return 0;
|
|
83
|
+
const e = Number(((u = (n = x.value) == null ? void 0 : n.point) == null ? void 0 : u.width) ?? 3);
|
|
84
|
+
return Number.isFinite(e) && e > 0 ? e + 1 : 0;
|
|
85
|
+
}), w = l(() => {
|
|
86
|
+
const e = S.value;
|
|
87
|
+
return {
|
|
88
|
+
x: a.value.minX - e,
|
|
89
|
+
y: a.value.minY - e,
|
|
90
|
+
width: f.value + e * 2,
|
|
91
|
+
height: b.value + e * 2
|
|
92
|
+
};
|
|
93
|
+
}), z = l(() => ({
|
|
94
|
+
x: a.value.minX,
|
|
95
|
+
y: a.value.minY,
|
|
96
|
+
width: f.value,
|
|
97
|
+
height: b.value,
|
|
95
98
|
opacity: 0
|
|
96
|
-
})),
|
|
97
|
-
x:
|
|
98
|
-
y:
|
|
99
|
-
})),
|
|
99
|
+
})), L = l(() => ({
|
|
100
|
+
x: a.value.minX + f.value / 2,
|
|
101
|
+
y: a.value.minY + b.value / 2
|
|
102
|
+
})), P = l(() => {
|
|
100
103
|
if (r.value.maxAmount <= 0)
|
|
101
104
|
return [];
|
|
102
105
|
if (r.value.maxAmount === 1)
|
|
103
|
-
return [Math.round(
|
|
104
|
-
const e =
|
|
106
|
+
return [Math.round(a.value.minX + f.value / 2)];
|
|
107
|
+
const e = f.value / (r.value.maxAmount - 1);
|
|
105
108
|
return Array.from({
|
|
106
109
|
length: r.value.maxAmount
|
|
107
|
-
}, (
|
|
108
|
-
}),
|
|
109
|
-
const e =
|
|
110
|
-
return e ? Math.min(Math.max(e.y,
|
|
111
|
-
}),
|
|
112
|
-
if (
|
|
113
|
-
const e =
|
|
114
|
-
|
|
110
|
+
}, (n, u) => Math.round(a.value.minX + e * u));
|
|
111
|
+
}), I = l(() => i.activeIndex === null ? null : P.value[i.activeIndex] ?? null), O = l(() => p(c.value, a.value, r.value.maxValue, r.value.minValue, r.value.maxAmount)), E = l(() => {
|
|
112
|
+
const e = i.activeIndex === null ? null : O.value[i.activeIndex];
|
|
113
|
+
return e ? Math.min(Math.max(e.y, a.value.minY), a.value.maxY) : a.value.minY;
|
|
114
|
+
}), s = j(null), M = () => {
|
|
115
|
+
if (s.value) {
|
|
116
|
+
const e = s.value.getBoundingClientRect();
|
|
117
|
+
i.width = e.width, i.height = e.height;
|
|
115
118
|
}
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
left: 0
|
|
122
|
-
};
|
|
123
|
-
}, I = () => {
|
|
124
|
-
if (v.value && M.value) {
|
|
125
|
-
const e = v.value.getBoundingClientRect(), l = M.value.$el.getBoundingClientRect();
|
|
126
|
-
a.labelsOverflowObject = {
|
|
127
|
-
top: Math.max(0, Number(e.top) - Number(l.top) + Number(c.value.top)),
|
|
128
|
-
right: Math.max(0, Number(l.right) - Number(e.right) + Number(c.value.right)),
|
|
129
|
-
bottom: Math.max(0, Number(l.bottom) - Number(e.bottom) + Number(c.value.bottom)),
|
|
130
|
-
left: Math.max(0, Number(c.value.left) - Number(l.left) + Number(e.left))
|
|
131
|
-
};
|
|
132
|
-
} else
|
|
133
|
-
C();
|
|
134
|
-
}, P = () => {
|
|
135
|
-
O(), f(() => {
|
|
136
|
-
C(), f(I);
|
|
137
|
-
});
|
|
138
|
-
}, q = (e) => {
|
|
139
|
-
const l = X.value;
|
|
140
|
-
if (!l.length)
|
|
119
|
+
}, X = () => {
|
|
120
|
+
M();
|
|
121
|
+
}, D = (e) => {
|
|
122
|
+
const n = P.value;
|
|
123
|
+
if (!n.length)
|
|
141
124
|
return null;
|
|
142
|
-
let
|
|
143
|
-
return
|
|
144
|
-
Math.abs(o - e) < Math.abs(
|
|
145
|
-
}),
|
|
146
|
-
},
|
|
147
|
-
if (
|
|
148
|
-
const
|
|
149
|
-
|
|
125
|
+
let u = 0;
|
|
126
|
+
return n.forEach((o, v) => {
|
|
127
|
+
Math.abs(o - e) < Math.abs(n[u] - e) && (u = v);
|
|
128
|
+
}), u;
|
|
129
|
+
}, G = (e) => {
|
|
130
|
+
if (s.value) {
|
|
131
|
+
const n = s.value.getBoundingClientRect();
|
|
132
|
+
i.activeIndex = D(e.clientX - n.left);
|
|
150
133
|
}
|
|
151
|
-
},
|
|
152
|
-
|
|
134
|
+
}, W = () => {
|
|
135
|
+
i.activeIndex = null;
|
|
153
136
|
};
|
|
154
|
-
let
|
|
155
|
-
const
|
|
156
|
-
typeof ResizeObserver > "u" || !
|
|
157
|
-
|
|
158
|
-
}),
|
|
159
|
-
},
|
|
160
|
-
|
|
137
|
+
let h = null;
|
|
138
|
+
const $ = () => {
|
|
139
|
+
typeof ResizeObserver > "u" || !s.value || (h = new ResizeObserver(() => {
|
|
140
|
+
X();
|
|
141
|
+
}), h.observe(s.value));
|
|
142
|
+
}, A = () => {
|
|
143
|
+
X();
|
|
161
144
|
};
|
|
162
|
-
return
|
|
163
|
-
|
|
164
|
-
}),
|
|
165
|
-
|
|
166
|
-
}), N(() =>
|
|
145
|
+
return H(() => {
|
|
146
|
+
M(), $(), window.addEventListener("resize", A);
|
|
147
|
+
}), q(() => {
|
|
148
|
+
h == null || h.disconnect(), h = null, window.removeEventListener("resize", A);
|
|
149
|
+
}), N(() => i.activeIndex, (e) => {
|
|
167
150
|
if (e !== null) {
|
|
168
|
-
const
|
|
169
|
-
if (
|
|
170
|
-
|
|
151
|
+
const n = c.value[e];
|
|
152
|
+
if (n === void 0) {
|
|
153
|
+
y("mouse-move", null);
|
|
171
154
|
return;
|
|
172
155
|
}
|
|
173
|
-
|
|
156
|
+
y("mouse-move", {
|
|
174
157
|
index: e,
|
|
175
|
-
data:
|
|
158
|
+
data: n
|
|
176
159
|
});
|
|
177
160
|
} else
|
|
178
|
-
|
|
179
|
-
}), N(
|
|
180
|
-
|
|
181
|
-
}), N(() => [t.
|
|
182
|
-
|
|
183
|
-
O(), f(I);
|
|
184
|
-
});
|
|
185
|
-
}, {
|
|
186
|
-
deep: !0
|
|
187
|
-
}), N(() => {
|
|
188
|
-
var e, l, i, o;
|
|
189
|
-
return [(e = t.grid) == null ? void 0 : e.verticalLines, (l = t.grid) == null ? void 0 : l.verticalLinesNumber, (o = (i = t.labels) == null ? void 0 : i.xLabels) == null ? void 0 : o.length, h.value.length];
|
|
190
|
-
}, () => {
|
|
161
|
+
y("mouse-move", null);
|
|
162
|
+
}), N(c, (e) => {
|
|
163
|
+
i.activeIndex !== null && i.activeIndex >= e.length && (i.activeIndex = null);
|
|
164
|
+
}), N(() => [t.dataset, t.min, t.max, t.padding, t.height], () => {
|
|
165
|
+
J(M);
|
|
191
166
|
}, {
|
|
192
|
-
immediate: !0,
|
|
193
167
|
deep: !0
|
|
194
168
|
}), () => {
|
|
195
|
-
var e,
|
|
169
|
+
var e, n, u, o, v, Y;
|
|
196
170
|
return m("svg", {
|
|
197
171
|
class: "x-trend-chart",
|
|
198
|
-
ref:
|
|
172
|
+
ref: s,
|
|
199
173
|
xmlns: "http://www.w3.org/2000/svg",
|
|
200
174
|
width: "100%",
|
|
201
175
|
height: "100%",
|
|
202
|
-
style:
|
|
176
|
+
style: F.value,
|
|
203
177
|
role: t.ariaLabel ? "img" : void 0,
|
|
204
178
|
"aria-label": t.ariaLabel
|
|
205
179
|
}, [m("defs", null, [m("clipPath", {
|
|
206
|
-
id:
|
|
180
|
+
id: C
|
|
207
181
|
}, [m("rect", {
|
|
208
|
-
x:
|
|
209
|
-
y:
|
|
210
|
-
width: Math.max(0,
|
|
211
|
-
height: Math.max(0,
|
|
212
|
-
}, null)])]),
|
|
213
|
-
class: "grid",
|
|
214
|
-
verticalLines: t.grid.verticalLines,
|
|
215
|
-
verticalLinesNumber: t.grid.verticalLinesNumber || ((l = (e = t.labels) == null ? void 0 : e.xLabels) == null ? void 0 : l.length) || r.value.maxAmount,
|
|
216
|
-
horizontalLines: t.grid.horizontalLines,
|
|
217
|
-
horizontalLinesNumber: t.grid.horizontalLinesNumber || ((i = t.labels) == null ? void 0 : i.yLabels) || 4,
|
|
218
|
-
boundary: n.value
|
|
219
|
-
}, null), t.labels && m(E, S({
|
|
220
|
-
ref: M,
|
|
221
|
-
class: "labels"
|
|
222
|
-
}, t.labels, {
|
|
223
|
-
boundary: n.value,
|
|
224
|
-
minValue: r.value.minValue,
|
|
225
|
-
maxValue: r.value.maxValue
|
|
226
|
-
}), null), m($, {
|
|
182
|
+
x: w.value.x,
|
|
183
|
+
y: w.value.y,
|
|
184
|
+
width: Math.max(0, w.value.width),
|
|
185
|
+
height: Math.max(0, w.value.height)
|
|
186
|
+
}, null)])]), m(R, {
|
|
227
187
|
class: "curve",
|
|
228
|
-
data:
|
|
229
|
-
boundary:
|
|
188
|
+
data: c.value,
|
|
189
|
+
boundary: a.value,
|
|
230
190
|
minValue: r.value.minValue,
|
|
231
191
|
maxValue: r.value.maxValue,
|
|
232
192
|
maxAmount: r.value.maxAmount,
|
|
233
|
-
activeLineParams:
|
|
234
|
-
index:
|
|
193
|
+
activeLineParams: i.activeIndex === null ? null : {
|
|
194
|
+
index: i.activeIndex
|
|
235
195
|
},
|
|
236
|
-
clipPath: `url(#${
|
|
196
|
+
clipPath: `url(#${C})`,
|
|
237
197
|
smooth: t.smooth,
|
|
238
198
|
stroke: t.stroke,
|
|
239
199
|
fill: t.fill,
|
|
240
200
|
showPoints: t.showPoints,
|
|
241
201
|
tooltip: t.tooltip,
|
|
242
202
|
tooltipFormatter: t.tooltipFormatter,
|
|
243
|
-
theme:
|
|
244
|
-
}, null), !
|
|
203
|
+
theme: x.value
|
|
204
|
+
}, null), !V.value && K("text", {
|
|
245
205
|
class: "x-trend-chart-empty",
|
|
246
|
-
x:
|
|
247
|
-
y:
|
|
206
|
+
x: L.value.x,
|
|
207
|
+
y: L.value.y,
|
|
248
208
|
"text-anchor": "middle",
|
|
249
209
|
"dominant-baseline": "middle",
|
|
250
210
|
style: {
|
|
@@ -252,27 +212,27 @@ const we = /* @__PURE__ */ Z({
|
|
|
252
212
|
fontSize: "12px",
|
|
253
213
|
pointerEvents: "none"
|
|
254
214
|
}
|
|
255
|
-
},
|
|
215
|
+
}, T("common.noData")), t.interactive && m(Q, null, [m("line", {
|
|
256
216
|
class: "x-trend-chart-active-line",
|
|
257
|
-
x1:
|
|
258
|
-
x2:
|
|
259
|
-
y1:
|
|
260
|
-
y2:
|
|
261
|
-
visibility:
|
|
217
|
+
x1: I.value ?? a.value.minX,
|
|
218
|
+
x2: I.value ?? a.value.minX,
|
|
219
|
+
y1: E.value,
|
|
220
|
+
y2: a.value.maxY,
|
|
221
|
+
visibility: I.value !== null ? "visible" : "hidden",
|
|
262
222
|
style: {
|
|
263
|
-
stroke: (
|
|
264
|
-
strokeWidth: (
|
|
265
|
-
strokeOpacity: (
|
|
223
|
+
stroke: (n = (e = x.value) == null ? void 0 : e.axisLine) == null ? void 0 : n.color,
|
|
224
|
+
strokeWidth: (o = (u = x.value) == null ? void 0 : u.axisLine) == null ? void 0 : o.width,
|
|
225
|
+
strokeOpacity: (Y = (v = x.value) == null ? void 0 : v.axisLine) == null ? void 0 : Y.opacity
|
|
266
226
|
}
|
|
267
|
-
}, null), m("rect",
|
|
227
|
+
}, null), m("rect", Z({
|
|
268
228
|
class: "x-trend-chart-overlay"
|
|
269
|
-
},
|
|
270
|
-
onMousemove:
|
|
271
|
-
onMouseout:
|
|
229
|
+
}, z.value, {
|
|
230
|
+
onMousemove: G,
|
|
231
|
+
onMouseout: W
|
|
272
232
|
}), null)])]);
|
|
273
233
|
};
|
|
274
234
|
}
|
|
275
235
|
});
|
|
276
236
|
export {
|
|
277
|
-
|
|
237
|
+
ce as default
|
|
278
238
|
};
|
|
@@ -1,106 +1,110 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { defineComponent as I, useId as M, computed as i, createVNode as o } from "vue";
|
|
2
|
+
import N from "../helpers/genPoints.js";
|
|
3
|
+
import { getComponentPrefix as R } from "../../../_utils/config.js";
|
|
4
|
+
import { trendChartCurveProps as A } from "../props.js";
|
|
5
|
+
import { genAreaPath as G, genLinePath as H } from "../../../_utils/chart/path.js";
|
|
6
|
+
import { estimateTextWidth as L } from "../../../_utils/chart/scale.js";
|
|
7
|
+
const j = /* @__PURE__ */ I({
|
|
8
|
+
name: R("TrendChartCurve"),
|
|
9
|
+
props: A,
|
|
10
|
+
setup(t) {
|
|
11
|
+
const b = `x-trend-chart-fill-${M()}`, h = i(() => N(t.data, t.boundary, t.maxValue, t.minValue, t.maxAmount)), y = i(() => ({
|
|
12
|
+
linePath: H(h.value, t.smooth),
|
|
13
|
+
fillPath: G(h.value, t.boundary.maxY, t.smooth)
|
|
14
|
+
})), k = i(() => {
|
|
15
|
+
var e;
|
|
16
|
+
return t.fill && ((e = y.value) == null ? void 0 : e.fillPath) && h.value.length > 1 && t.maxValue !== t.minValue;
|
|
17
|
+
}), x = i(() => {
|
|
18
|
+
var e, l;
|
|
19
|
+
return ((l = (e = t.theme) == null ? void 0 : e.fill) == null ? void 0 : l.color) || "var(--x-color-text-secondary)";
|
|
20
|
+
}), P = i(() => {
|
|
21
|
+
var e, l;
|
|
22
|
+
return ((l = (e = t.theme) == null ? void 0 : e.fill) == null ? void 0 : l.opacity) ?? 0.1;
|
|
19
23
|
}), g = i(() => {
|
|
20
|
-
var
|
|
21
|
-
return (((l = (
|
|
22
|
-
}),
|
|
23
|
-
var
|
|
24
|
-
return ((
|
|
25
|
-
}), C = 18,
|
|
26
|
-
if (
|
|
27
|
-
if (
|
|
28
|
-
const
|
|
29
|
-
return
|
|
30
|
-
}),
|
|
31
|
-
var
|
|
32
|
-
const l = ((
|
|
33
|
-
return
|
|
34
|
-
},
|
|
35
|
-
var
|
|
36
|
-
const l = ((
|
|
37
|
-
return
|
|
24
|
+
var e, l;
|
|
25
|
+
return (((l = (e = t.theme) == null ? void 0 : e.fill) == null ? void 0 : l.type) ?? "gradient") === "gradient";
|
|
26
|
+
}), s = i(() => {
|
|
27
|
+
var e;
|
|
28
|
+
return ((e = t.activeLineParams) == null ? void 0 : e.index) ?? -1;
|
|
29
|
+
}), C = 18, X = i(() => {
|
|
30
|
+
if (t.showPoints === !1) return !1;
|
|
31
|
+
if (t.showPoints === !0) return !0;
|
|
32
|
+
const e = h.value.length;
|
|
33
|
+
return e <= 2 ? !0 : (t.boundary.maxX - t.boundary.minX) / (e - 1) >= C;
|
|
34
|
+
}), w = (e) => {
|
|
35
|
+
var n, a;
|
|
36
|
+
const l = ((a = (n = t.theme) == null ? void 0 : n.point) == null ? void 0 : a.width) ?? 3;
|
|
37
|
+
return e ? l + 1 : l;
|
|
38
|
+
}, T = (e) => {
|
|
39
|
+
var n, a, d, r, u, c;
|
|
40
|
+
const l = ((a = (n = t.theme) == null ? void 0 : n.point) == null ? void 0 : a.color) ?? ((r = (d = t.theme) == null ? void 0 : d.stroke) == null ? void 0 : r.color);
|
|
41
|
+
return e ? {
|
|
38
42
|
fill: l,
|
|
39
43
|
stroke: l,
|
|
40
44
|
strokeWidth: 1
|
|
41
45
|
} : {
|
|
42
46
|
fill: l,
|
|
43
|
-
opacity: (
|
|
47
|
+
opacity: (c = (u = t.theme) == null ? void 0 : u.point) == null ? void 0 : c.opacity
|
|
44
48
|
};
|
|
45
|
-
},
|
|
46
|
-
var
|
|
47
|
-
const
|
|
48
|
-
k.value &&
|
|
49
|
+
}, V = i(() => {
|
|
50
|
+
var n, a, d, r, u, c, v;
|
|
51
|
+
const e = [];
|
|
52
|
+
k.value && e.push(o("path", {
|
|
49
53
|
class: "x-trend-chart-fill",
|
|
50
|
-
d:
|
|
54
|
+
d: y.value.fillPath,
|
|
51
55
|
fill: "none",
|
|
52
56
|
style: {
|
|
53
|
-
fill: g.value ? `url(#${
|
|
54
|
-
opacity: g.value ? 1 :
|
|
57
|
+
fill: g.value ? `url(#${b})` : x.value,
|
|
58
|
+
opacity: g.value ? 1 : P.value
|
|
55
59
|
}
|
|
56
|
-
}, null)),
|
|
60
|
+
}, null)), t.stroke && ((n = y.value) != null && n.linePath) && e.push(o("path", {
|
|
57
61
|
class: "x-trend-chart-stroke",
|
|
58
|
-
d:
|
|
62
|
+
d: y.value.linePath,
|
|
59
63
|
fill: "none",
|
|
60
64
|
stroke: "none",
|
|
61
65
|
"stroke-linecap": "round",
|
|
62
66
|
"stroke-linejoin": "round",
|
|
63
67
|
style: {
|
|
64
|
-
stroke: (
|
|
65
|
-
strokeWidth: (
|
|
66
|
-
opacity: (
|
|
68
|
+
stroke: (d = (a = t.theme) == null ? void 0 : a.stroke) == null ? void 0 : d.color,
|
|
69
|
+
strokeWidth: (u = (r = t.theme) == null ? void 0 : r.stroke) == null ? void 0 : u.width,
|
|
70
|
+
opacity: (v = (c = t.theme) == null ? void 0 : c.stroke) == null ? void 0 : v.opacity
|
|
67
71
|
}
|
|
68
72
|
}, null));
|
|
69
|
-
const l = h.value.map((
|
|
70
|
-
point:
|
|
71
|
-
index:
|
|
73
|
+
const l = h.value.map((m, f) => ({
|
|
74
|
+
point: m,
|
|
75
|
+
index: f
|
|
72
76
|
})).filter(({
|
|
73
|
-
index:
|
|
74
|
-
}) =>
|
|
75
|
-
return l.length &&
|
|
77
|
+
index: m
|
|
78
|
+
}) => X.value || m === s.value);
|
|
79
|
+
return l.length && e.push(o("g", {
|
|
76
80
|
class: "x-trend-chart-points"
|
|
77
81
|
}, [l.map(({
|
|
78
|
-
point:
|
|
79
|
-
index:
|
|
82
|
+
point: m,
|
|
83
|
+
index: f
|
|
80
84
|
}) => o("circle", {
|
|
81
|
-
key:
|
|
85
|
+
key: f,
|
|
82
86
|
class: {
|
|
83
87
|
point: !0,
|
|
84
|
-
"x-trend-chart-point-active":
|
|
88
|
+
"x-trend-chart-point-active": s.value === f
|
|
85
89
|
},
|
|
86
|
-
cx:
|
|
87
|
-
cy:
|
|
88
|
-
r:
|
|
89
|
-
style:
|
|
90
|
-
}, null))])),
|
|
91
|
-
}),
|
|
92
|
-
const
|
|
93
|
-
if (!
|
|
90
|
+
cx: m.x,
|
|
91
|
+
cy: m.y,
|
|
92
|
+
r: w(s.value === f),
|
|
93
|
+
style: T(s.value === f)
|
|
94
|
+
}, null))])), e;
|
|
95
|
+
}), W = i(() => {
|
|
96
|
+
const e = h.value[s.value];
|
|
97
|
+
if (!t.tooltip || s.value < 0 || !e)
|
|
94
98
|
return null;
|
|
95
|
-
const l =
|
|
99
|
+
const l = t.tooltipFormatter(t.data[s.value]), n = Math.max(24, Math.round(L(l, 12)) + 12), a = 18, r = e.y - a - 6 >= t.boundary.minY ? e.y - a - 6 : e.y + 6, u = t.boundary.minX + n / 2, c = t.boundary.maxX - n / 2, v = c >= u ? Math.min(Math.max(e.x, u), c) : (t.boundary.minX + t.boundary.maxX) / 2;
|
|
96
100
|
return o("g", {
|
|
97
101
|
class: "x-trend-chart-tooltip",
|
|
98
102
|
"pointer-events": "none"
|
|
99
103
|
}, [o("rect", {
|
|
100
|
-
x:
|
|
104
|
+
x: v - n / 2,
|
|
101
105
|
y: r,
|
|
102
|
-
width:
|
|
103
|
-
height:
|
|
106
|
+
width: n,
|
|
107
|
+
height: a,
|
|
104
108
|
rx: 4,
|
|
105
109
|
style: {
|
|
106
110
|
fill: "var(--x-color-bg-popup)",
|
|
@@ -108,8 +112,8 @@ const _ = /* @__PURE__ */ T({
|
|
|
108
112
|
strokeWidth: 1
|
|
109
113
|
}
|
|
110
114
|
}, null), o("text", {
|
|
111
|
-
x:
|
|
112
|
-
y: r +
|
|
115
|
+
x: v,
|
|
116
|
+
y: r + a / 2,
|
|
113
117
|
"text-anchor": "middle",
|
|
114
118
|
"dominant-baseline": "middle",
|
|
115
119
|
style: {
|
|
@@ -119,26 +123,26 @@ const _ = /* @__PURE__ */ T({
|
|
|
119
123
|
}, [l])]);
|
|
120
124
|
});
|
|
121
125
|
return () => o("g", {
|
|
122
|
-
class:
|
|
126
|
+
class: t.className
|
|
123
127
|
}, [o("defs", null, [o("linearGradient", {
|
|
124
|
-
id:
|
|
128
|
+
id: b,
|
|
125
129
|
x1: "0",
|
|
126
130
|
y1: "0",
|
|
127
131
|
x2: "0",
|
|
128
132
|
y2: "1"
|
|
129
133
|
}, [o("stop", {
|
|
130
134
|
offset: "0%",
|
|
131
|
-
"stop-color":
|
|
132
|
-
"stop-opacity":
|
|
135
|
+
"stop-color": x.value,
|
|
136
|
+
"stop-opacity": P.value
|
|
133
137
|
}, null), o("stop", {
|
|
134
138
|
offset: "100%",
|
|
135
|
-
"stop-color":
|
|
139
|
+
"stop-color": x.value,
|
|
136
140
|
"stop-opacity": "0"
|
|
137
141
|
}, null)])]), o("g", {
|
|
138
|
-
"clip-path":
|
|
139
|
-
}, [
|
|
142
|
+
"clip-path": t.clipPath
|
|
143
|
+
}, [V.value]), W.value]);
|
|
140
144
|
}
|
|
141
145
|
});
|
|
142
146
|
export {
|
|
143
|
-
|
|
147
|
+
j as default
|
|
144
148
|
};
|