vue-chrts 0.1.0 → 0.1.1-test.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineComponent as E, ref as T, computed as
|
|
2
|
-
import { Position as
|
|
3
|
-
import { VisXYContainer as
|
|
4
|
-
import
|
|
5
|
-
import { LegendPosition as
|
|
6
|
-
const
|
|
1
|
+
import { defineComponent as E, ref as T, computed as f, createApp as N, onUnmounted as P, createElementBlock as u, openBlock as l, normalizeClass as L, createVNode as s, createCommentVNode as g, unref as o, withCtx as M, createBlock as h, Fragment as b, renderList as U, mergeProps as j } from "vue";
|
|
2
|
+
import { Position as C, CurveType as x } from "@unovis/ts";
|
|
3
|
+
import { VisXYContainer as I, VisTooltip as S, VisArea as w, VisLine as z, VisAxis as B, VisCrosshair as R, VisBulletLegend as X } from "@unovis/vue";
|
|
4
|
+
import Y from "../Tooltip.js";
|
|
5
|
+
import { LegendPosition as H } from "../../types.js";
|
|
6
|
+
const p = 24, V = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ E({
|
|
7
7
|
__name: "AreaChart",
|
|
8
8
|
props: {
|
|
9
9
|
data: {},
|
|
@@ -14,10 +14,10 @@ const m = 24, A = 4, Y = 0.5, H = "#3b82f6", Z = /* @__PURE__ */ E({
|
|
|
14
14
|
xFormatter: {},
|
|
15
15
|
yFormatter: {},
|
|
16
16
|
curveType: {},
|
|
17
|
-
xNumTicks: { default: (i) => i.data.length >
|
|
17
|
+
xNumTicks: { default: (i) => i.data.length > p ? p / V : i.data.length - 1 },
|
|
18
18
|
xExplicitTicks: {},
|
|
19
19
|
minMaxTicksOnly: { type: Boolean },
|
|
20
|
-
yNumTicks: { default: (i) => i.data.length >
|
|
20
|
+
yNumTicks: { default: (i) => i.data.length > p ? p / V : i.data.length - 1 },
|
|
21
21
|
hideLegend: { type: Boolean },
|
|
22
22
|
hideTooltip: { type: Boolean },
|
|
23
23
|
xGridLine: { type: Boolean },
|
|
@@ -28,74 +28,83 @@ const m = 24, A = 4, Y = 0.5, H = "#3b82f6", Z = /* @__PURE__ */ E({
|
|
|
28
28
|
legendPosition: {}
|
|
29
29
|
},
|
|
30
30
|
setup(i) {
|
|
31
|
-
const
|
|
31
|
+
const r = i, m = Object.values(r.categories).map((e) => e.color), d = T(null), v = T(null), D = f(() => (e, t) => {
|
|
32
32
|
if (typeof window > "u" || typeof document > "u")
|
|
33
33
|
return "";
|
|
34
34
|
try {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return
|
|
45
|
-
} catch (t) {
|
|
46
|
-
return console.error("Error generating tooltip:", t), "";
|
|
35
|
+
const n = N(Y, {
|
|
36
|
+
data: e,
|
|
37
|
+
categories: r.categories,
|
|
38
|
+
xValue: r.xFormatter(Math.floor(t))
|
|
39
|
+
}), a = document.createElement("div");
|
|
40
|
+
n.mount(a);
|
|
41
|
+
const c = a.innerHTML;
|
|
42
|
+
return n.unmount(), c;
|
|
43
|
+
} catch {
|
|
44
|
+
return "";
|
|
47
45
|
}
|
|
48
46
|
});
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
P(() => {
|
|
48
|
+
d.value && (d.value.unmount(), d.value = null), v.value && (v.value = null);
|
|
51
49
|
});
|
|
52
|
-
function
|
|
50
|
+
function F(e) {
|
|
53
51
|
var t;
|
|
54
52
|
return {
|
|
55
|
-
y: (
|
|
56
|
-
color: ((t =
|
|
53
|
+
y: (n) => Number(n[e]),
|
|
54
|
+
color: ((t = r.categories[e]) == null ? void 0 : t.color) ?? A
|
|
57
55
|
};
|
|
58
56
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
<
|
|
63
|
-
<stop offset="
|
|
64
|
-
|
|
57
|
+
function O(e, t) {
|
|
58
|
+
return `
|
|
59
|
+
<linearGradient id="gradient${e}-${t}" gradientTransform="rotate(90)">
|
|
60
|
+
<stop offset="0%" style="stop-color:var(--vis-color0);stop-opacity:1" />
|
|
61
|
+
<stop offset="100%" style="stop-color:var(--vis-color0);stop-opacity:0" />
|
|
62
|
+
</linearGradient>
|
|
63
|
+
`;
|
|
64
|
+
}
|
|
65
|
+
function G(e, t) {
|
|
66
|
+
return `
|
|
67
|
+
<linearGradient id="gradient${e}-${t}" gradientTransform="rotate(90)">
|
|
68
|
+
<stop offset="0%" stop-color="${t}" stop-opacity="1" />
|
|
69
|
+
<stop offset="100%" stop-color="${t}" stop-opacity="0" />
|
|
65
70
|
</linearGradient>
|
|
66
|
-
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
73
|
+
const $ = f(
|
|
74
|
+
() => m.map(
|
|
75
|
+
(e, t) => e != null && e.includes("#") ? G(t, e) : O(t, e ?? A)
|
|
67
76
|
).join("")
|
|
68
|
-
), k =
|
|
69
|
-
() =>
|
|
77
|
+
), k = f(
|
|
78
|
+
() => r.legendPosition === H.Top
|
|
70
79
|
);
|
|
71
|
-
return (e, t) => (
|
|
80
|
+
return (e, t) => (l(), u("div", {
|
|
72
81
|
class: L(["flex flex-col space-y-4", { "flex-col-reverse": k.value }])
|
|
73
82
|
}, [
|
|
74
|
-
s(o(
|
|
83
|
+
s(o(I), {
|
|
75
84
|
data: e.data,
|
|
76
85
|
height: e.height,
|
|
77
|
-
"svg-defs":
|
|
86
|
+
"svg-defs": $.value
|
|
78
87
|
}, {
|
|
79
|
-
default:
|
|
80
|
-
e.hideTooltip ?
|
|
88
|
+
default: M(() => [
|
|
89
|
+
e.hideTooltip ? g("", !0) : (l(), h(o(S), {
|
|
81
90
|
key: 0,
|
|
82
|
-
"horizontal-placement": o(
|
|
83
|
-
"vertical-placement": o(
|
|
91
|
+
"horizontal-placement": o(C).Right,
|
|
92
|
+
"vertical-placement": o(C).Top
|
|
84
93
|
}, null, 8, ["horizontal-placement", "vertical-placement"])),
|
|
85
|
-
(
|
|
86
|
-
s(o(
|
|
87
|
-
x: (
|
|
94
|
+
(l(!0), u(b, null, U(Object.keys(r.categories), (n, a) => (l(), u(b, { key: a }, [
|
|
95
|
+
s(o(w), j({
|
|
96
|
+
x: (c, y) => y,
|
|
88
97
|
ref_for: !0
|
|
89
|
-
},
|
|
90
|
-
color: `url(#gradient${
|
|
91
|
-
opacity:
|
|
92
|
-
"curve-type": e.curveType ?? o(
|
|
98
|
+
}, F(n), {
|
|
99
|
+
color: `url(#gradient${a}-${o(m)[a]})`,
|
|
100
|
+
opacity: q,
|
|
101
|
+
"curve-type": e.curveType ?? o(x).MonotoneX
|
|
93
102
|
}), null, 16, ["x", "color", "curve-type"]),
|
|
94
|
-
s(o(
|
|
95
|
-
x: (
|
|
96
|
-
y: (
|
|
97
|
-
color: o(
|
|
98
|
-
"curve-type": e.curveType ?? o(
|
|
103
|
+
s(o(z), {
|
|
104
|
+
x: (c, y) => y,
|
|
105
|
+
y: (c) => c[n],
|
|
106
|
+
color: o(m)[a],
|
|
107
|
+
"curve-type": e.curveType ?? o(x).MonotoneX
|
|
99
108
|
}, null, 8, ["x", "y", "color", "curve-type"])
|
|
100
109
|
], 64))), 128)),
|
|
101
110
|
s(o(B), {
|
|
@@ -119,7 +128,7 @@ const m = 24, A = 4, Y = 0.5, H = "#3b82f6", Z = /* @__PURE__ */ E({
|
|
|
119
128
|
"domain-line": e.yDomainLine,
|
|
120
129
|
"tick-line": !!e.yGridLine
|
|
121
130
|
}, null, 8, ["num-ticks", "tick-format", "label", "grid-line", "domain-line", "tick-line"]),
|
|
122
|
-
e.hideTooltip ?
|
|
131
|
+
e.hideTooltip ? g("", !0) : (l(), h(o(R), {
|
|
123
132
|
key: 1,
|
|
124
133
|
color: "#666",
|
|
125
134
|
template: D.value
|
|
@@ -127,11 +136,11 @@ const m = 24, A = 4, Y = 0.5, H = "#3b82f6", Z = /* @__PURE__ */ E({
|
|
|
127
136
|
]),
|
|
128
137
|
_: 1
|
|
129
138
|
}, 8, ["data", "height", "svg-defs"]),
|
|
130
|
-
e.hideLegend ?
|
|
139
|
+
e.hideLegend ? g("", !0) : (l(), u("div", {
|
|
131
140
|
key: 0,
|
|
132
141
|
class: L(["flex items-center justify-end", { "pb-4": k.value }])
|
|
133
142
|
}, [
|
|
134
|
-
s(o(
|
|
143
|
+
s(o(X), {
|
|
135
144
|
items: Object.values(e.categories)
|
|
136
145
|
}, null, 8, ["items"])
|
|
137
146
|
], 2))
|
|
@@ -139,5 +148,5 @@ const m = 24, A = 4, Y = 0.5, H = "#3b82f6", Z = /* @__PURE__ */ E({
|
|
|
139
148
|
}
|
|
140
149
|
});
|
|
141
150
|
export {
|
|
142
|
-
|
|
151
|
+
_ as default
|
|
143
152
|
};
|
|
@@ -1,37 +1,44 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as m, computed as b, createElementBlock as r, openBlock as l, createElementVNode as o, toDisplayString as i, Fragment as v, renderList as h, normalizeStyle as a } from "vue";
|
|
2
|
+
const x = {
|
|
3
|
+
class: "capitalize border-b mb-1 pb-1",
|
|
4
|
+
style: {
|
|
5
|
+
color: "var(--tooltip-value-color)",
|
|
6
|
+
borderColor: "rgba(255, 255, 255, 0.05)"
|
|
7
|
+
}
|
|
8
|
+
}, f = /* @__PURE__ */ m({
|
|
3
9
|
__name: "Tooltip",
|
|
4
10
|
props: {
|
|
5
11
|
data: {},
|
|
6
|
-
categories: {}
|
|
12
|
+
categories: {},
|
|
13
|
+
xValue: {}
|
|
7
14
|
},
|
|
8
15
|
setup(s) {
|
|
9
|
-
const
|
|
10
|
-
([
|
|
11
|
-
var e;
|
|
12
|
-
return !c.includes(t) && ((e = i.categories[t]) == null ? void 0 : e.color);
|
|
13
|
-
}
|
|
16
|
+
const n = s, c = ["_index", "_stacked", "_ending"], p = b(() => Object.entries(n.data ?? []).filter(
|
|
17
|
+
([e, d]) => !c.includes(e) && Object.keys(n.categories).includes(e)
|
|
14
18
|
));
|
|
15
|
-
return (
|
|
16
|
-
(
|
|
17
|
-
|
|
19
|
+
return (e, d) => (l(), r("div", null, [
|
|
20
|
+
o("div", x, i(e.xValue), 1),
|
|
21
|
+
(l(!0), r(v, null, h(p.value, ([t, u], g) => (l(), r("div", {
|
|
22
|
+
key: t,
|
|
18
23
|
style: { display: "flex", "align-items": "center", "margin-bottom": "4px" }
|
|
19
24
|
}, [
|
|
20
25
|
o("span", {
|
|
21
|
-
style:
|
|
26
|
+
style: a([{ width: "8px", height: "8px", "border-radius": "4px", "margin-right": "8px" }, {
|
|
27
|
+
backgroundColor: e.categories[t].color ? e.categories[t].color : `var(--vis-color${g})`
|
|
28
|
+
}])
|
|
22
29
|
}, null, 4),
|
|
23
30
|
o("div", null, [
|
|
24
31
|
o("span", {
|
|
25
|
-
style:
|
|
26
|
-
},
|
|
32
|
+
style: a([{ "font-weight": "600", "margin-right": "8px" }, { color: "var(--tooltip-label-color)" }])
|
|
33
|
+
}, i(t) + ":", 1),
|
|
27
34
|
o("span", {
|
|
28
|
-
style:
|
|
29
|
-
},
|
|
35
|
+
style: a([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
|
|
36
|
+
}, i(u), 1)
|
|
30
37
|
])
|
|
31
38
|
]))), 128))
|
|
32
39
|
]));
|
|
33
40
|
}
|
|
34
41
|
});
|
|
35
42
|
export {
|
|
36
|
-
|
|
43
|
+
f as default
|
|
37
44
|
};
|
|
@@ -3,6 +3,7 @@ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>
|
|
|
3
3
|
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & {
|
|
4
4
|
data: T;
|
|
5
5
|
categories: Record<string, BulletLegendItemInterface>;
|
|
6
|
+
xValue: string | number;
|
|
6
7
|
} & Partial<{}>> & import('vue').PublicProps;
|
|
7
8
|
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
8
9
|
attrs: any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-chrts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1-test.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@tailwindcss/vite": "^4.0.15",
|
|
26
26
|
"@tanstack/vue-table": "^8.21.2",
|
|
27
|
+
"@types/culori": "^2.1.1",
|
|
27
28
|
"@types/node": "^22.13.11",
|
|
28
29
|
"@unovis/ts": "^1.5.1",
|
|
29
30
|
"@unovis/vue": "^1.5.1",
|