vue-chrts 0.2.3 → 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 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 = {
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
+ const ie = {
8
8
  ref: "slotWrapper",
9
9
  style: { display: "none" }
10
- }, y = 24, V = 4, ie = 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 te = {
22
22
  curveType: {},
23
23
  lineWidth: { default: 2 },
24
24
  lineDashArray: {},
25
- xNumTicks: { default: (a) => a.data.length > y ? y / V : a.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: (a) => a.data.length > y ? y / V : a.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 },
@@ -39,79 +40,84 @@ const te = {
39
40
  hideYAxis: { type: Boolean },
40
41
  crosshairConfig: { default: () => ({
41
42
  color: "#666"
42
- }) }
43
+ }) },
44
+ yDomain: {},
45
+ xDomain: {}
43
46
  },
44
47
  emits: ["click"],
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
- const e = (t, o) => `
50
- <linearGradient id="gradient${t}-${o}" gradientTransform="rotate(90)">
51
- <stop offset="0%" stop-color="${o}" stop-opacity="1" />
52
- <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" />
53
56
  </linearGradient>
54
- `, l = (t, o) => `
55
- <linearGradient id="gradient${t}-${o}" gradientTransform="rotate(90)">
57
+ `, r = (t, a) => `
58
+ <linearGradient id="gradient${t}-${a}" gradientTransform="rotate(90)">
56
59
  <stop offset="0%" style="stop-color:var(--vis-color0);stop-opacity:1" />
57
60
  <stop offset="100%" style="stop-color:var(--vis-color0);stop-opacity:0" />
58
61
  </linearGradient>
59
62
  `;
60
- return f.value.map(
61
- (t, o) => t != null && t.includes("#") ? e(o, t) : l(o, t ?? F)
63
+ return g.value.map(
64
+ (t, a) => t != null && t.includes("#") ? l(a, t) : r(a, t ?? B)
62
65
  ).join("");
63
66
  });
64
- function P(e) {
65
- var l;
67
+ function E(l) {
68
+ var r;
66
69
  return {
67
- y: (t) => Number(t[e]),
68
- 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
69
72
  };
70
73
  }
71
- function W(e) {
72
- return typeof window > "u" ? "" : h.value ? h.value.innerHTML : "";
74
+ function W(l) {
75
+ return typeof window > "u" ? "" : T.value ? T.value.innerHTML : "";
73
76
  }
74
- function M(e) {
75
- return s.value = e, W();
77
+ function S(l) {
78
+ return s.value = l, W();
76
79
  }
77
- return (e, l) => (r(), m("div", {
78
- style: T({
80
+ return (l, r) => (o(), m("div", {
81
+ style: h({
79
82
  display: "flex",
80
- flexDirection: g.value ? "column-reverse" : "column"
83
+ flexDirection: O.value ? "column-reverse" : "column",
84
+ gap: "var(--vis-legend-spacing)"
81
85
  }),
82
- class: S({ markers: !!n.markerConfig }),
83
- onClick: l[0] || (l[0] = (t) => G("click", t, s.value))
86
+ class: R({ markers: !!n.markerConfig }),
87
+ onClick: r[0] || (r[0] = (t) => F("click", t, s.value))
84
88
  }, [
85
- p(i(K), {
89
+ u(i(q), {
86
90
  data: e.data,
87
91
  height: e.height,
88
92
  padding: e.padding,
89
- "svg-defs": E.value + N.value
93
+ "svg-defs": P.value + G.value,
94
+ "y-domain": e.yDomain,
95
+ "x-domain": e.xDomain
90
96
  }, {
91
97
  default: z(() => [
92
- e.hideTooltip ? d("", !0) : (r(), c(i(q), {
98
+ e.hideTooltip ? c("", !0) : (o(), y(i(J), {
93
99
  key: 0,
94
- "horizontal-placement": i(D).Right,
95
- "vertical-placement": i(D).Top
100
+ "horizontal-placement": i(C).Right,
101
+ "vertical-placement": i(C).Top
96
102
  }, null, 8, ["horizontal-placement", "vertical-placement"])),
97
- (r(!0), m(L, null, I(Object.keys(n.categories), (t, o) => (r(), m(L, { key: t }, [
98
- p(i(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({
99
105
  x: (k, v) => v
100
- }, { ref_for: !0 }, P(t), {
101
- color: `url(#gradient${o}-${f.value[o]})`,
102
- opacity: ie,
103
- "curve-type": e.curveType ?? i(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
104
110
  }), null, 16, ["x", "color", "curve-type"]),
105
- p(i(Q), {
111
+ u(i(Z), {
106
112
  x: (k, v) => v,
107
113
  y: (k) => k[t],
108
- color: f.value[o],
109
- "curve-type": e.curveType ?? i(b).MonotoneX,
114
+ color: g.value[a],
115
+ "curve-type": e.curveType ?? i(D).MonotoneX,
110
116
  "line-width": e.lineWidth,
111
- lineDashArray: e.lineDashArray ? e.lineDashArray[o] : void 0
117
+ lineDashArray: e.lineDashArray ? e.lineDashArray[a] : void 0
112
118
  }, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"])
113
119
  ], 64))), 128)),
114
- e.hideXAxis ? d("", !0) : (r(), c(i(B), {
120
+ e.hideXAxis ? c("", !0) : (o(), y(i(A), {
115
121
  key: 1,
116
122
  type: "x",
117
123
  label: e.xLabel,
@@ -124,7 +130,7 @@ const te = {
124
130
  "tick-line": e.xTickLine,
125
131
  "min-max-ticks-only": e.minMaxTicksOnly
126
132
  }, null, 8, ["label", "num-ticks", "tick-format", "tick-values", "grid-line", "domain-line", "tick-line", "min-max-ticks-only"])),
127
- e.hideYAxis ? d("", !0) : (r(), c(i(B), {
133
+ e.hideYAxis ? c("", !0) : (o(), y(i(A), {
128
134
  key: 2,
129
135
  type: "y",
130
136
  label: e.yLabel,
@@ -134,36 +140,37 @@ const te = {
134
140
  "domain-line": e.yDomainLine,
135
141
  "tick-line": e.yTickLine
136
142
  }, null, 8, ["label", "num-ticks", "tick-format", "grid-line", "domain-line", "tick-line"])),
137
- e.hideTooltip ? d("", !0) : (r(), c(i(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))
138
144
  ]),
139
145
  _: 1
140
- }, 8, ["data", "height", "padding", "svg-defs"]),
141
- e.hideLegend ? d("", !0) : (r(), m("div", {
146
+ }, 8, ["data", "height", "padding", "svg-defs", "y-domain", "x-domain"]),
147
+ n.hideLegend ? c("", !0) : (o(), m("div", {
142
148
  key: 0,
143
- style: T({
149
+ style: h({
144
150
  display: "flex",
145
- alignItems: "center",
146
- justifyContent: "flex-end",
147
- paddingBottom: g.value ? "1rem" : void 0,
148
- paddingTop: g.value ? void 0 : "1rem"
151
+ justifyContent: N.value
149
152
  })
150
153
  }, [
151
- p(i(_), {
152
- items: Object.values(e.categories)
153
- }, 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"])
154
161
  ], 4)),
155
- X("div", te, [
156
- i(O).tooltip ? A(e.$slots, "tooltip", {
162
+ X("div", ie, [
163
+ i($).tooltip ? L(l.$slots, "tooltip", {
157
164
  key: 0,
158
165
  values: s.value
159
- }) : s.value ? A(e.$slots, "fallback", { key: 1 }, () => [
160
- p(H, {
166
+ }) : s.value ? L(l.$slots, "fallback", { key: 1 }, () => [
167
+ u(K, {
161
168
  data: s.value,
162
169
  categories: e.categories,
163
- toolTipTitle: i(x)(s.value) ?? "",
170
+ toolTipTitle: i(H)(s.value) ?? "",
164
171
  yFormatter: n.yFormatter
165
172
  }, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
166
- ]) : d("", !0)
173
+ ]) : c("", !0)
167
174
  ], 512)
168
175
  ], 6));
169
176
  }
@@ -72,7 +72,7 @@ export interface AreaChartProps<T> {
72
72
  /**
73
73
  * Force specific ticks on the x-axis.
74
74
  */
75
- xExplicitTicks?: number;
75
+ xExplicitTicks?: (number | string | Date)[];
76
76
  /**
77
77
  * Force only first and last ticks on the x-axis.
78
78
  */
@@ -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
  */
@@ -130,4 +134,12 @@ export interface AreaChartProps<T> {
130
134
  * Crosshair configuration object for customizing the appearance of the crosshair line.
131
135
  */
132
136
  crosshairConfig?: CrosshairConfig;
137
+ /**
138
+ * The domain for the y-axis, specified as a tuple of two values.
139
+ */
140
+ yDomain?: [number | undefined, number | undefined];
141
+ /**
142
+ * The domain for the x-axis, specified as a tuple of two values.
143
+ */
144
+ xDomain?: [number | undefined, number | undefined];
133
145
  }
@@ -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
  };