vue-chrts 0.1.12-test.2 → 0.2.0-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 +87 -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 +114 -62
- package/dist/components/BarChart/BarChart.vue.d.ts +6 -1
- package/dist/components/BarChart/types.d.ts +7 -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 +3 -3
|
@@ -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,126 +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: (
|
|
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,
|
|
106
88
|
ref_for: !0
|
|
107
|
-
},
|
|
108
|
-
color: `url(#gradient${
|
|
109
|
-
opacity:
|
|
110
|
-
"curve-type": e.curveType ?? i(
|
|
89
|
+
}, G(t), {
|
|
90
|
+
color: `url(#gradient${o}-${y.value[o]})`,
|
|
91
|
+
opacity: Q,
|
|
92
|
+
"curve-type": e.curveType ?? i(B).MonotoneX
|
|
111
93
|
}), null, 16, ["x", "color", "curve-type"]),
|
|
112
|
-
|
|
113
|
-
x: (
|
|
114
|
-
y: (
|
|
115
|
-
color:
|
|
116
|
-
"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
|
|
117
99
|
}, null, 8, ["x", "y", "color", "curve-type"])
|
|
118
100
|
], 64))), 128)),
|
|
119
|
-
e.hideXAxis ?
|
|
101
|
+
e.hideXAxis ? r("", !0) : (a(), u(i(V), {
|
|
120
102
|
key: 1,
|
|
121
103
|
type: "x",
|
|
122
|
-
"tick-format": e.xFormatter,
|
|
123
104
|
label: e.xLabel,
|
|
124
105
|
"label-margin": 8,
|
|
125
|
-
"domain-line": e.xDomainLine,
|
|
126
|
-
"grid-line": e.xGridLine,
|
|
127
106
|
"num-ticks": e.xNumTicks,
|
|
128
|
-
"tick-
|
|
107
|
+
"tick-format": e.xFormatter,
|
|
129
108
|
"tick-values": e.xExplicitTicks,
|
|
109
|
+
"grid-line": e.xGridLine,
|
|
110
|
+
"domain-line": e.xDomainLine,
|
|
111
|
+
"tick-line": e.xTickLine,
|
|
130
112
|
"min-max-ticks-only": e.minMaxTicksOnly
|
|
131
|
-
}, null, 8, ["
|
|
132
|
-
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), {
|
|
133
115
|
key: 2,
|
|
134
116
|
type: "y",
|
|
117
|
+
label: e.yLabel,
|
|
135
118
|
"num-ticks": e.yNumTicks,
|
|
136
119
|
"tick-format": e.yFormatter,
|
|
137
|
-
label: e.yLabel,
|
|
138
120
|
"grid-line": e.yGridLine,
|
|
139
121
|
"domain-line": e.yDomainLine,
|
|
140
122
|
"tick-line": e.yTickLine
|
|
141
|
-
}, null, 8, ["num-ticks", "tick-format", "
|
|
142
|
-
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), {
|
|
143
125
|
key: 3,
|
|
144
126
|
color: "#666",
|
|
145
|
-
template:
|
|
146
|
-
}
|
|
127
|
+
template: N
|
|
128
|
+
}))
|
|
147
129
|
]),
|
|
148
130
|
_: 1
|
|
149
131
|
}, 8, ["data", "height", "padding", "svg-defs"]),
|
|
150
|
-
e.hideLegend ?
|
|
132
|
+
e.hideLegend ? r("", !0) : (a(), d("div", {
|
|
151
133
|
key: 0,
|
|
152
|
-
class:
|
|
134
|
+
class: h(["flex items-center justify-end", { "pb-4": T.value }])
|
|
153
135
|
}, [
|
|
154
|
-
|
|
136
|
+
c(i(K), {
|
|
155
137
|
items: Object.values(e.categories)
|
|
156
138
|
}, null, 8, ["items"])
|
|
157
|
-
], 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)
|
|
158
153
|
], 2));
|
|
159
154
|
}
|
|
160
155
|
});
|
|
161
156
|
export {
|
|
162
|
-
|
|
157
|
+
ae as default
|
|
163
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,13 +1,18 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Orientation as
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
1
|
+
import { defineComponent as M, useSlots as E, useTemplateRef as $, ref as S, computed as s, createElementBlock as y, openBlock as d, normalizeClass as B, createVNode as u, createCommentVNode as g, createElementVNode as z, unref as a, withCtx as H, createBlock as m, Fragment as W, renderSlot as P } from "vue";
|
|
2
|
+
import { Orientation as l, StackedBar as X, GroupedBar as Y } from "@unovis/ts";
|
|
3
|
+
import { getFirstPropertyValue as R } from "../../utils.js";
|
|
4
|
+
import { VisXYContainer as q, VisTooltip as U, VisStackedBar as k, VisGroupedBar as I, VisAxis as V, VisBulletLegend as J } from "@unovis/vue";
|
|
5
|
+
import K from "../Tooltip.js";
|
|
6
|
+
import { LegendPosition as Q } from "../../types.js";
|
|
7
|
+
const Z = {
|
|
8
|
+
ref: "slotWrapper",
|
|
9
|
+
class: "hidden"
|
|
10
|
+
}, re = /* @__PURE__ */ M({
|
|
7
11
|
__name: "BarChart",
|
|
8
12
|
props: {
|
|
9
13
|
data: {},
|
|
10
14
|
stacked: { type: Boolean },
|
|
15
|
+
stackAndGrouped: { type: Boolean },
|
|
11
16
|
height: {},
|
|
12
17
|
xLabel: {},
|
|
13
18
|
yLabel: {},
|
|
@@ -20,16 +25,16 @@ const H = /* @__PURE__ */ x({
|
|
|
20
25
|
categories: {},
|
|
21
26
|
xFormatter: {},
|
|
22
27
|
yFormatter: {},
|
|
23
|
-
yNumTicks: { default: (
|
|
28
|
+
yNumTicks: { default: (t) => t.data.length > 24 ? 24 / 4 : t.data.length - 1 },
|
|
24
29
|
minMaxTicksOnly: { type: Boolean },
|
|
25
|
-
xNumTicks: { default: (
|
|
30
|
+
xNumTicks: { default: (t) => t.data.length > 24 ? 24 / 4 : t.data.length - 1 },
|
|
26
31
|
xExplicitTicks: {},
|
|
27
32
|
yAxis: {},
|
|
28
33
|
groupPadding: {},
|
|
29
34
|
barPadding: {},
|
|
30
35
|
radius: {},
|
|
31
36
|
hideLegend: { type: Boolean },
|
|
32
|
-
orientation: { default:
|
|
37
|
+
orientation: { default: l.Vertical },
|
|
33
38
|
legendPosition: {},
|
|
34
39
|
xDomainLine: { type: Boolean },
|
|
35
40
|
yDomainLine: { type: Boolean },
|
|
@@ -40,67 +45,101 @@ const H = /* @__PURE__ */ x({
|
|
|
40
45
|
hideXAxis: { type: Boolean },
|
|
41
46
|
hideYAxis: { type: Boolean }
|
|
42
47
|
},
|
|
43
|
-
setup(
|
|
44
|
-
const
|
|
45
|
-
if (!
|
|
48
|
+
setup(t) {
|
|
49
|
+
const o = t, A = E(), f = $("slotWrapper"), p = S();
|
|
50
|
+
if (!o.yAxis || o.yAxis.length === 0)
|
|
46
51
|
throw new Error("yAxis is required");
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
52
|
+
const b = s(() => o.yAxis.map((e) => (n) => n[e])), h = (e, n) => {
|
|
53
|
+
var r;
|
|
54
|
+
return (r = Object.values(o.categories)[n]) == null ? void 0 : r.color;
|
|
55
|
+
}, C = s(() => Object.values(o.categories).slice(0, 4).map((e) => e.color)), G = s(() => Object.values(o.categories).slice(4, 8).map((e) => e.color)), D = (e, n) => C.value[n] ?? "#ccc", F = (e, n) => G.value[n] ?? "#eee", v = s(
|
|
56
|
+
() => o.legendPosition === Q.Top
|
|
57
|
+
);
|
|
58
|
+
function T(e) {
|
|
59
|
+
return p.value = e, O();
|
|
60
|
+
}
|
|
61
|
+
function O(e) {
|
|
62
|
+
return typeof window > "u" ? "" : f.value ? f.value.innerHTML : "";
|
|
63
|
+
}
|
|
64
|
+
const N = s(() => o.stackAndGrouped ? Object.keys(o.data[0]).filter((e) => e !== "month") : []), j = (e) => {
|
|
65
|
+
const n = ["Done", "Pending"];
|
|
66
|
+
return e.map((r) => ({
|
|
67
|
+
month: r.month,
|
|
68
|
+
...N.value.flatMap(
|
|
69
|
+
(i) => n.map((c) => ({
|
|
70
|
+
[`${i}${c}`]: r[i][c.toLowerCase()]
|
|
71
|
+
}))
|
|
72
|
+
).reduce((i, c) => ({ ...i, ...c }), {})
|
|
73
|
+
}));
|
|
74
|
+
}, L = s(() => o.stackAndGrouped ? j(o.data) : o.data), w = [
|
|
75
|
+
(e) => e.desktopDone,
|
|
76
|
+
(e) => e.mobileDone,
|
|
77
|
+
(e) => e.androidDone,
|
|
78
|
+
(e) => e.iosDone
|
|
79
|
+
], x = [
|
|
80
|
+
(e) => e.desktopPending,
|
|
81
|
+
(e) => e.mobilePending,
|
|
82
|
+
(e) => e.androidPending,
|
|
83
|
+
(e) => e.iosPending
|
|
84
|
+
];
|
|
85
|
+
return (e, n) => (d(), y("div", {
|
|
86
|
+
class: B(["flex flex-col space-y-4", { "flex-col-reverse": v.value }])
|
|
69
87
|
}, [
|
|
70
|
-
|
|
88
|
+
u(a(q), {
|
|
71
89
|
padding: e.padding,
|
|
72
90
|
height: e.height
|
|
73
91
|
}, {
|
|
74
|
-
default:
|
|
75
|
-
|
|
92
|
+
default: H(() => [
|
|
93
|
+
u(a(U), {
|
|
76
94
|
triggers: {
|
|
77
|
-
[
|
|
78
|
-
[
|
|
95
|
+
[a(Y).selectors.bar]: T,
|
|
96
|
+
[a(X).selectors.bar]: T
|
|
79
97
|
}
|
|
80
98
|
}, null, 8, ["triggers"]),
|
|
81
|
-
e.
|
|
82
|
-
|
|
99
|
+
e.stackAndGrouped ? (d(), y(W, { key: 0 }, [
|
|
100
|
+
u(a(k), {
|
|
101
|
+
data: L.value,
|
|
102
|
+
x: (r, i) => i - 0.2,
|
|
103
|
+
y: w,
|
|
104
|
+
color: D,
|
|
105
|
+
"rounded-corners": e.radius ?? 0,
|
|
106
|
+
"group-padding": e.groupPadding ?? 0,
|
|
107
|
+
"bar-padding": e.barPadding ?? 0.2,
|
|
108
|
+
orientation: e.orientation ?? a(l).Vertical
|
|
109
|
+
}, null, 8, ["data", "x", "rounded-corners", "group-padding", "bar-padding", "orientation"]),
|
|
110
|
+
u(a(k), {
|
|
111
|
+
data: L.value,
|
|
112
|
+
x: (r, i) => i + 0.2,
|
|
113
|
+
y: x,
|
|
114
|
+
color: F,
|
|
115
|
+
"rounded-corners": e.radius ?? 0,
|
|
116
|
+
"group-padding": e.groupPadding ?? 0,
|
|
117
|
+
"bar-padding": e.barPadding ?? 0.2,
|
|
118
|
+
orientation: e.orientation ?? a(l).Vertical
|
|
119
|
+
}, null, 8, ["data", "x", "rounded-corners", "group-padding", "bar-padding", "orientation"])
|
|
120
|
+
], 64)) : e.stacked ? (d(), m(a(k), {
|
|
121
|
+
key: 2,
|
|
83
122
|
data: e.data,
|
|
84
|
-
x: (
|
|
85
|
-
y:
|
|
86
|
-
color:
|
|
123
|
+
x: (r, i) => i,
|
|
124
|
+
y: b.value,
|
|
125
|
+
color: h,
|
|
87
126
|
"rounded-corners": e.radius ?? 0,
|
|
88
127
|
"group-padding": e.groupPadding ?? 0,
|
|
89
128
|
"bar-padding": e.barPadding ?? 0.2,
|
|
90
|
-
orientation: e.orientation ??
|
|
91
|
-
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (
|
|
92
|
-
key:
|
|
129
|
+
orientation: e.orientation ?? a(l).Vertical
|
|
130
|
+
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (d(), m(a(I), {
|
|
131
|
+
key: 1,
|
|
93
132
|
data: e.data,
|
|
94
|
-
x: (
|
|
95
|
-
y:
|
|
96
|
-
color:
|
|
133
|
+
x: (r, i) => i,
|
|
134
|
+
y: b.value,
|
|
135
|
+
color: h,
|
|
97
136
|
"rounded-corners": e.radius ?? 0,
|
|
98
137
|
"group-padding": e.groupPadding ?? 0,
|
|
99
138
|
"bar-padding": e.barPadding ?? 0.2,
|
|
100
|
-
orientation: e.orientation ??
|
|
139
|
+
orientation: e.orientation ?? a(l).Vertical
|
|
101
140
|
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])),
|
|
102
|
-
e.hideXAxis ?
|
|
103
|
-
key:
|
|
141
|
+
e.hideXAxis ? g("", !0) : (d(), m(a(V), {
|
|
142
|
+
key: 3,
|
|
104
143
|
type: "x",
|
|
105
144
|
"tick-format": e.xFormatter,
|
|
106
145
|
label: e.xLabel,
|
|
@@ -111,11 +150,11 @@ const H = /* @__PURE__ */ x({
|
|
|
111
150
|
"tick-values": e.xExplicitTicks,
|
|
112
151
|
minMaxTicksOnly: e.minMaxTicksOnly
|
|
113
152
|
}, null, 8, ["tick-format", "label", "grid-line", "domain-line", "tick-line", "num-ticks", "tick-values", "minMaxTicksOnly"])),
|
|
114
|
-
e.hideYAxis ?
|
|
115
|
-
key:
|
|
153
|
+
e.hideYAxis ? g("", !0) : (d(), m(a(V), {
|
|
154
|
+
key: 4,
|
|
116
155
|
type: "y",
|
|
117
156
|
label: e.yLabel,
|
|
118
|
-
"grid-line": e.orientation !==
|
|
157
|
+
"grid-line": e.orientation !== a(l).Horizontal && e.yGridLine,
|
|
119
158
|
"domain-line": !!e.yDomainLine,
|
|
120
159
|
"tick-format": e.yFormatter,
|
|
121
160
|
"num-ticks": e.yNumTicks,
|
|
@@ -124,17 +163,30 @@ const H = /* @__PURE__ */ x({
|
|
|
124
163
|
]),
|
|
125
164
|
_: 1
|
|
126
165
|
}, 8, ["padding", "height"]),
|
|
127
|
-
e.hideLegend ?
|
|
166
|
+
e.hideLegend ? g("", !0) : (d(), y("div", {
|
|
128
167
|
key: 0,
|
|
129
|
-
class:
|
|
168
|
+
class: B(["flex items center justify-end", { "pb-4": v.value }])
|
|
130
169
|
}, [
|
|
131
|
-
|
|
132
|
-
items: Object.values(
|
|
170
|
+
u(a(J), {
|
|
171
|
+
items: Object.values(o.categories)
|
|
133
172
|
}, null, 8, ["items"])
|
|
134
|
-
], 2))
|
|
173
|
+
], 2)),
|
|
174
|
+
z("div", Z, [
|
|
175
|
+
a(A).tooltip ? P(e.$slots, "tooltip", {
|
|
176
|
+
key: 0,
|
|
177
|
+
values: p.value
|
|
178
|
+
}) : p.value ? P(e.$slots, "fallback", { key: 1 }, () => [
|
|
179
|
+
u(K, {
|
|
180
|
+
data: p.value,
|
|
181
|
+
categories: o.categories,
|
|
182
|
+
toolTipTitle: a(R)(p.value) ?? "",
|
|
183
|
+
yFormatter: o.orientation === a(l).Horizontal ? o.xFormatter : o.yFormatter
|
|
184
|
+
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
185
|
+
]) : g("", !0)
|
|
186
|
+
], 512)
|
|
135
187
|
], 2));
|
|
136
188
|
}
|
|
137
189
|
});
|
|
138
190
|
export {
|
|
139
|
-
|
|
191
|
+
re as default
|
|
140
192
|
};
|
|
@@ -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.
|
|
@@ -10,6 +10,10 @@ export interface BarChartProps<T> {
|
|
|
10
10
|
* If `true`, creates a stacked bar chart instead of grouped bars.
|
|
11
11
|
*/
|
|
12
12
|
stacked?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* If `true`, creates a combination of stacked and grouped bar charts.
|
|
15
|
+
*/
|
|
16
|
+
stackAndGrouped?: boolean;
|
|
13
17
|
/**
|
|
14
18
|
* The height of the chart in pixels.
|
|
15
19
|
*/
|
|
@@ -43,14 +47,14 @@ export interface BarChartProps<T> {
|
|
|
43
47
|
* @param {(number[]|Date[])} ticks - An array of all tick values for the x-axis.
|
|
44
48
|
* @returns {string} The formatted string representation of the tick.
|
|
45
49
|
*/
|
|
46
|
-
xFormatter?:
|
|
50
|
+
xFormatter?: axisFormatter<T>;
|
|
47
51
|
/**
|
|
48
52
|
* @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
53
|
* @param {number} i - The index of the tick in the `ticks` array.
|
|
50
54
|
* @param {(number[]|Date[])} ticks - An array of all tick values for the y-axis.
|
|
51
55
|
* @returns {string} The formatted string representation of the tick.
|
|
52
56
|
*/
|
|
53
|
-
yFormatter?:
|
|
57
|
+
yFormatter?: axisFormatter<T>;
|
|
54
58
|
/**
|
|
55
59
|
* The desired number of ticks on the y-axis.
|
|
56
60
|
*/
|
|
@@ -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 typeof window > "u" ? "" : u.value ? u.value.innerHTML : "";
|
|
49
|
+
}
|
|
50
|
+
function B(e) {
|
|
51
|
+
return l.value = e, b();
|
|
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.yFormatter
|
|
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);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-chrts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-test.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"release": "commit-and-tag-version"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@unovis/ts": "^1.5.
|
|
24
|
+
"@unovis/ts": "^1.5.2"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"vue": "^3.5.13"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@tailwindcss/vite": "^4.0.15",
|
|
31
31
|
"@tanstack/vue-table": "^8.21.2",
|
|
32
32
|
"@types/node": "^22.13.11",
|
|
33
|
-
"@unovis/vue": "^1.5.
|
|
33
|
+
"@unovis/vue": "^1.5.2",
|
|
34
34
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
35
35
|
"@vue/tsconfig": "^0.7.0",
|
|
36
36
|
"@vueuse/core": "^13.0.0",
|