vue-chrts 0.2.3 → 0.2.5-test.1
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 +79 -72
- package/dist/components/AreaChart/types.d.ts +13 -1
- package/dist/components/AreaStackedChart/AreaStackedChart.js +31 -31
- package/dist/components/BarChart/BarChart.js +160 -122
- package/dist/components/BarChart/BarChart.vue.d.ts +1 -1
- package/dist/components/BarChart/stackedGroupedUtils.d.ts +1 -1
- package/dist/components/BarChart/stackedGroupedUtils.js +40 -39
- package/dist/components/BarChart/types.d.ts +28 -12
- package/dist/components/BubbleChart/BubbleChart.js +74 -56
- package/dist/components/BubbleChart/types.d.ts +4 -0
- package/dist/components/DonutChart/DonutChart.js +39 -39
- package/dist/components/LineChart/LineChart.js +67 -59
- package/dist/components/LineChart/types.d.ts +13 -1
- package/dist/components/Tooltip.js +24 -24
- package/dist/types.d.ts +7 -3
- package/dist/types.js +4 -4
- package/package.json +3 -3
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Position as
|
|
3
|
-
import { createMarkers as
|
|
4
|
-
import
|
|
5
|
-
import { VisXYContainer as
|
|
6
|
-
import { LegendPosition as
|
|
7
|
-
const
|
|
1
|
+
import { defineComponent as M, useSlots as U, useTemplateRef as j, ref as w, computed as d, createElementBlock as m, openBlock as o, normalizeClass as R, normalizeStyle as h, createVNode as u, createCommentVNode as c, createElementVNode as X, unref as i, withCtx as z, createBlock as y, Fragment as x, renderList as Y, mergeProps as p, renderSlot as L } from "vue";
|
|
2
|
+
import { Position as C, CurveType as D } from "@unovis/ts";
|
|
3
|
+
import { createMarkers as I, getFirstPropertyValue as H } from "../../utils.js";
|
|
4
|
+
import K from "../Tooltip.js";
|
|
5
|
+
import { VisXYContainer as q, VisTooltip as J, VisArea as Q, VisLine as Z, VisAxis as A, VisCrosshair as _, VisBulletLegend as ee } from "@unovis/vue";
|
|
6
|
+
import { LegendPosition as te } from "../../types.js";
|
|
7
|
+
const ie = {
|
|
8
8
|
ref: "slotWrapper",
|
|
9
9
|
style: { display: "none" }
|
|
10
|
-
},
|
|
10
|
+
}, f = 24, b = 4, ne = 0.5, B = "#3b82f6", de = /* @__PURE__ */ M({
|
|
11
11
|
__name: "AreaChart",
|
|
12
12
|
props: {
|
|
13
13
|
data: {},
|
|
@@ -22,13 +22,14 @@ const te = {
|
|
|
22
22
|
curveType: {},
|
|
23
23
|
lineWidth: { default: 2 },
|
|
24
24
|
lineDashArray: {},
|
|
25
|
-
xNumTicks: { default: (
|
|
25
|
+
xNumTicks: { default: (e) => e.data.length > f ? f / b : e.data.length - 1 },
|
|
26
26
|
xExplicitTicks: {},
|
|
27
27
|
minMaxTicksOnly: { type: Boolean },
|
|
28
|
-
yNumTicks: { default: (
|
|
29
|
-
hideLegend: { type: Boolean },
|
|
28
|
+
yNumTicks: { default: (e) => e.data.length > f ? f / b : e.data.length - 1 },
|
|
29
|
+
hideLegend: { type: Boolean, default: !1 },
|
|
30
30
|
hideTooltip: { type: Boolean },
|
|
31
|
-
legendPosition: {},
|
|
31
|
+
legendPosition: { default: te.BottomCenter },
|
|
32
|
+
legendStyle: { default: void 0 },
|
|
32
33
|
xDomainLine: { type: Boolean },
|
|
33
34
|
yDomainLine: { type: Boolean },
|
|
34
35
|
xTickLine: { type: Boolean },
|
|
@@ -39,79 +40,84 @@ const te = {
|
|
|
39
40
|
hideYAxis: { type: Boolean },
|
|
40
41
|
crosshairConfig: { default: () => ({
|
|
41
42
|
color: "#666"
|
|
42
|
-
}) }
|
|
43
|
+
}) },
|
|
44
|
+
yDomain: {},
|
|
45
|
+
xDomain: {}
|
|
43
46
|
},
|
|
44
47
|
emits: ["click"],
|
|
45
|
-
setup(
|
|
46
|
-
const
|
|
47
|
-
() => Object.values(n.categories).map((
|
|
48
|
-
),
|
|
49
|
-
const
|
|
50
|
-
<linearGradient id="gradient${t}-${
|
|
51
|
-
<stop offset="0%" stop-color="${
|
|
52
|
-
<stop offset="100%" stop-color="${
|
|
48
|
+
setup(e, { emit: V }) {
|
|
49
|
+
const F = V, n = e, $ = U(), T = j("slotWrapper"), s = w(), g = d(
|
|
50
|
+
() => Object.values(n.categories).map((l) => l.color)
|
|
51
|
+
), G = d(() => n.markerConfig ? I(n.markerConfig) : ""), O = d(() => n.legendPosition.startsWith("top")), N = d(() => n.legendPosition.includes("left") ? "flex-start" : n.legendPosition.includes("right") ? "flex-end" : "center"), P = d(() => {
|
|
52
|
+
const l = (t, a) => `
|
|
53
|
+
<linearGradient id="gradient${t}-${a}" gradientTransform="rotate(90)">
|
|
54
|
+
<stop offset="0%" stop-color="${a}" stop-opacity="1" />
|
|
55
|
+
<stop offset="100%" stop-color="${a}" stop-opacity="0" />
|
|
53
56
|
</linearGradient>
|
|
54
|
-
`,
|
|
55
|
-
<linearGradient id="gradient${t}-${
|
|
57
|
+
`, r = (t, a) => `
|
|
58
|
+
<linearGradient id="gradient${t}-${a}" gradientTransform="rotate(90)">
|
|
56
59
|
<stop offset="0%" style="stop-color:var(--vis-color0);stop-opacity:1" />
|
|
57
60
|
<stop offset="100%" style="stop-color:var(--vis-color0);stop-opacity:0" />
|
|
58
61
|
</linearGradient>
|
|
59
62
|
`;
|
|
60
|
-
return
|
|
61
|
-
(t,
|
|
63
|
+
return g.value.map(
|
|
64
|
+
(t, a) => t != null && t.includes("#") ? l(a, t) : r(a, t ?? B)
|
|
62
65
|
).join("");
|
|
63
66
|
});
|
|
64
|
-
function
|
|
65
|
-
var
|
|
67
|
+
function E(l) {
|
|
68
|
+
var r;
|
|
66
69
|
return {
|
|
67
|
-
y: (t) => Number(t[
|
|
68
|
-
color: ((
|
|
70
|
+
y: (t) => Number(t[l]),
|
|
71
|
+
color: ((r = n.categories[l]) == null ? void 0 : r.color) ?? B
|
|
69
72
|
};
|
|
70
73
|
}
|
|
71
|
-
function W(
|
|
72
|
-
return typeof window > "u" ? "" :
|
|
74
|
+
function W(l) {
|
|
75
|
+
return typeof window > "u" ? "" : T.value ? T.value.innerHTML : "";
|
|
73
76
|
}
|
|
74
|
-
function
|
|
75
|
-
return s.value =
|
|
77
|
+
function S(l) {
|
|
78
|
+
return s.value = l, W();
|
|
76
79
|
}
|
|
77
|
-
return (
|
|
78
|
-
style:
|
|
80
|
+
return (l, r) => (o(), m("div", {
|
|
81
|
+
style: h({
|
|
79
82
|
display: "flex",
|
|
80
|
-
flexDirection:
|
|
83
|
+
flexDirection: O.value ? "column-reverse" : "column",
|
|
84
|
+
gap: "var(--vis-legend-spacing)"
|
|
81
85
|
}),
|
|
82
|
-
class:
|
|
83
|
-
onClick:
|
|
86
|
+
class: R({ markers: !!n.markerConfig }),
|
|
87
|
+
onClick: r[0] || (r[0] = (t) => F("click", t, s.value))
|
|
84
88
|
}, [
|
|
85
|
-
|
|
89
|
+
u(i(q), {
|
|
86
90
|
data: e.data,
|
|
87
91
|
height: e.height,
|
|
88
92
|
padding: e.padding,
|
|
89
|
-
"svg-defs":
|
|
93
|
+
"svg-defs": P.value + G.value,
|
|
94
|
+
"y-domain": e.yDomain,
|
|
95
|
+
"x-domain": e.xDomain
|
|
90
96
|
}, {
|
|
91
97
|
default: z(() => [
|
|
92
|
-
e.hideTooltip ?
|
|
98
|
+
e.hideTooltip ? c("", !0) : (o(), y(i(J), {
|
|
93
99
|
key: 0,
|
|
94
|
-
"horizontal-placement": i(
|
|
95
|
-
"vertical-placement": i(
|
|
100
|
+
"horizontal-placement": i(C).Right,
|
|
101
|
+
"vertical-placement": i(C).Top
|
|
96
102
|
}, null, 8, ["horizontal-placement", "vertical-placement"])),
|
|
97
|
-
(
|
|
98
|
-
|
|
103
|
+
(o(!0), m(x, null, Y(Object.keys(n.categories), (t, a) => (o(), m(x, { key: t }, [
|
|
104
|
+
u(i(Q), p({
|
|
99
105
|
x: (k, v) => v
|
|
100
|
-
}, { ref_for: !0 },
|
|
101
|
-
color: `url(#gradient${
|
|
102
|
-
opacity:
|
|
103
|
-
"curve-type": e.curveType ?? i(
|
|
106
|
+
}, { ref_for: !0 }, E(t), {
|
|
107
|
+
color: `url(#gradient${a}-${g.value[a]})`,
|
|
108
|
+
opacity: ne,
|
|
109
|
+
"curve-type": e.curveType ?? i(D).MonotoneX
|
|
104
110
|
}), null, 16, ["x", "color", "curve-type"]),
|
|
105
|
-
|
|
111
|
+
u(i(Z), {
|
|
106
112
|
x: (k, v) => v,
|
|
107
113
|
y: (k) => k[t],
|
|
108
|
-
color:
|
|
109
|
-
"curve-type": e.curveType ?? i(
|
|
114
|
+
color: g.value[a],
|
|
115
|
+
"curve-type": e.curveType ?? i(D).MonotoneX,
|
|
110
116
|
"line-width": e.lineWidth,
|
|
111
|
-
lineDashArray: e.lineDashArray ? e.lineDashArray[
|
|
117
|
+
lineDashArray: e.lineDashArray ? e.lineDashArray[a] : void 0
|
|
112
118
|
}, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"])
|
|
113
119
|
], 64))), 128)),
|
|
114
|
-
e.hideXAxis ?
|
|
120
|
+
e.hideXAxis ? c("", !0) : (o(), y(i(A), {
|
|
115
121
|
key: 1,
|
|
116
122
|
type: "x",
|
|
117
123
|
label: e.xLabel,
|
|
@@ -124,7 +130,7 @@ const te = {
|
|
|
124
130
|
"tick-line": e.xTickLine,
|
|
125
131
|
"min-max-ticks-only": e.minMaxTicksOnly
|
|
126
132
|
}, null, 8, ["label", "num-ticks", "tick-format", "tick-values", "grid-line", "domain-line", "tick-line", "min-max-ticks-only"])),
|
|
127
|
-
e.hideYAxis ?
|
|
133
|
+
e.hideYAxis ? c("", !0) : (o(), y(i(A), {
|
|
128
134
|
key: 2,
|
|
129
135
|
type: "y",
|
|
130
136
|
label: e.yLabel,
|
|
@@ -134,36 +140,37 @@ const te = {
|
|
|
134
140
|
"domain-line": e.yDomainLine,
|
|
135
141
|
"tick-line": e.yTickLine
|
|
136
142
|
}, null, 8, ["label", "num-ticks", "tick-format", "grid-line", "domain-line", "tick-line"])),
|
|
137
|
-
e.hideTooltip ?
|
|
143
|
+
e.hideTooltip ? c("", !0) : (o(), y(i(_), p({ key: 3 }, e.crosshairConfig, { template: S }), null, 16))
|
|
138
144
|
]),
|
|
139
145
|
_: 1
|
|
140
|
-
}, 8, ["data", "height", "padding", "svg-defs"]),
|
|
141
|
-
|
|
146
|
+
}, 8, ["data", "height", "padding", "svg-defs", "y-domain", "x-domain"]),
|
|
147
|
+
n.hideLegend ? c("", !0) : (o(), m("div", {
|
|
142
148
|
key: 0,
|
|
143
|
-
style:
|
|
149
|
+
style: h({
|
|
144
150
|
display: "flex",
|
|
145
|
-
|
|
146
|
-
justifyContent: "flex-end",
|
|
147
|
-
paddingBottom: g.value ? "1rem" : void 0,
|
|
148
|
-
paddingTop: g.value ? void 0 : "1rem"
|
|
151
|
+
justifyContent: N.value
|
|
149
152
|
})
|
|
150
153
|
}, [
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
+
u(i(ee), {
|
|
155
|
+
style: h([
|
|
156
|
+
n.legendStyle,
|
|
157
|
+
"display: flex; gap: var(--vis-legend-spacing);"
|
|
158
|
+
]),
|
|
159
|
+
items: Object.values(n.categories)
|
|
160
|
+
}, null, 8, ["style", "items"])
|
|
154
161
|
], 4)),
|
|
155
|
-
X("div",
|
|
156
|
-
i(
|
|
162
|
+
X("div", ie, [
|
|
163
|
+
i($).tooltip ? L(l.$slots, "tooltip", {
|
|
157
164
|
key: 0,
|
|
158
165
|
values: s.value
|
|
159
|
-
}) : s.value ?
|
|
160
|
-
|
|
166
|
+
}) : s.value ? L(l.$slots, "fallback", { key: 1 }, () => [
|
|
167
|
+
u(K, {
|
|
161
168
|
data: s.value,
|
|
162
169
|
categories: e.categories,
|
|
163
|
-
toolTipTitle: i(
|
|
170
|
+
toolTipTitle: i(H)(s.value) ?? "",
|
|
164
171
|
yFormatter: n.yFormatter
|
|
165
172
|
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
166
|
-
]) :
|
|
173
|
+
]) : c("", !0)
|
|
167
174
|
], 512)
|
|
168
175
|
], 6));
|
|
169
176
|
}
|
|
@@ -72,7 +72,7 @@ export interface AreaChartProps<T> {
|
|
|
72
72
|
/**
|
|
73
73
|
* Force specific ticks on the x-axis.
|
|
74
74
|
*/
|
|
75
|
-
xExplicitTicks?: number;
|
|
75
|
+
xExplicitTicks?: (number | string | Date)[];
|
|
76
76
|
/**
|
|
77
77
|
* Force only first and last ticks on the x-axis.
|
|
78
78
|
*/
|
|
@@ -94,6 +94,10 @@ export interface AreaChartProps<T> {
|
|
|
94
94
|
* See `LegendPosition` for available options.
|
|
95
95
|
*/
|
|
96
96
|
legendPosition?: LegendPosition;
|
|
97
|
+
/**
|
|
98
|
+
* Optional style object for the legend container. Allows custom CSS styling.
|
|
99
|
+
*/
|
|
100
|
+
legendStyle?: string | Record<string, string>;
|
|
97
101
|
/**
|
|
98
102
|
* If `true`, displays a domain line (axis line) along the x-axis.
|
|
99
103
|
*/
|
|
@@ -130,4 +134,12 @@ export interface AreaChartProps<T> {
|
|
|
130
134
|
* Crosshair configuration object for customizing the appearance of the crosshair line.
|
|
131
135
|
*/
|
|
132
136
|
crosshairConfig?: CrosshairConfig;
|
|
137
|
+
/**
|
|
138
|
+
* The domain for the y-axis, specified as a tuple of two values.
|
|
139
|
+
*/
|
|
140
|
+
yDomain?: [number | undefined, number | undefined];
|
|
141
|
+
/**
|
|
142
|
+
* The domain for the x-axis, specified as a tuple of two values.
|
|
143
|
+
*/
|
|
144
|
+
xDomain?: [number | undefined, number | undefined];
|
|
133
145
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as y, computed as f, createApp as h, createElementBlock as g, openBlock as
|
|
2
|
-
import { VisXYContainer as
|
|
3
|
-
import { CurveType as
|
|
4
|
-
import
|
|
5
|
-
const
|
|
1
|
+
import { defineComponent as y, computed as f, createApp as h, createElementBlock as g, openBlock as c, createVNode as i, createElementVNode as x, unref as o, withCtx as B, createBlock as L, createCommentVNode as v, mergeProps as C } from "vue";
|
|
2
|
+
import { VisXYContainer as k, VisArea as b, VisAxis as s, VisCrosshair as T, VisBulletLegend as V } from "@unovis/vue";
|
|
3
|
+
import { CurveType as N } from "@unovis/ts";
|
|
4
|
+
import A from "../Tooltip.js";
|
|
5
|
+
const j = { class: "flex flex-col space-y-4" }, w = { class: "flex items center justify-end" }, H = /* @__PURE__ */ y({
|
|
6
6
|
__name: "AreaStackedChart",
|
|
7
7
|
props: {
|
|
8
8
|
data: {},
|
|
@@ -21,57 +21,57 @@ const A = { class: "flex flex-col space-y-4" }, j = { class: "flex items center
|
|
|
21
21
|
yTickLine: { type: Boolean },
|
|
22
22
|
crosshairConfig: {}
|
|
23
23
|
},
|
|
24
|
-
setup(
|
|
25
|
-
const
|
|
24
|
+
setup(t) {
|
|
25
|
+
const a = t, l = f(() => (e, u) => {
|
|
26
26
|
if (typeof window > "u" || typeof document > "u")
|
|
27
27
|
return "";
|
|
28
28
|
try {
|
|
29
|
-
const
|
|
29
|
+
const n = h(A, {
|
|
30
30
|
data: e,
|
|
31
|
-
categories:
|
|
31
|
+
categories: a.categories
|
|
32
32
|
}), r = document.createElement("div");
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
return
|
|
33
|
+
n.mount(r);
|
|
34
|
+
const p = r.innerHTML;
|
|
35
|
+
return n.unmount(), p;
|
|
36
36
|
} catch {
|
|
37
37
|
return "";
|
|
38
38
|
}
|
|
39
|
-
}),
|
|
40
|
-
return (e,
|
|
41
|
-
|
|
42
|
-
data:
|
|
43
|
-
padding:
|
|
44
|
-
height:
|
|
39
|
+
}), d = (e) => Number.parseInt(e.time), m = [(e) => e.firstTime, (e) => e.returning];
|
|
40
|
+
return (e, u) => (c(), g("div", j, [
|
|
41
|
+
i(o(k), {
|
|
42
|
+
data: t.data,
|
|
43
|
+
padding: t.padding,
|
|
44
|
+
height: t.height
|
|
45
45
|
}, {
|
|
46
|
-
default:
|
|
47
|
-
|
|
48
|
-
x:
|
|
49
|
-
y:
|
|
50
|
-
color: Object.values(
|
|
51
|
-
"curve-type":
|
|
46
|
+
default: B(() => [
|
|
47
|
+
i(o(b), {
|
|
48
|
+
x: d,
|
|
49
|
+
y: m,
|
|
50
|
+
color: Object.values(a.categories).map((n) => n.color),
|
|
51
|
+
"curve-type": o(N).Linear
|
|
52
52
|
}, null, 8, ["color", "curve-type"]),
|
|
53
|
-
|
|
53
|
+
i(o(s), {
|
|
54
54
|
type: "x",
|
|
55
55
|
label: "Time",
|
|
56
56
|
"num-ticks": 12
|
|
57
57
|
}),
|
|
58
|
-
|
|
58
|
+
i(o(s), {
|
|
59
59
|
type: "y",
|
|
60
60
|
label: "Number of visitors",
|
|
61
61
|
"num-ticks": 3
|
|
62
62
|
}),
|
|
63
|
-
|
|
63
|
+
t.hideTooltip ? v("", !0) : (c(), L(o(T), C({ key: 0 }, t.crosshairConfig, { template: l.value }), null, 16, ["template"]))
|
|
64
64
|
]),
|
|
65
65
|
_: 1
|
|
66
66
|
}, 8, ["data", "padding", "height"]),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
items: Object.values(
|
|
67
|
+
x("div", w, [
|
|
68
|
+
i(o(V), {
|
|
69
|
+
items: Object.values(t.categories)
|
|
70
70
|
}, null, 8, ["items"])
|
|
71
71
|
])
|
|
72
72
|
]));
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
75
|
export {
|
|
76
|
-
|
|
76
|
+
H as default
|
|
77
77
|
};
|