vue-chrts 0.1.11 → 0.1.12-test.0
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.
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Orientation as s, StackedBar as
|
|
3
|
-
import { VisXYContainer as C, VisTooltip as F, VisGroupedBar as G, VisStackedBar as N, VisAxis as
|
|
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
4
|
import w from "../Tooltip.js";
|
|
5
5
|
import { LegendPosition as E } from "../../types.js";
|
|
6
|
-
const
|
|
6
|
+
const H = /* @__PURE__ */ x({
|
|
7
7
|
__name: "BarChart",
|
|
8
8
|
props: {
|
|
9
9
|
data: {},
|
|
@@ -36,68 +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
43
|
setup(a) {
|
|
42
44
|
const n = a;
|
|
43
45
|
if (!n.yAxis || n.yAxis.length === 0)
|
|
44
46
|
throw new Error("yAxis is required");
|
|
45
|
-
const
|
|
47
|
+
const y = c(() => n.yAxis.map((e) => (o) => o[e])), g = (e, o) => Object.values(n.categories)[o].color, k = c(
|
|
46
48
|
() => n.legendPosition === E.Top
|
|
47
|
-
),
|
|
49
|
+
), f = c(() => (e, o) => {
|
|
48
50
|
if (typeof window > "u" || typeof document > "u")
|
|
49
51
|
return "";
|
|
50
|
-
const u = Object.keys(n.categories),
|
|
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
56
|
categories: n.categories,
|
|
55
|
-
toolTipTitle: e[
|
|
57
|
+
toolTipTitle: e[B],
|
|
56
58
|
yFormatter: n.yFormatter
|
|
57
|
-
}),
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
return
|
|
59
|
+
}), h = document.createElement("div");
|
|
60
|
+
r.mount(h);
|
|
61
|
+
const v = h.innerHTML;
|
|
62
|
+
return r.unmount(), v;
|
|
61
63
|
} catch {
|
|
62
64
|
return "";
|
|
63
65
|
}
|
|
64
66
|
});
|
|
65
|
-
return (e,
|
|
66
|
-
class:
|
|
67
|
+
return (e, o) => (t(), b("div", {
|
|
68
|
+
class: L(["flex flex-col space-y-4", { "flex-col-reverse": k.value }])
|
|
67
69
|
}, [
|
|
68
|
-
|
|
70
|
+
p(i(C), {
|
|
69
71
|
padding: e.padding,
|
|
70
72
|
height: e.height
|
|
71
73
|
}, {
|
|
72
|
-
default:
|
|
73
|
-
|
|
74
|
+
default: V(() => [
|
|
75
|
+
p(i(F), {
|
|
74
76
|
triggers: {
|
|
75
|
-
[i(O).selectors.bar]:
|
|
76
|
-
[i(
|
|
77
|
+
[i(O).selectors.bar]: f.value,
|
|
78
|
+
[i(P).selectors.bar]: f.value
|
|
77
79
|
}
|
|
78
80
|
}, null, 8, ["triggers"]),
|
|
79
|
-
e.stacked ? (
|
|
81
|
+
e.stacked ? (t(), l(i(N), {
|
|
80
82
|
key: 1,
|
|
81
83
|
data: e.data,
|
|
82
84
|
x: (u, d) => d,
|
|
83
|
-
y:
|
|
84
|
-
color:
|
|
85
|
+
y: y.value,
|
|
86
|
+
color: g,
|
|
85
87
|
"rounded-corners": e.radius ?? 0,
|
|
86
88
|
"group-padding": e.groupPadding ?? 0,
|
|
87
89
|
"bar-padding": e.barPadding ?? 0.2,
|
|
88
90
|
orientation: e.orientation ?? i(s).Vertical
|
|
89
|
-
}, 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), {
|
|
90
92
|
key: 0,
|
|
91
93
|
data: e.data,
|
|
92
94
|
x: (u, d) => d,
|
|
93
|
-
y:
|
|
94
|
-
color:
|
|
95
|
+
y: y.value,
|
|
96
|
+
color: g,
|
|
95
97
|
"rounded-corners": e.radius ?? 0,
|
|
96
98
|
"group-padding": e.groupPadding ?? 0,
|
|
97
99
|
"bar-padding": e.barPadding ?? 0.2,
|
|
98
100
|
orientation: e.orientation ?? i(s).Vertical
|
|
99
101
|
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])),
|
|
100
|
-
|
|
102
|
+
e.hideXAxis ? m("", !0) : (t(), l(i(T), {
|
|
103
|
+
key: 2,
|
|
101
104
|
type: "x",
|
|
102
105
|
"tick-format": e.xFormatter,
|
|
103
106
|
label: e.xLabel,
|
|
@@ -106,9 +109,10 @@ const S = /* @__PURE__ */ v({
|
|
|
106
109
|
"tick-line": e.xTickLine,
|
|
107
110
|
"num-ticks": e.xNumTicks,
|
|
108
111
|
"tick-values": e.xExplicitTicks,
|
|
109
|
-
|
|
110
|
-
}, null, 8, ["tick-format", "label", "grid-line", "domain-line", "tick-line", "num-ticks", "tick-values", "
|
|
111
|
-
|
|
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,
|
|
112
116
|
type: "y",
|
|
113
117
|
label: e.yLabel,
|
|
114
118
|
"grid-line": e.orientation !== i(s).Horizontal && e.yGridLine,
|
|
@@ -116,15 +120,15 @@ const S = /* @__PURE__ */ v({
|
|
|
116
120
|
"tick-format": e.yFormatter,
|
|
117
121
|
"num-ticks": e.yNumTicks,
|
|
118
122
|
"tick-line": e.yTickLine
|
|
119
|
-
}, 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"]))
|
|
120
124
|
]),
|
|
121
125
|
_: 1
|
|
122
126
|
}, 8, ["padding", "height"]),
|
|
123
|
-
e.hideLegend ?
|
|
127
|
+
e.hideLegend ? m("", !0) : (t(), b("div", {
|
|
124
128
|
key: 0,
|
|
125
|
-
class:
|
|
129
|
+
class: L(["flex items center justify-end", { "pb-4": k.value }])
|
|
126
130
|
}, [
|
|
127
|
-
|
|
131
|
+
p(i(j), {
|
|
128
132
|
items: Object.values(e.categories)
|
|
129
133
|
}, null, 8, ["items"])
|
|
130
134
|
], 2))
|
|
@@ -132,5 +136,5 @@ const S = /* @__PURE__ */ v({
|
|
|
132
136
|
}
|
|
133
137
|
});
|
|
134
138
|
export {
|
|
135
|
-
|
|
139
|
+
H as default
|
|
136
140
|
};
|
|
@@ -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
|
};
|
|
@@ -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
|
}
|