vue-chrts 0.2.4 → 0.2.5-test.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 +73 -70
- package/dist/components/AreaChart/types.d.ts +4 -0
- package/dist/components/AreaStackedChart/AreaStackedChart.js +31 -31
- package/dist/components/BarChart/BarChart.js +160 -122
- package/dist/components/BarChart/BarChart.vue.d.ts +1 -1
- package/dist/components/BarChart/types.d.ts +27 -11
- package/dist/components/BubbleChart/BubbleChart.js +74 -56
- package/dist/components/BubbleChart/types.d.ts +4 -0
- package/dist/components/DonutChart/DonutChart.js +39 -39
- package/dist/components/LineChart/LineChart.js +62 -58
- package/dist/components/LineChart/types.d.ts +4 -0
- package/dist/components/Tooltip.js +24 -24
- package/dist/types.d.ts +6 -2
- package/dist/types.js +4 -4
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Position as
|
|
3
|
-
import { createMarkers as I, getFirstPropertyValue as
|
|
4
|
-
import
|
|
5
|
-
import { VisXYContainer as
|
|
6
|
-
import { LegendPosition as
|
|
1
|
+
import { defineComponent as M, useSlots as U, useTemplateRef as j, ref as w, computed as d, createElementBlock as m, openBlock as o, normalizeClass as R, normalizeStyle as h, createVNode as u, createCommentVNode as c, createElementVNode as X, unref as i, withCtx as z, createBlock as y, Fragment as x, renderList as Y, mergeProps as p, renderSlot as L } from "vue";
|
|
2
|
+
import { Position as C, CurveType as D } from "@unovis/ts";
|
|
3
|
+
import { createMarkers as I, getFirstPropertyValue as H } from "../../utils.js";
|
|
4
|
+
import K from "../Tooltip.js";
|
|
5
|
+
import { VisXYContainer as q, VisTooltip as J, VisArea as Q, VisLine as Z, VisAxis as A, VisCrosshair as _, VisBulletLegend as ee } from "@unovis/vue";
|
|
6
|
+
import { LegendPosition as te } from "../../types.js";
|
|
7
7
|
const ie = {
|
|
8
8
|
ref: "slotWrapper",
|
|
9
9
|
style: { display: "none" }
|
|
10
|
-
},
|
|
10
|
+
}, f = 24, b = 4, ne = 0.5, B = "#3b82f6", de = /* @__PURE__ */ M({
|
|
11
11
|
__name: "AreaChart",
|
|
12
12
|
props: {
|
|
13
13
|
data: {},
|
|
@@ -22,13 +22,14 @@ const ie = {
|
|
|
22
22
|
curveType: {},
|
|
23
23
|
lineWidth: { default: 2 },
|
|
24
24
|
lineDashArray: {},
|
|
25
|
-
xNumTicks: { default: (
|
|
25
|
+
xNumTicks: { default: (e) => e.data.length > f ? f / b : e.data.length - 1 },
|
|
26
26
|
xExplicitTicks: {},
|
|
27
27
|
minMaxTicksOnly: { type: Boolean },
|
|
28
|
-
yNumTicks: { default: (
|
|
29
|
-
hideLegend: { type: Boolean },
|
|
28
|
+
yNumTicks: { default: (e) => e.data.length > f ? f / b : e.data.length - 1 },
|
|
29
|
+
hideLegend: { type: Boolean, default: !1 },
|
|
30
30
|
hideTooltip: { type: Boolean },
|
|
31
|
-
legendPosition: {},
|
|
31
|
+
legendPosition: { default: te.BottomCenter },
|
|
32
|
+
legendStyle: { default: void 0 },
|
|
32
33
|
xDomainLine: { type: Boolean },
|
|
33
34
|
yDomainLine: { type: Boolean },
|
|
34
35
|
xTickLine: { type: Boolean },
|
|
@@ -44,78 +45,79 @@ const ie = {
|
|
|
44
45
|
xDomain: {}
|
|
45
46
|
},
|
|
46
47
|
emits: ["click"],
|
|
47
|
-
setup(
|
|
48
|
-
const
|
|
49
|
-
() => Object.values(n.categories).map((
|
|
50
|
-
),
|
|
51
|
-
const
|
|
52
|
-
<linearGradient id="gradient${
|
|
53
|
-
<stop offset="0%" stop-color="${
|
|
54
|
-
<stop offset="100%" stop-color="${
|
|
48
|
+
setup(e, { emit: V }) {
|
|
49
|
+
const F = V, n = e, $ = U(), T = j("slotWrapper"), s = w(), g = d(
|
|
50
|
+
() => Object.values(n.categories).map((l) => l.color)
|
|
51
|
+
), G = d(() => n.markerConfig ? I(n.markerConfig) : ""), O = d(() => n.legendPosition.startsWith("top")), N = d(() => n.legendPosition.includes("left") ? "flex-start" : n.legendPosition.includes("right") ? "flex-end" : "center"), P = d(() => {
|
|
52
|
+
const l = (t, a) => `
|
|
53
|
+
<linearGradient id="gradient${t}-${a}" gradientTransform="rotate(90)">
|
|
54
|
+
<stop offset="0%" stop-color="${a}" stop-opacity="1" />
|
|
55
|
+
<stop offset="100%" stop-color="${a}" stop-opacity="0" />
|
|
55
56
|
</linearGradient>
|
|
56
|
-
`,
|
|
57
|
-
<linearGradient id="gradient${
|
|
57
|
+
`, r = (t, a) => `
|
|
58
|
+
<linearGradient id="gradient${t}-${a}" gradientTransform="rotate(90)">
|
|
58
59
|
<stop offset="0%" style="stop-color:var(--vis-color0);stop-opacity:1" />
|
|
59
60
|
<stop offset="100%" style="stop-color:var(--vis-color0);stop-opacity:0" />
|
|
60
61
|
</linearGradient>
|
|
61
62
|
`;
|
|
62
|
-
return
|
|
63
|
-
(
|
|
63
|
+
return g.value.map(
|
|
64
|
+
(t, a) => t != null && t.includes("#") ? l(a, t) : r(a, t ?? B)
|
|
64
65
|
).join("");
|
|
65
66
|
});
|
|
66
|
-
function
|
|
67
|
-
var
|
|
67
|
+
function E(l) {
|
|
68
|
+
var r;
|
|
68
69
|
return {
|
|
69
|
-
y: (
|
|
70
|
-
color: ((
|
|
70
|
+
y: (t) => Number(t[l]),
|
|
71
|
+
color: ((r = n.categories[l]) == null ? void 0 : r.color) ?? B
|
|
71
72
|
};
|
|
72
73
|
}
|
|
73
|
-
function W(
|
|
74
|
-
return typeof window > "u" ? "" :
|
|
74
|
+
function W(l) {
|
|
75
|
+
return typeof window > "u" ? "" : T.value ? T.value.innerHTML : "";
|
|
75
76
|
}
|
|
76
|
-
function
|
|
77
|
-
return s.value =
|
|
77
|
+
function S(l) {
|
|
78
|
+
return s.value = l, W();
|
|
78
79
|
}
|
|
79
|
-
return (
|
|
80
|
-
style:
|
|
80
|
+
return (l, r) => (o(), m("div", {
|
|
81
|
+
style: h({
|
|
81
82
|
display: "flex",
|
|
82
|
-
flexDirection:
|
|
83
|
+
flexDirection: O.value ? "column-reverse" : "column",
|
|
84
|
+
gap: "var(--vis-legend-spacing)"
|
|
83
85
|
}),
|
|
84
|
-
class:
|
|
85
|
-
onClick:
|
|
86
|
+
class: R({ markers: !!n.markerConfig }),
|
|
87
|
+
onClick: r[0] || (r[0] = (t) => F("click", t, s.value))
|
|
86
88
|
}, [
|
|
87
|
-
|
|
89
|
+
u(i(q), {
|
|
88
90
|
data: e.data,
|
|
89
91
|
height: e.height,
|
|
90
92
|
padding: e.padding,
|
|
91
|
-
"svg-defs":
|
|
93
|
+
"svg-defs": P.value + G.value,
|
|
92
94
|
"y-domain": e.yDomain,
|
|
93
95
|
"x-domain": e.xDomain
|
|
94
96
|
}, {
|
|
95
|
-
default:
|
|
96
|
-
e.hideTooltip ?
|
|
97
|
+
default: z(() => [
|
|
98
|
+
e.hideTooltip ? c("", !0) : (o(), y(i(J), {
|
|
97
99
|
key: 0,
|
|
98
|
-
"horizontal-placement":
|
|
99
|
-
"vertical-placement":
|
|
100
|
+
"horizontal-placement": i(C).Right,
|
|
101
|
+
"vertical-placement": i(C).Top
|
|
100
102
|
}, null, 8, ["horizontal-placement", "vertical-placement"])),
|
|
101
|
-
(
|
|
102
|
-
|
|
103
|
+
(o(!0), m(x, null, Y(Object.keys(n.categories), (t, a) => (o(), m(x, { key: t }, [
|
|
104
|
+
u(i(Q), p({
|
|
103
105
|
x: (k, v) => v
|
|
104
|
-
}, { ref_for: !0 },
|
|
105
|
-
color: `url(#gradient${
|
|
106
|
-
opacity:
|
|
107
|
-
"curve-type": e.curveType ??
|
|
106
|
+
}, { ref_for: !0 }, E(t), {
|
|
107
|
+
color: `url(#gradient${a}-${g.value[a]})`,
|
|
108
|
+
opacity: ne,
|
|
109
|
+
"curve-type": e.curveType ?? i(D).MonotoneX
|
|
108
110
|
}), null, 16, ["x", "color", "curve-type"]),
|
|
109
|
-
|
|
111
|
+
u(i(Z), {
|
|
110
112
|
x: (k, v) => v,
|
|
111
|
-
y: (k) => k[
|
|
112
|
-
color:
|
|
113
|
-
"curve-type": e.curveType ??
|
|
113
|
+
y: (k) => k[t],
|
|
114
|
+
color: g.value[a],
|
|
115
|
+
"curve-type": e.curveType ?? i(D).MonotoneX,
|
|
114
116
|
"line-width": e.lineWidth,
|
|
115
|
-
lineDashArray: e.lineDashArray ? e.lineDashArray[
|
|
117
|
+
lineDashArray: e.lineDashArray ? e.lineDashArray[a] : void 0
|
|
116
118
|
}, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"])
|
|
117
119
|
], 64))), 128)),
|
|
118
|
-
e.hideXAxis ?
|
|
120
|
+
e.hideXAxis ? c("", !0) : (o(), y(i(A), {
|
|
119
121
|
key: 1,
|
|
120
122
|
type: "x",
|
|
121
123
|
label: e.xLabel,
|
|
@@ -128,7 +130,7 @@ const ie = {
|
|
|
128
130
|
"tick-line": e.xTickLine,
|
|
129
131
|
"min-max-ticks-only": e.minMaxTicksOnly
|
|
130
132
|
}, null, 8, ["label", "num-ticks", "tick-format", "tick-values", "grid-line", "domain-line", "tick-line", "min-max-ticks-only"])),
|
|
131
|
-
e.hideYAxis ?
|
|
133
|
+
e.hideYAxis ? c("", !0) : (o(), y(i(A), {
|
|
132
134
|
key: 2,
|
|
133
135
|
type: "y",
|
|
134
136
|
label: e.yLabel,
|
|
@@ -138,36 +140,37 @@ const ie = {
|
|
|
138
140
|
"domain-line": e.yDomainLine,
|
|
139
141
|
"tick-line": e.yTickLine
|
|
140
142
|
}, null, 8, ["label", "num-ticks", "tick-format", "grid-line", "domain-line", "tick-line"])),
|
|
141
|
-
e.hideTooltip ?
|
|
143
|
+
e.hideTooltip ? c("", !0) : (o(), y(i(_), p({ key: 3 }, e.crosshairConfig, { template: S }), null, 16))
|
|
142
144
|
]),
|
|
143
145
|
_: 1
|
|
144
146
|
}, 8, ["data", "height", "padding", "svg-defs", "y-domain", "x-domain"]),
|
|
145
|
-
|
|
147
|
+
n.hideLegend ? c("", !0) : (o(), m("div", {
|
|
146
148
|
key: 0,
|
|
147
|
-
style:
|
|
149
|
+
style: h({
|
|
148
150
|
display: "flex",
|
|
149
|
-
|
|
150
|
-
justifyContent: "flex-end",
|
|
151
|
-
paddingBottom: g.value ? "1rem" : void 0,
|
|
152
|
-
paddingTop: g.value ? void 0 : "1rem"
|
|
151
|
+
justifyContent: N.value
|
|
153
152
|
})
|
|
154
153
|
}, [
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
u(i(ee), {
|
|
155
|
+
style: h([
|
|
156
|
+
n.legendStyle,
|
|
157
|
+
"display: flex; gap: var(--vis-legend-spacing);"
|
|
158
|
+
]),
|
|
159
|
+
items: Object.values(n.categories)
|
|
160
|
+
}, null, 8, ["style", "items"])
|
|
158
161
|
], 4)),
|
|
159
162
|
X("div", ie, [
|
|
160
|
-
|
|
163
|
+
i($).tooltip ? L(l.$slots, "tooltip", {
|
|
161
164
|
key: 0,
|
|
162
165
|
values: s.value
|
|
163
|
-
}) : s.value ?
|
|
164
|
-
|
|
166
|
+
}) : s.value ? L(l.$slots, "fallback", { key: 1 }, () => [
|
|
167
|
+
u(K, {
|
|
165
168
|
data: s.value,
|
|
166
169
|
categories: e.categories,
|
|
167
|
-
toolTipTitle:
|
|
170
|
+
toolTipTitle: i(H)(s.value) ?? "",
|
|
168
171
|
yFormatter: n.yFormatter
|
|
169
172
|
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
170
|
-
]) :
|
|
173
|
+
]) : c("", !0)
|
|
171
174
|
], 512)
|
|
172
175
|
], 6));
|
|
173
176
|
}
|
|
@@ -94,6 +94,10 @@ export interface AreaChartProps<T> {
|
|
|
94
94
|
* See `LegendPosition` for available options.
|
|
95
95
|
*/
|
|
96
96
|
legendPosition?: LegendPosition;
|
|
97
|
+
/**
|
|
98
|
+
* Optional style object for the legend container. Allows custom CSS styling.
|
|
99
|
+
*/
|
|
100
|
+
legendStyle?: string | Record<string, string>;
|
|
97
101
|
/**
|
|
98
102
|
* If `true`, displays a domain line (axis line) along the x-axis.
|
|
99
103
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as y, computed as f, createApp as h, createElementBlock as g, openBlock 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 c, createVNode as i, createElementVNode as x, unref as o, withCtx as B, createBlock as L, createCommentVNode as v, mergeProps as C } from "vue";
|
|
2
|
+
import { VisXYContainer as k, VisArea as b, VisAxis as s, VisCrosshair as T, VisBulletLegend as V } from "@unovis/vue";
|
|
3
|
+
import { CurveType as N } from "@unovis/ts";
|
|
4
|
+
import A from "../Tooltip.js";
|
|
5
|
+
const j = { class: "flex flex-col space-y-4" }, w = { class: "flex items center justify-end" }, H = /* @__PURE__ */ y({
|
|
6
6
|
__name: "AreaStackedChart",
|
|
7
7
|
props: {
|
|
8
8
|
data: {},
|
|
@@ -21,57 +21,57 @@ const A = { class: "flex flex-col space-y-4" }, j = { class: "flex items center
|
|
|
21
21
|
yTickLine: { type: Boolean },
|
|
22
22
|
crosshairConfig: {}
|
|
23
23
|
},
|
|
24
|
-
setup(
|
|
25
|
-
const
|
|
24
|
+
setup(t) {
|
|
25
|
+
const a = t, l = f(() => (e, u) => {
|
|
26
26
|
if (typeof window > "u" || typeof document > "u")
|
|
27
27
|
return "";
|
|
28
28
|
try {
|
|
29
|
-
const
|
|
29
|
+
const n = h(A, {
|
|
30
30
|
data: e,
|
|
31
|
-
categories:
|
|
31
|
+
categories: a.categories
|
|
32
32
|
}), r = document.createElement("div");
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
return
|
|
33
|
+
n.mount(r);
|
|
34
|
+
const p = r.innerHTML;
|
|
35
|
+
return n.unmount(), p;
|
|
36
36
|
} catch {
|
|
37
37
|
return "";
|
|
38
38
|
}
|
|
39
|
-
}),
|
|
40
|
-
return (e,
|
|
41
|
-
|
|
42
|
-
data:
|
|
43
|
-
padding:
|
|
44
|
-
height:
|
|
39
|
+
}), d = (e) => Number.parseInt(e.time), m = [(e) => e.firstTime, (e) => e.returning];
|
|
40
|
+
return (e, u) => (c(), g("div", j, [
|
|
41
|
+
i(o(k), {
|
|
42
|
+
data: t.data,
|
|
43
|
+
padding: t.padding,
|
|
44
|
+
height: t.height
|
|
45
45
|
}, {
|
|
46
|
-
default:
|
|
47
|
-
|
|
48
|
-
x:
|
|
49
|
-
y:
|
|
50
|
-
color: Object.values(
|
|
51
|
-
"curve-type":
|
|
46
|
+
default: B(() => [
|
|
47
|
+
i(o(b), {
|
|
48
|
+
x: d,
|
|
49
|
+
y: m,
|
|
50
|
+
color: Object.values(a.categories).map((n) => n.color),
|
|
51
|
+
"curve-type": o(N).Linear
|
|
52
52
|
}, null, 8, ["color", "curve-type"]),
|
|
53
|
-
|
|
53
|
+
i(o(s), {
|
|
54
54
|
type: "x",
|
|
55
55
|
label: "Time",
|
|
56
56
|
"num-ticks": 12
|
|
57
57
|
}),
|
|
58
|
-
|
|
58
|
+
i(o(s), {
|
|
59
59
|
type: "y",
|
|
60
60
|
label: "Number of visitors",
|
|
61
61
|
"num-ticks": 3
|
|
62
62
|
}),
|
|
63
|
-
|
|
63
|
+
t.hideTooltip ? v("", !0) : (c(), L(o(T), C({ key: 0 }, t.crosshairConfig, { template: l.value }), null, 16, ["template"]))
|
|
64
64
|
]),
|
|
65
65
|
_: 1
|
|
66
66
|
}, 8, ["data", "padding", "height"]),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
items: Object.values(
|
|
67
|
+
x("div", w, [
|
|
68
|
+
i(o(V), {
|
|
69
|
+
items: Object.values(t.categories)
|
|
70
70
|
}, null, 8, ["items"])
|
|
71
71
|
])
|
|
72
72
|
]));
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
75
|
export {
|
|
76
|
-
|
|
76
|
+
H as default
|
|
77
77
|
};
|