vue-chrts 0.2.0-test.5 → 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 -161
- package/dist/components/AreaChart/types.d.ts +20 -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 +56 -55
- package/dist/components/LineChart/LineChart.vue.d.ts +4 -2
- package/dist/components/LineChart/types.d.ts +24 -5
- 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,18 +1,18 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Orientation as l, StackedBar as
|
|
3
|
-
import { getFirstPropertyValue as
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
1
|
+
import { defineComponent as C, useSlots as N, useTemplateRef as O, ref as D, computed as T, createElementBlock as m, openBlock as n, normalizeClass as L, createVNode as g, createCommentVNode as c, createElementVNode as w, unref as i, withCtx as E, createBlock as u, Fragment as M, renderList as S, renderSlot as v } from "vue";
|
|
2
|
+
import { Orientation as l, StackedBar as j, GroupedBar as z } from "@unovis/ts";
|
|
3
|
+
import { getFirstPropertyValue as H } from "../../utils.js";
|
|
4
|
+
import { useStackedGrouped as W } from "./stackedGroupedUtils.js";
|
|
5
|
+
import { VisXYContainer as X, VisTooltip as Y, VisStackedBar as B, VisGroupedBar as $, VisAxis as A, VisBulletLegend as R } from "@unovis/vue";
|
|
6
|
+
import q from "../Tooltip.js";
|
|
7
|
+
import { LegendPosition as U } from "../../types.js";
|
|
8
|
+
const I = {
|
|
8
9
|
ref: "slotWrapper",
|
|
9
10
|
class: "hidden"
|
|
10
|
-
},
|
|
11
|
+
}, ae = /* @__PURE__ */ C({
|
|
11
12
|
__name: "BarChart",
|
|
12
13
|
props: {
|
|
13
14
|
data: {},
|
|
14
15
|
stacked: { type: Boolean },
|
|
15
|
-
stackAndGrouped: { type: Boolean },
|
|
16
16
|
height: {},
|
|
17
17
|
xLabel: {},
|
|
18
18
|
yLabel: {},
|
|
@@ -34,6 +34,7 @@ const Z = {
|
|
|
34
34
|
barPadding: {},
|
|
35
35
|
radius: {},
|
|
36
36
|
hideLegend: { type: Boolean },
|
|
37
|
+
hideTooltip: { type: Boolean, default: !1 },
|
|
37
38
|
orientation: { default: l.Vertical },
|
|
38
39
|
legendPosition: {},
|
|
39
40
|
xDomainLine: { type: Boolean },
|
|
@@ -43,102 +44,79 @@ const Z = {
|
|
|
43
44
|
xGridLine: { type: Boolean },
|
|
44
45
|
yGridLine: { type: Boolean, default: !0 },
|
|
45
46
|
hideXAxis: { type: Boolean },
|
|
46
|
-
hideYAxis: { type: Boolean }
|
|
47
|
+
hideYAxis: { type: Boolean },
|
|
48
|
+
stackAndGrouped: { type: Boolean },
|
|
49
|
+
xAxis: {}
|
|
47
50
|
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
emits: ["click"],
|
|
52
|
+
setup(t, { emit: V }) {
|
|
53
|
+
const x = V, a = t, P = N(), y = O("slotWrapper"), r = D();
|
|
54
|
+
if (!a.yAxis || a.yAxis.length === 0)
|
|
51
55
|
throw new Error("yAxis is required");
|
|
52
|
-
const
|
|
53
|
-
var
|
|
54
|
-
return (
|
|
55
|
-
},
|
|
56
|
-
|
|
56
|
+
const k = T(() => a.yAxis.map((e) => (d) => d[e])), f = (e, d) => {
|
|
57
|
+
var o;
|
|
58
|
+
return (o = Object.values(a.categories)[d]) == null ? void 0 : o.color;
|
|
59
|
+
}, s = W({
|
|
60
|
+
data: a.data,
|
|
61
|
+
categories: a.categories,
|
|
62
|
+
stackAndGrouped: a.stackAndGrouped,
|
|
63
|
+
xAxis: a.xAxis
|
|
64
|
+
}), h = T(
|
|
65
|
+
() => a.legendPosition === U.Top
|
|
57
66
|
);
|
|
58
|
-
function
|
|
59
|
-
return
|
|
67
|
+
function b(e) {
|
|
68
|
+
return r.value = e, G();
|
|
60
69
|
}
|
|
61
|
-
function
|
|
62
|
-
return typeof window > "u" ? "" :
|
|
70
|
+
function G(e) {
|
|
71
|
+
return typeof window > "u" ? "" : y.value ? y.value.innerHTML : "";
|
|
63
72
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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 }])
|
|
73
|
+
return (e, d) => (n(), m("div", {
|
|
74
|
+
class: L(["flex flex-col space-y-4", { "flex-col-reverse": h.value }]),
|
|
75
|
+
onClick: d[0] || (d[0] = (o) => x("click", o, r.value))
|
|
87
76
|
}, [
|
|
88
|
-
|
|
77
|
+
g(i(X), {
|
|
89
78
|
padding: e.padding,
|
|
90
79
|
height: e.height
|
|
91
80
|
}, {
|
|
92
|
-
default:
|
|
93
|
-
|
|
81
|
+
default: E(() => [
|
|
82
|
+
g(i(Y), {
|
|
94
83
|
triggers: {
|
|
95
|
-
[
|
|
96
|
-
[
|
|
84
|
+
[i(z).selectors.bar]: b,
|
|
85
|
+
[i(j).selectors.bar]: b
|
|
97
86
|
}
|
|
98
87
|
}, null, 8, ["triggers"]),
|
|
99
|
-
e.stackAndGrouped ? (
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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), {
|
|
88
|
+
e.stackAndGrouped ? (n(!0), m(M, { key: 0 }, S(i(s).states, (o) => (n(), u(i(B), {
|
|
89
|
+
key: o,
|
|
90
|
+
data: i(s).chartData,
|
|
91
|
+
x: (p, F) => F + i(s).positions[o],
|
|
92
|
+
y: i(s).bars[o],
|
|
93
|
+
color: i(s).colorFunctions[o],
|
|
94
|
+
"rounded-corners": e.radius ?? 0,
|
|
95
|
+
"group-padding": e.groupPadding ?? 0,
|
|
96
|
+
"bar-padding": e.barPadding ?? 0.2,
|
|
97
|
+
orientation: e.orientation ?? i(l).Vertical
|
|
98
|
+
}, null, 8, ["data", "x", "y", "color", "rounded-corners", "group-padding", "bar-padding", "orientation"]))), 128)) : e.stacked ? (n(), u(i(B), {
|
|
121
99
|
key: 2,
|
|
122
100
|
data: e.data,
|
|
123
|
-
x: (
|
|
124
|
-
y:
|
|
125
|
-
color:
|
|
101
|
+
x: (o, p) => p,
|
|
102
|
+
y: k.value,
|
|
103
|
+
color: f,
|
|
126
104
|
"rounded-corners": e.radius ?? 0,
|
|
127
105
|
"group-padding": e.groupPadding ?? 0,
|
|
128
106
|
"bar-padding": e.barPadding ?? 0.2,
|
|
129
|
-
orientation: e.orientation ??
|
|
130
|
-
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (
|
|
107
|
+
orientation: e.orientation ?? i(l).Vertical
|
|
108
|
+
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (n(), u(i($), {
|
|
131
109
|
key: 1,
|
|
132
110
|
data: e.data,
|
|
133
|
-
x: (
|
|
134
|
-
y:
|
|
135
|
-
color:
|
|
111
|
+
x: (o, p) => p,
|
|
112
|
+
y: k.value,
|
|
113
|
+
color: f,
|
|
136
114
|
"rounded-corners": e.radius ?? 0,
|
|
137
115
|
"group-padding": e.groupPadding ?? 0,
|
|
138
116
|
"bar-padding": e.barPadding ?? 0.2,
|
|
139
|
-
orientation: e.orientation ??
|
|
117
|
+
orientation: e.orientation ?? i(l).Vertical
|
|
140
118
|
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])),
|
|
141
|
-
e.hideXAxis ?
|
|
119
|
+
e.hideXAxis ? c("", !0) : (n(), u(i(A), {
|
|
142
120
|
key: 3,
|
|
143
121
|
type: "x",
|
|
144
122
|
"tick-format": e.xFormatter,
|
|
@@ -150,11 +128,11 @@ const Z = {
|
|
|
150
128
|
"tick-values": e.xExplicitTicks,
|
|
151
129
|
minMaxTicksOnly: e.minMaxTicksOnly
|
|
152
130
|
}, null, 8, ["tick-format", "label", "grid-line", "domain-line", "tick-line", "num-ticks", "tick-values", "minMaxTicksOnly"])),
|
|
153
|
-
e.hideYAxis ?
|
|
131
|
+
e.hideYAxis ? c("", !0) : (n(), u(i(A), {
|
|
154
132
|
key: 4,
|
|
155
133
|
type: "y",
|
|
156
134
|
label: e.yLabel,
|
|
157
|
-
"grid-line": e.orientation !==
|
|
135
|
+
"grid-line": e.orientation !== i(l).Horizontal && e.yGridLine,
|
|
158
136
|
"domain-line": !!e.yDomainLine,
|
|
159
137
|
"tick-format": e.yFormatter,
|
|
160
138
|
"num-ticks": e.yNumTicks,
|
|
@@ -163,30 +141,30 @@ const Z = {
|
|
|
163
141
|
]),
|
|
164
142
|
_: 1
|
|
165
143
|
}, 8, ["padding", "height"]),
|
|
166
|
-
e.hideLegend ?
|
|
144
|
+
e.hideLegend ? c("", !0) : (n(), m("div", {
|
|
167
145
|
key: 0,
|
|
168
|
-
class:
|
|
146
|
+
class: L(["flex items center justify-end", { "pb-4": h.value }])
|
|
169
147
|
}, [
|
|
170
|
-
|
|
171
|
-
items: Object.values(
|
|
148
|
+
g(i(R), {
|
|
149
|
+
items: Object.values(a.categories)
|
|
172
150
|
}, null, 8, ["items"])
|
|
173
151
|
], 2)),
|
|
174
|
-
|
|
175
|
-
|
|
152
|
+
w("div", I, [
|
|
153
|
+
i(P).tooltip ? v(e.$slots, "tooltip", {
|
|
176
154
|
key: 0,
|
|
177
|
-
values:
|
|
178
|
-
}) :
|
|
179
|
-
|
|
180
|
-
data:
|
|
181
|
-
categories:
|
|
182
|
-
toolTipTitle:
|
|
183
|
-
yFormatter:
|
|
155
|
+
values: r.value
|
|
156
|
+
}) : r.value ? v(e.$slots, "fallback", { key: 1 }, () => [
|
|
157
|
+
g(q, {
|
|
158
|
+
data: r.value,
|
|
159
|
+
categories: a.categories,
|
|
160
|
+
toolTipTitle: i(H)(r.value) ?? "",
|
|
161
|
+
yFormatter: a.orientation === i(l).Horizontal ? a.xFormatter : a.yFormatter
|
|
184
162
|
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
185
|
-
]) :
|
|
163
|
+
]) : c("", !0)
|
|
186
164
|
], 512)
|
|
187
165
|
], 2));
|
|
188
166
|
}
|
|
189
167
|
});
|
|
190
168
|
export {
|
|
191
|
-
|
|
169
|
+
ae as default
|
|
192
170
|
};
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { BarChartProps } from './types';
|
|
2
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<{
|
|
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"> & BarChartProps<T> & Partial<{}>> & import('vue').PublicProps;
|
|
4
6
|
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
5
7
|
attrs: any;
|
|
6
8
|
slots: {
|
|
7
9
|
tooltip?(_: {
|
|
8
|
-
values:
|
|
10
|
+
values: any;
|
|
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
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ComputedRef } from 'vue';
|
|
2
|
+
export interface StackedGroupedConfig<T> {
|
|
3
|
+
data: T[];
|
|
4
|
+
categories: Record<string, {
|
|
5
|
+
color?: string;
|
|
6
|
+
}>;
|
|
7
|
+
stackAndGrouped: boolean;
|
|
8
|
+
xAxis?: keyof T;
|
|
9
|
+
}
|
|
10
|
+
export interface StackedGroupedResult<T> {
|
|
11
|
+
states: string[];
|
|
12
|
+
groupedByState: Record<string, string[]>;
|
|
13
|
+
colors: Record<string, string[]>;
|
|
14
|
+
bars: Record<string, ((d: any) => any)[]>;
|
|
15
|
+
colorFunctions: Record<string, (d: unknown, i: number) => string>;
|
|
16
|
+
positions: Record<string, number>;
|
|
17
|
+
chartData: T[] | any[];
|
|
18
|
+
}
|
|
19
|
+
export declare function useStackedGrouped<T extends {}>(config: StackedGroupedConfig<T>): ComputedRef<StackedGroupedResult<T>>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { computed as u } from "vue";
|
|
2
|
+
import { flattenData as i } from "../../utils.js";
|
|
3
|
+
function b(t) {
|
|
4
|
+
return u(() => {
|
|
5
|
+
const o = f(t.categories), e = l(t.categories, o), r = p(e, t.categories), c = d(e), n = m(r), s = h(o);
|
|
6
|
+
console.log(t, "config");
|
|
7
|
+
const a = t.stackAndGrouped ? i(t.data, t.xAxis) : t.data;
|
|
8
|
+
return {
|
|
9
|
+
states: o,
|
|
10
|
+
groupedByState: e,
|
|
11
|
+
colors: r,
|
|
12
|
+
bars: c,
|
|
13
|
+
colorFunctions: n,
|
|
14
|
+
positions: s,
|
|
15
|
+
chartData: a
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function f(t) {
|
|
20
|
+
const o = /* @__PURE__ */ new Set();
|
|
21
|
+
return Object.keys(t).forEach((r) => {
|
|
22
|
+
const c = r.match(/([A-Z][a-z]+)$/);
|
|
23
|
+
c && o.add(c[1]);
|
|
24
|
+
}), Array.from(o);
|
|
25
|
+
}
|
|
26
|
+
function l(t, o) {
|
|
27
|
+
const e = {};
|
|
28
|
+
return o.forEach((r) => {
|
|
29
|
+
e[r] = Object.keys(t).filter(
|
|
30
|
+
(c) => c.endsWith(r)
|
|
31
|
+
);
|
|
32
|
+
}), e;
|
|
33
|
+
}
|
|
34
|
+
function p(t, o) {
|
|
35
|
+
const e = {};
|
|
36
|
+
return Object.entries(t).forEach(([r, c]) => {
|
|
37
|
+
e[r] = c.map((n) => {
|
|
38
|
+
var s;
|
|
39
|
+
return ((s = o[n]) == null ? void 0 : s.color) ?? "#ccc";
|
|
40
|
+
});
|
|
41
|
+
}), e;
|
|
42
|
+
}
|
|
43
|
+
function d(t) {
|
|
44
|
+
const o = {};
|
|
45
|
+
return Object.entries(t).forEach(([e, r]) => {
|
|
46
|
+
o[e] = r.map((c) => {
|
|
47
|
+
const n = c.replace(e, "").toLowerCase();
|
|
48
|
+
return (s) => s[n + e];
|
|
49
|
+
});
|
|
50
|
+
}), o;
|
|
51
|
+
}
|
|
52
|
+
function m(t) {
|
|
53
|
+
const o = {};
|
|
54
|
+
return Object.entries(t).forEach(([e, r]) => {
|
|
55
|
+
o[e] = (c, n) => r[n] ?? "#ccc";
|
|
56
|
+
}), o;
|
|
57
|
+
}
|
|
58
|
+
function h(t) {
|
|
59
|
+
const o = t.length, e = 0.4, r = {};
|
|
60
|
+
return t.forEach((c, n) => {
|
|
61
|
+
const s = (n - (o - 1) / 2) * e;
|
|
62
|
+
r[c] = s;
|
|
63
|
+
}), r;
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
b as useStackedGrouped
|
|
67
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { BulletLegendItemInterface, Orientation
|
|
2
|
-
|
|
1
|
+
import { BulletLegendItemInterface, Orientation } from '@unovis/ts';
|
|
2
|
+
import { LegendPosition, axisFormatter } from '../../types';
|
|
3
|
+
type BarChartPropsBase<T> = {
|
|
3
4
|
/**
|
|
4
5
|
* The data to be displayed in the bar chart.
|
|
5
6
|
* Each element of the array represents a data point.
|
|
@@ -10,10 +11,6 @@ export interface BarChartProps<T> {
|
|
|
10
11
|
* If `true`, creates a stacked bar chart instead of grouped bars.
|
|
11
12
|
*/
|
|
12
13
|
stacked?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* If `true`, creates a combination of stacked and grouped bar charts.
|
|
15
|
-
*/
|
|
16
|
-
stackAndGrouped?: boolean;
|
|
17
14
|
/**
|
|
18
15
|
* The height of the chart in pixels.
|
|
19
16
|
*/
|
|
@@ -27,9 +24,9 @@ export interface BarChartProps<T> {
|
|
|
27
24
|
*/
|
|
28
25
|
yLabel?: string;
|
|
29
26
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
* Optional padding applied to the chart.
|
|
28
|
+
* Allows specifying individual padding values for the top, right, bottom, and left sides.
|
|
29
|
+
*/
|
|
33
30
|
padding?: {
|
|
34
31
|
top: number;
|
|
35
32
|
right: number;
|
|
@@ -42,19 +39,19 @@ export interface BarChartProps<T> {
|
|
|
42
39
|
*/
|
|
43
40
|
categories: Record<string, BulletLegendItemInterface>;
|
|
44
41
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
xFormatter?: axisFormatter
|
|
42
|
+
* @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.
|
|
43
|
+
* @param {number} i - The index of the tick in the `ticks` array.
|
|
44
|
+
* @param {(number[]|Date[])} ticks - An array of all tick values for the x-axis.
|
|
45
|
+
* @returns {string} The formatted string representation of the tick.
|
|
46
|
+
*/
|
|
47
|
+
xFormatter?: axisFormatter;
|
|
51
48
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
yFormatter?: axisFormatter
|
|
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
|
+
* @param {number} i - The index of the tick in the `ticks` array.
|
|
51
|
+
* @param {(number[]|Date[])} ticks - An array of all tick values for the y-axis.
|
|
52
|
+
* @returns {string} The formatted string representation of the tick.
|
|
53
|
+
*/
|
|
54
|
+
yFormatter?: axisFormatter;
|
|
58
55
|
/**
|
|
59
56
|
* The desired number of ticks on the y-axis.
|
|
60
57
|
*/
|
|
@@ -91,6 +88,10 @@ export interface BarChartProps<T> {
|
|
|
91
88
|
* If `true`, hides the chart legend.
|
|
92
89
|
*/
|
|
93
90
|
hideLegend?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* If `true`, hides the chart tooltip.
|
|
93
|
+
*/
|
|
94
|
+
hideTooltip?: boolean;
|
|
94
95
|
/**
|
|
95
96
|
* The orientation of the bars (vertical or horizontal).
|
|
96
97
|
* See `Orientation` for available options.
|
|
@@ -133,4 +134,22 @@ export interface BarChartProps<T> {
|
|
|
133
134
|
* If `true`, hide the y-axis.
|
|
134
135
|
*/
|
|
135
136
|
hideYAxis?: boolean;
|
|
136
|
-
}
|
|
137
|
+
};
|
|
138
|
+
type BarChartPropsStackAndGrouped<T> = BarChartPropsBase<T> & {
|
|
139
|
+
stackAndGrouped: true;
|
|
140
|
+
/**
|
|
141
|
+
* The key in the data object type 'T' to be used for the x-axis values.
|
|
142
|
+
* Required when stackAndGrouped is true.
|
|
143
|
+
*/
|
|
144
|
+
xAxis: keyof T;
|
|
145
|
+
};
|
|
146
|
+
type BarChartPropsNormal<T> = BarChartPropsBase<T> & {
|
|
147
|
+
stackAndGrouped?: false;
|
|
148
|
+
/**
|
|
149
|
+
* The key in the data object type 'T' to be used for the x-axis values.
|
|
150
|
+
* Optional when stackAndGrouped is not true.
|
|
151
|
+
*/
|
|
152
|
+
xAxis?: keyof T;
|
|
153
|
+
};
|
|
154
|
+
export type BarChartProps<T> = BarChartPropsStackAndGrouped<T> | BarChartPropsNormal<T>;
|
|
155
|
+
export {};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Donut as
|
|
3
|
-
import { DonutType as
|
|
4
|
-
import { VisSingleContainer as
|
|
5
|
-
const
|
|
1
|
+
import { defineComponent as V, useSlots as b, useTemplateRef as D, ref as S, createElementBlock as d, openBlock as c, Fragment as T, createElementVNode as o, createCommentVNode as p, createVNode as r, renderSlot as a, unref as l, withCtx as w, normalizeStyle as B, toDisplayString as L } from "vue";
|
|
2
|
+
import { Donut as $ } from "@unovis/ts";
|
|
3
|
+
import { DonutType as H } from "./types.js";
|
|
4
|
+
import { VisSingleContainer as N, VisTooltip as W, VisDonut as _, VisBulletLegend as j } from "@unovis/vue";
|
|
5
|
+
const z = {
|
|
6
6
|
ref: "slotWrapper",
|
|
7
7
|
class: "hidden"
|
|
8
|
-
},
|
|
8
|
+
}, A = { class: "flex items-center" }, E = {
|
|
9
9
|
key: 0,
|
|
10
10
|
class: "flex items-center justify-center mt-4"
|
|
11
|
-
}, q = /* @__PURE__ */
|
|
11
|
+
}, q = /* @__PURE__ */ V({
|
|
12
12
|
__name: "DonutChart",
|
|
13
13
|
props: {
|
|
14
14
|
type: {},
|
|
@@ -16,58 +16,64 @@ const N = { class: "flex items-center justify-center" }, W = {
|
|
|
16
16
|
height: {},
|
|
17
17
|
radius: {},
|
|
18
18
|
hideLegend: { type: Boolean },
|
|
19
|
-
labels: {}
|
|
19
|
+
labels: {},
|
|
20
|
+
padAngle: {}
|
|
20
21
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
emits: ["click"],
|
|
23
|
+
setup(f, { emit: m }) {
|
|
24
|
+
const g = m, n = f, h = b(), i = D("slotWrapper"), t = S(), v = (e) => e, y = n.type === H.Half;
|
|
25
|
+
function k(e) {
|
|
26
|
+
return t.value = e, C();
|
|
25
27
|
}
|
|
26
|
-
function
|
|
27
|
-
return typeof window > "u" ? "" :
|
|
28
|
+
function C(e) {
|
|
29
|
+
return typeof window > "u" ? "" : i.value ? i.value.innerHTML : "";
|
|
28
30
|
}
|
|
29
|
-
return (e,
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
return (e, u) => (c(), d(T, null, [
|
|
32
|
+
o("div", {
|
|
33
|
+
class: "flex items-center justify-center",
|
|
34
|
+
onClick: u[0] || (u[0] = (s) => g("click", s, t.value))
|
|
35
|
+
}, [
|
|
36
|
+
r(l(N), {
|
|
32
37
|
data: e.data,
|
|
33
38
|
height: e.height,
|
|
34
39
|
margin: {}
|
|
35
40
|
}, {
|
|
36
|
-
default:
|
|
37
|
-
r(
|
|
41
|
+
default: w(() => [
|
|
42
|
+
r(l(W), {
|
|
38
43
|
"horizontal-shift": 20,
|
|
39
44
|
"vertical-shift": 20,
|
|
40
45
|
triggers: {
|
|
41
|
-
[
|
|
46
|
+
[l($).selectors.segment]: k
|
|
42
47
|
}
|
|
43
48
|
}, null, 8, ["triggers"]),
|
|
44
|
-
r(
|
|
45
|
-
value:
|
|
49
|
+
r(l(_), {
|
|
50
|
+
value: v,
|
|
46
51
|
"corner-radius": e.radius,
|
|
47
|
-
color: n.labels.map((
|
|
48
|
-
"angle-range":
|
|
49
|
-
|
|
52
|
+
color: n.labels.map((s) => s.color),
|
|
53
|
+
"angle-range": y ? [-1.5707963267948966, 1.5707963267948966] : [],
|
|
54
|
+
"pad-angle": n.padAngle || 0
|
|
55
|
+
}, null, 8, ["corner-radius", "color", "angle-range", "pad-angle"])
|
|
50
56
|
]),
|
|
51
57
|
_: 1
|
|
52
58
|
}, 8, ["data", "height"]),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
a(e.$slots, "default"),
|
|
60
|
+
o("div", z, [
|
|
61
|
+
l(h).tooltip ? a(e.$slots, "tooltip", {
|
|
56
62
|
key: 0,
|
|
57
|
-
values:
|
|
58
|
-
}) :
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
values: t.value
|
|
64
|
+
}) : t.value ? a(e.$slots, "fallback", { key: 1 }, () => [
|
|
65
|
+
o("div", A, [
|
|
66
|
+
o("div", {
|
|
61
67
|
class: "w-2 h-2 rounded-full mr-2",
|
|
62
|
-
style:
|
|
68
|
+
style: B(`background-color: ${n.labels[t.value.index].color} ;`)
|
|
63
69
|
}, null, 4),
|
|
64
|
-
|
|
70
|
+
o("div", null, L(t.value.data), 1)
|
|
65
71
|
])
|
|
66
|
-
]) :
|
|
72
|
+
]) : p("", !0)
|
|
67
73
|
], 512)
|
|
68
74
|
]),
|
|
69
|
-
e.hideLegend ?
|
|
70
|
-
r(
|
|
75
|
+
e.hideLegend ? p("", !0) : (c(), d("div", E, [
|
|
76
|
+
r(l(j), { items: e.labels }, null, 8, ["items"])
|
|
71
77
|
]))
|
|
72
78
|
], 64));
|
|
73
79
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { DonutChartProps } from './types';
|
|
2
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<{
|
|
3
|
+
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
4
|
+
readonly onClick?: ((event: MouseEvent, values?: any) => any) | undefined;
|
|
5
|
+
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onClick"> & DonutChartProps & Partial<{}>> & import('vue').PublicProps;
|
|
4
6
|
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
5
7
|
attrs: any;
|
|
6
8
|
slots: {
|
|
@@ -10,7 +12,7 @@ declare const _default: <T extends {}>(__VLS_props: NonNullable<Awaited<typeof _
|
|
|
10
12
|
}): any;
|
|
11
13
|
fallback?(_: {}): any;
|
|
12
14
|
};
|
|
13
|
-
emit:
|
|
15
|
+
emit: (e: "click", event: MouseEvent, values?: any) => void;
|
|
14
16
|
}>) => import('vue').VNode & {
|
|
15
17
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
16
18
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export type DonutChartProps = {
|
|
2
2
|
/**
|
|
3
3
|
* The type of donut chart to render.
|
|
4
4
|
* See `DonutType` for available options.
|
|
@@ -28,9 +28,13 @@ interface DonutChartProps {
|
|
|
28
28
|
name: string;
|
|
29
29
|
color: string;
|
|
30
30
|
}[];
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Pad angle. Default: 0
|
|
33
|
+
*/
|
|
34
|
+
padAngle?: number;
|
|
35
|
+
};
|
|
32
36
|
declare enum DonutType {
|
|
33
37
|
Half = "half",
|
|
34
38
|
Full = "full"
|
|
35
39
|
}
|
|
36
|
-
export {
|
|
40
|
+
export { DonutType };
|