vue-chrts 0.1.1-test.2 → 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.
- package/dist/components/AreaChart/AreaChart.js +77 -79
- 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,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
|
-
};
|