vue-chrts 0.1.0-beta.5 → 0.1.0

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.
@@ -16,7 +16,7 @@ const m = 24, A = 4, Y = 0.5, H = "#3b82f6", Z = /* @__PURE__ */ E({
16
16
  curveType: {},
17
17
  xNumTicks: { default: (i) => i.data.length > m ? m / A : i.data.length - 1 },
18
18
  xExplicitTicks: {},
19
- minMaxTicksOnly: {},
19
+ minMaxTicksOnly: { type: Boolean },
20
20
  yNumTicks: { default: (i) => i.data.length > m ? m / A : i.data.length - 1 },
21
21
  hideLegend: { type: Boolean },
22
22
  hideTooltip: { type: Boolean },
@@ -54,7 +54,7 @@ export interface AreaChartProps<T> {
54
54
  /**
55
55
  * Force only first and last ticks on the x-axis.
56
56
  */
57
- minMaxTicksOnly?: number;
57
+ minMaxTicksOnly?: boolean;
58
58
  /**
59
59
  * The desired number of ticks on the y-axis.
60
60
  */
@@ -1,9 +1,9 @@
1
- import { defineComponent as b, computed as u, createApp as h, createElementBlock as y, openBlock as d, normalizeClass as k, createVNode as t, createCommentVNode as B, unref as i, withCtx as T, createBlock as f } from "vue";
2
- import { Orientation as s, StackedBar as v, GroupedBar as V } from "@unovis/ts";
3
- import { VisXYContainer as P, VisTooltip as x, VisGroupedBar as C, VisStackedBar as G, VisAxis as L, VisBulletLegend as N } from "@unovis/vue";
4
- import A from "../Tooltip.js";
5
- import { LegendPosition as O } from "../../types.js";
6
- const M = /* @__PURE__ */ b({
1
+ import { defineComponent as h, computed as u, createApp as b, createElementBlock as y, openBlock as d, normalizeClass as k, createVNode as r, createCommentVNode as B, unref as i, withCtx as T, createBlock as f } from "vue";
2
+ import { Orientation as s, StackedBar as v, GroupedBar as x } from "@unovis/ts";
3
+ import { VisXYContainer as V, VisTooltip as P, VisGroupedBar as A, VisStackedBar as C, VisAxis as L, VisBulletLegend as G } from "@unovis/vue";
4
+ import N from "../Tooltip.js";
5
+ import { LegendPosition as w } from "../../types.js";
6
+ const M = /* @__PURE__ */ h({
7
7
  __name: "BarChart",
8
8
  props: {
9
9
  data: {},
@@ -15,7 +15,7 @@ const M = /* @__PURE__ */ b({
15
15
  xFormatter: {},
16
16
  yFormatter: {},
17
17
  yNumTicks: { default: (a) => a.data.length > 24 ? 24 / 4 : a.data.length - 1 },
18
- minMaxTicksOnly: {},
18
+ minMaxTicksOnly: { type: Boolean },
19
19
  xNumTicks: { default: (a) => a.data.length > 24 ? 24 / 4 : a.data.length - 1 },
20
20
  xExplicitTicks: {},
21
21
  yAxis: {},
@@ -33,19 +33,22 @@ const M = /* @__PURE__ */ b({
33
33
  yGridLine: { type: Boolean, default: !0 }
34
34
  },
35
35
  setup(a) {
36
- const r = a, m = u(() => r.yAxis.map((e) => (n) => n[e])), c = (e, n) => Object.values(r.categories)[n].color, p = u(
37
- () => r.legendPosition === O.Top
36
+ const o = a;
37
+ if (!o.yAxis || o.yAxis.length === 0)
38
+ throw new Error("yAxis is required");
39
+ const c = u(() => o.yAxis.map((e) => (n) => n[e])), m = (e, n) => Object.values(o.categories)[n].color, p = u(
40
+ () => o.legendPosition === w.Top
38
41
  ), g = u(() => (e) => {
39
42
  if (typeof window > "u" || typeof document > "u")
40
43
  return "";
41
44
  try {
42
- const n = h(A, {
45
+ const n = b(N, {
43
46
  data: e,
44
- categories: r.categories
47
+ categories: o.categories
45
48
  }), l = document.createElement("div");
46
49
  n.mount(l);
47
- const o = l.innerHTML;
48
- return n.unmount(), o;
50
+ const t = l.innerHTML;
51
+ return n.unmount(), t;
49
52
  } catch {
50
53
  return "";
51
54
  }
@@ -53,36 +56,36 @@ const M = /* @__PURE__ */ b({
53
56
  return (e, n) => (d(), y("div", {
54
57
  class: k(["flex flex-col space-y-4", { "flex-col-reverse": p.value }])
55
58
  }, [
56
- t(i(P), { height: e.height }, {
59
+ r(i(V), { height: e.height }, {
57
60
  default: T(() => [
58
- t(i(x), {
61
+ r(i(P), {
59
62
  triggers: {
60
- [i(V).selectors.bar]: g.value,
63
+ [i(x).selectors.bar]: g.value,
61
64
  [i(v).selectors.bar]: g.value
62
65
  }
63
66
  }, null, 8, ["triggers"]),
64
- e.stacked ? (d(), f(i(G), {
67
+ e.stacked ? (d(), f(i(C), {
65
68
  key: 1,
66
69
  data: e.data,
67
- x: (l, o) => o,
68
- y: m.value,
69
- color: c,
70
+ x: (l, t) => t,
71
+ y: c.value,
72
+ color: m,
70
73
  "rounded-corners": e.radius ?? 0,
71
74
  "group-padding": e.groupPadding ?? 0,
72
75
  "bar-padding": e.barPadding ?? 0.2,
73
76
  orientation: e.orientation ?? i(s).Vertical
74
- }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (d(), f(i(C), {
77
+ }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (d(), f(i(A), {
75
78
  key: 0,
76
79
  data: e.data,
77
- x: (l, o) => o,
78
- y: m.value,
79
- color: c,
80
+ x: (l, t) => t,
81
+ y: c.value,
82
+ color: m,
80
83
  "rounded-corners": e.radius ?? 0,
81
84
  "group-padding": e.groupPadding ?? 0,
82
85
  "bar-padding": e.barPadding ?? 0.2,
83
86
  orientation: e.orientation ?? i(s).Vertical
84
87
  }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])),
85
- t(i(L), {
88
+ r(i(L), {
86
89
  type: "x",
87
90
  "tick-format": e.xFormatter,
88
91
  label: e.xLabel,
@@ -93,15 +96,15 @@ const M = /* @__PURE__ */ b({
93
96
  "tick-values": e.xExplicitTicks,
94
97
  "min-max-ticks-only": e.minMaxTicksOnly
95
98
  }, null, 8, ["tick-format", "label", "grid-line", "domain-line", "tick-line", "num-ticks", "tick-values", "min-max-ticks-only"]),
96
- t(i(L), {
99
+ r(i(L), {
97
100
  type: "y",
98
101
  label: e.yLabel,
99
102
  "grid-line": e.orientation !== i(s).Horizontal && e.yGridLine,
100
103
  "domain-line": !!e.yDomainLine,
101
- "tick-format": e.yFormatter,
104
+ "tick-format": () => "",
102
105
  "num-ticks": e.yNumTicks,
103
106
  "tick-line": e.yTickLine
104
- }, null, 8, ["label", "grid-line", "domain-line", "tick-format", "num-ticks", "tick-line"])
107
+ }, null, 8, ["label", "grid-line", "domain-line", "num-ticks", "tick-line"])
105
108
  ]),
106
109
  _: 1
107
110
  }, 8, ["height"]),
@@ -109,7 +112,7 @@ const M = /* @__PURE__ */ b({
109
112
  key: 0,
110
113
  class: k(["flex items center justify-end", { "pb-4": p.value }])
111
114
  }, [
112
- t(i(N), {
115
+ r(i(G), {
113
116
  items: Object.values(e.categories)
114
117
  }, null, 8, ["items"])
115
118
  ], 2))
@@ -48,7 +48,7 @@ export interface BarChartProps<T> {
48
48
  /**
49
49
  * Force only first and last ticks on the x-axis.
50
50
  */
51
- minMaxTicksOnly?: number;
51
+ minMaxTicksOnly?: boolean;
52
52
  /**
53
53
  * The desired number of ticks on the x-axis.
54
54
  */
@@ -16,7 +16,7 @@ const X = /* @__PURE__ */ v({
16
16
  curveType: {},
17
17
  xNumTicks: { default: (t) => t.data.length > 24 ? 24 / 4 : t.data.length - 1 },
18
18
  xExplicitTicks: {},
19
- minMaxTicksOnly: {},
19
+ minMaxTicksOnly: { type: Boolean },
20
20
  yNumTicks: { default: (t) => t.data.length > 24 ? 24 / 4 : t.data.length - 1 },
21
21
  hideTooltip: { type: Boolean },
22
22
  hideLegend: { type: Boolean },
@@ -53,7 +53,7 @@ export interface LineChartProps<T> {
53
53
  /**
54
54
  * Force only first and last ticks on the x-axis.
55
55
  */
56
- minMaxTicksOnly?: number;
56
+ minMaxTicksOnly?: boolean;
57
57
  /**
58
58
  * The desired number of ticks on the y-axis.
59
59
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-chrts",
3
- "version": "0.1.0-beta.5",
3
+ "version": "0.1.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"