vue-chrts 0.1.0-beta.3 → 0.1.0-beta.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 +59 -59
- package/dist/components/AreaChart/types.d.ts +11 -3
- package/dist/components/BarChart/BarChart.js +47 -49
- package/dist/components/BarChart/types.d.ts +11 -3
- package/dist/components/LineChart/LineChart.js +49 -51
- package/dist/components/LineChart/types.d.ts +15 -7
- package/package.json +1 -1
- package/dist/utils.js +0 -18
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Position as
|
|
3
|
-
import { VisXYContainer as
|
|
4
|
-
import
|
|
5
|
-
import { LegendPosition as
|
|
6
|
-
|
|
7
|
-
const Q = /* @__PURE__ */ D({
|
|
1
|
+
import { defineComponent as V, computed as f, createApp as C, createElementBlock as c, openBlock as a, normalizeClass as g, createVNode as l, createCommentVNode as d, unref as t, withCtx as G, createBlock as k, Fragment as h, renderList as N, mergeProps as $ } from "vue";
|
|
2
|
+
import { Position as v, CurveType as T } from "@unovis/ts";
|
|
3
|
+
import { VisXYContainer as P, VisTooltip as j, VisArea as D, VisLine as F, VisAxis as L, VisCrosshair as M, VisBulletLegend as O } from "@unovis/vue";
|
|
4
|
+
import A from "../Tooltip.js";
|
|
5
|
+
import { LegendPosition as E } from "../../types.js";
|
|
6
|
+
const Y = /* @__PURE__ */ V({
|
|
8
7
|
__name: "AreaChart",
|
|
9
8
|
props: {
|
|
10
9
|
data: {},
|
|
@@ -15,8 +14,10 @@ const Q = /* @__PURE__ */ D({
|
|
|
15
14
|
xFormatter: {},
|
|
16
15
|
yFormatter: {},
|
|
17
16
|
curveType: {},
|
|
18
|
-
xNumTicks: { default: (
|
|
19
|
-
|
|
17
|
+
xNumTicks: { default: (i) => i.data.length > 24 ? 24 / 4 : i.data.length - 1 },
|
|
18
|
+
xExplicitTicks: {},
|
|
19
|
+
minMaxTicksOnly: {},
|
|
20
|
+
yNumTicks: { default: (i) => i.data.length > 24 ? 24 / 4 : i.data.length - 1 },
|
|
20
21
|
hideLegend: { type: Boolean },
|
|
21
22
|
hideTooltip: { type: Boolean },
|
|
22
23
|
xGridLine: { type: Boolean },
|
|
@@ -25,82 +26,81 @@ const Q = /* @__PURE__ */ D({
|
|
|
25
26
|
yDomainLine: { type: Boolean },
|
|
26
27
|
legendPosition: {}
|
|
27
28
|
},
|
|
28
|
-
setup(
|
|
29
|
-
const
|
|
29
|
+
setup(i) {
|
|
30
|
+
const s = i, m = Object.values(s.categories).map((e) => e.color), b = f(() => (e) => {
|
|
30
31
|
if (typeof window > "u" || typeof document > "u")
|
|
31
32
|
return "";
|
|
32
33
|
try {
|
|
33
|
-
const o =
|
|
34
|
+
const o = C(A, {
|
|
34
35
|
data: e,
|
|
35
|
-
categories:
|
|
36
|
-
}),
|
|
37
|
-
o.mount(
|
|
38
|
-
const r =
|
|
36
|
+
categories: s.categories
|
|
37
|
+
}), n = document.createElement("div");
|
|
38
|
+
o.mount(n);
|
|
39
|
+
const r = n.innerHTML;
|
|
39
40
|
return o.unmount(), r;
|
|
40
41
|
} catch {
|
|
41
42
|
return "";
|
|
42
43
|
}
|
|
43
44
|
});
|
|
44
|
-
function
|
|
45
|
+
function x(e) {
|
|
45
46
|
var o;
|
|
46
47
|
return {
|
|
47
|
-
y: (
|
|
48
|
-
color: ((o =
|
|
48
|
+
y: (n) => Number(n[e]),
|
|
49
|
+
color: ((o = s.categories[e]) == null ? void 0 : o.color) ?? "#3b82f6"
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
|
-
const
|
|
52
|
+
const B = m.map(
|
|
52
53
|
(e, o) => `
|
|
53
54
|
<linearGradient id="gradient${o}-${e}" gradientTransform="rotate(90)">
|
|
54
55
|
<stop offset="0%" stop-color="${e}" stop-opacity="1" />
|
|
55
56
|
<stop offset="100%" stop-color="${e}" stop-opacity="0" />
|
|
56
57
|
</linearGradient>
|
|
57
58
|
`
|
|
58
|
-
).join(""),
|
|
59
|
-
() =>
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
64
|
-
return (e, o) => (l(), d("div", {
|
|
65
|
-
class: v(["flex flex-col space-y-4", { "flex-col-reverse": h.value }])
|
|
59
|
+
).join(""), y = f(
|
|
60
|
+
() => s.legendPosition === E.Top
|
|
61
|
+
);
|
|
62
|
+
return (e, o) => (a(), c("div", {
|
|
63
|
+
class: g(["flex flex-col space-y-4", { "flex-col-reverse": y.value }])
|
|
66
64
|
}, [
|
|
67
|
-
|
|
68
|
-
data:
|
|
65
|
+
l(t(P), {
|
|
66
|
+
data: e.data,
|
|
69
67
|
height: e.height,
|
|
70
|
-
"svg-defs": t(
|
|
68
|
+
"svg-defs": t(B)
|
|
71
69
|
}, {
|
|
72
|
-
default:
|
|
73
|
-
e.hideTooltip ?
|
|
70
|
+
default: G(() => [
|
|
71
|
+
e.hideTooltip ? d("", !0) : (a(), k(t(j), {
|
|
74
72
|
key: 0,
|
|
75
|
-
"horizontal-placement": t(
|
|
76
|
-
"vertical-placement": t(
|
|
73
|
+
"horizontal-placement": t(v).Right,
|
|
74
|
+
"vertical-placement": t(v).Top
|
|
77
75
|
}, null, 8, ["horizontal-placement", "vertical-placement"])),
|
|
78
|
-
(
|
|
79
|
-
|
|
80
|
-
x: (
|
|
76
|
+
(a(!0), c(h, null, N(Object.keys(s.categories), (n, r) => (a(), c(h, { key: r }, [
|
|
77
|
+
l(t(D), $({
|
|
78
|
+
x: (p, u) => u,
|
|
81
79
|
ref_for: !0
|
|
82
|
-
},
|
|
83
|
-
color: `url(#gradient${r}-${t(
|
|
80
|
+
}, x(n), {
|
|
81
|
+
color: `url(#gradient${r}-${t(m)[r]})`,
|
|
84
82
|
opacity: 0.5,
|
|
85
|
-
"curve-type": e.curveType ?? t(
|
|
83
|
+
"curve-type": e.curveType ?? t(T).MonotoneX
|
|
86
84
|
}), null, 16, ["x", "color", "curve-type"]),
|
|
87
|
-
|
|
88
|
-
x: (
|
|
89
|
-
y: (
|
|
90
|
-
color: t(
|
|
91
|
-
"curve-type": e.curveType ?? t(
|
|
85
|
+
l(t(F), {
|
|
86
|
+
x: (p, u) => u,
|
|
87
|
+
y: (p) => p[n],
|
|
88
|
+
color: t(m)[r],
|
|
89
|
+
"curve-type": e.curveType ?? t(T).MonotoneX
|
|
92
90
|
}, null, 8, ["x", "y", "color", "curve-type"])
|
|
93
91
|
], 64))), 128)),
|
|
94
|
-
|
|
92
|
+
l(t(L), {
|
|
95
93
|
type: "x",
|
|
96
|
-
"
|
|
97
|
-
"tick-format": (i, r) => e.xFormatter(p.value[i], r),
|
|
94
|
+
"tick-format": e.xFormatter,
|
|
98
95
|
label: e.xLabel,
|
|
99
|
-
"
|
|
96
|
+
"label-margin": 8,
|
|
100
97
|
"domain-line": e.xDomainLine,
|
|
101
|
-
"
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
"grid-line": e.xGridLine,
|
|
99
|
+
"num-ticks": e.xNumTicks,
|
|
100
|
+
"tick-values": e.xExplicitTicks,
|
|
101
|
+
"min-max-ticks-only": e.minMaxTicksOnly
|
|
102
|
+
}, null, 8, ["tick-format", "label", "domain-line", "grid-line", "num-ticks", "tick-values", "min-max-ticks-only"]),
|
|
103
|
+
l(t(L), {
|
|
104
104
|
type: "y",
|
|
105
105
|
"num-ticks": e.yNumTicks,
|
|
106
106
|
"tick-format": e.yFormatter,
|
|
@@ -109,19 +109,19 @@ const Q = /* @__PURE__ */ D({
|
|
|
109
109
|
"domain-line": e.yDomainLine,
|
|
110
110
|
"tick-line": !!e.yGridLine
|
|
111
111
|
}, null, 8, ["num-ticks", "tick-format", "label", "grid-line", "domain-line", "tick-line"]),
|
|
112
|
-
e.hideTooltip ?
|
|
112
|
+
e.hideTooltip ? d("", !0) : (a(), k(t(M), {
|
|
113
113
|
key: 1,
|
|
114
114
|
color: "#666",
|
|
115
|
-
template:
|
|
115
|
+
template: b.value
|
|
116
116
|
}, null, 8, ["template"]))
|
|
117
117
|
]),
|
|
118
118
|
_: 1
|
|
119
119
|
}, 8, ["data", "height", "svg-defs"]),
|
|
120
|
-
e.hideLegend ?
|
|
120
|
+
e.hideLegend ? d("", !0) : (a(), c("div", {
|
|
121
121
|
key: 0,
|
|
122
|
-
class:
|
|
122
|
+
class: g(["flex items center justify-end", { "pb-4": y.value }])
|
|
123
123
|
}, [
|
|
124
|
-
|
|
124
|
+
l(t(O), {
|
|
125
125
|
items: Object.values(e.categories)
|
|
126
126
|
}, null, 8, ["items"])
|
|
127
127
|
], 2))
|
|
@@ -129,5 +129,5 @@ const Q = /* @__PURE__ */ D({
|
|
|
129
129
|
}
|
|
130
130
|
});
|
|
131
131
|
export {
|
|
132
|
-
|
|
132
|
+
Y as default
|
|
133
133
|
};
|
|
@@ -26,14 +26,14 @@ export interface AreaChartProps<T> {
|
|
|
26
26
|
categories: Record<string, BulletLegendItemInterface>;
|
|
27
27
|
/**
|
|
28
28
|
* A function that formats the x-axis tick labels.
|
|
29
|
-
* @param
|
|
29
|
+
* @param i The x-axis key of the item to be formatted.
|
|
30
30
|
* @param idx The index of the data point.
|
|
31
31
|
* @returns The formatted x-axis label.
|
|
32
32
|
*/
|
|
33
|
-
xFormatter: (
|
|
33
|
+
xFormatter: (i: number, idx: number) => string | number;
|
|
34
34
|
/**
|
|
35
35
|
* An optional function that formats the y-axis tick labels.
|
|
36
|
-
* @param i The
|
|
36
|
+
* @param i The y-axis key of the item to be formatted.
|
|
37
37
|
* @param idx The index of the data point (optional).
|
|
38
38
|
* @returns The formatted y-axis label or value.
|
|
39
39
|
*/
|
|
@@ -47,6 +47,14 @@ export interface AreaChartProps<T> {
|
|
|
47
47
|
* The desired number of ticks on the x-axis.
|
|
48
48
|
*/
|
|
49
49
|
xNumTicks?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Force specific ticks on the x-axis.
|
|
52
|
+
*/
|
|
53
|
+
xExplicitTicks?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Force only first and last ticks on the x-axis.
|
|
56
|
+
*/
|
|
57
|
+
minMaxTicksOnly?: number;
|
|
50
58
|
/**
|
|
51
59
|
* The desired number of ticks on the y-axis.
|
|
52
60
|
*/
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Orientation as s, StackedBar as
|
|
3
|
-
import { VisXYContainer as
|
|
4
|
-
import
|
|
5
|
-
import { LegendPosition as
|
|
6
|
-
|
|
7
|
-
const M = /* @__PURE__ */ v({
|
|
1
|
+
import { defineComponent as b, computed as u, createApp as h, createElementBlock as y, openBlock as d, normalizeClass as k, createVNode as t, createCommentVNode as B, unref as i, withCtx as T, createBlock as f } from "vue";
|
|
2
|
+
import { Orientation as s, StackedBar as v, GroupedBar as V } from "@unovis/ts";
|
|
3
|
+
import { VisXYContainer as P, VisTooltip as x, VisGroupedBar as C, VisStackedBar as G, VisAxis as L, VisBulletLegend as N } from "@unovis/vue";
|
|
4
|
+
import A from "../Tooltip.js";
|
|
5
|
+
import { LegendPosition as O } from "../../types.js";
|
|
6
|
+
const M = /* @__PURE__ */ b({
|
|
8
7
|
__name: "BarChart",
|
|
9
8
|
props: {
|
|
10
9
|
data: {},
|
|
@@ -15,8 +14,10 @@ const M = /* @__PURE__ */ v({
|
|
|
15
14
|
categories: {},
|
|
16
15
|
xFormatter: {},
|
|
17
16
|
yFormatter: {},
|
|
18
|
-
yNumTicks: { default: (
|
|
19
|
-
|
|
17
|
+
yNumTicks: { default: (a) => a.data.length > 24 ? 24 / 4 : a.data.length - 1 },
|
|
18
|
+
minMaxTicksOnly: {},
|
|
19
|
+
xNumTicks: { default: (a) => a.data.length > 24 ? 24 / 4 : a.data.length - 1 },
|
|
20
|
+
xExplicitTicks: {},
|
|
20
21
|
yAxis: {},
|
|
21
22
|
groupPadding: {},
|
|
22
23
|
barPadding: {},
|
|
@@ -31,71 +32,68 @@ const M = /* @__PURE__ */ v({
|
|
|
31
32
|
xGridLine: { type: Boolean },
|
|
32
33
|
yGridLine: { type: Boolean, default: !0 }
|
|
33
34
|
},
|
|
34
|
-
setup(
|
|
35
|
-
const
|
|
36
|
-
() =>
|
|
37
|
-
),
|
|
38
|
-
() => w(a.data.length, a.xNumTicks)
|
|
39
|
-
), u = d(() => {
|
|
40
|
-
var e;
|
|
41
|
-
return !((e = a.data) != null && e.length) || !m || m.value.length === 0 ? [] : m.value.map((n) => a.data[n]);
|
|
42
|
-
}), f = d(() => (e) => {
|
|
35
|
+
setup(a) {
|
|
36
|
+
const r = a, m = u(() => r.yAxis.map((e) => (n) => n[e])), c = (e, n) => Object.values(r.categories)[n].color, p = u(
|
|
37
|
+
() => r.legendPosition === O.Top
|
|
38
|
+
), g = u(() => (e) => {
|
|
43
39
|
if (typeof window > "u" || typeof document > "u")
|
|
44
40
|
return "";
|
|
45
41
|
try {
|
|
46
|
-
const n =
|
|
42
|
+
const n = h(A, {
|
|
47
43
|
data: e,
|
|
48
|
-
categories:
|
|
49
|
-
}),
|
|
50
|
-
n.mount(
|
|
51
|
-
const o =
|
|
44
|
+
categories: r.categories
|
|
45
|
+
}), l = document.createElement("div");
|
|
46
|
+
n.mount(l);
|
|
47
|
+
const o = l.innerHTML;
|
|
52
48
|
return n.unmount(), o;
|
|
53
49
|
} catch {
|
|
54
50
|
return "";
|
|
55
51
|
}
|
|
56
52
|
});
|
|
57
|
-
return (e, n) => (
|
|
58
|
-
class:
|
|
53
|
+
return (e, n) => (d(), y("div", {
|
|
54
|
+
class: k(["flex flex-col space-y-4", { "flex-col-reverse": p.value }])
|
|
59
55
|
}, [
|
|
60
|
-
|
|
61
|
-
default:
|
|
62
|
-
|
|
56
|
+
t(i(P), { height: e.height }, {
|
|
57
|
+
default: T(() => [
|
|
58
|
+
t(i(x), {
|
|
63
59
|
triggers: {
|
|
64
|
-
[i(
|
|
65
|
-
[i(
|
|
60
|
+
[i(V).selectors.bar]: g.value,
|
|
61
|
+
[i(v).selectors.bar]: g.value
|
|
66
62
|
}
|
|
67
63
|
}, null, 8, ["triggers"]),
|
|
68
|
-
e.stacked ? (
|
|
64
|
+
e.stacked ? (d(), f(i(G), {
|
|
69
65
|
key: 1,
|
|
70
|
-
data:
|
|
71
|
-
x: (
|
|
72
|
-
y:
|
|
73
|
-
color:
|
|
66
|
+
data: e.data,
|
|
67
|
+
x: (l, o) => o,
|
|
68
|
+
y: m.value,
|
|
69
|
+
color: c,
|
|
74
70
|
"rounded-corners": e.radius ?? 0,
|
|
75
71
|
"group-padding": e.groupPadding ?? 0,
|
|
76
72
|
"bar-padding": e.barPadding ?? 0.2,
|
|
77
73
|
orientation: e.orientation ?? i(s).Vertical
|
|
78
|
-
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (
|
|
74
|
+
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (d(), f(i(C), {
|
|
79
75
|
key: 0,
|
|
80
|
-
data:
|
|
81
|
-
x: (
|
|
82
|
-
y:
|
|
83
|
-
color:
|
|
76
|
+
data: e.data,
|
|
77
|
+
x: (l, o) => o,
|
|
78
|
+
y: m.value,
|
|
79
|
+
color: c,
|
|
84
80
|
"rounded-corners": e.radius ?? 0,
|
|
85
81
|
"group-padding": e.groupPadding ?? 0,
|
|
86
82
|
"bar-padding": e.barPadding ?? 0.2,
|
|
87
83
|
orientation: e.orientation ?? i(s).Vertical
|
|
88
84
|
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])),
|
|
89
|
-
|
|
85
|
+
t(i(L), {
|
|
90
86
|
type: "x",
|
|
91
|
-
"
|
|
92
|
-
"tick-format": a.orientation === i(s).Horizontal ? e.xFormatter : (r, o) => e.xFormatter(u.value[r], o),
|
|
87
|
+
"tick-format": e.xFormatter,
|
|
93
88
|
label: e.xLabel,
|
|
94
89
|
"grid-line": e.xGridLine,
|
|
95
90
|
"domain-line": e.xDomainLine,
|
|
96
|
-
"tick-line": e.xTickLine
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
"tick-line": e.xTickLine,
|
|
92
|
+
"num-ticks": e.xNumTicks,
|
|
93
|
+
"tick-values": e.xExplicitTicks,
|
|
94
|
+
"min-max-ticks-only": e.minMaxTicksOnly
|
|
95
|
+
}, null, 8, ["tick-format", "label", "grid-line", "domain-line", "tick-line", "num-ticks", "tick-values", "min-max-ticks-only"]),
|
|
96
|
+
t(i(L), {
|
|
99
97
|
type: "y",
|
|
100
98
|
label: e.yLabel,
|
|
101
99
|
"grid-line": e.orientation !== i(s).Horizontal && e.yGridLine,
|
|
@@ -107,11 +105,11 @@ const M = /* @__PURE__ */ v({
|
|
|
107
105
|
]),
|
|
108
106
|
_: 1
|
|
109
107
|
}, 8, ["height"]),
|
|
110
|
-
e.hideLegend ?
|
|
108
|
+
e.hideLegend ? B("", !0) : (d(), y("div", {
|
|
111
109
|
key: 0,
|
|
112
|
-
class:
|
|
110
|
+
class: k(["flex items center justify-end", { "pb-4": p.value }])
|
|
113
111
|
}, [
|
|
114
|
-
|
|
112
|
+
t(i(N), {
|
|
115
113
|
items: Object.values(e.categories)
|
|
116
114
|
}, null, 8, ["items"])
|
|
117
115
|
], 2))
|
|
@@ -29,14 +29,14 @@ export interface BarChartProps<T> {
|
|
|
29
29
|
categories: Record<string, BulletLegendItemInterface>;
|
|
30
30
|
/**
|
|
31
31
|
* A function that formats the x-axis tick labels.
|
|
32
|
-
* @param
|
|
32
|
+
* @param i The x-axis key of the item to be formatted.
|
|
33
33
|
* @param idx The index of the data point.
|
|
34
34
|
* @returns The formatted x-axis label.
|
|
35
35
|
*/
|
|
36
|
-
xFormatter: (
|
|
36
|
+
xFormatter: (i: number, idx: number) => string | number;
|
|
37
37
|
/**
|
|
38
38
|
* An optional function that formats the y-axis tick labels.
|
|
39
|
-
* @param i The
|
|
39
|
+
* @param i The y-axis key of the item to be formatted.
|
|
40
40
|
* @param idx The index of the data point (optional).
|
|
41
41
|
* @returns The formatted y-axis label or value.
|
|
42
42
|
*/
|
|
@@ -45,10 +45,18 @@ export interface BarChartProps<T> {
|
|
|
45
45
|
* The desired number of ticks on the y-axis.
|
|
46
46
|
*/
|
|
47
47
|
yNumTicks?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Force only first and last ticks on the x-axis.
|
|
50
|
+
*/
|
|
51
|
+
minMaxTicksOnly?: number;
|
|
48
52
|
/**
|
|
49
53
|
* The desired number of ticks on the x-axis.
|
|
50
54
|
*/
|
|
51
55
|
xNumTicks?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Force specific ticks on the x-axis.
|
|
58
|
+
*/
|
|
59
|
+
xExplicitTicks?: number;
|
|
52
60
|
/**
|
|
53
61
|
* An array of property keys from the data object type 'T' to be used for the y-axis values.
|
|
54
62
|
*/
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Position as
|
|
3
|
-
import { VisXYContainer as
|
|
4
|
-
import
|
|
5
|
-
import { LegendPosition as
|
|
6
|
-
|
|
7
|
-
const Y = /* @__PURE__ */ B({
|
|
1
|
+
import { defineComponent as v, computed as u, createApp as b, createElementBlock as m, openBlock as n, normalizeClass as p, createVNode as o, createCommentVNode as y, unref as i, withCtx as B, createBlock as k, Fragment as x, renderList as C } from "vue";
|
|
2
|
+
import { Position as g, CurveType as V } from "@unovis/ts";
|
|
3
|
+
import { VisXYContainer as N, VisTooltip as F, VisLine as O, VisAxis as f, VisCrosshair as P, VisBulletLegend as j } from "@unovis/vue";
|
|
4
|
+
import D from "../Tooltip.js";
|
|
5
|
+
import { LegendPosition as E } from "../../types.js";
|
|
6
|
+
const X = /* @__PURE__ */ v({
|
|
8
7
|
__name: "LineChart",
|
|
9
8
|
props: {
|
|
10
9
|
data: {},
|
|
@@ -15,9 +14,11 @@ const Y = /* @__PURE__ */ B({
|
|
|
15
14
|
xFormatter: {},
|
|
16
15
|
yFormatter: {},
|
|
17
16
|
curveType: {},
|
|
17
|
+
xNumTicks: { default: (t) => t.data.length > 24 ? 24 / 4 : t.data.length - 1 },
|
|
18
|
+
xExplicitTicks: {},
|
|
19
|
+
minMaxTicksOnly: {},
|
|
20
|
+
yNumTicks: { default: (t) => t.data.length > 24 ? 24 / 4 : t.data.length - 1 },
|
|
18
21
|
hideTooltip: { type: Boolean },
|
|
19
|
-
yNumTicks: { default: (n) => n.data.length > 24 ? 24 / 4 : n.data.length - 1 },
|
|
20
|
-
xNumTicks: { default: (n) => n.data.length > 24 ? 24 / 4 : n.data.length - 1 },
|
|
21
22
|
hideLegend: { type: Boolean },
|
|
22
23
|
legendPosition: {},
|
|
23
24
|
xGridLine: { type: Boolean },
|
|
@@ -27,59 +28,56 @@ const Y = /* @__PURE__ */ B({
|
|
|
27
28
|
xTickLine: { type: Boolean },
|
|
28
29
|
yTickLine: { type: Boolean }
|
|
29
30
|
},
|
|
30
|
-
setup(
|
|
31
|
-
const
|
|
31
|
+
setup(t) {
|
|
32
|
+
const l = t, h = (e) => Object.values(l.categories)[e].color, L = u(() => (e) => {
|
|
32
33
|
if (typeof window > "u" || typeof document > "u")
|
|
33
34
|
return "";
|
|
34
35
|
try {
|
|
35
|
-
const
|
|
36
|
+
const a = b(D, {
|
|
36
37
|
data: e,
|
|
37
|
-
categories:
|
|
38
|
-
}),
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
return
|
|
38
|
+
categories: l.categories
|
|
39
|
+
}), r = document.createElement("div");
|
|
40
|
+
a.mount(r);
|
|
41
|
+
const c = r.innerHTML;
|
|
42
|
+
return a.unmount(), c;
|
|
42
43
|
} catch {
|
|
43
44
|
return "";
|
|
44
45
|
}
|
|
45
|
-
}),
|
|
46
|
-
() =>
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var e;
|
|
51
|
-
return !((e = i.data) != null && e.length) || !s || s.value.length === 0 ? [] : s.value.map((o) => i.data[o]);
|
|
52
|
-
});
|
|
53
|
-
return (e, o) => (r(), u("div", {
|
|
54
|
-
class: g(["flex flex-col space-y-4", { "flex-col-reverse": p.value }])
|
|
46
|
+
}), s = u(
|
|
47
|
+
() => l.legendPosition === E.Top
|
|
48
|
+
);
|
|
49
|
+
return (e, a) => (n(), m("div", {
|
|
50
|
+
class: p(["flex flex-col space-y-4", { "flex-col-reverse": s.value }])
|
|
55
51
|
}, [
|
|
56
|
-
|
|
57
|
-
data:
|
|
52
|
+
o(i(N), {
|
|
53
|
+
data: e.data,
|
|
58
54
|
height: e.height
|
|
59
55
|
}, {
|
|
60
|
-
default:
|
|
61
|
-
|
|
62
|
-
"horizontal-placement":
|
|
63
|
-
"vertical-placement":
|
|
56
|
+
default: B(() => [
|
|
57
|
+
o(i(F), {
|
|
58
|
+
"horizontal-placement": i(g).Right,
|
|
59
|
+
"vertical-placement": i(g).Top
|
|
64
60
|
}, null, 8, ["horizontal-placement", "vertical-placement"]),
|
|
65
|
-
(
|
|
66
|
-
key:
|
|
67
|
-
x: (
|
|
68
|
-
y: (
|
|
69
|
-
color:
|
|
70
|
-
"curve-type": e.curveType ??
|
|
61
|
+
(n(!0), m(x, null, C(Object.keys(l.categories), (r, c) => (n(), k(i(O), {
|
|
62
|
+
key: c,
|
|
63
|
+
x: (d, T) => T,
|
|
64
|
+
y: (d) => d[r],
|
|
65
|
+
color: h(c),
|
|
66
|
+
"curve-type": e.curveType ?? i(V).MonotoneX
|
|
71
67
|
}, null, 8, ["x", "y", "color", "curve-type"]))), 128)),
|
|
72
|
-
|
|
68
|
+
o(i(f), {
|
|
73
69
|
type: "x",
|
|
74
|
-
"
|
|
75
|
-
"tick-format": (a, l) => e.xFormatter(d.value[a], l),
|
|
70
|
+
"tick-format": e.xFormatter,
|
|
76
71
|
label: e.xLabel,
|
|
77
72
|
"label-margin": 8,
|
|
78
73
|
"domain-line": e.xDomainLine,
|
|
79
74
|
"grid-line": e.xGridLine,
|
|
80
|
-
"tick-line": e.xTickLine
|
|
81
|
-
|
|
82
|
-
|
|
75
|
+
"tick-line": e.xTickLine,
|
|
76
|
+
"num-ticks": e.xNumTicks,
|
|
77
|
+
"tick-values": e.xExplicitTicks,
|
|
78
|
+
"min-max-ticks-only": e.minMaxTicksOnly
|
|
79
|
+
}, null, 8, ["tick-format", "label", "domain-line", "grid-line", "tick-line", "num-ticks", "tick-values", "min-max-ticks-only"]),
|
|
80
|
+
o(i(f), {
|
|
83
81
|
type: "y",
|
|
84
82
|
"tick-format": e.yFormatter,
|
|
85
83
|
label: e.yLabel,
|
|
@@ -88,19 +86,19 @@ const Y = /* @__PURE__ */ B({
|
|
|
88
86
|
"grid-line": e.yGridLine,
|
|
89
87
|
"tick-line": e.yTickLine
|
|
90
88
|
}, null, 8, ["tick-format", "label", "num-ticks", "domain-line", "grid-line", "tick-line"]),
|
|
91
|
-
e.hideTooltip ?
|
|
89
|
+
e.hideTooltip ? y("", !0) : (n(), k(i(P), {
|
|
92
90
|
key: 0,
|
|
93
91
|
color: "#666",
|
|
94
|
-
template:
|
|
92
|
+
template: L.value
|
|
95
93
|
}, null, 8, ["template"]))
|
|
96
94
|
]),
|
|
97
95
|
_: 1
|
|
98
96
|
}, 8, ["data", "height"]),
|
|
99
|
-
e.hideLegend ?
|
|
97
|
+
e.hideLegend ? y("", !0) : (n(), m("div", {
|
|
100
98
|
key: 0,
|
|
101
|
-
class:
|
|
99
|
+
class: p(["flex items center justify-end", { "pb-4": s.value }])
|
|
102
100
|
}, [
|
|
103
|
-
|
|
101
|
+
o(i(j), {
|
|
104
102
|
items: Object.values(e.categories)
|
|
105
103
|
}, null, 8, ["items"])
|
|
106
104
|
], 2))
|
|
@@ -108,5 +106,5 @@ const Y = /* @__PURE__ */ B({
|
|
|
108
106
|
}
|
|
109
107
|
});
|
|
110
108
|
export {
|
|
111
|
-
|
|
109
|
+
X as default
|
|
112
110
|
};
|
|
@@ -25,14 +25,14 @@ export interface LineChartProps<T> {
|
|
|
25
25
|
categories: Record<string, BulletLegendItemInterface>;
|
|
26
26
|
/**
|
|
27
27
|
* A function that formats the x-axis tick labels.
|
|
28
|
-
* @param
|
|
28
|
+
* @param i The x-axis key of the item to be formatted.
|
|
29
29
|
* @param idx The index of the data point.
|
|
30
30
|
* @returns The formatted x-axis label.
|
|
31
31
|
*/
|
|
32
|
-
xFormatter: (
|
|
32
|
+
xFormatter: (i: number, idx: number) => string | number;
|
|
33
33
|
/**
|
|
34
34
|
* An optional function that formats the y-axis tick labels.
|
|
35
|
-
* @param i The
|
|
35
|
+
* @param i The y-axis key of the item to be formatted.
|
|
36
36
|
* @param idx The index of the data point.
|
|
37
37
|
* @returns The formatted y-axis label.
|
|
38
38
|
*/
|
|
@@ -43,17 +43,25 @@ export interface LineChartProps<T> {
|
|
|
43
43
|
*/
|
|
44
44
|
curveType?: CurveType;
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* The desired number of ticks on the x-axis.
|
|
47
47
|
*/
|
|
48
|
-
|
|
48
|
+
xNumTicks?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Force specific ticks on the x-axis.
|
|
51
|
+
*/
|
|
52
|
+
xExplicitTicks?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Force only first and last ticks on the x-axis.
|
|
55
|
+
*/
|
|
56
|
+
minMaxTicksOnly?: number;
|
|
49
57
|
/**
|
|
50
58
|
* The desired number of ticks on the y-axis.
|
|
51
59
|
*/
|
|
52
60
|
yNumTicks?: number;
|
|
53
61
|
/**
|
|
54
|
-
*
|
|
62
|
+
* If `true`, hides the chart tooltip.
|
|
55
63
|
*/
|
|
56
|
-
|
|
64
|
+
hideTooltip?: boolean;
|
|
57
65
|
/**
|
|
58
66
|
* If `true`, hides the chart legend.
|
|
59
67
|
*/
|
package/package.json
CHANGED
package/dist/utils.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
function i(t, r) {
|
|
2
|
-
if (r <= 0) return [];
|
|
3
|
-
if (r >= t)
|
|
4
|
-
return Array.from({ length: t }, (o, e) => e);
|
|
5
|
-
if (r === 1)
|
|
6
|
-
return [Math.floor((t - 1) / 2)];
|
|
7
|
-
if (r === 2)
|
|
8
|
-
return [0, t - 1];
|
|
9
|
-
const f = [];
|
|
10
|
-
for (let o = 0; o < r; o++) {
|
|
11
|
-
const e = Math.round(o * (t - 1) / (r - 1));
|
|
12
|
-
f.push(e);
|
|
13
|
-
}
|
|
14
|
-
return f;
|
|
15
|
-
}
|
|
16
|
-
export {
|
|
17
|
-
i as getDistributedIndices
|
|
18
|
-
};
|