vue-chrts 0.1.2 → 0.1.4

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.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Vue-Chrts
1
+ # Vue-chrts
2
2
 
3
3
  A Vue 3 charts package inspired by [Tremor](https://tremor.so/), built on top of [Unovis](https://unovis.dev). Vue-Chrts provides beautiful, responsive charts for your Vue applications with minimal setup.
4
4
 
@@ -1,9 +1,9 @@
1
- import { defineComponent as E, ref as T, computed as f, createApp as N, onUnmounted as P, createElementBlock as u, openBlock as l, normalizeClass as L, createVNode as s, createCommentVNode as g, unref as o, withCtx as M, createBlock as h, Fragment as b, renderList as U, mergeProps as j } from "vue";
2
- import { Position as C, CurveType as x } from "@unovis/ts";
3
- import { VisXYContainer as I, VisTooltip as S, VisArea as w, VisLine as z, VisAxis as B, VisCrosshair as R, VisBulletLegend as X } from "@unovis/vue";
1
+ import { defineComponent as G, ref as T, computed as f, createApp as N, onUnmounted as P, createElementBlock as u, openBlock as l, normalizeClass as L, createVNode as s, createCommentVNode as g, unref as o, withCtx as M, createBlock as h, Fragment as b, renderList as U, mergeProps as j } from "vue";
2
+ import { Position as C, CurveType as B } from "@unovis/ts";
3
+ import { VisXYContainer as I, VisTooltip as S, VisArea as w, VisLine as z, VisAxis as x, VisCrosshair as R, VisBulletLegend as X } from "@unovis/vue";
4
4
  import Y from "../Tooltip.js";
5
5
  import { LegendPosition as H } from "../../types.js";
6
- const p = 24, V = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ E({
6
+ const p = 24, V = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
7
7
  __name: "AreaChart",
8
8
  props: {
9
9
  data: {},
@@ -20,15 +20,16 @@ const p = 24, V = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ E({
20
20
  yNumTicks: { default: (i) => i.data.length > p ? p / V : i.data.length - 1 },
21
21
  hideLegend: { type: Boolean },
22
22
  hideTooltip: { type: Boolean },
23
- xGridLine: { type: Boolean },
23
+ legendPosition: {},
24
24
  xDomainLine: { type: Boolean },
25
- yGridLine: { type: Boolean },
26
25
  yDomainLine: { type: Boolean },
27
26
  xTickLine: { type: Boolean },
28
- legendPosition: {}
27
+ yTickLine: { type: Boolean },
28
+ xGridLine: { type: Boolean },
29
+ yGridLine: { type: Boolean }
29
30
  },
30
31
  setup(i) {
31
- const r = i, m = Object.values(r.categories).map((e) => e.color), d = T(null), v = T(null), D = f(() => (e, t) => {
32
+ const r = i, m = Object.values(r.categories).map((e) => e.color), d = T(null), k = T(null), D = f(() => (e, t) => {
32
33
  if (typeof window > "u" || typeof document > "u")
33
34
  return "";
34
35
  try {
@@ -45,7 +46,7 @@ const p = 24, V = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ E({
45
46
  }
46
47
  });
47
48
  P(() => {
48
- d.value && (d.value.unmount(), d.value = null), v.value && (v.value = null);
49
+ d.value && (d.value.unmount(), d.value = null), k.value && (k.value = null);
49
50
  });
50
51
  function F(e) {
51
52
  var t;
@@ -62,7 +63,7 @@ const p = 24, V = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ E({
62
63
  </linearGradient>
63
64
  `;
64
65
  }
65
- function G(e, t) {
66
+ function $(e, t) {
66
67
  return `
67
68
  <linearGradient id="gradient${e}-${t}" gradientTransform="rotate(90)">
68
69
  <stop offset="0%" stop-color="${t}" stop-opacity="1" />
@@ -70,20 +71,20 @@ const p = 24, V = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ E({
70
71
  </linearGradient>
71
72
  `;
72
73
  }
73
- const $ = f(
74
+ const E = f(
74
75
  () => m.map(
75
- (e, t) => e != null && e.includes("#") ? G(t, e) : O(t, e ?? A)
76
+ (e, t) => e != null && e.includes("#") ? $(t, e) : O(t, e ?? A)
76
77
  ).join("")
77
- ), k = f(
78
+ ), v = f(
78
79
  () => r.legendPosition === H.Top
79
80
  );
80
81
  return (e, t) => (l(), u("div", {
81
- class: L(["flex flex-col space-y-4", { "flex-col-reverse": k.value }])
82
+ class: L(["flex flex-col space-y-4", { "flex-col-reverse": v.value }])
82
83
  }, [
83
84
  s(o(I), {
84
85
  data: e.data,
85
86
  height: e.height,
86
- "svg-defs": $.value
87
+ "svg-defs": E.value
87
88
  }, {
88
89
  default: M(() => [
89
90
  e.hideTooltip ? g("", !0) : (l(), h(o(S), {
@@ -98,16 +99,16 @@ const p = 24, V = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ E({
98
99
  }, F(n), {
99
100
  color: `url(#gradient${a}-${o(m)[a]})`,
100
101
  opacity: q,
101
- "curve-type": e.curveType ?? o(x).MonotoneX
102
+ "curve-type": e.curveType ?? o(B).MonotoneX
102
103
  }), null, 16, ["x", "color", "curve-type"]),
103
104
  s(o(z), {
104
105
  x: (c, y) => y,
105
106
  y: (c) => c[n],
106
107
  color: o(m)[a],
107
- "curve-type": e.curveType ?? o(x).MonotoneX
108
+ "curve-type": e.curveType ?? o(B).MonotoneX
108
109
  }, null, 8, ["x", "y", "color", "curve-type"])
109
110
  ], 64))), 128)),
110
- s(o(B), {
111
+ s(o(x), {
111
112
  type: "x",
112
113
  "tick-format": e.xFormatter,
113
114
  label: e.xLabel,
@@ -119,14 +120,14 @@ const p = 24, V = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ E({
119
120
  "tick-values": e.xExplicitTicks,
120
121
  "min-max-ticks-only": e.minMaxTicksOnly
121
122
  }, null, 8, ["tick-format", "label", "domain-line", "grid-line", "num-ticks", "tick-line", "tick-values", "min-max-ticks-only"]),
122
- s(o(B), {
123
+ s(o(x), {
123
124
  type: "y",
124
125
  "num-ticks": e.yNumTicks,
125
126
  "tick-format": e.yFormatter,
126
127
  label: e.yLabel,
127
128
  "grid-line": e.yGridLine,
128
129
  "domain-line": e.yDomainLine,
129
- "tick-line": !!e.yGridLine
130
+ "tick-line": e.yTickLine
130
131
  }, null, 8, ["num-ticks", "tick-format", "label", "grid-line", "domain-line", "tick-line"]),
131
132
  e.hideTooltip ? g("", !0) : (l(), h(o(R), {
132
133
  key: 1,
@@ -138,7 +139,7 @@ const p = 24, V = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ E({
138
139
  }, 8, ["data", "height", "svg-defs"]),
139
140
  e.hideLegend ? g("", !0) : (l(), u("div", {
140
141
  key: 0,
141
- class: L(["flex items-center justify-end", { "pb-4": k.value }])
142
+ class: L(["flex items-center justify-end", { "pb-4": v.value }])
142
143
  }, [
143
144
  s(o(X), {
144
145
  items: Object.values(e.categories)
@@ -68,17 +68,14 @@ export interface AreaChartProps<T> {
68
68
  */
69
69
  hideTooltip?: boolean;
70
70
  /**
71
- * If `true`, displays grid lines along the x-axis.
71
+ * Optional position for the legend, if applicable.
72
+ * See `LegendPosition` for available options.
72
73
  */
73
- xGridLine?: boolean;
74
+ legendPosition?: LegendPosition;
74
75
  /**
75
76
  * If `true`, displays a domain line (axis line) along the x-axis.
76
77
  */
77
78
  xDomainLine?: boolean;
78
- /**
79
- * If `true`, displays grid lines along the y-axis.
80
- */
81
- yGridLine?: boolean;
82
79
  /**
83
80
  * If `true`, displays a domain line (axis line) along the y-axis.
84
81
  */
@@ -88,8 +85,15 @@ export interface AreaChartProps<T> {
88
85
  */
89
86
  xTickLine?: boolean;
90
87
  /**
91
- * Optional position for the legend, if applicable.
92
- * See `LegendPosition` for available options.
88
+ * If `true`, displays tick lines on the y-axis.
93
89
  */
94
- legendPosition?: LegendPosition;
90
+ yTickLine?: boolean;
91
+ /**
92
+ * If `true`, displays grid lines along the x-axis.
93
+ */
94
+ xGridLine?: boolean;
95
+ /**
96
+ * If `true`, displays grid lines along the y-axis.
97
+ */
98
+ yGridLine?: boolean;
95
99
  }
@@ -66,11 +66,11 @@ export interface BarChartProps<T> {
66
66
  */
67
67
  groupPadding?: number;
68
68
  /**
69
- * The padding between bars within the same group in pixels.
69
+ * Fractional padding between the bars in the range of [0,1). Default: 0
70
70
  */
71
71
  barPadding?: number;
72
72
  /**
73
- * The corner radius of the bars in pixels.
73
+ * Rounded corners for top bars. Boolean or number (to set the radius in pixels). Default: 2
74
74
  */
75
75
  radius?: number;
76
76
  /**
@@ -1,44 +1,47 @@
1
1
  import { defineComponent as m, computed as b, createElementBlock as r, openBlock as l, createElementVNode as o, toDisplayString as i, Fragment as v, renderList as h, normalizeStyle as a } from "vue";
2
- const x = {
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__ */ m({
8
+ }, _ = /* @__PURE__ */ m({
9
9
  __name: "Tooltip",
10
10
  props: {
11
11
  data: {},
12
12
  categories: {},
13
13
  xValue: {}
14
14
  },
15
- setup(s) {
16
- const n = s, c = ["_index", "_stacked", "_ending"], p = b(() => Object.entries(n.data ?? []).filter(
17
- ([e, d]) => !c.includes(e) && Object.keys(n.categories).includes(e)
15
+ setup(c) {
16
+ const n = c, p = ["_index", "_stacked", "_ending"], d = b(() => Object.entries(n.data ?? []).filter(
17
+ ([e, u]) => !p.includes(e) && Object.keys(n.categories).includes(e)
18
18
  ));
19
- return (e, d) => (l(), r("div", null, [
20
- o("div", x, i(e.xValue), 1),
21
- (l(!0), r(v, null, h(p.value, ([t, u], g) => (l(), r("div", {
22
- key: t,
23
- style: { display: "flex", "align-items": "center", "margin-bottom": "4px" }
24
- }, [
25
- o("span", {
26
- style: a([{ width: "8px", height: "8px", "border-radius": "4px", "margin-right": "8px" }, {
27
- backgroundColor: e.categories[t].color ? e.categories[t].color : `var(--vis-color${g})`
28
- }])
29
- }, null, 4),
30
- o("div", null, [
19
+ return (e, u) => (l(), r("div", null, [
20
+ o("div", f, i(e.xValue), 1),
21
+ (l(!0), r(v, null, h(d.value, ([t, g]) => {
22
+ var s;
23
+ return l(), r("div", {
24
+ key: t,
25
+ style: { display: "flex", "align-items": "center", "margin-bottom": "4px" }
26
+ }, [
31
27
  o("span", {
32
- style: a([{ "font-weight": "600", "margin-right": "8px" }, { color: "var(--tooltip-label-color)" }])
33
- }, i(t) + ":", 1),
34
- o("span", {
35
- style: a([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
36
- }, i(u), 1)
37
- ])
38
- ]))), 128))
28
+ style: a([{ width: "8px", height: "8px", "border-radius": "4px", "margin-right": "8px" }, {
29
+ backgroundColor: (s = e.categories[t]) != null && s.color ? e.categories[t].color : "var(--vis-color0)"
30
+ }])
31
+ }, null, 4),
32
+ o("div", null, [
33
+ o("span", {
34
+ style: a([{ "font-weight": "600", "margin-right": "8px" }, { color: "var(--tooltip-label-color)" }])
35
+ }, i(e.categories[t].name) + ":", 1),
36
+ o("span", {
37
+ style: a([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
38
+ }, i(g), 1)
39
+ ])
40
+ ]);
41
+ }), 128))
39
42
  ]));
40
43
  }
41
44
  });
42
45
  export {
43
- f as default
46
+ _ as default
44
47
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-chrts",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"