vue-chrts 0.1.0 → 0.1.1-test.3

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,9 +1,9 @@
1
- import { defineComponent as E, ref as T, computed as g, createApp as F, onUnmounted as $, createElementBlock as p, openBlock as r, normalizeClass as L, createVNode as s, createCommentVNode as v, unref as o, withCtx as N, createBlock as h, Fragment as b, renderList as G, mergeProps as P } from "vue";
2
- import { Position as x, CurveType as C } from "@unovis/ts";
3
- import { VisXYContainer as U, VisTooltip as j, VisArea as I, VisLine as M, VisAxis as B, VisCrosshair as w, VisBulletLegend as z } from "@unovis/vue";
4
- import R from "../Tooltip.js";
5
- import { LegendPosition as X } from "../../types.js";
6
- const m = 24, A = 4, Y = 0.5, H = "#3b82f6", Z = /* @__PURE__ */ E({
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";
4
+ import Y from "../Tooltip.js";
5
+ import { LegendPosition as H } from "../../types.js";
6
+ const p = 24, V = 4, q = 0.5, A = "#3b82f6", _ = /* @__PURE__ */ E({
7
7
  __name: "AreaChart",
8
8
  props: {
9
9
  data: {},
@@ -14,10 +14,10 @@ const m = 24, A = 4, Y = 0.5, H = "#3b82f6", Z = /* @__PURE__ */ E({
14
14
  xFormatter: {},
15
15
  yFormatter: {},
16
16
  curveType: {},
17
- xNumTicks: { default: (i) => i.data.length > m ? m / A : i.data.length - 1 },
17
+ xNumTicks: { default: (i) => i.data.length > p ? p / V : i.data.length - 1 },
18
18
  xExplicitTicks: {},
19
19
  minMaxTicksOnly: { type: Boolean },
20
- yNumTicks: { default: (i) => i.data.length > m ? m / A : i.data.length - 1 },
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
23
  xGridLine: { type: Boolean },
@@ -28,74 +28,83 @@ const m = 24, A = 4, Y = 0.5, H = "#3b82f6", Z = /* @__PURE__ */ E({
28
28
  legendPosition: {}
29
29
  },
30
30
  setup(i) {
31
- const l = i, d = Object.values(l.categories).map((e) => e.color), n = T(null), a = T(null), D = g(() => (e) => {
31
+ const r = i, m = Object.values(r.categories).map((e) => e.color), d = T(null), v = T(null), D = f(() => (e, t) => {
32
32
  if (typeof window > "u" || typeof document > "u")
33
33
  return "";
34
34
  try {
35
- if (a.value || (a.value = document.createElement("div")), !n.value)
36
- n.value = F(R, {
37
- data: e,
38
- categories: l.categories
39
- }), n.value.mount(a.value);
40
- else {
41
- const t = n.value._instance;
42
- t != null && t.proxy && (t.proxy.$props.data = e, t.proxy.$props.categories = l.categories);
43
- }
44
- return a.value.innerHTML;
45
- } catch (t) {
46
- return console.error("Error generating tooltip:", t), "";
35
+ const n = N(Y, {
36
+ data: e,
37
+ categories: r.categories,
38
+ xValue: r.xFormatter(Math.floor(t))
39
+ }), a = document.createElement("div");
40
+ n.mount(a);
41
+ const c = a.innerHTML;
42
+ return n.unmount(), c;
43
+ } catch {
44
+ return "";
47
45
  }
48
46
  });
49
- $(() => {
50
- n.value && (n.value.unmount(), n.value = null), a.value && (a.value = null);
47
+ P(() => {
48
+ d.value && (d.value.unmount(), d.value = null), v.value && (v.value = null);
51
49
  });
52
- function O(e) {
50
+ function F(e) {
53
51
  var t;
54
52
  return {
55
- y: (c) => Number(c[e]),
56
- color: ((t = l.categories[e]) == null ? void 0 : t.color) ?? H
53
+ y: (n) => Number(n[e]),
54
+ color: ((t = r.categories[e]) == null ? void 0 : t.color) ?? A
57
55
  };
58
56
  }
59
- const V = g(
60
- () => d.map(
61
- (e, t) => `
62
- <linearGradient id="gradient${t}-${e}" gradientTransform="rotate(90)">
63
- <stop offset="0%" stop-color="${e}" stop-opacity="1" />
64
- <stop offset="100%" stop-color="${e}" stop-opacity="0" />
57
+ function O(e, t) {
58
+ return `
59
+ <linearGradient id="gradient${e}-${t}" gradientTransform="rotate(90)">
60
+ <stop offset="0%" style="stop-color:var(--vis-color0);stop-opacity:1" />
61
+ <stop offset="100%" style="stop-color:var(--vis-color0);stop-opacity:0" />
62
+ </linearGradient>
63
+ `;
64
+ }
65
+ function G(e, t) {
66
+ return `
67
+ <linearGradient id="gradient${e}-${t}" gradientTransform="rotate(90)">
68
+ <stop offset="0%" stop-color="${t}" stop-opacity="1" />
69
+ <stop offset="100%" stop-color="${t}" stop-opacity="0" />
65
70
  </linearGradient>
66
- `
71
+ `;
72
+ }
73
+ const $ = f(
74
+ () => m.map(
75
+ (e, t) => e != null && e.includes("#") ? G(t, e) : O(t, e ?? A)
67
76
  ).join("")
68
- ), k = g(
69
- () => l.legendPosition === X.Top
77
+ ), k = f(
78
+ () => r.legendPosition === H.Top
70
79
  );
71
- return (e, t) => (r(), p("div", {
80
+ return (e, t) => (l(), u("div", {
72
81
  class: L(["flex flex-col space-y-4", { "flex-col-reverse": k.value }])
73
82
  }, [
74
- s(o(U), {
83
+ s(o(I), {
75
84
  data: e.data,
76
85
  height: e.height,
77
- "svg-defs": V.value
86
+ "svg-defs": $.value
78
87
  }, {
79
- default: N(() => [
80
- e.hideTooltip ? v("", !0) : (r(), h(o(j), {
88
+ default: M(() => [
89
+ e.hideTooltip ? g("", !0) : (l(), h(o(S), {
81
90
  key: 0,
82
- "horizontal-placement": o(x).Right,
83
- "vertical-placement": o(x).Top
91
+ "horizontal-placement": o(C).Right,
92
+ "vertical-placement": o(C).Top
84
93
  }, null, 8, ["horizontal-placement", "vertical-placement"])),
85
- (r(!0), p(b, null, G(Object.keys(l.categories), (c, u) => (r(), p(b, { key: u }, [
86
- s(o(I), P({
87
- x: (y, f) => f,
94
+ (l(!0), u(b, null, U(Object.keys(r.categories), (n, a) => (l(), u(b, { key: a }, [
95
+ s(o(w), j({
96
+ x: (c, y) => y,
88
97
  ref_for: !0
89
- }, O(c), {
90
- color: `url(#gradient${u}-${o(d)[u]})`,
91
- opacity: Y,
92
- "curve-type": e.curveType ?? o(C).MonotoneX
98
+ }, F(n), {
99
+ color: `url(#gradient${a}-${o(m)[a]})`,
100
+ opacity: q,
101
+ "curve-type": e.curveType ?? o(x).MonotoneX
93
102
  }), null, 16, ["x", "color", "curve-type"]),
94
- s(o(M), {
95
- x: (y, f) => f,
96
- y: (y) => y[c],
97
- color: o(d)[u],
98
- "curve-type": e.curveType ?? o(C).MonotoneX
103
+ s(o(z), {
104
+ x: (c, y) => y,
105
+ y: (c) => c[n],
106
+ color: o(m)[a],
107
+ "curve-type": e.curveType ?? o(x).MonotoneX
99
108
  }, null, 8, ["x", "y", "color", "curve-type"])
100
109
  ], 64))), 128)),
101
110
  s(o(B), {
@@ -119,7 +128,7 @@ const m = 24, A = 4, Y = 0.5, H = "#3b82f6", Z = /* @__PURE__ */ E({
119
128
  "domain-line": e.yDomainLine,
120
129
  "tick-line": !!e.yGridLine
121
130
  }, null, 8, ["num-ticks", "tick-format", "label", "grid-line", "domain-line", "tick-line"]),
122
- e.hideTooltip ? v("", !0) : (r(), h(o(w), {
131
+ e.hideTooltip ? g("", !0) : (l(), h(o(R), {
123
132
  key: 1,
124
133
  color: "#666",
125
134
  template: D.value
@@ -127,11 +136,11 @@ const m = 24, A = 4, Y = 0.5, H = "#3b82f6", Z = /* @__PURE__ */ E({
127
136
  ]),
128
137
  _: 1
129
138
  }, 8, ["data", "height", "svg-defs"]),
130
- e.hideLegend ? v("", !0) : (r(), p("div", {
139
+ e.hideLegend ? g("", !0) : (l(), u("div", {
131
140
  key: 0,
132
141
  class: L(["flex items-center justify-end", { "pb-4": k.value }])
133
142
  }, [
134
- s(o(z), {
143
+ s(o(X), {
135
144
  items: Object.values(e.categories)
136
145
  }, null, 8, ["items"])
137
146
  ], 2))
@@ -139,5 +148,5 @@ const m = 24, A = 4, Y = 0.5, H = "#3b82f6", Z = /* @__PURE__ */ E({
139
148
  }
140
149
  });
141
150
  export {
142
- Z as default
151
+ _ as default
143
152
  };
@@ -1,37 +1,44 @@
1
- import { defineComponent as g, computed as m, createElementBlock as r, openBlock as l, Fragment as x, renderList as _, createElementVNode as o, normalizeStyle as n, toDisplayString as a } from "vue";
2
- const h = /* @__PURE__ */ g({
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 = {
3
+ class: "capitalize border-b mb-1 pb-1",
4
+ style: {
5
+ color: "var(--tooltip-value-color)",
6
+ borderColor: "rgba(255, 255, 255, 0.05)"
7
+ }
8
+ }, f = /* @__PURE__ */ m({
3
9
  __name: "Tooltip",
4
10
  props: {
5
11
  data: {},
6
- categories: {}
12
+ categories: {},
13
+ xValue: {}
7
14
  },
8
15
  setup(s) {
9
- const i = s, c = ["_index", "_stacked", "_ending"], p = m(() => Object.entries(i.data ?? []).filter(
10
- ([t, d]) => {
11
- var e;
12
- return !c.includes(t) && ((e = i.categories[t]) == null ? void 0 : e.color);
13
- }
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)
14
18
  ));
15
- return (t, d) => (l(), r("div", null, [
16
- (l(!0), r(x, null, _(p.value, ([e, u]) => (l(), r("div", {
17
- key: e,
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,
18
23
  style: { display: "flex", "align-items": "center", "margin-bottom": "4px" }
19
24
  }, [
20
25
  o("span", {
21
- style: n([{ width: "8px", height: "8px", "border-radius": "4px", "margin-right": "8px" }, { backgroundColor: t.categories[e].color }])
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
+ }])
22
29
  }, null, 4),
23
30
  o("div", null, [
24
31
  o("span", {
25
- style: n([{ "font-weight": "600", "margin-right": "8px" }, { color: "var(--tooltip-label-color)" }])
26
- }, a(e) + ":", 1),
32
+ style: a([{ "font-weight": "600", "margin-right": "8px" }, { color: "var(--tooltip-label-color)" }])
33
+ }, i(t) + ":", 1),
27
34
  o("span", {
28
- style: n([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
29
- }, a(u), 1)
35
+ style: a([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
36
+ }, i(u), 1)
30
37
  ])
31
38
  ]))), 128))
32
39
  ]));
33
40
  }
34
41
  });
35
42
  export {
36
- h as default
43
+ f as default
37
44
  };
@@ -3,6 +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
+ xValue: string | number;
6
7
  } & Partial<{}>> & import('vue').PublicProps;
7
8
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
8
9
  attrs: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-chrts",
3
- "version": "0.1.0",
3
+ "version": "0.1.1-test.3",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -24,6 +24,7 @@
24
24
  "devDependencies": {
25
25
  "@tailwindcss/vite": "^4.0.15",
26
26
  "@tanstack/vue-table": "^8.21.2",
27
+ "@types/culori": "^2.1.1",
27
28
  "@types/node": "^22.13.11",
28
29
  "@unovis/ts": "^1.5.1",
29
30
  "@unovis/vue": "^1.5.1",