vue-chrts 0.1.9 → 0.1.10

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,10 +1,9 @@
1
- import { defineComponent as A, computed as y, createApp as $, createElementBlock as c, openBlock as l, normalizeClass as T, createVNode as s, createCommentVNode as f, unref as o, withCtx as E, createBlock as k, Fragment as v, renderList as G, mergeProps as N } from "vue";
2
- import { Position as L, CurveType as h } 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 w from "../Tooltip.js";
5
- import { LegendPosition as z } from "../../types.js";
6
- import { getFirstPropertyValue as R } from "../../utils.js";
7
- const p = 24, C = 4, X = 0.5, B = "#3b82f6", Z = /* @__PURE__ */ A({
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 n, 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 V, VisCrosshair as R, VisBulletLegend as X } from "@unovis/vue";
4
+ import Y from "../Tooltip.js";
5
+ import { LegendPosition as H } from "../../types.js";
6
+ const p = 24, x = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ G({
8
7
  __name: "AreaChart",
9
8
  props: {
10
9
  data: {},
@@ -21,10 +20,10 @@ const p = 24, C = 4, X = 0.5, B = "#3b82f6", Z = /* @__PURE__ */ A({
21
20
  xFormatter: {},
22
21
  yFormatter: {},
23
22
  curveType: {},
24
- xNumTicks: { default: (i) => i.data.length > p ? p / C : i.data.length - 1 },
23
+ xNumTicks: { default: (i) => i.data.length > p ? p / x : i.data.length - 1 },
25
24
  xExplicitTicks: {},
26
25
  minMaxTicksOnly: { type: Boolean },
27
- yNumTicks: { default: (i) => i.data.length > p ? p / C : i.data.length - 1 },
26
+ yNumTicks: { default: (i) => i.data.length > p ? p / x : i.data.length - 1 },
28
27
  hideLegend: { type: Boolean },
29
28
  hideTooltip: { type: Boolean },
30
29
  legendPosition: {},
@@ -36,31 +35,33 @@ const p = 24, C = 4, X = 0.5, B = "#3b82f6", Z = /* @__PURE__ */ A({
36
35
  yGridLine: { type: Boolean }
37
36
  },
38
37
  setup(i) {
39
- const r = i, m = Object.values(r.categories).map((e) => e.color), F = y(() => (e) => {
38
+ const r = i, m = Object.values(r.categories).map((e) => e.color), d = T(null), k = T(null), D = f(() => (e, t) => {
40
39
  if (typeof window > "u" || typeof document > "u")
41
40
  return "";
42
41
  try {
43
- const t = $(w, {
42
+ const o = N(Y, {
44
43
  data: e,
45
44
  categories: r.categories,
46
- toolTipTitle: R(e),
47
- yFormatter: r.yFormatter
48
- }), n = document.createElement("div");
49
- t.mount(n);
50
- const a = n.innerHTML;
51
- return t.unmount(), a;
45
+ xValue: r.xFormatter(Math.floor(t))
46
+ }), a = document.createElement("div");
47
+ o.mount(a);
48
+ const c = a.innerHTML;
49
+ return o.unmount(), c;
52
50
  } catch {
53
51
  return "";
54
52
  }
55
53
  });
56
- function V(e) {
54
+ P(() => {
55
+ d.value && (d.value.unmount(), d.value = null), k.value && (k.value = null);
56
+ });
57
+ function F(e) {
57
58
  var t;
58
59
  return {
59
- y: (n) => Number(n[e]),
60
- color: ((t = r.categories[e]) == null ? void 0 : t.color) ?? B
60
+ y: (o) => Number(o[e]),
61
+ color: ((t = r.categories[e]) == null ? void 0 : t.color) ?? A
61
62
  };
62
63
  }
63
- function D(e, t) {
64
+ function O(e, t) {
64
65
  return `
65
66
  <linearGradient id="gradient${e}-${t}" gradientTransform="rotate(90)">
66
67
  <stop offset="0%" style="stop-color:var(--vis-color0);stop-opacity:1" />
@@ -68,7 +69,7 @@ const p = 24, C = 4, X = 0.5, B = "#3b82f6", Z = /* @__PURE__ */ A({
68
69
  </linearGradient>
69
70
  `;
70
71
  }
71
- function O(e, t) {
72
+ function $(e, t) {
72
73
  return `
73
74
  <linearGradient id="gradient${e}-${t}" gradientTransform="rotate(90)">
74
75
  <stop offset="0%" stop-color="${t}" stop-opacity="1" />
@@ -76,45 +77,45 @@ const p = 24, C = 4, X = 0.5, B = "#3b82f6", Z = /* @__PURE__ */ A({
76
77
  </linearGradient>
77
78
  `;
78
79
  }
79
- const x = y(
80
+ const E = f(
80
81
  () => m.map(
81
- (e, t) => e != null && e.includes("#") ? O(t, e) : D(t, e ?? B)
82
+ (e, t) => e != null && e.includes("#") ? $(t, e) : O(t, e ?? A)
82
83
  ).join("")
83
- ), g = y(
84
- () => r.legendPosition === z.Top
84
+ ), v = f(
85
+ () => r.legendPosition === H.Top
85
86
  );
86
- return (e, t) => (l(), c("div", {
87
- class: T(["flex flex-col space-y-4", { "flex-col-reverse": g.value }])
87
+ return (e, t) => (l(), u("div", {
88
+ class: L(["flex flex-col space-y-4", { "flex-col-reverse": v.value }])
88
89
  }, [
89
- s(o(P), {
90
+ s(n(I), {
90
91
  data: e.data,
91
92
  height: e.height,
92
93
  padding: e.padding,
93
- "svg-defs": x.value
94
+ "svg-defs": E.value
94
95
  }, {
95
- default: E(() => [
96
- e.hideTooltip ? f("", !0) : (l(), k(o(j), {
96
+ default: M(() => [
97
+ e.hideTooltip ? g("", !0) : (l(), h(n(S), {
97
98
  key: 0,
98
- "horizontal-placement": o(L).Right,
99
- "vertical-placement": o(L).Top
99
+ "horizontal-placement": n(C).Right,
100
+ "vertical-placement": n(C).Top
100
101
  }, null, 8, ["horizontal-placement", "vertical-placement"])),
101
- (l(!0), c(v, null, G(Object.keys(r.categories), (n, a) => (l(), c(v, { key: a }, [
102
- s(o(I), N({
103
- x: (d, u) => u,
102
+ (l(!0), u(b, null, U(Object.keys(r.categories), (o, a) => (l(), u(b, { key: a }, [
103
+ s(n(w), j({
104
+ x: (c, y) => y,
104
105
  ref_for: !0
105
- }, V(n), {
106
- color: `url(#gradient${a}-${o(m)[a]})`,
107
- opacity: X,
108
- "curve-type": e.curveType ?? o(h).MonotoneX
106
+ }, F(o), {
107
+ color: `url(#gradient${a}-${n(m)[a]})`,
108
+ opacity: q,
109
+ "curve-type": e.curveType ?? n(B).MonotoneX
109
110
  }), null, 16, ["x", "color", "curve-type"]),
110
- s(o(M), {
111
- x: (d, u) => u,
112
- y: (d) => d[n],
113
- color: o(m)[a],
114
- "curve-type": e.curveType ?? o(h).MonotoneX
111
+ s(n(z), {
112
+ x: (c, y) => y,
113
+ y: (c) => c[o],
114
+ color: n(m)[a],
115
+ "curve-type": e.curveType ?? n(B).MonotoneX
115
116
  }, null, 8, ["x", "y", "color", "curve-type"])
116
117
  ], 64))), 128)),
117
- s(o(b), {
118
+ s(n(V), {
118
119
  type: "x",
119
120
  "tick-format": e.xFormatter,
120
121
  label: e.xLabel,
@@ -126,7 +127,7 @@ const p = 24, C = 4, X = 0.5, B = "#3b82f6", Z = /* @__PURE__ */ A({
126
127
  "tick-values": e.xExplicitTicks,
127
128
  "min-max-ticks-only": e.minMaxTicksOnly
128
129
  }, null, 8, ["tick-format", "label", "domain-line", "grid-line", "num-ticks", "tick-line", "tick-values", "min-max-ticks-only"]),
129
- s(o(b), {
130
+ s(n(V), {
130
131
  type: "y",
131
132
  "num-ticks": e.yNumTicks,
132
133
  "tick-format": e.yFormatter,
@@ -135,19 +136,19 @@ const p = 24, C = 4, X = 0.5, B = "#3b82f6", Z = /* @__PURE__ */ A({
135
136
  "domain-line": e.yDomainLine,
136
137
  "tick-line": e.yTickLine
137
138
  }, null, 8, ["num-ticks", "tick-format", "label", "grid-line", "domain-line", "tick-line"]),
138
- e.hideTooltip ? f("", !0) : (l(), k(o(S), {
139
+ e.hideTooltip ? g("", !0) : (l(), h(n(R), {
139
140
  key: 1,
140
141
  color: "#666",
141
- template: F.value
142
+ template: D.value
142
143
  }, null, 8, ["template"]))
143
144
  ]),
144
145
  _: 1
145
146
  }, 8, ["data", "height", "padding", "svg-defs"]),
146
- e.hideLegend ? f("", !0) : (l(), c("div", {
147
+ e.hideLegend ? g("", !0) : (l(), u("div", {
147
148
  key: 0,
148
- class: T(["flex items-center justify-end", { "pb-4": g.value }])
149
+ class: L(["flex items-center justify-end", { "pb-4": v.value }])
149
150
  }, [
150
- s(o(U), {
151
+ s(n(X), {
151
152
  items: Object.values(e.categories)
152
153
  }, null, 8, ["items"])
153
154
  ], 2))
@@ -155,5 +156,5 @@ const p = 24, C = 4, X = 0.5, B = "#3b82f6", Z = /* @__PURE__ */ A({
155
156
  }
156
157
  });
157
158
  export {
158
- Z as default
159
+ _ as default
159
160
  };
@@ -47,16 +47,16 @@ const S = /* @__PURE__ */ v({
47
47
  ), y = c(() => (e, t) => {
48
48
  if (typeof window > "u" || typeof document > "u")
49
49
  return "";
50
- const u = Object.keys(a.categories), T = Object.keys(e).find((o) => !u.includes(o));
50
+ const u = Object.keys(a.categories), B = Object.keys(e).find((o) => !u.includes(o));
51
51
  try {
52
52
  const o = V(E, {
53
53
  data: e,
54
54
  categories: a.categories,
55
- toolTipTitle: e[T]
55
+ xValue: e[B]
56
56
  }), k = document.createElement("div");
57
57
  o.mount(k);
58
- const B = k.innerHTML;
59
- return o.unmount(), B;
58
+ const T = k.innerHTML;
59
+ return o.unmount(), T;
60
60
  } catch {
61
61
  return "";
62
62
  }
@@ -1,10 +1,9 @@
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";
1
+ import { defineComponent as b, computed as u, createApp as B, createElementBlock as s, openBlock as l, normalizeClass as p, createVNode as r, createCommentVNode as y, unref as i, withCtx as x, createBlock as g, Fragment as C, renderList as V } from "vue";
2
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({
3
+ import { VisXYContainer as N, VisTooltip as O, VisLine as j, VisAxis as f, VisCrosshair as M, VisBulletLegend as P } from "@unovis/vue";
4
+ import D from "../Tooltip.js";
5
+ import { LegendPosition as E } from "../../types.js";
6
+ const $ = /* @__PURE__ */ b({
8
7
  __name: "LineChart",
9
8
  props: {
10
9
  data: {},
@@ -36,15 +35,14 @@ const R = /* @__PURE__ */ b({
36
35
  yTickLine: { type: Boolean }
37
36
  },
38
37
  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) => {
38
+ 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 = u(() => (e, c) => {
40
39
  if (typeof window > "u" || typeof document > "u")
41
40
  return "";
42
41
  try {
43
- const o = B(E, {
42
+ const o = B(D, {
44
43
  data: e,
45
44
  categories: n.categories,
46
- toolTipTitle: M(e),
47
- yFormatter: n.yFormatter
45
+ xValue: n.xFormatter(Math.floor(c))
48
46
  }), a = document.createElement("div");
49
47
  o.mount(a);
50
48
  const m = a.innerHTML;
@@ -52,11 +50,11 @@ const R = /* @__PURE__ */ b({
52
50
  } catch {
53
51
  return "";
54
52
  }
55
- }), d = p(
56
- () => n.legendPosition === G.Top
53
+ }), d = u(
54
+ () => n.legendPosition === E.Top
57
55
  );
58
56
  return (e, c) => (l(), s("div", {
59
- class: u(["flex flex-col space-y-4", { "flex-col-reverse": d.value }])
57
+ class: p(["flex flex-col space-y-4", { "flex-col-reverse": d.value }])
60
58
  }, [
61
59
  r(i(N), {
62
60
  data: e.data,
@@ -68,7 +66,7 @@ const R = /* @__PURE__ */ b({
68
66
  "horizontal-placement": i(k).Right,
69
67
  "vertical-placement": i(k).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), {
69
+ (l(!0), s(C, null, V(Object.keys(n.categories), (o, a) => (l(), g(i(j), {
72
70
  key: a,
73
71
  x: (m, v) => v,
74
72
  y: (m) => m[o],
@@ -96,7 +94,7 @@ const R = /* @__PURE__ */ b({
96
94
  "grid-line": e.yGridLine,
97
95
  "tick-line": e.yTickLine
98
96
  }, null, 8, ["tick-format", "label", "num-ticks", "domain-line", "grid-line", "tick-line"]),
99
- e.hideTooltip ? y("", !0) : (l(), g(i(j), {
97
+ e.hideTooltip ? y("", !0) : (l(), g(i(M), {
100
98
  key: 0,
101
99
  color: "#666",
102
100
  template: T.value
@@ -106,9 +104,9 @@ const R = /* @__PURE__ */ b({
106
104
  }, 8, ["data", "padding", "height"]),
107
105
  e.hideLegend ? y("", !0) : (l(), s("div", {
108
106
  key: 0,
109
- class: u(["flex items center justify-end", { "pb-4": d.value }])
107
+ class: p(["flex items center justify-end", { "pb-4": d.value }])
110
108
  }, [
111
- r(i(D), {
109
+ r(i(P), {
112
110
  items: Object.values(e.categories)
113
111
  }, null, 8, ["items"])
114
112
  ], 2))
@@ -116,5 +114,5 @@ const R = /* @__PURE__ */ b({
116
114
  }
117
115
  });
118
116
  export {
119
- R as default
117
+ $ as default
120
118
  };
@@ -1,42 +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";
2
- const f = {
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 f, normalizeStyle as a } from "vue";
2
+ const x = {
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
+ }, y = /* @__PURE__ */ b({
9
9
  __name: "Tooltip",
10
10
  props: {
11
11
  data: {},
12
12
  categories: {},
13
- toolTipTitle: {},
14
- yFormatter: { type: Function }
13
+ xValue: {}
15
14
  },
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)
15
+ setup(c) {
16
+ const n = c, p = ["_index", "_stacked", "_ending"], d = v(() => Object.entries(n.data ?? []).filter(
17
+ ([e, u]) => !p.includes(e) && Object.keys(n.categories).includes(e)
19
18
  ));
20
- return (e, g) => (l(), r("div", null, [
21
- o("div", f, i(e.toolTipTitle), 1),
22
- (l(!0), r(y, null, h(m.value, ([t, s], u) => {
23
- var c;
19
+ return (e, u) => (l(), r("div", null, [
20
+ o("div", x, i(e.xValue), 1),
21
+ (l(!0), r(h, null, f(d.value, ([t, g], m) => {
22
+ var s;
24
23
  return l(), r("div", {
25
24
  key: t,
26
25
  style: { display: "flex", "align-items": "center", "margin-bottom": "4px" }
27
26
  }, [
28
27
  o("span", {
29
- style: n([{ width: "8px", height: "8px", "border-radius": "4px", "margin-right": "8px" }, {
30
- backgroundColor: (c = e.categories[t]) != null && c.color ? e.categories[t].color : `var(--vis-color${u})`
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-color${m})`
31
30
  }])
32
31
  }, null, 4),
33
32
  o("div", null, [
34
33
  o("span", {
35
- style: n([{ "font-weight": "600", "margin-right": "8px" }, { color: "var(--tooltip-label-color)" }])
34
+ style: a([{ "font-weight": "600", "margin-right": "8px" }, { color: "var(--tooltip-label-color)" }])
36
35
  }, i(e.categories[t].name) + ":", 1),
37
36
  o("span", {
38
- style: n([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
39
- }, i(e.yFormatter ? e.yFormatter(s) : s), 1)
37
+ style: a([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
38
+ }, i(g), 1)
40
39
  ])
41
40
  ]);
42
41
  }), 128))
@@ -44,5 +43,5 @@ const f = {
44
43
  }
45
44
  });
46
45
  export {
47
- F as default
46
+ y as default
48
47
  };
@@ -3,8 +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;
7
- yFormatter?: (value: T) => any;
6
+ xValue: string | number;
8
7
  } & Partial<{}>> & import('vue').PublicProps;
9
8
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
10
9
  attrs: any;
package/dist/utils.d.ts CHANGED
@@ -1,2 +1 @@
1
1
  export declare function getDistributedIndices(length: number, numTicks: number): number[];
2
- export declare function getFirstPropertyValue(obj: unknown): undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-chrts",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -14,12 +14,6 @@
14
14
  "require": "./dist/index.umd.cjs"
15
15
  }
16
16
  },
17
- "scripts": {
18
- "dev": "vite",
19
- "build": "vue-tsc -b && vite build",
20
- "preview": "vite preview",
21
- "release": "commit-and-tag-version"
22
- },
23
17
  "peerDependencies": {
24
18
  "vue": "^3.5.13"
25
19
  },
@@ -40,5 +34,10 @@
40
34
  "vue-router": "^4.5.0",
41
35
  "vue-tsc": "^2.2.4"
42
36
  },
43
- "packageManager": "pnpm@8.15.4+sha256.cea6d0bdf2de3a0549582da3983c70c92ffc577ff4410cbf190817ddc35137c2"
44
- }
37
+ "scripts": {
38
+ "dev": "vite",
39
+ "build": "vue-tsc -b && vite build",
40
+ "preview": "vite preview",
41
+ "release": "commit-and-tag-version"
42
+ }
43
+ }
package/dist/utils.js DELETED
@@ -1,9 +0,0 @@
1
- function r(e) {
2
- if (e && Object.keys(e).length > 0) {
3
- const t = Object.keys(e)[0];
4
- return e[t];
5
- }
6
- }
7
- export {
8
- r as getFirstPropertyValue
9
- };