vue-chrts 0.2.4 → 0.2.5-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 p, createElementBlock as u, openBlock as a, normalizeClass as S, normalizeStyle as T, createVNode as m, createCommentVNode as d, createElementVNode as X, unref as t, withCtx as x, createBlock as c, Fragment as L, renderList as z, mergeProps as C, renderSlot as D } from "vue";
2
- import { Position as A, CurveType as b } from "@unovis/ts";
3
- import { createMarkers as I, getFirstPropertyValue as Y } 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";
1
+ import { defineComponent as M, useSlots as U, useTemplateRef as j, ref as w, computed as d, createElementBlock as m, openBlock as o, normalizeClass as R, normalizeStyle as h, createVNode as u, createCommentVNode as c, createElementVNode as X, unref as i, withCtx as z, createBlock as y, Fragment as x, renderList as Y, mergeProps as p, renderSlot as L } from "vue";
2
+ import { Position as C, CurveType as D } from "@unovis/ts";
3
+ import { createMarkers as I, getFirstPropertyValue as H } from "../../utils.js";
4
+ import K from "../Tooltip.js";
5
+ import { VisXYContainer as q, VisTooltip as J, VisArea as Q, VisLine as Z, VisAxis as A, VisCrosshair as _, VisBulletLegend as ee } from "@unovis/vue";
6
+ import { LegendPosition as te } from "../../types.js";
7
7
  const ie = {
8
8
  ref: "slotWrapper",
9
9
  style: { display: "none" }
10
- }, y = 24, V = 4, te = 0.5, F = "#3b82f6", de = /* @__PURE__ */ U({
10
+ }, f = 24, b = 4, ne = 0.5, B = "#3b82f6", de = /* @__PURE__ */ M({
11
11
  __name: "AreaChart",
12
12
  props: {
13
13
  data: {},
@@ -22,13 +22,14 @@ const ie = {
22
22
  curveType: {},
23
23
  lineWidth: { default: 2 },
24
24
  lineDashArray: {},
25
- xNumTicks: { default: (r) => r.data.length > y ? y / V : r.data.length - 1 },
25
+ xNumTicks: { default: (e) => e.data.length > f ? f / b : e.data.length - 1 },
26
26
  xExplicitTicks: {},
27
27
  minMaxTicksOnly: { type: Boolean },
28
- yNumTicks: { default: (r) => r.data.length > y ? y / V : r.data.length - 1 },
29
- hideLegend: { type: Boolean },
28
+ yNumTicks: { default: (e) => e.data.length > f ? f / b : e.data.length - 1 },
29
+ hideLegend: { type: Boolean, default: !1 },
30
30
  hideTooltip: { type: Boolean },
31
- legendPosition: {},
31
+ legendPosition: { default: te.BottomCenter },
32
+ legendStyle: { default: void 0 },
32
33
  xDomainLine: { type: Boolean },
33
34
  yDomainLine: { type: Boolean },
34
35
  xTickLine: { type: Boolean },
@@ -44,78 +45,79 @@ const ie = {
44
45
  xDomain: {}
45
46
  },
46
47
  emits: ["click"],
47
- setup(r, { emit: $ }) {
48
- const G = $, n = r, O = j(), h = w("slotWrapper"), s = R(), f = p(
49
- () => Object.values(n.categories).map((e) => e.color)
50
- ), N = p(() => n.markerConfig ? I(n.markerConfig) : ""), g = p(() => n.legendPosition === ee.Top), E = p(() => {
51
- const e = (i, o) => `
52
- <linearGradient id="gradient${i}-${o}" gradientTransform="rotate(90)">
53
- <stop offset="0%" stop-color="${o}" stop-opacity="1" />
54
- <stop offset="100%" stop-color="${o}" stop-opacity="0" />
48
+ setup(e, { emit: V }) {
49
+ const F = V, n = e, $ = U(), T = j("slotWrapper"), s = w(), g = d(
50
+ () => Object.values(n.categories).map((l) => l.color)
51
+ ), G = d(() => n.markerConfig ? I(n.markerConfig) : ""), O = d(() => n.legendPosition.startsWith("top")), N = d(() => n.legendPosition.includes("left") ? "flex-start" : n.legendPosition.includes("right") ? "flex-end" : "center"), P = d(() => {
52
+ const l = (t, a) => `
53
+ <linearGradient id="gradient${t}-${a}" gradientTransform="rotate(90)">
54
+ <stop offset="0%" stop-color="${a}" stop-opacity="1" />
55
+ <stop offset="100%" stop-color="${a}" stop-opacity="0" />
55
56
  </linearGradient>
56
- `, l = (i, o) => `
57
- <linearGradient id="gradient${i}-${o}" gradientTransform="rotate(90)">
57
+ `, r = (t, a) => `
58
+ <linearGradient id="gradient${t}-${a}" gradientTransform="rotate(90)">
58
59
  <stop offset="0%" style="stop-color:var(--vis-color0);stop-opacity:1" />
59
60
  <stop offset="100%" style="stop-color:var(--vis-color0);stop-opacity:0" />
60
61
  </linearGradient>
61
62
  `;
62
- return f.value.map(
63
- (i, o) => i != null && i.includes("#") ? e(o, i) : l(o, i ?? F)
63
+ return g.value.map(
64
+ (t, a) => t != null && t.includes("#") ? l(a, t) : r(a, t ?? B)
64
65
  ).join("");
65
66
  });
66
- function P(e) {
67
- var l;
67
+ function E(l) {
68
+ var r;
68
69
  return {
69
- y: (i) => Number(i[e]),
70
- color: ((l = n.categories[e]) == null ? void 0 : l.color) ?? F
70
+ y: (t) => Number(t[l]),
71
+ color: ((r = n.categories[l]) == null ? void 0 : r.color) ?? B
71
72
  };
72
73
  }
73
- function W(e) {
74
- return typeof window > "u" ? "" : h.value ? h.value.innerHTML : "";
74
+ function W(l) {
75
+ return typeof window > "u" ? "" : T.value ? T.value.innerHTML : "";
75
76
  }
76
- function M(e) {
77
- return s.value = e, W();
77
+ function S(l) {
78
+ return s.value = l, W();
78
79
  }
79
- return (e, l) => (a(), u("div", {
80
- style: T({
80
+ return (l, r) => (o(), m("div", {
81
+ style: h({
81
82
  display: "flex",
82
- flexDirection: g.value ? "column-reverse" : "column"
83
+ flexDirection: O.value ? "column-reverse" : "column",
84
+ gap: "var(--vis-legend-spacing)"
83
85
  }),
84
- class: S({ markers: !!n.markerConfig }),
85
- onClick: l[0] || (l[0] = (i) => G("click", i, s.value))
86
+ class: R({ markers: !!n.markerConfig }),
87
+ onClick: r[0] || (r[0] = (t) => F("click", t, s.value))
86
88
  }, [
87
- m(t(K), {
89
+ u(i(q), {
88
90
  data: e.data,
89
91
  height: e.height,
90
92
  padding: e.padding,
91
- "svg-defs": E.value + N.value,
93
+ "svg-defs": P.value + G.value,
92
94
  "y-domain": e.yDomain,
93
95
  "x-domain": e.xDomain
94
96
  }, {
95
- default: x(() => [
96
- e.hideTooltip ? d("", !0) : (a(), c(t(q), {
97
+ default: z(() => [
98
+ e.hideTooltip ? c("", !0) : (o(), y(i(J), {
97
99
  key: 0,
98
- "horizontal-placement": t(A).Right,
99
- "vertical-placement": t(A).Top
100
+ "horizontal-placement": i(C).Right,
101
+ "vertical-placement": i(C).Top
100
102
  }, null, 8, ["horizontal-placement", "vertical-placement"])),
101
- (a(!0), u(L, null, z(Object.keys(n.categories), (i, o) => (a(), u(L, { key: i }, [
102
- m(t(J), C({
103
+ (o(!0), m(x, null, Y(Object.keys(n.categories), (t, a) => (o(), m(x, { key: t }, [
104
+ u(i(Q), p({
103
105
  x: (k, v) => v
104
- }, { ref_for: !0 }, P(i), {
105
- color: `url(#gradient${o}-${f.value[o]})`,
106
- opacity: te,
107
- "curve-type": e.curveType ?? t(b).MonotoneX
106
+ }, { ref_for: !0 }, E(t), {
107
+ color: `url(#gradient${a}-${g.value[a]})`,
108
+ opacity: ne,
109
+ "curve-type": e.curveType ?? i(D).MonotoneX
108
110
  }), null, 16, ["x", "color", "curve-type"]),
109
- m(t(Q), {
111
+ u(i(Z), {
110
112
  x: (k, v) => v,
111
- y: (k) => k[i],
112
- color: f.value[o],
113
- "curve-type": e.curveType ?? t(b).MonotoneX,
113
+ y: (k) => k[t],
114
+ color: g.value[a],
115
+ "curve-type": e.curveType ?? i(D).MonotoneX,
114
116
  "line-width": e.lineWidth,
115
- lineDashArray: e.lineDashArray ? e.lineDashArray[o] : void 0
117
+ lineDashArray: e.lineDashArray ? e.lineDashArray[a] : void 0
116
118
  }, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"])
117
119
  ], 64))), 128)),
118
- e.hideXAxis ? d("", !0) : (a(), c(t(B), {
120
+ e.hideXAxis ? c("", !0) : (o(), y(i(A), {
119
121
  key: 1,
120
122
  type: "x",
121
123
  label: e.xLabel,
@@ -128,7 +130,7 @@ const ie = {
128
130
  "tick-line": e.xTickLine,
129
131
  "min-max-ticks-only": e.minMaxTicksOnly
130
132
  }, null, 8, ["label", "num-ticks", "tick-format", "tick-values", "grid-line", "domain-line", "tick-line", "min-max-ticks-only"])),
131
- e.hideYAxis ? d("", !0) : (a(), c(t(B), {
133
+ e.hideYAxis ? c("", !0) : (o(), y(i(A), {
132
134
  key: 2,
133
135
  type: "y",
134
136
  label: e.yLabel,
@@ -138,36 +140,37 @@ const ie = {
138
140
  "domain-line": e.yDomainLine,
139
141
  "tick-line": e.yTickLine
140
142
  }, null, 8, ["label", "num-ticks", "tick-format", "grid-line", "domain-line", "tick-line"])),
141
- e.hideTooltip ? d("", !0) : (a(), c(t(Z), C({ key: 3 }, e.crosshairConfig, { template: M }), null, 16))
143
+ e.hideTooltip ? c("", !0) : (o(), y(i(_), p({ key: 3 }, e.crosshairConfig, { template: S }), null, 16))
142
144
  ]),
143
145
  _: 1
144
146
  }, 8, ["data", "height", "padding", "svg-defs", "y-domain", "x-domain"]),
145
- e.hideLegend ? d("", !0) : (a(), u("div", {
147
+ n.hideLegend ? c("", !0) : (o(), m("div", {
146
148
  key: 0,
147
- style: T({
149
+ style: h({
148
150
  display: "flex",
149
- alignItems: "center",
150
- justifyContent: "flex-end",
151
- paddingBottom: g.value ? "1rem" : void 0,
152
- paddingTop: g.value ? void 0 : "1rem"
151
+ justifyContent: N.value
153
152
  })
154
153
  }, [
155
- m(t(_), {
156
- items: Object.values(e.categories)
157
- }, null, 8, ["items"])
154
+ u(i(ee), {
155
+ style: h([
156
+ n.legendStyle,
157
+ "display: flex; gap: var(--vis-legend-spacing);"
158
+ ]),
159
+ items: Object.values(n.categories)
160
+ }, null, 8, ["style", "items"])
158
161
  ], 4)),
159
162
  X("div", ie, [
160
- t(O).tooltip ? D(e.$slots, "tooltip", {
163
+ i($).tooltip ? L(l.$slots, "tooltip", {
161
164
  key: 0,
162
165
  values: s.value
163
- }) : s.value ? D(e.$slots, "fallback", { key: 1 }, () => [
164
- m(H, {
166
+ }) : s.value ? L(l.$slots, "fallback", { key: 1 }, () => [
167
+ u(K, {
165
168
  data: s.value,
166
169
  categories: e.categories,
167
- toolTipTitle: t(Y)(s.value) ?? "",
170
+ toolTipTitle: i(H)(s.value) ?? "",
168
171
  yFormatter: n.yFormatter
169
172
  }, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
170
- ]) : d("", !0)
173
+ ]) : c("", !0)
171
174
  ], 512)
172
175
  ], 6));
173
176
  }
@@ -94,6 +94,10 @@ export interface AreaChartProps<T> {
94
94
  * See `LegendPosition` for available options.
95
95
  */
96
96
  legendPosition?: LegendPosition;
97
+ /**
98
+ * Optional style object for the legend container. Allows custom CSS styling.
99
+ */
100
+ legendStyle?: string | Record<string, string>;
97
101
  /**
98
102
  * If `true`, displays a domain line (axis line) along the x-axis.
99
103
  */
@@ -1,8 +1,8 @@
1
- import { defineComponent as y, computed as f, createApp as h, createElementBlock as g, openBlock as a, createVNode as n, createElementVNode as B, unref as t, withCtx as L, createBlock as v, createCommentVNode as C, mergeProps as k } from "vue";
2
- import { VisXYContainer as b, VisArea as x, VisAxis as s, VisCrosshair as T, VisBulletLegend as V } from "@unovis/vue";
3
- import { CurveType as _ } from "@unovis/ts";
4
- import N from "../Tooltip.js";
5
- const A = { class: "flex flex-col space-y-4" }, j = { class: "flex items center justify-end" }, O = /* @__PURE__ */ y({
1
+ import { defineComponent as y, computed as f, createApp as h, createElementBlock as g, openBlock as c, createVNode as i, createElementVNode as x, unref as o, withCtx as B, createBlock as L, createCommentVNode as v, mergeProps as C } from "vue";
2
+ import { VisXYContainer as k, VisArea as b, VisAxis as s, VisCrosshair as T, VisBulletLegend as V } from "@unovis/vue";
3
+ import { CurveType as N } from "@unovis/ts";
4
+ import A from "../Tooltip.js";
5
+ const j = { class: "flex flex-col space-y-4" }, w = { class: "flex items center justify-end" }, H = /* @__PURE__ */ y({
6
6
  __name: "AreaStackedChart",
7
7
  props: {
8
8
  data: {},
@@ -21,57 +21,57 @@ const A = { class: "flex flex-col space-y-4" }, j = { class: "flex items center
21
21
  yTickLine: { type: Boolean },
22
22
  crosshairConfig: {}
23
23
  },
24
- setup(c) {
25
- const i = c, l = f(() => (e, m) => {
24
+ setup(t) {
25
+ const a = t, l = f(() => (e, u) => {
26
26
  if (typeof window > "u" || typeof document > "u")
27
27
  return "";
28
28
  try {
29
- const o = h(N, {
29
+ const n = h(A, {
30
30
  data: e,
31
- categories: i.categories
31
+ categories: a.categories
32
32
  }), r = document.createElement("div");
33
- o.mount(r);
34
- const u = r.innerHTML;
35
- return o.unmount(), u;
33
+ n.mount(r);
34
+ const p = r.innerHTML;
35
+ return n.unmount(), p;
36
36
  } catch {
37
37
  return "";
38
38
  }
39
- }), p = (e) => Number.parseInt(e.time), d = [(e) => e.firstTime, (e) => e.returning];
40
- return (e, m) => (a(), g("div", A, [
41
- n(t(b), {
42
- data: e.data,
43
- padding: e.padding,
44
- height: e.height
39
+ }), d = (e) => Number.parseInt(e.time), m = [(e) => e.firstTime, (e) => e.returning];
40
+ return (e, u) => (c(), g("div", j, [
41
+ i(o(k), {
42
+ data: t.data,
43
+ padding: t.padding,
44
+ height: t.height
45
45
  }, {
46
- default: L(() => [
47
- n(t(x), {
48
- x: p,
49
- y: d,
50
- color: Object.values(i.categories).map((o) => o.color),
51
- "curve-type": t(_).Linear
46
+ default: B(() => [
47
+ i(o(b), {
48
+ x: d,
49
+ y: m,
50
+ color: Object.values(a.categories).map((n) => n.color),
51
+ "curve-type": o(N).Linear
52
52
  }, null, 8, ["color", "curve-type"]),
53
- n(t(s), {
53
+ i(o(s), {
54
54
  type: "x",
55
55
  label: "Time",
56
56
  "num-ticks": 12
57
57
  }),
58
- n(t(s), {
58
+ i(o(s), {
59
59
  type: "y",
60
60
  label: "Number of visitors",
61
61
  "num-ticks": 3
62
62
  }),
63
- e.hideTooltip ? C("", !0) : (a(), v(t(T), k({ key: 0 }, e.crosshairConfig, { template: l.value }), null, 16, ["template"]))
63
+ t.hideTooltip ? v("", !0) : (c(), L(o(T), C({ key: 0 }, t.crosshairConfig, { template: l.value }), null, 16, ["template"]))
64
64
  ]),
65
65
  _: 1
66
66
  }, 8, ["data", "padding", "height"]),
67
- B("div", j, [
68
- n(t(V), {
69
- items: Object.values(e.categories)
67
+ x("div", w, [
68
+ i(o(V), {
69
+ items: Object.values(t.categories)
70
70
  }, null, 8, ["items"])
71
71
  ])
72
72
  ]));
73
73
  }
74
74
  });
75
75
  export {
76
- O as default
76
+ H as default
77
77
  };