vue-chrts 0.1.0 → 0.1.1-test.2
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/colors.d.ts +11 -0
- package/dist/colors.js +100 -0
- package/dist/components/AreaChart/AreaChart.js +74 -63
- package/package.json +2 -1
package/dist/colors.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import R from "
|
|
5
|
-
import
|
|
6
|
-
|
|
1
|
+
import { defineComponent as G, ref as T, computed as L, createApp as M, onUnmounted as P, createElementBlock as m, openBlock as s, normalizeClass as h, createVNode as c, createCommentVNode as v, unref as o, withCtx as $, createBlock as C, Fragment as b, renderList as U, mergeProps as j } from "vue";
|
|
2
|
+
import { getColorValue as I, getOklchFromCssVariable as w, oklch2web as g, convertCategories as z } from "../../colors.js";
|
|
3
|
+
import { Position as x, CurveType as V } from "@unovis/ts";
|
|
4
|
+
import { VisXYContainer as H, VisTooltip as R, VisArea as X, VisLine as Y, VisAxis as B, VisCrosshair as S, VisBulletLegend as q } from "@unovis/vue";
|
|
5
|
+
import J from "../Tooltip.js";
|
|
6
|
+
import { LegendPosition as Q } from "../../types.js";
|
|
7
|
+
const p = 24, O = 4, W = 0.5, A = "#3b82f6", ne = /* @__PURE__ */ G({
|
|
7
8
|
__name: "AreaChart",
|
|
8
9
|
props: {
|
|
9
10
|
data: {},
|
|
@@ -14,10 +15,10 @@ const m = 24, A = 4, Y = 0.5, H = "#3b82f6", Z = /* @__PURE__ */ E({
|
|
|
14
15
|
xFormatter: {},
|
|
15
16
|
yFormatter: {},
|
|
16
17
|
curveType: {},
|
|
17
|
-
xNumTicks: { default: (i) => i.data.length >
|
|
18
|
+
xNumTicks: { default: (i) => i.data.length > p ? p / O : i.data.length - 1 },
|
|
18
19
|
xExplicitTicks: {},
|
|
19
20
|
minMaxTicksOnly: { type: Boolean },
|
|
20
|
-
yNumTicks: { default: (i) => i.data.length >
|
|
21
|
+
yNumTicks: { default: (i) => i.data.length > p ? p / O : i.data.length - 1 },
|
|
21
22
|
hideLegend: { type: Boolean },
|
|
22
23
|
hideTooltip: { type: Boolean },
|
|
23
24
|
xGridLine: { type: Boolean },
|
|
@@ -28,77 +29,89 @@ const m = 24, A = 4, Y = 0.5, H = "#3b82f6", Z = /* @__PURE__ */ E({
|
|
|
28
29
|
legendPosition: {}
|
|
29
30
|
},
|
|
30
31
|
setup(i) {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
t
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
return console.error("Error generating tooltip:", t), "";
|
|
47
|
-
}
|
|
32
|
+
const a = i, d = Object.values(a.categories).map(
|
|
33
|
+
(e) => I(e.color, g)
|
|
34
|
+
), D = Object.values(a.categories).map((e) => {
|
|
35
|
+
var n;
|
|
36
|
+
if ((n = e.color) != null && n.includes("#")) return e;
|
|
37
|
+
const t = w(e.color);
|
|
38
|
+
return t ? {
|
|
39
|
+
...e,
|
|
40
|
+
color: g(
|
|
41
|
+
t.l,
|
|
42
|
+
t.c,
|
|
43
|
+
t.h,
|
|
44
|
+
t.a
|
|
45
|
+
)
|
|
46
|
+
} : { ...e, color: A };
|
|
48
47
|
});
|
|
49
|
-
|
|
50
|
-
n.value && (n.value.unmount(), n.value = null), a.value && (a.value = null);
|
|
51
|
-
});
|
|
52
|
-
function O(e) {
|
|
48
|
+
function F(e) {
|
|
53
49
|
var t;
|
|
54
50
|
return {
|
|
55
|
-
y: (
|
|
56
|
-
color: ((t =
|
|
51
|
+
y: (n) => Number(n[e]),
|
|
52
|
+
color: ((t = a.categories[e]) == null ? void 0 : t.color) ?? A
|
|
57
53
|
};
|
|
58
54
|
}
|
|
59
|
-
const
|
|
60
|
-
()
|
|
61
|
-
|
|
55
|
+
const r = T(null), l = T(null), E = L(() => (e) => {
|
|
56
|
+
if (typeof window > "u") return "";
|
|
57
|
+
l.value || (l.value = document.createElement("div"));
|
|
58
|
+
const t = z(a.categories, g);
|
|
59
|
+
try {
|
|
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) => `
|
|
62
76
|
<linearGradient id="gradient${t}-${e}" gradientTransform="rotate(90)">
|
|
63
77
|
<stop offset="0%" stop-color="${e}" stop-opacity="1" />
|
|
64
78
|
<stop offset="100%" stop-color="${e}" stop-opacity="0" />
|
|
65
79
|
</linearGradient>
|
|
66
80
|
`
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
() => l.legendPosition === X.Top
|
|
81
|
+
).join(""), k = L(
|
|
82
|
+
() => a.legendPosition === Q.Top
|
|
70
83
|
);
|
|
71
|
-
return (e, t) => (
|
|
72
|
-
class:
|
|
84
|
+
return (e, t) => (s(), m("div", {
|
|
85
|
+
class: h(["flex flex-col space-y-4", { "flex-col-reverse": k.value }])
|
|
73
86
|
}, [
|
|
74
|
-
|
|
87
|
+
c(o(H), {
|
|
75
88
|
data: e.data,
|
|
76
89
|
height: e.height,
|
|
77
|
-
"svg-defs":
|
|
90
|
+
"svg-defs": o(N)
|
|
78
91
|
}, {
|
|
79
|
-
default:
|
|
80
|
-
e.hideTooltip ? v("", !0) : (
|
|
92
|
+
default: $(() => [
|
|
93
|
+
e.hideTooltip ? v("", !0) : (s(), C(o(R), {
|
|
81
94
|
key: 0,
|
|
82
95
|
"horizontal-placement": o(x).Right,
|
|
83
96
|
"vertical-placement": o(x).Top
|
|
84
97
|
}, null, 8, ["horizontal-placement", "vertical-placement"])),
|
|
85
|
-
(
|
|
86
|
-
|
|
87
|
-
x: (
|
|
98
|
+
(s(!0), m(b, null, U(Object.keys(a.categories), (n, u) => (s(), m(b, { key: u }, [
|
|
99
|
+
c(o(X), j({
|
|
100
|
+
x: (f, y) => y,
|
|
88
101
|
ref_for: !0
|
|
89
|
-
},
|
|
102
|
+
}, F(n), {
|
|
90
103
|
color: `url(#gradient${u}-${o(d)[u]})`,
|
|
91
|
-
opacity:
|
|
92
|
-
"curve-type": e.curveType ?? o(
|
|
104
|
+
opacity: W,
|
|
105
|
+
"curve-type": e.curveType ?? o(V).MonotoneX
|
|
93
106
|
}), null, 16, ["x", "color", "curve-type"]),
|
|
94
|
-
|
|
95
|
-
x: (
|
|
96
|
-
y: (
|
|
107
|
+
c(o(Y), {
|
|
108
|
+
x: (f, y) => y,
|
|
109
|
+
y: (f) => f[n],
|
|
97
110
|
color: o(d)[u],
|
|
98
|
-
"curve-type": e.curveType ?? o(
|
|
111
|
+
"curve-type": e.curveType ?? o(V).MonotoneX
|
|
99
112
|
}, null, 8, ["x", "y", "color", "curve-type"])
|
|
100
113
|
], 64))), 128)),
|
|
101
|
-
|
|
114
|
+
c(o(B), {
|
|
102
115
|
type: "x",
|
|
103
116
|
"tick-format": e.xFormatter,
|
|
104
117
|
label: e.xLabel,
|
|
@@ -110,7 +123,7 @@ const m = 24, A = 4, Y = 0.5, H = "#3b82f6", Z = /* @__PURE__ */ E({
|
|
|
110
123
|
"tick-values": e.xExplicitTicks,
|
|
111
124
|
"min-max-ticks-only": e.minMaxTicksOnly
|
|
112
125
|
}, null, 8, ["tick-format", "label", "domain-line", "grid-line", "num-ticks", "tick-line", "tick-values", "min-max-ticks-only"]),
|
|
113
|
-
|
|
126
|
+
c(o(B), {
|
|
114
127
|
type: "y",
|
|
115
128
|
"num-ticks": e.yNumTicks,
|
|
116
129
|
"tick-format": e.yFormatter,
|
|
@@ -119,25 +132,23 @@ const m = 24, A = 4, Y = 0.5, H = "#3b82f6", Z = /* @__PURE__ */ E({
|
|
|
119
132
|
"domain-line": e.yDomainLine,
|
|
120
133
|
"tick-line": !!e.yGridLine
|
|
121
134
|
}, null, 8, ["num-ticks", "tick-format", "label", "grid-line", "domain-line", "tick-line"]),
|
|
122
|
-
e.hideTooltip ? v("", !0) : (
|
|
135
|
+
e.hideTooltip ? v("", !0) : (s(), C(o(S), {
|
|
123
136
|
key: 1,
|
|
124
137
|
color: "#666",
|
|
125
|
-
template:
|
|
138
|
+
template: E.value
|
|
126
139
|
}, null, 8, ["template"]))
|
|
127
140
|
]),
|
|
128
141
|
_: 1
|
|
129
142
|
}, 8, ["data", "height", "svg-defs"]),
|
|
130
|
-
e.hideLegend ? v("", !0) : (
|
|
143
|
+
e.hideLegend ? v("", !0) : (s(), m("div", {
|
|
131
144
|
key: 0,
|
|
132
|
-
class:
|
|
145
|
+
class: h(["flex items-center justify-end", { "pb-4": k.value }])
|
|
133
146
|
}, [
|
|
134
|
-
|
|
135
|
-
items: Object.values(e.categories)
|
|
136
|
-
}, null, 8, ["items"])
|
|
147
|
+
c(o(q), { items: o(D) }, null, 8, ["items"])
|
|
137
148
|
], 2))
|
|
138
149
|
], 2));
|
|
139
150
|
}
|
|
140
151
|
});
|
|
141
152
|
export {
|
|
142
|
-
|
|
153
|
+
ne as default
|
|
143
154
|
};
|
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.2",
|
|
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",
|