vue-chrts 0.2.5-test.1 → 0.2.5-test.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AreaChart/AreaChart.js +103 -77
- package/dist/components/AreaChart/types.d.ts +11 -0
- package/dist/components/BarChart/BarChart.js +91 -91
- package/dist/components/DonutChart/DonutChart.js +81 -75
- package/dist/components/DonutChart/types.d.ts +10 -0
- package/dist/components/LineChart/LineChart.js +27 -132
- package/dist/components/LineChart/LineChart.vue.d.ts +3 -10
- package/dist/components/LineChart/types.d.ts +2 -144
- package/dist/components/Timeline/Timeline.js +120 -0
- package/dist/components/Timeline/Timeline.vue.d.ts +33 -0
- package/dist/components/Timeline/Timeline2.js +4 -0
- package/dist/components/Timeline/types.d.ts +24 -0
- package/dist/components/Tooltip.js +23 -23
- package/dist/index.d.ts +2 -2
- package/dist/index.js +14 -14
- package/dist/types.d.ts +2 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +27 -26
- package/package.json +1 -1
- package/dist/components/AreaStackedChart/AreaStackedChart.js +0 -77
- package/dist/components/AreaStackedChart/AreaStackedChart.vue.d.ts +0 -14
- package/dist/components/AreaStackedChart/AreaStackedChart2.js +0 -4
- package/dist/components/AreaStackedChart/types.d.ts +0 -86
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Donut as
|
|
3
|
-
import { DonutType as
|
|
4
|
-
import { VisSingleContainer as
|
|
5
|
-
|
|
1
|
+
import { defineComponent as x, useSlots as D, useTemplateRef as L, ref as T, computed as p, createElementBlock as g, openBlock as c, normalizeStyle as o, createVNode as i, createCommentVNode as f, renderSlot as s, createElementVNode as r, unref as n, withCtx as B, toDisplayString as P } from "vue";
|
|
2
|
+
import { Donut as W } from "@unovis/ts";
|
|
3
|
+
import { DonutType as R } from "./types.js";
|
|
4
|
+
import { VisSingleContainer as A, VisTooltip as H, VisDonut as N, VisBulletLegend as $ } from "@unovis/vue";
|
|
5
|
+
import { LegendPosition as z } from "../../types.js";
|
|
6
|
+
const E = {
|
|
6
7
|
ref: "slotWrapper",
|
|
7
8
|
style: { display: "none" }
|
|
8
|
-
},
|
|
9
|
-
key: 0,
|
|
10
|
-
style: {
|
|
11
|
-
display: "flex",
|
|
12
|
-
alignItems: "center",
|
|
13
|
-
justifyContent: "center",
|
|
14
|
-
marginTop: "1rem"
|
|
15
|
-
}
|
|
16
|
-
}, U = /* @__PURE__ */ V({
|
|
9
|
+
}, j = { style: { display: "flex", "align-items": "center", padding: "10px 15px" } }, G = /* @__PURE__ */ x({
|
|
17
10
|
__name: "DonutChart",
|
|
18
11
|
props: {
|
|
19
12
|
type: {},
|
|
@@ -22,78 +15,91 @@ const j = {
|
|
|
22
15
|
height: {},
|
|
23
16
|
radius: {},
|
|
24
17
|
hideLegend: { type: Boolean },
|
|
18
|
+
legendPosition: { default: z.BottomCenter },
|
|
19
|
+
legendStyle: {},
|
|
25
20
|
labels: {},
|
|
26
21
|
padAngle: {}
|
|
27
22
|
},
|
|
28
23
|
emits: ["click"],
|
|
29
|
-
setup(
|
|
30
|
-
const
|
|
31
|
-
function
|
|
32
|
-
return l.value = e,
|
|
24
|
+
setup(m, { emit: h }) {
|
|
25
|
+
const v = h, t = m, y = D(), d = L("slotWrapper"), l = T(), C = (e) => e, k = t.type === R.Half;
|
|
26
|
+
function V(e) {
|
|
27
|
+
return l.value = e, b();
|
|
33
28
|
}
|
|
34
|
-
function
|
|
29
|
+
function b(e) {
|
|
35
30
|
return typeof window > "u" ? "" : d.value ? d.value.innerHTML : "";
|
|
36
31
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
const S = p(() => t.legendPosition.includes("top")), w = p(() => t.legendPosition.includes("left") ? "flex-start" : t.legendPosition.includes("right") ? "flex-end" : "center");
|
|
33
|
+
return (e, u) => (c(), g("div", {
|
|
34
|
+
style: o({
|
|
35
|
+
display: "flex",
|
|
36
|
+
flexDirection: S.value ? "column-reverse" : "column",
|
|
37
|
+
gap: "var(--vis-legend-spacing)"
|
|
38
|
+
}),
|
|
39
|
+
onClick: u[0] || (u[0] = (a) => v("click", a, l.value))
|
|
40
|
+
}, [
|
|
41
|
+
i(n(A), {
|
|
42
|
+
data: e.data,
|
|
43
|
+
height: e.height,
|
|
44
|
+
margin: {}
|
|
45
|
+
}, {
|
|
46
|
+
default: B(() => [
|
|
47
|
+
i(n(H), {
|
|
48
|
+
"horizontal-shift": 20,
|
|
49
|
+
"vertical-shift": 20,
|
|
50
|
+
triggers: {
|
|
51
|
+
[n(W).selectors.segment]: V
|
|
52
|
+
}
|
|
53
|
+
}, null, 8, ["triggers"]),
|
|
54
|
+
i(n(N), {
|
|
55
|
+
value: C,
|
|
56
|
+
"corner-radius": e.radius,
|
|
57
|
+
"arc-width": e.arcWidth ?? 20,
|
|
58
|
+
color: t.labels.map((a) => a.color),
|
|
59
|
+
"angle-range": k ? [-1.5707963267948966, 1.5707963267948966] : [],
|
|
60
|
+
"pad-angle": t.padAngle || 0
|
|
61
|
+
}, null, 8, ["corner-radius", "arc-width", "color", "angle-range", "pad-angle"])
|
|
62
|
+
]),
|
|
63
|
+
_: 1
|
|
64
|
+
}, 8, ["data", "height"]),
|
|
65
|
+
t.hideLegend ? f("", !0) : (c(), g("div", {
|
|
66
|
+
key: 0,
|
|
67
|
+
style: o({
|
|
40
68
|
display: "flex",
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
onClick: u[0] || (u[0] = (o) => f("click", o, l.value))
|
|
69
|
+
justifyContent: w.value
|
|
70
|
+
})
|
|
45
71
|
}, [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}, {
|
|
51
|
-
default: D(() => [
|
|
52
|
-
r(n(H), {
|
|
53
|
-
"horizontal-shift": 20,
|
|
54
|
-
"vertical-shift": 20,
|
|
55
|
-
triggers: {
|
|
56
|
-
[n(B).selectors.segment]: C
|
|
57
|
-
}
|
|
58
|
-
}, null, 8, ["triggers"]),
|
|
59
|
-
r(n(N), {
|
|
60
|
-
value: y,
|
|
61
|
-
"corner-radius": t.radius,
|
|
62
|
-
"arc-width": t.arcWidth ?? 20,
|
|
63
|
-
color: i.labels.map((o) => o.color),
|
|
64
|
-
"angle-range": v ? [-1.5707963267948966, 1.5707963267948966] : [],
|
|
65
|
-
"pad-angle": i.padAngle || 0
|
|
66
|
-
}, null, 8, ["corner-radius", "arc-width", "color", "angle-range", "pad-angle"])
|
|
72
|
+
i(n($), {
|
|
73
|
+
style: o([
|
|
74
|
+
t.legendStyle,
|
|
75
|
+
"display: flex; gap: var(--vis-legend-spacing);"
|
|
67
76
|
]),
|
|
68
|
-
|
|
69
|
-
}, 8, ["
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
])
|
|
89
|
-
],
|
|
90
|
-
])
|
|
91
|
-
|
|
92
|
-
r(n($), { items: t.labels }, null, 8, ["items"])
|
|
93
|
-
]))
|
|
94
|
-
], 64));
|
|
77
|
+
items: e.labels
|
|
78
|
+
}, null, 8, ["style", "items"])
|
|
79
|
+
], 4)),
|
|
80
|
+
s(e.$slots, "default"),
|
|
81
|
+
r("div", E, [
|
|
82
|
+
n(y).tooltip ? s(e.$slots, "tooltip", {
|
|
83
|
+
key: 0,
|
|
84
|
+
values: l.value
|
|
85
|
+
}) : l.value ? s(e.$slots, "fallback", { key: 1 }, () => [
|
|
86
|
+
r("div", j, [
|
|
87
|
+
r("div", {
|
|
88
|
+
style: o({
|
|
89
|
+
width: "0.5rem",
|
|
90
|
+
height: "0.5rem",
|
|
91
|
+
borderRadius: "9999px",
|
|
92
|
+
marginRight: "0.5rem",
|
|
93
|
+
backgroundColor: t.labels[l.value.index].color
|
|
94
|
+
})
|
|
95
|
+
}, null, 4),
|
|
96
|
+
r("div", null, P(l.value.data), 1)
|
|
97
|
+
])
|
|
98
|
+
]) : f("", !0)
|
|
99
|
+
], 512)
|
|
100
|
+
], 4));
|
|
95
101
|
}
|
|
96
102
|
});
|
|
97
103
|
export {
|
|
98
|
-
|
|
104
|
+
G as default
|
|
99
105
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LegendPosition } from '../../types';
|
|
1
2
|
export type DonutChartProps = {
|
|
2
3
|
/**
|
|
3
4
|
* The type of donut chart to render.
|
|
@@ -25,6 +26,15 @@ export type DonutChartProps = {
|
|
|
25
26
|
* If `true`, hides the chart legend.
|
|
26
27
|
*/
|
|
27
28
|
hideLegend?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Optional position for the legend, if applicable.
|
|
31
|
+
* See `LegendPosition` for available options.
|
|
32
|
+
*/
|
|
33
|
+
legendPosition?: LegendPosition;
|
|
34
|
+
/**
|
|
35
|
+
* Optional style object for the legend container. Allows custom CSS styling.
|
|
36
|
+
*/
|
|
37
|
+
legendStyle?: string | Record<string, string>;
|
|
28
38
|
/**
|
|
29
39
|
* An array of label objects defining the name and color for each segment.
|
|
30
40
|
*/
|
|
@@ -1,158 +1,53 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { VisXYContainer as H, VisTooltip as U, VisLine as q, VisAxis as x, VisCrosshair as I, VisBulletLegend as J } from "@unovis/vue";
|
|
6
|
-
import { LegendPosition as Q } from "../../types.js";
|
|
7
|
-
const Z = {
|
|
8
|
-
ref: "slotWrapper",
|
|
9
|
-
style: { display: "none" }
|
|
10
|
-
}, le = /* @__PURE__ */ N({
|
|
1
|
+
import { defineComponent as a, createBlock as r, openBlock as p, mergeProps as s, createSlots as l, renderList as y, withCtx as c, renderSlot as m, normalizeProps as d, guardReactiveProps as h } from "vue";
|
|
2
|
+
import B from "../AreaChart/AreaChart.js";
|
|
3
|
+
const g = /* @__PURE__ */ a({
|
|
4
|
+
inheritAttrs: !1,
|
|
11
5
|
__name: "LineChart",
|
|
12
6
|
props: {
|
|
13
7
|
data: {},
|
|
14
8
|
height: {},
|
|
15
9
|
xLabel: {},
|
|
16
10
|
yLabel: {},
|
|
17
|
-
padding: {
|
|
18
|
-
top: 5,
|
|
19
|
-
right: 5,
|
|
20
|
-
bottom: 5,
|
|
21
|
-
left: 5
|
|
22
|
-
}) },
|
|
11
|
+
padding: {},
|
|
23
12
|
categories: {},
|
|
24
13
|
markerConfig: {},
|
|
25
|
-
xFormatter: {},
|
|
26
|
-
yFormatter: {},
|
|
14
|
+
xFormatter: { type: Function },
|
|
15
|
+
yFormatter: { type: Function },
|
|
27
16
|
curveType: {},
|
|
28
|
-
lineWidth: {
|
|
17
|
+
lineWidth: {},
|
|
29
18
|
lineDashArray: {},
|
|
30
|
-
xNumTicks: {
|
|
19
|
+
xNumTicks: {},
|
|
31
20
|
xExplicitTicks: {},
|
|
32
21
|
minMaxTicksOnly: { type: Boolean },
|
|
33
|
-
yNumTicks: {
|
|
22
|
+
yNumTicks: {},
|
|
23
|
+
hideLegend: { type: Boolean },
|
|
34
24
|
hideTooltip: { type: Boolean },
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
legendStyle: { default: void 0 },
|
|
38
|
-
xGridLine: { type: Boolean },
|
|
25
|
+
legendPosition: {},
|
|
26
|
+
legendStyle: {},
|
|
39
27
|
xDomainLine: { type: Boolean },
|
|
40
|
-
yGridLine: { type: Boolean },
|
|
41
28
|
yDomainLine: { type: Boolean },
|
|
42
29
|
xTickLine: { type: Boolean },
|
|
43
30
|
yTickLine: { type: Boolean },
|
|
31
|
+
xGridLine: { type: Boolean },
|
|
32
|
+
yGridLine: { type: Boolean },
|
|
44
33
|
hideXAxis: { type: Boolean },
|
|
45
34
|
hideYAxis: { type: Boolean },
|
|
46
|
-
crosshairConfig: {
|
|
47
|
-
color: "#666"
|
|
48
|
-
}) },
|
|
35
|
+
crosshairConfig: {},
|
|
49
36
|
yDomain: {},
|
|
50
37
|
xDomain: {}
|
|
51
38
|
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
(n, s) => `var(--vis-color${s})`
|
|
63
|
-
), F = (n) => Object.values(t.categories)[n].color ?? V[n];
|
|
64
|
-
return (n, s) => (a(), y("div", {
|
|
65
|
-
style: g({
|
|
66
|
-
display: "flex",
|
|
67
|
-
flexDirection: b.value ? "column-reverse" : "column",
|
|
68
|
-
gap: "var(--vis-legend-spacing)"
|
|
69
|
-
}),
|
|
70
|
-
class: w({ markers: !!t.markerConfig }),
|
|
71
|
-
onClick: s[0] || (s[0] = (l) => L("click", l, o.value))
|
|
72
|
-
}, [
|
|
73
|
-
c(i(H), {
|
|
74
|
-
data: e.data,
|
|
75
|
-
padding: e.padding,
|
|
76
|
-
height: e.height,
|
|
77
|
-
svgDefs: D.value,
|
|
78
|
-
yDomain: e.yDomain,
|
|
79
|
-
xDomain: e.xDomain
|
|
80
|
-
}, {
|
|
81
|
-
default: S(() => [
|
|
82
|
-
c(i(U), {
|
|
83
|
-
"horizontal-placement": i(v).Right,
|
|
84
|
-
"vertical-placement": i(v).Top
|
|
85
|
-
}, null, 8, ["horizontal-placement", "vertical-placement"]),
|
|
86
|
-
(a(!0), y(z, null, E(Object.keys(t.categories), (l, m) => (a(), d(i(q), {
|
|
87
|
-
key: m,
|
|
88
|
-
x: (k, P) => P,
|
|
89
|
-
y: (k) => k[l],
|
|
90
|
-
color: F(m),
|
|
91
|
-
"curve-type": e.curveType ?? i(X).MonotoneX,
|
|
92
|
-
"line-width": e.lineWidth,
|
|
93
|
-
lineDashArray: e.lineDashArray ? e.lineDashArray[m] : void 0
|
|
94
|
-
}, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"]))), 128)),
|
|
95
|
-
e.hideXAxis ? r("", !0) : (a(), d(i(x), {
|
|
96
|
-
key: 0,
|
|
97
|
-
type: "x",
|
|
98
|
-
"tick-format": e.xFormatter,
|
|
99
|
-
label: e.xLabel,
|
|
100
|
-
"label-margin": 8,
|
|
101
|
-
"domain-line": e.xDomainLine,
|
|
102
|
-
"grid-line": e.xGridLine,
|
|
103
|
-
"tick-line": e.xTickLine,
|
|
104
|
-
"num-ticks": e.xNumTicks,
|
|
105
|
-
"tick-values": e.xExplicitTicks,
|
|
106
|
-
"min-max-ticks-only": e.minMaxTicksOnly
|
|
107
|
-
}, null, 8, ["tick-format", "label", "domain-line", "grid-line", "tick-line", "num-ticks", "tick-values", "min-max-ticks-only"])),
|
|
108
|
-
e.hideYAxis ? r("", !0) : (a(), d(i(x), {
|
|
109
|
-
key: 1,
|
|
110
|
-
type: "y",
|
|
111
|
-
"tick-format": e.yFormatter,
|
|
112
|
-
label: e.yLabel,
|
|
113
|
-
"num-ticks": e.yNumTicks,
|
|
114
|
-
"domain-line": e.yDomainLine,
|
|
115
|
-
"grid-line": e.yGridLine,
|
|
116
|
-
"tick-line": e.yTickLine
|
|
117
|
-
}, null, 8, ["tick-format", "label", "num-ticks", "domain-line", "grid-line", "tick-line"])),
|
|
118
|
-
e.hideTooltip ? r("", !0) : (a(), d(i(I), G({ key: 2 }, e.crosshairConfig, { template: B }), null, 16))
|
|
119
|
-
]),
|
|
120
|
-
_: 1
|
|
121
|
-
}, 8, ["data", "padding", "height", "svgDefs", "yDomain", "xDomain"]),
|
|
122
|
-
t.hideLegend ? r("", !0) : (a(), y("div", {
|
|
123
|
-
key: 0,
|
|
124
|
-
style: g({
|
|
125
|
-
display: "flex",
|
|
126
|
-
justifyContent: A.value
|
|
127
|
-
})
|
|
128
|
-
}, [
|
|
129
|
-
c(i(J), {
|
|
130
|
-
style: g([
|
|
131
|
-
t.legendStyle,
|
|
132
|
-
"display: flex; gap: var(--vis-legend-spacing);"
|
|
133
|
-
]),
|
|
134
|
-
items: Object.values(t.categories).map((l) => ({
|
|
135
|
-
...l,
|
|
136
|
-
color: Array.isArray(l.color) ? l.color[0] : l.color
|
|
137
|
-
}))
|
|
138
|
-
}, null, 8, ["style", "items"])
|
|
139
|
-
], 4)),
|
|
140
|
-
M("div", Z, [
|
|
141
|
-
i(C).tooltip ? h(n.$slots, "tooltip", {
|
|
142
|
-
key: 0,
|
|
143
|
-
values: o.value
|
|
144
|
-
}) : o.value ? h(n.$slots, "fallback", { key: 1 }, () => [
|
|
145
|
-
c(Y, {
|
|
146
|
-
data: o.value,
|
|
147
|
-
categories: e.categories,
|
|
148
|
-
toolTipTitle: i(R)(o.value) ?? "",
|
|
149
|
-
yFormatter: t.yFormatter
|
|
150
|
-
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
151
|
-
]) : r("", !0)
|
|
152
|
-
], 512)
|
|
153
|
-
], 6));
|
|
39
|
+
setup(n) {
|
|
40
|
+
const i = n;
|
|
41
|
+
return (e, u) => (p(), r(B, s({ ...e.$attrs, ...i }, { "hide-area": !0 }), l({ _: 2 }, [
|
|
42
|
+
y(e.$slots, (x, o) => ({
|
|
43
|
+
name: o,
|
|
44
|
+
fn: c((t) => [
|
|
45
|
+
m(e.$slots, o, d(h(t)))
|
|
46
|
+
])
|
|
47
|
+
}))
|
|
48
|
+
]), 1040));
|
|
154
49
|
}
|
|
155
50
|
});
|
|
156
51
|
export {
|
|
157
|
-
|
|
52
|
+
g as default
|
|
158
53
|
};
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import { LineChartProps } from './types';
|
|
2
2
|
declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
3
|
-
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
4
|
-
readonly onClick?: ((event: MouseEvent, values?: T | undefined) => any) | undefined;
|
|
5
|
-
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onClick"> & LineChartProps<T> & Partial<{}>> & import('vue').PublicProps;
|
|
3
|
+
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & LineChartProps<T> & Partial<{}>> & import('vue').PublicProps;
|
|
6
4
|
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
7
5
|
attrs: any;
|
|
8
|
-
slots:
|
|
9
|
-
|
|
10
|
-
values: T | undefined;
|
|
11
|
-
}): any;
|
|
12
|
-
fallback?(_: {}): any;
|
|
13
|
-
};
|
|
14
|
-
emit: (e: "click", event: MouseEvent, values?: T) => void;
|
|
6
|
+
slots: Partial<Record<number, (_: any) => any>>;
|
|
7
|
+
emit: {};
|
|
15
8
|
}>) => import('vue').VNode & {
|
|
16
9
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
17
10
|
};
|
|
@@ -1,144 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
/**
|
|
4
|
-
* The data to be displayed in the line chart.
|
|
5
|
-
* Each element of the array represents a data point.
|
|
6
|
-
* The structure of 'T' should be compatible with the chart's rendering logic.
|
|
7
|
-
*/
|
|
8
|
-
data: T[];
|
|
9
|
-
/**
|
|
10
|
-
* The height of the chart in pixels.
|
|
11
|
-
*/
|
|
12
|
-
height: number;
|
|
13
|
-
/**
|
|
14
|
-
* Optional label for the x-axis.
|
|
15
|
-
*/
|
|
16
|
-
xLabel?: string;
|
|
17
|
-
/**
|
|
18
|
-
* Optional label for the y-axis.
|
|
19
|
-
*/
|
|
20
|
-
yLabel?: string;
|
|
21
|
-
/**
|
|
22
|
-
* Optional padding applied to the chart.
|
|
23
|
-
* Allows specifying individual padding values for the top, right, bottom, and left sides.
|
|
24
|
-
*/
|
|
25
|
-
padding?: {
|
|
26
|
-
top: number;
|
|
27
|
-
right: number;
|
|
28
|
-
bottom: number;
|
|
29
|
-
left: number;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* A record mapping category keys to `BulletLegendItemInterface` objects.
|
|
33
|
-
* This defines the visual representation and labels for each category in the chart's legend.
|
|
34
|
-
*/
|
|
35
|
-
categories: Record<string, BulletLegendItemInterface>;
|
|
36
|
-
/**
|
|
37
|
-
* A record mapping marker keys to show custom patterns.
|
|
38
|
-
*/
|
|
39
|
-
markerConfig?: Record<string, MarkerConfig>;
|
|
40
|
-
/**
|
|
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.
|
|
42
|
-
* @param {number} i - The index of the tick in the `ticks` array.
|
|
43
|
-
* @param {(number[]|Date[])} ticks - An array of all tick values for the x-axis.
|
|
44
|
-
* @returns {string} The formatted string representation of the tick.
|
|
45
|
-
*/
|
|
46
|
-
xFormatter?: axisFormatter;
|
|
47
|
-
/**
|
|
48
|
-
* @param {number|Date} tick - The value of the tick. This can be a number or a Date object depending on the scale of the y-axis.
|
|
49
|
-
* @param {number} i - The index of the tick in the `ticks` array.
|
|
50
|
-
* @param {(number[]|Date[])} ticks - An array of all tick values for the y-axis.
|
|
51
|
-
* @returns {string} The formatted string representation of the tick.
|
|
52
|
-
*/
|
|
53
|
-
yFormatter?: axisFormatter;
|
|
54
|
-
/**
|
|
55
|
-
* The type of curve to use for the line chart.
|
|
56
|
-
* See `CurveType` for available options.
|
|
57
|
-
*/
|
|
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[][];
|
|
67
|
-
/**
|
|
68
|
-
* The desired number of ticks on the x-axis.
|
|
69
|
-
*/
|
|
70
|
-
xNumTicks?: number;
|
|
71
|
-
/**
|
|
72
|
-
* Force specific ticks on the x-axis.
|
|
73
|
-
*/
|
|
74
|
-
xExplicitTicks?: (number | string | Date)[];
|
|
75
|
-
/**
|
|
76
|
-
* Force only first and last ticks on the x-axis.
|
|
77
|
-
*/
|
|
78
|
-
minMaxTicksOnly?: boolean;
|
|
79
|
-
/**
|
|
80
|
-
* The desired number of ticks on the y-axis.
|
|
81
|
-
*/
|
|
82
|
-
yNumTicks?: number;
|
|
83
|
-
/**
|
|
84
|
-
* If `true`, hides the chart tooltip.
|
|
85
|
-
*/
|
|
86
|
-
hideTooltip?: boolean;
|
|
87
|
-
/**
|
|
88
|
-
* If `true`, hides the chart legend.
|
|
89
|
-
*/
|
|
90
|
-
hideLegend?: boolean;
|
|
91
|
-
/**
|
|
92
|
-
* Optional position for the legend, if applicable.
|
|
93
|
-
* See `LegendPosition` for available options.
|
|
94
|
-
*/
|
|
95
|
-
legendPosition?: LegendPosition;
|
|
96
|
-
/**
|
|
97
|
-
* Optional style object for the legend container. Allows custom CSS styling.
|
|
98
|
-
*/
|
|
99
|
-
legendStyle?: string | Record<string, string>;
|
|
100
|
-
/**
|
|
101
|
-
* If `true`, displays grid lines along the x-axis.
|
|
102
|
-
*/
|
|
103
|
-
xGridLine?: boolean;
|
|
104
|
-
/**
|
|
105
|
-
* If `true`, displays a domain line (axis line) along the x-axis.
|
|
106
|
-
*/
|
|
107
|
-
xDomainLine?: boolean;
|
|
108
|
-
/**
|
|
109
|
-
* If `true`, displays grid lines along the y-axis.
|
|
110
|
-
*/
|
|
111
|
-
yGridLine?: boolean;
|
|
112
|
-
/**
|
|
113
|
-
* If `true`, displays a domain line (axis line) along the y-axis.
|
|
114
|
-
*/
|
|
115
|
-
yDomainLine?: boolean;
|
|
116
|
-
/**
|
|
117
|
-
* If `true`, displays tick lines on the x-axis.
|
|
118
|
-
*/
|
|
119
|
-
xTickLine?: boolean;
|
|
120
|
-
/**
|
|
121
|
-
* If `true`, displays tick lines on the y-axis.
|
|
122
|
-
*/
|
|
123
|
-
yTickLine?: boolean;
|
|
124
|
-
/**
|
|
125
|
-
* If `true`, hide the x-axis.
|
|
126
|
-
*/
|
|
127
|
-
hideXAxis?: boolean;
|
|
128
|
-
/**
|
|
129
|
-
* If `true`, hide the y-axis.
|
|
130
|
-
*/
|
|
131
|
-
hideYAxis?: boolean;
|
|
132
|
-
/**
|
|
133
|
-
* Crosshair configuration object for customizing the appearance of the crosshair line.
|
|
134
|
-
*/
|
|
135
|
-
crosshairConfig?: CrosshairConfig;
|
|
136
|
-
/**
|
|
137
|
-
* The domain for the y-axis, specified as a tuple of two values.
|
|
138
|
-
*/
|
|
139
|
-
yDomain?: [number | undefined, number | undefined];
|
|
140
|
-
/**
|
|
141
|
-
* The domain for the x-axis, specified as a tuple of two values.
|
|
142
|
-
*/
|
|
143
|
-
xDomain?: [number | undefined, number | undefined];
|
|
144
|
-
}
|
|
1
|
+
import { AreaChartProps } from '../AreaChart/types';
|
|
2
|
+
export type LineChartProps<T> = Omit<AreaChartProps<T>, "hideArea" | "gradientStops">;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { defineComponent as L, useSlots as V, useTemplateRef as C, ref as _, computed as c, createElementBlock as u, openBlock as p, normalizeStyle as d, createVNode as i, createCommentVNode as g, createElementVNode as H, unref as o, withCtx as B, renderSlot as f } from "vue";
|
|
2
|
+
import { Timeline as P } from "@unovis/ts";
|
|
3
|
+
import { dateFormatter as S, getFirstPropertyValue as j } from "../../utils.js";
|
|
4
|
+
import A from "../Tooltip.js";
|
|
5
|
+
import { VisXYContainer as F, VisTimeline as $, VisTooltip as N, VisAxis as O, VisBulletLegend as E } from "@unovis/vue";
|
|
6
|
+
import { LegendPosition as R } from "../../types.js";
|
|
7
|
+
const G = /* @__PURE__ */ L({
|
|
8
|
+
__name: "Timeline",
|
|
9
|
+
props: {
|
|
10
|
+
data: {},
|
|
11
|
+
labelWidth: { default: 220 },
|
|
12
|
+
height: {},
|
|
13
|
+
title: { default: "" },
|
|
14
|
+
categories: {},
|
|
15
|
+
x: {},
|
|
16
|
+
length: {},
|
|
17
|
+
type: {},
|
|
18
|
+
getTooltipText: {},
|
|
19
|
+
showLabels: { type: Boolean, default: !0 },
|
|
20
|
+
hideTooltip: { type: Boolean, default: !1 },
|
|
21
|
+
crosshairConfig: {},
|
|
22
|
+
lineWidth: { default: 12 },
|
|
23
|
+
rowHeight: { default: 24 },
|
|
24
|
+
legendPosition: { default: R.TopRight },
|
|
25
|
+
legendStyle: {},
|
|
26
|
+
hideLegend: { type: Boolean }
|
|
27
|
+
},
|
|
28
|
+
emits: ["click", "scroll", "labelHover"],
|
|
29
|
+
setup(h, { emit: m }) {
|
|
30
|
+
const e = h, n = m, y = V(), s = C("slotWrapper"), r = _(), v = c(() => e.legendPosition.startsWith("top")), T = c(() => e.legendPosition.includes("left") ? "flex-start" : e.legendPosition.includes("right") ? "flex-end" : "center"), b = { [P.selectors.label]: k };
|
|
31
|
+
function k(t) {
|
|
32
|
+
return r.value = t, n("labelHover", t), typeof window > "u" ? "" : s.value ? s.value.innerHTML : "";
|
|
33
|
+
}
|
|
34
|
+
function x(t, a, l) {
|
|
35
|
+
n("click", l, { index: a, item: t });
|
|
36
|
+
}
|
|
37
|
+
function W(t) {
|
|
38
|
+
n("scroll", t.deltaY);
|
|
39
|
+
}
|
|
40
|
+
const w = c(() => {
|
|
41
|
+
const t = Object.values(e.categories).map(
|
|
42
|
+
(a, l) => `var(--vis-color${l})`
|
|
43
|
+
);
|
|
44
|
+
return Object.values(e.categories).map(
|
|
45
|
+
(a, l) => a.color ?? t[l]
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
return (t, a) => (p(), u("div", {
|
|
49
|
+
style: d({
|
|
50
|
+
display: "flex",
|
|
51
|
+
flexDirection: v.value ? "column-reverse" : "column",
|
|
52
|
+
gap: "var(--vis-legend-spacing)"
|
|
53
|
+
})
|
|
54
|
+
}, [
|
|
55
|
+
i(o(F), {
|
|
56
|
+
data: e.data,
|
|
57
|
+
height: e.height,
|
|
58
|
+
onWheel: W
|
|
59
|
+
}, {
|
|
60
|
+
default: B(() => [
|
|
61
|
+
i(o($), {
|
|
62
|
+
x: e.x,
|
|
63
|
+
length: e.length,
|
|
64
|
+
lineWidth: e.lineWidth,
|
|
65
|
+
rowHeight: e.rowHeight,
|
|
66
|
+
type: e.type,
|
|
67
|
+
color: w.value,
|
|
68
|
+
labelWidth: e.labelWidth,
|
|
69
|
+
showLabels: e.showLabels,
|
|
70
|
+
onClick: x
|
|
71
|
+
}, null, 8, ["x", "length", "lineWidth", "rowHeight", "type", "color", "labelWidth", "showLabels"]),
|
|
72
|
+
i(o(N), { triggers: b }),
|
|
73
|
+
i(o(O), {
|
|
74
|
+
type: "x",
|
|
75
|
+
tickFormat: o(S),
|
|
76
|
+
numTicks: 10
|
|
77
|
+
}, null, 8, ["tickFormat"])
|
|
78
|
+
]),
|
|
79
|
+
_: 1
|
|
80
|
+
}, 8, ["data", "height"]),
|
|
81
|
+
e.hideLegend ? g("", !0) : (p(), u("div", {
|
|
82
|
+
key: 0,
|
|
83
|
+
style: d({
|
|
84
|
+
display: "flex",
|
|
85
|
+
justifyContent: T.value
|
|
86
|
+
})
|
|
87
|
+
}, [
|
|
88
|
+
i(o(E), {
|
|
89
|
+
style: d([
|
|
90
|
+
e.legendStyle,
|
|
91
|
+
"display: flex; gap: var(--vis-legend-spacing);"
|
|
92
|
+
]),
|
|
93
|
+
items: Object.values(e.categories).map((l) => ({
|
|
94
|
+
...l,
|
|
95
|
+
color: Array.isArray(l.color) ? l.color[0] : l.color
|
|
96
|
+
}))
|
|
97
|
+
}, null, 8, ["style", "items"])
|
|
98
|
+
], 4)),
|
|
99
|
+
H("div", {
|
|
100
|
+
ref_key: "slotWrapper",
|
|
101
|
+
ref: s,
|
|
102
|
+
style: { display: "none" }
|
|
103
|
+
}, [
|
|
104
|
+
o(y).labelTooltip ? f(t.$slots, "labelTooltip", {
|
|
105
|
+
key: 0,
|
|
106
|
+
values: r.value
|
|
107
|
+
}) : r.value ? f(t.$slots, "fallback", { key: 1 }, () => [
|
|
108
|
+
i(A, {
|
|
109
|
+
data: r.value,
|
|
110
|
+
categories: t.categories,
|
|
111
|
+
toolTipTitle: o(j)(r.value) ?? ""
|
|
112
|
+
}, null, 8, ["data", "categories", "toolTipTitle"])
|
|
113
|
+
]) : g("", !0)
|
|
114
|
+
], 512)
|
|
115
|
+
], 4));
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
export {
|
|
119
|
+
G as default
|
|
120
|
+
};
|