vue-chrts 0.1.1-test.2 → 0.1.1-test.4
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 +77 -79
- package/dist/components/AreaStackedChart/AreaStackedChart.js +24 -24
- package/dist/components/BarChart/BarChart.js +36 -35
- package/dist/components/LineChart/LineChart.js +30 -29
- package/dist/components/Tooltip.js +24 -17
- package/dist/components/Tooltip.vue.d.ts +1 -0
- package/package.json +1 -1
- package/dist/colors.d.ts +0 -11
- package/dist/colors.js +0 -100
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
const p = 24, O = 4, W = 0.5, A = "#3b82f6", ne = /* @__PURE__ */ G({
|
|
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({
|
|
8
7
|
__name: "AreaChart",
|
|
9
8
|
props: {
|
|
10
9
|
data: {},
|
|
@@ -15,10 +14,10 @@ const p = 24, O = 4, W = 0.5, A = "#3b82f6", ne = /* @__PURE__ */ G({
|
|
|
15
14
|
xFormatter: {},
|
|
16
15
|
yFormatter: {},
|
|
17
16
|
curveType: {},
|
|
18
|
-
xNumTicks: { default: (i) => i.data.length > p ? p /
|
|
17
|
+
xNumTicks: { default: (i) => i.data.length > p ? p / V : i.data.length - 1 },
|
|
19
18
|
xExplicitTicks: {},
|
|
20
19
|
minMaxTicksOnly: { type: Boolean },
|
|
21
|
-
yNumTicks: { default: (i) => i.data.length > p ? p /
|
|
20
|
+
yNumTicks: { default: (i) => i.data.length > p ? p / V : i.data.length - 1 },
|
|
22
21
|
hideLegend: { type: Boolean },
|
|
23
22
|
hideTooltip: { type: Boolean },
|
|
24
23
|
xGridLine: { type: Boolean },
|
|
@@ -29,89 +28,86 @@ const p = 24, O = 4, W = 0.5, A = "#3b82f6", ne = /* @__PURE__ */ G({
|
|
|
29
28
|
legendPosition: {}
|
|
30
29
|
},
|
|
31
30
|
setup(i) {
|
|
32
|
-
const
|
|
33
|
-
(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
31
|
+
const r = i, m = Object.values(r.categories).map((e) => e.color), d = T(null), v = T(null), D = f(() => (e, t) => {
|
|
32
|
+
if (typeof window > "u" || typeof document > "u")
|
|
33
|
+
return "";
|
|
34
|
+
try {
|
|
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 "";
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
P(() => {
|
|
48
|
+
d.value && (d.value.unmount(), d.value = null), v.value && (v.value = null);
|
|
47
49
|
});
|
|
48
50
|
function F(e) {
|
|
49
51
|
var t;
|
|
50
52
|
return {
|
|
51
53
|
y: (n) => Number(n[e]),
|
|
52
|
-
color: ((t =
|
|
54
|
+
color: ((t = r.categories[e]) == null ? void 0 : t.color) ?? A
|
|
53
55
|
};
|
|
54
56
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (!r.value)
|
|
61
|
-
return r.value = M(J, {
|
|
62
|
-
data: e,
|
|
63
|
-
categories: t
|
|
64
|
-
}), r.value.mount(l.value), l.value.innerHTML;
|
|
65
|
-
const n = r.value._instance;
|
|
66
|
-
return n != null && n.proxy, l.value.innerHTML;
|
|
67
|
-
} catch (n) {
|
|
68
|
-
return console.error("Error generating tooltip:", n), "";
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
P(() => {
|
|
72
|
-
r.value && (r.value.unmount(), r.value = null), l.value = null;
|
|
73
|
-
});
|
|
74
|
-
const N = d.map(
|
|
75
|
-
(e, t) => `
|
|
76
|
-
<linearGradient id="gradient${t}-${e}" gradientTransform="rotate(90)">
|
|
77
|
-
<stop offset="0%" stop-color="${e}" stop-opacity="1" />
|
|
78
|
-
<stop offset="100%" stop-color="${e}" stop-opacity="0" />
|
|
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" />
|
|
79
62
|
</linearGradient>
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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" />
|
|
70
|
+
</linearGradient>
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
73
|
+
const $ = f(
|
|
74
|
+
() => m.map(
|
|
75
|
+
(e, t) => e != null && e.includes("#") ? G(t, e) : O(t, e ?? A)
|
|
76
|
+
).join("")
|
|
77
|
+
), k = f(
|
|
78
|
+
() => r.legendPosition === H.Top
|
|
83
79
|
);
|
|
84
|
-
return (e, t) => (
|
|
85
|
-
class:
|
|
80
|
+
return (e, t) => (l(), u("div", {
|
|
81
|
+
class: L(["flex flex-col space-y-4", { "flex-col-reverse": k.value }])
|
|
86
82
|
}, [
|
|
87
|
-
|
|
83
|
+
s(o(I), {
|
|
88
84
|
data: e.data,
|
|
89
85
|
height: e.height,
|
|
90
|
-
"svg-defs":
|
|
86
|
+
"svg-defs": $.value
|
|
91
87
|
}, {
|
|
92
|
-
default:
|
|
93
|
-
e.hideTooltip ?
|
|
88
|
+
default: M(() => [
|
|
89
|
+
e.hideTooltip ? g("", !0) : (l(), h(o(S), {
|
|
94
90
|
key: 0,
|
|
95
|
-
"horizontal-placement": o(
|
|
96
|
-
"vertical-placement": o(
|
|
91
|
+
"horizontal-placement": o(C).Right,
|
|
92
|
+
"vertical-placement": o(C).Top
|
|
97
93
|
}, null, 8, ["horizontal-placement", "vertical-placement"])),
|
|
98
|
-
(
|
|
99
|
-
|
|
100
|
-
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,
|
|
101
97
|
ref_for: !0
|
|
102
98
|
}, F(n), {
|
|
103
|
-
color: `url(#gradient${
|
|
104
|
-
opacity:
|
|
105
|
-
"curve-type": e.curveType ?? o(
|
|
99
|
+
color: `url(#gradient${a}-${o(m)[a]})`,
|
|
100
|
+
opacity: q,
|
|
101
|
+
"curve-type": e.curveType ?? o(x).MonotoneX
|
|
106
102
|
}), null, 16, ["x", "color", "curve-type"]),
|
|
107
|
-
|
|
108
|
-
x: (
|
|
109
|
-
y: (
|
|
110
|
-
color: o(
|
|
111
|
-
"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
|
|
112
108
|
}, null, 8, ["x", "y", "color", "curve-type"])
|
|
113
109
|
], 64))), 128)),
|
|
114
|
-
|
|
110
|
+
s(o(B), {
|
|
115
111
|
type: "x",
|
|
116
112
|
"tick-format": e.xFormatter,
|
|
117
113
|
label: e.xLabel,
|
|
@@ -123,7 +119,7 @@ const p = 24, O = 4, W = 0.5, A = "#3b82f6", ne = /* @__PURE__ */ G({
|
|
|
123
119
|
"tick-values": e.xExplicitTicks,
|
|
124
120
|
"min-max-ticks-only": e.minMaxTicksOnly
|
|
125
121
|
}, null, 8, ["tick-format", "label", "domain-line", "grid-line", "num-ticks", "tick-line", "tick-values", "min-max-ticks-only"]),
|
|
126
|
-
|
|
122
|
+
s(o(B), {
|
|
127
123
|
type: "y",
|
|
128
124
|
"num-ticks": e.yNumTicks,
|
|
129
125
|
"tick-format": e.yFormatter,
|
|
@@ -132,23 +128,25 @@ const p = 24, O = 4, W = 0.5, A = "#3b82f6", ne = /* @__PURE__ */ G({
|
|
|
132
128
|
"domain-line": e.yDomainLine,
|
|
133
129
|
"tick-line": !!e.yGridLine
|
|
134
130
|
}, null, 8, ["num-ticks", "tick-format", "label", "grid-line", "domain-line", "tick-line"]),
|
|
135
|
-
e.hideTooltip ?
|
|
131
|
+
e.hideTooltip ? g("", !0) : (l(), h(o(R), {
|
|
136
132
|
key: 1,
|
|
137
133
|
color: "#666",
|
|
138
|
-
template:
|
|
134
|
+
template: D.value
|
|
139
135
|
}, null, 8, ["template"]))
|
|
140
136
|
]),
|
|
141
137
|
_: 1
|
|
142
138
|
}, 8, ["data", "height", "svg-defs"]),
|
|
143
|
-
e.hideLegend ?
|
|
139
|
+
e.hideLegend ? g("", !0) : (l(), u("div", {
|
|
144
140
|
key: 0,
|
|
145
|
-
class:
|
|
141
|
+
class: L(["flex items-center justify-end", { "pb-4": k.value }])
|
|
146
142
|
}, [
|
|
147
|
-
|
|
143
|
+
s(o(X), {
|
|
144
|
+
items: Object.values(e.categories)
|
|
145
|
+
}, null, 8, ["items"])
|
|
148
146
|
], 2))
|
|
149
147
|
], 2));
|
|
150
148
|
}
|
|
151
149
|
});
|
|
152
150
|
export {
|
|
153
|
-
|
|
151
|
+
_ as default
|
|
154
152
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { VisXYContainer as
|
|
3
|
-
import { CurveType as
|
|
4
|
-
import
|
|
5
|
-
const
|
|
1
|
+
import { defineComponent as f, computed as h, createApp as y, createElementBlock as g, openBlock as a, createVNode as r, createElementVNode as v, unref as t, withCtx as _, createBlock as V, createCommentVNode as k } from "vue";
|
|
2
|
+
import { VisXYContainer as C, VisArea as T, VisAxis as c, VisCrosshair as b, VisBulletLegend as x } from "@unovis/vue";
|
|
3
|
+
import { CurveType as B } from "@unovis/ts";
|
|
4
|
+
import N from "../Tooltip.js";
|
|
5
|
+
const A = { class: "flex flex-col space-y-4" }, j = { class: "flex items center justify-end" }, H = /* @__PURE__ */ f({
|
|
6
6
|
__name: "AreaStackedChart",
|
|
7
7
|
props: {
|
|
8
8
|
data: {},
|
|
@@ -11,44 +11,44 @@ const N = { class: "flex flex-col space-y-4" }, A = { class: "flex items center
|
|
|
11
11
|
hideTooltip: { type: Boolean }
|
|
12
12
|
},
|
|
13
13
|
setup(s) {
|
|
14
|
-
const
|
|
14
|
+
const n = s, l = h(() => (e, p) => {
|
|
15
15
|
if (typeof window > "u" || typeof document > "u")
|
|
16
16
|
return "";
|
|
17
17
|
try {
|
|
18
|
-
const
|
|
18
|
+
const o = y(N, {
|
|
19
19
|
data: e,
|
|
20
|
-
categories:
|
|
21
|
-
}),
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
return
|
|
20
|
+
categories: n.categories
|
|
21
|
+
}), i = document.createElement("div");
|
|
22
|
+
o.mount(i);
|
|
23
|
+
const d = i.innerHTML;
|
|
24
|
+
return o.unmount(), d;
|
|
25
25
|
} catch {
|
|
26
26
|
return "";
|
|
27
27
|
}
|
|
28
28
|
}), m = (e) => Number.parseInt(e.time), u = [(e) => e.firstTime, (e) => e.returning];
|
|
29
|
-
return (e,
|
|
30
|
-
|
|
29
|
+
return (e, p) => (a(), g("div", A, [
|
|
30
|
+
r(t(C), {
|
|
31
31
|
data: e.data,
|
|
32
32
|
height: e.height
|
|
33
33
|
}, {
|
|
34
|
-
default:
|
|
35
|
-
|
|
34
|
+
default: _(() => [
|
|
35
|
+
r(t(T), {
|
|
36
36
|
x: m,
|
|
37
37
|
y: u,
|
|
38
|
-
color: Object.values(
|
|
39
|
-
"curve-type": t(
|
|
38
|
+
color: Object.values(n.categories).map((o) => o.color),
|
|
39
|
+
"curve-type": t(B).Linear
|
|
40
40
|
}, null, 8, ["color", "curve-type"]),
|
|
41
|
-
|
|
41
|
+
r(t(c), {
|
|
42
42
|
type: "x",
|
|
43
43
|
label: "Time",
|
|
44
44
|
"num-ticks": 12
|
|
45
45
|
}),
|
|
46
|
-
|
|
46
|
+
r(t(c), {
|
|
47
47
|
type: "y",
|
|
48
48
|
label: "Number of visitors",
|
|
49
49
|
"num-ticks": 3
|
|
50
50
|
}),
|
|
51
|
-
e.hideTooltip ?
|
|
51
|
+
e.hideTooltip ? k("", !0) : (a(), V(t(b), {
|
|
52
52
|
key: 0,
|
|
53
53
|
color: "#666",
|
|
54
54
|
template: l.value
|
|
@@ -56,8 +56,8 @@ const N = { class: "flex flex-col space-y-4" }, A = { class: "flex items center
|
|
|
56
56
|
]),
|
|
57
57
|
_: 1
|
|
58
58
|
}, 8, ["data", "height"]),
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
v("div", j, [
|
|
60
|
+
r(t(x), {
|
|
61
61
|
items: Object.values(e.categories)
|
|
62
62
|
}, null, 8, ["items"])
|
|
63
63
|
])
|
|
@@ -65,5 +65,5 @@ const N = { class: "flex flex-col space-y-4" }, A = { class: "flex items center
|
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
export {
|
|
68
|
-
|
|
68
|
+
H as default
|
|
69
69
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Orientation as s, StackedBar as
|
|
3
|
-
import { VisXYContainer as
|
|
4
|
-
import
|
|
5
|
-
import { LegendPosition as
|
|
6
|
-
const
|
|
1
|
+
import { defineComponent as b, computed as u, createApp as B, createElementBlock as y, openBlock as d, normalizeClass as k, createVNode as l, createCommentVNode as T, unref as i, withCtx as v, createBlock as f } from "vue";
|
|
2
|
+
import { Orientation as s, StackedBar as x, GroupedBar as V } from "@unovis/ts";
|
|
3
|
+
import { VisXYContainer as P, VisTooltip as A, VisGroupedBar as C, VisStackedBar as G, VisAxis as h, VisBulletLegend as N } from "@unovis/vue";
|
|
4
|
+
import w from "../Tooltip.js";
|
|
5
|
+
import { LegendPosition as E } from "../../types.js";
|
|
6
|
+
const z = /* @__PURE__ */ b({
|
|
7
7
|
__name: "BarChart",
|
|
8
8
|
props: {
|
|
9
9
|
data: {},
|
|
@@ -14,9 +14,9 @@ const M = /* @__PURE__ */ h({
|
|
|
14
14
|
categories: {},
|
|
15
15
|
xFormatter: {},
|
|
16
16
|
yFormatter: {},
|
|
17
|
-
yNumTicks: { default: (
|
|
17
|
+
yNumTicks: { default: (n) => n.data.length > 24 ? 24 / 4 : n.data.length - 1 },
|
|
18
18
|
minMaxTicksOnly: { type: Boolean },
|
|
19
|
-
xNumTicks: { default: (
|
|
19
|
+
xNumTicks: { default: (n) => n.data.length > 24 ? 24 / 4 : n.data.length - 1 },
|
|
20
20
|
xExplicitTicks: {},
|
|
21
21
|
yAxis: {},
|
|
22
22
|
groupPadding: {},
|
|
@@ -32,52 +32,53 @@ const M = /* @__PURE__ */ h({
|
|
|
32
32
|
xGridLine: { type: Boolean },
|
|
33
33
|
yGridLine: { type: Boolean, default: !0 }
|
|
34
34
|
},
|
|
35
|
-
setup(
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
35
|
+
setup(n) {
|
|
36
|
+
const a = n;
|
|
37
|
+
if (!a.yAxis || a.yAxis.length === 0)
|
|
38
38
|
throw new Error("yAxis is required");
|
|
39
|
-
const c = u(() =>
|
|
40
|
-
() =>
|
|
41
|
-
), g = u(() => (e) => {
|
|
39
|
+
const c = u(() => a.yAxis.map((e) => (o) => o[e])), m = (e, o) => Object.values(a.categories)[o].color, p = u(
|
|
40
|
+
() => a.legendPosition === E.Top
|
|
41
|
+
), g = u(() => (e, o) => {
|
|
42
42
|
if (typeof window > "u" || typeof document > "u")
|
|
43
43
|
return "";
|
|
44
44
|
try {
|
|
45
|
-
const
|
|
45
|
+
const r = B(w, {
|
|
46
46
|
data: e,
|
|
47
|
-
categories:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
categories: a.categories,
|
|
48
|
+
xValue: a.xFormatter(Math.floor(o))
|
|
49
|
+
}), t = document.createElement("div");
|
|
50
|
+
r.mount(t);
|
|
51
|
+
const L = t.innerHTML;
|
|
52
|
+
return r.unmount(), L;
|
|
52
53
|
} catch {
|
|
53
54
|
return "";
|
|
54
55
|
}
|
|
55
56
|
});
|
|
56
|
-
return (e,
|
|
57
|
+
return (e, o) => (d(), y("div", {
|
|
57
58
|
class: k(["flex flex-col space-y-4", { "flex-col-reverse": p.value }])
|
|
58
59
|
}, [
|
|
59
|
-
|
|
60
|
-
default:
|
|
61
|
-
|
|
60
|
+
l(i(P), { height: e.height }, {
|
|
61
|
+
default: v(() => [
|
|
62
|
+
l(i(A), {
|
|
62
63
|
triggers: {
|
|
63
|
-
[i(
|
|
64
|
-
[i(
|
|
64
|
+
[i(V).selectors.bar]: g.value,
|
|
65
|
+
[i(x).selectors.bar]: g.value
|
|
65
66
|
}
|
|
66
67
|
}, null, 8, ["triggers"]),
|
|
67
|
-
e.stacked ? (d(), f(i(
|
|
68
|
+
e.stacked ? (d(), f(i(G), {
|
|
68
69
|
key: 1,
|
|
69
70
|
data: e.data,
|
|
70
|
-
x: (
|
|
71
|
+
x: (r, t) => t,
|
|
71
72
|
y: c.value,
|
|
72
73
|
color: m,
|
|
73
74
|
"rounded-corners": e.radius ?? 0,
|
|
74
75
|
"group-padding": e.groupPadding ?? 0,
|
|
75
76
|
"bar-padding": e.barPadding ?? 0.2,
|
|
76
77
|
orientation: e.orientation ?? i(s).Vertical
|
|
77
|
-
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (d(), f(i(
|
|
78
|
+
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (d(), f(i(C), {
|
|
78
79
|
key: 0,
|
|
79
80
|
data: e.data,
|
|
80
|
-
x: (
|
|
81
|
+
x: (r, t) => t,
|
|
81
82
|
y: c.value,
|
|
82
83
|
color: m,
|
|
83
84
|
"rounded-corners": e.radius ?? 0,
|
|
@@ -85,7 +86,7 @@ const M = /* @__PURE__ */ h({
|
|
|
85
86
|
"bar-padding": e.barPadding ?? 0.2,
|
|
86
87
|
orientation: e.orientation ?? i(s).Vertical
|
|
87
88
|
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])),
|
|
88
|
-
|
|
89
|
+
l(i(h), {
|
|
89
90
|
type: "x",
|
|
90
91
|
"tick-format": e.xFormatter,
|
|
91
92
|
label: e.xLabel,
|
|
@@ -96,7 +97,7 @@ const M = /* @__PURE__ */ h({
|
|
|
96
97
|
"tick-values": e.xExplicitTicks,
|
|
97
98
|
"min-max-ticks-only": e.minMaxTicksOnly
|
|
98
99
|
}, null, 8, ["tick-format", "label", "grid-line", "domain-line", "tick-line", "num-ticks", "tick-values", "min-max-ticks-only"]),
|
|
99
|
-
|
|
100
|
+
l(i(h), {
|
|
100
101
|
type: "y",
|
|
101
102
|
label: e.yLabel,
|
|
102
103
|
"grid-line": e.orientation !== i(s).Horizontal && e.yGridLine,
|
|
@@ -108,11 +109,11 @@ const M = /* @__PURE__ */ h({
|
|
|
108
109
|
]),
|
|
109
110
|
_: 1
|
|
110
111
|
}, 8, ["height"]),
|
|
111
|
-
e.hideLegend ?
|
|
112
|
+
e.hideLegend ? T("", !0) : (d(), y("div", {
|
|
112
113
|
key: 0,
|
|
113
114
|
class: k(["flex items center justify-end", { "pb-4": p.value }])
|
|
114
115
|
}, [
|
|
115
|
-
|
|
116
|
+
l(i(N), {
|
|
116
117
|
items: Object.values(e.categories)
|
|
117
118
|
}, null, 8, ["items"])
|
|
118
119
|
], 2))
|
|
@@ -120,5 +121,5 @@ const M = /* @__PURE__ */ h({
|
|
|
120
121
|
}
|
|
121
122
|
});
|
|
122
123
|
export {
|
|
123
|
-
|
|
124
|
+
z as default
|
|
124
125
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as v, computed as
|
|
2
|
-
import { Position as g, CurveType as
|
|
3
|
-
import { VisXYContainer as
|
|
4
|
-
import
|
|
5
|
-
import { LegendPosition as
|
|
1
|
+
import { defineComponent as v, computed as d, createApp as b, createElementBlock as m, openBlock as l, normalizeClass as p, createVNode as r, createCommentVNode as y, unref as i, withCtx as x, createBlock as k, Fragment as B, renderList as V } from "vue";
|
|
2
|
+
import { Position as g, CurveType as C } from "@unovis/ts";
|
|
3
|
+
import { VisXYContainer as F, VisTooltip as N, VisLine as M, VisAxis as f, VisCrosshair as O, VisBulletLegend as P } from "@unovis/vue";
|
|
4
|
+
import j from "../Tooltip.js";
|
|
5
|
+
import { LegendPosition as D } from "../../types.js";
|
|
6
6
|
const X = /* @__PURE__ */ v({
|
|
7
7
|
__name: "LineChart",
|
|
8
8
|
props: {
|
|
@@ -29,43 +29,44 @@ const X = /* @__PURE__ */ v({
|
|
|
29
29
|
yTickLine: { type: Boolean }
|
|
30
30
|
},
|
|
31
31
|
setup(t) {
|
|
32
|
-
const
|
|
32
|
+
const n = t, h = (e) => Object.values(n.categories)[e].color, L = d(() => (e, u) => {
|
|
33
33
|
if (typeof window > "u" || typeof document > "u")
|
|
34
34
|
return "";
|
|
35
35
|
try {
|
|
36
|
-
const
|
|
36
|
+
const o = b(j, {
|
|
37
37
|
data: e,
|
|
38
|
-
categories:
|
|
39
|
-
|
|
40
|
-
a.
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
categories: n.categories,
|
|
39
|
+
xValue: n.xFormatter(Math.floor(u))
|
|
40
|
+
}), a = document.createElement("div");
|
|
41
|
+
o.mount(a);
|
|
42
|
+
const c = a.innerHTML;
|
|
43
|
+
return o.unmount(), c;
|
|
43
44
|
} catch {
|
|
44
45
|
return "";
|
|
45
46
|
}
|
|
46
|
-
}), s =
|
|
47
|
-
() =>
|
|
47
|
+
}), s = d(
|
|
48
|
+
() => n.legendPosition === D.Top
|
|
48
49
|
);
|
|
49
|
-
return (e,
|
|
50
|
+
return (e, u) => (l(), m("div", {
|
|
50
51
|
class: p(["flex flex-col space-y-4", { "flex-col-reverse": s.value }])
|
|
51
52
|
}, [
|
|
52
|
-
|
|
53
|
+
r(i(F), {
|
|
53
54
|
data: e.data,
|
|
54
55
|
height: e.height
|
|
55
56
|
}, {
|
|
56
|
-
default:
|
|
57
|
-
|
|
57
|
+
default: x(() => [
|
|
58
|
+
r(i(N), {
|
|
58
59
|
"horizontal-placement": i(g).Right,
|
|
59
60
|
"vertical-placement": i(g).Top
|
|
60
61
|
}, null, 8, ["horizontal-placement", "vertical-placement"]),
|
|
61
|
-
(
|
|
62
|
-
key:
|
|
63
|
-
x: (
|
|
64
|
-
y: (
|
|
65
|
-
color: h(
|
|
66
|
-
"curve-type": e.curveType ?? i(
|
|
62
|
+
(l(!0), m(B, null, V(Object.keys(n.categories), (o, a) => (l(), k(i(M), {
|
|
63
|
+
key: a,
|
|
64
|
+
x: (c, T) => T,
|
|
65
|
+
y: (c) => c[o],
|
|
66
|
+
color: h(a),
|
|
67
|
+
"curve-type": e.curveType ?? i(C).MonotoneX
|
|
67
68
|
}, null, 8, ["x", "y", "color", "curve-type"]))), 128)),
|
|
68
|
-
|
|
69
|
+
r(i(f), {
|
|
69
70
|
type: "x",
|
|
70
71
|
"tick-format": e.xFormatter,
|
|
71
72
|
label: e.xLabel,
|
|
@@ -77,7 +78,7 @@ const X = /* @__PURE__ */ v({
|
|
|
77
78
|
"tick-values": e.xExplicitTicks,
|
|
78
79
|
"min-max-ticks-only": e.minMaxTicksOnly
|
|
79
80
|
}, null, 8, ["tick-format", "label", "domain-line", "grid-line", "tick-line", "num-ticks", "tick-values", "min-max-ticks-only"]),
|
|
80
|
-
|
|
81
|
+
r(i(f), {
|
|
81
82
|
type: "y",
|
|
82
83
|
"tick-format": e.yFormatter,
|
|
83
84
|
label: e.yLabel,
|
|
@@ -86,7 +87,7 @@ const X = /* @__PURE__ */ v({
|
|
|
86
87
|
"grid-line": e.yGridLine,
|
|
87
88
|
"tick-line": e.yTickLine
|
|
88
89
|
}, null, 8, ["tick-format", "label", "num-ticks", "domain-line", "grid-line", "tick-line"]),
|
|
89
|
-
e.hideTooltip ? y("", !0) : (
|
|
90
|
+
e.hideTooltip ? y("", !0) : (l(), k(i(O), {
|
|
90
91
|
key: 0,
|
|
91
92
|
color: "#666",
|
|
92
93
|
template: L.value
|
|
@@ -94,11 +95,11 @@ const X = /* @__PURE__ */ v({
|
|
|
94
95
|
]),
|
|
95
96
|
_: 1
|
|
96
97
|
}, 8, ["data", "height"]),
|
|
97
|
-
e.hideLegend ? y("", !0) : (
|
|
98
|
+
e.hideLegend ? y("", !0) : (l(), m("div", {
|
|
98
99
|
key: 0,
|
|
99
100
|
class: p(["flex items center justify-end", { "pb-4": s.value }])
|
|
100
101
|
}, [
|
|
101
|
-
|
|
102
|
+
r(i(P), {
|
|
102
103
|
items: Object.values(e.categories)
|
|
103
104
|
}, null, 8, ["items"])
|
|
104
105
|
], 2))
|
|
@@ -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
package/dist/colors.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare function getOklchFromCssVariable(cssVariableName: any): {
|
|
2
|
-
l: number;
|
|
3
|
-
c: number;
|
|
4
|
-
h: number;
|
|
5
|
-
a: number;
|
|
6
|
-
} | null;
|
|
7
|
-
export declare function getColorValue(colorStr: any, oklch2web: any): any;
|
|
8
|
-
export declare function convertCategories(categories: any, oklch2web: any): {};
|
|
9
|
-
declare function oklch2web(l: any, c: any, h: any, a: any): string;
|
|
10
|
-
declare function extractHue(color: any): number;
|
|
11
|
-
export { extractHue, oklch2web };
|
package/dist/colors.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
function l(n) {
|
|
2
|
-
if (typeof window > "u") return null;
|
|
3
|
-
const e = getComputedStyle(document.documentElement).getPropertyValue(n).trim();
|
|
4
|
-
if (!e) return null;
|
|
5
|
-
const t = e.match(/oklch\(\s*([\d.]+)\s+([\d.]+)\s+([\d.]+)\s*\)/);
|
|
6
|
-
if (!t) return null;
|
|
7
|
-
const o = parseFloat(t[1]) * 100, s = parseFloat(t[2]), c = parseFloat(t[3]), u = parseFloat(t[4]);
|
|
8
|
-
return { l: o, c: s, h: c, a: u };
|
|
9
|
-
}
|
|
10
|
-
function f(n, r) {
|
|
11
|
-
const e = "#3b82f6";
|
|
12
|
-
if (n != null && n.includes("#")) return n;
|
|
13
|
-
const t = l(n);
|
|
14
|
-
return t ? r(t.l, t.c, t.h) : e;
|
|
15
|
-
}
|
|
16
|
-
function M(n, r) {
|
|
17
|
-
return Object.keys(n).reduce(
|
|
18
|
-
(e, t) => {
|
|
19
|
-
const o = n[t];
|
|
20
|
-
return e[t] = {
|
|
21
|
-
...o,
|
|
22
|
-
color: f(o.color, r)
|
|
23
|
-
}, e;
|
|
24
|
-
},
|
|
25
|
-
{}
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
function h(n) {
|
|
29
|
-
const { l: r, c: e, h: t } = n;
|
|
30
|
-
return {
|
|
31
|
-
l: r,
|
|
32
|
-
a: e ? e * Math.cos(t / 180 * Math.PI) : 0,
|
|
33
|
-
b: e ? e * Math.sin(t / 180 * Math.PI) : 0
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function b(n) {
|
|
37
|
-
const { l: r, a: e, b: t } = n, o = Math.pow(
|
|
38
|
-
r * 0.9999999984505198 + 0.39633779217376786 * e + 0.2158037580607588 * t,
|
|
39
|
-
3
|
|
40
|
-
), s = Math.pow(
|
|
41
|
-
r * 1.0000000088817609 - 0.10556134232365635 * e - 0.06385417477170591 * t,
|
|
42
|
-
3
|
|
43
|
-
), c = Math.pow(
|
|
44
|
-
r * 1.0000000546724108 - 0.08948418209496575 * e - 1.2914855378640917 * t,
|
|
45
|
-
3
|
|
46
|
-
);
|
|
47
|
-
return {
|
|
48
|
-
r: 4.076741661347994 * o - 3.307711590408193 * s + 0.230969928729428 * c,
|
|
49
|
-
g: -1.2684380040921763 * o + 2.6097574006633715 * s - 0.3413193963102197 * c,
|
|
50
|
-
b: -0.004196086541837188 * o - 0.7034186144594493 * s + 1.7076147009309444 * c
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function g(n) {
|
|
54
|
-
const r = (e) => {
|
|
55
|
-
const t = Math.abs(e);
|
|
56
|
-
return t > 31308e-7 ? (Math.sign(e) || 1) * (1.055 * Math.pow(t, 0.4166666666666667) - 0.055) : e * 12.92;
|
|
57
|
-
};
|
|
58
|
-
return { r: r(n.r) * 255, g: r(n.g) * 255, b: r(n.b) * 255 };
|
|
59
|
-
}
|
|
60
|
-
function a(n) {
|
|
61
|
-
return g(b(h(n)));
|
|
62
|
-
}
|
|
63
|
-
function p(n) {
|
|
64
|
-
let r = a(n);
|
|
65
|
-
const e = (t) => [t.r, t.g, t.b].some((o) => o < 0 || o > 255);
|
|
66
|
-
if (e(r) && !e(a({ ...n, c: 0 }))) {
|
|
67
|
-
let t = 0, o = n.c, s = 0;
|
|
68
|
-
const c = 0.4 / Math.pow(2, 13);
|
|
69
|
-
for (; o - t > c; ) {
|
|
70
|
-
const u = t + (o - t) * 0.5, i = a({ ...n, c: u });
|
|
71
|
-
e(i) ? o = u : (s = u, t = u);
|
|
72
|
-
}
|
|
73
|
-
r = a({ ...n, c: s });
|
|
74
|
-
}
|
|
75
|
-
return r;
|
|
76
|
-
}
|
|
77
|
-
function d(n, r, e) {
|
|
78
|
-
return `#${((1 << 24) + (n << 16) + (r << 8) + e).toString(16).slice(1)}`;
|
|
79
|
-
}
|
|
80
|
-
function m(n) {
|
|
81
|
-
const [r, e, t] = [n.r, n.g, n.b].map((o) => {
|
|
82
|
-
const s = Math.round(o);
|
|
83
|
-
return Math.min(Math.max(s, 0), 255);
|
|
84
|
-
});
|
|
85
|
-
return {
|
|
86
|
-
r,
|
|
87
|
-
g: e,
|
|
88
|
-
b: t
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
function w(n, r, e, t) {
|
|
92
|
-
const o = p({ l: n / 100, c: r, h: e }), { r: s, g: c, b: u } = m(o);
|
|
93
|
-
return t ? `rgba(${s},${c},${u},${t})` : d(s, c, u);
|
|
94
|
-
}
|
|
95
|
-
export {
|
|
96
|
-
M as convertCategories,
|
|
97
|
-
f as getColorValue,
|
|
98
|
-
l as getOklchFromCssVariable,
|
|
99
|
-
w as oklch2web
|
|
100
|
-
};
|