vue-chrts 1.0.2 → 2.0.0-beta.2

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,17 +1,18 @@
1
- import { defineComponent as T, useSlots as B, useTemplateRef as P, ref as W, computed as c, createElementBlock as f, openBlock as m, normalizeStyle as s, createVNode as a, createCommentVNode as v, createElementVNode as i, unref as l, withCtx as _, renderSlot as p, toDisplayString as b } from "vue";
2
- import { Donut as R } from "@unovis/ts";
3
- import { DonutType as z } from "./types.js";
4
- import { VisSingleContainer as H, VisTooltip as N, VisDonut as $, VisBulletLegend as j } from "@unovis/vue";
5
- import { LegendPosition as E } from "../../types.js";
6
- const M = { style: {
1
+ import { defineComponent as B, useSlots as D, useTemplateRef as P, ref as W, computed as s, createElementBlock as p, openBlock as m, normalizeStyle as d, createVNode as a, createCommentVNode as v, createElementVNode as y, unref as r, withCtx as b, renderSlot as u } from "vue";
2
+ import { Donut as N } from "@unovis/ts";
3
+ import { DonutType as $ } from "./types.js";
4
+ import j from "../Tooltip.js";
5
+ import { VisSingleContainer as z, VisTooltip as H, VisDonut as E, VisBulletLegend as F } from "@unovis/vue";
6
+ import { LegendPosition as O } from "../../types.js";
7
+ const R = { style: {
7
8
  position: "absolute",
8
9
  top: "50%",
9
10
  left: "50%",
10
11
  transform: "translate(-50%, -50%)"
11
- } }, O = {
12
+ } }, M = {
12
13
  ref: "slotWrapper",
13
14
  style: { display: "none" }
14
- }, U = { style: { display: "flex", "align-items": "center", padding: "10px 15px" } }, K = /* @__PURE__ */ T({
15
+ }, K = /* @__PURE__ */ B({
15
16
  __name: "DonutChart",
16
17
  props: {
17
18
  type: {},
@@ -20,99 +21,94 @@ const M = { style: {
20
21
  height: {},
21
22
  radius: {},
22
23
  hideLegend: { type: Boolean },
23
- legendPosition: { default: E.BottomCenter },
24
+ legendPosition: { default: O.BottomCenter },
24
25
  legendStyle: {},
25
26
  categories: {},
26
- padAngle: {}
27
+ padAngle: {},
28
+ tooltipTitleFormatter: {}
27
29
  },
28
30
  emits: ["click"],
29
- setup(y, { emit: h }) {
30
- const C = h, n = y, k = B(), g = P("slotWrapper"), r = W(), V = (e) => e, x = n.type === z.Half;
31
- function S(e) {
32
- return r.value = e, w();
31
+ setup(l, { emit: h }) {
32
+ const C = h, t = l, k = D(), c = P("slotWrapper"), i = W(), T = (e) => e, V = t.type === $.Half;
33
+ function x(e) {
34
+ const o = Object.values(t.categories)[e.index].name;
35
+ return i.value = {
36
+ label: o,
37
+ [o]: e.data
38
+ }, A();
33
39
  }
34
- function w(e) {
35
- return typeof window > "u" ? "" : g.value ? g.value.innerHTML : "";
40
+ function A() {
41
+ return typeof window > "u" ? "" : c.value ? c.value.innerHTML : "";
36
42
  }
37
- const A = c(() => n.legendPosition.includes("top")), D = c(() => n.legendPosition.includes("left") ? "flex-start" : n.legendPosition.includes("right") ? "flex-end" : "center"), d = (e, o = "#ccc") => e ? Array.isArray(e) ? e[0] || o : e : o, u = c(() => Object.values(n.categories)), L = (e, o) => {
38
- const t = u.value[o];
39
- if (t)
40
- return d(t.color);
43
+ const L = s(() => t.legendPosition.includes("top")), S = s(() => t.legendPosition.includes("left") ? "flex-start" : t.legendPosition.includes("right") ? "flex-end" : "center"), g = (e, o = "#ccc") => e ? Array.isArray(e) ? e[0] || o : e : o, f = s(() => Object.values(t.categories)), w = (e, o) => {
44
+ const n = f.value[o];
45
+ if (n)
46
+ return g(n.color);
41
47
  };
42
- return (e, o) => (m(), f("div", {
43
- style: s({
48
+ return (e, o) => (m(), p("div", {
49
+ style: d({
44
50
  display: "flex",
45
- flexDirection: A.value ? "column-reverse" : "column",
51
+ flexDirection: L.value ? "column-reverse" : "column",
46
52
  gap: "var(--vis-legend-spacing)"
47
53
  }),
48
- onClick: o[0] || (o[0] = (t) => C("click", t, r.value))
54
+ onClick: o[0] || (o[0] = (n) => C("click", n, i.value))
49
55
  }, [
50
- a(l(H), {
51
- data: e.data,
52
- height: e.height,
56
+ a(r(z), {
57
+ data: l.data,
58
+ height: l.height,
53
59
  margin: {}
54
60
  }, {
55
- default: _(() => [
56
- a(l(N), {
61
+ default: b(() => [
62
+ a(r(H), {
57
63
  "horizontal-shift": 20,
58
64
  "vertical-shift": 20,
59
65
  triggers: {
60
- [l(R).selectors.segment]: S
66
+ [r(N).selectors.segment]: x
61
67
  }
62
68
  }, null, 8, ["triggers"]),
63
- a(l($), {
64
- value: V,
65
- "corner-radius": e.radius,
66
- "arc-width": e.arcWidth ?? 20,
67
- color: L,
68
- "angle-range": x ? [-1.5707963267948966, 1.5707963267948966] : [],
69
- "pad-angle": n.padAngle || 0
69
+ a(r(E), {
70
+ value: T,
71
+ "corner-radius": l.radius,
72
+ "arc-width": l.arcWidth ?? 20,
73
+ color: w,
74
+ "angle-range": V ? [-1.5707963267948966, 1.5707963267948966] : [],
75
+ "pad-angle": t.padAngle || 0
70
76
  }, null, 8, ["corner-radius", "arc-width", "angle-range", "pad-angle"]),
71
- i("div", M, [
72
- p(e.$slots, "default")
77
+ y("div", R, [
78
+ u(e.$slots, "default")
73
79
  ])
74
80
  ]),
75
81
  _: 3
76
82
  }, 8, ["data", "height"]),
77
- n.hideLegend ? v("", !0) : (m(), f("div", {
83
+ t.hideLegend ? v("", !0) : (m(), p("div", {
78
84
  key: 0,
79
- style: s({
85
+ style: d({
80
86
  display: "flex",
81
- justifyContent: D.value
87
+ justifyContent: S.value
82
88
  })
83
89
  }, [
84
- a(l(j), {
85
- style: s([
86
- n.legendStyle,
90
+ a(r(F), {
91
+ style: d([
92
+ t.legendStyle,
87
93
  "display: flex; gap: var(--vis-legend-spacing);"
88
94
  ]),
89
- items: u.value.map((t) => ({
90
- ...t,
91
- color: d(t.color)
95
+ items: f.value.map((n) => ({
96
+ ...n,
97
+ color: g(n.color)
92
98
  }))
93
99
  }, null, 8, ["style", "items"])
94
100
  ], 4)),
95
- i("div", O, [
96
- l(k).tooltip ? p(e.$slots, "tooltip", {
101
+ y("div", M, [
102
+ r(k).tooltip ? u(e.$slots, "tooltip", {
97
103
  key: 0,
98
- values: r.value
99
- }) : r.value ? p(e.$slots, "fallback", { key: 1 }, () => {
100
- var t;
101
- return [
102
- i("div", U, [
103
- i("div", {
104
- style: s({
105
- width: "0.5rem",
106
- height: "0.5rem",
107
- borderRadius: "9999px",
108
- marginRight: "0.5rem",
109
- backgroundColor: d((t = u.value[r.value.index]) == null ? void 0 : t.color)
110
- })
111
- }, null, 4),
112
- i("div", null, b(r.value.data), 1)
113
- ])
114
- ];
115
- }) : v("", !0)
104
+ values: i.value
105
+ }) : i.value ? u(e.$slots, "fallback", { key: 1 }, () => [
106
+ a(j, {
107
+ data: i.value,
108
+ categories: t.categories,
109
+ "title-formatter": t.tooltipTitleFormatter
110
+ }, null, 8, ["data", "categories", "title-formatter"])
111
+ ]) : v("", !0)
116
112
  ], 512)
117
113
  ], 4));
118
114
  }
@@ -2,7 +2,7 @@ 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
3
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
4
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;
5
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onClick"> & DonutChartProps<T> & Partial<{}>> & import('vue').PublicProps;
6
6
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
7
7
  attrs: any;
8
8
  slots: {
@@ -1,5 +1,5 @@
1
1
  import { BulletLegendItemInterface, LegendPosition } from '../../types';
2
- export type DonutChartProps = {
2
+ export type DonutChartProps<T> = {
3
3
  /**
4
4
  * The type of donut chart to render.
5
5
  * See `DonutType` for available options.
@@ -44,6 +44,10 @@ export type DonutChartProps = {
44
44
  * Pad angle. Default: 0
45
45
  */
46
46
  padAngle?: number;
47
+ /**
48
+ * Use custom formatter for tooltip titles
49
+ */
50
+ tooltipTitleFormatter?: (data: T) => string | number;
47
51
  };
48
52
  declare enum DonutType {
49
53
  Half = "half",
@@ -1,10 +1,10 @@
1
- import { defineComponent as V, useSlots as B, useTemplateRef as w, ref as A, computed as s, createElementBlock as g, openBlock as m, normalizeStyle as c, createVNode as o, createCommentVNode as f, createElementVNode as H, unref as i, withCtx as P, mergeProps as F, renderSlot as h } from "vue";
2
- import { Timeline as y } from "@unovis/ts";
3
- import { dateFormatter as S, getFirstPropertyValue as N } from "../../utils.js";
4
- import j from "../Tooltip.js";
5
- import { VisXYContainer as O, VisTimeline as $, VisTooltip as D, VisAxis as G, VisBulletLegend as M } from "@unovis/vue";
6
- import { LegendPosition as E } from "../../types.js";
7
- const I = /* @__PURE__ */ V({
1
+ import { defineComponent as B, useSlots as V, useTemplateRef as w, ref as A, computed as c, createElementBlock as f, openBlock as p, normalizeStyle as d, createVNode as n, createCommentVNode as h, createElementVNode as F, unref as o, withCtx as H, mergeProps as P, renderSlot as y } from "vue";
2
+ import { Timeline as x } from "@unovis/ts";
3
+ import { dateFormatter as S } from "../../utils.js";
4
+ import N from "../Tooltip.js";
5
+ import { VisXYContainer as j, VisTimeline as O, VisTooltip as $, VisAxis as D, VisBulletLegend as G } from "@unovis/vue";
6
+ import { LegendPosition as M } from "../../types.js";
7
+ const I = /* @__PURE__ */ B({
8
8
  __name: "GanttChart",
9
9
  props: {
10
10
  data: {},
@@ -15,6 +15,7 @@ const I = /* @__PURE__ */ V({
15
15
  x: {},
16
16
  length: {},
17
17
  type: {},
18
+ tooltipTitleFormatter: {},
18
19
  getTooltipText: {},
19
20
  xNumTicks: {},
20
21
  showLabels: { type: Boolean, default: !0 },
@@ -22,7 +23,7 @@ const I = /* @__PURE__ */ V({
22
23
  crosshairConfig: {},
23
24
  lineWidth: { default: 12 },
24
25
  rowHeight: { default: 24 },
25
- legendPosition: { default: E.TopRight },
26
+ legendPosition: { default: M.TopRight },
26
27
  legendStyle: {},
27
28
  hideLegend: { type: Boolean },
28
29
  xTickLine: { type: Boolean },
@@ -35,102 +36,102 @@ const I = /* @__PURE__ */ V({
35
36
  yAxisConfig: {}
36
37
  },
37
38
  emits: ["click", "scroll", "labelHover"],
38
- setup(T, { emit: k }) {
39
- const l = T, r = k, v = B(), d = w("slotWrapper"), n = A(), x = s(() => l.legendPosition.startsWith("top")), b = s(() => l.legendPosition.includes("left") ? "flex-start" : l.legendPosition.includes("right") ? "flex-end" : "center");
40
- y.selectors.label + "";
41
- function u(e) {
42
- n.value = e, r("labelHover", e);
39
+ setup(i, { emit: T }) {
40
+ const e = i, s = T, k = V(), u = w("slotWrapper"), r = A(), v = c(() => e.legendPosition.startsWith("top")), b = c(() => e.legendPosition.includes("left") ? "flex-start" : e.legendPosition.includes("right") ? "flex-end" : "center");
41
+ x.selectors.label + "";
42
+ function g(l) {
43
+ r.value = l, s("labelHover", l);
43
44
  }
44
- function L(e, a, t) {
45
- r("click", t, { index: a, item: e });
45
+ function L(l, a, t) {
46
+ s("click", t, { index: a, item: l });
46
47
  }
47
- function C(e) {
48
- r("scroll", e.deltaY);
48
+ function C(l) {
49
+ s("scroll", l.deltaY);
49
50
  }
50
- const W = s(() => {
51
- const e = Object.values(l.categories).map(
51
+ const W = c(() => {
52
+ const l = Object.values(e.categories).map(
52
53
  (a, t) => `var(--vis-color${t})`
53
54
  );
54
- return Object.values(l.categories).map(
55
- (a, t) => a.color ?? e[t]
55
+ return Object.values(e.categories).map(
56
+ (a, t) => a.color ?? l[t]
56
57
  );
57
58
  });
58
- return (e, a) => (m(), g("div", {
59
- style: c({
59
+ return (l, a) => (p(), f("div", {
60
+ style: d({
60
61
  display: "flex",
61
- flexDirection: x.value ? "column-reverse" : "column",
62
+ flexDirection: v.value ? "column-reverse" : "column",
62
63
  gap: "var(--vis-legend-spacing)"
63
64
  })
64
65
  }, [
65
- o(i(O), {
66
- data: l.data,
67
- height: l.height,
66
+ n(o(j), {
67
+ data: e.data,
68
+ height: e.height,
68
69
  onWheel: C
69
70
  }, {
70
- default: P(() => [
71
- o(i($), {
72
- x: l.x,
73
- length: l.length,
74
- lineWidth: l.lineWidth,
75
- rowHeight: l.rowHeight,
76
- type: l.type,
71
+ default: H(() => [
72
+ n(o(O), {
73
+ x: e.x,
74
+ length: e.length,
75
+ lineWidth: e.lineWidth,
76
+ rowHeight: e.rowHeight,
77
+ type: e.type,
77
78
  color: W.value,
78
- labelWidth: l.labelWidth,
79
- showLabels: l.showLabels,
79
+ labelWidth: e.labelWidth,
80
+ showLabels: e.showLabels,
80
81
  onClick: L
81
82
  }, null, 8, ["x", "length", "lineWidth", "rowHeight", "type", "color", "labelWidth", "showLabels"]),
82
- o(i(D), {
83
+ n(o($), {
83
84
  triggers: {
84
- [i(y).selectors.label]: (t) => {
85
- var p;
86
- return u(t), t ? (p = d.value) == null ? void 0 : p.innerHTML : "";
85
+ [o(x).selectors.label]: (t) => {
86
+ var m;
87
+ return g(t), t ? (m = u.value) == null ? void 0 : m.innerHTML : "";
87
88
  }
88
89
  }
89
90
  }, null, 8, ["triggers"]),
90
- o(i(G), F({
91
+ n(o(D), P({
91
92
  type: "x",
92
- tickFormat: e.xTickFormat || i(S),
93
- numTicks: e.xNumTicks,
94
- "tick-line": e.xTickLine,
95
- "grid-line": e.xGridLine,
96
- "domain-line": e.xDomainLine
97
- }, e.xAxisConfig), null, 16, ["tickFormat", "numTicks", "tick-line", "grid-line", "domain-line"])
93
+ tickFormat: i.xTickFormat || o(S),
94
+ numTicks: i.xNumTicks,
95
+ "tick-line": i.xTickLine,
96
+ "grid-line": i.xGridLine,
97
+ "domain-line": i.xDomainLine
98
+ }, i.xAxisConfig), null, 16, ["tickFormat", "numTicks", "tick-line", "grid-line", "domain-line"])
98
99
  ]),
99
100
  _: 1
100
101
  }, 8, ["data", "height"]),
101
- l.hideLegend ? f("", !0) : (m(), g("div", {
102
+ e.hideLegend ? h("", !0) : (p(), f("div", {
102
103
  key: 0,
103
- style: c({
104
+ style: d({
104
105
  display: "flex",
105
106
  justifyContent: b.value
106
107
  })
107
108
  }, [
108
- o(i(M), {
109
- style: c([
110
- l.legendStyle,
109
+ n(o(G), {
110
+ style: d([
111
+ e.legendStyle,
111
112
  "display: flex; gap: var(--vis-legend-spacing);"
112
113
  ]),
113
- items: Object.values(l.categories).map((t) => ({
114
+ items: Object.values(e.categories).map((t) => ({
114
115
  ...t,
115
116
  color: Array.isArray(t.color) ? t.color[0] : t.color
116
117
  }))
117
118
  }, null, 8, ["style", "items"])
118
119
  ], 4)),
119
- H("div", {
120
+ F("div", {
120
121
  ref_key: "slotWrapper",
121
- ref: d,
122
+ ref: u,
122
123
  style: { display: "none" }
123
124
  }, [
124
- i(v).labelTooltip ? h(e.$slots, "labelTooltip", {
125
+ o(k).labelTooltip ? y(l.$slots, "labelTooltip", {
125
126
  key: 0,
126
- values: n.value
127
- }) : n.value ? h(e.$slots, "fallback", { key: 1 }, () => [
128
- o(j, {
129
- data: n.value,
130
- categories: e.categories,
131
- toolTipTitle: i(N)(n.value) ?? ""
132
- }, null, 8, ["data", "categories", "toolTipTitle"])
133
- ]) : f("", !0)
127
+ values: r.value
128
+ }) : r.value ? y(l.$slots, "fallback", { key: 1 }, () => [
129
+ n(N, {
130
+ data: r.value,
131
+ "title-formatter": e.tooltipTitleFormatter,
132
+ categories: i.categories
133
+ }, null, 8, ["data", "title-formatter", "categories"])
134
+ ]) : h("", !0)
134
135
  ], 512)
135
136
  ], 4));
136
137
  }
@@ -11,7 +11,7 @@ declare const _default: <T extends Record<string, any>>(__VLS_props: NonNullable
11
11
  }) => any) | undefined;
12
12
  readonly onScroll?: ((distance: number) => any) | undefined;
13
13
  readonly onLabelHover?: ((item: T | undefined) => any) | undefined;
14
- } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onClick" | "onScroll" | "onLabelHover"> & GanttChartProps<T> & Partial<{}>> & import('vue').PublicProps;
14
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onScroll" | "onClick" | "onLabelHover"> & GanttChartProps<T> & Partial<{}>> & import('vue').PublicProps;
15
15
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
16
16
  attrs: any;
17
17
  slots: {
@@ -43,6 +43,10 @@ export interface GanttChartProps<T> {
43
43
  * @returns {string} The type/category identifier.
44
44
  */
45
45
  type: (d: T) => string;
46
+ /**
47
+ * Use custom formatter for tooltip titles
48
+ */
49
+ tooltipTitleFormatter?: (data: T) => string | number;
46
50
  /**
47
51
  * Optional custom tooltip text generator function.
48
52
  * @param {string} label - The label of the item.
@@ -102,8 +106,8 @@ export interface GanttChartProps<T> {
102
106
  xGridLine?: boolean;
103
107
  xDomainLine?: boolean;
104
108
  /**
105
- * Axis configuration object for customizing the appearance of the axes.
106
- */
109
+ * Axis configuration object for customizing the appearance of the axes.
110
+ */
107
111
  xAxisConfig?: AxisConfig;
108
112
  /**
109
113
  * Axis configuration object for customizing the appearance of the axes.
@@ -1,6 +1,6 @@
1
- import { defineComponent as t, useSlots as a, createBlock as r, openBlock as l, mergeProps as p, createSlots as s, withCtx as y, renderSlot as c, normalizeProps as m, guardReactiveProps as d } from "vue";
1
+ import { defineComponent as n, useSlots as a, createBlock as r, openBlock as l, mergeProps as p, createSlots as s, withCtx as y, renderSlot as c, normalizeProps as m, guardReactiveProps as d } from "vue";
2
2
  import x from "../AreaChart/AreaChart.js";
3
- const u = /* @__PURE__ */ t({
3
+ const g = /* @__PURE__ */ n({
4
4
  __name: "LineChart",
5
5
  props: {
6
6
  data: {},
@@ -12,6 +12,7 @@ const u = /* @__PURE__ */ t({
12
12
  markerConfig: {},
13
13
  xFormatter: { type: Function },
14
14
  yFormatter: { type: Function },
15
+ tooltipTitleFormatter: { type: Function },
15
16
  curveType: {},
16
17
  lineWidth: {},
17
18
  lineDashArray: {},
@@ -42,8 +43,8 @@ const u = /* @__PURE__ */ t({
42
43
  return a(), (e, h) => (l(), r(x, p(i, { "hide-area": !0 }), s({ _: 2 }, [
43
44
  e.$slots.tooltip ? {
44
45
  name: "tooltip",
45
- fn: y((n) => [
46
- c(e.$slots, "tooltip", m(d(n)))
46
+ fn: y((t) => [
47
+ c(e.$slots, "tooltip", m(d(t)))
47
48
  ]),
48
49
  key: "0"
49
50
  } : void 0
@@ -51,5 +52,5 @@ const u = /* @__PURE__ */ t({
51
52
  }
52
53
  });
53
54
  export {
54
- u as default
55
+ g as default
55
56
  };
@@ -1,42 +1,67 @@
1
- import { defineComponent as y, computed as f, createElementBlock as r, openBlock as i, createElementVNode as e, toDisplayString as l, Fragment as h, renderList as b, normalizeStyle as n } from "vue";
2
- const x = { style: { padding: "10px 15px" } }, _ = { style: {
3
- color: "var(--tooltip-value-color)",
4
- textTransform: "capitalize",
5
- borderBottom: "1px solid var(--tooltip-border-color)",
6
- marginBottom: "0.25rem",
7
- paddingBottom: "0.25rem"
8
- } }, T = /* @__PURE__ */ y({
1
+ import { defineComponent as S, computed as p, createElementBlock as l, openBlock as a, createElementVNode as o, toDisplayString as n, Fragment as z, renderList as B, normalizeStyle as w } from "vue";
2
+ import { getFirstPropertyValue as j } from "../utils.js";
3
+ const C = { style: { display: "flex", "align-items": "center" } }, W = /* @__PURE__ */ S({
9
4
  __name: "Tooltip",
10
5
  props: {
11
6
  data: {},
12
7
  categories: {},
13
- toolTipTitle: {},
8
+ titleFormatter: { type: Function },
14
9
  yFormatter: { type: Function }
15
10
  },
16
- setup(d) {
17
- const a = d, m = ["_index", "_stacked", "_ending"], g = f(() => Object.entries(a.data ?? []).filter(
18
- ([o, u]) => !m.includes(o) && Object.keys(a.categories).includes(o)
19
- ));
20
- return (o, u) => (i(), r("div", x, [
21
- e("div", _, l(o.toolTipTitle), 1),
22
- (i(!0), r(h, null, b(g.value, ([t, s], v) => {
23
- var p, c;
24
- return i(), r("div", {
25
- key: t,
26
- style: { display: "flex", "align-items": "center", "margin-bottom": "4px" }
11
+ setup(t) {
12
+ const e = t, c = p(
13
+ () => e.titleFormatter ? e.titleFormatter(e.data) : j(e.data)
14
+ ), m = ["_index", "_stacked", "_ending"], g = p(() => Object.entries(e.data ?? []).filter(
15
+ ([r, x]) => !m.includes(r) && Object.keys(e.categories).includes(r)
16
+ )), u = {
17
+ color: "var(--vis-tooltip-title-color, #000)",
18
+ textTransform: "var(--vis-tooltip-title-text-transform, capitalize)",
19
+ borderBottom: "var(--vis-tooltip-title-border-bottom, 1px solid #e5e7eb)",
20
+ marginBottom: "var(--vis-tooltip-title-margin-bottom, 0.25rem)",
21
+ paddingBottom: "var(--vis-tooltip-title-padding-bottom, 0.25rem)",
22
+ padding: "var(--vis-tooltip-title-padding, 0.75rem)",
23
+ fontSize: "var(--vis-tooltip-title-font-size, 0.875rem)",
24
+ lineHeight: "var(--vis-tooltip-title-line-height, 100%)",
25
+ fontWeight: "var(--vis-tooltip-title-font-weight, 600)"
26
+ }, f = {
27
+ display: "flex",
28
+ alignItems: "center",
29
+ justifyContent: "space-between",
30
+ padding: "var(--vis-tooltip-entry-padding-top, 0.25rem) var(--vis-tooltip-entry-padding-right, 0.25rem) var(--vis-tooltip-entry-padding-bottom, 0.5rem) var(--vis-tooltip-entry-padding-left, 0.25rem)"
31
+ }, y = {
32
+ width: "var(--vis-tooltip-dot-width, 8px)",
33
+ height: "var(--vis-tooltip-dot-height, 8px)",
34
+ borderRadius: "var(--vis-tooltip-dot-border-radius, 4px)",
35
+ marginRight: "var(--vis-tooltip-dot-margin-right, 8px)"
36
+ }, h = {
37
+ fontWeight: "var(--vis-tooltip-label-font-weight, 400)",
38
+ fontSize: "var(--vis-tooltip-label-font-size, 0.875rem)",
39
+ marginRight: "var(--vis-tooltip-label-margin-right, 1rem)",
40
+ color: "var(--vis-tooltip-label-color)"
41
+ }, b = {
42
+ fontSize: "var(--vis-tooltip-value-font-size, 0.875rem)",
43
+ fontWeight: "var(--vis-tooltip-value-font-weight, 600)",
44
+ color: "var(--vis-tooltip-value-color)"
45
+ };
46
+ return (r, x) => (a(), l("div", null, [
47
+ o("div", { style: u }, n(c.value), 1),
48
+ (a(!0), l(z, null, B(g.value, ([i, s], F) => {
49
+ var v, d;
50
+ return a(), l("div", {
51
+ key: i,
52
+ style: f
27
53
  }, [
28
- e("span", {
29
- style: n([{ width: "8px", height: "8px", "border-radius": "4px", "margin-right": "8px" }, {
30
- backgroundColor: typeof ((p = o.categories[t]) == null ? void 0 : p.color) == "string" && ((c = o.categories[t]) != null && c.color) ? o.categories[t].color : `var(--vis-color${v})`
31
- }])
32
- }, null, 4),
33
- e("div", null, [
34
- e("span", {
35
- style: n([{ "font-weight": "600", "margin-right": "8px" }, { color: "var(--tooltip-label-color)" }])
36
- }, l(o.categories[t].name) + ":", 1),
37
- e("span", {
38
- style: n([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
39
- }, l(o.yFormatter ? o.yFormatter(s) : s), 1)
54
+ o("div", C, [
55
+ o("span", {
56
+ style: w({
57
+ ...y,
58
+ backgroundColor: typeof ((v = t.categories[i]) == null ? void 0 : v.color) == "string" && ((d = t.categories[i]) != null && d.color) ? t.categories[i].color : `var(--vis-color${F})`
59
+ })
60
+ }, null, 4),
61
+ o("span", { style: h }, n(t.categories[i].name) + ": ", 1)
62
+ ]),
63
+ o("div", null, [
64
+ o("span", { style: b }, n(t.yFormatter ? t.yFormatter(s) : s), 1)
40
65
  ])
41
66
  ]);
42
67
  }), 128))
@@ -44,5 +69,5 @@ const x = { style: { padding: "10px 15px" } }, _ = { style: {
44
69
  }
45
70
  });
46
71
  export {
47
- T as default
72
+ W as default
48
73
  };
@@ -3,7 +3,7 @@ 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> & {
4
4
  data: T;
5
5
  categories: Record<string, BulletLegendItemInterface>;
6
- toolTipTitle: string | number;
6
+ titleFormatter?: (data: T) => string | number;
7
7
  yFormatter?: axisFormatter;
8
8
  } & Partial<{}>> & import('vue').PublicProps;
9
9
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
package/dist/types.d.ts CHANGED
@@ -62,13 +62,18 @@ export interface AxisConfig {
62
62
  minMaxTicksOnlyShowGridLines?: boolean;
63
63
  tickValues?: readonly number[] | readonly Date[];
64
64
  }
65
- export interface MarkerConfig {
66
- type?: "circle" | "square" | "triangle" | "diamond";
67
- size?: number;
68
- strokeWidth?: number;
69
- color?: string;
70
- strokeColor?: string;
71
- }
65
+ export type MarkerConfig = {
66
+ id: string;
67
+ config: {
68
+ [key: string]: {
69
+ type?: "circle" | "square" | "triangle" | "diamond";
70
+ size?: number;
71
+ strokeWidth?: number;
72
+ color?: string;
73
+ strokeColor?: string;
74
+ };
75
+ };
76
+ };
72
77
  export interface CrosshairConfig {
73
78
  color?: string;
74
79
  strokeColor?: string;
package/dist/utils.d.ts CHANGED
@@ -2,7 +2,7 @@ import { MarkerConfig } from './types';
2
2
  export declare function getDistributedIndices(length: number, numTicks: number): number[];
3
3
  export declare function getFirstPropertyValue(obj: unknown): undefined;
4
4
  export declare const markerShape: (type: string, size: number, strokeWidth: number, color: string, strokeColor: string) => string;
5
- export declare function createMarkers(markerConfig: Record<string, MarkerConfig>): string;
5
+ export declare function createMarkers(markerConfig: MarkerConfig): string;
6
6
  export declare const flattenData: (data: any[], xAxis: string) => {
7
7
  month: any;
8
8
  }[];