vue-chrts 0.1.10 → 0.1.11
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 +64 -61
- package/dist/components/AreaChart/types.d.ts +21 -13
- package/dist/components/BarChart/BarChart.js +21 -20
- package/dist/components/BarChart/types.d.ts +12 -12
- package/dist/components/LineChart/LineChart.js +18 -16
- package/dist/components/LineChart/types.d.ts +12 -12
- 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 +9 -8
|
@@ -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 O, computed as g, createApp as $, createElementBlock as c, openBlock as o, normalizeClass as T, createVNode as p, createCommentVNode as s, unref as i, withCtx as E, createBlock as d, Fragment as h, renderList as G, mergeProps as N } from "vue";
|
|
2
|
+
import { Position as v, CurveType as L } 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 X from "../Tooltip.js";
|
|
5
|
+
import { LegendPosition as Y } from "../../types.js";
|
|
6
|
+
import { getFirstPropertyValue as w } from "../../utils.js";
|
|
7
|
+
const m = 24, B = 4, z = 0.5, C = "#3b82f6", Z = /* @__PURE__ */ O({
|
|
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: (
|
|
24
|
+
xNumTicks: { default: (n) => n.data.length > m ? m / B : n.data.length - 1 },
|
|
24
25
|
xExplicitTicks: {},
|
|
25
26
|
minMaxTicksOnly: { type: Boolean },
|
|
26
|
-
yNumTicks: { default: (
|
|
27
|
+
yNumTicks: { default: (n) => n.data.length > m ? m / B : n.data.length - 1 },
|
|
27
28
|
hideLegend: { type: Boolean },
|
|
28
29
|
hideTooltip: { type: Boolean },
|
|
29
30
|
legendPosition: {},
|
|
@@ -32,36 +33,36 @@ const p = 24, x = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
|
|
|
32
33
|
xTickLine: { type: Boolean },
|
|
33
34
|
yTickLine: { type: Boolean },
|
|
34
35
|
xGridLine: { type: Boolean },
|
|
35
|
-
yGridLine: { type: Boolean }
|
|
36
|
+
yGridLine: { type: Boolean },
|
|
37
|
+
hideXAxis: { type: Boolean },
|
|
38
|
+
hideYAxis: { type: Boolean }
|
|
36
39
|
},
|
|
37
|
-
setup(
|
|
38
|
-
const
|
|
40
|
+
setup(n) {
|
|
41
|
+
const a = n, u = Object.values(a.categories).map((e) => e.color), A = g(() => (e) => {
|
|
39
42
|
if (typeof window > "u" || typeof document > "u")
|
|
40
43
|
return "";
|
|
41
44
|
try {
|
|
42
|
-
const
|
|
45
|
+
const t = $(X, {
|
|
43
46
|
data: e,
|
|
44
|
-
categories:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
categories: a.categories,
|
|
48
|
+
toolTipTitle: w(e),
|
|
49
|
+
yFormatter: a.yFormatter
|
|
50
|
+
}), r = document.createElement("div");
|
|
51
|
+
t.mount(r);
|
|
52
|
+
const l = r.innerHTML;
|
|
53
|
+
return t.unmount(), l;
|
|
50
54
|
} catch {
|
|
51
55
|
return "";
|
|
52
56
|
}
|
|
53
57
|
});
|
|
54
|
-
P(() => {
|
|
55
|
-
d.value && (d.value.unmount(), d.value = null), k.value && (k.value = null);
|
|
56
|
-
});
|
|
57
58
|
function F(e) {
|
|
58
59
|
var t;
|
|
59
60
|
return {
|
|
60
|
-
y: (
|
|
61
|
-
color: ((t =
|
|
61
|
+
y: (r) => Number(r[e]),
|
|
62
|
+
color: ((t = a.categories[e]) == null ? void 0 : t.color) ?? C
|
|
62
63
|
};
|
|
63
64
|
}
|
|
64
|
-
function
|
|
65
|
+
function V(e, t) {
|
|
65
66
|
return `
|
|
66
67
|
<linearGradient id="gradient${e}-${t}" gradientTransform="rotate(90)">
|
|
67
68
|
<stop offset="0%" style="stop-color:var(--vis-color0);stop-opacity:1" />
|
|
@@ -69,7 +70,7 @@ const p = 24, x = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
|
|
|
69
70
|
</linearGradient>
|
|
70
71
|
`;
|
|
71
72
|
}
|
|
72
|
-
function
|
|
73
|
+
function x(e, t) {
|
|
73
74
|
return `
|
|
74
75
|
<linearGradient id="gradient${e}-${t}" gradientTransform="rotate(90)">
|
|
75
76
|
<stop offset="0%" stop-color="${t}" stop-opacity="1" />
|
|
@@ -77,45 +78,46 @@ const p = 24, x = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
|
|
|
77
78
|
</linearGradient>
|
|
78
79
|
`;
|
|
79
80
|
}
|
|
80
|
-
const
|
|
81
|
-
() =>
|
|
82
|
-
(e, t) => e != null && e.includes("#") ?
|
|
81
|
+
const D = g(
|
|
82
|
+
() => u.map(
|
|
83
|
+
(e, t) => e != null && e.includes("#") ? x(t, e) : V(t, e ?? C)
|
|
83
84
|
).join("")
|
|
84
|
-
),
|
|
85
|
-
() =>
|
|
85
|
+
), k = g(
|
|
86
|
+
() => a.legendPosition === Y.Top
|
|
86
87
|
);
|
|
87
|
-
return (e, t) => (
|
|
88
|
-
class:
|
|
88
|
+
return (e, t) => (o(), c("div", {
|
|
89
|
+
class: T(["flex flex-col space-y-4", { "flex-col-reverse": k.value }])
|
|
89
90
|
}, [
|
|
90
|
-
|
|
91
|
+
p(i(P), {
|
|
91
92
|
data: e.data,
|
|
92
93
|
height: e.height,
|
|
93
94
|
padding: e.padding,
|
|
94
|
-
"svg-defs":
|
|
95
|
+
"svg-defs": D.value
|
|
95
96
|
}, {
|
|
96
|
-
default:
|
|
97
|
-
e.hideTooltip ?
|
|
97
|
+
default: E(() => [
|
|
98
|
+
e.hideTooltip ? s("", !0) : (o(), d(i(j), {
|
|
98
99
|
key: 0,
|
|
99
|
-
"horizontal-placement":
|
|
100
|
-
"vertical-placement":
|
|
100
|
+
"horizontal-placement": i(v).Right,
|
|
101
|
+
"vertical-placement": i(v).Top
|
|
101
102
|
}, null, 8, ["horizontal-placement", "vertical-placement"])),
|
|
102
|
-
(
|
|
103
|
-
|
|
104
|
-
x: (
|
|
103
|
+
(o(!0), c(h, null, G(Object.keys(a.categories), (r, l) => (o(), c(h, { key: l }, [
|
|
104
|
+
p(i(I), N({
|
|
105
|
+
x: (y, f) => f,
|
|
105
106
|
ref_for: !0
|
|
106
|
-
}, F(
|
|
107
|
-
color: `url(#gradient${
|
|
108
|
-
opacity:
|
|
109
|
-
"curve-type": e.curveType ??
|
|
107
|
+
}, F(r), {
|
|
108
|
+
color: `url(#gradient${l}-${i(u)[l]})`,
|
|
109
|
+
opacity: z,
|
|
110
|
+
"curve-type": e.curveType ?? i(L).MonotoneX
|
|
110
111
|
}), null, 16, ["x", "color", "curve-type"]),
|
|
111
|
-
|
|
112
|
-
x: (
|
|
113
|
-
y: (
|
|
114
|
-
color:
|
|
115
|
-
"curve-type": e.curveType ??
|
|
112
|
+
p(i(M), {
|
|
113
|
+
x: (y, f) => f,
|
|
114
|
+
y: (y) => y[r],
|
|
115
|
+
color: i(u)[l],
|
|
116
|
+
"curve-type": e.curveType ?? i(L).MonotoneX
|
|
116
117
|
}, null, 8, ["x", "y", "color", "curve-type"])
|
|
117
118
|
], 64))), 128)),
|
|
118
|
-
s(
|
|
119
|
+
e.hideXAxis ? s("", !0) : (o(), d(i(b), {
|
|
120
|
+
key: 1,
|
|
119
121
|
type: "x",
|
|
120
122
|
"tick-format": e.xFormatter,
|
|
121
123
|
label: e.xLabel,
|
|
@@ -126,8 +128,9 @@ const p = 24, x = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
|
|
|
126
128
|
"tick-line": e.xTickLine,
|
|
127
129
|
"tick-values": e.xExplicitTicks,
|
|
128
130
|
"min-max-ticks-only": e.minMaxTicksOnly
|
|
129
|
-
}, null, 8, ["tick-format", "label", "domain-line", "grid-line", "num-ticks", "tick-line", "tick-values", "min-max-ticks-only"]),
|
|
130
|
-
s(
|
|
131
|
+
}, null, 8, ["tick-format", "label", "domain-line", "grid-line", "num-ticks", "tick-line", "tick-values", "min-max-ticks-only"])),
|
|
132
|
+
e.hideYAxis ? s("", !0) : (o(), d(i(b), {
|
|
133
|
+
key: 2,
|
|
131
134
|
type: "y",
|
|
132
135
|
"num-ticks": e.yNumTicks,
|
|
133
136
|
"tick-format": e.yFormatter,
|
|
@@ -135,20 +138,20 @@ const p = 24, x = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
|
|
|
135
138
|
"grid-line": e.yGridLine,
|
|
136
139
|
"domain-line": e.yDomainLine,
|
|
137
140
|
"tick-line": e.yTickLine
|
|
138
|
-
}, null, 8, ["num-ticks", "tick-format", "label", "grid-line", "domain-line", "tick-line"]),
|
|
139
|
-
e.hideTooltip ?
|
|
140
|
-
key:
|
|
141
|
+
}, null, 8, ["num-ticks", "tick-format", "label", "grid-line", "domain-line", "tick-line"])),
|
|
142
|
+
e.hideTooltip ? s("", !0) : (o(), d(i(S), {
|
|
143
|
+
key: 3,
|
|
141
144
|
color: "#666",
|
|
142
|
-
template:
|
|
145
|
+
template: A.value
|
|
143
146
|
}, null, 8, ["template"]))
|
|
144
147
|
]),
|
|
145
148
|
_: 1
|
|
146
149
|
}, 8, ["data", "height", "padding", "svg-defs"]),
|
|
147
|
-
e.hideLegend ?
|
|
150
|
+
e.hideLegend ? s("", !0) : (o(), c("div", {
|
|
148
151
|
key: 0,
|
|
149
|
-
class:
|
|
152
|
+
class: T(["flex items-center justify-end", { "pb-4": k.value }])
|
|
150
153
|
}, [
|
|
151
|
-
|
|
154
|
+
p(i(U), {
|
|
152
155
|
items: Object.values(e.categories)
|
|
153
156
|
}, null, 8, ["items"])
|
|
154
157
|
], 2))
|
|
@@ -156,5 +159,5 @@ const p = 24, x = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
|
|
|
156
159
|
}
|
|
157
160
|
});
|
|
158
161
|
export {
|
|
159
|
-
|
|
162
|
+
Z as default
|
|
160
163
|
};
|
|
@@ -35,19 +35,19 @@ export interface AreaChartProps<T> {
|
|
|
35
35
|
*/
|
|
36
36
|
categories: Record<string, BulletLegendItemInterface>;
|
|
37
37
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
xFormatter:
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
yFormatter?: (i: number,
|
|
38
|
+
* @param {number|Date} tick - The value of the tick. This can be a number or a Date object depending on the scale of the x-axis.
|
|
39
|
+
* @param {number} i - The index of the tick in the `ticks` array.
|
|
40
|
+
* @param {(number[]|Date[])} ticks - An array of all tick values for the x-axis.
|
|
41
|
+
* @returns {string} The formatted string representation of the tick.
|
|
42
|
+
*/
|
|
43
|
+
xFormatter?: ((tick: number, i: number, ticks: number[]) => string) | ((tick: Date, i: number, ticks: Date[]) => string);
|
|
44
|
+
/**
|
|
45
|
+
* @param {number|Date} tick - The value of the tick. This can be a number or a Date object depending on the scale of the y-axis.
|
|
46
|
+
* @param {number} i - The index of the tick in the `ticks` array.
|
|
47
|
+
* @param {(number[]|Date[])} ticks - An array of all tick values for the y-axis.
|
|
48
|
+
* @returns {string} The formatted string representation of the tick.
|
|
49
|
+
*/
|
|
50
|
+
yFormatter?: ((tick: number, i: number, ticks: number[]) => string) | ((tick: Date, i: number, ticks: Date[]) => string);
|
|
51
51
|
/**
|
|
52
52
|
* The type of curve to use for the area chart lines.
|
|
53
53
|
* See `CurveType` for available options.
|
|
@@ -106,4 +106,12 @@ export interface AreaChartProps<T> {
|
|
|
106
106
|
* If `true`, displays grid lines along the y-axis.
|
|
107
107
|
*/
|
|
108
108
|
yGridLine?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* If `true`, hide the x-axis.
|
|
111
|
+
*/
|
|
112
|
+
hideXAxis?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* If `true`, hide the y-axis.
|
|
115
|
+
*/
|
|
116
|
+
hideYAxis?: boolean;
|
|
109
117
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { defineComponent as v, computed as c, createApp as V, createElementBlock as f, openBlock as l, normalizeClass as b, createVNode as r, createCommentVNode as x, unref as i, withCtx as P, createBlock as h } from "vue";
|
|
2
2
|
import { Orientation as s, StackedBar as A, GroupedBar as O } from "@unovis/ts";
|
|
3
|
-
import { VisXYContainer as C, VisTooltip as
|
|
4
|
-
import
|
|
5
|
-
import { LegendPosition as
|
|
3
|
+
import { VisXYContainer as C, VisTooltip as F, VisGroupedBar as G, VisStackedBar as N, VisAxis as L, VisBulletLegend as j } from "@unovis/vue";
|
|
4
|
+
import w from "../Tooltip.js";
|
|
5
|
+
import { LegendPosition as E } from "../../types.js";
|
|
6
6
|
const S = /* @__PURE__ */ v({
|
|
7
7
|
__name: "BarChart",
|
|
8
8
|
props: {
|
|
@@ -20,9 +20,9 @@ const S = /* @__PURE__ */ v({
|
|
|
20
20
|
categories: {},
|
|
21
21
|
xFormatter: {},
|
|
22
22
|
yFormatter: {},
|
|
23
|
-
yNumTicks: { default: (
|
|
23
|
+
yNumTicks: { default: (a) => a.data.length > 24 ? 24 / 4 : a.data.length - 1 },
|
|
24
24
|
minMaxTicksOnly: { type: Boolean },
|
|
25
|
-
xNumTicks: { default: (
|
|
25
|
+
xNumTicks: { default: (a) => a.data.length > 24 ? 24 / 4 : a.data.length - 1 },
|
|
26
26
|
xExplicitTicks: {},
|
|
27
27
|
yAxis: {},
|
|
28
28
|
groupPadding: {},
|
|
@@ -38,25 +38,26 @@ const S = /* @__PURE__ */ v({
|
|
|
38
38
|
xGridLine: { type: Boolean },
|
|
39
39
|
yGridLine: { type: Boolean, default: !0 }
|
|
40
40
|
},
|
|
41
|
-
setup(
|
|
42
|
-
const
|
|
43
|
-
if (!
|
|
41
|
+
setup(a) {
|
|
42
|
+
const n = a;
|
|
43
|
+
if (!n.yAxis || n.yAxis.length === 0)
|
|
44
44
|
throw new Error("yAxis is required");
|
|
45
|
-
const m = c(() =>
|
|
46
|
-
() =>
|
|
45
|
+
const m = c(() => n.yAxis.map((e) => (t) => t[e])), p = (e, t) => Object.values(n.categories)[t].color, g = c(
|
|
46
|
+
() => n.legendPosition === E.Top
|
|
47
47
|
), y = c(() => (e, t) => {
|
|
48
48
|
if (typeof window > "u" || typeof document > "u")
|
|
49
49
|
return "";
|
|
50
|
-
const u = Object.keys(
|
|
50
|
+
const u = Object.keys(n.categories), T = Object.keys(e).find((o) => !u.includes(o));
|
|
51
51
|
try {
|
|
52
|
-
const o = V(
|
|
52
|
+
const o = V(w, {
|
|
53
53
|
data: e,
|
|
54
|
-
categories:
|
|
55
|
-
|
|
54
|
+
categories: n.categories,
|
|
55
|
+
toolTipTitle: e[T],
|
|
56
|
+
yFormatter: n.yFormatter
|
|
56
57
|
}), k = document.createElement("div");
|
|
57
58
|
o.mount(k);
|
|
58
|
-
const
|
|
59
|
-
return o.unmount(),
|
|
59
|
+
const B = k.innerHTML;
|
|
60
|
+
return o.unmount(), B;
|
|
60
61
|
} catch {
|
|
61
62
|
return "";
|
|
62
63
|
}
|
|
@@ -69,13 +70,13 @@ const S = /* @__PURE__ */ v({
|
|
|
69
70
|
height: e.height
|
|
70
71
|
}, {
|
|
71
72
|
default: P(() => [
|
|
72
|
-
r(i(
|
|
73
|
+
r(i(F), {
|
|
73
74
|
triggers: {
|
|
74
75
|
[i(O).selectors.bar]: y.value,
|
|
75
76
|
[i(A).selectors.bar]: y.value
|
|
76
77
|
}
|
|
77
78
|
}, null, 8, ["triggers"]),
|
|
78
|
-
e.stacked ? (l(), h(i(
|
|
79
|
+
e.stacked ? (l(), h(i(N), {
|
|
79
80
|
key: 1,
|
|
80
81
|
data: e.data,
|
|
81
82
|
x: (u, d) => d,
|
|
@@ -85,7 +86,7 @@ const S = /* @__PURE__ */ v({
|
|
|
85
86
|
"group-padding": e.groupPadding ?? 0,
|
|
86
87
|
"bar-padding": e.barPadding ?? 0.2,
|
|
87
88
|
orientation: e.orientation ?? i(s).Vertical
|
|
88
|
-
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (l(), h(i(
|
|
89
|
+
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (l(), h(i(G), {
|
|
89
90
|
key: 0,
|
|
90
91
|
data: e.data,
|
|
91
92
|
x: (u, d) => d,
|
|
@@ -123,7 +124,7 @@ const S = /* @__PURE__ */ v({
|
|
|
123
124
|
key: 0,
|
|
124
125
|
class: b(["flex items center justify-end", { "pb-4": g.value }])
|
|
125
126
|
}, [
|
|
126
|
-
r(i(
|
|
127
|
+
r(i(j), {
|
|
127
128
|
items: Object.values(e.categories)
|
|
128
129
|
}, null, 8, ["items"])
|
|
129
130
|
], 2))
|
|
@@ -38,19 +38,19 @@ export interface BarChartProps<T> {
|
|
|
38
38
|
*/
|
|
39
39
|
categories: Record<string, BulletLegendItemInterface>;
|
|
40
40
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
xFormatter:
|
|
41
|
+
* @param {number|Date} tick - The value of the tick. This can be a number or a Date object depending on the scale of the x-axis.
|
|
42
|
+
* @param {number} i - The index of the tick in the `ticks` array.
|
|
43
|
+
* @param {(number[]|Date[])} ticks - An array of all tick values for the x-axis.
|
|
44
|
+
* @returns {string} The formatted string representation of the tick.
|
|
45
|
+
*/
|
|
46
|
+
xFormatter?: ((tick: number, i: number, ticks: number[]) => string) | ((tick: Date, i: number, ticks: Date[]) => string);
|
|
47
47
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
yFormatter?: (i: number,
|
|
48
|
+
* @param {number|Date} tick - The value of the tick. This can be a number or a Date object depending on the scale of the y-axis.
|
|
49
|
+
* @param {number} i - The index of the tick in the `ticks` array.
|
|
50
|
+
* @param {(number[]|Date[])} ticks - An array of all tick values for the y-axis.
|
|
51
|
+
* @returns {string} The formatted string representation of the tick.
|
|
52
|
+
*/
|
|
53
|
+
yFormatter?: ((tick: number, i: number, ticks: number[]) => string) | ((tick: Date, i: number, ticks: Date[]) => string);
|
|
54
54
|
/**
|
|
55
55
|
* The desired number of ticks on the y-axis.
|
|
56
56
|
*/
|
|
@@ -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
|
};
|
|
@@ -34,19 +34,19 @@ export interface LineChartProps<T> {
|
|
|
34
34
|
*/
|
|
35
35
|
categories: Record<string, BulletLegendItemInterface>;
|
|
36
36
|
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
xFormatter:
|
|
37
|
+
* @param {number|Date} tick - The value of the tick. This can be a number or a Date object depending on the scale of the x-axis.
|
|
38
|
+
* @param {number} i - The index of the tick in the `ticks` array.
|
|
39
|
+
* @param {(number[]|Date[])} ticks - An array of all tick values for the x-axis.
|
|
40
|
+
* @returns {string} The formatted string representation of the tick.
|
|
41
|
+
*/
|
|
42
|
+
xFormatter?: ((tick: number, i: number, ticks: number[]) => string) | ((tick: Date, i: number, ticks: Date[]) => string);
|
|
43
43
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
yFormatter?: (i: number,
|
|
44
|
+
* @param {number|Date} tick - The value of the tick. This can be a number or a Date object depending on the scale of the y-axis.
|
|
45
|
+
* @param {number} i - The index of the tick in the `ticks` array.
|
|
46
|
+
* @param {(number[]|Date[])} ticks - An array of all tick values for the y-axis.
|
|
47
|
+
* @returns {string} The formatted string representation of the tick.
|
|
48
|
+
*/
|
|
49
|
+
yFormatter?: ((tick: number, i: number, ticks: number[]) => string) | ((tick: Date, i: number, ticks: Date[]) => string);
|
|
50
50
|
/**
|
|
51
51
|
* The type of curve to use for the line chart.
|
|
52
52
|
* See `CurveType` for available options.
|
|
@@ -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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-chrts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -14,6 +14,12 @@
|
|
|
14
14
|
"require": "./dist/index.umd.cjs"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"dev": "vite",
|
|
19
|
+
"build": "vue-tsc -b && vite build",
|
|
20
|
+
"preview": "vite preview",
|
|
21
|
+
"release": "commit-and-tag-version"
|
|
22
|
+
},
|
|
17
23
|
"peerDependencies": {
|
|
18
24
|
"vue": "^3.5.13"
|
|
19
25
|
},
|
|
@@ -34,10 +40,5 @@
|
|
|
34
40
|
"vue-router": "^4.5.0",
|
|
35
41
|
"vue-tsc": "^2.2.4"
|
|
36
42
|
},
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
"build": "vue-tsc -b && vite build",
|
|
40
|
-
"preview": "vite preview",
|
|
41
|
-
"release": "commit-and-tag-version"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
43
|
+
"packageManager": "pnpm@8.15.4+sha256.cea6d0bdf2de3a0549582da3983c70c92ffc577ff4410cbf190817ddc35137c2"
|
|
44
|
+
}
|