vue-chrts 0.2.3 → 0.2.4
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.
- package/dist/components/AreaChart/AreaChart.js +48 -44
- package/dist/components/AreaChart/types.d.ts +9 -1
- package/dist/components/BarChart/stackedGroupedUtils.d.ts +1 -1
- package/dist/components/BarChart/stackedGroupedUtils.js +40 -39
- package/dist/components/BarChart/types.d.ts +1 -1
- package/dist/components/LineChart/LineChart.js +38 -34
- package/dist/components/LineChart/types.d.ts +9 -1
- package/dist/components/Tooltip.js +12 -12
- package/dist/types.d.ts +1 -1
- package/package.json +3 -3
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { defineComponent as U, useSlots as j, useTemplateRef as w, ref as R, computed as
|
|
2
|
-
import { Position as
|
|
3
|
-
import { createMarkers as
|
|
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
4
|
import H from "../Tooltip.js";
|
|
5
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
6
|
import { LegendPosition as ee } from "../../types.js";
|
|
7
|
-
const
|
|
7
|
+
const ie = {
|
|
8
8
|
ref: "slotWrapper",
|
|
9
9
|
style: { display: "none" }
|
|
10
|
-
}, y = 24, V = 4,
|
|
10
|
+
}, y = 24, V = 4, te = 0.5, F = "#3b82f6", de = /* @__PURE__ */ U({
|
|
11
11
|
__name: "AreaChart",
|
|
12
12
|
props: {
|
|
13
13
|
data: {},
|
|
@@ -22,10 +22,10 @@ const te = {
|
|
|
22
22
|
curveType: {},
|
|
23
23
|
lineWidth: { default: 2 },
|
|
24
24
|
lineDashArray: {},
|
|
25
|
-
xNumTicks: { default: (
|
|
25
|
+
xNumTicks: { default: (r) => r.data.length > y ? y / V : r.data.length - 1 },
|
|
26
26
|
xExplicitTicks: {},
|
|
27
27
|
minMaxTicksOnly: { type: Boolean },
|
|
28
|
-
yNumTicks: { default: (
|
|
28
|
+
yNumTicks: { default: (r) => r.data.length > y ? y / V : r.data.length - 1 },
|
|
29
29
|
hideLegend: { type: Boolean },
|
|
30
30
|
hideTooltip: { type: Boolean },
|
|
31
31
|
legendPosition: {},
|
|
@@ -39,32 +39,34 @@ const te = {
|
|
|
39
39
|
hideYAxis: { type: Boolean },
|
|
40
40
|
crosshairConfig: { default: () => ({
|
|
41
41
|
color: "#666"
|
|
42
|
-
}) }
|
|
42
|
+
}) },
|
|
43
|
+
yDomain: {},
|
|
44
|
+
xDomain: {}
|
|
43
45
|
},
|
|
44
46
|
emits: ["click"],
|
|
45
|
-
setup(
|
|
46
|
-
const G = $, n =
|
|
47
|
+
setup(r, { emit: $ }) {
|
|
48
|
+
const G = $, n = r, O = j(), h = w("slotWrapper"), s = R(), f = p(
|
|
47
49
|
() => Object.values(n.categories).map((e) => e.color)
|
|
48
|
-
), N =
|
|
49
|
-
const e = (
|
|
50
|
-
<linearGradient id="gradient${
|
|
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)">
|
|
51
53
|
<stop offset="0%" stop-color="${o}" stop-opacity="1" />
|
|
52
54
|
<stop offset="100%" stop-color="${o}" stop-opacity="0" />
|
|
53
55
|
</linearGradient>
|
|
54
|
-
`, l = (
|
|
55
|
-
<linearGradient id="gradient${
|
|
56
|
+
`, l = (i, o) => `
|
|
57
|
+
<linearGradient id="gradient${i}-${o}" gradientTransform="rotate(90)">
|
|
56
58
|
<stop offset="0%" style="stop-color:var(--vis-color0);stop-opacity:1" />
|
|
57
59
|
<stop offset="100%" style="stop-color:var(--vis-color0);stop-opacity:0" />
|
|
58
60
|
</linearGradient>
|
|
59
61
|
`;
|
|
60
62
|
return f.value.map(
|
|
61
|
-
(
|
|
63
|
+
(i, o) => i != null && i.includes("#") ? e(o, i) : l(o, i ?? F)
|
|
62
64
|
).join("");
|
|
63
65
|
});
|
|
64
66
|
function P(e) {
|
|
65
67
|
var l;
|
|
66
68
|
return {
|
|
67
|
-
y: (
|
|
69
|
+
y: (i) => Number(i[e]),
|
|
68
70
|
color: ((l = n.categories[e]) == null ? void 0 : l.color) ?? F
|
|
69
71
|
};
|
|
70
72
|
}
|
|
@@ -74,44 +76,46 @@ const te = {
|
|
|
74
76
|
function M(e) {
|
|
75
77
|
return s.value = e, W();
|
|
76
78
|
}
|
|
77
|
-
return (e, l) => (
|
|
79
|
+
return (e, l) => (a(), u("div", {
|
|
78
80
|
style: T({
|
|
79
81
|
display: "flex",
|
|
80
82
|
flexDirection: g.value ? "column-reverse" : "column"
|
|
81
83
|
}),
|
|
82
84
|
class: S({ markers: !!n.markerConfig }),
|
|
83
|
-
onClick: l[0] || (l[0] = (
|
|
85
|
+
onClick: l[0] || (l[0] = (i) => G("click", i, s.value))
|
|
84
86
|
}, [
|
|
85
|
-
|
|
87
|
+
m(t(K), {
|
|
86
88
|
data: e.data,
|
|
87
89
|
height: e.height,
|
|
88
90
|
padding: e.padding,
|
|
89
|
-
"svg-defs": E.value + N.value
|
|
91
|
+
"svg-defs": E.value + N.value,
|
|
92
|
+
"y-domain": e.yDomain,
|
|
93
|
+
"x-domain": e.xDomain
|
|
90
94
|
}, {
|
|
91
|
-
default:
|
|
92
|
-
e.hideTooltip ? d("", !0) : (
|
|
95
|
+
default: x(() => [
|
|
96
|
+
e.hideTooltip ? d("", !0) : (a(), c(t(q), {
|
|
93
97
|
key: 0,
|
|
94
|
-
"horizontal-placement":
|
|
95
|
-
"vertical-placement":
|
|
98
|
+
"horizontal-placement": t(A).Right,
|
|
99
|
+
"vertical-placement": t(A).Top
|
|
96
100
|
}, null, 8, ["horizontal-placement", "vertical-placement"])),
|
|
97
|
-
(
|
|
98
|
-
|
|
101
|
+
(a(!0), u(L, null, z(Object.keys(n.categories), (i, o) => (a(), u(L, { key: i }, [
|
|
102
|
+
m(t(J), C({
|
|
99
103
|
x: (k, v) => v
|
|
100
|
-
}, { ref_for: !0 }, P(
|
|
104
|
+
}, { ref_for: !0 }, P(i), {
|
|
101
105
|
color: `url(#gradient${o}-${f.value[o]})`,
|
|
102
|
-
opacity:
|
|
103
|
-
"curve-type": e.curveType ??
|
|
106
|
+
opacity: te,
|
|
107
|
+
"curve-type": e.curveType ?? t(b).MonotoneX
|
|
104
108
|
}), null, 16, ["x", "color", "curve-type"]),
|
|
105
|
-
|
|
109
|
+
m(t(Q), {
|
|
106
110
|
x: (k, v) => v,
|
|
107
|
-
y: (k) => k[
|
|
111
|
+
y: (k) => k[i],
|
|
108
112
|
color: f.value[o],
|
|
109
|
-
"curve-type": e.curveType ??
|
|
113
|
+
"curve-type": e.curveType ?? t(b).MonotoneX,
|
|
110
114
|
"line-width": e.lineWidth,
|
|
111
115
|
lineDashArray: e.lineDashArray ? e.lineDashArray[o] : void 0
|
|
112
116
|
}, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"])
|
|
113
117
|
], 64))), 128)),
|
|
114
|
-
e.hideXAxis ? d("", !0) : (
|
|
118
|
+
e.hideXAxis ? d("", !0) : (a(), c(t(B), {
|
|
115
119
|
key: 1,
|
|
116
120
|
type: "x",
|
|
117
121
|
label: e.xLabel,
|
|
@@ -124,7 +128,7 @@ const te = {
|
|
|
124
128
|
"tick-line": e.xTickLine,
|
|
125
129
|
"min-max-ticks-only": e.minMaxTicksOnly
|
|
126
130
|
}, null, 8, ["label", "num-ticks", "tick-format", "tick-values", "grid-line", "domain-line", "tick-line", "min-max-ticks-only"])),
|
|
127
|
-
e.hideYAxis ? d("", !0) : (
|
|
131
|
+
e.hideYAxis ? d("", !0) : (a(), c(t(B), {
|
|
128
132
|
key: 2,
|
|
129
133
|
type: "y",
|
|
130
134
|
label: e.yLabel,
|
|
@@ -134,11 +138,11 @@ const te = {
|
|
|
134
138
|
"domain-line": e.yDomainLine,
|
|
135
139
|
"tick-line": e.yTickLine
|
|
136
140
|
}, null, 8, ["label", "num-ticks", "tick-format", "grid-line", "domain-line", "tick-line"])),
|
|
137
|
-
e.hideTooltip ? d("", !0) : (
|
|
141
|
+
e.hideTooltip ? d("", !0) : (a(), c(t(Z), C({ key: 3 }, e.crosshairConfig, { template: M }), null, 16))
|
|
138
142
|
]),
|
|
139
143
|
_: 1
|
|
140
|
-
}, 8, ["data", "height", "padding", "svg-defs"]),
|
|
141
|
-
e.hideLegend ? d("", !0) : (
|
|
144
|
+
}, 8, ["data", "height", "padding", "svg-defs", "y-domain", "x-domain"]),
|
|
145
|
+
e.hideLegend ? d("", !0) : (a(), u("div", {
|
|
142
146
|
key: 0,
|
|
143
147
|
style: T({
|
|
144
148
|
display: "flex",
|
|
@@ -148,19 +152,19 @@ const te = {
|
|
|
148
152
|
paddingTop: g.value ? void 0 : "1rem"
|
|
149
153
|
})
|
|
150
154
|
}, [
|
|
151
|
-
|
|
155
|
+
m(t(_), {
|
|
152
156
|
items: Object.values(e.categories)
|
|
153
157
|
}, null, 8, ["items"])
|
|
154
158
|
], 4)),
|
|
155
|
-
X("div",
|
|
156
|
-
|
|
159
|
+
X("div", ie, [
|
|
160
|
+
t(O).tooltip ? D(e.$slots, "tooltip", {
|
|
157
161
|
key: 0,
|
|
158
162
|
values: s.value
|
|
159
|
-
}) : s.value ?
|
|
160
|
-
|
|
163
|
+
}) : s.value ? D(e.$slots, "fallback", { key: 1 }, () => [
|
|
164
|
+
m(H, {
|
|
161
165
|
data: s.value,
|
|
162
166
|
categories: e.categories,
|
|
163
|
-
toolTipTitle:
|
|
167
|
+
toolTipTitle: t(Y)(s.value) ?? "",
|
|
164
168
|
yFormatter: n.yFormatter
|
|
165
169
|
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
166
170
|
]) : d("", !0)
|
|
@@ -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
|
*/
|
|
@@ -130,4 +130,12 @@ export interface AreaChartProps<T> {
|
|
|
130
130
|
* Crosshair configuration object for customizing the appearance of the crosshair line.
|
|
131
131
|
*/
|
|
132
132
|
crosshairConfig?: CrosshairConfig;
|
|
133
|
+
/**
|
|
134
|
+
* The domain for the y-axis, specified as a tuple of two values.
|
|
135
|
+
*/
|
|
136
|
+
yDomain?: [number | undefined, number | undefined];
|
|
137
|
+
/**
|
|
138
|
+
* The domain for the x-axis, specified as a tuple of two values.
|
|
139
|
+
*/
|
|
140
|
+
xDomain?: [number | undefined, number | undefined];
|
|
133
141
|
}
|
|
@@ -2,11 +2,11 @@ import { computed as u } from "vue";
|
|
|
2
2
|
import { flattenData as i } from "../../utils.js";
|
|
3
3
|
function g(t) {
|
|
4
4
|
return u(() => {
|
|
5
|
-
const
|
|
5
|
+
const r = f(t.categories), e = p(t.categories, r), o = l(e, t.categories), c = d(e), n = m(o), s = y(r, t.spacing), a = t.stackAndGrouped ? i(t.data, t.xAxis) : t.data;
|
|
6
6
|
return {
|
|
7
|
-
states:
|
|
8
|
-
groupedByState:
|
|
9
|
-
colors:
|
|
7
|
+
states: r,
|
|
8
|
+
groupedByState: e,
|
|
9
|
+
colors: o,
|
|
10
10
|
bars: c,
|
|
11
11
|
colorFunctions: n,
|
|
12
12
|
positions: s,
|
|
@@ -14,51 +14,52 @@ function g(t) {
|
|
|
14
14
|
};
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
const
|
|
19
|
-
return Object.keys(t).forEach((
|
|
20
|
-
const c =
|
|
21
|
-
c &&
|
|
22
|
-
}), Array.from(
|
|
17
|
+
function f(t) {
|
|
18
|
+
const r = /* @__PURE__ */ new Set();
|
|
19
|
+
return Object.keys(t).forEach((o) => {
|
|
20
|
+
const c = o.match(/([A-Z][a-z]+)$/);
|
|
21
|
+
c && r.add(c[1]);
|
|
22
|
+
}), Array.from(r);
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
const
|
|
26
|
-
return
|
|
27
|
-
o
|
|
28
|
-
(c) => c.endsWith(
|
|
24
|
+
function p(t, r) {
|
|
25
|
+
const e = {};
|
|
26
|
+
return r.forEach((o) => {
|
|
27
|
+
e[o] = Object.keys(t).filter(
|
|
28
|
+
(c) => c.endsWith(o)
|
|
29
29
|
);
|
|
30
|
-
}),
|
|
31
|
-
}
|
|
32
|
-
function d(t, e) {
|
|
33
|
-
const o = {};
|
|
34
|
-
return Object.entries(t).forEach(([r, c]) => {
|
|
35
|
-
o[r] = c.map((n) => {
|
|
36
|
-
var s;
|
|
37
|
-
return ((s = e[n]) == null ? void 0 : s.color) ?? "#ccc";
|
|
38
|
-
});
|
|
39
|
-
}), o;
|
|
30
|
+
}), e;
|
|
40
31
|
}
|
|
41
|
-
function l(t) {
|
|
32
|
+
function l(t, r) {
|
|
42
33
|
const e = {};
|
|
43
|
-
return Object.entries(t).forEach(([o,
|
|
44
|
-
e[o] =
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
return Object.entries(t).forEach(([o, c]) => {
|
|
35
|
+
e[o] = c.map((n) => {
|
|
36
|
+
var a;
|
|
37
|
+
const s = (a = r[n]) == null ? void 0 : a.color;
|
|
38
|
+
return Array.isArray(s) ? s[0] ?? "#ccc" : s ?? "#ccc";
|
|
47
39
|
});
|
|
48
40
|
}), e;
|
|
49
41
|
}
|
|
42
|
+
function d(t) {
|
|
43
|
+
const r = {};
|
|
44
|
+
return Object.entries(t).forEach(([e, o]) => {
|
|
45
|
+
r[e] = o.map((c) => {
|
|
46
|
+
const n = c.replace(e, "").toLowerCase();
|
|
47
|
+
return (s) => s[n + e];
|
|
48
|
+
});
|
|
49
|
+
}), r;
|
|
50
|
+
}
|
|
50
51
|
function m(t) {
|
|
51
|
-
const
|
|
52
|
-
return Object.entries(t).forEach(([
|
|
53
|
-
e
|
|
54
|
-
}),
|
|
52
|
+
const r = {};
|
|
53
|
+
return Object.entries(t).forEach(([e, o]) => {
|
|
54
|
+
r[e] = (c, n) => o[n] ?? "#ccc";
|
|
55
|
+
}), r;
|
|
55
56
|
}
|
|
56
|
-
function
|
|
57
|
-
const
|
|
57
|
+
function y(t, r = 0.4) {
|
|
58
|
+
const e = t.length, o = {};
|
|
58
59
|
return t.forEach((c, n) => {
|
|
59
|
-
const s = (n - (
|
|
60
|
-
|
|
61
|
-
}),
|
|
60
|
+
const s = (n - (e - 1) / 2) * r;
|
|
61
|
+
o[c] = s;
|
|
62
|
+
}), o;
|
|
62
63
|
}
|
|
63
64
|
export {
|
|
64
65
|
g as useStackedGrouped
|
|
@@ -66,7 +66,7 @@ type BarChartPropsBase<T> = {
|
|
|
66
66
|
/**
|
|
67
67
|
* Force specific ticks on the x-axis.
|
|
68
68
|
*/
|
|
69
|
-
xExplicitTicks?: number;
|
|
69
|
+
xExplicitTicks?: (number | string | Date)[];
|
|
70
70
|
/**
|
|
71
71
|
* An array of property keys from the data object type 'T' to be used for the y-axis values.
|
|
72
72
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as N, computed as f, useSlots as P, useTemplateRef as O, ref as j, createElementBlock as p, openBlock as n, normalizeClass as w, normalizeStyle as k, createVNode as s, createCommentVNode as l, 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
3
|
import { createMarkers as $, getFirstPropertyValue as R } from "../../utils.js";
|
|
4
4
|
import S from "../Tooltip.js";
|
|
@@ -7,7 +7,7 @@ import { LegendPosition as J } from "../../types.js";
|
|
|
7
7
|
const Q = {
|
|
8
8
|
ref: "slotWrapper",
|
|
9
9
|
style: { display: "none" }
|
|
10
|
-
},
|
|
10
|
+
}, te = /* @__PURE__ */ N({
|
|
11
11
|
__name: "LineChart",
|
|
12
12
|
props: {
|
|
13
13
|
data: {},
|
|
@@ -27,10 +27,10 @@ const Q = {
|
|
|
27
27
|
curveType: {},
|
|
28
28
|
lineWidth: { default: 2 },
|
|
29
29
|
lineDashArray: {},
|
|
30
|
-
xNumTicks: { default: (
|
|
30
|
+
xNumTicks: { default: (t) => t.data.length > 24 ? 24 / 4 : t.data.length - 1 },
|
|
31
31
|
xExplicitTicks: {},
|
|
32
32
|
minMaxTicksOnly: { type: Boolean },
|
|
33
|
-
yNumTicks: { default: (
|
|
33
|
+
yNumTicks: { default: (t) => t.data.length > 24 ? 24 / 4 : t.data.length - 1 },
|
|
34
34
|
hideTooltip: { type: Boolean },
|
|
35
35
|
hideLegend: { type: Boolean },
|
|
36
36
|
legendPosition: {},
|
|
@@ -44,52 +44,56 @@ const Q = {
|
|
|
44
44
|
hideYAxis: { type: Boolean },
|
|
45
45
|
crosshairConfig: { default: () => ({
|
|
46
46
|
color: "#666"
|
|
47
|
-
}) }
|
|
47
|
+
}) },
|
|
48
|
+
yDomain: {},
|
|
49
|
+
xDomain: {}
|
|
48
50
|
},
|
|
49
51
|
emits: ["click"],
|
|
50
|
-
setup(
|
|
51
|
-
const
|
|
52
|
-
function
|
|
53
|
-
return typeof window > "u" ? "" :
|
|
52
|
+
setup(t, { emit: L }) {
|
|
53
|
+
const D = L, o = t, C = f(() => o.markerConfig ? $(o.markerConfig) : ""), B = P(), y = O("slotWrapper"), a = j();
|
|
54
|
+
function b(e) {
|
|
55
|
+
return typeof window > "u" ? "" : y.value ? y.value.innerHTML : "";
|
|
54
56
|
}
|
|
55
57
|
function V(e) {
|
|
56
|
-
return
|
|
58
|
+
return a.value = e, b();
|
|
57
59
|
}
|
|
58
|
-
const
|
|
59
|
-
() =>
|
|
60
|
-
), A = Object.values(
|
|
60
|
+
const c = f(
|
|
61
|
+
() => o.legendPosition === J.Top
|
|
62
|
+
), A = Object.values(o.categories).map(
|
|
61
63
|
(e, r) => `var(--vis-color${r})`
|
|
62
|
-
), F = (e) => Object.values(
|
|
64
|
+
), F = (e) => Object.values(o.categories)[e].color ?? A[e];
|
|
63
65
|
return (e, r) => (n(), p("div", {
|
|
64
66
|
style: k({
|
|
65
67
|
display: "flex",
|
|
66
|
-
flexDirection:
|
|
68
|
+
flexDirection: c.value ? "column-reverse" : "column",
|
|
67
69
|
gap: "1rem"
|
|
68
70
|
}),
|
|
69
|
-
class:
|
|
70
|
-
onClick: r[0] || (r[0] = (d) =>
|
|
71
|
+
class: w({ markers: !!o.markerConfig }),
|
|
72
|
+
onClick: r[0] || (r[0] = (d) => D("click", d, a.value))
|
|
71
73
|
}, [
|
|
72
74
|
s(i(Y), {
|
|
73
75
|
data: e.data,
|
|
74
76
|
padding: e.padding,
|
|
75
77
|
height: e.height,
|
|
76
|
-
svgDefs:
|
|
78
|
+
svgDefs: C.value,
|
|
79
|
+
yDomain: e.yDomain,
|
|
80
|
+
xDomain: e.xDomain
|
|
77
81
|
}, {
|
|
78
82
|
default: W(() => [
|
|
79
83
|
s(i(H), {
|
|
80
84
|
"horizontal-placement": i(v).Right,
|
|
81
85
|
"vertical-placement": i(v).Top
|
|
82
86
|
}, null, 8, ["horizontal-placement", "vertical-placement"]),
|
|
83
|
-
(n(!0), p(z, null, E(Object.keys(
|
|
87
|
+
(n(!0), p(z, null, E(Object.keys(o.categories), (d, u) => (n(), m(i(I), {
|
|
84
88
|
key: u,
|
|
85
|
-
x: (g,
|
|
89
|
+
x: (g, x) => x,
|
|
86
90
|
y: (g) => g[d],
|
|
87
91
|
color: F(u),
|
|
88
92
|
"curve-type": e.curveType ?? i(X).MonotoneX,
|
|
89
93
|
"line-width": e.lineWidth,
|
|
90
94
|
lineDashArray: e.lineDashArray ? e.lineDashArray[u] : void 0
|
|
91
95
|
}, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"]))), 128)),
|
|
92
|
-
e.hideXAxis ?
|
|
96
|
+
e.hideXAxis ? l("", !0) : (n(), m(i(T), {
|
|
93
97
|
key: 0,
|
|
94
98
|
type: "x",
|
|
95
99
|
"tick-format": e.xFormatter,
|
|
@@ -102,7 +106,7 @@ const Q = {
|
|
|
102
106
|
"tick-values": e.xExplicitTicks,
|
|
103
107
|
"min-max-ticks-only": e.minMaxTicksOnly
|
|
104
108
|
}, null, 8, ["tick-format", "label", "domain-line", "grid-line", "tick-line", "num-ticks", "tick-values", "min-max-ticks-only"])),
|
|
105
|
-
e.hideYAxis ?
|
|
109
|
+
e.hideYAxis ? l("", !0) : (n(), m(i(T), {
|
|
106
110
|
key: 1,
|
|
107
111
|
type: "y",
|
|
108
112
|
"tick-format": e.yFormatter,
|
|
@@ -112,17 +116,17 @@ const Q = {
|
|
|
112
116
|
"grid-line": e.yGridLine,
|
|
113
117
|
"tick-line": e.yTickLine
|
|
114
118
|
}, null, 8, ["tick-format", "label", "num-ticks", "domain-line", "grid-line", "tick-line"])),
|
|
115
|
-
e.hideTooltip ?
|
|
119
|
+
e.hideTooltip ? l("", !0) : (n(), m(i(U), G({ key: 2 }, e.crosshairConfig, { template: V }), null, 16))
|
|
116
120
|
]),
|
|
117
121
|
_: 1
|
|
118
|
-
}, 8, ["data", "padding", "height", "svgDefs"]),
|
|
119
|
-
e.hideLegend ?
|
|
122
|
+
}, 8, ["data", "padding", "height", "svgDefs", "yDomain", "xDomain"]),
|
|
123
|
+
e.hideLegend ? l("", !0) : (n(), p("div", {
|
|
120
124
|
key: 0,
|
|
121
125
|
style: k({
|
|
122
126
|
display: "flex",
|
|
123
127
|
alignItems: "center",
|
|
124
128
|
justifyContent: "flex-end",
|
|
125
|
-
paddingBottom:
|
|
129
|
+
paddingBottom: c.value ? "1rem" : void 0
|
|
126
130
|
})
|
|
127
131
|
}, [
|
|
128
132
|
s(i(q), {
|
|
@@ -130,21 +134,21 @@ const Q = {
|
|
|
130
134
|
}, null, 8, ["items"])
|
|
131
135
|
], 4)),
|
|
132
136
|
M("div", Q, [
|
|
133
|
-
i(
|
|
137
|
+
i(B).tooltip ? h(e.$slots, "tooltip", {
|
|
134
138
|
key: 0,
|
|
135
|
-
values:
|
|
136
|
-
}) :
|
|
139
|
+
values: a.value
|
|
140
|
+
}) : a.value ? h(e.$slots, "fallback", { key: 1 }, () => [
|
|
137
141
|
s(S, {
|
|
138
|
-
data:
|
|
142
|
+
data: a.value,
|
|
139
143
|
categories: e.categories,
|
|
140
|
-
toolTipTitle: i(R)(
|
|
141
|
-
yFormatter:
|
|
144
|
+
toolTipTitle: i(R)(a.value) ?? "",
|
|
145
|
+
yFormatter: o.yFormatter
|
|
142
146
|
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
143
|
-
]) :
|
|
147
|
+
]) : l("", !0)
|
|
144
148
|
], 512)
|
|
145
149
|
], 6));
|
|
146
150
|
}
|
|
147
151
|
});
|
|
148
152
|
export {
|
|
149
|
-
|
|
153
|
+
te as default
|
|
150
154
|
};
|
|
@@ -71,7 +71,7 @@ export interface LineChartProps<T> {
|
|
|
71
71
|
/**
|
|
72
72
|
* Force specific ticks on the x-axis.
|
|
73
73
|
*/
|
|
74
|
-
xExplicitTicks?: number;
|
|
74
|
+
xExplicitTicks?: (number | string | Date)[];
|
|
75
75
|
/**
|
|
76
76
|
* Force only first and last ticks on the x-axis.
|
|
77
77
|
*/
|
|
@@ -129,4 +129,12 @@ export interface LineChartProps<T> {
|
|
|
129
129
|
* Crosshair configuration object for customizing the appearance of the crosshair line.
|
|
130
130
|
*/
|
|
131
131
|
crosshairConfig?: CrosshairConfig;
|
|
132
|
+
/**
|
|
133
|
+
* The domain for the y-axis, specified as a tuple of two values.
|
|
134
|
+
*/
|
|
135
|
+
yDomain?: [number | undefined, number | undefined];
|
|
136
|
+
/**
|
|
137
|
+
* The domain for the x-axis, specified as a tuple of two values.
|
|
138
|
+
*/
|
|
139
|
+
xDomain?: [number | undefined, number | undefined];
|
|
132
140
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as y, computed as f, 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 x = { style: { padding: "10px 15px" } }, _ = { style: {
|
|
3
3
|
color: "var(--tooltip-value-color)",
|
|
4
4
|
textTransform: "capitalize",
|
|
5
5
|
borderBottom: "1px solid rgba(255, 255, 255, 0.05)",
|
|
6
6
|
marginBottom: "0.25rem",
|
|
7
7
|
paddingBottom: "0.25rem"
|
|
8
|
-
} },
|
|
8
|
+
} }, T = /* @__PURE__ */ y({
|
|
9
9
|
__name: "Tooltip",
|
|
10
10
|
props: {
|
|
11
11
|
data: {},
|
|
@@ -13,21 +13,21 @@ const f = { style: { padding: "10px 15px" } }, x = { style: {
|
|
|
13
13
|
toolTipTitle: {},
|
|
14
14
|
yFormatter: { type: Function }
|
|
15
15
|
},
|
|
16
|
-
setup(
|
|
17
|
-
const a =
|
|
18
|
-
([t,
|
|
16
|
+
setup(d) {
|
|
17
|
+
const a = d, m = ["_index", "_stacked", "_ending"], g = f(() => Object.entries(a.data ?? []).filter(
|
|
18
|
+
([t, u]) => !m.includes(t) && Object.keys(a.categories).includes(t)
|
|
19
19
|
));
|
|
20
|
-
return (t,
|
|
21
|
-
e("div",
|
|
22
|
-
(i(!0), r(h, null, b(
|
|
23
|
-
var p;
|
|
20
|
+
return (t, u) => (i(), r("div", x, [
|
|
21
|
+
e("div", _, l(t.toolTipTitle), 1),
|
|
22
|
+
(i(!0), r(h, null, b(g.value, ([o, s], v) => {
|
|
23
|
+
var p, c;
|
|
24
24
|
return i(), r("div", {
|
|
25
25
|
key: o,
|
|
26
26
|
style: { display: "flex", "align-items": "center", "margin-bottom": "4px" }
|
|
27
27
|
}, [
|
|
28
28
|
e("span", {
|
|
29
29
|
style: n([{ width: "8px", height: "8px", "border-radius": "4px", "margin-right": "8px" }, {
|
|
30
|
-
backgroundColor: (p = t.categories[o]) != null &&
|
|
30
|
+
backgroundColor: typeof ((p = t.categories[o]) == null ? void 0 : p.color) == "string" && ((c = t.categories[o]) != null && c.color) ? t.categories[o].color : `var(--vis-color${v})`
|
|
31
31
|
}])
|
|
32
32
|
}, null, 4),
|
|
33
33
|
e("div", null, [
|
|
@@ -44,5 +44,5 @@ const f = { style: { padding: "10px 15px" } }, x = { style: {
|
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
export {
|
|
47
|
-
|
|
47
|
+
T as default
|
|
48
48
|
};
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-chrts",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"@tanstack/vue-table": "^8.21.2",
|
|
29
29
|
"@types/node": "^22.13.11",
|
|
30
30
|
"@types/rollup": "^0.54.0",
|
|
31
|
-
"@unovis/ts": "^1.
|
|
32
|
-
"@unovis/vue": "^1.
|
|
31
|
+
"@unovis/ts": "^1.6.1",
|
|
32
|
+
"@unovis/vue": "^1.6.1",
|
|
33
33
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
34
34
|
"@vue/tsconfig": "^0.7.0",
|
|
35
35
|
"@vueuse/core": "^13.0.0",
|