vue-chrts 0.2.0-test.4 → 0.2.0-test.6
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 +161 -4
- package/dist/components/AreaChart/AreaChart.vue.d.ts +4 -2
- package/dist/components/AreaChart/AreaChart2.js +2 -157
- package/dist/components/AreaChart/types.d.ts +28 -2
- package/dist/components/AreaStackedChart/AreaStackedChart.js +20 -23
- package/dist/components/AreaStackedChart/types.d.ts +18 -0
- package/dist/components/BarChart/BarChart.js +77 -99
- package/dist/components/BarChart/BarChart.vue.d.ts +5 -3
- package/dist/components/BarChart/stackedGroupedUtils.d.ts +19 -0
- package/dist/components/BarChart/stackedGroupedUtils.js +67 -0
- package/dist/components/BarChart/types.d.ts +41 -22
- package/dist/components/DonutChart/DonutChart.js +43 -37
- package/dist/components/DonutChart/DonutChart.vue.d.ts +4 -2
- package/dist/components/DonutChart/types.d.ts +7 -3
- package/dist/components/LineChart/LineChart.js +59 -54
- package/dist/components/LineChart/LineChart.vue.d.ts +4 -2
- package/dist/components/LineChart/types.d.ts +30 -3
- package/dist/components/Tooltip.js +10 -10
- package/dist/components/Tooltip.vue.d.ts +3 -2
- package/dist/index.d.ts +2 -3
- package/dist/index.js +9 -11
- package/dist/types.d.ts +6 -43
- package/dist/types.js +2 -4
- package/dist/utils.d.ts +4 -1
- package/dist/utils.js +33 -18
- package/package.json +14 -15
- package/dist/_virtual/_plugin-vue_export-helper.js +0 -9
- package/dist/index.js.css +0 -1
|
@@ -1,6 +1,163 @@
|
|
|
1
|
-
import a from "
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { defineComponent as U, useSlots as j, useTemplateRef as w, ref as R, computed as d, createElementBlock as c, openBlock as a, normalizeClass as T, createVNode as u, createCommentVNode as p, createElementVNode as X, unref as i, withCtx as x, createBlock as m, Fragment as L, renderList as S, mergeProps as C, renderSlot as b } from "vue";
|
|
2
|
+
import { Position as A, CurveType as B } from "@unovis/ts";
|
|
3
|
+
import { createMarkers as Y, getFirstPropertyValue as z } from "../../utils.js";
|
|
4
|
+
import I from "../Tooltip.js";
|
|
5
|
+
import { VisXYContainer as H, VisTooltip as K, VisArea as q, VisLine as J, VisAxis as D, VisCrosshair as Q, VisBulletLegend as Z } from "@unovis/vue";
|
|
6
|
+
import { LegendPosition as _ } from "../../types.js";
|
|
7
|
+
const ee = {
|
|
8
|
+
ref: "slotWrapper",
|
|
9
|
+
class: "hidden"
|
|
10
|
+
}, y = 24, V = 4, te = 0.5, F = "#3b82f6", se = /* @__PURE__ */ U({
|
|
11
|
+
__name: "AreaChart",
|
|
12
|
+
props: {
|
|
13
|
+
data: {},
|
|
14
|
+
height: {},
|
|
15
|
+
xLabel: {},
|
|
16
|
+
yLabel: {},
|
|
17
|
+
padding: { default: () => ({ top: 5, right: 5, bottom: 5, left: 5 }) },
|
|
18
|
+
categories: {},
|
|
19
|
+
markerConfig: {},
|
|
20
|
+
xFormatter: {},
|
|
21
|
+
yFormatter: {},
|
|
22
|
+
curveType: {},
|
|
23
|
+
lineWidth: { default: 2 },
|
|
24
|
+
lineDashArray: {},
|
|
25
|
+
xNumTicks: { default: (n) => n.data.length > y ? y / V : n.data.length - 1 },
|
|
26
|
+
xExplicitTicks: {},
|
|
27
|
+
minMaxTicksOnly: { type: Boolean },
|
|
28
|
+
yNumTicks: { default: (n) => n.data.length > y ? y / V : n.data.length - 1 },
|
|
29
|
+
hideLegend: { type: Boolean },
|
|
30
|
+
hideTooltip: { type: Boolean },
|
|
31
|
+
legendPosition: {},
|
|
32
|
+
xDomainLine: { type: Boolean },
|
|
33
|
+
yDomainLine: { type: Boolean },
|
|
34
|
+
xTickLine: { type: Boolean },
|
|
35
|
+
yTickLine: { type: Boolean },
|
|
36
|
+
xGridLine: { type: Boolean },
|
|
37
|
+
yGridLine: { type: Boolean },
|
|
38
|
+
hideXAxis: { type: Boolean },
|
|
39
|
+
hideYAxis: { type: Boolean },
|
|
40
|
+
crosshairConfig: { default: () => ({
|
|
41
|
+
color: "#666"
|
|
42
|
+
}) }
|
|
43
|
+
},
|
|
44
|
+
emits: ["click"],
|
|
45
|
+
setup(n, { emit: $ }) {
|
|
46
|
+
const G = $, r = n, O = j(), h = w("slotWrapper"), s = R(), f = d(
|
|
47
|
+
() => Object.values(r.categories).map((e) => e.color)
|
|
48
|
+
), N = d(() => r.markerConfig ? Y(r.markerConfig) : ""), g = d(() => r.legendPosition === _.Top), E = d(() => {
|
|
49
|
+
const e = (t, o) => `
|
|
50
|
+
<linearGradient id="gradient${t}-${o}" gradientTransform="rotate(90)">
|
|
51
|
+
<stop offset="0%" stop-color="${o}" stop-opacity="1" />
|
|
52
|
+
<stop offset="100%" stop-color="${o}" stop-opacity="0" />
|
|
53
|
+
</linearGradient>
|
|
54
|
+
`, l = (t, o) => `
|
|
55
|
+
<linearGradient id="gradient${t}-${o}" gradientTransform="rotate(90)">
|
|
56
|
+
<stop offset="0%" style="stop-color:var(--vis-color0);stop-opacity:1" />
|
|
57
|
+
<stop offset="100%" style="stop-color:var(--vis-color0);stop-opacity:0" />
|
|
58
|
+
</linearGradient>
|
|
59
|
+
`;
|
|
60
|
+
return f.value.map(
|
|
61
|
+
(t, o) => t != null && t.includes("#") ? e(o, t) : l(o, t ?? F)
|
|
62
|
+
).join("");
|
|
63
|
+
});
|
|
64
|
+
function P(e) {
|
|
65
|
+
var l;
|
|
66
|
+
return {
|
|
67
|
+
y: (t) => Number(t[e]),
|
|
68
|
+
color: ((l = r.categories[e]) == null ? void 0 : l.color) ?? F
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function W(e) {
|
|
72
|
+
return typeof window > "u" ? "" : h.value ? h.value.innerHTML : "";
|
|
73
|
+
}
|
|
74
|
+
function M(e) {
|
|
75
|
+
return s.value = e, W();
|
|
76
|
+
}
|
|
77
|
+
return (e, l) => (a(), c("div", {
|
|
78
|
+
class: T(["flex flex-col", { "flex-col-reverse": g.value, markers: !!r.markerConfig }]),
|
|
79
|
+
onClick: l[0] || (l[0] = (t) => G("click", t, s.value))
|
|
80
|
+
}, [
|
|
81
|
+
u(i(H), {
|
|
82
|
+
data: e.data,
|
|
83
|
+
height: e.height,
|
|
84
|
+
padding: e.padding,
|
|
85
|
+
"svg-defs": E.value + N.value
|
|
86
|
+
}, {
|
|
87
|
+
default: x(() => [
|
|
88
|
+
e.hideTooltip ? p("", !0) : (a(), m(i(K), {
|
|
89
|
+
key: 0,
|
|
90
|
+
"horizontal-placement": i(A).Right,
|
|
91
|
+
"vertical-placement": i(A).Top
|
|
92
|
+
}, null, 8, ["horizontal-placement", "vertical-placement"])),
|
|
93
|
+
(a(!0), c(L, null, S(Object.keys(r.categories), (t, o) => (a(), c(L, { key: t }, [
|
|
94
|
+
u(i(q), C({
|
|
95
|
+
x: (k, v) => v
|
|
96
|
+
}, { ref_for: !0 }, P(t), {
|
|
97
|
+
color: `url(#gradient${o}-${f.value[o]})`,
|
|
98
|
+
opacity: te,
|
|
99
|
+
"curve-type": e.curveType ?? i(B).MonotoneX
|
|
100
|
+
}), null, 16, ["x", "color", "curve-type"]),
|
|
101
|
+
u(i(J), {
|
|
102
|
+
x: (k, v) => v,
|
|
103
|
+
y: (k) => k[t],
|
|
104
|
+
color: f.value[o],
|
|
105
|
+
"curve-type": e.curveType ?? i(B).MonotoneX,
|
|
106
|
+
"line-width": e.lineWidth,
|
|
107
|
+
lineDashArray: e.lineDashArray
|
|
108
|
+
}, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"])
|
|
109
|
+
], 64))), 128)),
|
|
110
|
+
e.hideXAxis ? p("", !0) : (a(), m(i(D), {
|
|
111
|
+
key: 1,
|
|
112
|
+
type: "x",
|
|
113
|
+
label: e.xLabel,
|
|
114
|
+
"label-margin": 8,
|
|
115
|
+
"num-ticks": e.xNumTicks,
|
|
116
|
+
"tick-format": e.xFormatter,
|
|
117
|
+
"tick-values": e.xExplicitTicks,
|
|
118
|
+
"grid-line": e.xGridLine,
|
|
119
|
+
"domain-line": e.xDomainLine,
|
|
120
|
+
"tick-line": e.xTickLine,
|
|
121
|
+
"min-max-ticks-only": e.minMaxTicksOnly
|
|
122
|
+
}, null, 8, ["label", "num-ticks", "tick-format", "tick-values", "grid-line", "domain-line", "tick-line", "min-max-ticks-only"])),
|
|
123
|
+
e.hideYAxis ? p("", !0) : (a(), m(i(D), {
|
|
124
|
+
key: 2,
|
|
125
|
+
type: "y",
|
|
126
|
+
label: e.yLabel,
|
|
127
|
+
"num-ticks": e.yNumTicks,
|
|
128
|
+
"tick-format": e.yFormatter,
|
|
129
|
+
"grid-line": e.yGridLine,
|
|
130
|
+
"domain-line": e.yDomainLine,
|
|
131
|
+
"tick-line": e.yTickLine
|
|
132
|
+
}, null, 8, ["label", "num-ticks", "tick-format", "grid-line", "domain-line", "tick-line"])),
|
|
133
|
+
e.hideTooltip ? p("", !0) : (a(), m(i(Q), C({ key: 3 }, e.crosshairConfig, { template: M }), null, 16))
|
|
134
|
+
]),
|
|
135
|
+
_: 1
|
|
136
|
+
}, 8, ["data", "height", "padding", "svg-defs"]),
|
|
137
|
+
e.hideLegend ? p("", !0) : (a(), c("div", {
|
|
138
|
+
key: 0,
|
|
139
|
+
class: T(["flex items-center justify-end", { "pb-4": g.value, "pt-4": !g.value }])
|
|
140
|
+
}, [
|
|
141
|
+
u(i(Z), {
|
|
142
|
+
items: Object.values(e.categories)
|
|
143
|
+
}, null, 8, ["items"])
|
|
144
|
+
], 2)),
|
|
145
|
+
X("div", ee, [
|
|
146
|
+
i(O).tooltip ? b(e.$slots, "tooltip", {
|
|
147
|
+
key: 0,
|
|
148
|
+
values: s.value
|
|
149
|
+
}) : s.value ? b(e.$slots, "fallback", { key: 1 }, () => [
|
|
150
|
+
u(I, {
|
|
151
|
+
data: s.value,
|
|
152
|
+
categories: e.categories,
|
|
153
|
+
toolTipTitle: i(z)(s.value) ?? "",
|
|
154
|
+
yFormatter: r.yFormatter
|
|
155
|
+
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
156
|
+
]) : p("", !0)
|
|
157
|
+
], 512)
|
|
158
|
+
], 2));
|
|
159
|
+
}
|
|
160
|
+
});
|
|
4
161
|
export {
|
|
5
|
-
|
|
162
|
+
se as default
|
|
6
163
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { AreaChartProps } from './types';
|
|
2
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<{
|
|
3
|
-
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
3
|
+
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
4
|
+
readonly onClick?: ((event: MouseEvent, values?: T | undefined) => any) | undefined;
|
|
5
|
+
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onClick"> & AreaChartProps<T> & Partial<{}>> & import('vue').PublicProps;
|
|
4
6
|
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
5
7
|
attrs: any;
|
|
6
8
|
slots: {
|
|
@@ -9,7 +11,7 @@ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>
|
|
|
9
11
|
}): any;
|
|
10
12
|
fallback?(_: {}): any;
|
|
11
13
|
};
|
|
12
|
-
emit:
|
|
14
|
+
emit: (e: "click", event: MouseEvent, values?: T) => void;
|
|
13
15
|
}>) => import('vue').VNode & {
|
|
14
16
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
15
17
|
};
|
|
@@ -1,159 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Position as b, CurveType as B } from "@unovis/ts";
|
|
3
|
-
import { createMarkers as S, getFirstPropertyValue as Y } from "../../utils.js";
|
|
4
|
-
import w from "../Tooltip.js";
|
|
5
|
-
import { VisXYContainer as z, VisTooltip as I, VisArea as H, VisLine as K, VisAxis as V, VisCrosshair as q, VisBulletLegend as J } from "@unovis/vue";
|
|
6
|
-
import { LegendPosition as Q } from "../../types.js";
|
|
7
|
-
const Z = {
|
|
8
|
-
ref: "slotWrapper",
|
|
9
|
-
class: "hidden"
|
|
10
|
-
}, y = 24, A = 4, _ = 0.5, F = "#3b82f6", ne = /* @__PURE__ */ x({
|
|
11
|
-
__name: "AreaChart",
|
|
12
|
-
props: {
|
|
13
|
-
data: {},
|
|
14
|
-
height: {},
|
|
15
|
-
xLabel: {},
|
|
16
|
-
yLabel: {},
|
|
17
|
-
padding: { default: () => ({ top: 5, right: 5, bottom: 5, left: 5 }) },
|
|
18
|
-
categories: {},
|
|
19
|
-
markerConfig: {},
|
|
20
|
-
xFormatter: {},
|
|
21
|
-
yFormatter: {},
|
|
22
|
-
curveType: {},
|
|
23
|
-
xNumTicks: { default: (n) => n.data.length > y ? y / A : n.data.length - 1 },
|
|
24
|
-
xExplicitTicks: {},
|
|
25
|
-
minMaxTicksOnly: { type: Boolean },
|
|
26
|
-
yNumTicks: { default: (n) => n.data.length > y ? y / A : n.data.length - 1 },
|
|
27
|
-
hideLegend: { type: Boolean },
|
|
28
|
-
hideTooltip: { type: Boolean },
|
|
29
|
-
legendPosition: {},
|
|
30
|
-
xDomainLine: { type: Boolean },
|
|
31
|
-
yDomainLine: { type: Boolean },
|
|
32
|
-
xTickLine: { type: Boolean },
|
|
33
|
-
yTickLine: { type: Boolean },
|
|
34
|
-
xGridLine: { type: Boolean },
|
|
35
|
-
yGridLine: { type: Boolean },
|
|
36
|
-
hideXAxis: { type: Boolean },
|
|
37
|
-
hideYAxis: { type: Boolean }
|
|
38
|
-
},
|
|
39
|
-
setup(n) {
|
|
40
|
-
const r = n, D = P(), v = M("slotWrapper"), s = U(), f = c(
|
|
41
|
-
() => Object.values(r.categories).map((e) => e.color)
|
|
42
|
-
), T = c(() => r.legendPosition === Q.Top), $ = c(() => {
|
|
43
|
-
const e = (t, o) => `
|
|
44
|
-
<linearGradient id="gradient${t}-${o}" gradientTransform="rotate(90)">
|
|
45
|
-
<stop offset="0%" stop-color="${o}" stop-opacity="1" />
|
|
46
|
-
<stop offset="100%" stop-color="${o}" stop-opacity="0" />
|
|
47
|
-
</linearGradient>
|
|
48
|
-
`, p = (t, o) => `
|
|
49
|
-
<linearGradient id="gradient${t}-${o}" gradientTransform="rotate(90)">
|
|
50
|
-
<stop offset="0%" style="stop-color:var(--vis-color0);stop-opacity:1" />
|
|
51
|
-
<stop offset="100%" style="stop-color:var(--vis-color0);stop-opacity:0" />
|
|
52
|
-
</linearGradient>
|
|
53
|
-
`;
|
|
54
|
-
return f.value.map(
|
|
55
|
-
(t, o) => t != null && t.includes("#") ? e(o, t) : p(o, t ?? F)
|
|
56
|
-
).join("");
|
|
57
|
-
}), G = c(() => r.markerConfig ? S(r.markerConfig) : "");
|
|
58
|
-
function O(e) {
|
|
59
|
-
var p;
|
|
60
|
-
return {
|
|
61
|
-
y: (t) => Number(t[e]),
|
|
62
|
-
color: ((p = r.categories[e]) == null ? void 0 : p.color) ?? F
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function N(e) {
|
|
66
|
-
return typeof window > "u" ? "" : v.value ? v.value.innerHTML : "";
|
|
67
|
-
}
|
|
68
|
-
function E(e) {
|
|
69
|
-
return s.value = e, N();
|
|
70
|
-
}
|
|
71
|
-
return (e, p) => (a(), d("div", {
|
|
72
|
-
class: h(["flex flex-col space-y-4", { "flex-col-reverse": T.value, markers: !!r.markerConfig }])
|
|
73
|
-
}, [
|
|
74
|
-
u(i(z), {
|
|
75
|
-
data: e.data,
|
|
76
|
-
height: e.height,
|
|
77
|
-
padding: e.padding,
|
|
78
|
-
"svg-defs": $.value + G.value
|
|
79
|
-
}, {
|
|
80
|
-
default: R(() => [
|
|
81
|
-
e.hideTooltip ? l("", !0) : (a(), m(i(I), {
|
|
82
|
-
key: 0,
|
|
83
|
-
"horizontal-placement": i(b).Right,
|
|
84
|
-
"vertical-placement": i(b).Top
|
|
85
|
-
}, null, 8, ["horizontal-placement", "vertical-placement"])),
|
|
86
|
-
(a(!0), d(L, null, W(Object.keys(r.categories), (t, o) => (a(), d(L, { key: t }, [
|
|
87
|
-
u(i(H), X({
|
|
88
|
-
x: (g, k) => k,
|
|
89
|
-
ref_for: !0
|
|
90
|
-
}, O(t), {
|
|
91
|
-
color: `url(#gradient${o}-${f.value[o]})`,
|
|
92
|
-
opacity: _,
|
|
93
|
-
"curve-type": e.curveType ?? i(B).MonotoneX
|
|
94
|
-
}), null, 16, ["x", "color", "curve-type"]),
|
|
95
|
-
u(i(K), {
|
|
96
|
-
x: (g, k) => k,
|
|
97
|
-
y: (g) => g[t],
|
|
98
|
-
color: f.value[o],
|
|
99
|
-
"curve-type": e.curveType ?? i(B).MonotoneX
|
|
100
|
-
}, null, 8, ["x", "y", "color", "curve-type"])
|
|
101
|
-
], 64))), 128)),
|
|
102
|
-
e.hideXAxis ? l("", !0) : (a(), m(i(V), {
|
|
103
|
-
key: 1,
|
|
104
|
-
type: "x",
|
|
105
|
-
label: e.xLabel,
|
|
106
|
-
"label-margin": 8,
|
|
107
|
-
"num-ticks": e.xNumTicks,
|
|
108
|
-
"tick-format": e.xFormatter,
|
|
109
|
-
"tick-values": e.xExplicitTicks,
|
|
110
|
-
"grid-line": e.xGridLine,
|
|
111
|
-
"domain-line": e.xDomainLine,
|
|
112
|
-
"tick-line": e.xTickLine,
|
|
113
|
-
"min-max-ticks-only": e.minMaxTicksOnly
|
|
114
|
-
}, null, 8, ["label", "num-ticks", "tick-format", "tick-values", "grid-line", "domain-line", "tick-line", "min-max-ticks-only"])),
|
|
115
|
-
e.hideYAxis ? l("", !0) : (a(), m(i(V), {
|
|
116
|
-
key: 2,
|
|
117
|
-
type: "y",
|
|
118
|
-
label: e.yLabel,
|
|
119
|
-
"num-ticks": e.yNumTicks,
|
|
120
|
-
"tick-format": e.yFormatter,
|
|
121
|
-
"grid-line": e.yGridLine,
|
|
122
|
-
"domain-line": e.yDomainLine,
|
|
123
|
-
"tick-line": e.yTickLine
|
|
124
|
-
}, null, 8, ["label", "num-ticks", "tick-format", "grid-line", "domain-line", "tick-line"])),
|
|
125
|
-
e.hideTooltip ? l("", !0) : (a(), m(i(q), {
|
|
126
|
-
key: 3,
|
|
127
|
-
color: "#666",
|
|
128
|
-
template: E
|
|
129
|
-
}))
|
|
130
|
-
]),
|
|
131
|
-
_: 1
|
|
132
|
-
}, 8, ["data", "height", "padding", "svg-defs"]),
|
|
133
|
-
e.hideLegend ? l("", !0) : (a(), d("div", {
|
|
134
|
-
key: 0,
|
|
135
|
-
class: h(["flex items-center justify-end", { "pb-4": T.value }])
|
|
136
|
-
}, [
|
|
137
|
-
u(i(J), {
|
|
138
|
-
items: Object.values(e.categories)
|
|
139
|
-
}, null, 8, ["items"])
|
|
140
|
-
], 2)),
|
|
141
|
-
j("div", Z, [
|
|
142
|
-
i(D).tooltip ? C(e.$slots, "tooltip", {
|
|
143
|
-
key: 0,
|
|
144
|
-
values: s.value
|
|
145
|
-
}, void 0, !0) : s.value ? C(e.$slots, "fallback", { key: 1 }, () => [
|
|
146
|
-
u(w, {
|
|
147
|
-
data: s.value,
|
|
148
|
-
categories: e.categories,
|
|
149
|
-
toolTipTitle: i(Y)(s.value) ?? "",
|
|
150
|
-
yFormatter: r.yFormatter
|
|
151
|
-
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
152
|
-
], !0) : l("", !0)
|
|
153
|
-
], 512)
|
|
154
|
-
], 2));
|
|
155
|
-
}
|
|
156
|
-
});
|
|
1
|
+
import f from "./AreaChart.js";
|
|
157
2
|
export {
|
|
158
|
-
|
|
3
|
+
f as default
|
|
159
4
|
};
|
|
@@ -44,19 +44,27 @@ export interface AreaChartProps<T> {
|
|
|
44
44
|
* @param {(number[]|Date[])} ticks - An array of all tick values for the x-axis.
|
|
45
45
|
* @returns {string} The formatted string representation of the tick.
|
|
46
46
|
*/
|
|
47
|
-
xFormatter?: axisFormatter
|
|
47
|
+
xFormatter?: axisFormatter;
|
|
48
48
|
/**
|
|
49
49
|
* @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.
|
|
50
50
|
* @param {number} i - The index of the tick in the `ticks` array.
|
|
51
51
|
* @param {(number[]|Date[])} ticks - An array of all tick values for the y-axis.
|
|
52
52
|
* @returns {string} The formatted string representation of the tick.
|
|
53
53
|
*/
|
|
54
|
-
yFormatter?: axisFormatter
|
|
54
|
+
yFormatter?: axisFormatter;
|
|
55
55
|
/**
|
|
56
56
|
* The type of curve to use for the area chart lines.
|
|
57
57
|
* See `CurveType` for available options.
|
|
58
58
|
*/
|
|
59
59
|
curveType?: CurveType;
|
|
60
|
+
/**
|
|
61
|
+
* The width of the line in pixels. Default is 2px.
|
|
62
|
+
*/
|
|
63
|
+
lineWidth?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Line dash array, see SVG's stroke-dasharray. Default: `undefined`
|
|
66
|
+
*/
|
|
67
|
+
lineDashArray?: number[];
|
|
60
68
|
/**
|
|
61
69
|
* The desired number of ticks on the x-axis.
|
|
62
70
|
*/
|
|
@@ -118,4 +126,22 @@ export interface AreaChartProps<T> {
|
|
|
118
126
|
* If `true`, hide the y-axis.
|
|
119
127
|
*/
|
|
120
128
|
hideYAxis?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Crosshair configuration object for customizing the appearance of the crosshair line.
|
|
131
|
+
*/
|
|
132
|
+
crosshairConfig?: {
|
|
133
|
+
/**
|
|
134
|
+
* The color of the crosshair line. Accepts any valid CSS color string.
|
|
135
|
+
* Example: '#f00', 'rgba(0,0,0,0.5)', 'blue'
|
|
136
|
+
*/
|
|
137
|
+
color?: string;
|
|
138
|
+
/**
|
|
139
|
+
* The stroke color of the crosshair line. Accepts any valid CSS color string.
|
|
140
|
+
*/
|
|
141
|
+
strokeColor?: string;
|
|
142
|
+
/**
|
|
143
|
+
* The stroke width of the crosshair line in pixels.
|
|
144
|
+
*/
|
|
145
|
+
strokeWidth?: number;
|
|
146
|
+
};
|
|
121
147
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as y, computed as f, createApp as h, createElementBlock as g, openBlock as
|
|
2
|
-
import { VisXYContainer as
|
|
1
|
+
import { defineComponent as y, computed as f, createApp as h, createElementBlock as g, openBlock as a, createVNode as n, createElementVNode as B, unref as t, withCtx as L, createBlock as v, createCommentVNode as C, mergeProps as k } from "vue";
|
|
2
|
+
import { VisXYContainer as b, VisArea as x, VisAxis as s, VisCrosshair as T, VisBulletLegend as V } from "@unovis/vue";
|
|
3
3
|
import { CurveType as _ } from "@unovis/ts";
|
|
4
|
-
import
|
|
5
|
-
const
|
|
4
|
+
import N from "../Tooltip.js";
|
|
5
|
+
const A = { class: "flex flex-col space-y-4" }, j = { class: "flex items center justify-end" }, O = /* @__PURE__ */ y({
|
|
6
6
|
__name: "AreaStackedChart",
|
|
7
7
|
props: {
|
|
8
8
|
data: {},
|
|
@@ -18,56 +18,53 @@ const N = { class: "flex flex-col space-y-4" }, A = { class: "flex items center
|
|
|
18
18
|
yGridLine: { type: Boolean },
|
|
19
19
|
yDomainLine: { type: Boolean },
|
|
20
20
|
xTickLine: { type: Boolean },
|
|
21
|
-
yTickLine: { type: Boolean }
|
|
21
|
+
yTickLine: { type: Boolean },
|
|
22
|
+
crosshairConfig: {}
|
|
22
23
|
},
|
|
23
|
-
setup(
|
|
24
|
-
const i =
|
|
24
|
+
setup(c) {
|
|
25
|
+
const i = c, l = f(() => (e, m) => {
|
|
25
26
|
if (typeof window > "u" || typeof document > "u")
|
|
26
27
|
return "";
|
|
27
28
|
try {
|
|
28
|
-
const o = h(
|
|
29
|
+
const o = h(N, {
|
|
29
30
|
data: e,
|
|
30
31
|
categories: i.categories
|
|
31
|
-
}),
|
|
32
|
-
o.mount(
|
|
33
|
-
const u =
|
|
32
|
+
}), r = document.createElement("div");
|
|
33
|
+
o.mount(r);
|
|
34
|
+
const u = r.innerHTML;
|
|
34
35
|
return o.unmount(), u;
|
|
35
36
|
} catch {
|
|
36
37
|
return "";
|
|
37
38
|
}
|
|
38
39
|
}), p = (e) => Number.parseInt(e.time), d = [(e) => e.firstTime, (e) => e.returning];
|
|
39
|
-
return (e, m) => (
|
|
40
|
-
n(t(
|
|
40
|
+
return (e, m) => (a(), g("div", A, [
|
|
41
|
+
n(t(b), {
|
|
41
42
|
data: e.data,
|
|
42
43
|
padding: e.padding,
|
|
43
44
|
height: e.height
|
|
44
45
|
}, {
|
|
45
46
|
default: L(() => [
|
|
46
|
-
n(t(
|
|
47
|
+
n(t(x), {
|
|
47
48
|
x: p,
|
|
48
49
|
y: d,
|
|
49
50
|
color: Object.values(i.categories).map((o) => o.color),
|
|
50
51
|
"curve-type": t(_).Linear
|
|
51
52
|
}, null, 8, ["color", "curve-type"]),
|
|
52
|
-
n(t(
|
|
53
|
+
n(t(s), {
|
|
53
54
|
type: "x",
|
|
54
55
|
label: "Time",
|
|
55
56
|
"num-ticks": 12
|
|
56
57
|
}),
|
|
57
|
-
n(t(
|
|
58
|
+
n(t(s), {
|
|
58
59
|
type: "y",
|
|
59
60
|
label: "Number of visitors",
|
|
60
61
|
"num-ticks": 3
|
|
61
62
|
}),
|
|
62
|
-
e.hideTooltip ?
|
|
63
|
-
key: 0,
|
|
64
|
-
color: "#666",
|
|
65
|
-
template: s.value
|
|
66
|
-
}, null, 8, ["template"]))
|
|
63
|
+
e.hideTooltip ? C("", !0) : (a(), v(t(T), k({ key: 0 }, e.crosshairConfig, { template: l.value }), null, 16, ["template"]))
|
|
67
64
|
]),
|
|
68
65
|
_: 1
|
|
69
66
|
}, 8, ["data", "padding", "height"]),
|
|
70
|
-
B("div",
|
|
67
|
+
B("div", j, [
|
|
71
68
|
n(t(V), {
|
|
72
69
|
items: Object.values(e.categories)
|
|
73
70
|
}, null, 8, ["items"])
|
|
@@ -76,5 +73,5 @@ const N = { class: "flex flex-col space-y-4" }, A = { class: "flex items center
|
|
|
76
73
|
}
|
|
77
74
|
});
|
|
78
75
|
export {
|
|
79
|
-
|
|
76
|
+
O as default
|
|
80
77
|
};
|
|
@@ -65,4 +65,22 @@ export interface AreaStackedChartProps<T> {
|
|
|
65
65
|
* If `true`, displays tick lines on the y-axis.
|
|
66
66
|
*/
|
|
67
67
|
yTickLine?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Crosshair configuration object for customizing the appearance of the crosshair line.
|
|
70
|
+
*/
|
|
71
|
+
crosshairConfig?: {
|
|
72
|
+
/**
|
|
73
|
+
* The color of the crosshair line. Accepts any valid CSS color string.
|
|
74
|
+
* Example: '#f00', 'rgba(0,0,0,0.5)', 'blue'
|
|
75
|
+
*/
|
|
76
|
+
color?: string;
|
|
77
|
+
/**
|
|
78
|
+
* The stroke color of the crosshair line. Accepts any valid CSS color string.
|
|
79
|
+
*/
|
|
80
|
+
strokeColor?: string;
|
|
81
|
+
/**
|
|
82
|
+
* The stroke width of the crosshair line in pixels.
|
|
83
|
+
*/
|
|
84
|
+
strokeWidth?: number;
|
|
85
|
+
};
|
|
68
86
|
}
|