vue-chrts 0.1.11-beta.1 → 0.1.12-custom-tooltips.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 +88 -92
- package/dist/components/AreaChart/AreaChart.vue.d.ts +6 -1
- package/dist/components/AreaChart/types.d.ts +14 -14
- package/dist/components/BarChart/BarChart.js +63 -57
- package/dist/components/BarChart/BarChart.vue.d.ts +6 -1
- package/dist/components/BarChart/types.d.ts +3 -3
- package/dist/components/DonutChart/DonutChart.js +48 -29
- package/dist/components/DonutChart/DonutChart.vue.d.ts +14 -12
- package/dist/components/LineChart/LineChart.js +57 -48
- package/dist/components/LineChart/LineChart.vue.d.ts +6 -1
- package/dist/components/LineChart/types.d.ts +17 -17
- package/dist/components/Tooltip.js +10 -10
- package/dist/components/Tooltip.vue.d.ts +2 -2
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,30 +1,28 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Position as
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
const
|
|
1
|
+
import { defineComponent as E, useSlots as x, useTemplateRef as P, ref as U, computed as k, createElementBlock as d, openBlock as a, normalizeClass as h, createVNode as c, createCommentVNode as r, createElementVNode as j, unref as i, withCtx as M, createBlock as u, Fragment as L, renderList as R, mergeProps as W, renderSlot as b } from "vue";
|
|
2
|
+
import { Position as C, CurveType as B } from "@unovis/ts";
|
|
3
|
+
import { getFirstPropertyValue as X } from "../../utils.js";
|
|
4
|
+
import Y from "../Tooltip.js";
|
|
5
|
+
import { VisXYContainer as w, VisTooltip as z, VisArea as I, VisLine as S, VisAxis as V, VisCrosshair as H, VisBulletLegend as K } from "@unovis/vue";
|
|
6
|
+
import { LegendPosition as q } from "../../types.js";
|
|
7
|
+
const J = {
|
|
8
|
+
ref: "slotWrapper",
|
|
9
|
+
class: "hidden"
|
|
10
|
+
}, m = 24, A = 4, Q = 0.5, F = "#3b82f6", ae = /* @__PURE__ */ E({
|
|
8
11
|
__name: "AreaChart",
|
|
9
12
|
props: {
|
|
10
13
|
data: {},
|
|
11
14
|
height: {},
|
|
12
15
|
xLabel: {},
|
|
13
16
|
yLabel: {},
|
|
14
|
-
padding: { default: () => ({
|
|
15
|
-
top: 5,
|
|
16
|
-
right: 5,
|
|
17
|
-
bottom: 5,
|
|
18
|
-
left: 5
|
|
19
|
-
}) },
|
|
17
|
+
padding: { default: () => ({ top: 5, right: 5, bottom: 5, left: 5 }) },
|
|
20
18
|
categories: {},
|
|
21
19
|
xFormatter: {},
|
|
22
20
|
yFormatter: {},
|
|
23
21
|
curveType: {},
|
|
24
|
-
xNumTicks: { default: (n) => n.data.length > m ? m /
|
|
22
|
+
xNumTicks: { default: (n) => n.data.length > m ? m / A : n.data.length - 1 },
|
|
25
23
|
xExplicitTicks: {},
|
|
26
24
|
minMaxTicksOnly: { type: Boolean },
|
|
27
|
-
yNumTicks: { default: (n) => n.data.length > m ? m /
|
|
25
|
+
yNumTicks: { default: (n) => n.data.length > m ? m / A : n.data.length - 1 },
|
|
28
26
|
hideLegend: { type: Boolean },
|
|
29
27
|
hideTooltip: { type: Boolean },
|
|
30
28
|
legendPosition: {},
|
|
@@ -38,125 +36,123 @@ const m = 24, B = 4, z = 0.5, C = "#3b82f6", Z = /* @__PURE__ */ O({
|
|
|
38
36
|
hideYAxis: { type: Boolean }
|
|
39
37
|
},
|
|
40
38
|
setup(n) {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
39
|
+
const l = n, $ = x(), v = P("slotWrapper"), s = U(), y = k(
|
|
40
|
+
() => Object.values(l.categories).map((e) => e.color)
|
|
41
|
+
), T = k(() => l.legendPosition === q.Top), D = k(() => {
|
|
42
|
+
const e = (t, o) => `
|
|
43
|
+
<linearGradient id="gradient${t}-${o}" gradientTransform="rotate(90)">
|
|
44
|
+
<stop offset="0%" stop-color="${o}" stop-opacity="1" />
|
|
45
|
+
<stop offset="100%" stop-color="${o}" stop-opacity="0" />
|
|
46
|
+
</linearGradient>
|
|
47
|
+
`, p = (t, o) => `
|
|
48
|
+
<linearGradient id="gradient${t}-${o}" gradientTransform="rotate(90)">
|
|
49
|
+
<stop offset="0%" style="stop-color:var(--vis-color0);stop-opacity:1" />
|
|
50
|
+
<stop offset="100%" style="stop-color:var(--vis-color0);stop-opacity:0" />
|
|
51
|
+
</linearGradient>
|
|
52
|
+
`;
|
|
53
|
+
return y.value.map(
|
|
54
|
+
(t, o) => t != null && t.includes("#") ? e(o, t) : p(o, t ?? F)
|
|
55
|
+
).join("");
|
|
57
56
|
});
|
|
58
|
-
function
|
|
59
|
-
var
|
|
57
|
+
function G(e) {
|
|
58
|
+
var p;
|
|
60
59
|
return {
|
|
61
|
-
y: (
|
|
62
|
-
color: ((
|
|
60
|
+
y: (t) => Number(t[e]),
|
|
61
|
+
color: ((p = l.categories[e]) == null ? void 0 : p.color) ?? F
|
|
63
62
|
};
|
|
64
63
|
}
|
|
65
|
-
function
|
|
66
|
-
return
|
|
67
|
-
<linearGradient id="gradient${e}-${t}" gradientTransform="rotate(90)">
|
|
68
|
-
<stop offset="0%" style="stop-color:var(--vis-color0);stop-opacity:1" />
|
|
69
|
-
<stop offset="100%" style="stop-color:var(--vis-color0);stop-opacity:0" />
|
|
70
|
-
</linearGradient>
|
|
71
|
-
`;
|
|
64
|
+
function O(e) {
|
|
65
|
+
return typeof window > "u" ? "" : v.value ? v.value.innerHTML : "";
|
|
72
66
|
}
|
|
73
|
-
function
|
|
74
|
-
return
|
|
75
|
-
<linearGradient id="gradient${e}-${t}" gradientTransform="rotate(90)">
|
|
76
|
-
<stop offset="0%" stop-color="${t}" stop-opacity="1" />
|
|
77
|
-
<stop offset="100%" stop-color="${t}" stop-opacity="0" />
|
|
78
|
-
</linearGradient>
|
|
79
|
-
`;
|
|
67
|
+
function N(e) {
|
|
68
|
+
return s.value = e, O();
|
|
80
69
|
}
|
|
81
|
-
|
|
82
|
-
(
|
|
83
|
-
(e, t) => e != null && e.includes("#") ? x(t, e) : V(t, e ?? C)
|
|
84
|
-
).join("")
|
|
85
|
-
), k = g(
|
|
86
|
-
() => a.legendPosition === Y.Top
|
|
87
|
-
);
|
|
88
|
-
return (e, t) => (o(), c("div", {
|
|
89
|
-
class: T(["flex flex-col space-y-4", { "flex-col-reverse": k.value }])
|
|
70
|
+
return (e, p) => (a(), d("div", {
|
|
71
|
+
class: h(["flex flex-col space-y-4", { "flex-col-reverse": T.value }])
|
|
90
72
|
}, [
|
|
91
|
-
|
|
73
|
+
c(i(w), {
|
|
92
74
|
data: e.data,
|
|
93
75
|
height: e.height,
|
|
94
76
|
padding: e.padding,
|
|
95
77
|
"svg-defs": D.value
|
|
96
78
|
}, {
|
|
97
|
-
default:
|
|
98
|
-
e.hideTooltip ?
|
|
79
|
+
default: M(() => [
|
|
80
|
+
e.hideTooltip ? r("", !0) : (a(), u(i(z), {
|
|
99
81
|
key: 0,
|
|
100
|
-
"horizontal-placement": i(
|
|
101
|
-
"vertical-placement": i(
|
|
82
|
+
"horizontal-placement": i(C).Right,
|
|
83
|
+
"vertical-placement": i(C).Top
|
|
102
84
|
}, null, 8, ["horizontal-placement", "vertical-placement"])),
|
|
103
|
-
(
|
|
104
|
-
|
|
105
|
-
x: (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
85
|
+
(a(!0), d(L, null, R(Object.keys(l.categories), (t, o) => (a(), d(L, { key: t }, [
|
|
86
|
+
c(i(I), W({
|
|
87
|
+
x: (f, g) => g,
|
|
88
|
+
ref_for: !0
|
|
89
|
+
}, G(t), {
|
|
90
|
+
color: `url(#gradient${o}-${y.value[o]})`,
|
|
91
|
+
opacity: Q,
|
|
92
|
+
"curve-type": e.curveType ?? i(B).MonotoneX
|
|
110
93
|
}), null, 16, ["x", "color", "curve-type"]),
|
|
111
|
-
|
|
112
|
-
x: (
|
|
113
|
-
y: (
|
|
114
|
-
color:
|
|
115
|
-
"curve-type": e.curveType ?? i(
|
|
94
|
+
c(i(S), {
|
|
95
|
+
x: (f, g) => g,
|
|
96
|
+
y: (f) => f[t],
|
|
97
|
+
color: y.value[o],
|
|
98
|
+
"curve-type": e.curveType ?? i(B).MonotoneX
|
|
116
99
|
}, null, 8, ["x", "y", "color", "curve-type"])
|
|
117
100
|
], 64))), 128)),
|
|
118
|
-
e.hideXAxis ?
|
|
101
|
+
e.hideXAxis ? r("", !0) : (a(), u(i(V), {
|
|
119
102
|
key: 1,
|
|
120
103
|
type: "x",
|
|
121
|
-
"tick-format": e.xFormatter,
|
|
122
104
|
label: e.xLabel,
|
|
123
105
|
"label-margin": 8,
|
|
124
|
-
"domain-line": e.xDomainLine,
|
|
125
|
-
"grid-line": e.xGridLine,
|
|
126
106
|
"num-ticks": e.xNumTicks,
|
|
127
|
-
"tick-
|
|
107
|
+
"tick-format": e.xFormatter,
|
|
128
108
|
"tick-values": e.xExplicitTicks,
|
|
109
|
+
"grid-line": e.xGridLine,
|
|
110
|
+
"domain-line": e.xDomainLine,
|
|
111
|
+
"tick-line": e.xTickLine,
|
|
129
112
|
"min-max-ticks-only": e.minMaxTicksOnly
|
|
130
|
-
}, null, 8, ["
|
|
131
|
-
e.hideYAxis ?
|
|
113
|
+
}, null, 8, ["label", "num-ticks", "tick-format", "tick-values", "grid-line", "domain-line", "tick-line", "min-max-ticks-only"])),
|
|
114
|
+
e.hideYAxis ? r("", !0) : (a(), u(i(V), {
|
|
132
115
|
key: 2,
|
|
133
116
|
type: "y",
|
|
117
|
+
label: e.yLabel,
|
|
134
118
|
"num-ticks": e.yNumTicks,
|
|
135
119
|
"tick-format": e.yFormatter,
|
|
136
|
-
label: e.yLabel,
|
|
137
120
|
"grid-line": e.yGridLine,
|
|
138
121
|
"domain-line": e.yDomainLine,
|
|
139
122
|
"tick-line": e.yTickLine
|
|
140
|
-
}, null, 8, ["num-ticks", "tick-format", "
|
|
141
|
-
e.hideTooltip ?
|
|
123
|
+
}, null, 8, ["label", "num-ticks", "tick-format", "grid-line", "domain-line", "tick-line"])),
|
|
124
|
+
e.hideTooltip ? r("", !0) : (a(), u(i(H), {
|
|
142
125
|
key: 3,
|
|
143
126
|
color: "#666",
|
|
144
|
-
template:
|
|
145
|
-
}
|
|
127
|
+
template: N
|
|
128
|
+
}))
|
|
146
129
|
]),
|
|
147
130
|
_: 1
|
|
148
131
|
}, 8, ["data", "height", "padding", "svg-defs"]),
|
|
149
|
-
e.hideLegend ?
|
|
132
|
+
e.hideLegend ? r("", !0) : (a(), d("div", {
|
|
150
133
|
key: 0,
|
|
151
|
-
class:
|
|
134
|
+
class: h(["flex items-center justify-end", { "pb-4": T.value }])
|
|
152
135
|
}, [
|
|
153
|
-
|
|
136
|
+
c(i(K), {
|
|
154
137
|
items: Object.values(e.categories)
|
|
155
138
|
}, null, 8, ["items"])
|
|
156
|
-
], 2))
|
|
139
|
+
], 2)),
|
|
140
|
+
j("div", J, [
|
|
141
|
+
i($).tooltip ? b(e.$slots, "tooltip", {
|
|
142
|
+
key: 0,
|
|
143
|
+
values: s.value
|
|
144
|
+
}) : s.value ? b(e.$slots, "fallback", { key: 1 }, () => [
|
|
145
|
+
c(Y, {
|
|
146
|
+
data: s.value,
|
|
147
|
+
categories: e.categories,
|
|
148
|
+
toolTipTitle: i(X)(s.value) ?? "",
|
|
149
|
+
yFormatter: l.yFormatter
|
|
150
|
+
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
151
|
+
]) : r("", !0)
|
|
152
|
+
], 512)
|
|
157
153
|
], 2));
|
|
158
154
|
}
|
|
159
155
|
});
|
|
160
156
|
export {
|
|
161
|
-
|
|
157
|
+
ae as default
|
|
162
158
|
};
|
|
@@ -3,7 +3,12 @@ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>
|
|
|
3
3
|
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & AreaChartProps<T> & Partial<{}>> & import('vue').PublicProps;
|
|
4
4
|
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
5
5
|
attrs: any;
|
|
6
|
-
slots: {
|
|
6
|
+
slots: {
|
|
7
|
+
tooltip?(_: {
|
|
8
|
+
values: T | undefined;
|
|
9
|
+
}): any;
|
|
10
|
+
fallback?(_: {}): any;
|
|
11
|
+
};
|
|
7
12
|
emit: {};
|
|
8
13
|
}>) => import('vue').VNode & {
|
|
9
14
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LegendPosition } from '../../types';
|
|
1
|
+
import { axisFormatter, LegendPosition } from '../../types';
|
|
2
2
|
import { BulletLegendItemInterface, CurveType } from '@unovis/ts';
|
|
3
3
|
export interface AreaChartProps<T> {
|
|
4
4
|
/**
|
|
@@ -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?:
|
|
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?: axisFormatter<T>;
|
|
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?: axisFormatter<T>;
|
|
51
51
|
/**
|
|
52
52
|
* The type of curve to use for the area chart lines.
|
|
53
53
|
* See `CurveType` for available options.
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { defineComponent as x,
|
|
2
|
-
import { Orientation as
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
1
|
+
import { defineComponent as A, useSlots as P, useTemplateRef as x, ref as F, computed as f, createElementBlock as h, openBlock as o, normalizeClass as T, createVNode as d, createCommentVNode as s, createElementVNode as C, unref as i, withCtx as N, createBlock as u, renderSlot as b } from "vue";
|
|
2
|
+
import { Orientation as r, StackedBar as O, GroupedBar as G } from "@unovis/ts";
|
|
3
|
+
import { getFirstPropertyValue as w } from "../../utils.js";
|
|
4
|
+
import { VisXYContainer as E, VisTooltip as M, VisGroupedBar as D, VisStackedBar as S, VisAxis as L, VisBulletLegend as j } from "@unovis/vue";
|
|
5
|
+
import z from "../Tooltip.js";
|
|
6
|
+
import { LegendPosition as H } from "../../types.js";
|
|
7
|
+
const W = {
|
|
8
|
+
ref: "slotWrapper",
|
|
9
|
+
class: "hidden"
|
|
10
|
+
}, I = /* @__PURE__ */ A({
|
|
7
11
|
__name: "BarChart",
|
|
8
12
|
props: {
|
|
9
13
|
data: {},
|
|
@@ -20,16 +24,16 @@ const H = /* @__PURE__ */ x({
|
|
|
20
24
|
categories: {},
|
|
21
25
|
xFormatter: {},
|
|
22
26
|
yFormatter: {},
|
|
23
|
-
yNumTicks: { default: (
|
|
27
|
+
yNumTicks: { default: (n) => n.data.length > 24 ? 24 / 4 : n.data.length - 1 },
|
|
24
28
|
minMaxTicksOnly: { type: Boolean },
|
|
25
|
-
xNumTicks: { default: (
|
|
29
|
+
xNumTicks: { default: (n) => n.data.length > 24 ? 24 / 4 : n.data.length - 1 },
|
|
26
30
|
xExplicitTicks: {},
|
|
27
31
|
yAxis: {},
|
|
28
32
|
groupPadding: {},
|
|
29
33
|
barPadding: {},
|
|
30
34
|
radius: {},
|
|
31
35
|
hideLegend: { type: Boolean },
|
|
32
|
-
orientation: { default:
|
|
36
|
+
orientation: { default: r.Vertical },
|
|
33
37
|
legendPosition: {},
|
|
34
38
|
xDomainLine: { type: Boolean },
|
|
35
39
|
yDomainLine: { type: Boolean },
|
|
@@ -40,66 +44,55 @@ const H = /* @__PURE__ */ x({
|
|
|
40
44
|
hideXAxis: { type: Boolean },
|
|
41
45
|
hideYAxis: { type: Boolean }
|
|
42
46
|
},
|
|
43
|
-
setup(
|
|
44
|
-
const n =
|
|
45
|
-
if (!
|
|
47
|
+
setup(n) {
|
|
48
|
+
const a = n, v = P(), m = x("slotWrapper"), t = F();
|
|
49
|
+
if (!a.yAxis || a.yAxis.length === 0)
|
|
46
50
|
throw new Error("yAxis is required");
|
|
47
|
-
const
|
|
48
|
-
() =>
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
yFormatter: n.yFormatter
|
|
59
|
-
}), h = document.createElement("div");
|
|
60
|
-
r.mount(h);
|
|
61
|
-
const v = h.innerHTML;
|
|
62
|
-
return r.unmount(), v;
|
|
63
|
-
} catch {
|
|
64
|
-
return "";
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
return (e, o) => (t(), b("div", {
|
|
68
|
-
class: L(["flex flex-col space-y-4", { "flex-col-reverse": k.value }])
|
|
51
|
+
const g = f(() => a.yAxis.map((e) => (l) => l[e])), y = (e, l) => Object.values(a.categories)[l].color, c = f(
|
|
52
|
+
() => a.legendPosition === H.Top
|
|
53
|
+
);
|
|
54
|
+
function k(e) {
|
|
55
|
+
return t.value = e, B();
|
|
56
|
+
}
|
|
57
|
+
function B(e) {
|
|
58
|
+
return typeof window > "u" ? "" : m.value ? m.value.innerHTML : "";
|
|
59
|
+
}
|
|
60
|
+
return (e, l) => (o(), h("div", {
|
|
61
|
+
class: T(["flex flex-col space-y-4", { "flex-col-reverse": c.value }])
|
|
69
62
|
}, [
|
|
70
|
-
|
|
63
|
+
d(i(E), {
|
|
71
64
|
padding: e.padding,
|
|
72
65
|
height: e.height
|
|
73
66
|
}, {
|
|
74
|
-
default:
|
|
75
|
-
|
|
67
|
+
default: N(() => [
|
|
68
|
+
d(i(M), {
|
|
76
69
|
triggers: {
|
|
77
|
-
[i(
|
|
78
|
-
[i(
|
|
70
|
+
[i(G).selectors.bar]: k,
|
|
71
|
+
[i(O).selectors.bar]: k
|
|
79
72
|
}
|
|
80
73
|
}, null, 8, ["triggers"]),
|
|
81
|
-
e.stacked ? (
|
|
74
|
+
e.stacked ? (o(), u(i(S), {
|
|
82
75
|
key: 1,
|
|
83
76
|
data: e.data,
|
|
84
|
-
x: (
|
|
85
|
-
y:
|
|
86
|
-
color:
|
|
77
|
+
x: (V, p) => p,
|
|
78
|
+
y: g.value,
|
|
79
|
+
color: y,
|
|
87
80
|
"rounded-corners": e.radius ?? 0,
|
|
88
81
|
"group-padding": e.groupPadding ?? 0,
|
|
89
82
|
"bar-padding": e.barPadding ?? 0.2,
|
|
90
|
-
orientation: e.orientation ?? i(
|
|
91
|
-
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (
|
|
83
|
+
orientation: e.orientation ?? i(r).Vertical
|
|
84
|
+
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (o(), u(i(D), {
|
|
92
85
|
key: 0,
|
|
93
86
|
data: e.data,
|
|
94
|
-
x: (
|
|
95
|
-
y:
|
|
96
|
-
color:
|
|
87
|
+
x: (V, p) => p,
|
|
88
|
+
y: g.value,
|
|
89
|
+
color: y,
|
|
97
90
|
"rounded-corners": e.radius ?? 0,
|
|
98
91
|
"group-padding": e.groupPadding ?? 0,
|
|
99
92
|
"bar-padding": e.barPadding ?? 0.2,
|
|
100
|
-
orientation: e.orientation ?? i(
|
|
93
|
+
orientation: e.orientation ?? i(r).Vertical
|
|
101
94
|
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])),
|
|
102
|
-
e.hideXAxis ?
|
|
95
|
+
e.hideXAxis ? s("", !0) : (o(), u(i(L), {
|
|
103
96
|
key: 2,
|
|
104
97
|
type: "x",
|
|
105
98
|
"tick-format": e.xFormatter,
|
|
@@ -111,11 +104,11 @@ const H = /* @__PURE__ */ x({
|
|
|
111
104
|
"tick-values": e.xExplicitTicks,
|
|
112
105
|
minMaxTicksOnly: e.minMaxTicksOnly
|
|
113
106
|
}, null, 8, ["tick-format", "label", "grid-line", "domain-line", "tick-line", "num-ticks", "tick-values", "minMaxTicksOnly"])),
|
|
114
|
-
e.hideYAxis ?
|
|
107
|
+
e.hideYAxis ? s("", !0) : (o(), u(i(L), {
|
|
115
108
|
key: 3,
|
|
116
109
|
type: "y",
|
|
117
110
|
label: e.yLabel,
|
|
118
|
-
"grid-line": e.orientation !== i(
|
|
111
|
+
"grid-line": e.orientation !== i(r).Horizontal && e.yGridLine,
|
|
119
112
|
"domain-line": !!e.yDomainLine,
|
|
120
113
|
"tick-format": e.yFormatter,
|
|
121
114
|
"num-ticks": e.yNumTicks,
|
|
@@ -124,17 +117,30 @@ const H = /* @__PURE__ */ x({
|
|
|
124
117
|
]),
|
|
125
118
|
_: 1
|
|
126
119
|
}, 8, ["padding", "height"]),
|
|
127
|
-
e.hideLegend ?
|
|
120
|
+
e.hideLegend ? s("", !0) : (o(), h("div", {
|
|
128
121
|
key: 0,
|
|
129
|
-
class:
|
|
122
|
+
class: T(["flex items center justify-end", { "pb-4": c.value }])
|
|
130
123
|
}, [
|
|
131
|
-
|
|
124
|
+
d(i(j), {
|
|
132
125
|
items: Object.values(e.categories)
|
|
133
126
|
}, null, 8, ["items"])
|
|
134
|
-
], 2))
|
|
127
|
+
], 2)),
|
|
128
|
+
C("div", W, [
|
|
129
|
+
i(v).tooltip ? b(e.$slots, "tooltip", {
|
|
130
|
+
key: 0,
|
|
131
|
+
values: t.value
|
|
132
|
+
}) : t.value ? b(e.$slots, "fallback", { key: 1 }, () => [
|
|
133
|
+
d(z, {
|
|
134
|
+
data: t.value,
|
|
135
|
+
categories: e.categories,
|
|
136
|
+
toolTipTitle: i(w)(t.value) ?? "",
|
|
137
|
+
yFormatter: a.orientation === i(r).Horizontal ? a.xFormatter : a.yFormatter
|
|
138
|
+
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
139
|
+
]) : s("", !0)
|
|
140
|
+
], 512)
|
|
135
141
|
], 2));
|
|
136
142
|
}
|
|
137
143
|
});
|
|
138
144
|
export {
|
|
139
|
-
|
|
145
|
+
I as default
|
|
140
146
|
};
|
|
@@ -3,7 +3,12 @@ declare const _default: <T extends {}>(__VLS_props: NonNullable<Awaited<typeof _
|
|
|
3
3
|
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & BarChartProps<T> & Partial<{}>> & import('vue').PublicProps;
|
|
4
4
|
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
5
5
|
attrs: any;
|
|
6
|
-
slots: {
|
|
6
|
+
slots: {
|
|
7
|
+
tooltip?(_: {
|
|
8
|
+
values: T | undefined;
|
|
9
|
+
}): any;
|
|
10
|
+
fallback?(_: {}): any;
|
|
11
|
+
};
|
|
7
12
|
emit: {};
|
|
8
13
|
}>) => import('vue').VNode & {
|
|
9
14
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BulletLegendItemInterface, Orientation, LegendPosition } from '../../types';
|
|
1
|
+
import { BulletLegendItemInterface, Orientation, LegendPosition, axisFormatter } from '../../types';
|
|
2
2
|
export interface BarChartProps<T> {
|
|
3
3
|
/**
|
|
4
4
|
* The data to be displayed in the bar chart.
|
|
@@ -43,14 +43,14 @@ export interface BarChartProps<T> {
|
|
|
43
43
|
* @param {(number[]|Date[])} ticks - An array of all tick values for the x-axis.
|
|
44
44
|
* @returns {string} The formatted string representation of the tick.
|
|
45
45
|
*/
|
|
46
|
-
xFormatter?:
|
|
46
|
+
xFormatter?: axisFormatter<T>;
|
|
47
47
|
/**
|
|
48
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
49
|
* @param {number} i - The index of the tick in the `ticks` array.
|
|
50
50
|
* @param {(number[]|Date[])} ticks - An array of all tick values for the y-axis.
|
|
51
51
|
* @returns {string} The formatted string representation of the tick.
|
|
52
52
|
*/
|
|
53
|
-
yFormatter?:
|
|
53
|
+
yFormatter?: axisFormatter<T>;
|
|
54
54
|
/**
|
|
55
55
|
* The desired number of ticks on the y-axis.
|
|
56
56
|
*/
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Donut as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
const
|
|
1
|
+
import { defineComponent as y, useSlots as V, useTemplateRef as k, ref as C, createElementBlock as i, openBlock as u, Fragment as _, createElementVNode as l, createCommentVNode as d, createVNode as r, renderSlot as s, unref as t, withCtx as b, normalizeStyle as D, toDisplayString as S } from "vue";
|
|
2
|
+
import { Donut as T } from "@unovis/ts";
|
|
3
|
+
import { DonutType as w } from "./types.js";
|
|
4
|
+
import { VisSingleContainer as B, VisTooltip as L, VisDonut as $, VisBulletLegend as H } from "@unovis/vue";
|
|
5
|
+
const N = { class: "flex items-center justify-center" }, W = {
|
|
6
|
+
ref: "slotWrapper",
|
|
7
|
+
class: "hidden"
|
|
8
|
+
}, j = { class: "flex items-center" }, z = {
|
|
6
9
|
key: 0,
|
|
7
10
|
class: "flex items-center justify-center mt-4"
|
|
8
|
-
},
|
|
11
|
+
}, q = /* @__PURE__ */ y({
|
|
9
12
|
__name: "DonutChart",
|
|
10
13
|
props: {
|
|
11
14
|
type: {},
|
|
@@ -15,44 +18,60 @@ const k = { class: "flex items-center justify-center" }, B = {
|
|
|
15
18
|
hideLegend: { type: Boolean },
|
|
16
19
|
labels: {}
|
|
17
20
|
},
|
|
18
|
-
setup(
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
return (e,
|
|
27
|
-
|
|
28
|
-
t(
|
|
21
|
+
setup(c) {
|
|
22
|
+
const n = c, f = V(), a = k("slotWrapper"), o = C(), p = (e) => e, m = n.type === w.Half;
|
|
23
|
+
function h(e) {
|
|
24
|
+
return o.value = e, g();
|
|
25
|
+
}
|
|
26
|
+
function g(e) {
|
|
27
|
+
return typeof window > "u" ? "" : a.value ? a.value.innerHTML : "";
|
|
28
|
+
}
|
|
29
|
+
return (e, E) => (u(), i(_, null, [
|
|
30
|
+
l("div", N, [
|
|
31
|
+
r(t(B), {
|
|
29
32
|
data: e.data,
|
|
30
33
|
height: e.height,
|
|
31
34
|
margin: {}
|
|
32
35
|
}, {
|
|
33
|
-
default:
|
|
34
|
-
t(
|
|
36
|
+
default: b(() => [
|
|
37
|
+
r(t(L), {
|
|
35
38
|
"horizontal-shift": 20,
|
|
36
39
|
"vertical-shift": 20,
|
|
37
|
-
triggers:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
triggers: {
|
|
41
|
+
[t(T).selectors.segment]: h
|
|
42
|
+
}
|
|
43
|
+
}, null, 8, ["triggers"]),
|
|
44
|
+
r(t($), {
|
|
45
|
+
value: p,
|
|
41
46
|
"corner-radius": e.radius,
|
|
42
|
-
color:
|
|
43
|
-
"angle-range":
|
|
47
|
+
color: n.labels.map((v) => v.color),
|
|
48
|
+
"angle-range": m ? [-1.5707963267948966, 1.5707963267948966] : []
|
|
44
49
|
}, null, 8, ["corner-radius", "color", "angle-range"])
|
|
45
50
|
]),
|
|
46
51
|
_: 1
|
|
47
52
|
}, 8, ["data", "height"]),
|
|
48
|
-
|
|
53
|
+
s(e.$slots, "default"),
|
|
54
|
+
l("div", W, [
|
|
55
|
+
t(f).tooltip ? s(e.$slots, "tooltip", {
|
|
56
|
+
key: 0,
|
|
57
|
+
values: o.value
|
|
58
|
+
}) : o.value ? s(e.$slots, "fallback", { key: 1 }, () => [
|
|
59
|
+
l("div", j, [
|
|
60
|
+
l("div", {
|
|
61
|
+
class: "w-2 h-2 rounded-full mr-2",
|
|
62
|
+
style: D(`background-color: ${n.labels[o.value.index].color} ;`)
|
|
63
|
+
}, null, 4),
|
|
64
|
+
l("div", null, S(o.value.data), 1)
|
|
65
|
+
])
|
|
66
|
+
]) : d("", !0)
|
|
67
|
+
], 512)
|
|
49
68
|
]),
|
|
50
|
-
e.hideLegend ?
|
|
51
|
-
t(
|
|
69
|
+
e.hideLegend ? d("", !0) : (u(), i("div", z, [
|
|
70
|
+
r(t(H), { items: e.labels }, null, 8, ["items"])
|
|
52
71
|
]))
|
|
53
72
|
], 64));
|
|
54
73
|
}
|
|
55
74
|
});
|
|
56
75
|
export {
|
|
57
|
-
|
|
76
|
+
q as default
|
|
58
77
|
};
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { DonutChartProps } from './types';
|
|
2
|
-
declare
|
|
3
|
-
|
|
2
|
+
declare const _default: <T extends {}>(__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<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & DonutChartProps & Partial<{}>> & import('vue').PublicProps;
|
|
4
|
+
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
5
|
+
attrs: any;
|
|
4
6
|
slots: {
|
|
5
7
|
default?(_: {}): any;
|
|
8
|
+
tooltip?(_: {
|
|
9
|
+
values: any;
|
|
10
|
+
}): any;
|
|
11
|
+
fallback?(_: {}): any;
|
|
6
12
|
};
|
|
7
|
-
|
|
8
|
-
|
|
13
|
+
emit: {};
|
|
14
|
+
}>) => import('vue').VNode & {
|
|
15
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
9
16
|
};
|
|
10
|
-
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
11
|
-
declare const __VLS_component: import('vue').DefineComponent<DonutChartProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<DonutChartProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
12
|
-
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
13
17
|
export default _default;
|
|
14
|
-
type
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
};
|
|
18
|
+
type __VLS_PrettifyLocal<T> = {
|
|
19
|
+
[K in keyof T]: T[K];
|
|
20
|
+
} & {};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Position as
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
const
|
|
1
|
+
import { defineComponent as x, useSlots as F, useTemplateRef as O, ref as N, computed as M, createElementBlock as d, openBlock as o, normalizeClass as k, createVNode as r, createCommentVNode as a, createElementVNode as P, unref as i, withCtx as j, createBlock as s, Fragment as A, renderList as D, renderSlot as f } from "vue";
|
|
2
|
+
import { Position as g, CurveType as E } from "@unovis/ts";
|
|
3
|
+
import { getFirstPropertyValue as G } from "../../utils.js";
|
|
4
|
+
import X from "../Tooltip.js";
|
|
5
|
+
import { VisXYContainer as $, VisTooltip as w, VisLine as z, VisAxis as h, VisCrosshair as R, VisBulletLegend as W } from "@unovis/vue";
|
|
6
|
+
import { LegendPosition as Y } from "../../types.js";
|
|
7
|
+
const S = {
|
|
8
|
+
ref: "slotWrapper",
|
|
9
|
+
class: "hidden"
|
|
10
|
+
}, Z = /* @__PURE__ */ x({
|
|
8
11
|
__name: "LineChart",
|
|
9
12
|
props: {
|
|
10
13
|
data: {},
|
|
@@ -38,46 +41,39 @@ const H = /* @__PURE__ */ b({
|
|
|
38
41
|
hideYAxis: { type: Boolean }
|
|
39
42
|
},
|
|
40
43
|
setup(t) {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const r = l.innerHTML;
|
|
53
|
-
return a.unmount(), r;
|
|
54
|
-
} catch {
|
|
55
|
-
return "";
|
|
56
|
-
}
|
|
57
|
-
}), u = y(
|
|
58
|
-
() => o.legendPosition === D.Top
|
|
44
|
+
const n = t, T = F(), u = O("slotWrapper"), l = N(), v = Object.values(n.categories).map(
|
|
45
|
+
(e, c) => `var(--vis-color${c})`
|
|
46
|
+
), L = (e) => Object.values(n.categories)[e].color ?? v[e];
|
|
47
|
+
function b(e) {
|
|
48
|
+
return l.value = e, B();
|
|
49
|
+
}
|
|
50
|
+
function B(e) {
|
|
51
|
+
return typeof window > "u" ? "" : u.value ? u.value.innerHTML : "";
|
|
52
|
+
}
|
|
53
|
+
const m = M(
|
|
54
|
+
() => n.legendPosition === Y.Top
|
|
59
55
|
);
|
|
60
|
-
return (e, c) => (
|
|
61
|
-
class:
|
|
56
|
+
return (e, c) => (o(), d("div", {
|
|
57
|
+
class: k(["flex flex-col space-y-4", { "flex-col-reverse": m.value }])
|
|
62
58
|
}, [
|
|
63
|
-
|
|
59
|
+
r(i($), {
|
|
64
60
|
data: e.data,
|
|
65
61
|
padding: e.padding,
|
|
66
62
|
height: e.height
|
|
67
63
|
}, {
|
|
68
|
-
default:
|
|
69
|
-
|
|
70
|
-
"horizontal-placement": i(
|
|
71
|
-
"vertical-placement": i(
|
|
64
|
+
default: j(() => [
|
|
65
|
+
r(i(w), {
|
|
66
|
+
"horizontal-placement": i(g).Right,
|
|
67
|
+
"vertical-placement": i(g).Top
|
|
72
68
|
}, null, 8, ["horizontal-placement", "vertical-placement"]),
|
|
73
|
-
(
|
|
74
|
-
key:
|
|
75
|
-
x: (
|
|
76
|
-
y: (
|
|
77
|
-
color:
|
|
78
|
-
"curve-type": e.curveType ?? i(
|
|
69
|
+
(o(!0), d(A, null, D(Object.keys(n.categories), (C, p) => (o(), s(i(z), {
|
|
70
|
+
key: p,
|
|
71
|
+
x: (y, V) => V,
|
|
72
|
+
y: (y) => y[C],
|
|
73
|
+
color: L(p),
|
|
74
|
+
"curve-type": e.curveType ?? i(E).MonotoneX
|
|
79
75
|
}, null, 8, ["x", "y", "color", "curve-type"]))), 128)),
|
|
80
|
-
e.hideXAxis ?
|
|
76
|
+
e.hideXAxis ? a("", !0) : (o(), s(i(h), {
|
|
81
77
|
key: 0,
|
|
82
78
|
type: "x",
|
|
83
79
|
"tick-format": e.xFormatter,
|
|
@@ -90,7 +86,7 @@ const H = /* @__PURE__ */ b({
|
|
|
90
86
|
"tick-values": e.xExplicitTicks,
|
|
91
87
|
minMaxTicksOnly: e.minMaxTicksOnly
|
|
92
88
|
}, null, 8, ["tick-format", "label", "domain-line", "grid-line", "tick-line", "num-ticks", "tick-values", "minMaxTicksOnly"])),
|
|
93
|
-
e.hideYAxis ?
|
|
89
|
+
e.hideYAxis ? a("", !0) : (o(), s(i(h), {
|
|
94
90
|
key: 1,
|
|
95
91
|
type: "y",
|
|
96
92
|
"tick-format": e.yFormatter,
|
|
@@ -100,25 +96,38 @@ const H = /* @__PURE__ */ b({
|
|
|
100
96
|
"grid-line": e.yGridLine,
|
|
101
97
|
"tick-line": e.yTickLine
|
|
102
98
|
}, null, 8, ["tick-format", "label", "num-ticks", "domain-line", "grid-line", "tick-line"])),
|
|
103
|
-
e.hideTooltip ?
|
|
99
|
+
e.hideTooltip ? a("", !0) : (o(), s(i(R), {
|
|
104
100
|
key: 2,
|
|
105
101
|
color: "#666",
|
|
106
|
-
template:
|
|
107
|
-
}
|
|
102
|
+
template: b
|
|
103
|
+
}))
|
|
108
104
|
]),
|
|
109
105
|
_: 1
|
|
110
106
|
}, 8, ["data", "padding", "height"]),
|
|
111
|
-
e.hideLegend ?
|
|
107
|
+
e.hideLegend ? a("", !0) : (o(), d("div", {
|
|
112
108
|
key: 0,
|
|
113
|
-
class:
|
|
109
|
+
class: k(["flex items center justify-end", { "pb-4": m.value }])
|
|
114
110
|
}, [
|
|
115
|
-
|
|
111
|
+
r(i(W), {
|
|
116
112
|
items: Object.values(e.categories)
|
|
117
113
|
}, null, 8, ["items"])
|
|
118
|
-
], 2))
|
|
114
|
+
], 2)),
|
|
115
|
+
P("div", S, [
|
|
116
|
+
i(T).tooltip ? f(e.$slots, "tooltip", {
|
|
117
|
+
key: 0,
|
|
118
|
+
values: l.value
|
|
119
|
+
}) : l.value ? f(e.$slots, "fallback", { key: 1 }, () => [
|
|
120
|
+
r(X, {
|
|
121
|
+
data: l.value,
|
|
122
|
+
categories: e.categories,
|
|
123
|
+
toolTipTitle: i(G)(l.value) ?? "",
|
|
124
|
+
yFormatter: n.xFormatter
|
|
125
|
+
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
126
|
+
]) : a("", !0)
|
|
127
|
+
], 512)
|
|
119
128
|
], 2));
|
|
120
129
|
}
|
|
121
130
|
});
|
|
122
131
|
export {
|
|
123
|
-
|
|
132
|
+
Z as default
|
|
124
133
|
};
|
|
@@ -3,7 +3,12 @@ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>
|
|
|
3
3
|
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & LineChartProps<T> & Partial<{}>> & import('vue').PublicProps;
|
|
4
4
|
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
5
5
|
attrs: any;
|
|
6
|
-
slots: {
|
|
6
|
+
slots: {
|
|
7
|
+
tooltip?(_: {
|
|
8
|
+
values: T | undefined;
|
|
9
|
+
}): any;
|
|
10
|
+
fallback?(_: {}): any;
|
|
11
|
+
};
|
|
7
12
|
emit: {};
|
|
8
13
|
}>) => import('vue').VNode & {
|
|
9
14
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BulletLegendItemInterface, CurveType, LegendPosition } from '../../types';
|
|
1
|
+
import { axisFormatter, BulletLegendItemInterface, CurveType, LegendPosition } from '../../types';
|
|
2
2
|
export interface LineChartProps<T> {
|
|
3
3
|
/**
|
|
4
4
|
* The data to be displayed in the line chart.
|
|
@@ -19,9 +19,9 @@ export interface LineChartProps<T> {
|
|
|
19
19
|
*/
|
|
20
20
|
yLabel?: string;
|
|
21
21
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
* Optional padding applied to the chart.
|
|
23
|
+
* Allows specifying individual padding values for the top, right, bottom, and left sides.
|
|
24
|
+
*/
|
|
25
25
|
padding?: {
|
|
26
26
|
top: number;
|
|
27
27
|
right: number;
|
|
@@ -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?:
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
yFormatter?:
|
|
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?: axisFormatter<T>;
|
|
43
|
+
/**
|
|
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?: axisFormatter<T>;
|
|
50
50
|
/**
|
|
51
51
|
* The type of curve to use for the line chart.
|
|
52
52
|
* See `CurveType` for available options.
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { defineComponent as b, computed as v, createElementBlock as r, openBlock as l, createElementVNode as o, toDisplayString as i, Fragment as
|
|
1
|
+
import { defineComponent as b, computed as v, createElementBlock as r, openBlock as l, createElementVNode as o, toDisplayString as i, Fragment as h, renderList as y, normalizeStyle as a } from "vue";
|
|
2
2
|
const f = {
|
|
3
3
|
class: "capitalize border-b mb-1 pb-1",
|
|
4
4
|
style: {
|
|
5
5
|
color: "var(--tooltip-value-color)",
|
|
6
6
|
borderColor: "rgba(255, 255, 255, 0.05)"
|
|
7
7
|
}
|
|
8
|
-
},
|
|
8
|
+
}, T = /* @__PURE__ */ b({
|
|
9
9
|
__name: "Tooltip",
|
|
10
10
|
props: {
|
|
11
11
|
data: {},
|
|
12
12
|
categories: {},
|
|
13
13
|
toolTipTitle: {},
|
|
14
|
-
yFormatter: {
|
|
14
|
+
yFormatter: {}
|
|
15
15
|
},
|
|
16
16
|
setup(p) {
|
|
17
|
-
const
|
|
18
|
-
([e, g]) => !d.includes(e) && Object.keys(
|
|
17
|
+
const n = p, d = ["_index", "_stacked", "_ending"], m = v(() => Object.entries(n.data ?? []).filter(
|
|
18
|
+
([e, g]) => !d.includes(e) && Object.keys(n.categories).includes(e)
|
|
19
19
|
));
|
|
20
20
|
return (e, g) => (l(), r("div", null, [
|
|
21
21
|
o("div", f, i(e.toolTipTitle), 1),
|
|
22
|
-
(l(!0), r(
|
|
22
|
+
(l(!0), r(h, null, y(m.value, ([t, s], u) => {
|
|
23
23
|
var c;
|
|
24
24
|
return l(), r("div", {
|
|
25
25
|
key: t,
|
|
26
26
|
style: { display: "flex", "align-items": "center", "margin-bottom": "4px" }
|
|
27
27
|
}, [
|
|
28
28
|
o("span", {
|
|
29
|
-
style:
|
|
29
|
+
style: a([{ width: "8px", height: "8px", "border-radius": "4px", "margin-right": "8px" }, {
|
|
30
30
|
backgroundColor: (c = e.categories[t]) != null && c.color ? e.categories[t].color : `var(--vis-color${u})`
|
|
31
31
|
}])
|
|
32
32
|
}, null, 4),
|
|
33
33
|
o("div", null, [
|
|
34
34
|
o("span", {
|
|
35
|
-
style:
|
|
35
|
+
style: a([{ "font-weight": "600", "margin-right": "8px" }, { color: "var(--tooltip-label-color)" }])
|
|
36
36
|
}, i(e.categories[t].name) + ":", 1),
|
|
37
37
|
o("span", {
|
|
38
|
-
style:
|
|
38
|
+
style: a([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
|
|
39
39
|
}, i(e.yFormatter ? e.yFormatter(s) : s), 1)
|
|
40
40
|
])
|
|
41
41
|
]);
|
|
@@ -44,5 +44,5 @@ const f = {
|
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
export {
|
|
47
|
-
|
|
47
|
+
T as default
|
|
48
48
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { BulletLegendItemInterface } from '../types';
|
|
1
|
+
import { axisFormatter, BulletLegendItemInterface } 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
3
|
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & {
|
|
4
4
|
data: T;
|
|
5
5
|
categories: Record<string, BulletLegendItemInterface>;
|
|
6
6
|
toolTipTitle: string | number;
|
|
7
|
-
yFormatter?:
|
|
7
|
+
yFormatter?: axisFormatter<T>;
|
|
8
8
|
} & Partial<{}>> & import('vue').PublicProps;
|
|
9
9
|
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
10
10
|
attrs: any;
|
package/dist/types.d.ts
CHANGED
|
@@ -40,3 +40,4 @@ declare enum Orientation {
|
|
|
40
40
|
Vertical = "vertical"
|
|
41
41
|
}
|
|
42
42
|
export { LegendPosition, CurveType, Orientation, type AreaChartProps, type BarChartProps, type LineChartProps, type DonutChartProps, type BulletLegendItemInterface, };
|
|
43
|
+
export type axisFormatter<T> = ((tick: number, i?: number, ticks?: number[]) => string) | ((tick: Date, i?: number, ticks?: Date[]) => string);
|