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