vue-chrts 0.1.8 → 0.1.9
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/components/AreaChart/AreaChart.js +54 -55
- package/dist/components/BarChart/BarChart.js +4 -4
- package/dist/components/LineChart/LineChart.js +18 -16
- package/dist/components/Tooltip.js +18 -17
- package/dist/components/Tooltip.vue.d.ts +2 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +9 -0
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Position as
|
|
3
|
-
import { VisXYContainer as
|
|
4
|
-
import
|
|
5
|
-
import { LegendPosition as
|
|
6
|
-
|
|
1
|
+
import { defineComponent as A, computed as y, createApp as $, createElementBlock as c, openBlock as l, normalizeClass as T, createVNode as s, createCommentVNode as f, unref as o, withCtx as E, createBlock as k, Fragment as v, renderList as G, mergeProps as N } from "vue";
|
|
2
|
+
import { Position as L, CurveType as h } from "@unovis/ts";
|
|
3
|
+
import { VisXYContainer as P, VisTooltip as j, VisArea as I, VisLine as M, VisAxis as b, VisCrosshair as S, VisBulletLegend as U } from "@unovis/vue";
|
|
4
|
+
import w from "../Tooltip.js";
|
|
5
|
+
import { LegendPosition as z } from "../../types.js";
|
|
6
|
+
import { getFirstPropertyValue as R } from "../../utils.js";
|
|
7
|
+
const p = 24, C = 4, X = 0.5, B = "#3b82f6", Z = /* @__PURE__ */ A({
|
|
7
8
|
__name: "AreaChart",
|
|
8
9
|
props: {
|
|
9
10
|
data: {},
|
|
@@ -20,10 +21,10 @@ const p = 24, x = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
|
|
|
20
21
|
xFormatter: {},
|
|
21
22
|
yFormatter: {},
|
|
22
23
|
curveType: {},
|
|
23
|
-
xNumTicks: { default: (i) => i.data.length > p ? p /
|
|
24
|
+
xNumTicks: { default: (i) => i.data.length > p ? p / C : i.data.length - 1 },
|
|
24
25
|
xExplicitTicks: {},
|
|
25
26
|
minMaxTicksOnly: { type: Boolean },
|
|
26
|
-
yNumTicks: { default: (i) => i.data.length > p ? p /
|
|
27
|
+
yNumTicks: { default: (i) => i.data.length > p ? p / C : i.data.length - 1 },
|
|
27
28
|
hideLegend: { type: Boolean },
|
|
28
29
|
hideTooltip: { type: Boolean },
|
|
29
30
|
legendPosition: {},
|
|
@@ -35,33 +36,31 @@ const p = 24, x = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
|
|
|
35
36
|
yGridLine: { type: Boolean }
|
|
36
37
|
},
|
|
37
38
|
setup(i) {
|
|
38
|
-
const r = i, m = Object.values(r.categories).map((e) => e.color),
|
|
39
|
+
const r = i, m = Object.values(r.categories).map((e) => e.color), F = y(() => (e) => {
|
|
39
40
|
if (typeof window > "u" || typeof document > "u")
|
|
40
41
|
return "";
|
|
41
42
|
try {
|
|
42
|
-
const
|
|
43
|
+
const t = $(w, {
|
|
43
44
|
data: e,
|
|
44
45
|
categories: r.categories,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
toolTipTitle: R(e),
|
|
47
|
+
yFormatter: r.yFormatter
|
|
48
|
+
}), n = document.createElement("div");
|
|
49
|
+
t.mount(n);
|
|
50
|
+
const a = n.innerHTML;
|
|
51
|
+
return t.unmount(), a;
|
|
50
52
|
} catch {
|
|
51
53
|
return "";
|
|
52
54
|
}
|
|
53
55
|
});
|
|
54
|
-
|
|
55
|
-
d.value && (d.value.unmount(), d.value = null), k.value && (k.value = null);
|
|
56
|
-
});
|
|
57
|
-
function F(e) {
|
|
56
|
+
function V(e) {
|
|
58
57
|
var t;
|
|
59
58
|
return {
|
|
60
|
-
y: (
|
|
61
|
-
color: ((t = r.categories[e]) == null ? void 0 : t.color) ??
|
|
59
|
+
y: (n) => Number(n[e]),
|
|
60
|
+
color: ((t = r.categories[e]) == null ? void 0 : t.color) ?? B
|
|
62
61
|
};
|
|
63
62
|
}
|
|
64
|
-
function
|
|
63
|
+
function D(e, t) {
|
|
65
64
|
return `
|
|
66
65
|
<linearGradient id="gradient${e}-${t}" gradientTransform="rotate(90)">
|
|
67
66
|
<stop offset="0%" style="stop-color:var(--vis-color0);stop-opacity:1" />
|
|
@@ -69,7 +68,7 @@ const p = 24, x = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
|
|
|
69
68
|
</linearGradient>
|
|
70
69
|
`;
|
|
71
70
|
}
|
|
72
|
-
function
|
|
71
|
+
function O(e, t) {
|
|
73
72
|
return `
|
|
74
73
|
<linearGradient id="gradient${e}-${t}" gradientTransform="rotate(90)">
|
|
75
74
|
<stop offset="0%" stop-color="${t}" stop-opacity="1" />
|
|
@@ -77,45 +76,45 @@ const p = 24, x = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
|
|
|
77
76
|
</linearGradient>
|
|
78
77
|
`;
|
|
79
78
|
}
|
|
80
|
-
const
|
|
79
|
+
const x = y(
|
|
81
80
|
() => m.map(
|
|
82
|
-
(e, t) => e != null && e.includes("#") ?
|
|
81
|
+
(e, t) => e != null && e.includes("#") ? O(t, e) : D(t, e ?? B)
|
|
83
82
|
).join("")
|
|
84
|
-
),
|
|
85
|
-
() => r.legendPosition ===
|
|
83
|
+
), g = y(
|
|
84
|
+
() => r.legendPosition === z.Top
|
|
86
85
|
);
|
|
87
|
-
return (e, t) => (l(),
|
|
88
|
-
class:
|
|
86
|
+
return (e, t) => (l(), c("div", {
|
|
87
|
+
class: T(["flex flex-col space-y-4", { "flex-col-reverse": g.value }])
|
|
89
88
|
}, [
|
|
90
|
-
s(
|
|
89
|
+
s(o(P), {
|
|
91
90
|
data: e.data,
|
|
92
91
|
height: e.height,
|
|
93
92
|
padding: e.padding,
|
|
94
|
-
"svg-defs":
|
|
93
|
+
"svg-defs": x.value
|
|
95
94
|
}, {
|
|
96
|
-
default:
|
|
97
|
-
e.hideTooltip ?
|
|
95
|
+
default: E(() => [
|
|
96
|
+
e.hideTooltip ? f("", !0) : (l(), k(o(j), {
|
|
98
97
|
key: 0,
|
|
99
|
-
"horizontal-placement":
|
|
100
|
-
"vertical-placement":
|
|
98
|
+
"horizontal-placement": o(L).Right,
|
|
99
|
+
"vertical-placement": o(L).Top
|
|
101
100
|
}, null, 8, ["horizontal-placement", "vertical-placement"])),
|
|
102
|
-
(l(!0),
|
|
103
|
-
s(
|
|
104
|
-
x: (
|
|
101
|
+
(l(!0), c(v, null, G(Object.keys(r.categories), (n, a) => (l(), c(v, { key: a }, [
|
|
102
|
+
s(o(I), N({
|
|
103
|
+
x: (d, u) => u,
|
|
105
104
|
ref_for: !0
|
|
106
|
-
},
|
|
107
|
-
color: `url(#gradient${a}-${
|
|
108
|
-
opacity:
|
|
109
|
-
"curve-type": e.curveType ??
|
|
105
|
+
}, V(n), {
|
|
106
|
+
color: `url(#gradient${a}-${o(m)[a]})`,
|
|
107
|
+
opacity: X,
|
|
108
|
+
"curve-type": e.curveType ?? o(h).MonotoneX
|
|
110
109
|
}), null, 16, ["x", "color", "curve-type"]),
|
|
111
|
-
s(
|
|
112
|
-
x: (
|
|
113
|
-
y: (
|
|
114
|
-
color:
|
|
115
|
-
"curve-type": e.curveType ??
|
|
110
|
+
s(o(M), {
|
|
111
|
+
x: (d, u) => u,
|
|
112
|
+
y: (d) => d[n],
|
|
113
|
+
color: o(m)[a],
|
|
114
|
+
"curve-type": e.curveType ?? o(h).MonotoneX
|
|
116
115
|
}, null, 8, ["x", "y", "color", "curve-type"])
|
|
117
116
|
], 64))), 128)),
|
|
118
|
-
s(
|
|
117
|
+
s(o(b), {
|
|
119
118
|
type: "x",
|
|
120
119
|
"tick-format": e.xFormatter,
|
|
121
120
|
label: e.xLabel,
|
|
@@ -127,7 +126,7 @@ const p = 24, x = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
|
|
|
127
126
|
"tick-values": e.xExplicitTicks,
|
|
128
127
|
"min-max-ticks-only": e.minMaxTicksOnly
|
|
129
128
|
}, null, 8, ["tick-format", "label", "domain-line", "grid-line", "num-ticks", "tick-line", "tick-values", "min-max-ticks-only"]),
|
|
130
|
-
s(
|
|
129
|
+
s(o(b), {
|
|
131
130
|
type: "y",
|
|
132
131
|
"num-ticks": e.yNumTicks,
|
|
133
132
|
"tick-format": e.yFormatter,
|
|
@@ -136,19 +135,19 @@ const p = 24, x = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
|
|
|
136
135
|
"domain-line": e.yDomainLine,
|
|
137
136
|
"tick-line": e.yTickLine
|
|
138
137
|
}, null, 8, ["num-ticks", "tick-format", "label", "grid-line", "domain-line", "tick-line"]),
|
|
139
|
-
e.hideTooltip ?
|
|
138
|
+
e.hideTooltip ? f("", !0) : (l(), k(o(S), {
|
|
140
139
|
key: 1,
|
|
141
140
|
color: "#666",
|
|
142
|
-
template:
|
|
141
|
+
template: F.value
|
|
143
142
|
}, null, 8, ["template"]))
|
|
144
143
|
]),
|
|
145
144
|
_: 1
|
|
146
145
|
}, 8, ["data", "height", "padding", "svg-defs"]),
|
|
147
|
-
e.hideLegend ?
|
|
146
|
+
e.hideLegend ? f("", !0) : (l(), c("div", {
|
|
148
147
|
key: 0,
|
|
149
|
-
class:
|
|
148
|
+
class: T(["flex items-center justify-end", { "pb-4": g.value }])
|
|
150
149
|
}, [
|
|
151
|
-
s(
|
|
150
|
+
s(o(U), {
|
|
152
151
|
items: Object.values(e.categories)
|
|
153
152
|
}, null, 8, ["items"])
|
|
154
153
|
], 2))
|
|
@@ -156,5 +155,5 @@ const p = 24, x = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
|
|
|
156
155
|
}
|
|
157
156
|
});
|
|
158
157
|
export {
|
|
159
|
-
|
|
158
|
+
Z as default
|
|
160
159
|
};
|
|
@@ -47,16 +47,16 @@ const S = /* @__PURE__ */ v({
|
|
|
47
47
|
), y = c(() => (e, t) => {
|
|
48
48
|
if (typeof window > "u" || typeof document > "u")
|
|
49
49
|
return "";
|
|
50
|
-
const u = Object.keys(a.categories),
|
|
50
|
+
const u = Object.keys(a.categories), T = Object.keys(e).find((o) => !u.includes(o));
|
|
51
51
|
try {
|
|
52
52
|
const o = V(E, {
|
|
53
53
|
data: e,
|
|
54
54
|
categories: a.categories,
|
|
55
|
-
|
|
55
|
+
toolTipTitle: e[T]
|
|
56
56
|
}), k = document.createElement("div");
|
|
57
57
|
o.mount(k);
|
|
58
|
-
const
|
|
59
|
-
return o.unmount(),
|
|
58
|
+
const B = k.innerHTML;
|
|
59
|
+
return o.unmount(), B;
|
|
60
60
|
} catch {
|
|
61
61
|
return "";
|
|
62
62
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { defineComponent as b, computed as
|
|
1
|
+
import { defineComponent as b, computed as p, createApp as B, createElementBlock as s, openBlock as l, normalizeClass as u, createVNode as r, createCommentVNode as y, unref as i, withCtx as x, createBlock as g, Fragment as C, renderList as V } from "vue";
|
|
2
2
|
import { Position as k, CurveType as F } from "@unovis/ts";
|
|
3
|
-
import { VisXYContainer as N, VisTooltip as O, VisLine as
|
|
4
|
-
import
|
|
5
|
-
import { LegendPosition as
|
|
6
|
-
|
|
3
|
+
import { VisXYContainer as N, VisTooltip as O, VisLine as P, VisAxis as f, VisCrosshair as j, VisBulletLegend as D } from "@unovis/vue";
|
|
4
|
+
import E from "../Tooltip.js";
|
|
5
|
+
import { LegendPosition as G } from "../../types.js";
|
|
6
|
+
import { getFirstPropertyValue as M } from "../../utils.js";
|
|
7
|
+
const R = /* @__PURE__ */ b({
|
|
7
8
|
__name: "LineChart",
|
|
8
9
|
props: {
|
|
9
10
|
data: {},
|
|
@@ -35,14 +36,15 @@ const $ = /* @__PURE__ */ b({
|
|
|
35
36
|
yTickLine: { type: Boolean }
|
|
36
37
|
},
|
|
37
38
|
setup(t) {
|
|
38
|
-
const n = t, h = Object.values(n.categories).map((e, c) => `var(--vis-color${c})`), L = (e) => Object.values(n.categories)[e].color ?? h[e], T =
|
|
39
|
+
const n = t, h = Object.values(n.categories).map((e, c) => `var(--vis-color${c})`), L = (e) => Object.values(n.categories)[e].color ?? h[e], T = p(() => (e, c) => {
|
|
39
40
|
if (typeof window > "u" || typeof document > "u")
|
|
40
41
|
return "";
|
|
41
42
|
try {
|
|
42
|
-
const o = B(
|
|
43
|
+
const o = B(E, {
|
|
43
44
|
data: e,
|
|
44
45
|
categories: n.categories,
|
|
45
|
-
|
|
46
|
+
toolTipTitle: M(e),
|
|
47
|
+
yFormatter: n.yFormatter
|
|
46
48
|
}), a = document.createElement("div");
|
|
47
49
|
o.mount(a);
|
|
48
50
|
const m = a.innerHTML;
|
|
@@ -50,11 +52,11 @@ const $ = /* @__PURE__ */ b({
|
|
|
50
52
|
} catch {
|
|
51
53
|
return "";
|
|
52
54
|
}
|
|
53
|
-
}), d =
|
|
54
|
-
() => n.legendPosition ===
|
|
55
|
+
}), d = p(
|
|
56
|
+
() => n.legendPosition === G.Top
|
|
55
57
|
);
|
|
56
58
|
return (e, c) => (l(), s("div", {
|
|
57
|
-
class:
|
|
59
|
+
class: u(["flex flex-col space-y-4", { "flex-col-reverse": d.value }])
|
|
58
60
|
}, [
|
|
59
61
|
r(i(N), {
|
|
60
62
|
data: e.data,
|
|
@@ -66,7 +68,7 @@ const $ = /* @__PURE__ */ b({
|
|
|
66
68
|
"horizontal-placement": i(k).Right,
|
|
67
69
|
"vertical-placement": i(k).Top
|
|
68
70
|
}, null, 8, ["horizontal-placement", "vertical-placement"]),
|
|
69
|
-
(l(!0), s(C, null, V(Object.keys(n.categories), (o, a) => (l(), g(i(
|
|
71
|
+
(l(!0), s(C, null, V(Object.keys(n.categories), (o, a) => (l(), g(i(P), {
|
|
70
72
|
key: a,
|
|
71
73
|
x: (m, v) => v,
|
|
72
74
|
y: (m) => m[o],
|
|
@@ -94,7 +96,7 @@ const $ = /* @__PURE__ */ b({
|
|
|
94
96
|
"grid-line": e.yGridLine,
|
|
95
97
|
"tick-line": e.yTickLine
|
|
96
98
|
}, null, 8, ["tick-format", "label", "num-ticks", "domain-line", "grid-line", "tick-line"]),
|
|
97
|
-
e.hideTooltip ? y("", !0) : (l(), g(i(
|
|
99
|
+
e.hideTooltip ? y("", !0) : (l(), g(i(j), {
|
|
98
100
|
key: 0,
|
|
99
101
|
color: "#666",
|
|
100
102
|
template: T.value
|
|
@@ -104,9 +106,9 @@ const $ = /* @__PURE__ */ b({
|
|
|
104
106
|
}, 8, ["data", "padding", "height"]),
|
|
105
107
|
e.hideLegend ? y("", !0) : (l(), s("div", {
|
|
106
108
|
key: 0,
|
|
107
|
-
class:
|
|
109
|
+
class: u(["flex items center justify-end", { "pb-4": d.value }])
|
|
108
110
|
}, [
|
|
109
|
-
r(i(
|
|
111
|
+
r(i(D), {
|
|
110
112
|
items: Object.values(e.categories)
|
|
111
113
|
}, null, 8, ["items"])
|
|
112
114
|
], 2))
|
|
@@ -114,5 +116,5 @@ const $ = /* @__PURE__ */ b({
|
|
|
114
116
|
}
|
|
115
117
|
});
|
|
116
118
|
export {
|
|
117
|
-
|
|
119
|
+
R as default
|
|
118
120
|
};
|
|
@@ -1,41 +1,42 @@
|
|
|
1
|
-
import { defineComponent as b, computed as v, createElementBlock as r, openBlock as l, createElementVNode as o, toDisplayString as i, Fragment as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as b, computed as v, createElementBlock as r, openBlock as l, createElementVNode as o, toDisplayString as i, Fragment as y, renderList as h, normalizeStyle as n } from "vue";
|
|
2
|
+
const f = {
|
|
3
3
|
class: "capitalize border-b mb-1 pb-1",
|
|
4
4
|
style: {
|
|
5
5
|
color: "var(--tooltip-value-color)",
|
|
6
6
|
borderColor: "rgba(255, 255, 255, 0.05)"
|
|
7
7
|
}
|
|
8
|
-
},
|
|
8
|
+
}, F = /* @__PURE__ */ b({
|
|
9
9
|
__name: "Tooltip",
|
|
10
10
|
props: {
|
|
11
11
|
data: {},
|
|
12
12
|
categories: {},
|
|
13
|
-
|
|
13
|
+
toolTipTitle: {},
|
|
14
|
+
yFormatter: { type: Function }
|
|
14
15
|
},
|
|
15
|
-
setup(
|
|
16
|
-
const
|
|
17
|
-
([e,
|
|
16
|
+
setup(p) {
|
|
17
|
+
const a = p, d = ["_index", "_stacked", "_ending"], m = v(() => Object.entries(a.data ?? []).filter(
|
|
18
|
+
([e, g]) => !d.includes(e) && Object.keys(a.categories).includes(e)
|
|
18
19
|
));
|
|
19
|
-
return (e,
|
|
20
|
-
o("div",
|
|
21
|
-
(l(!0), r(
|
|
22
|
-
var
|
|
20
|
+
return (e, g) => (l(), r("div", null, [
|
|
21
|
+
o("div", f, i(e.toolTipTitle), 1),
|
|
22
|
+
(l(!0), r(y, null, h(m.value, ([t, s], u) => {
|
|
23
|
+
var c;
|
|
23
24
|
return l(), r("div", {
|
|
24
25
|
key: t,
|
|
25
26
|
style: { display: "flex", "align-items": "center", "margin-bottom": "4px" }
|
|
26
27
|
}, [
|
|
27
28
|
o("span", {
|
|
28
|
-
style:
|
|
29
|
-
backgroundColor: (
|
|
29
|
+
style: n([{ width: "8px", height: "8px", "border-radius": "4px", "margin-right": "8px" }, {
|
|
30
|
+
backgroundColor: (c = e.categories[t]) != null && c.color ? e.categories[t].color : `var(--vis-color${u})`
|
|
30
31
|
}])
|
|
31
32
|
}, null, 4),
|
|
32
33
|
o("div", null, [
|
|
33
34
|
o("span", {
|
|
34
|
-
style:
|
|
35
|
+
style: n([{ "font-weight": "600", "margin-right": "8px" }, { color: "var(--tooltip-label-color)" }])
|
|
35
36
|
}, i(e.categories[t].name) + ":", 1),
|
|
36
37
|
o("span", {
|
|
37
|
-
style:
|
|
38
|
-
}, i(
|
|
38
|
+
style: n([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
|
|
39
|
+
}, i(e.yFormatter ? e.yFormatter(s) : s), 1)
|
|
39
40
|
])
|
|
40
41
|
]);
|
|
41
42
|
}), 128))
|
|
@@ -43,5 +44,5 @@ const x = {
|
|
|
43
44
|
}
|
|
44
45
|
});
|
|
45
46
|
export {
|
|
46
|
-
|
|
47
|
+
F as default
|
|
47
48
|
};
|
|
@@ -3,7 +3,8 @@ 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
|
-
|
|
6
|
+
toolTipTitle: string | number;
|
|
7
|
+
yFormatter?: (value: T) => any;
|
|
7
8
|
} & Partial<{}>> & import('vue').PublicProps;
|
|
8
9
|
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
9
10
|
attrs: any;
|
package/dist/utils.d.ts
CHANGED
package/dist/utils.js
ADDED