vue-chrts 0.2.0-test.4 → 0.2.0-test.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,18 +1,18 @@
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 = {
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
- }, re = /* @__PURE__ */ M({
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
- setup(t) {
49
- const o = t, A = E(), f = $("slotWrapper"), p = S();
50
- if (!o.yAxis || o.yAxis.length === 0)
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 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
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 T(e) {
59
- return p.value = e, O();
67
+ function b(e) {
68
+ return r.value = e, G();
60
69
  }
61
- function O(e) {
62
- return typeof window > "u" ? "" : f.value ? f.value.innerHTML : "";
70
+ function G(e) {
71
+ return typeof window > "u" ? "" : y.value ? y.value.innerHTML : "";
63
72
  }
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 }])
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
- u(a(q), {
77
+ g(i(X), {
89
78
  padding: e.padding,
90
79
  height: e.height
91
80
  }, {
92
- default: H(() => [
93
- u(a(U), {
81
+ default: E(() => [
82
+ g(i(Y), {
94
83
  triggers: {
95
- [a(Y).selectors.bar]: T,
96
- [a(X).selectors.bar]: T
84
+ [i(z).selectors.bar]: b,
85
+ [i(j).selectors.bar]: b
97
86
  }
98
87
  }, null, 8, ["triggers"]),
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), {
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: (r, i) => i,
124
- y: b.value,
125
- color: h,
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 ?? a(l).Vertical
130
- }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (d(), m(a(I), {
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: (r, i) => i,
134
- y: b.value,
135
- color: h,
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 ?? a(l).Vertical
117
+ orientation: e.orientation ?? i(l).Vertical
140
118
  }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])),
141
- e.hideXAxis ? g("", !0) : (d(), m(a(V), {
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 ? g("", !0) : (d(), m(a(V), {
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 !== a(l).Horizontal && e.yGridLine,
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 ? g("", !0) : (d(), y("div", {
144
+ e.hideLegend ? c("", !0) : (n(), m("div", {
167
145
  key: 0,
168
- class: B(["flex items center justify-end", { "pb-4": v.value }])
146
+ class: L(["flex items center justify-end", { "pb-4": h.value }])
169
147
  }, [
170
- u(a(J), {
171
- items: Object.values(o.categories)
148
+ g(i(R), {
149
+ items: Object.values(a.categories)
172
150
  }, null, 8, ["items"])
173
151
  ], 2)),
174
- z("div", Z, [
175
- a(A).tooltip ? P(e.$slots, "tooltip", {
152
+ w("div", I, [
153
+ i(P).tooltip ? v(e.$slots, "tooltip", {
176
154
  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
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
- ]) : g("", !0)
163
+ ]) : c("", !0)
186
164
  ], 512)
187
165
  ], 2));
188
166
  }
189
167
  });
190
168
  export {
191
- re as default
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<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & BarChartProps<T> & Partial<{}>> & import('vue').PublicProps;
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: T | undefined;
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, LegendPosition, axisFormatter } from '../../types';
2
- export interface BarChartProps<T> {
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
- * Optional padding applied to the chart.
31
- * Allows specifying individual padding values for the top, right, bottom, and left sides.
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
- * @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.
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 x-axis.
48
- * @returns {string} The formatted string representation of the tick.
49
- */
50
- xFormatter?: axisFormatter<T>;
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
- * @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.
53
- * @param {number} i - The index of the tick in the `ticks` array.
54
- * @param {(number[]|Date[])} ticks - An array of all tick values for the y-axis.
55
- * @returns {string} The formatted string representation of the tick.
56
- */
57
- yFormatter?: axisFormatter<T>;
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 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 = {
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
- }, j = { class: "flex items-center" }, z = {
8
+ }, A = { class: "flex items-center" }, E = {
9
9
  key: 0,
10
10
  class: "flex items-center justify-center mt-4"
11
- }, q = /* @__PURE__ */ y({
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
- 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();
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 g(e) {
27
- return typeof window > "u" ? "" : a.value ? a.value.innerHTML : "";
28
+ function C(e) {
29
+ return typeof window > "u" ? "" : i.value ? i.value.innerHTML : "";
28
30
  }
29
- return (e, E) => (u(), i(_, null, [
30
- l("div", N, [
31
- r(t(B), {
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: b(() => [
37
- r(t(L), {
41
+ default: w(() => [
42
+ r(l(W), {
38
43
  "horizontal-shift": 20,
39
44
  "vertical-shift": 20,
40
45
  triggers: {
41
- [t(T).selectors.segment]: h
46
+ [l($).selectors.segment]: k
42
47
  }
43
48
  }, null, 8, ["triggers"]),
44
- r(t($), {
45
- value: p,
49
+ r(l(_), {
50
+ value: v,
46
51
  "corner-radius": e.radius,
47
- color: n.labels.map((v) => v.color),
48
- "angle-range": m ? [-1.5707963267948966, 1.5707963267948966] : []
49
- }, null, 8, ["corner-radius", "color", "angle-range"])
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
- s(e.$slots, "default"),
54
- l("div", W, [
55
- t(f).tooltip ? s(e.$slots, "tooltip", {
59
+ a(e.$slots, "default"),
60
+ o("div", z, [
61
+ l(h).tooltip ? a(e.$slots, "tooltip", {
56
62
  key: 0,
57
- values: o.value
58
- }) : o.value ? s(e.$slots, "fallback", { key: 1 }, () => [
59
- l("div", j, [
60
- l("div", {
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: D(`background-color: ${n.labels[o.value.index].color} ;`)
68
+ style: B(`background-color: ${n.labels[t.value.index].color} ;`)
63
69
  }, null, 4),
64
- l("div", null, S(o.value.data), 1)
70
+ o("div", null, L(t.value.data), 1)
65
71
  ])
66
- ]) : d("", !0)
72
+ ]) : p("", !0)
67
73
  ], 512)
68
74
  ]),
69
- e.hideLegend ? d("", !0) : (u(), i("div", z, [
70
- r(t(H), { items: e.labels }, null, 8, ["items"])
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<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & DonutChartProps & Partial<{}>> & import('vue').PublicProps;
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
- interface DonutChartProps {
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 { type DonutChartProps, DonutType };
40
+ export { DonutType };