vue-chrts 0.2.3 → 0.2.5

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,13 +1,13 @@
1
- import { defineComponent as U, useSlots as j, useTemplateRef as w, ref as R, computed as u, createElementBlock as m, openBlock as r, normalizeClass as S, normalizeStyle as T, createVNode as p, createCommentVNode as d, createElementVNode as X, unref as i, withCtx as z, createBlock as c, Fragment as L, renderList as I, mergeProps as C, renderSlot as A } from "vue";
2
- import { Position as D, CurveType as b } from "@unovis/ts";
3
- import { createMarkers as Y, getFirstPropertyValue as x } from "../../utils.js";
1
+ import { defineComponent as U, useSlots as j, useTemplateRef as w, ref as R, computed as p, createElementBlock as u, openBlock as a, normalizeClass as S, normalizeStyle as T, createVNode as m, createCommentVNode as d, createElementVNode as X, unref as t, withCtx as x, createBlock as c, Fragment as L, renderList as z, mergeProps as C, renderSlot as D } from "vue";
2
+ import { Position as A, CurveType as b } from "@unovis/ts";
3
+ import { createMarkers as I, getFirstPropertyValue as Y } from "../../utils.js";
4
4
  import H from "../Tooltip.js";
5
5
  import { VisXYContainer as K, VisTooltip as q, VisArea as J, VisLine as Q, VisAxis as B, VisCrosshair as Z, VisBulletLegend as _ } from "@unovis/vue";
6
6
  import { LegendPosition as ee } from "../../types.js";
7
- const te = {
7
+ const ie = {
8
8
  ref: "slotWrapper",
9
9
  style: { display: "none" }
10
- }, y = 24, V = 4, ie = 0.5, F = "#3b82f6", de = /* @__PURE__ */ U({
10
+ }, y = 24, V = 4, te = 0.5, F = "#3b82f6", de = /* @__PURE__ */ U({
11
11
  __name: "AreaChart",
12
12
  props: {
13
13
  data: {},
@@ -22,10 +22,10 @@ const te = {
22
22
  curveType: {},
23
23
  lineWidth: { default: 2 },
24
24
  lineDashArray: {},
25
- xNumTicks: { default: (a) => a.data.length > y ? y / V : a.data.length - 1 },
25
+ xNumTicks: { default: (r) => r.data.length > y ? y / V : r.data.length - 1 },
26
26
  xExplicitTicks: {},
27
27
  minMaxTicksOnly: { type: Boolean },
28
- yNumTicks: { default: (a) => a.data.length > y ? y / V : a.data.length - 1 },
28
+ yNumTicks: { default: (r) => r.data.length > y ? y / V : r.data.length - 1 },
29
29
  hideLegend: { type: Boolean },
30
30
  hideTooltip: { type: Boolean },
31
31
  legendPosition: {},
@@ -39,32 +39,34 @@ const te = {
39
39
  hideYAxis: { type: Boolean },
40
40
  crosshairConfig: { default: () => ({
41
41
  color: "#666"
42
- }) }
42
+ }) },
43
+ yDomain: {},
44
+ xDomain: {}
43
45
  },
44
46
  emits: ["click"],
45
- setup(a, { emit: $ }) {
46
- const G = $, n = a, O = j(), h = w("slotWrapper"), s = R(), f = u(
47
+ setup(r, { emit: $ }) {
48
+ const G = $, n = r, O = j(), h = w("slotWrapper"), s = R(), f = p(
47
49
  () => Object.values(n.categories).map((e) => e.color)
48
- ), N = u(() => n.markerConfig ? Y(n.markerConfig) : ""), g = u(() => n.legendPosition === ee.Top), E = u(() => {
49
- const e = (t, o) => `
50
- <linearGradient id="gradient${t}-${o}" gradientTransform="rotate(90)">
50
+ ), N = p(() => n.markerConfig ? I(n.markerConfig) : ""), g = p(() => n.legendPosition === ee.Top), E = p(() => {
51
+ const e = (i, o) => `
52
+ <linearGradient id="gradient${i}-${o}" gradientTransform="rotate(90)">
51
53
  <stop offset="0%" stop-color="${o}" stop-opacity="1" />
52
54
  <stop offset="100%" stop-color="${o}" stop-opacity="0" />
53
55
  </linearGradient>
54
- `, l = (t, o) => `
55
- <linearGradient id="gradient${t}-${o}" gradientTransform="rotate(90)">
56
+ `, l = (i, o) => `
57
+ <linearGradient id="gradient${i}-${o}" gradientTransform="rotate(90)">
56
58
  <stop offset="0%" style="stop-color:var(--vis-color0);stop-opacity:1" />
57
59
  <stop offset="100%" style="stop-color:var(--vis-color0);stop-opacity:0" />
58
60
  </linearGradient>
59
61
  `;
60
62
  return f.value.map(
61
- (t, o) => t != null && t.includes("#") ? e(o, t) : l(o, t ?? F)
63
+ (i, o) => i != null && i.includes("#") ? e(o, i) : l(o, i ?? F)
62
64
  ).join("");
63
65
  });
64
66
  function P(e) {
65
67
  var l;
66
68
  return {
67
- y: (t) => Number(t[e]),
69
+ y: (i) => Number(i[e]),
68
70
  color: ((l = n.categories[e]) == null ? void 0 : l.color) ?? F
69
71
  };
70
72
  }
@@ -74,44 +76,46 @@ const te = {
74
76
  function M(e) {
75
77
  return s.value = e, W();
76
78
  }
77
- return (e, l) => (r(), m("div", {
79
+ return (e, l) => (a(), u("div", {
78
80
  style: T({
79
81
  display: "flex",
80
82
  flexDirection: g.value ? "column-reverse" : "column"
81
83
  }),
82
84
  class: S({ markers: !!n.markerConfig }),
83
- onClick: l[0] || (l[0] = (t) => G("click", t, s.value))
85
+ onClick: l[0] || (l[0] = (i) => G("click", i, s.value))
84
86
  }, [
85
- p(i(K), {
87
+ m(t(K), {
86
88
  data: e.data,
87
89
  height: e.height,
88
90
  padding: e.padding,
89
- "svg-defs": E.value + N.value
91
+ "svg-defs": E.value + N.value,
92
+ "y-domain": e.yDomain,
93
+ "x-domain": e.xDomain
90
94
  }, {
91
- default: z(() => [
92
- e.hideTooltip ? d("", !0) : (r(), c(i(q), {
95
+ default: x(() => [
96
+ e.hideTooltip ? d("", !0) : (a(), c(t(q), {
93
97
  key: 0,
94
- "horizontal-placement": i(D).Right,
95
- "vertical-placement": i(D).Top
98
+ "horizontal-placement": t(A).Right,
99
+ "vertical-placement": t(A).Top
96
100
  }, null, 8, ["horizontal-placement", "vertical-placement"])),
97
- (r(!0), m(L, null, I(Object.keys(n.categories), (t, o) => (r(), m(L, { key: t }, [
98
- p(i(J), C({
101
+ (a(!0), u(L, null, z(Object.keys(n.categories), (i, o) => (a(), u(L, { key: i }, [
102
+ m(t(J), C({
99
103
  x: (k, v) => v
100
- }, { ref_for: !0 }, P(t), {
104
+ }, { ref_for: !0 }, P(i), {
101
105
  color: `url(#gradient${o}-${f.value[o]})`,
102
- opacity: ie,
103
- "curve-type": e.curveType ?? i(b).MonotoneX
106
+ opacity: te,
107
+ "curve-type": e.curveType ?? t(b).MonotoneX
104
108
  }), null, 16, ["x", "color", "curve-type"]),
105
- p(i(Q), {
109
+ m(t(Q), {
106
110
  x: (k, v) => v,
107
- y: (k) => k[t],
111
+ y: (k) => k[i],
108
112
  color: f.value[o],
109
- "curve-type": e.curveType ?? i(b).MonotoneX,
113
+ "curve-type": e.curveType ?? t(b).MonotoneX,
110
114
  "line-width": e.lineWidth,
111
115
  lineDashArray: e.lineDashArray ? e.lineDashArray[o] : void 0
112
116
  }, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"])
113
117
  ], 64))), 128)),
114
- e.hideXAxis ? d("", !0) : (r(), c(i(B), {
118
+ e.hideXAxis ? d("", !0) : (a(), c(t(B), {
115
119
  key: 1,
116
120
  type: "x",
117
121
  label: e.xLabel,
@@ -124,7 +128,7 @@ const te = {
124
128
  "tick-line": e.xTickLine,
125
129
  "min-max-ticks-only": e.minMaxTicksOnly
126
130
  }, null, 8, ["label", "num-ticks", "tick-format", "tick-values", "grid-line", "domain-line", "tick-line", "min-max-ticks-only"])),
127
- e.hideYAxis ? d("", !0) : (r(), c(i(B), {
131
+ e.hideYAxis ? d("", !0) : (a(), c(t(B), {
128
132
  key: 2,
129
133
  type: "y",
130
134
  label: e.yLabel,
@@ -134,11 +138,11 @@ const te = {
134
138
  "domain-line": e.yDomainLine,
135
139
  "tick-line": e.yTickLine
136
140
  }, null, 8, ["label", "num-ticks", "tick-format", "grid-line", "domain-line", "tick-line"])),
137
- e.hideTooltip ? d("", !0) : (r(), c(i(Z), C({ key: 3 }, e.crosshairConfig, { template: M }), null, 16))
141
+ e.hideTooltip ? d("", !0) : (a(), c(t(Z), C({ key: 3 }, e.crosshairConfig, { template: M }), null, 16))
138
142
  ]),
139
143
  _: 1
140
- }, 8, ["data", "height", "padding", "svg-defs"]),
141
- e.hideLegend ? d("", !0) : (r(), m("div", {
144
+ }, 8, ["data", "height", "padding", "svg-defs", "y-domain", "x-domain"]),
145
+ e.hideLegend ? d("", !0) : (a(), u("div", {
142
146
  key: 0,
143
147
  style: T({
144
148
  display: "flex",
@@ -148,19 +152,19 @@ const te = {
148
152
  paddingTop: g.value ? void 0 : "1rem"
149
153
  })
150
154
  }, [
151
- p(i(_), {
155
+ m(t(_), {
152
156
  items: Object.values(e.categories)
153
157
  }, null, 8, ["items"])
154
158
  ], 4)),
155
- X("div", te, [
156
- i(O).tooltip ? A(e.$slots, "tooltip", {
159
+ X("div", ie, [
160
+ t(O).tooltip ? D(e.$slots, "tooltip", {
157
161
  key: 0,
158
162
  values: s.value
159
- }) : s.value ? A(e.$slots, "fallback", { key: 1 }, () => [
160
- p(H, {
163
+ }) : s.value ? D(e.$slots, "fallback", { key: 1 }, () => [
164
+ m(H, {
161
165
  data: s.value,
162
166
  categories: e.categories,
163
- toolTipTitle: i(x)(s.value) ?? "",
167
+ toolTipTitle: t(Y)(s.value) ?? "",
164
168
  yFormatter: n.yFormatter
165
169
  }, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
166
170
  ]) : d("", !0)
@@ -72,7 +72,7 @@ export interface AreaChartProps<T> {
72
72
  /**
73
73
  * Force specific ticks on the x-axis.
74
74
  */
75
- xExplicitTicks?: number;
75
+ xExplicitTicks?: (number | string | Date)[];
76
76
  /**
77
77
  * Force only first and last ticks on the x-axis.
78
78
  */
@@ -130,4 +130,12 @@ export interface AreaChartProps<T> {
130
130
  * Crosshair configuration object for customizing the appearance of the crosshair line.
131
131
  */
132
132
  crosshairConfig?: CrosshairConfig;
133
+ /**
134
+ * The domain for the y-axis, specified as a tuple of two values.
135
+ */
136
+ yDomain?: [number | undefined, number | undefined];
137
+ /**
138
+ * The domain for the x-axis, specified as a tuple of two values.
139
+ */
140
+ xDomain?: [number | undefined, number | undefined];
133
141
  }
@@ -1,14 +1,14 @@
1
- import { defineComponent as C, useSlots as S, useTemplateRef as D, ref as N, computed as c, createElementBlock as y, openBlock as n, normalizeStyle as T, createVNode as g, createCommentVNode as m, createElementVNode as O, unref as i, withCtx as w, createBlock as u, Fragment as E, renderList as M, renderSlot as B } 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 L, VisGroupedBar as $, VisAxis as A, VisBulletLegend as R } from "@unovis/vue";
6
- import q from "../Tooltip.js";
7
- import { LegendPosition as I } from "../../types.js";
8
- const U = {
1
+ import { defineComponent as R, useSlots as W, useTemplateRef as X, ref as Y, computed as b, createElementBlock as v, openBlock as t, normalizeStyle as P, createVNode as k, createCommentVNode as m, createElementVNode as j, unref as o, withCtx as H, createBlock as u, Fragment as $, renderList as q, renderSlot as C } from "vue";
2
+ import { Orientation as p, StackedBar as I, GroupedBar as U } from "@unovis/ts";
3
+ import { getFirstPropertyValue as J } from "../../utils.js";
4
+ import { useStackedGrouped as K } from "./stackedGroupedUtils.js";
5
+ import { VisXYContainer as Q, VisXYLabels as Z, VisTooltip as _, VisStackedBar as F, VisGroupedBar as ee, VisAxis as V, VisBulletLegend as ae } from "@unovis/vue";
6
+ import oe from "../Tooltip.js";
7
+ import { LegendPosition as ie } from "../../types.js";
8
+ const re = {
9
9
  ref: "slotWrapper",
10
10
  style: { display: "none" }
11
- }, ae = /* @__PURE__ */ C({
11
+ }, ce = /* @__PURE__ */ R({
12
12
  __name: "BarChart",
13
13
  props: {
14
14
  data: {},
@@ -25,17 +25,17 @@ const U = {
25
25
  categories: {},
26
26
  xFormatter: {},
27
27
  yFormatter: {},
28
- yNumTicks: { default: (t) => t.data.length > 24 ? 24 / 4 : t.data.length - 1 },
28
+ yNumTicks: {},
29
29
  minMaxTicksOnly: { type: Boolean },
30
- xNumTicks: { default: (t) => t.data.length > 24 ? 24 / 4 : t.data.length - 1 },
30
+ xNumTicks: {},
31
31
  xExplicitTicks: {},
32
32
  yAxis: {},
33
- groupPadding: {},
34
- barPadding: {},
33
+ groupPadding: { default: 0 },
34
+ barPadding: { default: 0.2 },
35
35
  radius: {},
36
36
  hideLegend: { type: Boolean },
37
37
  hideTooltip: { type: Boolean, default: !1 },
38
- orientation: { default: l.Vertical },
38
+ orientation: { default: p.Vertical },
39
39
  legendPosition: {},
40
40
  xDomainLine: { type: Boolean },
41
41
  yDomainLine: { type: Boolean },
@@ -47,131 +47,168 @@ const U = {
47
47
  hideYAxis: { type: Boolean },
48
48
  stackedGroupedSpacing: { default: 0.1 },
49
49
  stackAndGrouped: { type: Boolean },
50
+ valueLabel: {},
50
51
  xAxis: {}
51
52
  },
52
53
  emits: ["click"],
53
- setup(t, { emit: V }) {
54
- const x = V, a = t, G = S(), k = D("slotWrapper"), r = N();
54
+ setup(G, { emit: S }) {
55
+ const O = S, a = G, w = W(), L = X("slotWrapper"), s = Y();
56
+ if (a.valueLabel && !a.xAxis)
57
+ throw new Error(
58
+ "BarChart: 'xAxis' prop is required when 'valueLabel' is enabled. Please provide an 'xAxis' to display value labels."
59
+ );
55
60
  if (!a.yAxis || a.yAxis.length === 0)
56
61
  throw new Error("yAxis is required");
57
- const f = c(() => a.yAxis.map((e) => (d) => d[e])), v = (e, d) => {
58
- var o;
59
- return (o = Object.values(a.categories)[d]) == null ? void 0 : o.color;
60
- }, s = c(
61
- () => W({
62
+ const h = b(() => a.yAxis.map((e) => (r) => r[e])), x = (e, r) => {
63
+ var i;
64
+ return (i = Object.values(a.categories)[r]) == null ? void 0 : i.color;
65
+ }, c = b(
66
+ () => K({
62
67
  data: a.data,
63
68
  categories: a.categories,
64
69
  stackAndGrouped: a.stackAndGrouped,
65
70
  xAxis: a.xAxis,
66
71
  spacing: a.stackedGroupedSpacing
67
72
  }).value
68
- ), h = c(
69
- () => a.legendPosition === I.Top
73
+ ), A = b(
74
+ () => a.legendPosition === ie.Top
70
75
  );
71
- function b(e) {
72
- return r.value = e, P();
76
+ function B(e) {
77
+ return s.value = e, D();
73
78
  }
74
- function P(e) {
75
- return typeof window > "u" ? "" : k.value ? k.value.innerHTML : "";
79
+ function D(e) {
80
+ return typeof window > "u" ? "" : L.value ? L.value.innerHTML : "";
76
81
  }
77
- return (e, d) => (n(), y("div", {
78
- style: T({
82
+ const T = a.yAxis.map((e) => (r) => r[e]), E = T.length, N = a.data.flatMap(
83
+ (e, r) => T.map((i, d) => ({
84
+ x: r,
85
+ y: Number(i(e) ?? 0),
86
+ itemIndex: d
87
+ }))
88
+ ), z = (e) => {
89
+ if (a.stacked || a.stackAndGrouped) return e.x;
90
+ const r = E;
91
+ if (r <= 1) return e.x;
92
+ const d = 1 - (a.groupPadding ?? 0), g = d / r, y = -d / 2, n = g * e.itemIndex + g / 2, f = 1 - (a.barPadding ?? 0), M = (y + n) * f;
93
+ return e.x + M;
94
+ };
95
+ return (e, r) => (t(), v("div", {
96
+ style: P({
79
97
  display: "flex",
80
- flexDirection: h.value ? "column-reverse" : "column",
98
+ flexDirection: A.value ? "column-reverse" : "column",
81
99
  gap: "1rem"
82
100
  }),
83
- onClick: d[0] || (d[0] = (o) => x("click", o, r.value))
101
+ onClick: r[0] || (r[0] = (i) => O("click", i, s.value))
84
102
  }, [
85
- g(i(X), {
103
+ k(o(Q), {
86
104
  padding: e.padding,
87
105
  height: e.height
88
106
  }, {
89
- default: w(() => [
90
- g(i(Y), {
91
- triggers: {
92
- [i(z).selectors.bar]: b,
93
- [i(j).selectors.bar]: b
94
- }
95
- }, null, 8, ["triggers"]),
96
- e.stackAndGrouped ? (n(!0), y(E, { key: 0 }, M(s.value.states, (o) => (n(), u(i(L), {
97
- key: o,
98
- data: s.value.chartData,
99
- x: (p, F) => F + s.value.positions[o],
100
- y: s.value.bars[o],
101
- color: s.value.colorFunctions[o],
102
- "rounded-corners": e.radius ?? 0,
103
- "group-padding": e.groupPadding ?? 0,
104
- "bar-padding": e.barPadding,
105
- orientation: e.orientation ?? i(l).Vertical
106
- }, null, 8, ["data", "x", "y", "color", "rounded-corners", "group-padding", "bar-padding", "orientation"]))), 128)) : e.stacked ? (n(), u(i(L), {
107
- key: 2,
108
- data: e.data,
109
- x: (o, p) => p,
110
- y: f.value,
111
- color: v,
112
- "rounded-corners": e.radius ?? 0,
113
- "group-padding": e.groupPadding ?? 0,
114
- "bar-padding": e.barPadding ?? 0.2,
115
- orientation: e.orientation ?? i(l).Vertical
116
- }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (n(), u(i($), {
117
- key: 1,
118
- data: e.data,
119
- x: (o, p) => p,
120
- y: f.value,
121
- color: v,
122
- "rounded-corners": e.radius ?? 0,
123
- "group-padding": e.groupPadding ?? 0,
124
- "bar-padding": e.barPadding ?? 0.2,
125
- orientation: e.orientation ?? i(l).Vertical
126
- }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])),
127
- e.hideXAxis ? m("", !0) : (n(), u(i(A), {
128
- key: 3,
129
- type: "x",
130
- "tick-format": e.xFormatter,
131
- label: e.xLabel,
132
- "grid-line": e.xGridLine,
133
- "domain-line": !!e.xDomainLine,
134
- "tick-line": e.xTickLine,
135
- "num-ticks": e.xNumTicks,
136
- "tick-values": e.xExplicitTicks,
137
- minMaxTicksOnly: e.minMaxTicksOnly
138
- }, null, 8, ["tick-format", "label", "grid-line", "domain-line", "tick-line", "num-ticks", "tick-values", "minMaxTicksOnly"])),
139
- e.hideYAxis ? m("", !0) : (n(), u(i(A), {
140
- key: 4,
141
- type: "y",
142
- label: e.yLabel,
143
- "grid-line": e.orientation !== i(l).Horizontal && e.yGridLine,
144
- "domain-line": !!e.yDomainLine,
145
- "tick-format": e.yFormatter,
146
- "num-ticks": e.yNumTicks,
147
- "tick-line": e.yTickLine
148
- }, null, 8, ["label", "grid-line", "domain-line", "tick-format", "num-ticks", "tick-line"]))
149
- ]),
107
+ default: H(() => {
108
+ var i, d, g, y;
109
+ return [
110
+ e.valueLabel ? (t(), u(o(Z), {
111
+ key: 0,
112
+ data: o(N),
113
+ x: z,
114
+ y: (n) => {
115
+ var l;
116
+ return n.y + (((l = a.valueLabel) == null ? void 0 : l.labelSpacing) ?? 0);
117
+ },
118
+ label: (i = a.valueLabel) == null ? void 0 : i.label,
119
+ backgroundColor: ((d = a.valueLabel) == null ? void 0 : d.backgroundColor) ?? "transparent",
120
+ color: ((g = a.valueLabel) == null ? void 0 : g.color) ?? "red",
121
+ labelFontSize: (y = a.valueLabel) == null ? void 0 : y.labelFontSize
122
+ }, null, 8, ["data", "y", "label", "backgroundColor", "color", "labelFontSize"])) : m("", !0),
123
+ k(o(_), {
124
+ triggers: {
125
+ [o(U).selectors.bar]: B,
126
+ [o(I).selectors.bar]: B
127
+ }
128
+ }, null, 8, ["triggers"]),
129
+ e.stackAndGrouped ? (t(!0), v($, { key: 1 }, q(c.value.states, (n) => (t(), u(o(F), {
130
+ key: n,
131
+ data: c.value.chartData,
132
+ x: (l, f) => f + c.value.positions[n],
133
+ y: c.value.bars[n],
134
+ color: c.value.colorFunctions[n],
135
+ "rounded-corners": e.radius ?? 0,
136
+ "group-padding": e.groupPadding ?? 0,
137
+ "bar-padding": e.barPadding,
138
+ orientation: e.orientation ?? o(p).Vertical
139
+ }, null, 8, ["data", "x", "y", "color", "rounded-corners", "group-padding", "bar-padding", "orientation"]))), 128)) : e.stacked ? (t(), u(o(F), {
140
+ key: 3,
141
+ data: e.data,
142
+ x: (n, l) => l,
143
+ y: h.value,
144
+ color: x,
145
+ "rounded-corners": e.radius ?? 0,
146
+ "group-padding": e.groupPadding ?? 0,
147
+ "bar-padding": e.barPadding ?? 0.2,
148
+ orientation: e.orientation ?? o(p).Vertical
149
+ }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (t(), u(o(ee), {
150
+ key: 2,
151
+ data: e.data,
152
+ x: (n, l) => l,
153
+ y: h.value,
154
+ color: x,
155
+ "rounded-corners": e.radius ?? 0,
156
+ "group-padding": e.groupPadding ?? 0,
157
+ "bar-padding": e.barPadding ?? 0.2,
158
+ orientation: e.orientation ?? o(p).Vertical
159
+ }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])),
160
+ e.hideXAxis ? m("", !0) : (t(), u(o(V), {
161
+ key: 4,
162
+ type: "x",
163
+ "tick-format": e.xFormatter,
164
+ label: e.xLabel,
165
+ "grid-line": e.xGridLine,
166
+ "domain-line": !!e.xDomainLine,
167
+ "tick-line": e.xTickLine,
168
+ "num-ticks": e.xNumTicks,
169
+ "tick-values": e.xExplicitTicks,
170
+ minMaxTicksOnly: e.minMaxTicksOnly
171
+ }, null, 8, ["tick-format", "label", "grid-line", "domain-line", "tick-line", "num-ticks", "tick-values", "minMaxTicksOnly"])),
172
+ e.hideYAxis ? m("", !0) : (t(), u(o(V), {
173
+ key: 5,
174
+ type: "y",
175
+ label: e.yLabel,
176
+ "grid-line": e.orientation !== o(p).Horizontal && e.yGridLine,
177
+ "domain-line": !!e.yDomainLine,
178
+ "tick-format": e.yFormatter,
179
+ "num-ticks": e.yNumTicks,
180
+ "tick-line": e.yTickLine
181
+ }, null, 8, ["label", "grid-line", "domain-line", "tick-format", "num-ticks", "tick-line"]))
182
+ ];
183
+ }),
150
184
  _: 1
151
185
  }, 8, ["padding", "height"]),
152
- e.hideLegend ? m("", !0) : (n(), y("div", {
186
+ e.hideLegend ? m("", !0) : (t(), v("div", {
153
187
  key: 0,
154
- style: T({
188
+ style: P({
155
189
  display: "flex",
156
190
  alignItems: "center",
157
191
  justifyContent: "flex-end",
158
- paddingBottom: h.value ? "1rem" : void 0
192
+ paddingBottom: A.value ? "1rem" : void 0
159
193
  })
160
194
  }, [
161
- g(i(R), {
162
- items: Object.values(a.categories)
195
+ k(o(ae), {
196
+ items: Object.values(a.categories).map((i) => ({
197
+ ...i,
198
+ color: Array.isArray(i.color) ? i.color[0] : i.color
199
+ }))
163
200
  }, null, 8, ["items"])
164
201
  ], 4)),
165
- O("div", U, [
166
- i(G).tooltip ? B(e.$slots, "tooltip", {
202
+ j("div", re, [
203
+ o(w).tooltip ? C(e.$slots, "tooltip", {
167
204
  key: 0,
168
- values: r.value
169
- }) : r.value ? B(e.$slots, "fallback", { key: 1 }, () => [
170
- g(q, {
171
- data: r.value,
205
+ values: s.value
206
+ }) : s.value ? C(e.$slots, "fallback", { key: 1 }, () => [
207
+ k(oe, {
208
+ data: s.value,
172
209
  categories: a.categories,
173
- toolTipTitle: i(H)(r.value) ?? "",
174
- yFormatter: a.orientation === i(l).Horizontal ? a.xFormatter : a.yFormatter
210
+ toolTipTitle: o(J)(s.value) ?? "",
211
+ yFormatter: a.orientation === o(p).Horizontal ? a.xFormatter : a.yFormatter
175
212
  }, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
176
213
  ]) : m("", !0)
177
214
  ], 512)
@@ -179,5 +216,5 @@ const U = {
179
216
  }
180
217
  });
181
218
  export {
182
- ae as default
219
+ ce as default
183
220
  };
@@ -7,7 +7,7 @@ declare const _default: <T extends {}>(__VLS_props: NonNullable<Awaited<typeof _
7
7
  attrs: any;
8
8
  slots: {
9
9
  tooltip?(_: {
10
- values: any;
10
+ values: T | undefined;
11
11
  }): any;
12
12
  fallback?(_: {}): any;
13
13
  };
@@ -2,7 +2,7 @@ import { ComputedRef } from 'vue';
2
2
  export interface StackedGroupedConfig<T> {
3
3
  data: T[];
4
4
  categories: Record<string, {
5
- color?: string;
5
+ color?: string | Array<string>;
6
6
  }>;
7
7
  stackAndGrouped: boolean;
8
8
  xAxis?: keyof T;
@@ -2,11 +2,11 @@ import { computed as u } from "vue";
2
2
  import { flattenData as i } from "../../utils.js";
3
3
  function g(t) {
4
4
  return u(() => {
5
- const e = p(t.categories), o = f(t.categories, e), r = d(o, t.categories), c = l(o), n = m(r), s = h(e, t.spacing), a = t.stackAndGrouped ? i(t.data, t.xAxis) : t.data;
5
+ const r = f(t.categories), e = p(t.categories, r), o = l(e, t.categories), c = d(e), n = m(o), s = y(r, t.spacing), a = t.stackAndGrouped ? i(t.data, t.xAxis) : t.data;
6
6
  return {
7
- states: e,
8
- groupedByState: o,
9
- colors: r,
7
+ states: r,
8
+ groupedByState: e,
9
+ colors: o,
10
10
  bars: c,
11
11
  colorFunctions: n,
12
12
  positions: s,
@@ -14,51 +14,52 @@ function g(t) {
14
14
  };
15
15
  });
16
16
  }
17
- function p(t) {
18
- const e = /* @__PURE__ */ new Set();
19
- return Object.keys(t).forEach((r) => {
20
- const c = r.match(/([A-Z][a-z]+)$/);
21
- c && e.add(c[1]);
22
- }), Array.from(e);
17
+ function f(t) {
18
+ const r = /* @__PURE__ */ new Set();
19
+ return Object.keys(t).forEach((o) => {
20
+ const c = o.match(/([A-Z][a-z]+)$/);
21
+ c && r.add(c[1]);
22
+ }), Array.from(r);
23
23
  }
24
- function f(t, e) {
25
- const o = {};
26
- return e.forEach((r) => {
27
- o[r] = Object.keys(t).filter(
28
- (c) => c.endsWith(r)
24
+ function p(t, r) {
25
+ const e = {};
26
+ return r.forEach((o) => {
27
+ e[o] = Object.keys(t).filter(
28
+ (c) => c.endsWith(o)
29
29
  );
30
- }), o;
31
- }
32
- function d(t, e) {
33
- const o = {};
34
- return Object.entries(t).forEach(([r, c]) => {
35
- o[r] = c.map((n) => {
36
- var s;
37
- return ((s = e[n]) == null ? void 0 : s.color) ?? "#ccc";
38
- });
39
- }), o;
30
+ }), e;
40
31
  }
41
- function l(t) {
32
+ function l(t, r) {
42
33
  const e = {};
43
- return Object.entries(t).forEach(([o, r]) => {
44
- e[o] = r.map((c) => {
45
- const n = c.replace(o, "").toLowerCase();
46
- return (s) => s[n + o];
34
+ return Object.entries(t).forEach(([o, c]) => {
35
+ e[o] = c.map((n) => {
36
+ var a;
37
+ const s = (a = r[n]) == null ? void 0 : a.color;
38
+ return Array.isArray(s) ? s[0] ?? "#ccc" : s ?? "#ccc";
47
39
  });
48
40
  }), e;
49
41
  }
42
+ function d(t) {
43
+ const r = {};
44
+ return Object.entries(t).forEach(([e, o]) => {
45
+ r[e] = o.map((c) => {
46
+ const n = c.replace(e, "").toLowerCase();
47
+ return (s) => s[n + e];
48
+ });
49
+ }), r;
50
+ }
50
51
  function m(t) {
51
- const e = {};
52
- return Object.entries(t).forEach(([o, r]) => {
53
- e[o] = (c, n) => r[n] ?? "#ccc";
54
- }), e;
52
+ const r = {};
53
+ return Object.entries(t).forEach(([e, o]) => {
54
+ r[e] = (c, n) => o[n] ?? "#ccc";
55
+ }), r;
55
56
  }
56
- function h(t, e = 0.4) {
57
- const o = t.length, r = {};
57
+ function y(t, r = 0.4) {
58
+ const e = t.length, o = {};
58
59
  return t.forEach((c, n) => {
59
- const s = (n - (o - 1) / 2) * e;
60
- r[c] = s;
61
- }), r;
60
+ const s = (n - (e - 1) / 2) * r;
61
+ o[c] = s;
62
+ }), o;
62
63
  }
63
64
  export {
64
65
  g as useStackedGrouped
@@ -66,7 +66,7 @@ type BarChartPropsBase<T> = {
66
66
  /**
67
67
  * Force specific ticks on the x-axis.
68
68
  */
69
- xExplicitTicks?: number;
69
+ xExplicitTicks?: (number | string | Date)[];
70
70
  /**
71
71
  * An array of property keys from the data object type 'T' to be used for the y-axis values.
72
72
  */
@@ -133,23 +133,35 @@ type BarChartPropsBase<T> = {
133
133
  * If `true`, hide the y-axis.
134
134
  */
135
135
  hideYAxis?: boolean;
136
+ /**
137
+ * Specific spacing between stacked and grouped bars in pixels.
138
+ * Only applicable if `stackAndGrouped` is `true`.
139
+ */
136
140
  stackedGroupedSpacing?: number;
137
141
  };
138
- type BarChartPropsStackAndGrouped<T> = BarChartPropsBase<T> & {
139
- stackAndGrouped: true;
142
+ export type BarChartProps<T> = BarChartPropsBase<T> & {
140
143
  /**
141
- * The key in the data object type 'T' to be used for the x-axis values.
142
- * Required when stackAndGrouped is true.
144
+ * Whether the bars should be stacked and grouped.
145
+ * If true, `valueLabel` is optional and `xAxis` is required.
143
146
  */
144
- xAxis: keyof T;
145
- };
146
- type BarChartPropsNormal<T> = BarChartPropsBase<T> & {
147
- stackAndGrouped?: false;
147
+ stackAndGrouped?: boolean;
148
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.
149
+ * Configuration for the value label display.
150
+ * Required if `stackAndGrouped` is false and `xAxis` is present.
151
+ * Optional otherwise.
152
+ */
153
+ valueLabel?: ValueLabel;
154
+ /**
155
+ * The data key for the X-axis.
156
+ * Required if `stackAndGrouped` is true, or if `stackAndGrouped` is false AND `valueLabel` is present.
151
157
  */
152
158
  xAxis?: keyof T;
153
159
  };
154
- export type BarChartProps<T> = BarChartPropsStackAndGrouped<T> | BarChartPropsNormal<T>;
160
+ export type ValueLabel = {
161
+ label: (d: any, index: number) => string | number;
162
+ labelSpacing?: number;
163
+ backgroundColor?: string;
164
+ color?: string;
165
+ labelFontSize?: number;
166
+ };
155
167
  export {};
@@ -1,19 +1,16 @@
1
- import { defineComponent as z, useSlots as P, useTemplateRef as N, ref as O, computed as R, createElementBlock as c, openBlock as a, Fragment as j, createCommentVNode as r, createVNode as s, createElementVNode as w, unref as t, withCtx as D, createBlock as u, renderSlot as g } from "vue";
2
- import { Scatter as K, Position as M } from "@unovis/ts";
3
- import { VisBulletLegend as k, VisXYContainer as S, VisTooltip as E, VisScatter as G, VisAxis as x } from "@unovis/vue";
4
- import { LegendPosition as d } from "../../types.js";
5
- import { getFirstPropertyValue as $ } from "../../utils.js";
6
- import W from "../Tooltip.js";
7
- const X = {
1
+ import { defineComponent as C, useSlots as z, useTemplateRef as P, ref as _, createElementBlock as m, openBlock as n, Fragment as N, createCommentVNode as l, createVNode as s, createElementVNode as O, unref as t, withCtx as R, createBlock as c, renderSlot as p } from "vue";
2
+ import { Scatter as w, Position as D } from "@unovis/ts";
3
+ import { VisBulletLegend as K, VisXYContainer as M, VisTooltip as S, VisScatter as E, VisAxis as f } from "@unovis/vue";
4
+ import { LegendPosition as g } from "../../types.js";
5
+ import { getFirstPropertyValue as G } from "../../utils.js";
6
+ import $ from "../Tooltip.js";
7
+ const j = {
8
8
  key: 0,
9
9
  class: "flex items-center justify-end pb-4"
10
- }, Y = {
11
- key: 1,
12
- class: "flex items-center justify-end pt-4"
13
- }, q = {
10
+ }, W = {
14
11
  ref: "slotWrapper",
15
12
  class: "hidden"
16
- }, ee = /* @__PURE__ */ z({
13
+ }, J = /* @__PURE__ */ C({
17
14
  __name: "BubbleChart",
18
15
  props: {
19
16
  xAccessor: {},
@@ -34,7 +31,7 @@ const X = {
34
31
  categoryKey: {},
35
32
  xFormatter: {},
36
33
  yFormatter: {},
37
- legendPosition: { default: d.Bottom },
34
+ legendPosition: { default: g.Bottom },
38
35
  sizeOptions: {},
39
36
  xDomainLine: { type: Boolean, default: !0 },
40
37
  yDomainLine: { type: Boolean, default: !0 },
@@ -52,51 +49,60 @@ const X = {
52
49
  }) }
53
50
  },
54
51
  emits: ["click"],
55
- setup(L, { emit: h }) {
56
- const e = L, T = P(), m = N("slotWrapper"), o = O(), y = R(() => e.categories && typeof e.categories == "object" && !Array.isArray(e.categories) ? Object.values(e.categories) : Array.isArray(e.categories) ? e.categories : []), b = e.xAccessor, B = e.yAccessor, v = e.sizeAccessor || ((i) => typeof i.comments == "number" ? i.comments : 1), A = (i) => {
57
- var p, f;
52
+ setup(k, { emit: x }) {
53
+ const e = k, L = z(), u = P("slotWrapper"), a = _(), T = e.xAccessor, h = e.yAccessor, b = e.sizeAccessor || ((o) => typeof o.comments == "number" ? o.comments : 1), B = (o) => {
54
+ var d, y;
58
55
  if (!e.categories || !e.categoryKey)
59
- return console.warn("BubbleChart: categories and categoryKey are required for color mapping"), "#cccccc";
60
- const n = String(i[e.categoryKey]);
61
- let l = (p = e.categories[n]) == null ? void 0 : p.color;
62
- return Object.keys(e.categories).length === 1 && (l = (f = e.categories[e.categoryKey]) == null ? void 0 : f.color), l || (console.warn(`BubbleChart: No color defined for category "${n}"`), "#cccccc");
63
- }, F = h;
64
- function V(i) {
65
- return o.value = i, C();
56
+ return console.warn(
57
+ "BubbleChart: categories and categoryKey are required for color mapping"
58
+ ), "#cccccc";
59
+ const r = String(o[e.categoryKey]);
60
+ let i = (d = e.categories[r]) == null ? void 0 : d.color;
61
+ return Object.keys(e.categories).length === 1 && (i = (y = e.categories[e.categoryKey]) == null ? void 0 : y.color), i || (console.warn(
62
+ `BubbleChart: No color defined for category "${r}"`
63
+ ), "#cccccc");
64
+ }, v = x;
65
+ function A(o) {
66
+ return a.value = o, F();
66
67
  }
67
- function C(i) {
68
- return typeof window > "u" ? "" : m.value ? m.value.innerHTML : "";
68
+ function F(o) {
69
+ return typeof window > "u" ? "" : u.value ? u.value.innerHTML : "";
69
70
  }
70
- const _ = {
71
- [K.selectors.point]: V
71
+ const V = {
72
+ [w.selectors.point]: A
72
73
  };
73
- return (i, n) => (a(), c(j, null, [
74
- !e.hideLegend && e.legendPosition === t(d).Top ? (a(), c("div", X, [
75
- s(t(k), { items: y.value }, null, 8, ["items"])
76
- ])) : r("", !0),
77
- s(t(S), {
74
+ return (o, r) => (n(), m(N, null, [
75
+ !e.hideLegend && e.legendPosition === t(g).Top ? (n(), m("div", j, [
76
+ s(t(K), {
77
+ items: Object.values(e.categories).map((i) => ({
78
+ ...i,
79
+ color: Array.isArray(i.color) ? i.color[0] : i.color
80
+ }))
81
+ }, null, 8, ["items"])
82
+ ])) : l("", !0),
83
+ s(t(M), {
78
84
  data: e.data,
79
85
  height: e.height || 600,
80
86
  padding: e.padding,
81
87
  scaleByDomain: !0,
82
- onClick: n[0] || (n[0] = (l) => F("click", l, o.value))
88
+ onClick: r[0] || (r[0] = (i) => v("click", i, a.value))
83
89
  }, {
84
- default: D(() => [
85
- e.hideTooltip ? r("", !0) : (a(), u(t(E), {
90
+ default: R(() => [
91
+ e.hideTooltip ? l("", !0) : (n(), c(t(S), {
86
92
  key: 0,
87
- triggers: _
93
+ triggers: V
88
94
  })),
89
- s(t(G), {
90
- x: t(b),
91
- y: t(B),
92
- color: A,
93
- size: t(v),
94
- labelPosition: e.labelPosition || t(M).Bottom,
95
+ s(t(E), {
96
+ x: t(T),
97
+ y: t(h),
98
+ color: B,
99
+ size: t(b),
100
+ labelPosition: e.labelPosition || t(D).Bottom,
95
101
  sizeRange: e.sizeRange || [1, 20],
96
102
  opacity: e.opacity,
97
103
  cursor: "pointer"
98
104
  }, null, 8, ["x", "y", "size", "labelPosition", "sizeRange", "opacity"]),
99
- e.hideXAxis ? r("", !0) : (a(), u(t(x), {
105
+ e.hideXAxis ? l("", !0) : (n(), c(t(f), {
100
106
  key: 1,
101
107
  type: "x",
102
108
  label: e.xLabel,
@@ -108,7 +114,7 @@ const X = {
108
114
  tickValues: e.xExplicitTicks,
109
115
  minMaxTicksOnly: e.minMaxTicksOnly
110
116
  }, null, 8, ["label", "tickFormat", "gridLine", "domainLine", "tickLine", "numTicks", "tickValues", "minMaxTicksOnly"])),
111
- e.hideYAxis ? r("", !0) : (a(), u(t(x), {
117
+ e.hideYAxis ? l("", !0) : (n(), c(t(f), {
112
118
  key: 2,
113
119
  type: "y",
114
120
  label: e.yLabel,
@@ -121,25 +127,22 @@ const X = {
121
127
  ]),
122
128
  _: 1
123
129
  }, 8, ["data", "height", "padding"]),
124
- !e.hideLegend && e.legendPosition === t(d).Bottom ? (a(), c("div", Y, [
125
- s(t(k), { items: y.value }, null, 8, ["items"])
126
- ])) : r("", !0),
127
- w("div", q, [
128
- t(T).tooltip ? g(i.$slots, "tooltip", {
130
+ O("div", W, [
131
+ t(L).tooltip ? p(o.$slots, "tooltip", {
129
132
  key: 0,
130
- values: o.value
131
- }) : o.value ? g(i.$slots, "fallback", { key: 1 }, () => [
132
- s(W, {
133
- data: o.value,
133
+ values: a.value
134
+ }) : a.value ? p(o.$slots, "fallback", { key: 1 }, () => [
135
+ s($, {
136
+ data: a.value,
134
137
  categories: e.categories || {},
135
- toolTipTitle: t($)(o.value) ?? "",
138
+ toolTipTitle: t(G)(a.value) ?? "",
136
139
  yFormatter: e.yFormatter
137
140
  }, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
138
- ]) : r("", !0)
141
+ ]) : l("", !0)
139
142
  ], 512)
140
143
  ], 64));
141
144
  }
142
145
  });
143
146
  export {
144
- ee as default
147
+ J as default
145
148
  };
@@ -1,4 +1,4 @@
1
- import { defineComponent as P, computed as f, useSlots as O, useTemplateRef as j, ref as w, createElementBlock as p, openBlock as n, normalizeClass as x, normalizeStyle as k, createVNode as s, createCommentVNode as a, createElementVNode as M, unref as i, withCtx as W, createBlock as m, Fragment as z, renderList as E, mergeProps as G, renderSlot as h } from "vue";
1
+ import { defineComponent as N, computed as f, useSlots as P, useTemplateRef as O, ref as j, createElementBlock as p, openBlock as a, normalizeClass as w, normalizeStyle as k, createVNode as m, createCommentVNode as r, createElementVNode as M, unref as i, withCtx as W, createBlock as d, Fragment as z, renderList as E, mergeProps as G, renderSlot as h } from "vue";
2
2
  import { Position as v, CurveType as X } from "@unovis/ts";
3
3
  import { createMarkers as $, getFirstPropertyValue as R } from "../../utils.js";
4
4
  import S from "../Tooltip.js";
@@ -7,7 +7,7 @@ import { LegendPosition as J } from "../../types.js";
7
7
  const Q = {
8
8
  ref: "slotWrapper",
9
9
  style: { display: "none" }
10
- }, oe = /* @__PURE__ */ P({
10
+ }, te = /* @__PURE__ */ N({
11
11
  __name: "LineChart",
12
12
  props: {
13
13
  data: {},
@@ -27,10 +27,10 @@ const Q = {
27
27
  curveType: {},
28
28
  lineWidth: { default: 2 },
29
29
  lineDashArray: {},
30
- xNumTicks: { default: (o) => o.data.length > 24 ? 24 / 4 : o.data.length - 1 },
30
+ xNumTicks: { default: (n) => n.data.length > 24 ? 24 / 4 : n.data.length - 1 },
31
31
  xExplicitTicks: {},
32
32
  minMaxTicksOnly: { type: Boolean },
33
- yNumTicks: { default: (o) => o.data.length > 24 ? 24 / 4 : o.data.length - 1 },
33
+ yNumTicks: { default: (n) => n.data.length > 24 ? 24 / 4 : n.data.length - 1 },
34
34
  hideTooltip: { type: Boolean },
35
35
  hideLegend: { type: Boolean },
36
36
  legendPosition: {},
@@ -44,52 +44,56 @@ const Q = {
44
44
  hideYAxis: { type: Boolean },
45
45
  crosshairConfig: { default: () => ({
46
46
  color: "#666"
47
- }) }
47
+ }) },
48
+ yDomain: {},
49
+ xDomain: {}
48
50
  },
49
51
  emits: ["click"],
50
- setup(o, { emit: L }) {
51
- const C = L, t = o, B = f(() => t.markerConfig ? $(t.markerConfig) : ""), b = O(), c = j("slotWrapper"), l = w();
52
- function D(e) {
52
+ setup(n, { emit: L }) {
53
+ const D = L, o = n, C = f(() => o.markerConfig ? $(o.markerConfig) : ""), B = P(), c = O("slotWrapper"), l = j();
54
+ function b(e) {
53
55
  return typeof window > "u" ? "" : c.value ? c.value.innerHTML : "";
54
56
  }
55
- function V(e) {
56
- return l.value = e, D();
57
+ function A(e) {
58
+ return l.value = e, b();
57
59
  }
58
60
  const y = f(
59
- () => t.legendPosition === J.Top
60
- ), A = Object.values(t.categories).map(
61
- (e, r) => `var(--vis-color${r})`
62
- ), F = (e) => Object.values(t.categories)[e].color ?? A[e];
63
- return (e, r) => (n(), p("div", {
61
+ () => o.legendPosition === J.Top
62
+ ), V = Object.values(o.categories).map(
63
+ (e, s) => `var(--vis-color${s})`
64
+ ), F = (e) => Object.values(o.categories)[e].color ?? V[e];
65
+ return (e, s) => (a(), p("div", {
64
66
  style: k({
65
67
  display: "flex",
66
68
  flexDirection: y.value ? "column-reverse" : "column",
67
69
  gap: "1rem"
68
70
  }),
69
- class: x({ markers: !!t.markerConfig }),
70
- onClick: r[0] || (r[0] = (d) => C("click", d, l.value))
71
+ class: w({ markers: !!o.markerConfig }),
72
+ onClick: s[0] || (s[0] = (t) => D("click", t, l.value))
71
73
  }, [
72
- s(i(Y), {
74
+ m(i(Y), {
73
75
  data: e.data,
74
76
  padding: e.padding,
75
77
  height: e.height,
76
- svgDefs: B.value
78
+ svgDefs: C.value,
79
+ yDomain: e.yDomain,
80
+ xDomain: e.xDomain
77
81
  }, {
78
82
  default: W(() => [
79
- s(i(H), {
83
+ m(i(H), {
80
84
  "horizontal-placement": i(v).Right,
81
85
  "vertical-placement": i(v).Top
82
86
  }, null, 8, ["horizontal-placement", "vertical-placement"]),
83
- (n(!0), p(z, null, E(Object.keys(t.categories), (d, u) => (n(), m(i(I), {
87
+ (a(!0), p(z, null, E(Object.keys(o.categories), (t, u) => (a(), d(i(I), {
84
88
  key: u,
85
- x: (g, N) => N,
86
- y: (g) => g[d],
89
+ x: (g, x) => x,
90
+ y: (g) => g[t],
87
91
  color: F(u),
88
92
  "curve-type": e.curveType ?? i(X).MonotoneX,
89
93
  "line-width": e.lineWidth,
90
94
  lineDashArray: e.lineDashArray ? e.lineDashArray[u] : void 0
91
95
  }, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"]))), 128)),
92
- e.hideXAxis ? a("", !0) : (n(), m(i(T), {
96
+ e.hideXAxis ? r("", !0) : (a(), d(i(T), {
93
97
  key: 0,
94
98
  type: "x",
95
99
  "tick-format": e.xFormatter,
@@ -102,7 +106,7 @@ const Q = {
102
106
  "tick-values": e.xExplicitTicks,
103
107
  "min-max-ticks-only": e.minMaxTicksOnly
104
108
  }, null, 8, ["tick-format", "label", "domain-line", "grid-line", "tick-line", "num-ticks", "tick-values", "min-max-ticks-only"])),
105
- e.hideYAxis ? a("", !0) : (n(), m(i(T), {
109
+ e.hideYAxis ? r("", !0) : (a(), d(i(T), {
106
110
  key: 1,
107
111
  type: "y",
108
112
  "tick-format": e.yFormatter,
@@ -112,11 +116,11 @@ const Q = {
112
116
  "grid-line": e.yGridLine,
113
117
  "tick-line": e.yTickLine
114
118
  }, null, 8, ["tick-format", "label", "num-ticks", "domain-line", "grid-line", "tick-line"])),
115
- e.hideTooltip ? a("", !0) : (n(), m(i(U), G({ key: 2 }, e.crosshairConfig, { template: V }), null, 16))
119
+ e.hideTooltip ? r("", !0) : (a(), d(i(U), G({ key: 2 }, e.crosshairConfig, { template: A }), null, 16))
116
120
  ]),
117
121
  _: 1
118
- }, 8, ["data", "padding", "height", "svgDefs"]),
119
- e.hideLegend ? a("", !0) : (n(), p("div", {
122
+ }, 8, ["data", "padding", "height", "svgDefs", "yDomain", "xDomain"]),
123
+ e.hideLegend ? r("", !0) : (a(), p("div", {
120
124
  key: 0,
121
125
  style: k({
122
126
  display: "flex",
@@ -125,26 +129,29 @@ const Q = {
125
129
  paddingBottom: y.value ? "1rem" : void 0
126
130
  })
127
131
  }, [
128
- s(i(q), {
129
- items: Object.values(e.categories)
132
+ m(i(q), {
133
+ items: Object.values(o.categories).map((t) => ({
134
+ ...t,
135
+ color: Array.isArray(t.color) ? t.color[0] : t.color
136
+ }))
130
137
  }, null, 8, ["items"])
131
138
  ], 4)),
132
139
  M("div", Q, [
133
- i(b).tooltip ? h(e.$slots, "tooltip", {
140
+ i(B).tooltip ? h(e.$slots, "tooltip", {
134
141
  key: 0,
135
142
  values: l.value
136
143
  }) : l.value ? h(e.$slots, "fallback", { key: 1 }, () => [
137
- s(S, {
144
+ m(S, {
138
145
  data: l.value,
139
146
  categories: e.categories,
140
147
  toolTipTitle: i(R)(l.value) ?? "",
141
- yFormatter: t.yFormatter
148
+ yFormatter: o.yFormatter
142
149
  }, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
143
- ]) : a("", !0)
150
+ ]) : r("", !0)
144
151
  ], 512)
145
152
  ], 6));
146
153
  }
147
154
  });
148
155
  export {
149
- oe as default
156
+ te as default
150
157
  };
@@ -71,7 +71,7 @@ export interface LineChartProps<T> {
71
71
  /**
72
72
  * Force specific ticks on the x-axis.
73
73
  */
74
- xExplicitTicks?: number;
74
+ xExplicitTicks?: (number | string | Date)[];
75
75
  /**
76
76
  * Force only first and last ticks on the x-axis.
77
77
  */
@@ -129,4 +129,12 @@ export interface LineChartProps<T> {
129
129
  * Crosshair configuration object for customizing the appearance of the crosshair line.
130
130
  */
131
131
  crosshairConfig?: CrosshairConfig;
132
+ /**
133
+ * The domain for the y-axis, specified as a tuple of two values.
134
+ */
135
+ yDomain?: [number | undefined, number | undefined];
136
+ /**
137
+ * The domain for the x-axis, specified as a tuple of two values.
138
+ */
139
+ xDomain?: [number | undefined, number | undefined];
132
140
  }
@@ -1,11 +1,11 @@
1
- import { defineComponent as v, computed as y, 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 f = { style: { padding: "10px 15px" } }, x = { style: {
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
3
  color: "var(--tooltip-value-color)",
4
4
  textTransform: "capitalize",
5
5
  borderBottom: "1px solid rgba(255, 255, 255, 0.05)",
6
6
  marginBottom: "0.25rem",
7
7
  paddingBottom: "0.25rem"
8
- } }, B = /* @__PURE__ */ v({
8
+ } }, T = /* @__PURE__ */ y({
9
9
  __name: "Tooltip",
10
10
  props: {
11
11
  data: {},
@@ -13,21 +13,21 @@ const f = { style: { padding: "10px 15px" } }, x = { style: {
13
13
  toolTipTitle: {},
14
14
  yFormatter: { type: Function }
15
15
  },
16
- setup(c) {
17
- const a = c, d = ["_index", "_stacked", "_ending"], m = y(() => Object.entries(a.data ?? []).filter(
18
- ([t, g]) => !d.includes(t) && Object.keys(a.categories).includes(t)
16
+ setup(d) {
17
+ const a = d, m = ["_index", "_stacked", "_ending"], g = f(() => Object.entries(a.data ?? []).filter(
18
+ ([t, u]) => !m.includes(t) && Object.keys(a.categories).includes(t)
19
19
  ));
20
- return (t, g) => (i(), r("div", f, [
21
- e("div", x, l(t.toolTipTitle), 1),
22
- (i(!0), r(h, null, b(m.value, ([o, s], u) => {
23
- var p;
20
+ return (t, u) => (i(), r("div", x, [
21
+ e("div", _, l(t.toolTipTitle), 1),
22
+ (i(!0), r(h, null, b(g.value, ([o, s], v) => {
23
+ var p, c;
24
24
  return i(), r("div", {
25
25
  key: o,
26
26
  style: { display: "flex", "align-items": "center", "margin-bottom": "4px" }
27
27
  }, [
28
28
  e("span", {
29
29
  style: n([{ width: "8px", height: "8px", "border-radius": "4px", "margin-right": "8px" }, {
30
- backgroundColor: (p = t.categories[o]) != null && p.color ? t.categories[o].color : `var(--vis-color${u})`
30
+ backgroundColor: typeof ((p = t.categories[o]) == null ? void 0 : p.color) == "string" && ((c = t.categories[o]) != null && c.color) ? t.categories[o].color : `var(--vis-color${v})`
31
31
  }])
32
32
  }, null, 4),
33
33
  e("div", null, [
@@ -44,5 +44,5 @@ const f = { style: { padding: "10px 15px" } }, x = { style: {
44
44
  }
45
45
  });
46
46
  export {
47
- B as default
47
+ T as default
48
48
  };
package/dist/types.d.ts CHANGED
@@ -29,7 +29,7 @@ declare enum CurveType {
29
29
  }
30
30
  interface BulletLegendItemInterface {
31
31
  name: string | number;
32
- color?: string;
32
+ color?: string | Array<string>;
33
33
  className?: string;
34
34
  shape?: any;
35
35
  inactive?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-chrts",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -28,8 +28,8 @@
28
28
  "@tanstack/vue-table": "^8.21.2",
29
29
  "@types/node": "^22.13.11",
30
30
  "@types/rollup": "^0.54.0",
31
- "@unovis/ts": "^1.5.2",
32
- "@unovis/vue": "^1.5.2",
31
+ "@unovis/ts": "^1.6.1",
32
+ "@unovis/vue": "^1.6.1",
33
33
  "@vitejs/plugin-vue": "^5.2.1",
34
34
  "@vue/tsconfig": "^0.7.0",
35
35
  "@vueuse/core": "^13.0.0",