vue-chrts 0.2.5-test.2 → 0.2.5-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,4 +1,4 @@
1
- import { defineComponent as N, useSlots as W, useTemplateRef as E, ref as M, computed as m, createElementBlock as f, openBlock as c, normalizeClass as w, normalizeStyle as v, createVNode as y, createCommentVNode as u, createElementVNode as X, unref as n, withCtx as z, createBlock as g, Fragment as h, renderList as R, mergeProps as x, renderSlot as T } from "vue";
1
+ import { defineComponent as W, useSlots as x, useTemplateRef as E, ref as M, computed as u, createElementBlock as c, openBlock as s, normalizeClass as w, normalizeStyle as g, createVNode as m, createCommentVNode as d, createElementVNode as X, unref as a, withCtx as z, createBlock as y, Fragment as v, renderList as R, mergeProps as h, renderSlot as T } from "vue";
2
2
  import { Position as L, CurveType as C } from "@unovis/ts";
3
3
  import { createMarkers as Y, getFirstPropertyValue as U } from "../../utils.js";
4
4
  import H from "../Tooltip.js";
@@ -7,7 +7,7 @@ import { LegendPosition as _ } from "../../types.js";
7
7
  const ee = {
8
8
  ref: "slotWrapper",
9
9
  style: { display: "none" }
10
- }, te = 0.5, $ = "#3b82f6", se = /* @__PURE__ */ N({
10
+ }, ie = 0.5, $ = "#3b82f6", se = /* @__PURE__ */ W({
11
11
  __name: "AreaChart",
12
12
  props: {
13
13
  data: {},
@@ -50,96 +50,97 @@ const ee = {
50
50
  xDomain: {}
51
51
  },
52
52
  emits: ["click"],
53
- setup(e, { emit: D }) {
54
- const b = D, i = e, B = W(), p = E("slotWrapper"), d = M(), k = m(() => {
55
- const o = Object.values(i.categories).map(
56
- (l, t) => `var(--vis-color${t})`
53
+ setup(D, { emit: b }) {
54
+ const B = b, t = D, O = x(), k = E("slotWrapper"), p = M(), f = u(() => {
55
+ const e = Object.values(t.categories).map(
56
+ (n, i) => `var(--vis-color${i})`
57
57
  );
58
- return Object.values(i.categories).map(
59
- (l, t) => l.color ?? o[t]
58
+ return Object.values(t.categories).map(
59
+ (n, i) => n.color ?? e[i]
60
60
  );
61
- }), O = m(() => i.markerConfig ? Y(i.markerConfig) : ""), V = m(() => i.legendPosition.startsWith("top")), F = m(() => i.legendPosition.includes("left") ? "flex-start" : i.legendPosition.includes("right") ? "flex-end" : "center"), G = m(() => {
62
- const o = (t, a) => {
61
+ }), V = u(() => t.markerConfig ? Y(t.markerConfig) : ""), F = u(() => t.legendPosition.startsWith("top")), G = u(() => t.legendPosition.includes("left") ? "flex-start" : t.legendPosition.includes("right") ? "flex-end" : "center"), P = u(() => {
62
+ const e = (i, o) => {
63
63
  var r;
64
64
  return `
65
- <linearGradient id="gradient${t}-${a}" gradientTransform="rotate(90)">
66
- ${((r = i.gradientStops) == null ? void 0 : r.map(
67
- (s) => `<stop offset="${s.offset}" stop-color="${a}" stop-opacity="${s.stopOpacity}" />`
65
+ <linearGradient id="gradient${i}-${o}" gradientTransform="rotate(90)">
66
+ ${((r = t.gradientStops) == null ? void 0 : r.map(
67
+ (l) => `<stop offset="${l.offset}" stop-color="${o}" stop-opacity="${l.stopOpacity}" />`
68
68
  ).join("")) ?? ""}
69
- <stop offset="100%" stop-color="${a}" stop-opacity="0" />
69
+ <stop offset="100%" stop-color="${o}" stop-opacity="0" />
70
70
  </linearGradient>
71
71
  `;
72
- }, l = (t, a) => {
72
+ }, n = (i, o) => {
73
73
  var r;
74
74
  return `
75
- <linearGradient id="gradient${t}-${a}" gradientTransform="rotate(90)">
75
+ <linearGradient id="gradient${i}-${o}" gradientTransform="rotate(90)">
76
76
 
77
- ${((r = i.gradientStops) == null ? void 0 : r.map(
78
- (s) => `
79
- <stop offset="${s.offset}" style="stop-color:var(${a});stop-opacity:${s.stopOpacity}" />
77
+ ${((r = t.gradientStops) == null ? void 0 : r.map(
78
+ (l) => `
79
+ <stop offset="${l.offset}" style="stop-color:var(${o});stop-opacity:${l.stopOpacity}" />
80
80
  `
81
81
  ).join("")) ?? ""}
82
82
  </linearGradient>
83
83
  `;
84
84
  };
85
- return k.value.map(
86
- (t, a) => t != null && t.includes("#") ? o(a, t) : l(a, t ?? $)
85
+ return f.value.map(
86
+ (i, o) => i != null && i.includes("#") ? e(o, i) : n(o, i ?? $)
87
87
  ).join("");
88
88
  });
89
- function P(o) {
90
- var l;
89
+ function S(e) {
90
+ var n;
91
91
  return {
92
- y: (t) => Number(t[o]),
93
- color: ((l = i.categories[o]) == null ? void 0 : l.color) ?? $
92
+ y: (i) => Number(i[e]),
93
+ color: ((n = t.categories[e]) == null ? void 0 : n.color) ?? $
94
94
  };
95
95
  }
96
- function S(o) {
97
- return typeof window > "u" ? "" : p.value ? p.value.innerHTML : "";
96
+ function j(e) {
97
+ return typeof window > "u" ? "" : k.value ? k.value.innerHTML : "";
98
98
  }
99
- function j(o) {
100
- return d.value = o, S();
99
+ function N(e) {
100
+ return p.value = e, j();
101
101
  }
102
- return (o, l) => (c(), f("div", {
103
- style: v({
102
+ return (e, n) => (s(), c("div", {
103
+ style: g({
104
104
  display: "flex",
105
- flexDirection: V.value ? "column-reverse" : "column",
105
+ flexDirection: F.value ? "column-reverse" : "column",
106
106
  gap: "var(--vis-legend-spacing)"
107
107
  }),
108
- class: w({ markers: !!i.markerConfig }),
109
- onClick: l[0] || (l[0] = (t) => b("click", t, d.value))
108
+ class: w({ markers: !!t.markerConfig }),
109
+ onClick: n[0] || (n[0] = (i) => B("click", i, p.value))
110
110
  }, [
111
- y(n(q), {
111
+ m(a(q), {
112
112
  data: e.data,
113
113
  height: e.height,
114
114
  padding: e.padding,
115
- "svg-defs": G.value + O.value,
115
+ "svg-defs": P.value + V.value,
116
116
  "y-domain": e.yDomain,
117
117
  "x-domain": e.xDomain
118
118
  }, {
119
119
  default: z(() => [
120
- e.hideTooltip ? u("", !0) : (c(), g(n(J), {
120
+ e.hideTooltip ? d("", !0) : (s(), y(a(J), {
121
121
  key: 0,
122
- "horizontal-placement": n(L).Right,
123
- "vertical-placement": n(L).Top
122
+ "horizontal-placement": a(L).Right,
123
+ "vertical-placement": a(L).Top
124
124
  }, null, 8, ["horizontal-placement", "vertical-placement"])),
125
- (c(!0), f(h, null, R(Object.keys(i.categories), (t, a) => (c(), f(h, { key: t }, [
126
- y(n(K), x({
127
- x: (r, s) => s
128
- }, { ref_for: !0 }, P(t), {
129
- color: `url(#gradient${a}-${k.value[a]})`,
130
- opacity: e.hideArea ? 0 : te,
131
- "curve-type": e.curveType ?? n(C).MonotoneX
125
+ (s(!0), c(v, null, R(Object.keys(t.categories), (i, o) => (s(), c(v, { key: i }, [
126
+ m(a(K), h({
127
+ x: (r, l) => l,
128
+ ref_for: !0
129
+ }, S(i), {
130
+ color: `url(#gradient${o}-${f.value[o]})`,
131
+ opacity: e.hideArea ? 0 : ie,
132
+ "curve-type": e.curveType ?? a(C).MonotoneX
132
133
  }), null, 16, ["x", "color", "opacity", "curve-type"]),
133
- y(n(Q), {
134
- x: (r, s) => s,
135
- y: (r) => r[t],
136
- color: k.value[a],
137
- "curve-type": e.curveType ?? n(C).MonotoneX,
134
+ m(a(Q), {
135
+ x: (r, l) => l,
136
+ y: (r) => r[i],
137
+ color: f.value[o],
138
+ "curve-type": e.curveType ?? a(C).MonotoneX,
138
139
  "line-width": e.lineWidth,
139
- lineDashArray: e.lineDashArray ? e.lineDashArray[a] : void 0
140
+ lineDashArray: e.lineDashArray ? e.lineDashArray[o] : void 0
140
141
  }, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"])
141
142
  ], 64))), 128)),
142
- e.hideXAxis ? u("", !0) : (c(), g(n(A), {
143
+ e.hideXAxis ? d("", !0) : (s(), y(a(A), {
143
144
  key: 1,
144
145
  type: "x",
145
146
  label: e.xLabel,
@@ -152,7 +153,7 @@ const ee = {
152
153
  "tick-line": e.xTickLine,
153
154
  "min-max-ticks-only": e.minMaxTicksOnly
154
155
  }, null, 8, ["label", "num-ticks", "tick-format", "tick-values", "grid-line", "domain-line", "tick-line", "min-max-ticks-only"])),
155
- e.hideYAxis ? u("", !0) : (c(), g(n(A), {
156
+ e.hideYAxis ? d("", !0) : (s(), y(a(A), {
156
157
  key: 2,
157
158
  type: "y",
158
159
  label: e.yLabel,
@@ -162,40 +163,40 @@ const ee = {
162
163
  "domain-line": e.yDomainLine,
163
164
  "tick-line": e.yTickLine
164
165
  }, null, 8, ["label", "num-ticks", "tick-format", "grid-line", "domain-line", "tick-line"])),
165
- e.hideTooltip ? u("", !0) : (c(), g(n(Z), x({ key: 3 }, e.crosshairConfig, { template: j }), null, 16))
166
+ e.hideTooltip ? d("", !0) : (s(), y(a(Z), h({ key: 3 }, e.crosshairConfig, { template: N }), null, 16))
166
167
  ]),
167
168
  _: 1
168
169
  }, 8, ["data", "height", "padding", "svg-defs", "y-domain", "x-domain"]),
169
- i.hideLegend ? u("", !0) : (c(), f("div", {
170
+ t.hideLegend ? d("", !0) : (s(), c("div", {
170
171
  key: 0,
171
- style: v({
172
+ style: g({
172
173
  display: "flex",
173
- justifyContent: F.value
174
+ justifyContent: G.value
174
175
  })
175
176
  }, [
176
- y(n(I), {
177
- style: v([
178
- i.legendStyle,
177
+ m(a(I), {
178
+ style: g([
179
+ t.legendStyle,
179
180
  "display: flex; gap: var(--vis-legend-spacing);"
180
181
  ]),
181
- items: Object.values(i.categories).map((t) => ({
182
- ...t,
183
- color: Array.isArray(t.color) ? t.color[0] : t.color
182
+ items: Object.values(t.categories).map((i) => ({
183
+ ...i,
184
+ color: Array.isArray(i.color) ? i.color[0] : i.color
184
185
  }))
185
186
  }, null, 8, ["style", "items"])
186
187
  ], 4)),
187
188
  X("div", ee, [
188
- n(B).tooltip ? T(o.$slots, "tooltip", {
189
+ a(O).tooltip ? T(e.$slots, "tooltip", {
189
190
  key: 0,
190
- values: d.value
191
- }) : d.value ? T(o.$slots, "fallback", { key: 1 }, () => [
192
- y(H, {
193
- data: d.value,
191
+ values: p.value
192
+ }) : p.value ? T(e.$slots, "fallback", { key: 1 }, () => [
193
+ m(H, {
194
+ data: p.value,
194
195
  categories: e.categories,
195
- toolTipTitle: n(U)(d.value) ?? "",
196
- yFormatter: i.yFormatter
196
+ toolTipTitle: a(U)(p.value) ?? "",
197
+ yFormatter: t.yFormatter
197
198
  }, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
198
- ]) : u("", !0)
199
+ ]) : d("", !0)
199
200
  ], 512)
200
201
  ], 6));
201
202
  }
@@ -1,14 +1,14 @@
1
- import { defineComponent as W, useSlots as X, useTemplateRef as Y, ref as j, computed as k, createElementBlock as v, openBlock as l, normalizeStyle as L, createVNode as b, createCommentVNode as f, createElementVNode as H, unref as a, withCtx as $, createBlock as c, Fragment as q, renderList as I, renderSlot as C } from "vue";
2
- import { Orientation as g, StackedBar as U, GroupedBar as J } from "@unovis/ts";
1
+ import { defineComponent as W, useSlots as X, useTemplateRef as Y, ref as j, computed as f, createElementBlock as v, openBlock as n, normalizeStyle as L, createVNode as k, createCommentVNode as y, createElementVNode as H, unref as i, withCtx as $, createBlock as u, Fragment as q, renderList as I, renderSlot as P } from "vue";
2
+ import { Orientation as p, StackedBar as U, GroupedBar as J } from "@unovis/ts";
3
3
  import { getFirstPropertyValue as K } from "../../utils.js";
4
4
  import { useStackedGrouped as Q } from "./stackedGroupedUtils.js";
5
- import { VisXYContainer as Z, VisXYLabels as _, VisTooltip as ee, VisStackedBar as F, VisGroupedBar as te, VisAxis as V, VisBulletLegend as ae } from "@unovis/vue";
6
- import ie from "../Tooltip.js";
7
- import { LegendPosition as ne } from "../../types.js";
8
- const oe = {
5
+ import { VisXYContainer as Z, VisXYLabels as _, VisTooltip as ee, VisStackedBar as C, VisGroupedBar as ae, VisAxis as F, VisBulletLegend as ie } from "@unovis/vue";
6
+ import oe from "../Tooltip.js";
7
+ import { LegendPosition as re } from "../../types.js";
8
+ const te = {
9
9
  ref: "slotWrapper",
10
10
  style: { display: "none" }
11
- }, ye = /* @__PURE__ */ W({
11
+ }, ge = /* @__PURE__ */ W({
12
12
  __name: "BarChart",
13
13
  props: {
14
14
  data: {},
@@ -35,8 +35,8 @@ const oe = {
35
35
  radius: {},
36
36
  hideLegend: { type: Boolean, default: !1 },
37
37
  hideTooltip: { type: Boolean, default: !1 },
38
- orientation: { default: g.Vertical },
39
- legendPosition: { default: ne.BottomCenter },
38
+ orientation: { default: p.Vertical },
39
+ legendPosition: { default: re.BottomCenter },
40
40
  legendStyle: { default: void 0 },
41
41
  xDomainLine: { type: Boolean },
42
42
  yDomainLine: { type: Boolean },
@@ -52,111 +52,111 @@ const oe = {
52
52
  xAxis: {}
53
53
  },
54
54
  emits: ["click"],
55
- setup(e, { emit: G }) {
56
- const S = G, t = e, O = X(), h = Y("slotWrapper"), u = j();
57
- if (t.valueLabel && !t.xAxis)
55
+ setup(V, { emit: G }) {
56
+ const S = G, a = V, O = X(), h = Y("slotWrapper"), s = j();
57
+ if (a.valueLabel && !a.xAxis)
58
58
  throw new Error(
59
59
  "BarChart: 'xAxis' prop is required when 'valueLabel' is enabled. Please provide an 'xAxis' to display value labels."
60
60
  );
61
- if (!t.yAxis || t.yAxis.length === 0)
61
+ if (!a.yAxis || a.yAxis.length === 0)
62
62
  throw new Error("yAxis is required");
63
- const A = k(() => t.yAxis.map((i) => (o) => o[i])), B = (i, o) => {
64
- var n;
65
- return (n = Object.values(t.categories)[o]) == null ? void 0 : n.color;
66
- }, y = k(
63
+ const x = f(() => a.yAxis.map((e) => (r) => r[e])), A = (e, r) => {
64
+ var o;
65
+ return (o = Object.values(a.categories)[r]) == null ? void 0 : o.color;
66
+ }, c = f(
67
67
  () => Q({
68
- data: t.data,
69
- categories: t.categories,
70
- stackAndGrouped: t.stackAndGrouped,
71
- xAxis: t.xAxis,
72
- spacing: t.stackedGroupedSpacing
68
+ data: a.data,
69
+ categories: a.categories,
70
+ stackAndGrouped: a.stackAndGrouped,
71
+ xAxis: a.xAxis,
72
+ spacing: a.stackedGroupedSpacing
73
73
  }).value
74
- ), w = k(() => t.legendPosition.startsWith("top")), D = k(() => t.legendPosition.includes("left") ? "flex-start" : t.legendPosition.includes("right") ? "flex-end" : "center");
75
- function T(i) {
76
- return u.value = i, E();
74
+ ), w = f(() => a.legendPosition.startsWith("top")), D = f(() => a.legendPosition.includes("left") ? "flex-start" : a.legendPosition.includes("right") ? "flex-end" : "center");
75
+ function B(e) {
76
+ return s.value = e, E();
77
77
  }
78
- function E(i) {
78
+ function E(e) {
79
79
  return typeof window > "u" ? "" : h.value ? h.value.innerHTML : "";
80
80
  }
81
- const P = t.yAxis.map((i) => (o) => o[i]), N = P.length, z = t.data.flatMap(
82
- (i, o) => P.map((n, s) => ({
83
- x: o,
84
- y: Number(n(i) ?? 0),
85
- itemIndex: s
81
+ const T = a.yAxis.map((e) => (r) => r[e]), N = T.length, z = a.data.flatMap(
82
+ (e, r) => T.map((o, d) => ({
83
+ x: r,
84
+ y: Number(o(e) ?? 0),
85
+ itemIndex: d
86
86
  }))
87
- ), M = (i) => {
88
- if (t.stacked || t.stackAndGrouped) return i.x;
89
- const o = N;
90
- if (o <= 1) return i.x;
91
- const s = 1 - (t.groupPadding ?? 0), m = s / o, x = -s / 2, r = m * i.itemIndex + m / 2, p = 1 - (t.barPadding ?? 0), R = (x + r) * p;
92
- return i.x + R;
87
+ ), M = (e) => {
88
+ if (a.stacked || a.stackAndGrouped) return e.x;
89
+ const r = N;
90
+ if (r <= 1) return e.x;
91
+ const d = 1 - (a.groupPadding ?? 0), g = d / r, m = -d / 2, t = g * e.itemIndex + g / 2, b = 1 - (a.barPadding ?? 0), R = (m + t) * b;
92
+ return e.x + R;
93
93
  };
94
- return (i, o) => (l(), v("div", {
94
+ return (e, r) => (n(), v("div", {
95
95
  style: L({
96
96
  display: "flex",
97
97
  flexDirection: w.value ? "column-reverse" : "column",
98
98
  gap: "var(--vis-legend-spacing)"
99
99
  }),
100
- onClick: o[0] || (o[0] = (n) => S("click", n, u.value))
100
+ onClick: r[0] || (r[0] = (o) => S("click", o, s.value))
101
101
  }, [
102
- b(a(Z), {
102
+ k(i(Z), {
103
103
  padding: e.padding,
104
104
  height: e.height
105
105
  }, {
106
106
  default: $(() => {
107
- var n, s, m, x;
107
+ var o, d, g, m;
108
108
  return [
109
- e.valueLabel ? (l(), c(a(_), {
109
+ e.valueLabel ? (n(), u(i(_), {
110
110
  key: 0,
111
- data: a(z),
111
+ data: i(z),
112
112
  x: M,
113
- y: (r) => {
114
- var d;
115
- return r.y + (((d = t.valueLabel) == null ? void 0 : d.labelSpacing) ?? 0);
113
+ y: (t) => {
114
+ var l;
115
+ return t.y + (((l = a.valueLabel) == null ? void 0 : l.labelSpacing) ?? 0);
116
116
  },
117
- label: (n = t.valueLabel) == null ? void 0 : n.label,
118
- backgroundColor: ((s = t.valueLabel) == null ? void 0 : s.backgroundColor) ?? "transparent",
119
- color: ((m = t.valueLabel) == null ? void 0 : m.color) ?? "red",
120
- labelFontSize: (x = t.valueLabel) == null ? void 0 : x.labelFontSize
121
- }, null, 8, ["data", "y", "label", "backgroundColor", "color", "labelFontSize"])) : f("", !0),
122
- b(a(ee), {
117
+ label: (o = a.valueLabel) == null ? void 0 : o.label,
118
+ backgroundColor: ((d = a.valueLabel) == null ? void 0 : d.backgroundColor) ?? "transparent",
119
+ color: ((g = a.valueLabel) == null ? void 0 : g.color) ?? "red",
120
+ labelFontSize: (m = a.valueLabel) == null ? void 0 : m.labelFontSize
121
+ }, null, 8, ["data", "y", "label", "backgroundColor", "color", "labelFontSize"])) : y("", !0),
122
+ k(i(ee), {
123
123
  triggers: {
124
- [a(J).selectors.bar]: T,
125
- [a(U).selectors.bar]: T
124
+ [i(J).selectors.bar]: B,
125
+ [i(U).selectors.bar]: B
126
126
  }
127
127
  }, null, 8, ["triggers"]),
128
- e.stackAndGrouped ? (l(!0), v(q, { key: 1 }, I(y.value.states, (r) => (l(), c(a(F), {
129
- key: r,
130
- data: y.value.chartData,
131
- x: (d, p) => p + y.value.positions[r],
132
- y: y.value.bars[r],
133
- color: y.value.colorFunctions[r],
128
+ e.stackAndGrouped ? (n(!0), v(q, { key: 1 }, I(c.value.states, (t) => (n(), u(i(C), {
129
+ key: t,
130
+ data: c.value.chartData,
131
+ x: (l, b) => b + c.value.positions[t],
132
+ y: c.value.bars[t],
133
+ color: c.value.colorFunctions[t],
134
134
  "rounded-corners": e.radius ?? 0,
135
135
  "group-padding": e.groupPadding ?? 0,
136
136
  "bar-padding": e.barPadding,
137
- orientation: e.orientation ?? a(g).Vertical
138
- }, null, 8, ["data", "x", "y", "color", "rounded-corners", "group-padding", "bar-padding", "orientation"]))), 128)) : e.stacked ? (l(), c(a(F), {
137
+ orientation: e.orientation ?? i(p).Vertical
138
+ }, null, 8, ["data", "x", "y", "color", "rounded-corners", "group-padding", "bar-padding", "orientation"]))), 128)) : e.stacked ? (n(), u(i(C), {
139
139
  key: 3,
140
140
  data: e.data,
141
- x: (r, d) => d,
142
- y: A.value,
143
- color: B,
141
+ x: (t, l) => l,
142
+ y: x.value,
143
+ color: A,
144
144
  "rounded-corners": e.radius ?? 0,
145
145
  "group-padding": e.groupPadding ?? 0,
146
146
  "bar-padding": e.barPadding ?? 0.2,
147
- orientation: e.orientation ?? a(g).Vertical
148
- }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (l(), c(a(te), {
147
+ orientation: e.orientation ?? i(p).Vertical
148
+ }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (n(), u(i(ae), {
149
149
  key: 2,
150
150
  data: e.data,
151
- x: (r, d) => d,
152
- y: A.value,
153
- color: B,
151
+ x: (t, l) => l,
152
+ y: x.value,
153
+ color: A,
154
154
  "rounded-corners": e.radius ?? 0,
155
155
  "group-padding": e.groupPadding ?? 0,
156
156
  "bar-padding": e.barPadding ?? 0.2,
157
- orientation: e.orientation ?? a(g).Vertical
157
+ orientation: e.orientation ?? i(p).Vertical
158
158
  }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])),
159
- e.hideXAxis ? f("", !0) : (l(), c(a(V), {
159
+ e.hideXAxis ? y("", !0) : (n(), u(i(F), {
160
160
  key: 4,
161
161
  type: "x",
162
162
  "tick-format": e.xFormatter,
@@ -168,11 +168,11 @@ const oe = {
168
168
  "tick-values": e.xExplicitTicks,
169
169
  minMaxTicksOnly: e.minMaxTicksOnly
170
170
  }, null, 8, ["tick-format", "label", "grid-line", "domain-line", "tick-line", "num-ticks", "tick-values", "minMaxTicksOnly"])),
171
- e.hideYAxis ? f("", !0) : (l(), c(a(V), {
171
+ e.hideYAxis ? y("", !0) : (n(), u(i(F), {
172
172
  key: 5,
173
173
  type: "y",
174
174
  label: e.yLabel,
175
- "grid-line": e.orientation !== a(g).Horizontal && e.yGridLine,
175
+ "grid-line": e.orientation !== i(p).Horizontal && e.yGridLine,
176
176
  "domain-line": !!e.yDomainLine,
177
177
  "tick-format": e.yFormatter,
178
178
  "num-ticks": e.yNumTicks,
@@ -182,40 +182,40 @@ const oe = {
182
182
  }),
183
183
  _: 1
184
184
  }, 8, ["padding", "height"]),
185
- t.hideLegend ? f("", !0) : (l(), v("div", {
185
+ a.hideLegend ? y("", !0) : (n(), v("div", {
186
186
  key: 0,
187
187
  style: L({
188
188
  display: "flex",
189
189
  justifyContent: D.value
190
190
  })
191
191
  }, [
192
- b(a(ae), {
192
+ k(i(ie), {
193
193
  style: L([
194
- t.legendStyle,
194
+ a.legendStyle,
195
195
  "display: flex; gap: var(--vis-legend-spacing);"
196
196
  ]),
197
- items: Object.values(t.categories).map((n) => ({
198
- ...n,
199
- color: Array.isArray(n.color) ? n.color[0] : n.color
197
+ items: Object.values(a.categories).map((o) => ({
198
+ ...o,
199
+ color: Array.isArray(o.color) ? o.color[0] : o.color
200
200
  }))
201
201
  }, null, 8, ["style", "items"])
202
202
  ], 4)),
203
- H("div", oe, [
204
- a(O).tooltip ? C(i.$slots, "tooltip", {
203
+ H("div", te, [
204
+ i(O).tooltip ? P(e.$slots, "tooltip", {
205
205
  key: 0,
206
- values: u.value
207
- }) : u.value ? C(i.$slots, "fallback", { key: 1 }, () => [
208
- b(ie, {
209
- data: u.value,
210
- categories: t.categories,
211
- toolTipTitle: a(K)(u.value) ?? "",
212
- yFormatter: t.orientation === a(g).Horizontal ? t.xFormatter : t.yFormatter
206
+ values: s.value
207
+ }) : s.value ? P(e.$slots, "fallback", { key: 1 }, () => [
208
+ k(oe, {
209
+ data: s.value,
210
+ categories: a.categories,
211
+ toolTipTitle: i(K)(s.value) ?? "",
212
+ yFormatter: a.orientation === i(p).Horizontal ? a.xFormatter : a.yFormatter
213
213
  }, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
214
- ]) : f("", !0)
214
+ ]) : y("", !0)
215
215
  ], 512)
216
216
  ], 4));
217
217
  }
218
218
  });
219
219
  export {
220
- ye as default
220
+ ge as default
221
221
  };
@@ -1,4 +1,4 @@
1
- import { defineComponent as w, useSlots as D, useTemplateRef as L, ref as T, computed as g, createElementBlock as p, openBlock as f, normalizeStyle as o, createVNode as r, createCommentVNode as m, renderSlot as d, createElementVNode as a, unref as i, withCtx as B, toDisplayString as P } from "vue";
1
+ import { defineComponent as x, useSlots as D, useTemplateRef as L, ref as T, computed as p, createElementBlock as g, openBlock as c, normalizeStyle as o, createVNode as i, createCommentVNode as f, renderSlot as s, createElementVNode as r, unref as n, withCtx as B, toDisplayString as P } from "vue";
2
2
  import { Donut as W } from "@unovis/ts";
3
3
  import { DonutType as R } from "./types.js";
4
4
  import { VisSingleContainer as A, VisTooltip as H, VisDonut as N, VisBulletLegend as $ } from "@unovis/vue";
@@ -6,7 +6,7 @@ import { LegendPosition as z } from "../../types.js";
6
6
  const E = {
7
7
  ref: "slotWrapper",
8
8
  style: { display: "none" }
9
- }, j = { style: { display: "flex", "align-items": "center", padding: "10px 15px" } }, I = /* @__PURE__ */ w({
9
+ }, j = { style: { display: "flex", "align-items": "center", padding: "10px 15px" } }, G = /* @__PURE__ */ x({
10
10
  __name: "DonutChart",
11
11
  props: {
12
12
  type: {},
@@ -21,85 +21,85 @@ const E = {
21
21
  padAngle: {}
22
22
  },
23
23
  emits: ["click"],
24
- setup(l, { emit: h }) {
25
- const v = h, e = l, y = D(), u = L("slotWrapper"), n = T(), x = (t) => t, C = e.type === R.Half;
26
- function k(t) {
27
- return n.value = t, V();
24
+ setup(m, { emit: h }) {
25
+ const v = h, t = m, y = D(), d = L("slotWrapper"), l = T(), C = (e) => e, k = t.type === R.Half;
26
+ function V(e) {
27
+ return l.value = e, b();
28
28
  }
29
- function V(t) {
30
- return typeof window > "u" ? "" : u.value ? u.value.innerHTML : "";
29
+ function b(e) {
30
+ return typeof window > "u" ? "" : d.value ? d.value.innerHTML : "";
31
31
  }
32
- const b = g(() => e.legendPosition.includes("top")), S = g(() => e.legendPosition.includes("left") ? "flex-start" : e.legendPosition.includes("right") ? "flex-end" : "center");
33
- return (t, c) => (f(), p("div", {
32
+ const S = p(() => t.legendPosition.includes("top")), w = p(() => t.legendPosition.includes("left") ? "flex-start" : t.legendPosition.includes("right") ? "flex-end" : "center");
33
+ return (e, u) => (c(), g("div", {
34
34
  style: o({
35
35
  display: "flex",
36
- flexDirection: b.value ? "column-reverse" : "column",
36
+ flexDirection: S.value ? "column-reverse" : "column",
37
37
  gap: "var(--vis-legend-spacing)"
38
38
  }),
39
- onClick: c[0] || (c[0] = (s) => v("click", s, n.value))
39
+ onClick: u[0] || (u[0] = (a) => v("click", a, l.value))
40
40
  }, [
41
- r(i(A), {
42
- data: l.data,
43
- height: l.height,
41
+ i(n(A), {
42
+ data: e.data,
43
+ height: e.height,
44
44
  margin: {}
45
45
  }, {
46
46
  default: B(() => [
47
- r(i(H), {
47
+ i(n(H), {
48
48
  "horizontal-shift": 20,
49
49
  "vertical-shift": 20,
50
50
  triggers: {
51
- [i(W).selectors.segment]: k
51
+ [n(W).selectors.segment]: V
52
52
  }
53
53
  }, null, 8, ["triggers"]),
54
- r(i(N), {
55
- value: x,
56
- "corner-radius": l.radius,
57
- "arc-width": l.arcWidth ?? 20,
58
- color: e.labels.map((s) => s.color),
59
- "angle-range": C ? [-1.5707963267948966, 1.5707963267948966] : [],
60
- "pad-angle": e.padAngle || 0
54
+ i(n(N), {
55
+ value: C,
56
+ "corner-radius": e.radius,
57
+ "arc-width": e.arcWidth ?? 20,
58
+ color: t.labels.map((a) => a.color),
59
+ "angle-range": k ? [-1.5707963267948966, 1.5707963267948966] : [],
60
+ "pad-angle": t.padAngle || 0
61
61
  }, null, 8, ["corner-radius", "arc-width", "color", "angle-range", "pad-angle"])
62
62
  ]),
63
63
  _: 1
64
64
  }, 8, ["data", "height"]),
65
- e.hideLegend ? m("", !0) : (f(), p("div", {
65
+ t.hideLegend ? f("", !0) : (c(), g("div", {
66
66
  key: 0,
67
67
  style: o({
68
68
  display: "flex",
69
- justifyContent: S.value
69
+ justifyContent: w.value
70
70
  })
71
71
  }, [
72
- r(i($), {
72
+ i(n($), {
73
73
  style: o([
74
- e.legendStyle,
74
+ t.legendStyle,
75
75
  "display: flex; gap: var(--vis-legend-spacing);"
76
76
  ]),
77
- items: l.labels
77
+ items: e.labels
78
78
  }, null, 8, ["style", "items"])
79
79
  ], 4)),
80
- d(t.$slots, "default"),
81
- a("div", E, [
82
- i(y).tooltip ? d(t.$slots, "tooltip", {
80
+ s(e.$slots, "default"),
81
+ r("div", E, [
82
+ n(y).tooltip ? s(e.$slots, "tooltip", {
83
83
  key: 0,
84
- values: n.value
85
- }) : n.value ? d(t.$slots, "fallback", { key: 1 }, () => [
86
- a("div", j, [
87
- a("div", {
84
+ values: l.value
85
+ }) : l.value ? s(e.$slots, "fallback", { key: 1 }, () => [
86
+ r("div", j, [
87
+ r("div", {
88
88
  style: o({
89
89
  width: "0.5rem",
90
90
  height: "0.5rem",
91
91
  borderRadius: "9999px",
92
92
  marginRight: "0.5rem",
93
- backgroundColor: e.labels[n.value.index].color
93
+ backgroundColor: t.labels[l.value.index].color
94
94
  })
95
95
  }, null, 4),
96
- a("div", null, P(n.value.data), 1)
96
+ r("div", null, P(l.value.data), 1)
97
97
  ])
98
- ]) : m("", !0)
98
+ ]) : f("", !0)
99
99
  ], 512)
100
100
  ], 4));
101
101
  }
102
102
  });
103
103
  export {
104
- I as default
104
+ G as default
105
105
  };
@@ -0,0 +1,120 @@
1
+ import { defineComponent as L, useSlots as V, useTemplateRef as C, ref as _, computed as c, createElementBlock as u, openBlock as p, normalizeStyle as d, createVNode as i, createCommentVNode as g, createElementVNode as H, unref as o, withCtx as B, renderSlot as f } from "vue";
2
+ import { Timeline as P } from "@unovis/ts";
3
+ import { dateFormatter as S, getFirstPropertyValue as j } from "../../utils.js";
4
+ import A from "../Tooltip.js";
5
+ import { VisXYContainer as F, VisTimeline as $, VisTooltip as N, VisAxis as O, VisBulletLegend as E } from "@unovis/vue";
6
+ import { LegendPosition as R } from "../../types.js";
7
+ const G = /* @__PURE__ */ L({
8
+ __name: "Timeline",
9
+ props: {
10
+ data: {},
11
+ labelWidth: { default: 220 },
12
+ height: {},
13
+ title: { default: "" },
14
+ categories: {},
15
+ x: {},
16
+ length: {},
17
+ type: {},
18
+ getTooltipText: {},
19
+ showLabels: { type: Boolean, default: !0 },
20
+ hideTooltip: { type: Boolean, default: !1 },
21
+ crosshairConfig: {},
22
+ lineWidth: { default: 12 },
23
+ rowHeight: { default: 24 },
24
+ legendPosition: { default: R.TopRight },
25
+ legendStyle: {},
26
+ hideLegend: { type: Boolean }
27
+ },
28
+ emits: ["click", "scroll", "labelHover"],
29
+ setup(h, { emit: m }) {
30
+ const e = h, n = m, y = V(), s = C("slotWrapper"), r = _(), v = c(() => e.legendPosition.startsWith("top")), T = c(() => e.legendPosition.includes("left") ? "flex-start" : e.legendPosition.includes("right") ? "flex-end" : "center"), b = { [P.selectors.label]: k };
31
+ function k(t) {
32
+ return r.value = t, n("labelHover", t), typeof window > "u" ? "" : s.value ? s.value.innerHTML : "";
33
+ }
34
+ function x(t, a, l) {
35
+ n("click", l, { index: a, item: t });
36
+ }
37
+ function W(t) {
38
+ n("scroll", t.deltaY);
39
+ }
40
+ const w = c(() => {
41
+ const t = Object.values(e.categories).map(
42
+ (a, l) => `var(--vis-color${l})`
43
+ );
44
+ return Object.values(e.categories).map(
45
+ (a, l) => a.color ?? t[l]
46
+ );
47
+ });
48
+ return (t, a) => (p(), u("div", {
49
+ style: d({
50
+ display: "flex",
51
+ flexDirection: v.value ? "column-reverse" : "column",
52
+ gap: "var(--vis-legend-spacing)"
53
+ })
54
+ }, [
55
+ i(o(F), {
56
+ data: e.data,
57
+ height: e.height,
58
+ onWheel: W
59
+ }, {
60
+ default: B(() => [
61
+ i(o($), {
62
+ x: e.x,
63
+ length: e.length,
64
+ lineWidth: e.lineWidth,
65
+ rowHeight: e.rowHeight,
66
+ type: e.type,
67
+ color: w.value,
68
+ labelWidth: e.labelWidth,
69
+ showLabels: e.showLabels,
70
+ onClick: x
71
+ }, null, 8, ["x", "length", "lineWidth", "rowHeight", "type", "color", "labelWidth", "showLabels"]),
72
+ i(o(N), { triggers: b }),
73
+ i(o(O), {
74
+ type: "x",
75
+ tickFormat: o(S),
76
+ numTicks: 10
77
+ }, null, 8, ["tickFormat"])
78
+ ]),
79
+ _: 1
80
+ }, 8, ["data", "height"]),
81
+ e.hideLegend ? g("", !0) : (p(), u("div", {
82
+ key: 0,
83
+ style: d({
84
+ display: "flex",
85
+ justifyContent: T.value
86
+ })
87
+ }, [
88
+ i(o(E), {
89
+ style: d([
90
+ e.legendStyle,
91
+ "display: flex; gap: var(--vis-legend-spacing);"
92
+ ]),
93
+ items: Object.values(e.categories).map((l) => ({
94
+ ...l,
95
+ color: Array.isArray(l.color) ? l.color[0] : l.color
96
+ }))
97
+ }, null, 8, ["style", "items"])
98
+ ], 4)),
99
+ H("div", {
100
+ ref_key: "slotWrapper",
101
+ ref: s,
102
+ style: { display: "none" }
103
+ }, [
104
+ o(y).labelTooltip ? f(t.$slots, "labelTooltip", {
105
+ key: 0,
106
+ values: r.value
107
+ }) : r.value ? f(t.$slots, "fallback", { key: 1 }, () => [
108
+ i(A, {
109
+ data: r.value,
110
+ categories: t.categories,
111
+ toolTipTitle: o(j)(r.value) ?? ""
112
+ }, null, 8, ["data", "categories", "toolTipTitle"])
113
+ ]) : g("", !0)
114
+ ], 512)
115
+ ], 4));
116
+ }
117
+ });
118
+ export {
119
+ G as default
120
+ };
@@ -0,0 +1,33 @@
1
+ import { TimelineProps } from '../../types';
2
+ export interface TimelineCategory {
3
+ name: string;
4
+ color?: string | string[];
5
+ }
6
+ declare const _default: <T extends Record<string, any>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
7
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
8
+ readonly onClick?: ((event: MouseEvent, data: {
9
+ index: number;
10
+ item: T;
11
+ }) => any) | undefined;
12
+ readonly onScroll?: ((distance: number) => any) | undefined;
13
+ readonly onLabelHover?: ((item: T | undefined) => any) | undefined;
14
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onClick" | "onScroll" | "onLabelHover"> & TimelineProps<T> & Partial<{}>> & import('vue').PublicProps;
15
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
16
+ attrs: any;
17
+ slots: {
18
+ labelTooltip?(_: {
19
+ values: T | undefined;
20
+ }): any;
21
+ fallback?(_: {}): any;
22
+ };
23
+ emit: ((evt: "click", event: MouseEvent, data: {
24
+ index: number;
25
+ item: T;
26
+ }) => void) & ((evt: "scroll", distance: number) => void) & ((evt: "labelHover", item: T | undefined) => void);
27
+ }>) => import('vue').VNode & {
28
+ __ctx?: Awaited<typeof __VLS_setup>;
29
+ };
30
+ export default _default;
31
+ type __VLS_PrettifyLocal<T> = {
32
+ [K in keyof T]: T[K];
33
+ } & {};
@@ -0,0 +1,4 @@
1
+ import f from "./Timeline.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,24 @@
1
+ import { BulletLegendItemInterface, CrosshairConfig, LegendPosition } from '../../types';
2
+ export interface TimelineLegendItem {
3
+ name: string;
4
+ color: string;
5
+ }
6
+ export interface TimelineProps<T extends Record<string, any>> {
7
+ data: T[];
8
+ labelWidth?: number;
9
+ height?: number;
10
+ title?: string;
11
+ categories: Record<string, BulletLegendItemInterface>;
12
+ x: (d: T) => number;
13
+ length: (d: T) => number;
14
+ type: (d: T) => string;
15
+ getTooltipText?: (label: string, index: number, data: T[]) => string;
16
+ showLabels?: boolean;
17
+ hideTooltip?: boolean;
18
+ crosshairConfig?: CrosshairConfig;
19
+ lineWidth?: number;
20
+ rowHeight?: number;
21
+ legendPosition?: LegendPosition;
22
+ legendStyle?: Record<string, string>;
23
+ hideLegend?: boolean;
24
+ }
@@ -1,11 +1,11 @@
1
- import { defineComponent as v, computed as y, createElementBlock as i, openBlock as l, createElementVNode as o, toDisplayString as n, Fragment as b, renderList as f, normalizeStyle as a } from "vue";
2
- const h = { style: { padding: "10px 15px" } }, B = { style: {
1
+ import { defineComponent as y, computed as b, createElementBlock as r, openBlock as i, createElementVNode as e, toDisplayString as l, Fragment as f, renderList as h, normalizeStyle as n } from "vue";
2
+ const x = { style: { padding: "10px 15px" } }, B = { style: {
3
3
  color: "var(--tooltip-value-color)",
4
4
  textTransform: "capitalize",
5
5
  borderBottom: "borderBottom: 1px solid var(--tooltip-border-color)",
6
6
  marginBottom: "0.25rem",
7
7
  paddingBottom: "0.25rem"
8
- } }, F = /* @__PURE__ */ v({
8
+ } }, T = /* @__PURE__ */ y({
9
9
  __name: "Tooltip",
10
10
  props: {
11
11
  data: {},
@@ -13,30 +13,30 @@ const h = { style: { padding: "10px 15px" } }, B = { style: {
13
13
  toolTipTitle: {},
14
14
  yFormatter: { type: Function }
15
15
  },
16
- setup(t) {
17
- const c = t, g = ["_index", "_stacked", "_ending"], p = y(() => Object.entries(c.data ?? []).filter(
18
- ([r, u]) => !g.includes(r) && Object.keys(c.categories).includes(r)
16
+ setup(d) {
17
+ const a = d, m = ["_index", "_stacked", "_ending"], g = b(() => Object.entries(a.data ?? []).filter(
18
+ ([o, u]) => !m.includes(o) && Object.keys(a.categories).includes(o)
19
19
  ));
20
- return (r, u) => (l(), i("div", h, [
21
- o("div", B, n(t.toolTipTitle), 1),
22
- (l(!0), i(b, null, f(p.value, ([e, s], x) => {
23
- var d, m;
24
- return l(), i("div", {
25
- key: e,
20
+ return (o, u) => (i(), r("div", x, [
21
+ e("div", B, l(o.toolTipTitle), 1),
22
+ (i(!0), r(f, null, h(g.value, ([t, s], v) => {
23
+ var p, c;
24
+ return i(), r("div", {
25
+ key: t,
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: typeof ((d = t.categories[e]) == null ? void 0 : d.color) == "string" && ((m = t.categories[e]) != null && m.color) ? t.categories[e].color : `var(--vis-color${x})`
28
+ e("span", {
29
+ style: n([{ width: "8px", height: "8px", "border-radius": "4px", "margin-right": "8px" }, {
30
+ backgroundColor: typeof ((p = o.categories[t]) == null ? void 0 : p.color) == "string" && ((c = o.categories[t]) != null && c.color) ? o.categories[t].color : `var(--vis-color${v})`
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
- }, n(t.categories[e].name) + ":", 1),
37
- o("span", {
38
- style: a([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
39
- }, n(t.yFormatter ? t.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(o.categories[t].name) + ":", 1),
37
+ e("span", {
38
+ style: n([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
39
+ }, l(o.yFormatter ? o.yFormatter(s) : s), 1)
40
40
  ])
41
41
  ]);
42
42
  }), 128))
@@ -44,5 +44,5 @@ const h = { style: { padding: "10px 15px" } }, B = { style: {
44
44
  }
45
45
  });
46
46
  export {
47
- F as default
47
+ T as default
48
48
  };
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import { default as LineChart } from './components/LineChart/LineChart.vue';
3
3
  import { default as BarChart } from './components/BarChart/BarChart.vue';
4
4
  import { default as DonutChart } from './components/DonutChart/DonutChart.vue';
5
5
  import { default as BubbleChart } from './components/BubbleChart/BubbleChart.vue';
6
+ import { default as Timeline } from './components/Timeline/Timeline.vue';
6
7
  import { LegendPosition, CurveType, Orientation, BulletLegendItemInterface, MarkerConfig, CrosshairConfig } from './types';
7
- export { AreaChart, LineChart, BarChart, DonutChart, BubbleChart, Orientation, CurveType, LegendPosition };
8
+ export { AreaChart, LineChart, BarChart, DonutChart, BubbleChart, Timeline, Orientation, CurveType, LegendPosition };
8
9
  export type { BulletLegendItemInterface, MarkerConfig, CrosshairConfig };
package/dist/index.js CHANGED
@@ -1,16 +1,18 @@
1
- import { default as e } from "./components/AreaChart/AreaChart.js";
1
+ import { default as t } from "./components/AreaChart/AreaChart.js";
2
2
  import { default as o } from "./components/LineChart/LineChart.js";
3
3
  import { default as u } from "./components/BarChart/BarChart.js";
4
- import { default as d } from "./components/DonutChart/DonutChart.js";
5
- import { default as m } from "./components/BubbleChart/BubbleChart.js";
6
- import { CurveType as s, LegendPosition as x, Orientation as C } from "./types.js";
4
+ import { default as m } from "./components/DonutChart/DonutChart.js";
5
+ import { default as d } from "./components/BubbleChart/BubbleChart.js";
6
+ import { default as n } from "./components/Timeline/Timeline.js";
7
+ import { CurveType as x, LegendPosition as C, Orientation as h } from "./types.js";
7
8
  export {
8
- e as AreaChart,
9
+ t as AreaChart,
9
10
  u as BarChart,
10
- m as BubbleChart,
11
- s as CurveType,
12
- d as DonutChart,
13
- x as LegendPosition,
11
+ d as BubbleChart,
12
+ x as CurveType,
13
+ m as DonutChart,
14
+ C as LegendPosition,
14
15
  o as LineChart,
15
- C as Orientation
16
+ h as Orientation,
17
+ n as Timeline
16
18
  };
package/dist/types.d.ts CHANGED
@@ -3,6 +3,7 @@ import { BarChartProps } from './components/BarChart/types';
3
3
  import { LineChartProps } from './components/LineChart/types';
4
4
  import { DonutChartProps } from './components/DonutChart/types';
5
5
  import { BubbleChartProps } from './components/BubbleChart/types';
6
+ import { TimelineProps, TimelineLegendItem } from './components/Timeline/types';
6
7
  declare enum LegendPosition {
7
8
  TopLeft = "top-left",
8
9
  TopCenter = "top-center",
@@ -44,7 +45,7 @@ declare enum Orientation {
44
45
  Horizontal = "horizontal",
45
46
  Vertical = "vertical"
46
47
  }
47
- export { LegendPosition, CurveType, Orientation, type AreaChartProps, type BarChartProps, type LineChartProps, type DonutChartProps, type BulletLegendItemInterface, type BubbleChartProps };
48
+ export { LegendPosition, CurveType, Orientation, type AreaChartProps, type BarChartProps, type LineChartProps, type DonutChartProps, type BulletLegendItemInterface, type BubbleChartProps, type TimelineProps, type TimelineLegendItem };
48
49
  export type axisFormatter = ((tick: number, i?: number, ticks?: number[]) => string) | ((tick: Date, i?: number, ticks?: Date[]) => string);
49
50
  export interface MarkerConfig {
50
51
  type?: "circle" | "square" | "triangle" | "diamond";
package/dist/utils.d.ts CHANGED
@@ -6,3 +6,4 @@ export declare function createMarkers(markerConfig: Record<string, MarkerConfig>
6
6
  export declare const flattenData: (data: any[], xAxis: string) => {
7
7
  month: any;
8
8
  }[];
9
+ export declare const dateFormatter: (date: number) => string;
package/dist/utils.js CHANGED
@@ -1,49 +1,50 @@
1
- function o(n) {
2
- if (n && Object.keys(n).length > 0) {
3
- const e = Object.keys(n)[0];
4
- return n[e];
1
+ function m(t) {
2
+ if (t && Object.keys(t).length > 0) {
3
+ const e = Object.keys(t)[0];
4
+ return t[e];
5
5
  }
6
6
  }
7
- const u = (n, e, r, t, $) => {
8
- switch (n) {
7
+ const o = (t, e, r, n, $) => {
8
+ switch (t) {
9
9
  case "circle":
10
- return `<circle cx="${e / 2}" cy="${e / 2}" r="${(e - r) / 2}" stroke-width="${r}" stroke="${$}" fill="${t}" />`;
10
+ return `<circle cx="${e / 2}" cy="${e / 2}" r="${(e - r) / 2}" stroke-width="${r}" stroke="${$}" fill="${n}" />`;
11
11
  case "square":
12
- return `<rect x="${r / 2}" y="${r / 2}" width="${e - r}" height="${e - r}" stroke-width="${r}" stroke="${$}" fill="${t}" />`;
12
+ return `<rect x="${r / 2}" y="${r / 2}" width="${e - r}" height="${e - r}" stroke-width="${r}" stroke="${$}" fill="${n}" />`;
13
13
  case "triangle":
14
- return `<polygon points="${e / 2},${r / 2} ${e - r / 2},${e - r / 2} ${r / 2},${e - r / 2}" stroke-width="${r}" stroke="${$}" fill="${t}" />`;
14
+ return `<polygon points="${e / 2},${r / 2} ${e - r / 2},${e - r / 2} ${r / 2},${e - r / 2}" stroke-width="${r}" stroke="${$}" fill="${n}" />`;
15
15
  case "diamond":
16
- return `<polygon points="${e / 2},${r / 2} ${e - r / 2},${e / 2} ${e / 2},${e - r / 2} ${r / 2},${e / 2}" stroke-width="${r}" stroke="${$}" fill="${t}" />`;
16
+ return `<polygon points="${e / 2},${r / 2} ${e - r / 2},${e / 2} ${e / 2},${e - r / 2} ${r / 2},${e / 2}" stroke-width="${r}" stroke="${$}" fill="${n}" />`;
17
17
  default:
18
18
  return "";
19
19
  }
20
20
  };
21
- function m(n) {
22
- return Object.entries(n).map(([e, r]) => {
23
- const t = r.type || "circle", $ = r.size || 10, c = r.strokeWidth || 2, a = r.color || "#000", l = r.strokeColor || r.color || "#000";
21
+ function p(t) {
22
+ return Object.entries(t).map(([e, r]) => {
23
+ const n = r.type || "circle", $ = r.size || 10, c = r.strokeWidth || 2, a = r.color || "#000", l = r.strokeColor || r.color || "#000";
24
24
  return `<marker id="circle-marker-${e}" viewBox="0 0 ${$} ${$}" refX="${$ / 2}" refY="${$ / 2}" markerWidth="${$ / 2}" markerHeight="${$ / 2}">
25
- ${u(t, $, c, a, l)}
25
+ ${o(n, $, c, a, l)}
26
26
  </marker>`;
27
27
  }).join(`
28
28
  `);
29
29
  }
30
- function p(n) {
31
- return n.charAt(0).toUpperCase() + n.slice(1);
30
+ function u(t) {
31
+ return t.charAt(0).toUpperCase() + t.slice(1);
32
32
  }
33
- const y = (n, e) => {
34
- const r = Object.keys(n[0]).filter(($) => $ !== e), t = Object.keys(n[0][r[0]]);
35
- return n.map(($) => ({
33
+ const f = (t, e) => {
34
+ const r = Object.keys(t[0]).filter(($) => $ !== e), n = Object.keys(t[0][r[0]]);
35
+ return t.map(($) => ({
36
36
  month: $.month,
37
37
  ...r.flatMap(
38
- (c) => t.map((a) => ({
39
- [`${c}${p(a)}`]: $[c][a]
38
+ (c) => n.map((a) => ({
39
+ [`${c}${u(a)}`]: $[c][a]
40
40
  }))
41
41
  ).reduce((c, a) => ({ ...c, ...a }), {})
42
42
  }));
43
- };
43
+ }, y = (t) => Intl.DateTimeFormat().format(t);
44
44
  export {
45
- m as createMarkers,
46
- y as flattenData,
47
- o as getFirstPropertyValue,
48
- u as markerShape
45
+ p as createMarkers,
46
+ y as dateFormatter,
47
+ f as flattenData,
48
+ m as getFirstPropertyValue,
49
+ o as markerShape
49
50
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-chrts",
3
- "version": "0.2.5-test.2",
3
+ "version": "0.2.5-test.3",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"