vue-chrts 0.2.0-test.2 → 0.2.0-test.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/_virtual/_plugin-vue_export-helper.js +9 -0
- package/dist/components/AreaChart/AreaChart.js +4 -156
- package/dist/components/AreaChart/AreaChart2.js +157 -2
- package/dist/components/AreaChart/types.d.ts +5 -1
- package/dist/components/LineChart/LineChart.js +56 -51
- package/dist/components/LineChart/types.d.ts +5 -1
- package/dist/index.js.css +1 -0
- package/dist/types.d.ts +6 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +30 -5
- package/package.json +3 -6
|
@@ -1,158 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import Y from "../Tooltip.js";
|
|
5
|
-
import { VisXYContainer as w, VisTooltip as z, VisArea as I, VisLine as S, VisAxis as V, VisCrosshair as H, VisBulletLegend as K } from "@unovis/vue";
|
|
6
|
-
import { LegendPosition as q } from "../../types.js";
|
|
7
|
-
const J = {
|
|
8
|
-
ref: "slotWrapper",
|
|
9
|
-
class: "hidden"
|
|
10
|
-
}, m = 24, A = 4, Q = 0.5, F = "#3b82f6", ae = /* @__PURE__ */ E({
|
|
11
|
-
__name: "AreaChart",
|
|
12
|
-
props: {
|
|
13
|
-
data: {},
|
|
14
|
-
height: {},
|
|
15
|
-
xLabel: {},
|
|
16
|
-
yLabel: {},
|
|
17
|
-
padding: { default: () => ({ top: 5, right: 5, bottom: 5, left: 5 }) },
|
|
18
|
-
categories: {},
|
|
19
|
-
xFormatter: {},
|
|
20
|
-
yFormatter: {},
|
|
21
|
-
curveType: {},
|
|
22
|
-
xNumTicks: { default: (n) => n.data.length > m ? m / A : n.data.length - 1 },
|
|
23
|
-
xExplicitTicks: {},
|
|
24
|
-
minMaxTicksOnly: { type: Boolean },
|
|
25
|
-
yNumTicks: { default: (n) => n.data.length > m ? m / A : n.data.length - 1 },
|
|
26
|
-
hideLegend: { type: Boolean },
|
|
27
|
-
hideTooltip: { type: Boolean },
|
|
28
|
-
legendPosition: {},
|
|
29
|
-
xDomainLine: { type: Boolean },
|
|
30
|
-
yDomainLine: { type: Boolean },
|
|
31
|
-
xTickLine: { type: Boolean },
|
|
32
|
-
yTickLine: { type: Boolean },
|
|
33
|
-
xGridLine: { type: Boolean },
|
|
34
|
-
yGridLine: { type: Boolean },
|
|
35
|
-
hideXAxis: { type: Boolean },
|
|
36
|
-
hideYAxis: { type: Boolean }
|
|
37
|
-
},
|
|
38
|
-
setup(n) {
|
|
39
|
-
const l = n, $ = x(), v = P("slotWrapper"), s = U(), y = k(
|
|
40
|
-
() => Object.values(l.categories).map((e) => e.color)
|
|
41
|
-
), T = k(() => l.legendPosition === q.Top), D = k(() => {
|
|
42
|
-
const e = (t, o) => `
|
|
43
|
-
<linearGradient id="gradient${t}-${o}" gradientTransform="rotate(90)">
|
|
44
|
-
<stop offset="0%" stop-color="${o}" stop-opacity="1" />
|
|
45
|
-
<stop offset="100%" stop-color="${o}" stop-opacity="0" />
|
|
46
|
-
</linearGradient>
|
|
47
|
-
`, p = (t, o) => `
|
|
48
|
-
<linearGradient id="gradient${t}-${o}" gradientTransform="rotate(90)">
|
|
49
|
-
<stop offset="0%" style="stop-color:var(--vis-color0);stop-opacity:1" />
|
|
50
|
-
<stop offset="100%" style="stop-color:var(--vis-color0);stop-opacity:0" />
|
|
51
|
-
</linearGradient>
|
|
52
|
-
`;
|
|
53
|
-
return y.value.map(
|
|
54
|
-
(t, o) => t != null && t.includes("#") ? e(o, t) : p(o, t ?? F)
|
|
55
|
-
).join("");
|
|
56
|
-
});
|
|
57
|
-
function G(e) {
|
|
58
|
-
var p;
|
|
59
|
-
return {
|
|
60
|
-
y: (t) => Number(t[e]),
|
|
61
|
-
color: ((p = l.categories[e]) == null ? void 0 : p.color) ?? F
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
function O(e) {
|
|
65
|
-
return typeof window > "u" ? "" : v.value ? v.value.innerHTML : "";
|
|
66
|
-
}
|
|
67
|
-
function N(e) {
|
|
68
|
-
return s.value = e, O();
|
|
69
|
-
}
|
|
70
|
-
return (e, p) => (a(), d("div", {
|
|
71
|
-
class: h(["flex flex-col space-y-4", { "flex-col-reverse": T.value }])
|
|
72
|
-
}, [
|
|
73
|
-
c(i(w), {
|
|
74
|
-
data: e.data,
|
|
75
|
-
height: e.height,
|
|
76
|
-
padding: e.padding,
|
|
77
|
-
"svg-defs": D.value
|
|
78
|
-
}, {
|
|
79
|
-
default: M(() => [
|
|
80
|
-
e.hideTooltip ? r("", !0) : (a(), u(i(z), {
|
|
81
|
-
key: 0,
|
|
82
|
-
"horizontal-placement": i(C).Right,
|
|
83
|
-
"vertical-placement": i(C).Top
|
|
84
|
-
}, null, 8, ["horizontal-placement", "vertical-placement"])),
|
|
85
|
-
(a(!0), d(L, null, R(Object.keys(l.categories), (t, o) => (a(), d(L, { key: t }, [
|
|
86
|
-
c(i(I), W({
|
|
87
|
-
x: (f, g) => g,
|
|
88
|
-
ref_for: !0
|
|
89
|
-
}, G(t), {
|
|
90
|
-
color: `url(#gradient${o}-${y.value[o]})`,
|
|
91
|
-
opacity: Q,
|
|
92
|
-
"curve-type": e.curveType ?? i(B).MonotoneX
|
|
93
|
-
}), null, 16, ["x", "color", "curve-type"]),
|
|
94
|
-
c(i(S), {
|
|
95
|
-
x: (f, g) => g,
|
|
96
|
-
y: (f) => f[t],
|
|
97
|
-
color: y.value[o],
|
|
98
|
-
"curve-type": e.curveType ?? i(B).MonotoneX
|
|
99
|
-
}, null, 8, ["x", "y", "color", "curve-type"])
|
|
100
|
-
], 64))), 128)),
|
|
101
|
-
e.hideXAxis ? r("", !0) : (a(), u(i(V), {
|
|
102
|
-
key: 1,
|
|
103
|
-
type: "x",
|
|
104
|
-
label: e.xLabel,
|
|
105
|
-
"label-margin": 8,
|
|
106
|
-
"num-ticks": e.xNumTicks,
|
|
107
|
-
"tick-format": e.xFormatter,
|
|
108
|
-
"tick-values": e.xExplicitTicks,
|
|
109
|
-
"grid-line": e.xGridLine,
|
|
110
|
-
"domain-line": e.xDomainLine,
|
|
111
|
-
"tick-line": e.xTickLine,
|
|
112
|
-
"min-max-ticks-only": e.minMaxTicksOnly
|
|
113
|
-
}, null, 8, ["label", "num-ticks", "tick-format", "tick-values", "grid-line", "domain-line", "tick-line", "min-max-ticks-only"])),
|
|
114
|
-
e.hideYAxis ? r("", !0) : (a(), u(i(V), {
|
|
115
|
-
key: 2,
|
|
116
|
-
type: "y",
|
|
117
|
-
label: e.yLabel,
|
|
118
|
-
"num-ticks": e.yNumTicks,
|
|
119
|
-
"tick-format": e.yFormatter,
|
|
120
|
-
"grid-line": e.yGridLine,
|
|
121
|
-
"domain-line": e.yDomainLine,
|
|
122
|
-
"tick-line": e.yTickLine
|
|
123
|
-
}, null, 8, ["label", "num-ticks", "tick-format", "grid-line", "domain-line", "tick-line"])),
|
|
124
|
-
e.hideTooltip ? r("", !0) : (a(), u(i(H), {
|
|
125
|
-
key: 3,
|
|
126
|
-
color: "#666",
|
|
127
|
-
template: N
|
|
128
|
-
}))
|
|
129
|
-
]),
|
|
130
|
-
_: 1
|
|
131
|
-
}, 8, ["data", "height", "padding", "svg-defs"]),
|
|
132
|
-
e.hideLegend ? r("", !0) : (a(), d("div", {
|
|
133
|
-
key: 0,
|
|
134
|
-
class: h(["flex items-center justify-end", { "pb-4": T.value }])
|
|
135
|
-
}, [
|
|
136
|
-
c(i(K), {
|
|
137
|
-
items: Object.values(e.categories)
|
|
138
|
-
}, null, 8, ["items"])
|
|
139
|
-
], 2)),
|
|
140
|
-
j("div", J, [
|
|
141
|
-
i($).tooltip ? b(e.$slots, "tooltip", {
|
|
142
|
-
key: 0,
|
|
143
|
-
values: s.value
|
|
144
|
-
}) : s.value ? b(e.$slots, "fallback", { key: 1 }, () => [
|
|
145
|
-
c(Y, {
|
|
146
|
-
data: s.value,
|
|
147
|
-
categories: e.categories,
|
|
148
|
-
toolTipTitle: i(X)(s.value) ?? "",
|
|
149
|
-
yFormatter: l.yFormatter
|
|
150
|
-
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
151
|
-
]) : r("", !0)
|
|
152
|
-
], 512)
|
|
153
|
-
], 2));
|
|
154
|
-
}
|
|
155
|
-
});
|
|
1
|
+
import a from "./AreaChart2.js";
|
|
2
|
+
import o from "../../_virtual/_plugin-vue_export-helper.js";
|
|
3
|
+
const f = /* @__PURE__ */ o(a, [["__scopeId", "data-v-b9ab9df3"]]);
|
|
156
4
|
export {
|
|
157
|
-
|
|
5
|
+
f as default
|
|
158
6
|
};
|
|
@@ -1,4 +1,159 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { defineComponent as x, useSlots as P, useTemplateRef as M, ref as U, computed as c, createElementBlock as d, openBlock as a, normalizeClass as h, createVNode as u, createCommentVNode as l, createElementVNode as j, unref as i, withCtx as R, createBlock as m, Fragment as L, renderList as W, mergeProps as X, renderSlot as C } from "vue";
|
|
2
|
+
import { Position as b, CurveType as B } from "@unovis/ts";
|
|
3
|
+
import { createMarkers as S, getFirstPropertyValue as Y } from "../../utils.js";
|
|
4
|
+
import w from "../Tooltip.js";
|
|
5
|
+
import { VisXYContainer as z, VisTooltip as I, VisArea as H, VisLine as K, VisAxis as V, VisCrosshair as q, VisBulletLegend as J } from "@unovis/vue";
|
|
6
|
+
import { LegendPosition as Q } from "../../types.js";
|
|
7
|
+
const Z = {
|
|
8
|
+
ref: "slotWrapper",
|
|
9
|
+
class: "hidden"
|
|
10
|
+
}, y = 24, A = 4, _ = 0.5, F = "#3b82f6", ne = /* @__PURE__ */ x({
|
|
11
|
+
__name: "AreaChart",
|
|
12
|
+
props: {
|
|
13
|
+
data: {},
|
|
14
|
+
height: {},
|
|
15
|
+
xLabel: {},
|
|
16
|
+
yLabel: {},
|
|
17
|
+
padding: { default: () => ({ top: 5, right: 5, bottom: 5, left: 5 }) },
|
|
18
|
+
categories: {},
|
|
19
|
+
markerConfig: {},
|
|
20
|
+
xFormatter: {},
|
|
21
|
+
yFormatter: {},
|
|
22
|
+
curveType: {},
|
|
23
|
+
xNumTicks: { default: (n) => n.data.length > y ? y / A : n.data.length - 1 },
|
|
24
|
+
xExplicitTicks: {},
|
|
25
|
+
minMaxTicksOnly: { type: Boolean },
|
|
26
|
+
yNumTicks: { default: (n) => n.data.length > y ? y / A : n.data.length - 1 },
|
|
27
|
+
hideLegend: { type: Boolean },
|
|
28
|
+
hideTooltip: { type: Boolean },
|
|
29
|
+
legendPosition: {},
|
|
30
|
+
xDomainLine: { type: Boolean },
|
|
31
|
+
yDomainLine: { type: Boolean },
|
|
32
|
+
xTickLine: { type: Boolean },
|
|
33
|
+
yTickLine: { type: Boolean },
|
|
34
|
+
xGridLine: { type: Boolean },
|
|
35
|
+
yGridLine: { type: Boolean },
|
|
36
|
+
hideXAxis: { type: Boolean },
|
|
37
|
+
hideYAxis: { type: Boolean }
|
|
38
|
+
},
|
|
39
|
+
setup(n) {
|
|
40
|
+
const r = n, D = P(), v = M("slotWrapper"), s = U(), f = c(
|
|
41
|
+
() => Object.values(r.categories).map((e) => e.color)
|
|
42
|
+
), T = c(() => r.legendPosition === Q.Top), $ = c(() => {
|
|
43
|
+
const e = (t, o) => `
|
|
44
|
+
<linearGradient id="gradient${t}-${o}" gradientTransform="rotate(90)">
|
|
45
|
+
<stop offset="0%" stop-color="${o}" stop-opacity="1" />
|
|
46
|
+
<stop offset="100%" stop-color="${o}" stop-opacity="0" />
|
|
47
|
+
</linearGradient>
|
|
48
|
+
`, p = (t, o) => `
|
|
49
|
+
<linearGradient id="gradient${t}-${o}" gradientTransform="rotate(90)">
|
|
50
|
+
<stop offset="0%" style="stop-color:var(--vis-color0);stop-opacity:1" />
|
|
51
|
+
<stop offset="100%" style="stop-color:var(--vis-color0);stop-opacity:0" />
|
|
52
|
+
</linearGradient>
|
|
53
|
+
`;
|
|
54
|
+
return f.value.map(
|
|
55
|
+
(t, o) => t != null && t.includes("#") ? e(o, t) : p(o, t ?? F)
|
|
56
|
+
).join("");
|
|
57
|
+
}), G = c(() => r.markerConfig ? S(r.markerConfig) : "");
|
|
58
|
+
function O(e) {
|
|
59
|
+
var p;
|
|
60
|
+
return {
|
|
61
|
+
y: (t) => Number(t[e]),
|
|
62
|
+
color: ((p = r.categories[e]) == null ? void 0 : p.color) ?? F
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function N(e) {
|
|
66
|
+
return typeof window > "u" ? "" : v.value ? v.value.innerHTML : "";
|
|
67
|
+
}
|
|
68
|
+
function E(e) {
|
|
69
|
+
return s.value = e, N();
|
|
70
|
+
}
|
|
71
|
+
return (e, p) => (a(), d("div", {
|
|
72
|
+
class: h(["flex flex-col space-y-4", { "flex-col-reverse": T.value, markers: !!r.markerConfig }])
|
|
73
|
+
}, [
|
|
74
|
+
u(i(z), {
|
|
75
|
+
data: e.data,
|
|
76
|
+
height: e.height,
|
|
77
|
+
padding: e.padding,
|
|
78
|
+
"svg-defs": $.value + G.value
|
|
79
|
+
}, {
|
|
80
|
+
default: R(() => [
|
|
81
|
+
e.hideTooltip ? l("", !0) : (a(), m(i(I), {
|
|
82
|
+
key: 0,
|
|
83
|
+
"horizontal-placement": i(b).Right,
|
|
84
|
+
"vertical-placement": i(b).Top
|
|
85
|
+
}, null, 8, ["horizontal-placement", "vertical-placement"])),
|
|
86
|
+
(a(!0), d(L, null, W(Object.keys(r.categories), (t, o) => (a(), d(L, { key: t }, [
|
|
87
|
+
u(i(H), X({
|
|
88
|
+
x: (g, k) => k,
|
|
89
|
+
ref_for: !0
|
|
90
|
+
}, O(t), {
|
|
91
|
+
color: `url(#gradient${o}-${f.value[o]})`,
|
|
92
|
+
opacity: _,
|
|
93
|
+
"curve-type": e.curveType ?? i(B).MonotoneX
|
|
94
|
+
}), null, 16, ["x", "color", "curve-type"]),
|
|
95
|
+
u(i(K), {
|
|
96
|
+
x: (g, k) => k,
|
|
97
|
+
y: (g) => g[t],
|
|
98
|
+
color: f.value[o],
|
|
99
|
+
"curve-type": e.curveType ?? i(B).MonotoneX
|
|
100
|
+
}, null, 8, ["x", "y", "color", "curve-type"])
|
|
101
|
+
], 64))), 128)),
|
|
102
|
+
e.hideXAxis ? l("", !0) : (a(), m(i(V), {
|
|
103
|
+
key: 1,
|
|
104
|
+
type: "x",
|
|
105
|
+
label: e.xLabel,
|
|
106
|
+
"label-margin": 8,
|
|
107
|
+
"num-ticks": e.xNumTicks,
|
|
108
|
+
"tick-format": e.xFormatter,
|
|
109
|
+
"tick-values": e.xExplicitTicks,
|
|
110
|
+
"grid-line": e.xGridLine,
|
|
111
|
+
"domain-line": e.xDomainLine,
|
|
112
|
+
"tick-line": e.xTickLine,
|
|
113
|
+
"min-max-ticks-only": e.minMaxTicksOnly
|
|
114
|
+
}, null, 8, ["label", "num-ticks", "tick-format", "tick-values", "grid-line", "domain-line", "tick-line", "min-max-ticks-only"])),
|
|
115
|
+
e.hideYAxis ? l("", !0) : (a(), m(i(V), {
|
|
116
|
+
key: 2,
|
|
117
|
+
type: "y",
|
|
118
|
+
label: e.yLabel,
|
|
119
|
+
"num-ticks": e.yNumTicks,
|
|
120
|
+
"tick-format": e.yFormatter,
|
|
121
|
+
"grid-line": e.yGridLine,
|
|
122
|
+
"domain-line": e.yDomainLine,
|
|
123
|
+
"tick-line": e.yTickLine
|
|
124
|
+
}, null, 8, ["label", "num-ticks", "tick-format", "grid-line", "domain-line", "tick-line"])),
|
|
125
|
+
e.hideTooltip ? l("", !0) : (a(), m(i(q), {
|
|
126
|
+
key: 3,
|
|
127
|
+
color: "#666",
|
|
128
|
+
template: E
|
|
129
|
+
}))
|
|
130
|
+
]),
|
|
131
|
+
_: 1
|
|
132
|
+
}, 8, ["data", "height", "padding", "svg-defs"]),
|
|
133
|
+
e.hideLegend ? l("", !0) : (a(), d("div", {
|
|
134
|
+
key: 0,
|
|
135
|
+
class: h(["flex items-center justify-end", { "pb-4": T.value }])
|
|
136
|
+
}, [
|
|
137
|
+
u(i(J), {
|
|
138
|
+
items: Object.values(e.categories)
|
|
139
|
+
}, null, 8, ["items"])
|
|
140
|
+
], 2)),
|
|
141
|
+
j("div", Z, [
|
|
142
|
+
i(D).tooltip ? C(e.$slots, "tooltip", {
|
|
143
|
+
key: 0,
|
|
144
|
+
values: s.value
|
|
145
|
+
}, void 0, !0) : s.value ? C(e.$slots, "fallback", { key: 1 }, () => [
|
|
146
|
+
u(w, {
|
|
147
|
+
data: s.value,
|
|
148
|
+
categories: e.categories,
|
|
149
|
+
toolTipTitle: i(Y)(s.value) ?? "",
|
|
150
|
+
yFormatter: r.yFormatter
|
|
151
|
+
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
152
|
+
], !0) : l("", !0)
|
|
153
|
+
], 512)
|
|
154
|
+
], 2));
|
|
155
|
+
}
|
|
156
|
+
});
|
|
2
157
|
export {
|
|
3
|
-
|
|
158
|
+
ne as default
|
|
4
159
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { axisFormatter, LegendPosition } from '../../types';
|
|
1
|
+
import { axisFormatter, LegendPosition, MarkerConfig } from '../../types';
|
|
2
2
|
import { BulletLegendItemInterface, CurveType } from '@unovis/ts';
|
|
3
3
|
export interface AreaChartProps<T> {
|
|
4
4
|
/**
|
|
@@ -34,6 +34,10 @@ export interface AreaChartProps<T> {
|
|
|
34
34
|
* This defines the visual representation and labels for each category in the chart's legend.
|
|
35
35
|
*/
|
|
36
36
|
categories: Record<string, BulletLegendItemInterface>;
|
|
37
|
+
/**
|
|
38
|
+
* A record mapping marker keys to show custom patterns.
|
|
39
|
+
*/
|
|
40
|
+
markerConfig?: Record<string, MarkerConfig>;
|
|
37
41
|
/**
|
|
38
42
|
* @param {number|Date} tick - The value of the tick. This can be a number or a Date object depending on the scale of the x-axis.
|
|
39
43
|
* @param {number} i - The index of the tick in the `ticks` array.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Position as
|
|
3
|
-
import { getFirstPropertyValue as
|
|
4
|
-
import
|
|
5
|
-
import { VisXYContainer as
|
|
6
|
-
import { LegendPosition as
|
|
7
|
-
const
|
|
1
|
+
import { defineComponent as D, computed as f, useSlots as N, useTemplateRef as O, ref as P, createElementBlock as m, openBlock as n, normalizeClass as k, createVNode as r, createCommentVNode as l, createElementVNode as j, unref as i, withCtx as A, createBlock as s, Fragment as M, renderList as E, renderSlot as g } from "vue";
|
|
2
|
+
import { Position as v, CurveType as G } from "@unovis/ts";
|
|
3
|
+
import { createMarkers as X, getFirstPropertyValue as $ } from "../../utils.js";
|
|
4
|
+
import w from "../Tooltip.js";
|
|
5
|
+
import { VisXYContainer as z, VisTooltip as R, VisLine as W, VisAxis as h, VisCrosshair as Y, VisBulletLegend as S } from "@unovis/vue";
|
|
6
|
+
import { LegendPosition as H } from "../../types.js";
|
|
7
|
+
const U = {
|
|
8
8
|
ref: "slotWrapper",
|
|
9
9
|
class: "hidden"
|
|
10
|
-
},
|
|
10
|
+
}, _ = /* @__PURE__ */ D({
|
|
11
11
|
__name: "LineChart",
|
|
12
12
|
props: {
|
|
13
13
|
data: {},
|
|
@@ -21,13 +21,14 @@ const S = {
|
|
|
21
21
|
left: 5
|
|
22
22
|
}) },
|
|
23
23
|
categories: {},
|
|
24
|
+
markerConfig: {},
|
|
24
25
|
xFormatter: {},
|
|
25
26
|
yFormatter: {},
|
|
26
27
|
curveType: {},
|
|
27
|
-
xNumTicks: { default: (
|
|
28
|
+
xNumTicks: { default: (o) => o.data.length > 24 ? 24 / 4 : o.data.length - 1 },
|
|
28
29
|
xExplicitTicks: {},
|
|
29
30
|
minMaxTicksOnly: { type: Boolean },
|
|
30
|
-
yNumTicks: { default: (
|
|
31
|
+
yNumTicks: { default: (o) => o.data.length > 24 ? 24 / 4 : o.data.length - 1 },
|
|
31
32
|
hideTooltip: { type: Boolean },
|
|
32
33
|
hideLegend: { type: Boolean },
|
|
33
34
|
legendPosition: {},
|
|
@@ -40,40 +41,44 @@ const S = {
|
|
|
40
41
|
hideXAxis: { type: Boolean },
|
|
41
42
|
hideYAxis: { type: Boolean }
|
|
42
43
|
},
|
|
43
|
-
setup(
|
|
44
|
-
const
|
|
45
|
-
(e, c) => `var(--vis-color${c})`
|
|
46
|
-
), L = (e) => Object.values(n.categories)[e].color ?? v[e];
|
|
44
|
+
setup(o) {
|
|
45
|
+
const t = o, T = f(() => t.markerConfig ? X(t.markerConfig) : ""), L = N(), d = O("slotWrapper"), a = P();
|
|
47
46
|
function b(e) {
|
|
48
|
-
return typeof window > "u" ? "" :
|
|
47
|
+
return typeof window > "u" ? "" : d.value ? d.value.innerHTML : "";
|
|
49
48
|
}
|
|
50
49
|
function B(e) {
|
|
51
|
-
return
|
|
50
|
+
return a.value = e, b();
|
|
52
51
|
}
|
|
53
|
-
const
|
|
54
|
-
() =>
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
const u = f(
|
|
53
|
+
() => t.legendPosition === H.Top
|
|
54
|
+
), C = Object.values(t.categories).map(
|
|
55
|
+
(e, c) => `var(--vis-color${c})`
|
|
56
|
+
), V = (e) => Object.values(t.categories)[e].color ?? C[e];
|
|
57
|
+
return (e, c) => (n(), m("div", {
|
|
58
|
+
class: k(["flex flex-col space-y-4", {
|
|
59
|
+
"flex-col-reverse": u.value,
|
|
60
|
+
markers: !!t.markerConfig
|
|
61
|
+
}])
|
|
58
62
|
}, [
|
|
59
|
-
r(i(
|
|
63
|
+
r(i(z), {
|
|
60
64
|
data: e.data,
|
|
61
65
|
padding: e.padding,
|
|
62
|
-
height: e.height
|
|
66
|
+
height: e.height,
|
|
67
|
+
svgDefs: T.value
|
|
63
68
|
}, {
|
|
64
|
-
default:
|
|
65
|
-
r(i(
|
|
66
|
-
"horizontal-placement": i(
|
|
67
|
-
"vertical-placement": i(
|
|
69
|
+
default: A(() => [
|
|
70
|
+
r(i(R), {
|
|
71
|
+
"horizontal-placement": i(v).Right,
|
|
72
|
+
"vertical-placement": i(v).Top
|
|
68
73
|
}, null, 8, ["horizontal-placement", "vertical-placement"]),
|
|
69
|
-
(
|
|
74
|
+
(n(!0), m(M, null, E(Object.keys(t.categories), (x, p) => (n(), s(i(W), {
|
|
70
75
|
key: p,
|
|
71
|
-
x: (y,
|
|
72
|
-
y: (y) => y[
|
|
73
|
-
color:
|
|
74
|
-
"curve-type": e.curveType ?? i(
|
|
76
|
+
x: (y, F) => F,
|
|
77
|
+
y: (y) => y[x],
|
|
78
|
+
color: V(p),
|
|
79
|
+
"curve-type": e.curveType ?? i(G).MonotoneX
|
|
75
80
|
}, null, 8, ["x", "y", "color", "curve-type"]))), 128)),
|
|
76
|
-
e.hideXAxis ?
|
|
81
|
+
e.hideXAxis ? l("", !0) : (n(), s(i(h), {
|
|
77
82
|
key: 0,
|
|
78
83
|
type: "x",
|
|
79
84
|
"tick-format": e.xFormatter,
|
|
@@ -84,9 +89,9 @@ const S = {
|
|
|
84
89
|
"tick-line": e.xTickLine,
|
|
85
90
|
"num-ticks": e.xNumTicks,
|
|
86
91
|
"tick-values": e.xExplicitTicks,
|
|
87
|
-
|
|
88
|
-
}, null, 8, ["tick-format", "label", "domain-line", "grid-line", "tick-line", "num-ticks", "tick-values", "
|
|
89
|
-
e.hideYAxis ?
|
|
92
|
+
"min-max-ticks-only": e.minMaxTicksOnly
|
|
93
|
+
}, null, 8, ["tick-format", "label", "domain-line", "grid-line", "tick-line", "num-ticks", "tick-values", "min-max-ticks-only"])),
|
|
94
|
+
e.hideYAxis ? l("", !0) : (n(), s(i(h), {
|
|
90
95
|
key: 1,
|
|
91
96
|
type: "y",
|
|
92
97
|
"tick-format": e.yFormatter,
|
|
@@ -96,38 +101,38 @@ const S = {
|
|
|
96
101
|
"grid-line": e.yGridLine,
|
|
97
102
|
"tick-line": e.yTickLine
|
|
98
103
|
}, null, 8, ["tick-format", "label", "num-ticks", "domain-line", "grid-line", "tick-line"])),
|
|
99
|
-
e.hideTooltip ?
|
|
104
|
+
e.hideTooltip ? l("", !0) : (n(), s(i(Y), {
|
|
100
105
|
key: 2,
|
|
101
106
|
color: "#666",
|
|
102
107
|
template: B
|
|
103
108
|
}))
|
|
104
109
|
]),
|
|
105
110
|
_: 1
|
|
106
|
-
}, 8, ["data", "padding", "height"]),
|
|
107
|
-
e.hideLegend ?
|
|
111
|
+
}, 8, ["data", "padding", "height", "svgDefs"]),
|
|
112
|
+
e.hideLegend ? l("", !0) : (n(), m("div", {
|
|
108
113
|
key: 0,
|
|
109
|
-
class: k(["flex items center justify-end", { "pb-4":
|
|
114
|
+
class: k(["flex items center justify-end", { "pb-4": u.value }])
|
|
110
115
|
}, [
|
|
111
|
-
r(i(
|
|
116
|
+
r(i(S), {
|
|
112
117
|
items: Object.values(e.categories)
|
|
113
118
|
}, null, 8, ["items"])
|
|
114
119
|
], 2)),
|
|
115
|
-
|
|
116
|
-
i(
|
|
120
|
+
j("div", U, [
|
|
121
|
+
i(L).tooltip ? g(e.$slots, "tooltip", {
|
|
117
122
|
key: 0,
|
|
118
|
-
values:
|
|
119
|
-
}) :
|
|
120
|
-
r(
|
|
121
|
-
data:
|
|
123
|
+
values: a.value
|
|
124
|
+
}) : a.value ? g(e.$slots, "fallback", { key: 1 }, () => [
|
|
125
|
+
r(w, {
|
|
126
|
+
data: a.value,
|
|
122
127
|
categories: e.categories,
|
|
123
|
-
toolTipTitle: i(
|
|
124
|
-
yFormatter:
|
|
128
|
+
toolTipTitle: i($)(a.value) ?? "",
|
|
129
|
+
yFormatter: t.yFormatter
|
|
125
130
|
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
126
|
-
]) :
|
|
131
|
+
]) : l("", !0)
|
|
127
132
|
], 512)
|
|
128
133
|
], 2));
|
|
129
134
|
}
|
|
130
135
|
});
|
|
131
136
|
export {
|
|
132
|
-
|
|
137
|
+
_ as default
|
|
133
138
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { axisFormatter, BulletLegendItemInterface, CurveType, LegendPosition } from '../../types';
|
|
1
|
+
import { axisFormatter, BulletLegendItemInterface, CurveType, LegendPosition, MarkerConfig } from '../../types';
|
|
2
2
|
export interface LineChartProps<T> {
|
|
3
3
|
/**
|
|
4
4
|
* The data to be displayed in the line chart.
|
|
@@ -33,6 +33,10 @@ export interface LineChartProps<T> {
|
|
|
33
33
|
* This defines the visual representation and labels for each category in the chart's legend.
|
|
34
34
|
*/
|
|
35
35
|
categories: Record<string, BulletLegendItemInterface>;
|
|
36
|
+
/**
|
|
37
|
+
* A record mapping marker keys to show custom patterns.
|
|
38
|
+
*/
|
|
39
|
+
markerConfig?: Record<string, MarkerConfig>;
|
|
36
40
|
/**
|
|
37
41
|
* @param {number|Date} tick - The value of the tick. This can be a number or a Date object depending on the scale of the x-axis.
|
|
38
42
|
* @param {number} i - The index of the tick in the `ticks` array.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.markers[data-v-b9ab9df3] *[stroke="#156F36"]{marker:url(#circle-marker-desktop)}.markers[data-v-b9ab9df3] *[stroke="#4ade80"]{marker:url(#circle-marker-mobile)}
|
package/dist/types.d.ts
CHANGED
|
@@ -41,3 +41,9 @@ declare enum Orientation {
|
|
|
41
41
|
}
|
|
42
42
|
export { LegendPosition, CurveType, Orientation, type AreaChartProps, type BarChartProps, type LineChartProps, type DonutChartProps, type BulletLegendItemInterface, };
|
|
43
43
|
export type axisFormatter<T> = ((tick: number, i?: number, ticks?: number[]) => string) | ((tick: Date, i?: number, ticks?: Date[]) => string);
|
|
44
|
+
export type MarkerConfig = {
|
|
45
|
+
type: "circle" | "square" | "triangle" | "diamond";
|
|
46
|
+
size?: number;
|
|
47
|
+
strokeWidth?: number;
|
|
48
|
+
color?: string;
|
|
49
|
+
};
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { MarkerConfig } from './types';
|
|
1
2
|
export declare function getDistributedIndices(length: number, numTicks: number): number[];
|
|
2
3
|
export declare function getFirstPropertyValue(obj: unknown): undefined;
|
|
4
|
+
export declare const markerShape: (type: string, size: number, strokeWidth: number, color: string) => string;
|
|
5
|
+
export declare function createMarkers(markerConfig: Record<string, MarkerConfig>): string;
|
package/dist/utils.js
CHANGED
|
@@ -1,9 +1,34 @@
|
|
|
1
|
-
function
|
|
2
|
-
if (
|
|
3
|
-
const
|
|
4
|
-
return
|
|
1
|
+
function u($) {
|
|
2
|
+
if ($ && Object.keys($).length > 0) {
|
|
3
|
+
const n = Object.keys($)[0];
|
|
4
|
+
return $[n];
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
+
const l = ($, n, r, c) => {
|
|
8
|
+
switch ($) {
|
|
9
|
+
case "circle":
|
|
10
|
+
return `<circle cx="${n / 2}" cy="${n / 2}" r="${(n - r) / 2}" stroke-width="${r}" stroke="${c}" fill="none" />`;
|
|
11
|
+
case "square":
|
|
12
|
+
return `<rect x="${r / 2}" y="${r / 2}" width="${n - r}" height="${n - r}" stroke-width="${r}" stroke="${c}" fill="none" />`;
|
|
13
|
+
case "triangle":
|
|
14
|
+
return `<polygon points="${n / 2},${r / 2} ${n - r / 2},${n - r / 2} ${r / 2},${n - r / 2}" stroke-width="${r}" stroke="${c}" fill="none" />`;
|
|
15
|
+
case "diamond":
|
|
16
|
+
return `<polygon points="${n / 2},${r / 2} ${n - r / 2},${n / 2} ${n / 2},${n - r / 2} ${r / 2},${n / 2}" stroke-width="${r}" stroke="${c}" fill="none" />`;
|
|
17
|
+
default:
|
|
18
|
+
return "";
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
function o($) {
|
|
22
|
+
return Object.entries($).map(([n, r]) => {
|
|
23
|
+
const c = r.type || "circle", e = r.size || 10, t = r.strokeWidth || 2, a = r.color || "#000";
|
|
24
|
+
return `<marker id="circle-marker-${n}" viewBox="0 0 ${e} ${e}" refX="${e / 2}" refY="${e / 2}" markerWidth="${e / 2}" markerHeight="${e / 2}">
|
|
25
|
+
${l(c, e, t, a)}
|
|
26
|
+
</marker>`;
|
|
27
|
+
}).join(`
|
|
28
|
+
`);
|
|
29
|
+
}
|
|
7
30
|
export {
|
|
8
|
-
|
|
31
|
+
o as createMarkers,
|
|
32
|
+
u as getFirstPropertyValue,
|
|
33
|
+
l as markerShape
|
|
9
34
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-chrts",
|
|
3
|
-
"version": "0.2.0-test.
|
|
3
|
+
"version": "0.2.0-test.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -23,15 +23,12 @@
|
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"vue": "^3.5.13"
|
|
25
25
|
},
|
|
26
|
-
"dependencies": {
|
|
27
|
-
"@unovis/ts": "^1.5.2",
|
|
28
|
-
"@unovis/vue": "^1.5.2",
|
|
29
|
-
"to-px": "^1.1.0"
|
|
30
|
-
},
|
|
31
26
|
"devDependencies": {
|
|
32
27
|
"@tailwindcss/vite": "^4.0.15",
|
|
33
28
|
"@tanstack/vue-table": "^8.21.2",
|
|
34
29
|
"@types/node": "^22.13.11",
|
|
30
|
+
"@unovis/ts": "^1.5.2",
|
|
31
|
+
"@unovis/vue": "^1.5.2",
|
|
35
32
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
36
33
|
"@vue/tsconfig": "^0.7.0",
|
|
37
34
|
"@vueuse/core": "^13.0.0",
|