vue-chrts 0.1.6 → 0.1.8
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 +34 -27
- package/dist/components/AreaChart/types.d.ts +10 -0
- package/dist/components/AreaStackedChart/AreaStackedChart.js +42 -31
- package/dist/components/AreaStackedChart/AreaStackedChart.vue.d.ts +1 -7
- package/dist/components/AreaStackedChart/types.d.ts +10 -0
- package/dist/components/BarChart/BarChart.js +35 -26
- package/dist/components/BarChart/types.d.ts +10 -0
- package/dist/components/LineChart/LineChart.js +26 -19
- package/dist/components/LineChart/types.d.ts +10 -0
- package/package.json +1 -1
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
import { defineComponent as G, 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
|
|
1
|
+
import { defineComponent as G, 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 n, withCtx as M, createBlock as h, Fragment as b, renderList as U, mergeProps as j } from "vue";
|
|
2
2
|
import { Position as C, CurveType as B } from "@unovis/ts";
|
|
3
|
-
import { VisXYContainer as I, VisTooltip as S, VisArea as w, VisLine as z, VisAxis as
|
|
3
|
+
import { VisXYContainer as I, VisTooltip as S, VisArea as w, VisLine as z, VisAxis as V, VisCrosshair as R, VisBulletLegend as X } from "@unovis/vue";
|
|
4
4
|
import Y from "../Tooltip.js";
|
|
5
5
|
import { LegendPosition as H } from "../../types.js";
|
|
6
|
-
const p = 24,
|
|
6
|
+
const p = 24, x = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
|
|
7
7
|
__name: "AreaChart",
|
|
8
8
|
props: {
|
|
9
9
|
data: {},
|
|
10
10
|
height: {},
|
|
11
11
|
xLabel: {},
|
|
12
12
|
yLabel: {},
|
|
13
|
+
padding: { default: () => ({
|
|
14
|
+
top: 5,
|
|
15
|
+
right: 5,
|
|
16
|
+
bottom: 5,
|
|
17
|
+
left: 5
|
|
18
|
+
}) },
|
|
13
19
|
categories: {},
|
|
14
20
|
xFormatter: {},
|
|
15
21
|
yFormatter: {},
|
|
16
22
|
curveType: {},
|
|
17
|
-
xNumTicks: { default: (i) => i.data.length > p ? p /
|
|
23
|
+
xNumTicks: { default: (i) => i.data.length > p ? p / x : i.data.length - 1 },
|
|
18
24
|
xExplicitTicks: {},
|
|
19
25
|
minMaxTicksOnly: { type: Boolean },
|
|
20
|
-
yNumTicks: { default: (i) => i.data.length > p ? p /
|
|
26
|
+
yNumTicks: { default: (i) => i.data.length > p ? p / x : i.data.length - 1 },
|
|
21
27
|
hideLegend: { type: Boolean },
|
|
22
28
|
hideTooltip: { type: Boolean },
|
|
23
29
|
legendPosition: {},
|
|
@@ -33,14 +39,14 @@ const p = 24, V = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
|
|
|
33
39
|
if (typeof window > "u" || typeof document > "u")
|
|
34
40
|
return "";
|
|
35
41
|
try {
|
|
36
|
-
const
|
|
42
|
+
const o = N(Y, {
|
|
37
43
|
data: e,
|
|
38
44
|
categories: r.categories,
|
|
39
45
|
xValue: r.xFormatter(Math.floor(t))
|
|
40
46
|
}), a = document.createElement("div");
|
|
41
|
-
|
|
47
|
+
o.mount(a);
|
|
42
48
|
const c = a.innerHTML;
|
|
43
|
-
return
|
|
49
|
+
return o.unmount(), c;
|
|
44
50
|
} catch {
|
|
45
51
|
return "";
|
|
46
52
|
}
|
|
@@ -51,7 +57,7 @@ const p = 24, V = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
|
|
|
51
57
|
function F(e) {
|
|
52
58
|
var t;
|
|
53
59
|
return {
|
|
54
|
-
y: (
|
|
60
|
+
y: (o) => Number(o[e]),
|
|
55
61
|
color: ((t = r.categories[e]) == null ? void 0 : t.color) ?? A
|
|
56
62
|
};
|
|
57
63
|
}
|
|
@@ -81,34 +87,35 @@ const p = 24, V = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
|
|
|
81
87
|
return (e, t) => (l(), u("div", {
|
|
82
88
|
class: L(["flex flex-col space-y-4", { "flex-col-reverse": v.value }])
|
|
83
89
|
}, [
|
|
84
|
-
s(
|
|
90
|
+
s(n(I), {
|
|
85
91
|
data: e.data,
|
|
86
92
|
height: e.height,
|
|
93
|
+
padding: e.padding,
|
|
87
94
|
"svg-defs": E.value
|
|
88
95
|
}, {
|
|
89
96
|
default: M(() => [
|
|
90
|
-
e.hideTooltip ? g("", !0) : (l(), h(
|
|
97
|
+
e.hideTooltip ? g("", !0) : (l(), h(n(S), {
|
|
91
98
|
key: 0,
|
|
92
|
-
"horizontal-placement":
|
|
93
|
-
"vertical-placement":
|
|
99
|
+
"horizontal-placement": n(C).Right,
|
|
100
|
+
"vertical-placement": n(C).Top
|
|
94
101
|
}, null, 8, ["horizontal-placement", "vertical-placement"])),
|
|
95
|
-
(l(!0), u(b, null, U(Object.keys(r.categories), (
|
|
96
|
-
s(
|
|
102
|
+
(l(!0), u(b, null, U(Object.keys(r.categories), (o, a) => (l(), u(b, { key: a }, [
|
|
103
|
+
s(n(w), j({
|
|
97
104
|
x: (c, y) => y,
|
|
98
105
|
ref_for: !0
|
|
99
|
-
}, F(
|
|
100
|
-
color: `url(#gradient${a}-${
|
|
106
|
+
}, F(o), {
|
|
107
|
+
color: `url(#gradient${a}-${n(m)[a]})`,
|
|
101
108
|
opacity: q,
|
|
102
|
-
"curve-type": e.curveType ??
|
|
109
|
+
"curve-type": e.curveType ?? n(B).MonotoneX
|
|
103
110
|
}), null, 16, ["x", "color", "curve-type"]),
|
|
104
|
-
s(
|
|
111
|
+
s(n(z), {
|
|
105
112
|
x: (c, y) => y,
|
|
106
|
-
y: (c) => c[
|
|
107
|
-
color:
|
|
108
|
-
"curve-type": e.curveType ??
|
|
113
|
+
y: (c) => c[o],
|
|
114
|
+
color: n(m)[a],
|
|
115
|
+
"curve-type": e.curveType ?? n(B).MonotoneX
|
|
109
116
|
}, null, 8, ["x", "y", "color", "curve-type"])
|
|
110
117
|
], 64))), 128)),
|
|
111
|
-
s(
|
|
118
|
+
s(n(V), {
|
|
112
119
|
type: "x",
|
|
113
120
|
"tick-format": e.xFormatter,
|
|
114
121
|
label: e.xLabel,
|
|
@@ -120,7 +127,7 @@ const p = 24, V = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
|
|
|
120
127
|
"tick-values": e.xExplicitTicks,
|
|
121
128
|
"min-max-ticks-only": e.minMaxTicksOnly
|
|
122
129
|
}, null, 8, ["tick-format", "label", "domain-line", "grid-line", "num-ticks", "tick-line", "tick-values", "min-max-ticks-only"]),
|
|
123
|
-
s(
|
|
130
|
+
s(n(V), {
|
|
124
131
|
type: "y",
|
|
125
132
|
"num-ticks": e.yNumTicks,
|
|
126
133
|
"tick-format": e.yFormatter,
|
|
@@ -129,19 +136,19 @@ const p = 24, V = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
|
|
|
129
136
|
"domain-line": e.yDomainLine,
|
|
130
137
|
"tick-line": e.yTickLine
|
|
131
138
|
}, null, 8, ["num-ticks", "tick-format", "label", "grid-line", "domain-line", "tick-line"]),
|
|
132
|
-
e.hideTooltip ? g("", !0) : (l(), h(
|
|
139
|
+
e.hideTooltip ? g("", !0) : (l(), h(n(R), {
|
|
133
140
|
key: 1,
|
|
134
141
|
color: "#666",
|
|
135
142
|
template: D.value
|
|
136
143
|
}, null, 8, ["template"]))
|
|
137
144
|
]),
|
|
138
145
|
_: 1
|
|
139
|
-
}, 8, ["data", "height", "svg-defs"]),
|
|
146
|
+
}, 8, ["data", "height", "padding", "svg-defs"]),
|
|
140
147
|
e.hideLegend ? g("", !0) : (l(), u("div", {
|
|
141
148
|
key: 0,
|
|
142
149
|
class: L(["flex items-center justify-end", { "pb-4": v.value }])
|
|
143
150
|
}, [
|
|
144
|
-
s(
|
|
151
|
+
s(n(X), {
|
|
145
152
|
items: Object.values(e.categories)
|
|
146
153
|
}, null, 8, ["items"])
|
|
147
154
|
], 2))
|
|
@@ -19,6 +19,16 @@ export interface AreaChartProps<T> {
|
|
|
19
19
|
* Optional label for the y-axis.
|
|
20
20
|
*/
|
|
21
21
|
yLabel?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Optional padding applied to the chart.
|
|
24
|
+
* Allows specifying individual padding values for the top, right, bottom, and left sides.
|
|
25
|
+
*/
|
|
26
|
+
padding?: {
|
|
27
|
+
top: number;
|
|
28
|
+
right: number;
|
|
29
|
+
bottom: number;
|
|
30
|
+
left: number;
|
|
31
|
+
};
|
|
22
32
|
/**
|
|
23
33
|
* A record mapping category keys to `BulletLegendItemInterface` objects.
|
|
24
34
|
* This defines the visual representation and labels for each category in the chart's legend.
|
|
@@ -1,63 +1,74 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { VisXYContainer as
|
|
3
|
-
import { CurveType as
|
|
4
|
-
import
|
|
5
|
-
const
|
|
1
|
+
import { defineComponent as y, computed as f, createApp as h, createElementBlock as g, openBlock as r, createVNode as n, createElementVNode as B, unref as t, withCtx as L, createBlock as v, createCommentVNode as k } from "vue";
|
|
2
|
+
import { VisXYContainer as x, VisArea as T, VisAxis as c, VisCrosshair as b, VisBulletLegend as V } from "@unovis/vue";
|
|
3
|
+
import { CurveType as _ } from "@unovis/ts";
|
|
4
|
+
import C from "../Tooltip.js";
|
|
5
|
+
const N = { class: "flex flex-col space-y-4" }, A = { class: "flex items center justify-end" }, G = /* @__PURE__ */ y({
|
|
6
6
|
__name: "AreaStackedChart",
|
|
7
7
|
props: {
|
|
8
8
|
data: {},
|
|
9
9
|
height: {},
|
|
10
10
|
categories: {},
|
|
11
|
-
hideTooltip: { type: Boolean }
|
|
11
|
+
hideTooltip: { type: Boolean },
|
|
12
|
+
xLabel: {},
|
|
13
|
+
yLabel: {},
|
|
14
|
+
padding: {},
|
|
15
|
+
hideLegend: { type: Boolean },
|
|
16
|
+
xGridLine: { type: Boolean },
|
|
17
|
+
xDomainLine: { type: Boolean },
|
|
18
|
+
yGridLine: { type: Boolean },
|
|
19
|
+
yDomainLine: { type: Boolean },
|
|
20
|
+
xTickLine: { type: Boolean },
|
|
21
|
+
yTickLine: { type: Boolean }
|
|
12
22
|
},
|
|
13
|
-
setup(
|
|
14
|
-
const
|
|
23
|
+
setup(l) {
|
|
24
|
+
const i = l, s = f(() => (e, m) => {
|
|
15
25
|
if (typeof window > "u" || typeof document > "u")
|
|
16
26
|
return "";
|
|
17
27
|
try {
|
|
18
|
-
const o =
|
|
28
|
+
const o = h(C, {
|
|
19
29
|
data: e,
|
|
20
|
-
categories:
|
|
21
|
-
}),
|
|
22
|
-
o.mount(
|
|
23
|
-
const
|
|
24
|
-
return o.unmount(),
|
|
30
|
+
categories: i.categories
|
|
31
|
+
}), a = document.createElement("div");
|
|
32
|
+
o.mount(a);
|
|
33
|
+
const u = a.innerHTML;
|
|
34
|
+
return o.unmount(), u;
|
|
25
35
|
} catch {
|
|
26
36
|
return "";
|
|
27
37
|
}
|
|
28
|
-
}),
|
|
29
|
-
return (e,
|
|
30
|
-
|
|
38
|
+
}), p = (e) => Number.parseInt(e.time), d = [(e) => e.firstTime, (e) => e.returning];
|
|
39
|
+
return (e, m) => (r(), g("div", N, [
|
|
40
|
+
n(t(x), {
|
|
31
41
|
data: e.data,
|
|
42
|
+
padding: e.padding,
|
|
32
43
|
height: e.height
|
|
33
44
|
}, {
|
|
34
|
-
default:
|
|
35
|
-
|
|
36
|
-
x:
|
|
37
|
-
y:
|
|
38
|
-
color: Object.values(
|
|
39
|
-
"curve-type": t(
|
|
45
|
+
default: L(() => [
|
|
46
|
+
n(t(T), {
|
|
47
|
+
x: p,
|
|
48
|
+
y: d,
|
|
49
|
+
color: Object.values(i.categories).map((o) => o.color),
|
|
50
|
+
"curve-type": t(_).Linear
|
|
40
51
|
}, null, 8, ["color", "curve-type"]),
|
|
41
|
-
|
|
52
|
+
n(t(c), {
|
|
42
53
|
type: "x",
|
|
43
54
|
label: "Time",
|
|
44
55
|
"num-ticks": 12
|
|
45
56
|
}),
|
|
46
|
-
|
|
57
|
+
n(t(c), {
|
|
47
58
|
type: "y",
|
|
48
59
|
label: "Number of visitors",
|
|
49
60
|
"num-ticks": 3
|
|
50
61
|
}),
|
|
51
|
-
e.hideTooltip ? k("", !0) : (
|
|
62
|
+
e.hideTooltip ? k("", !0) : (r(), v(t(b), {
|
|
52
63
|
key: 0,
|
|
53
64
|
color: "#666",
|
|
54
|
-
template:
|
|
65
|
+
template: s.value
|
|
55
66
|
}, null, 8, ["template"]))
|
|
56
67
|
]),
|
|
57
68
|
_: 1
|
|
58
|
-
}, 8, ["data", "height"]),
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
}, 8, ["data", "padding", "height"]),
|
|
70
|
+
B("div", A, [
|
|
71
|
+
n(t(V), {
|
|
61
72
|
items: Object.values(e.categories)
|
|
62
73
|
}, null, 8, ["items"])
|
|
63
74
|
])
|
|
@@ -65,5 +76,5 @@ const A = { class: "flex flex-col space-y-4" }, j = { class: "flex items center
|
|
|
65
76
|
}
|
|
66
77
|
});
|
|
67
78
|
export {
|
|
68
|
-
|
|
79
|
+
G as default
|
|
69
80
|
};
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type AreaStackedChartProps<T> = {
|
|
3
|
-
data: T[];
|
|
4
|
-
height: number;
|
|
5
|
-
categories: Record<string, BulletLegendItemInterface>;
|
|
6
|
-
hideTooltip?: boolean;
|
|
7
|
-
};
|
|
1
|
+
import { AreaStackedChartProps } from './types';
|
|
8
2
|
declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
9
3
|
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & AreaStackedChartProps<T> & Partial<{}>> & import('vue').PublicProps;
|
|
10
4
|
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
@@ -27,6 +27,16 @@ export interface AreaStackedChartProps<T> {
|
|
|
27
27
|
* Optional label for the y-axis.
|
|
28
28
|
*/
|
|
29
29
|
yLabel?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Optional padding applied to the chart.
|
|
32
|
+
* Allows specifying individual padding values for the top, right, bottom, and left sides.
|
|
33
|
+
*/
|
|
34
|
+
padding?: {
|
|
35
|
+
top: number;
|
|
36
|
+
right: number;
|
|
37
|
+
bottom: number;
|
|
38
|
+
left: number;
|
|
39
|
+
};
|
|
30
40
|
/**
|
|
31
41
|
* If `true`, hides the chart legend.
|
|
32
42
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as v, computed as c, createApp as V, createElementBlock as f, openBlock as
|
|
2
|
-
import { Orientation as
|
|
3
|
-
import { VisXYContainer as C, VisTooltip as G, VisGroupedBar as N, VisStackedBar as j, VisAxis as
|
|
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
|
+
import { Orientation as s, StackedBar as A, GroupedBar as O } from "@unovis/ts";
|
|
3
|
+
import { VisXYContainer as C, VisTooltip as G, VisGroupedBar as N, VisStackedBar as j, VisAxis as L, VisBulletLegend as w } from "@unovis/vue";
|
|
4
4
|
import E from "../Tooltip.js";
|
|
5
|
-
import { LegendPosition as
|
|
5
|
+
import { LegendPosition as D } from "../../types.js";
|
|
6
6
|
const S = /* @__PURE__ */ v({
|
|
7
7
|
__name: "BarChart",
|
|
8
8
|
props: {
|
|
@@ -11,6 +11,12 @@ const S = /* @__PURE__ */ v({
|
|
|
11
11
|
height: {},
|
|
12
12
|
xLabel: {},
|
|
13
13
|
yLabel: {},
|
|
14
|
+
padding: { default: () => ({
|
|
15
|
+
top: 5,
|
|
16
|
+
right: 5,
|
|
17
|
+
bottom: 5,
|
|
18
|
+
left: 5
|
|
19
|
+
}) },
|
|
14
20
|
categories: {},
|
|
15
21
|
xFormatter: {},
|
|
16
22
|
yFormatter: {},
|
|
@@ -23,7 +29,7 @@ const S = /* @__PURE__ */ v({
|
|
|
23
29
|
barPadding: {},
|
|
24
30
|
radius: {},
|
|
25
31
|
hideLegend: { type: Boolean },
|
|
26
|
-
orientation: { default:
|
|
32
|
+
orientation: { default: s.Vertical },
|
|
27
33
|
legendPosition: {},
|
|
28
34
|
xDomainLine: { type: Boolean },
|
|
29
35
|
yDomainLine: { type: Boolean },
|
|
@@ -37,57 +43,60 @@ const S = /* @__PURE__ */ v({
|
|
|
37
43
|
if (!a.yAxis || a.yAxis.length === 0)
|
|
38
44
|
throw new Error("yAxis is required");
|
|
39
45
|
const m = c(() => a.yAxis.map((e) => (t) => t[e])), p = (e, t) => Object.values(a.categories)[t].color, g = c(
|
|
40
|
-
() => a.legendPosition ===
|
|
46
|
+
() => a.legendPosition === D.Top
|
|
41
47
|
), y = c(() => (e, t) => {
|
|
42
48
|
if (typeof window > "u" || typeof document > "u")
|
|
43
49
|
return "";
|
|
44
|
-
const u = Object.keys(a.categories), B = Object.keys(e).find((
|
|
50
|
+
const u = Object.keys(a.categories), B = Object.keys(e).find((o) => !u.includes(o));
|
|
45
51
|
try {
|
|
46
|
-
const
|
|
52
|
+
const o = V(E, {
|
|
47
53
|
data: e,
|
|
48
54
|
categories: a.categories,
|
|
49
55
|
xValue: e[B]
|
|
50
56
|
}), k = document.createElement("div");
|
|
51
|
-
|
|
57
|
+
o.mount(k);
|
|
52
58
|
const T = k.innerHTML;
|
|
53
|
-
return
|
|
59
|
+
return o.unmount(), T;
|
|
54
60
|
} catch {
|
|
55
61
|
return "";
|
|
56
62
|
}
|
|
57
63
|
});
|
|
58
|
-
return (e, t) => (
|
|
64
|
+
return (e, t) => (l(), f("div", {
|
|
59
65
|
class: b(["flex flex-col space-y-4", { "flex-col-reverse": g.value }])
|
|
60
66
|
}, [
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
r(i(C), {
|
|
68
|
+
padding: e.padding,
|
|
69
|
+
height: e.height
|
|
70
|
+
}, {
|
|
71
|
+
default: P(() => [
|
|
72
|
+
r(i(G), {
|
|
64
73
|
triggers: {
|
|
65
74
|
[i(O).selectors.bar]: y.value,
|
|
66
75
|
[i(A).selectors.bar]: y.value
|
|
67
76
|
}
|
|
68
77
|
}, null, 8, ["triggers"]),
|
|
69
|
-
e.stacked ? (
|
|
78
|
+
e.stacked ? (l(), h(i(j), {
|
|
70
79
|
key: 1,
|
|
71
|
-
data: e.
|
|
80
|
+
data: e.data,
|
|
72
81
|
x: (u, d) => d,
|
|
73
82
|
y: m.value,
|
|
74
83
|
color: p,
|
|
75
84
|
"rounded-corners": e.radius ?? 0,
|
|
76
85
|
"group-padding": e.groupPadding ?? 0,
|
|
77
86
|
"bar-padding": e.barPadding ?? 0.2,
|
|
78
|
-
orientation: e.orientation ?? i(
|
|
79
|
-
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (
|
|
87
|
+
orientation: e.orientation ?? i(s).Vertical
|
|
88
|
+
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (l(), h(i(N), {
|
|
80
89
|
key: 0,
|
|
81
|
-
data: e.
|
|
90
|
+
data: e.data,
|
|
82
91
|
x: (u, d) => d,
|
|
83
92
|
y: m.value,
|
|
84
93
|
color: p,
|
|
85
94
|
"rounded-corners": e.radius ?? 0,
|
|
86
95
|
"group-padding": e.groupPadding ?? 0,
|
|
87
96
|
"bar-padding": e.barPadding ?? 0.2,
|
|
88
|
-
orientation: e.orientation ?? i(
|
|
97
|
+
orientation: e.orientation ?? i(s).Vertical
|
|
89
98
|
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])),
|
|
90
|
-
|
|
99
|
+
r(i(L), {
|
|
91
100
|
type: "x",
|
|
92
101
|
"tick-format": e.xFormatter,
|
|
93
102
|
label: e.xLabel,
|
|
@@ -98,10 +107,10 @@ const S = /* @__PURE__ */ v({
|
|
|
98
107
|
"tick-values": e.xExplicitTicks,
|
|
99
108
|
"min-max-ticks-only": e.minMaxTicksOnly
|
|
100
109
|
}, null, 8, ["tick-format", "label", "grid-line", "domain-line", "tick-line", "num-ticks", "tick-values", "min-max-ticks-only"]),
|
|
101
|
-
|
|
110
|
+
r(i(L), {
|
|
102
111
|
type: "y",
|
|
103
112
|
label: e.yLabel,
|
|
104
|
-
"grid-line": e.orientation !== i(
|
|
113
|
+
"grid-line": e.orientation !== i(s).Horizontal && e.yGridLine,
|
|
105
114
|
"domain-line": !!e.yDomainLine,
|
|
106
115
|
"tick-format": e.yFormatter,
|
|
107
116
|
"num-ticks": e.yNumTicks,
|
|
@@ -109,12 +118,12 @@ const S = /* @__PURE__ */ v({
|
|
|
109
118
|
}, null, 8, ["label", "grid-line", "domain-line", "tick-format", "num-ticks", "tick-line"])
|
|
110
119
|
]),
|
|
111
120
|
_: 1
|
|
112
|
-
}, 8, ["height"]),
|
|
113
|
-
e.hideLegend ?
|
|
121
|
+
}, 8, ["padding", "height"]),
|
|
122
|
+
e.hideLegend ? x("", !0) : (l(), f("div", {
|
|
114
123
|
key: 0,
|
|
115
124
|
class: b(["flex items center justify-end", { "pb-4": g.value }])
|
|
116
125
|
}, [
|
|
117
|
-
|
|
126
|
+
r(i(w), {
|
|
118
127
|
items: Object.values(e.categories)
|
|
119
128
|
}, null, 8, ["items"])
|
|
120
129
|
], 2))
|
|
@@ -22,6 +22,16 @@ export interface BarChartProps<T> {
|
|
|
22
22
|
* Optional label for the y-axis.
|
|
23
23
|
*/
|
|
24
24
|
yLabel?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Optional padding applied to the chart.
|
|
27
|
+
* Allows specifying individual padding values for the top, right, bottom, and left sides.
|
|
28
|
+
*/
|
|
29
|
+
padding?: {
|
|
30
|
+
top: number;
|
|
31
|
+
right: number;
|
|
32
|
+
bottom: number;
|
|
33
|
+
left: number;
|
|
34
|
+
};
|
|
25
35
|
/**
|
|
26
36
|
* A record mapping category keys to `BulletLegendItemInterface` objects.
|
|
27
37
|
* This defines the visual representation and labels for each category in the chart's legend.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as b, computed as
|
|
2
|
-
import { Position as
|
|
1
|
+
import { defineComponent as b, computed as u, createApp as B, createElementBlock as s, openBlock as l, normalizeClass as p, createVNode as r, createCommentVNode as y, unref as i, withCtx as x, createBlock as g, Fragment as C, renderList as V } from "vue";
|
|
2
|
+
import { Position as k, CurveType as F } from "@unovis/ts";
|
|
3
3
|
import { VisXYContainer as N, VisTooltip as O, VisLine as j, VisAxis as f, VisCrosshair as M, VisBulletLegend as P } from "@unovis/vue";
|
|
4
4
|
import D from "../Tooltip.js";
|
|
5
5
|
import { LegendPosition as E } from "../../types.js";
|
|
@@ -10,6 +10,12 @@ const $ = /* @__PURE__ */ b({
|
|
|
10
10
|
height: {},
|
|
11
11
|
xLabel: {},
|
|
12
12
|
yLabel: {},
|
|
13
|
+
padding: { default: () => ({
|
|
14
|
+
top: 5,
|
|
15
|
+
right: 5,
|
|
16
|
+
bottom: 5,
|
|
17
|
+
left: 5
|
|
18
|
+
}) },
|
|
13
19
|
categories: {},
|
|
14
20
|
xFormatter: {},
|
|
15
21
|
yFormatter: {},
|
|
@@ -29,40 +35,41 @@ const $ = /* @__PURE__ */ b({
|
|
|
29
35
|
yTickLine: { type: Boolean }
|
|
30
36
|
},
|
|
31
37
|
setup(t) {
|
|
32
|
-
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 =
|
|
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 = u(() => (e, c) => {
|
|
33
39
|
if (typeof window > "u" || typeof document > "u")
|
|
34
40
|
return "";
|
|
35
41
|
try {
|
|
36
|
-
const o =
|
|
42
|
+
const o = B(D, {
|
|
37
43
|
data: e,
|
|
38
44
|
categories: n.categories,
|
|
39
45
|
xValue: n.xFormatter(Math.floor(c))
|
|
40
46
|
}), a = document.createElement("div");
|
|
41
47
|
o.mount(a);
|
|
42
|
-
const
|
|
43
|
-
return o.unmount(),
|
|
48
|
+
const m = a.innerHTML;
|
|
49
|
+
return o.unmount(), m;
|
|
44
50
|
} catch {
|
|
45
51
|
return "";
|
|
46
52
|
}
|
|
47
|
-
}),
|
|
53
|
+
}), d = u(
|
|
48
54
|
() => n.legendPosition === E.Top
|
|
49
55
|
);
|
|
50
|
-
return (e, c) => (l(),
|
|
51
|
-
class: p(["flex flex-col space-y-4", { "flex-col-reverse":
|
|
56
|
+
return (e, c) => (l(), s("div", {
|
|
57
|
+
class: p(["flex flex-col space-y-4", { "flex-col-reverse": d.value }])
|
|
52
58
|
}, [
|
|
53
59
|
r(i(N), {
|
|
54
60
|
data: e.data,
|
|
61
|
+
padding: e.padding,
|
|
55
62
|
height: e.height
|
|
56
63
|
}, {
|
|
57
|
-
default:
|
|
64
|
+
default: x(() => [
|
|
58
65
|
r(i(O), {
|
|
59
|
-
"horizontal-placement": i(
|
|
60
|
-
"vertical-placement": i(
|
|
66
|
+
"horizontal-placement": i(k).Right,
|
|
67
|
+
"vertical-placement": i(k).Top
|
|
61
68
|
}, null, 8, ["horizontal-placement", "vertical-placement"]),
|
|
62
|
-
(l(!0),
|
|
69
|
+
(l(!0), s(C, null, V(Object.keys(n.categories), (o, a) => (l(), g(i(j), {
|
|
63
70
|
key: a,
|
|
64
|
-
x: (
|
|
65
|
-
y: (
|
|
71
|
+
x: (m, v) => v,
|
|
72
|
+
y: (m) => m[o],
|
|
66
73
|
color: L(a),
|
|
67
74
|
"curve-type": e.curveType ?? i(F).MonotoneX
|
|
68
75
|
}, null, 8, ["x", "y", "color", "curve-type"]))), 128)),
|
|
@@ -87,17 +94,17 @@ const $ = /* @__PURE__ */ b({
|
|
|
87
94
|
"grid-line": e.yGridLine,
|
|
88
95
|
"tick-line": e.yTickLine
|
|
89
96
|
}, null, 8, ["tick-format", "label", "num-ticks", "domain-line", "grid-line", "tick-line"]),
|
|
90
|
-
e.hideTooltip ? y("", !0) : (l(),
|
|
97
|
+
e.hideTooltip ? y("", !0) : (l(), g(i(M), {
|
|
91
98
|
key: 0,
|
|
92
99
|
color: "#666",
|
|
93
100
|
template: T.value
|
|
94
101
|
}, null, 8, ["template"]))
|
|
95
102
|
]),
|
|
96
103
|
_: 1
|
|
97
|
-
}, 8, ["data", "height"]),
|
|
98
|
-
e.hideLegend ? y("", !0) : (l(),
|
|
104
|
+
}, 8, ["data", "padding", "height"]),
|
|
105
|
+
e.hideLegend ? y("", !0) : (l(), s("div", {
|
|
99
106
|
key: 0,
|
|
100
|
-
class: p(["flex items center justify-end", { "pb-4":
|
|
107
|
+
class: p(["flex items center justify-end", { "pb-4": d.value }])
|
|
101
108
|
}, [
|
|
102
109
|
r(i(P), {
|
|
103
110
|
items: Object.values(e.categories)
|
|
@@ -18,6 +18,16 @@ export interface LineChartProps<T> {
|
|
|
18
18
|
* Optional label for the y-axis.
|
|
19
19
|
*/
|
|
20
20
|
yLabel?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Optional padding applied to the chart.
|
|
23
|
+
* Allows specifying individual padding values for the top, right, bottom, and left sides.
|
|
24
|
+
*/
|
|
25
|
+
padding?: {
|
|
26
|
+
top: number;
|
|
27
|
+
right: number;
|
|
28
|
+
bottom: number;
|
|
29
|
+
left: number;
|
|
30
|
+
};
|
|
21
31
|
/**
|
|
22
32
|
* A record mapping category keys to `BulletLegendItemInterface` objects.
|
|
23
33
|
* This defines the visual representation and labels for each category in the chart's legend.
|