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