vue-chrts 0.2.1 → 0.2.2-test.1

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 d, createElementBlock as c, openBlock as a, normalizeClass as T, createVNode as u, createCommentVNode as p, createElementVNode as X, unref as i, withCtx as S, createBlock as m, Fragment as L, renderList as Y, mergeProps as C, renderSlot as A } from "vue";
2
- import { Position as b, CurveType as D } from "@unovis/ts";
3
- import { createMarkers as z, getFirstPropertyValue as I } from "../../utils.js";
4
- import x from "../Tooltip.js";
5
- import { VisXYContainer as H, VisTooltip as K, VisArea as q, VisLine as J, VisAxis as B, VisCrosshair as Q, VisBulletLegend as Z } from "@unovis/vue";
6
- import { LegendPosition as _ } from "../../types.js";
7
- const ee = {
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";
4
+ import H from "../Tooltip.js";
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
+ import { LegendPosition as ee } from "../../types.js";
7
+ const te = {
8
8
  ref: "slotWrapper",
9
- class: "hidden"
10
- }, y = 24, V = 4, te = 0.5, F = "#3b82f6", se = /* @__PURE__ */ U({
9
+ style: { display: "none" }
10
+ }, y = 24, V = 4, ie = 0.5, F = "#3b82f6", de = /* @__PURE__ */ U({
11
11
  __name: "AreaChart",
12
12
  props: {
13
13
  data: {},
@@ -22,10 +22,10 @@ const ee = {
22
22
  curveType: {},
23
23
  lineWidth: { default: 2 },
24
24
  lineDashArray: {},
25
- xNumTicks: { default: (n) => n.data.length > y ? y / V : n.data.length - 1 },
25
+ xNumTicks: { default: (a) => a.data.length > y ? y / V : a.data.length - 1 },
26
26
  xExplicitTicks: {},
27
27
  minMaxTicksOnly: { type: Boolean },
28
- yNumTicks: { default: (n) => n.data.length > y ? y / V : n.data.length - 1 },
28
+ yNumTicks: { default: (a) => a.data.length > y ? y / V : a.data.length - 1 },
29
29
  hideLegend: { type: Boolean },
30
30
  hideTooltip: { type: Boolean },
31
31
  legendPosition: {},
@@ -42,10 +42,10 @@ const ee = {
42
42
  }) }
43
43
  },
44
44
  emits: ["click"],
45
- setup(n, { emit: $ }) {
46
- const G = $, r = n, O = j(), h = w("slotWrapper"), s = R(), f = d(
47
- () => Object.values(r.categories).map((e) => e.color)
48
- ), N = d(() => r.markerConfig ? z(r.markerConfig) : ""), g = d(() => r.legendPosition === _.Top), E = d(() => {
45
+ setup(a, { emit: $ }) {
46
+ const G = $, n = a, O = j(), h = w("slotWrapper"), s = R(), f = u(
47
+ () => 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
49
  const e = (t, o) => `
50
50
  <linearGradient id="gradient${t}-${o}" gradientTransform="rotate(90)">
51
51
  <stop offset="0%" stop-color="${o}" stop-opacity="1" />
@@ -65,7 +65,7 @@ const ee = {
65
65
  var l;
66
66
  return {
67
67
  y: (t) => Number(t[e]),
68
- color: ((l = r.categories[e]) == null ? void 0 : l.color) ?? F
68
+ color: ((l = n.categories[e]) == null ? void 0 : l.color) ?? F
69
69
  };
70
70
  }
71
71
  function W(e) {
@@ -74,40 +74,44 @@ const ee = {
74
74
  function M(e) {
75
75
  return s.value = e, W();
76
76
  }
77
- return (e, l) => (a(), c("div", {
78
- class: T(["flex flex-col", { "flex-col-reverse": g.value, markers: !!r.markerConfig }]),
77
+ return (e, l) => (r(), m("div", {
78
+ style: T({
79
+ display: "flex",
80
+ flexDirection: g.value ? "column-reverse" : "column"
81
+ }),
82
+ class: S({ markers: !!n.markerConfig }),
79
83
  onClick: l[0] || (l[0] = (t) => G("click", t, s.value))
80
84
  }, [
81
- u(i(H), {
85
+ p(i(K), {
82
86
  data: e.data,
83
87
  height: e.height,
84
88
  padding: e.padding,
85
89
  "svg-defs": E.value + N.value
86
90
  }, {
87
- default: S(() => [
88
- e.hideTooltip ? p("", !0) : (a(), m(i(K), {
91
+ default: z(() => [
92
+ e.hideTooltip ? d("", !0) : (r(), c(i(q), {
89
93
  key: 0,
90
- "horizontal-placement": i(b).Right,
91
- "vertical-placement": i(b).Top
94
+ "horizontal-placement": i(D).Right,
95
+ "vertical-placement": i(D).Top
92
96
  }, null, 8, ["horizontal-placement", "vertical-placement"])),
93
- (a(!0), c(L, null, Y(Object.keys(r.categories), (t, o) => (a(), c(L, { key: t }, [
94
- u(i(q), C({
97
+ (r(!0), m(L, null, I(Object.keys(n.categories), (t, o) => (r(), m(L, { key: t }, [
98
+ p(i(J), C({
95
99
  x: (k, v) => v
96
100
  }, { ref_for: !0 }, P(t), {
97
101
  color: `url(#gradient${o}-${f.value[o]})`,
98
- opacity: te,
99
- "curve-type": e.curveType ?? i(D).MonotoneX
102
+ opacity: ie,
103
+ "curve-type": e.curveType ?? i(b).MonotoneX
100
104
  }), null, 16, ["x", "color", "curve-type"]),
101
- u(i(J), {
105
+ p(i(Q), {
102
106
  x: (k, v) => v,
103
107
  y: (k) => k[t],
104
108
  color: f.value[o],
105
- "curve-type": e.curveType ?? i(D).MonotoneX,
109
+ "curve-type": e.curveType ?? i(b).MonotoneX,
106
110
  "line-width": e.lineWidth,
107
111
  lineDashArray: e.lineDashArray ? e.lineDashArray[o] : void 0
108
112
  }, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"])
109
113
  ], 64))), 128)),
110
- e.hideXAxis ? p("", !0) : (a(), m(i(B), {
114
+ e.hideXAxis ? d("", !0) : (r(), c(i(B), {
111
115
  key: 1,
112
116
  type: "x",
113
117
  label: e.xLabel,
@@ -120,7 +124,7 @@ const ee = {
120
124
  "tick-line": e.xTickLine,
121
125
  "min-max-ticks-only": e.minMaxTicksOnly
122
126
  }, null, 8, ["label", "num-ticks", "tick-format", "tick-values", "grid-line", "domain-line", "tick-line", "min-max-ticks-only"])),
123
- e.hideYAxis ? p("", !0) : (a(), m(i(B), {
127
+ e.hideYAxis ? d("", !0) : (r(), c(i(B), {
124
128
  key: 2,
125
129
  type: "y",
126
130
  label: e.yLabel,
@@ -130,34 +134,40 @@ const ee = {
130
134
  "domain-line": e.yDomainLine,
131
135
  "tick-line": e.yTickLine
132
136
  }, null, 8, ["label", "num-ticks", "tick-format", "grid-line", "domain-line", "tick-line"])),
133
- e.hideTooltip ? p("", !0) : (a(), m(i(Q), C({ key: 3 }, e.crosshairConfig, { template: M }), null, 16))
137
+ e.hideTooltip ? d("", !0) : (r(), c(i(Z), C({ key: 3 }, e.crosshairConfig, { template: M }), null, 16))
134
138
  ]),
135
139
  _: 1
136
140
  }, 8, ["data", "height", "padding", "svg-defs"]),
137
- e.hideLegend ? p("", !0) : (a(), c("div", {
141
+ e.hideLegend ? d("", !0) : (r(), m("div", {
138
142
  key: 0,
139
- class: T(["flex items-center justify-end", { "pb-4": g.value, "pt-4": !g.value }])
143
+ style: T({
144
+ display: "flex",
145
+ alignItems: "center",
146
+ justifyContent: "flex-end",
147
+ paddingBottom: g.value ? "1rem" : void 0,
148
+ paddingTop: g.value ? void 0 : "1rem"
149
+ })
140
150
  }, [
141
- u(i(Z), {
151
+ p(i(_), {
142
152
  items: Object.values(e.categories)
143
153
  }, null, 8, ["items"])
144
- ], 2)),
145
- X("div", ee, [
154
+ ], 4)),
155
+ X("div", te, [
146
156
  i(O).tooltip ? A(e.$slots, "tooltip", {
147
157
  key: 0,
148
158
  values: s.value
149
159
  }) : s.value ? A(e.$slots, "fallback", { key: 1 }, () => [
150
- u(x, {
160
+ p(H, {
151
161
  data: s.value,
152
162
  categories: e.categories,
153
- toolTipTitle: i(I)(s.value) ?? "",
154
- yFormatter: r.yFormatter
163
+ toolTipTitle: i(x)(s.value) ?? "",
164
+ yFormatter: n.yFormatter
155
165
  }, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
156
- ]) : p("", !0)
166
+ ]) : d("", !0)
157
167
  ], 512)
158
- ], 2));
168
+ ], 6));
159
169
  }
160
170
  });
161
171
  export {
162
- se as default
172
+ de as default
163
173
  };
@@ -1,13 +1,13 @@
1
- import { defineComponent as C, useSlots as N, useTemplateRef as O, ref as D, computed as T, createElementBlock as m, openBlock as n, normalizeClass as L, createVNode as g, createCommentVNode as c, createElementVNode as w, unref as i, withCtx as E, createBlock as u, Fragment as M, renderList as S, renderSlot as v } from "vue";
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
2
  import { Orientation as l, StackedBar as j, GroupedBar as z } from "@unovis/ts";
3
3
  import { getFirstPropertyValue as H } from "../../utils.js";
4
4
  import { useStackedGrouped as W } from "./stackedGroupedUtils.js";
5
- import { VisXYContainer as X, VisTooltip as Y, VisStackedBar as B, VisGroupedBar as $, VisAxis as A, VisBulletLegend as R } from "@unovis/vue";
5
+ import { VisXYContainer as X, VisTooltip as Y, VisStackedBar as L, VisGroupedBar as $, VisAxis as A, VisBulletLegend as R } from "@unovis/vue";
6
6
  import q from "../Tooltip.js";
7
- import { LegendPosition as U } from "../../types.js";
8
- const I = {
7
+ import { LegendPosition as I } from "../../types.js";
8
+ const U = {
9
9
  ref: "slotWrapper",
10
- class: "hidden"
10
+ style: { display: "none" }
11
11
  }, ae = /* @__PURE__ */ C({
12
12
  __name: "BarChart",
13
13
  props: {
@@ -45,62 +45,70 @@ const I = {
45
45
  yGridLine: { type: Boolean, default: !0 },
46
46
  hideXAxis: { type: Boolean },
47
47
  hideYAxis: { type: Boolean },
48
+ stackedGroupedSpacing: { default: 0.1 },
48
49
  stackAndGrouped: { type: Boolean },
49
50
  xAxis: {}
50
51
  },
51
52
  emits: ["click"],
52
53
  setup(t, { emit: V }) {
53
- const x = V, a = t, P = N(), y = O("slotWrapper"), r = D();
54
+ const x = V, a = t, G = S(), k = D("slotWrapper"), r = N();
54
55
  if (!a.yAxis || a.yAxis.length === 0)
55
56
  throw new Error("yAxis is required");
56
- const k = T(() => a.yAxis.map((e) => (d) => d[e])), f = (e, d) => {
57
+ const f = c(() => a.yAxis.map((e) => (d) => d[e])), v = (e, d) => {
57
58
  var o;
58
59
  return (o = Object.values(a.categories)[d]) == null ? void 0 : o.color;
59
- }, s = W({
60
- data: a.data,
61
- categories: a.categories,
62
- stackAndGrouped: a.stackAndGrouped,
63
- xAxis: a.xAxis
64
- }), h = T(
65
- () => a.legendPosition === U.Top
60
+ }, s = c(
61
+ () => W({
62
+ data: a.data,
63
+ categories: a.categories,
64
+ stackAndGrouped: a.stackAndGrouped,
65
+ xAxis: a.xAxis,
66
+ spacing: a.stackedGroupedSpacing
67
+ }).value
68
+ ), h = c(
69
+ () => a.legendPosition === I.Top
66
70
  );
67
71
  function b(e) {
68
- return r.value = e, G();
72
+ return r.value = e, P();
69
73
  }
70
- function G(e) {
71
- return typeof window > "u" ? "" : y.value ? y.value.innerHTML : "";
74
+ function P(e) {
75
+ return typeof window > "u" ? "" : k.value ? k.value.innerHTML : "";
72
76
  }
73
- return (e, d) => (n(), m("div", {
74
- class: L(["flex flex-col space-y-4", { "flex-col-reverse": h.value }]),
77
+ return (e, d) => (n(), y("div", {
78
+ style: T({
79
+ display: "flex",
80
+ flexDirection: h.value ? "column-reverse" : "column",
81
+ gap: "1rem"
82
+ }),
75
83
  onClick: d[0] || (d[0] = (o) => x("click", o, r.value))
76
84
  }, [
77
85
  g(i(X), {
78
86
  padding: e.padding,
79
87
  height: e.height
80
88
  }, {
81
- default: E(() => [
89
+ default: w(() => [
82
90
  g(i(Y), {
83
91
  triggers: {
84
92
  [i(z).selectors.bar]: b,
85
93
  [i(j).selectors.bar]: b
86
94
  }
87
95
  }, null, 8, ["triggers"]),
88
- e.stackAndGrouped ? (n(!0), m(M, { key: 0 }, S(i(s).states, (o) => (n(), u(i(B), {
96
+ e.stackAndGrouped ? (n(!0), y(E, { key: 0 }, M(s.value.states, (o) => (n(), u(i(L), {
89
97
  key: o,
90
- data: i(s).chartData,
91
- x: (p, F) => F + i(s).positions[o],
92
- y: i(s).bars[o],
93
- color: i(s).colorFunctions[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],
94
102
  "rounded-corners": e.radius ?? 0,
95
103
  "group-padding": e.groupPadding ?? 0,
96
- "bar-padding": e.barPadding ?? 0.2,
104
+ "bar-padding": e.barPadding,
97
105
  orientation: e.orientation ?? i(l).Vertical
98
- }, null, 8, ["data", "x", "y", "color", "rounded-corners", "group-padding", "bar-padding", "orientation"]))), 128)) : e.stacked ? (n(), u(i(B), {
106
+ }, null, 8, ["data", "x", "y", "color", "rounded-corners", "group-padding", "bar-padding", "orientation"]))), 128)) : e.stacked ? (n(), u(i(L), {
99
107
  key: 2,
100
108
  data: e.data,
101
109
  x: (o, p) => p,
102
- y: k.value,
103
- color: f,
110
+ y: f.value,
111
+ color: v,
104
112
  "rounded-corners": e.radius ?? 0,
105
113
  "group-padding": e.groupPadding ?? 0,
106
114
  "bar-padding": e.barPadding ?? 0.2,
@@ -109,14 +117,14 @@ const I = {
109
117
  key: 1,
110
118
  data: e.data,
111
119
  x: (o, p) => p,
112
- y: k.value,
113
- color: f,
120
+ y: f.value,
121
+ color: v,
114
122
  "rounded-corners": e.radius ?? 0,
115
123
  "group-padding": e.groupPadding ?? 0,
116
124
  "bar-padding": e.barPadding ?? 0.2,
117
125
  orientation: e.orientation ?? i(l).Vertical
118
126
  }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])),
119
- e.hideXAxis ? c("", !0) : (n(), u(i(A), {
127
+ e.hideXAxis ? m("", !0) : (n(), u(i(A), {
120
128
  key: 3,
121
129
  type: "x",
122
130
  "tick-format": e.xFormatter,
@@ -128,7 +136,7 @@ const I = {
128
136
  "tick-values": e.xExplicitTicks,
129
137
  minMaxTicksOnly: e.minMaxTicksOnly
130
138
  }, null, 8, ["tick-format", "label", "grid-line", "domain-line", "tick-line", "num-ticks", "tick-values", "minMaxTicksOnly"])),
131
- e.hideYAxis ? c("", !0) : (n(), u(i(A), {
139
+ e.hideYAxis ? m("", !0) : (n(), u(i(A), {
132
140
  key: 4,
133
141
  type: "y",
134
142
  label: e.yLabel,
@@ -141,28 +149,33 @@ const I = {
141
149
  ]),
142
150
  _: 1
143
151
  }, 8, ["padding", "height"]),
144
- e.hideLegend ? c("", !0) : (n(), m("div", {
152
+ e.hideLegend ? m("", !0) : (n(), y("div", {
145
153
  key: 0,
146
- class: L(["flex items center justify-end", { "pb-4": h.value }])
154
+ style: T({
155
+ display: "flex",
156
+ alignItems: "center",
157
+ justifyContent: "flex-end",
158
+ paddingBottom: h.value ? "1rem" : void 0
159
+ })
147
160
  }, [
148
161
  g(i(R), {
149
162
  items: Object.values(a.categories)
150
163
  }, null, 8, ["items"])
151
- ], 2)),
152
- w("div", I, [
153
- i(P).tooltip ? v(e.$slots, "tooltip", {
164
+ ], 4)),
165
+ O("div", U, [
166
+ i(G).tooltip ? B(e.$slots, "tooltip", {
154
167
  key: 0,
155
168
  values: r.value
156
- }) : r.value ? v(e.$slots, "fallback", { key: 1 }, () => [
169
+ }) : r.value ? B(e.$slots, "fallback", { key: 1 }, () => [
157
170
  g(q, {
158
171
  data: r.value,
159
172
  categories: a.categories,
160
173
  toolTipTitle: i(H)(r.value) ?? "",
161
174
  yFormatter: a.orientation === i(l).Horizontal ? a.xFormatter : a.yFormatter
162
175
  }, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
163
- ]) : c("", !0)
176
+ ]) : m("", !0)
164
177
  ], 512)
165
- ], 2));
178
+ ], 4));
166
179
  }
167
180
  });
168
181
  export {
@@ -6,6 +6,7 @@ export interface StackedGroupedConfig<T> {
6
6
  }>;
7
7
  stackAndGrouped: boolean;
8
8
  xAxis?: keyof T;
9
+ spacing?: number;
9
10
  }
10
11
  export interface StackedGroupedResult<T> {
11
12
  states: string[];
@@ -1,13 +1,11 @@
1
1
  import { computed as u } from "vue";
2
2
  import { flattenData as i } from "../../utils.js";
3
- function b(t) {
3
+ function g(t) {
4
4
  return u(() => {
5
- const o = f(t.categories), e = l(t.categories, o), r = p(e, t.categories), c = d(e), n = m(r), s = h(o);
6
- console.log(t, "config");
7
- const a = t.stackAndGrouped ? i(t.data, t.xAxis) : t.data;
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;
8
6
  return {
9
- states: o,
10
- groupedByState: e,
7
+ states: e,
8
+ groupedByState: o,
11
9
  colors: r,
12
10
  bars: c,
13
11
  colorFunctions: n,
@@ -16,52 +14,52 @@ function b(t) {
16
14
  };
17
15
  });
18
16
  }
19
- function f(t) {
20
- const o = /* @__PURE__ */ new Set();
17
+ function p(t) {
18
+ const e = /* @__PURE__ */ new Set();
21
19
  return Object.keys(t).forEach((r) => {
22
20
  const c = r.match(/([A-Z][a-z]+)$/);
23
- c && o.add(c[1]);
24
- }), Array.from(o);
21
+ c && e.add(c[1]);
22
+ }), Array.from(e);
25
23
  }
26
- function l(t, o) {
27
- const e = {};
28
- return o.forEach((r) => {
29
- e[r] = Object.keys(t).filter(
24
+ function f(t, e) {
25
+ const o = {};
26
+ return e.forEach((r) => {
27
+ o[r] = Object.keys(t).filter(
30
28
  (c) => c.endsWith(r)
31
29
  );
32
- }), e;
30
+ }), o;
33
31
  }
34
- function p(t, o) {
35
- const e = {};
32
+ function d(t, e) {
33
+ const o = {};
36
34
  return Object.entries(t).forEach(([r, c]) => {
37
- e[r] = c.map((n) => {
35
+ o[r] = c.map((n) => {
38
36
  var s;
39
- return ((s = o[n]) == null ? void 0 : s.color) ?? "#ccc";
37
+ return ((s = e[n]) == null ? void 0 : s.color) ?? "#ccc";
40
38
  });
41
- }), e;
39
+ }), o;
42
40
  }
43
- function d(t) {
44
- const o = {};
45
- return Object.entries(t).forEach(([e, r]) => {
46
- o[e] = r.map((c) => {
47
- const n = c.replace(e, "").toLowerCase();
48
- return (s) => s[n + e];
41
+ function l(t) {
42
+ 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];
49
47
  });
50
- }), o;
48
+ }), e;
51
49
  }
52
50
  function m(t) {
53
- const o = {};
54
- return Object.entries(t).forEach(([e, r]) => {
55
- o[e] = (c, n) => r[n] ?? "#ccc";
56
- }), o;
51
+ const e = {};
52
+ return Object.entries(t).forEach(([o, r]) => {
53
+ e[o] = (c, n) => r[n] ?? "#ccc";
54
+ }), e;
57
55
  }
58
- function h(t) {
59
- const o = t.length, e = 0.4, r = {};
56
+ function h(t, e = 0.4) {
57
+ const o = t.length, r = {};
60
58
  return t.forEach((c, n) => {
61
59
  const s = (n - (o - 1) / 2) * e;
62
60
  r[c] = s;
63
61
  }), r;
64
62
  }
65
63
  export {
66
- b as useStackedGrouped
64
+ g as useStackedGrouped
67
65
  };
@@ -133,6 +133,7 @@ type BarChartPropsBase<T> = {
133
133
  * If `true`, hide the y-axis.
134
134
  */
135
135
  hideYAxis?: boolean;
136
+ stackedGroupedSpacing?: number;
136
137
  };
137
138
  type BarChartPropsStackAndGrouped<T> = BarChartPropsBase<T> & {
138
139
  stackAndGrouped: true;
@@ -1,14 +1,19 @@
1
- import { defineComponent as V, useSlots as b, useTemplateRef as w, ref as D, createElementBlock as u, openBlock as c, Fragment as S, createElementVNode as o, createCommentVNode as p, createVNode as n, renderSlot as s, unref as l, withCtx as T, normalizeStyle as W, toDisplayString as B } from "vue";
1
+ import { defineComponent as V, useSlots as b, useTemplateRef as w, ref as T, createElementBlock as u, openBlock as p, Fragment as D, createElementVNode as n, createCommentVNode as m, createVNode as o, renderSlot as i, unref as l, withCtx as S, normalizeStyle as W, toDisplayString as B } from "vue";
2
2
  import { Donut as L } from "@unovis/ts";
3
- import { DonutType as $ } from "./types.js";
4
- import { VisSingleContainer as H, VisTooltip as N, VisDonut as j, VisBulletLegend as z } from "@unovis/vue";
5
- const A = {
3
+ import { DonutType as R } from "./types.js";
4
+ import { VisSingleContainer as H, VisTooltip as N, VisDonut as $, VisBulletLegend as j } from "@unovis/vue";
5
+ const z = {
6
6
  ref: "slotWrapper",
7
- class: "hidden"
8
- }, E = { class: "flex items-center px-[15px] py-[10px]" }, R = {
7
+ style: { display: "none" }
8
+ }, A = { style: { display: "flex", "align-items": "center", padding: "10px 15px" } }, E = {
9
9
  key: 0,
10
- class: "flex items-center justify-center mt-4"
11
- }, U = /* @__PURE__ */ V({
10
+ style: {
11
+ display: "flex",
12
+ alignItems: "center",
13
+ justifyContent: "center",
14
+ marginTop: "1rem"
15
+ }
16
+ }, M = /* @__PURE__ */ V({
12
17
  __name: "DonutChart",
13
18
  props: {
14
19
  type: {},
@@ -21,65 +26,74 @@ const A = {
21
26
  padAngle: {}
22
27
  },
23
28
  emits: ["click"],
24
- setup(f, { emit: m }) {
25
- const g = m, r = f, h = b(), i = w("slotWrapper"), t = D(), v = (e) => e, y = r.type === $.Half;
26
- function k(e) {
27
- return t.value = e, C();
28
- }
29
+ setup(c, { emit: g }) {
30
+ const f = g, r = c, h = b(), s = w("slotWrapper"), t = T(), y = (e) => e, v = r.type === R.Half;
29
31
  function C(e) {
30
- return typeof window > "u" ? "" : i.value ? i.value.innerHTML : "";
32
+ return t.value = e, k();
33
+ }
34
+ function k(e) {
35
+ return typeof window > "u" ? "" : s.value ? s.value.innerHTML : "";
31
36
  }
32
- return (e, d) => (c(), u(S, null, [
33
- o("div", {
34
- class: "flex items-center justify-center",
35
- onClick: d[0] || (d[0] = (a) => g("click", a, t.value))
37
+ return (e, d) => (p(), u(D, null, [
38
+ n("div", {
39
+ style: {
40
+ display: "flex",
41
+ alignItems: "center",
42
+ justifyContent: "center"
43
+ },
44
+ onClick: d[0] || (d[0] = (a) => f("click", a, t.value))
36
45
  }, [
37
- n(l(H), {
46
+ o(l(H), {
38
47
  data: e.data,
39
48
  height: e.height,
40
49
  margin: {}
41
50
  }, {
42
- default: T(() => [
43
- n(l(N), {
51
+ default: S(() => [
52
+ o(l(N), {
44
53
  "horizontal-shift": 20,
45
54
  "vertical-shift": 20,
46
55
  triggers: {
47
- [l(L).selectors.segment]: k
56
+ [l(L).selectors.segment]: C
48
57
  }
49
58
  }, null, 8, ["triggers"]),
50
- n(l(j), {
51
- value: v,
59
+ o(l($), {
60
+ value: y,
52
61
  "corner-radius": e.radius,
53
62
  "arc-width": e.arcWidth ?? 20,
54
63
  color: r.labels.map((a) => a.color),
55
- "angle-range": y ? [-1.5707963267948966, 1.5707963267948966] : [],
64
+ "angle-range": v ? [-1.5707963267948966, 1.5707963267948966] : [],
56
65
  "pad-angle": r.padAngle || 0
57
66
  }, null, 8, ["corner-radius", "arc-width", "color", "angle-range", "pad-angle"])
58
67
  ]),
59
68
  _: 1
60
69
  }, 8, ["data", "height"]),
61
- s(e.$slots, "default"),
62
- o("div", A, [
63
- l(h).tooltip ? s(e.$slots, "tooltip", {
70
+ i(e.$slots, "default"),
71
+ n("div", z, [
72
+ l(h).tooltip ? i(e.$slots, "tooltip", {
64
73
  key: 0,
65
74
  values: t.value
66
- }) : t.value ? s(e.$slots, "fallback", { key: 1 }, () => [
67
- o("div", E, [
68
- o("div", {
69
- class: "w-2 h-2 rounded-full mr-2",
70
- style: W(`background-color: ${r.labels[t.value.index].color} ;`)
75
+ }) : t.value ? i(e.$slots, "fallback", { key: 1 }, () => [
76
+ n("div", A, [
77
+ n("div", {
78
+ style: W({
79
+ width: "0.5rem",
80
+ height: "0.5rem",
81
+ borderRadius: "9999px",
82
+ marginRight: "0.5rem",
83
+ backgroundColor: r.labels[t.value.index].color
84
+ })
71
85
  }, null, 4),
72
- o("div", null, B(t.value.data), 1)
86
+ n("div", null, B(t.value.data), 1)
73
87
  ])
74
- ]) : p("", !0)
88
+ ]) : m("", !0)
75
89
  ], 512)
76
90
  ]),
77
- e.hideLegend ? p("", !0) : (c(), u("div", R, [
78
- n(l(z), { items: e.labels }, null, 8, ["items"])
91
+ e.hideLegend ? m("", !0) : (p(), u("div", E, [
92
+ o(l(j), { items: e.labels }, null, 8, ["items"])
79
93
  ]))
80
94
  ], 64));
81
95
  }
82
96
  });
83
97
  export {
84
- U as default
98
+ M as default
85
99
  };
@@ -1,13 +1,13 @@
1
- import { defineComponent as P, computed as k, useSlots as O, useTemplateRef as j, ref as w, createElementBlock as c, openBlock as n, normalizeClass as g, createVNode as s, createCommentVNode as l, createElementVNode as x, unref as i, withCtx as M, createBlock as d, Fragment as W, renderList as E, mergeProps as G, renderSlot as h } from "vue";
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";
2
2
  import { Position as v, CurveType as X } from "@unovis/ts";
3
- import { createMarkers as $, getFirstPropertyValue as z } from "../../utils.js";
4
- import R from "../Tooltip.js";
5
- import { VisXYContainer as Y, VisTooltip as S, VisLine as H, VisAxis as T, VisCrosshair as U, VisBulletLegend as q } from "@unovis/vue";
6
- import { LegendPosition as I } from "../../types.js";
7
- const J = {
3
+ import { createMarkers as $, getFirstPropertyValue as R } from "../../utils.js";
4
+ import S from "../Tooltip.js";
5
+ import { VisXYContainer as Y, VisTooltip as H, VisLine as I, VisAxis as T, VisCrosshair as U, VisBulletLegend as q } from "@unovis/vue";
6
+ import { LegendPosition as J } from "../../types.js";
7
+ const Q = {
8
8
  ref: "slotWrapper",
9
- class: "hidden"
10
- }, te = /* @__PURE__ */ P({
9
+ style: { display: "none" }
10
+ }, oe = /* @__PURE__ */ P({
11
11
  __name: "LineChart",
12
12
  props: {
13
13
  data: {},
@@ -48,46 +48,48 @@ const J = {
48
48
  },
49
49
  emits: ["click"],
50
50
  setup(o, { emit: L }) {
51
- const C = L, t = o, b = k(() => t.markerConfig ? $(t.markerConfig) : ""), B = O(), p = j("slotWrapper"), a = w();
51
+ const C = L, t = o, B = f(() => t.markerConfig ? $(t.markerConfig) : ""), b = O(), c = j("slotWrapper"), l = w();
52
52
  function D(e) {
53
- return typeof window > "u" ? "" : p.value ? p.value.innerHTML : "";
53
+ return typeof window > "u" ? "" : c.value ? c.value.innerHTML : "";
54
54
  }
55
55
  function V(e) {
56
- return a.value = e, D();
56
+ return l.value = e, D();
57
57
  }
58
- const y = k(
59
- () => t.legendPosition === I.Top
58
+ const y = f(
59
+ () => t.legendPosition === J.Top
60
60
  ), A = Object.values(t.categories).map(
61
61
  (e, r) => `var(--vis-color${r})`
62
62
  ), F = (e) => Object.values(t.categories)[e].color ?? A[e];
63
- return (e, r) => (n(), c("div", {
64
- class: g(["flex flex-col space-y-4", {
65
- "flex-col-reverse": y.value,
66
- markers: !!t.markerConfig
67
- }]),
68
- onClick: r[0] || (r[0] = (m) => C("click", m, a.value))
63
+ return (e, r) => (n(), p("div", {
64
+ style: k({
65
+ display: "flex",
66
+ flexDirection: y.value ? "column-reverse" : "column",
67
+ gap: "1rem"
68
+ }),
69
+ class: x({ markers: !!t.markerConfig }),
70
+ onClick: r[0] || (r[0] = (d) => C("click", d, l.value))
69
71
  }, [
70
72
  s(i(Y), {
71
73
  data: e.data,
72
74
  padding: e.padding,
73
75
  height: e.height,
74
- svgDefs: b.value
76
+ svgDefs: B.value
75
77
  }, {
76
- default: M(() => [
77
- s(i(S), {
78
+ default: W(() => [
79
+ s(i(H), {
78
80
  "horizontal-placement": i(v).Right,
79
81
  "vertical-placement": i(v).Top
80
82
  }, null, 8, ["horizontal-placement", "vertical-placement"]),
81
- (n(!0), c(W, null, E(Object.keys(t.categories), (m, u) => (n(), d(i(H), {
83
+ (n(!0), p(z, null, E(Object.keys(t.categories), (d, u) => (n(), m(i(I), {
82
84
  key: u,
83
- x: (f, N) => N,
84
- y: (f) => f[m],
85
+ x: (g, N) => N,
86
+ y: (g) => g[d],
85
87
  color: F(u),
86
88
  "curve-type": e.curveType ?? i(X).MonotoneX,
87
89
  "line-width": e.lineWidth,
88
90
  lineDashArray: e.lineDashArray ? e.lineDashArray[u] : void 0
89
91
  }, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"]))), 128)),
90
- e.hideXAxis ? l("", !0) : (n(), d(i(T), {
92
+ e.hideXAxis ? a("", !0) : (n(), m(i(T), {
91
93
  key: 0,
92
94
  type: "x",
93
95
  "tick-format": e.xFormatter,
@@ -100,7 +102,7 @@ const J = {
100
102
  "tick-values": e.xExplicitTicks,
101
103
  "min-max-ticks-only": e.minMaxTicksOnly
102
104
  }, null, 8, ["tick-format", "label", "domain-line", "grid-line", "tick-line", "num-ticks", "tick-values", "min-max-ticks-only"])),
103
- e.hideYAxis ? l("", !0) : (n(), d(i(T), {
105
+ e.hideYAxis ? a("", !0) : (n(), m(i(T), {
104
106
  key: 1,
105
107
  type: "y",
106
108
  "tick-format": e.yFormatter,
@@ -110,34 +112,39 @@ const J = {
110
112
  "grid-line": e.yGridLine,
111
113
  "tick-line": e.yTickLine
112
114
  }, null, 8, ["tick-format", "label", "num-ticks", "domain-line", "grid-line", "tick-line"])),
113
- e.hideTooltip ? l("", !0) : (n(), d(i(U), G({ key: 2 }, e.crosshairConfig, { template: V }), null, 16))
115
+ e.hideTooltip ? a("", !0) : (n(), m(i(U), G({ key: 2 }, e.crosshairConfig, { template: V }), null, 16))
114
116
  ]),
115
117
  _: 1
116
118
  }, 8, ["data", "padding", "height", "svgDefs"]),
117
- e.hideLegend ? l("", !0) : (n(), c("div", {
119
+ e.hideLegend ? a("", !0) : (n(), p("div", {
118
120
  key: 0,
119
- class: g(["flex items center justify-end", { "pb-4": y.value }])
121
+ style: k({
122
+ display: "flex",
123
+ alignItems: "center",
124
+ justifyContent: "flex-end",
125
+ paddingBottom: y.value ? "1rem" : void 0
126
+ })
120
127
  }, [
121
128
  s(i(q), {
122
129
  items: Object.values(e.categories)
123
130
  }, null, 8, ["items"])
124
- ], 2)),
125
- x("div", J, [
126
- i(B).tooltip ? h(e.$slots, "tooltip", {
131
+ ], 4)),
132
+ M("div", Q, [
133
+ i(b).tooltip ? h(e.$slots, "tooltip", {
127
134
  key: 0,
128
- values: a.value
129
- }) : a.value ? h(e.$slots, "fallback", { key: 1 }, () => [
130
- s(R, {
131
- data: a.value,
135
+ values: l.value
136
+ }) : l.value ? h(e.$slots, "fallback", { key: 1 }, () => [
137
+ s(S, {
138
+ data: l.value,
132
139
  categories: e.categories,
133
- toolTipTitle: i(z)(a.value) ?? "",
140
+ toolTipTitle: i(R)(l.value) ?? "",
134
141
  yFormatter: t.yFormatter
135
142
  }, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
136
- ]) : l("", !0)
143
+ ]) : a("", !0)
137
144
  ], 512)
138
- ], 2));
145
+ ], 6));
139
146
  }
140
147
  });
141
148
  export {
142
- te as default
149
+ oe as default
143
150
  };
@@ -1,11 +1,11 @@
1
- import { defineComponent as b, computed as v, createElementBlock as r, openBlock as i, createElementVNode as o, toDisplayString as l, Fragment as y, renderList as h, normalizeStyle as a } from "vue";
2
- const f = { class: "px-[15px] py-[10px]" }, _ = {
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__ */ b({
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: {
3
+ color: "var(--tooltip-value-color)",
4
+ textTransform: "capitalize",
5
+ borderBottom: "1px solid rgba(255, 255, 255, 0.05)",
6
+ marginBottom: "0.25rem",
7
+ paddingBottom: "0.25rem"
8
+ } }, B = /* @__PURE__ */ v({
9
9
  __name: "Tooltip",
10
10
  props: {
11
11
  data: {},
@@ -13,30 +13,30 @@ const f = { class: "px-[15px] py-[10px]" }, _ = {
13
13
  toolTipTitle: {},
14
14
  yFormatter: { type: Function }
15
15
  },
16
- setup(p) {
17
- const n = p, d = ["_index", "_stacked", "_ending"], m = v(() => Object.entries(n.data ?? []).filter(
18
- ([e, g]) => !d.includes(e) && Object.keys(n.categories).includes(e)
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)
19
19
  ));
20
- return (e, g) => (i(), r("div", f, [
21
- o("div", _, l(e.toolTipTitle), 1),
22
- (i(!0), r(y, null, h(m.value, ([t, s], u) => {
23
- var c;
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;
24
24
  return i(), r("div", {
25
- key: t,
25
+ key: o,
26
26
  style: { display: "flex", "align-items": "center", "margin-bottom": "4px" }
27
27
  }, [
28
- o("span", {
29
- style: a([{ 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
+ e("span", {
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})`
31
31
  }])
32
32
  }, null, 4),
33
- o("div", null, [
34
- o("span", {
35
- style: a([{ "font-weight": "600", "margin-right": "8px" }, { color: "var(--tooltip-label-color)" }])
36
- }, l(e.categories[t].name) + ":", 1),
37
- o("span", {
38
- style: a([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
39
- }, l(e.yFormatter ? e.yFormatter(s) : s), 1)
33
+ e("div", null, [
34
+ e("span", {
35
+ style: n([{ "font-weight": "600", "margin-right": "8px" }, { color: "var(--tooltip-label-color)" }])
36
+ }, l(t.categories[o].name) + ":", 1),
37
+ e("span", {
38
+ style: n([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
39
+ }, l(t.yFormatter ? t.yFormatter(s) : s), 1)
40
40
  ])
41
41
  ]);
42
42
  }), 128))
@@ -44,5 +44,5 @@ const f = { class: "px-[15px] py-[10px]" }, _ = {
44
44
  }
45
45
  });
46
46
  export {
47
- F as default
47
+ B as default
48
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-chrts",
3
- "version": "0.2.1",
3
+ "version": "0.2.2-test.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -27,12 +27,14 @@
27
27
  "@tailwindcss/vite": "^4.0.15",
28
28
  "@tanstack/vue-table": "^8.21.2",
29
29
  "@types/node": "^22.13.11",
30
+ "@types/rollup": "^0.54.0",
30
31
  "@unovis/ts": "^1.5.2",
31
32
  "@unovis/vue": "^1.5.2",
32
33
  "@vitejs/plugin-vue": "^5.2.1",
33
34
  "@vue/tsconfig": "^0.7.0",
34
35
  "@vueuse/core": "^13.0.0",
35
36
  "commit-and-tag-version": "^12.5.1",
37
+ "rollup": "^4.46.2",
36
38
  "tailwindcss": "^4.0.15",
37
39
  "typescript": "~5.7.2",
38
40
  "vite": "^6.2.0",