vue-chrts 0.1.11 → 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.
@@ -1,30 +1,28 @@
1
- import { defineComponent as O, computed as g, createApp as $, createElementBlock as c, openBlock as o, normalizeClass as T, createVNode as p, createCommentVNode as s, unref as i, withCtx as E, createBlock as d, Fragment as h, renderList as G, mergeProps as N } from "vue";
2
- import { Position as v, CurveType as L } from "@unovis/ts";
3
- import { VisXYContainer as P, VisTooltip as j, VisArea as I, VisLine as M, VisAxis as b, VisCrosshair as S, VisBulletLegend as U } from "@unovis/vue";
4
- import X from "../Tooltip.js";
5
- import { LegendPosition as Y } from "../../types.js";
6
- import { getFirstPropertyValue as w } from "../../utils.js";
7
- const m = 24, B = 4, z = 0.5, C = "#3b82f6", Z = /* @__PURE__ */ O({
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 / B : n.data.length - 1 },
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 / B : n.data.length - 1 },
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 a = n, u = Object.values(a.categories).map((e) => e.color), A = g(() => (e) => {
42
- if (typeof window > "u" || typeof document > "u")
43
- return "";
44
- try {
45
- const t = $(X, {
46
- data: e,
47
- categories: a.categories,
48
- toolTipTitle: w(e),
49
- yFormatter: a.yFormatter
50
- }), r = document.createElement("div");
51
- t.mount(r);
52
- const l = r.innerHTML;
53
- return t.unmount(), l;
54
- } catch {
55
- return "";
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 F(e) {
59
- var t;
57
+ function G(e) {
58
+ var p;
60
59
  return {
61
- y: (r) => Number(r[e]),
62
- color: ((t = a.categories[e]) == null ? void 0 : t.color) ?? C
60
+ y: (t) => Number(t[e]),
61
+ color: ((p = l.categories[e]) == null ? void 0 : p.color) ?? F
63
62
  };
64
63
  }
65
- function V(e, t) {
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 x(e, t) {
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
- const D = g(
82
- () => u.map(
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
- p(i(P), {
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: E(() => [
98
- e.hideTooltip ? s("", !0) : (o(), d(i(j), {
79
+ default: M(() => [
80
+ e.hideTooltip ? r("", !0) : (a(), u(i(z), {
99
81
  key: 0,
100
- "horizontal-placement": i(v).Right,
101
- "vertical-placement": i(v).Top
82
+ "horizontal-placement": i(C).Right,
83
+ "vertical-placement": i(C).Top
102
84
  }, null, 8, ["horizontal-placement", "vertical-placement"])),
103
- (o(!0), c(h, null, G(Object.keys(a.categories), (r, l) => (o(), c(h, { key: l }, [
104
- p(i(I), N({
105
- x: (y, f) => f,
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
- }, F(r), {
108
- color: `url(#gradient${l}-${i(u)[l]})`,
109
- opacity: z,
110
- "curve-type": e.curveType ?? i(L).MonotoneX
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
- p(i(M), {
113
- x: (y, f) => f,
114
- y: (y) => y[r],
115
- color: i(u)[l],
116
- "curve-type": e.curveType ?? i(L).MonotoneX
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 ? s("", !0) : (o(), d(i(b), {
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-line": e.xTickLine,
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, ["tick-format", "label", "domain-line", "grid-line", "num-ticks", "tick-line", "tick-values", "min-max-ticks-only"])),
132
- e.hideYAxis ? s("", !0) : (o(), d(i(b), {
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", "label", "grid-line", "domain-line", "tick-line"])),
142
- e.hideTooltip ? s("", !0) : (o(), d(i(S), {
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: A.value
146
- }, null, 8, ["template"]))
127
+ template: N
128
+ }))
147
129
  ]),
148
130
  _: 1
149
131
  }, 8, ["data", "height", "padding", "svg-defs"]),
150
- e.hideLegend ? s("", !0) : (o(), c("div", {
132
+ e.hideLegend ? r("", !0) : (a(), d("div", {
151
133
  key: 0,
152
- class: T(["flex items-center justify-end", { "pb-4": k.value }])
134
+ class: h(["flex items-center justify-end", { "pb-4": T.value }])
153
135
  }, [
154
- p(i(U), {
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
- Z as default
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
- * @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?: ((tick: number, i: number, ticks: number[]) => string) | ((tick: Date, i: number, ticks: Date[]) => string);
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?: ((tick: number, i: number, ticks: number[]) => string) | ((tick: Date, i: number, ticks: Date[]) => string);
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 v, computed as c, createApp as V, createElementBlock as f, openBlock as l, normalizeClass as b, createVNode as r, createCommentVNode as x, unref as i, withCtx as P, createBlock as h } from "vue";
2
- import { Orientation as s, StackedBar as A, GroupedBar as O } from "@unovis/ts";
3
- import { VisXYContainer as C, VisTooltip as F, VisGroupedBar as G, VisStackedBar as N, VisAxis as L, VisBulletLegend as j } from "@unovis/vue";
4
- import w from "../Tooltip.js";
5
- import { LegendPosition as E } from "../../types.js";
6
- const S = /* @__PURE__ */ v({
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,84 +24,76 @@ const S = /* @__PURE__ */ v({
20
24
  categories: {},
21
25
  xFormatter: {},
22
26
  yFormatter: {},
23
- yNumTicks: { default: (a) => a.data.length > 24 ? 24 / 4 : a.data.length - 1 },
27
+ yNumTicks: { default: (n) => n.data.length > 24 ? 24 / 4 : n.data.length - 1 },
24
28
  minMaxTicksOnly: { type: Boolean },
25
- xNumTicks: { default: (a) => a.data.length > 24 ? 24 / 4 : a.data.length - 1 },
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: s.Vertical },
36
+ orientation: { default: r.Vertical },
33
37
  legendPosition: {},
34
38
  xDomainLine: { type: Boolean },
35
39
  yDomainLine: { type: Boolean },
36
40
  xTickLine: { type: Boolean },
37
41
  yTickLine: { type: Boolean },
38
42
  xGridLine: { type: Boolean },
39
- yGridLine: { type: Boolean, default: !0 }
43
+ yGridLine: { type: Boolean, default: !0 },
44
+ hideXAxis: { type: Boolean },
45
+ hideYAxis: { type: Boolean }
40
46
  },
41
- setup(a) {
42
- const n = a;
43
- if (!n.yAxis || n.yAxis.length === 0)
47
+ setup(n) {
48
+ const a = n, v = P(), m = x("slotWrapper"), t = F();
49
+ if (!a.yAxis || a.yAxis.length === 0)
44
50
  throw new Error("yAxis is required");
45
- const m = c(() => n.yAxis.map((e) => (t) => t[e])), p = (e, t) => Object.values(n.categories)[t].color, g = c(
46
- () => n.legendPosition === E.Top
47
- ), y = c(() => (e, t) => {
48
- if (typeof window > "u" || typeof document > "u")
49
- return "";
50
- const u = Object.keys(n.categories), T = Object.keys(e).find((o) => !u.includes(o));
51
- try {
52
- const o = V(w, {
53
- data: e,
54
- categories: n.categories,
55
- toolTipTitle: e[T],
56
- yFormatter: n.yFormatter
57
- }), k = document.createElement("div");
58
- o.mount(k);
59
- const B = k.innerHTML;
60
- return o.unmount(), B;
61
- } catch {
62
- return "";
63
- }
64
- });
65
- return (e, t) => (l(), f("div", {
66
- class: b(["flex flex-col space-y-4", { "flex-col-reverse": g.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 }])
67
62
  }, [
68
- r(i(C), {
63
+ d(i(E), {
69
64
  padding: e.padding,
70
65
  height: e.height
71
66
  }, {
72
- default: P(() => [
73
- r(i(F), {
67
+ default: N(() => [
68
+ d(i(M), {
74
69
  triggers: {
75
- [i(O).selectors.bar]: y.value,
76
- [i(A).selectors.bar]: y.value
70
+ [i(G).selectors.bar]: k,
71
+ [i(O).selectors.bar]: k
77
72
  }
78
73
  }, null, 8, ["triggers"]),
79
- e.stacked ? (l(), h(i(N), {
74
+ e.stacked ? (o(), u(i(S), {
80
75
  key: 1,
81
76
  data: e.data,
82
- x: (u, d) => d,
83
- y: m.value,
84
- color: p,
77
+ x: (V, p) => p,
78
+ y: g.value,
79
+ color: y,
85
80
  "rounded-corners": e.radius ?? 0,
86
81
  "group-padding": e.groupPadding ?? 0,
87
82
  "bar-padding": e.barPadding ?? 0.2,
88
- orientation: e.orientation ?? i(s).Vertical
89
- }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (l(), h(i(G), {
83
+ orientation: e.orientation ?? i(r).Vertical
84
+ }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (o(), u(i(D), {
90
85
  key: 0,
91
86
  data: e.data,
92
- x: (u, d) => d,
93
- y: m.value,
94
- color: p,
87
+ x: (V, p) => p,
88
+ y: g.value,
89
+ color: y,
95
90
  "rounded-corners": e.radius ?? 0,
96
91
  "group-padding": e.groupPadding ?? 0,
97
92
  "bar-padding": e.barPadding ?? 0.2,
98
- orientation: e.orientation ?? i(s).Vertical
93
+ orientation: e.orientation ?? i(r).Vertical
99
94
  }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])),
100
- r(i(L), {
95
+ e.hideXAxis ? s("", !0) : (o(), u(i(L), {
96
+ key: 2,
101
97
  type: "x",
102
98
  "tick-format": e.xFormatter,
103
99
  label: e.xLabel,
@@ -106,31 +102,45 @@ const S = /* @__PURE__ */ v({
106
102
  "tick-line": e.xTickLine,
107
103
  "num-ticks": e.xNumTicks,
108
104
  "tick-values": e.xExplicitTicks,
109
- "min-max-ticks-only": e.minMaxTicksOnly
110
- }, null, 8, ["tick-format", "label", "grid-line", "domain-line", "tick-line", "num-ticks", "tick-values", "min-max-ticks-only"]),
111
- r(i(L), {
105
+ minMaxTicksOnly: e.minMaxTicksOnly
106
+ }, null, 8, ["tick-format", "label", "grid-line", "domain-line", "tick-line", "num-ticks", "tick-values", "minMaxTicksOnly"])),
107
+ e.hideYAxis ? s("", !0) : (o(), u(i(L), {
108
+ key: 3,
112
109
  type: "y",
113
110
  label: e.yLabel,
114
- "grid-line": e.orientation !== i(s).Horizontal && e.yGridLine,
111
+ "grid-line": e.orientation !== i(r).Horizontal && e.yGridLine,
115
112
  "domain-line": !!e.yDomainLine,
116
113
  "tick-format": e.yFormatter,
117
114
  "num-ticks": e.yNumTicks,
118
115
  "tick-line": e.yTickLine
119
- }, null, 8, ["label", "grid-line", "domain-line", "tick-format", "num-ticks", "tick-line"])
116
+ }, null, 8, ["label", "grid-line", "domain-line", "tick-format", "num-ticks", "tick-line"]))
120
117
  ]),
121
118
  _: 1
122
119
  }, 8, ["padding", "height"]),
123
- e.hideLegend ? x("", !0) : (l(), f("div", {
120
+ e.hideLegend ? s("", !0) : (o(), h("div", {
124
121
  key: 0,
125
- class: b(["flex items center justify-end", { "pb-4": g.value }])
122
+ class: T(["flex items center justify-end", { "pb-4": c.value }])
126
123
  }, [
127
- r(i(j), {
124
+ d(i(j), {
128
125
  items: Object.values(e.categories)
129
126
  }, null, 8, ["items"])
130
- ], 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)
131
141
  ], 2));
132
142
  }
133
143
  });
134
144
  export {
135
- S as default
145
+ I as default
136
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?: ((tick: number, i: number, ticks: number[]) => string) | ((tick: Date, i: number, ticks: Date[]) => string);
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?: ((tick: number, i: number, ticks: number[]) => string) | ((tick: Date, i: number, ticks: Date[]) => string);
53
+ yFormatter?: axisFormatter<T>;
54
54
  /**
55
55
  * The desired number of ticks on the y-axis.
56
56
  */
@@ -121,4 +121,12 @@ export interface BarChartProps<T> {
121
121
  * If `true`, displays grid lines along the y-axis.
122
122
  */
123
123
  yGridLine?: boolean;
124
+ /**
125
+ * If `true`, hide the x-axis.
126
+ */
127
+ hideXAxis?: boolean;
128
+ /**
129
+ * If `true`, hide the y-axis.
130
+ */
131
+ hideYAxis?: boolean;
124
132
  }
@@ -1,11 +1,14 @@
1
- import { defineComponent as u, createElementBlock as n, openBlock as i, Fragment as m, createElementVNode as f, createCommentVNode as p, createVNode as t, renderSlot as g, unref as o, withCtx as h } from "vue";
2
- import { Donut as v } from "@unovis/ts";
3
- import { VisSingleContainer as y, VisTooltip as V, VisDonut as b, VisBulletLegend as C } from "@unovis/vue";
4
- import { DonutType as _ } from "./types.js";
5
- const k = { class: "flex items-center justify-center" }, B = {
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
- }, w = /* @__PURE__ */ u({
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(l) {
19
- const r = l, s = (e) => e, a = r.type === _.Half, d = {
20
- [v.selectors.segment]: (e) => `<div class='flex items-center'><div class='w-2 h-2 rounded-full mr-2' style='background-color: ${r.labels[e.index].color} ;'></div>
21
- <div>${e.data}</div>
22
- </vistooltip>
23
- </vissinglecontainer>
24
- </div>`
25
- };
26
- return (e, D) => (i(), n(m, null, [
27
- f("div", k, [
28
- t(o(y), {
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: h(() => [
34
- t(o(V), {
36
+ default: b(() => [
37
+ r(t(L), {
35
38
  "horizontal-shift": 20,
36
39
  "vertical-shift": 20,
37
- triggers: d
38
- }),
39
- t(o(b), {
40
- value: s,
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: r.labels.map((c) => c.color),
43
- "angle-range": a ? [-1.5707963267948966, 1.5707963267948966] : []
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
- g(e.$slots, "default")
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 ? p("", !0) : (i(), n("div", B, [
51
- t(o(C), { items: e.labels }, null, 8, ["items"])
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
- w as default
76
+ q as default
58
77
  };
@@ -1,18 +1,20 @@
1
1
  import { DonutChartProps } from './types';
2
- declare function __VLS_template(): {
3
- attrs: Partial<{}>;
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
- refs: {};
8
- rootEl: any;
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 __VLS_WithTemplateSlots<T, S> = T & {
15
- new (): {
16
- $slots: S;
17
- };
18
- };
18
+ type __VLS_PrettifyLocal<T> = {
19
+ [K in keyof T]: T[K];
20
+ } & {};
@@ -1,10 +1,13 @@
1
- import { defineComponent as b, computed as p, createApp as B, createElementBlock as s, openBlock as l, normalizeClass as u, createVNode as r, createCommentVNode as y, unref as i, withCtx as x, createBlock as g, Fragment as C, renderList as V } from "vue";
2
- import { Position as k, CurveType as F } from "@unovis/ts";
3
- import { VisXYContainer as N, VisTooltip as O, VisLine as P, VisAxis as f, VisCrosshair as j, VisBulletLegend as D } from "@unovis/vue";
4
- import E from "../Tooltip.js";
5
- import { LegendPosition as G } from "../../types.js";
6
- import { getFirstPropertyValue as M } from "../../utils.js";
7
- const R = /* @__PURE__ */ b({
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: {},
@@ -33,49 +36,45 @@ const R = /* @__PURE__ */ b({
33
36
  yGridLine: { type: Boolean },
34
37
  yDomainLine: { type: Boolean },
35
38
  xTickLine: { type: Boolean },
36
- yTickLine: { type: Boolean }
39
+ yTickLine: { type: Boolean },
40
+ hideXAxis: { type: Boolean },
41
+ hideYAxis: { type: Boolean }
37
42
  },
38
43
  setup(t) {
39
- const n = t, h = Object.values(n.categories).map((e, c) => `var(--vis-color${c})`), L = (e) => Object.values(n.categories)[e].color ?? h[e], T = p(() => (e, c) => {
40
- if (typeof window > "u" || typeof document > "u")
41
- return "";
42
- try {
43
- const o = B(E, {
44
- data: e,
45
- categories: n.categories,
46
- toolTipTitle: M(e),
47
- yFormatter: n.yFormatter
48
- }), a = document.createElement("div");
49
- o.mount(a);
50
- const m = a.innerHTML;
51
- return o.unmount(), m;
52
- } catch {
53
- return "";
54
- }
55
- }), d = p(
56
- () => n.legendPosition === G.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
57
55
  );
58
- return (e, c) => (l(), s("div", {
59
- class: u(["flex flex-col space-y-4", { "flex-col-reverse": d.value }])
56
+ return (e, c) => (o(), d("div", {
57
+ class: k(["flex flex-col space-y-4", { "flex-col-reverse": m.value }])
60
58
  }, [
61
- r(i(N), {
59
+ r(i($), {
62
60
  data: e.data,
63
61
  padding: e.padding,
64
62
  height: e.height
65
63
  }, {
66
- default: x(() => [
67
- r(i(O), {
68
- "horizontal-placement": i(k).Right,
69
- "vertical-placement": i(k).Top
64
+ default: j(() => [
65
+ r(i(w), {
66
+ "horizontal-placement": i(g).Right,
67
+ "vertical-placement": i(g).Top
70
68
  }, null, 8, ["horizontal-placement", "vertical-placement"]),
71
- (l(!0), s(C, null, V(Object.keys(n.categories), (o, a) => (l(), g(i(P), {
72
- key: a,
73
- x: (m, v) => v,
74
- y: (m) => m[o],
75
- color: L(a),
76
- "curve-type": e.curveType ?? i(F).MonotoneX
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
77
75
  }, null, 8, ["x", "y", "color", "curve-type"]))), 128)),
78
- r(i(f), {
76
+ e.hideXAxis ? a("", !0) : (o(), s(i(h), {
77
+ key: 0,
79
78
  type: "x",
80
79
  "tick-format": e.xFormatter,
81
80
  label: e.xLabel,
@@ -85,9 +84,10 @@ const R = /* @__PURE__ */ b({
85
84
  "tick-line": e.xTickLine,
86
85
  "num-ticks": e.xNumTicks,
87
86
  "tick-values": e.xExplicitTicks,
88
- "min-max-ticks-only": e.minMaxTicksOnly
89
- }, null, 8, ["tick-format", "label", "domain-line", "grid-line", "tick-line", "num-ticks", "tick-values", "min-max-ticks-only"]),
90
- r(i(f), {
87
+ minMaxTicksOnly: e.minMaxTicksOnly
88
+ }, null, 8, ["tick-format", "label", "domain-line", "grid-line", "tick-line", "num-ticks", "tick-values", "minMaxTicksOnly"])),
89
+ e.hideYAxis ? a("", !0) : (o(), s(i(h), {
90
+ key: 1,
91
91
  type: "y",
92
92
  "tick-format": e.yFormatter,
93
93
  label: e.yLabel,
@@ -95,26 +95,39 @@ const R = /* @__PURE__ */ b({
95
95
  "domain-line": e.yDomainLine,
96
96
  "grid-line": e.yGridLine,
97
97
  "tick-line": e.yTickLine
98
- }, null, 8, ["tick-format", "label", "num-ticks", "domain-line", "grid-line", "tick-line"]),
99
- e.hideTooltip ? y("", !0) : (l(), g(i(j), {
100
- key: 0,
98
+ }, null, 8, ["tick-format", "label", "num-ticks", "domain-line", "grid-line", "tick-line"])),
99
+ e.hideTooltip ? a("", !0) : (o(), s(i(R), {
100
+ key: 2,
101
101
  color: "#666",
102
- template: T.value
103
- }, null, 8, ["template"]))
102
+ template: b
103
+ }))
104
104
  ]),
105
105
  _: 1
106
106
  }, 8, ["data", "padding", "height"]),
107
- e.hideLegend ? y("", !0) : (l(), s("div", {
107
+ e.hideLegend ? a("", !0) : (o(), d("div", {
108
108
  key: 0,
109
- class: u(["flex items center justify-end", { "pb-4": d.value }])
109
+ class: k(["flex items center justify-end", { "pb-4": m.value }])
110
110
  }, [
111
- r(i(D), {
111
+ r(i(W), {
112
112
  items: Object.values(e.categories)
113
113
  }, null, 8, ["items"])
114
- ], 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)
115
128
  ], 2));
116
129
  }
117
130
  });
118
131
  export {
119
- R as default
132
+ Z as default
120
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
- * Optional padding applied to the chart.
23
- * Allows specifying individual padding values for the top, right, bottom, and left sides.
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
- * @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?: ((tick: number, i: number, ticks: number[]) => string) | ((tick: Date, i: number, ticks: Date[]) => string);
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
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?: ((tick: number, i: number, ticks: number[]) => string) | ((tick: Date, i: number, ticks: Date[]) => string);
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.
@@ -105,4 +105,12 @@ export interface LineChartProps<T> {
105
105
  * If `true`, displays tick lines on the y-axis.
106
106
  */
107
107
  yTickLine?: boolean;
108
+ /**
109
+ * If `true`, hide the x-axis.
110
+ */
111
+ hideXAxis?: boolean;
112
+ /**
113
+ * If `true`, hide the y-axis.
114
+ */
115
+ hideYAxis?: boolean;
108
116
  }
@@ -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 y, renderList as h, normalizeStyle as n } from "vue";
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
- }, F = /* @__PURE__ */ b({
8
+ }, T = /* @__PURE__ */ b({
9
9
  __name: "Tooltip",
10
10
  props: {
11
11
  data: {},
12
12
  categories: {},
13
13
  toolTipTitle: {},
14
- yFormatter: { type: Function }
14
+ yFormatter: {}
15
15
  },
16
16
  setup(p) {
17
- const a = p, d = ["_index", "_stacked", "_ending"], m = v(() => Object.entries(a.data ?? []).filter(
18
- ([e, g]) => !d.includes(e) && Object.keys(a.categories).includes(e)
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(y, null, h(m.value, ([t, s], u) => {
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: n([{ width: "8px", height: "8px", "border-radius": "4px", "margin-right": "8px" }, {
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: n([{ "font-weight": "600", "margin-right": "8px" }, { color: "var(--tooltip-label-color)" }])
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: n([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
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
- F as default
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?: (value: T) => any;
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.1.11",
3
+ "version": "0.1.12-custom-tooltips.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"