vue-chrts 0.2.0-test.7 → 0.2.0-test.8
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 +163 -0
- package/dist/components/AreaChart/AreaChart2.js +4 -0
- package/dist/components/AreaStackedChart/AreaStackedChart.js +77 -0
- package/dist/components/AreaStackedChart/AreaStackedChart2.js +4 -0
- package/dist/components/BarChart/BarChart.js +170 -0
- package/dist/components/BarChart/BarChart2.js +4 -0
- package/dist/components/BarChart/stackedGroupedUtils.js +67 -0
- package/dist/components/DonutChart/DonutChart.js +83 -0
- package/dist/components/DonutChart/DonutChart2.js +4 -0
- package/dist/components/DonutChart/types.js +4 -0
- package/dist/components/LineChart/LineChart.js +143 -0
- package/dist/components/LineChart/LineChart2.js +4 -0
- package/dist/components/Tooltip.js +48 -0
- package/dist/components/Tooltip2.js +4 -0
- package/dist/index.js +14 -0
- package/dist/types.js +4 -0
- package/dist/utils.js +49 -0
- package/package.json +1 -1
- package/dist/index.js.js +0 -753
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { defineComponent as P, computed as k, useSlots as x, useTemplateRef as O, ref as j, createElementBlock as u, openBlock as n, normalizeClass as g, createVNode as s, createCommentVNode as a, createElementVNode as w, unref as i, withCtx as M, createBlock as m, Fragment as W, renderList as E, mergeProps as G, renderSlot as h } from "vue";
|
|
2
|
+
import { Position as v, CurveType as X } from "@unovis/ts";
|
|
3
|
+
import { createMarkers as $, getFirstPropertyValue as z } from "../../utils.js";
|
|
4
|
+
import R from "../Tooltip.js";
|
|
5
|
+
import { VisXYContainer as Y, VisTooltip as S, VisLine as H, VisAxis as T, VisCrosshair as U, VisBulletLegend as q } from "@unovis/vue";
|
|
6
|
+
import { LegendPosition as I } from "../../types.js";
|
|
7
|
+
const J = {
|
|
8
|
+
ref: "slotWrapper",
|
|
9
|
+
class: "hidden"
|
|
10
|
+
}, te = /* @__PURE__ */ P({
|
|
11
|
+
__name: "LineChart",
|
|
12
|
+
props: {
|
|
13
|
+
data: {},
|
|
14
|
+
height: {},
|
|
15
|
+
xLabel: {},
|
|
16
|
+
yLabel: {},
|
|
17
|
+
padding: { default: () => ({
|
|
18
|
+
top: 5,
|
|
19
|
+
right: 5,
|
|
20
|
+
bottom: 5,
|
|
21
|
+
left: 5
|
|
22
|
+
}) },
|
|
23
|
+
categories: {},
|
|
24
|
+
markerConfig: {},
|
|
25
|
+
xFormatter: {},
|
|
26
|
+
yFormatter: {},
|
|
27
|
+
curveType: {},
|
|
28
|
+
lineWidth: { default: 2 },
|
|
29
|
+
lineDashArray: {},
|
|
30
|
+
xNumTicks: { default: (o) => o.data.length > 24 ? 24 / 4 : o.data.length - 1 },
|
|
31
|
+
xExplicitTicks: {},
|
|
32
|
+
minMaxTicksOnly: { type: Boolean },
|
|
33
|
+
yNumTicks: { default: (o) => o.data.length > 24 ? 24 / 4 : o.data.length - 1 },
|
|
34
|
+
hideTooltip: { type: Boolean },
|
|
35
|
+
hideLegend: { type: Boolean },
|
|
36
|
+
legendPosition: {},
|
|
37
|
+
xGridLine: { type: Boolean },
|
|
38
|
+
xDomainLine: { type: Boolean },
|
|
39
|
+
yGridLine: { type: Boolean },
|
|
40
|
+
yDomainLine: { type: Boolean },
|
|
41
|
+
xTickLine: { type: Boolean },
|
|
42
|
+
yTickLine: { type: Boolean },
|
|
43
|
+
hideXAxis: { type: Boolean },
|
|
44
|
+
hideYAxis: { type: Boolean },
|
|
45
|
+
crosshairConfig: { default: () => ({
|
|
46
|
+
color: "#666"
|
|
47
|
+
}) }
|
|
48
|
+
},
|
|
49
|
+
emits: ["click"],
|
|
50
|
+
setup(o, { emit: L }) {
|
|
51
|
+
const C = L, t = o, b = k(() => t.markerConfig ? $(t.markerConfig) : ""), B = x(), c = O("slotWrapper"), l = j();
|
|
52
|
+
function D(e) {
|
|
53
|
+
return typeof window > "u" ? "" : c.value ? c.value.innerHTML : "";
|
|
54
|
+
}
|
|
55
|
+
function V(e) {
|
|
56
|
+
return l.value = e, D();
|
|
57
|
+
}
|
|
58
|
+
const p = k(
|
|
59
|
+
() => t.legendPosition === I.Top
|
|
60
|
+
), A = Object.values(t.categories).map(
|
|
61
|
+
(e, r) => `var(--vis-color${r})`
|
|
62
|
+
), F = (e) => Object.values(t.categories)[e].color ?? A[e];
|
|
63
|
+
return (e, r) => (n(), u("div", {
|
|
64
|
+
class: g(["flex flex-col space-y-4", {
|
|
65
|
+
"flex-col-reverse": p.value,
|
|
66
|
+
markers: !!t.markerConfig
|
|
67
|
+
}]),
|
|
68
|
+
onClick: r[0] || (r[0] = (d) => C("click", d, l.value))
|
|
69
|
+
}, [
|
|
70
|
+
s(i(Y), {
|
|
71
|
+
data: e.data,
|
|
72
|
+
padding: e.padding,
|
|
73
|
+
height: e.height,
|
|
74
|
+
svgDefs: b.value
|
|
75
|
+
}, {
|
|
76
|
+
default: M(() => [
|
|
77
|
+
s(i(S), {
|
|
78
|
+
"horizontal-placement": i(v).Right,
|
|
79
|
+
"vertical-placement": i(v).Top
|
|
80
|
+
}, null, 8, ["horizontal-placement", "vertical-placement"]),
|
|
81
|
+
(n(!0), u(W, null, E(Object.keys(t.categories), (d, y) => (n(), m(i(H), {
|
|
82
|
+
key: y,
|
|
83
|
+
x: (f, N) => N,
|
|
84
|
+
y: (f) => f[d],
|
|
85
|
+
color: F(y),
|
|
86
|
+
"curve-type": e.curveType ?? i(X).MonotoneX,
|
|
87
|
+
"line-width": e.lineWidth,
|
|
88
|
+
lineDashArray: e.lineDashArray
|
|
89
|
+
}, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"]))), 128)),
|
|
90
|
+
e.hideXAxis ? a("", !0) : (n(), m(i(T), {
|
|
91
|
+
key: 0,
|
|
92
|
+
type: "x",
|
|
93
|
+
"tick-format": e.xFormatter,
|
|
94
|
+
label: e.xLabel,
|
|
95
|
+
"label-margin": 8,
|
|
96
|
+
"domain-line": e.xDomainLine,
|
|
97
|
+
"grid-line": e.xGridLine,
|
|
98
|
+
"tick-line": e.xTickLine,
|
|
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", "tick-line", "num-ticks", "tick-values", "min-max-ticks-only"])),
|
|
103
|
+
e.hideYAxis ? a("", !0) : (n(), m(i(T), {
|
|
104
|
+
key: 1,
|
|
105
|
+
type: "y",
|
|
106
|
+
"tick-format": e.yFormatter,
|
|
107
|
+
label: e.yLabel,
|
|
108
|
+
"num-ticks": e.yNumTicks,
|
|
109
|
+
"domain-line": e.yDomainLine,
|
|
110
|
+
"grid-line": e.yGridLine,
|
|
111
|
+
"tick-line": e.yTickLine
|
|
112
|
+
}, null, 8, ["tick-format", "label", "num-ticks", "domain-line", "grid-line", "tick-line"])),
|
|
113
|
+
e.hideTooltip ? a("", !0) : (n(), m(i(U), G({ key: 2 }, e.crosshairConfig, { template: V }), null, 16))
|
|
114
|
+
]),
|
|
115
|
+
_: 1
|
|
116
|
+
}, 8, ["data", "padding", "height", "svgDefs"]),
|
|
117
|
+
e.hideLegend ? a("", !0) : (n(), u("div", {
|
|
118
|
+
key: 0,
|
|
119
|
+
class: g(["flex items center justify-end", { "pb-4": p.value }])
|
|
120
|
+
}, [
|
|
121
|
+
s(i(q), {
|
|
122
|
+
items: Object.values(e.categories)
|
|
123
|
+
}, null, 8, ["items"])
|
|
124
|
+
], 2)),
|
|
125
|
+
w("div", J, [
|
|
126
|
+
i(B).tooltip ? h(e.$slots, "tooltip", {
|
|
127
|
+
key: 0,
|
|
128
|
+
values: l.value
|
|
129
|
+
}) : l.value ? h(e.$slots, "fallback", { key: 1 }, () => [
|
|
130
|
+
s(R, {
|
|
131
|
+
data: l.value,
|
|
132
|
+
categories: e.categories,
|
|
133
|
+
toolTipTitle: i(z)(l.value) ?? "",
|
|
134
|
+
yFormatter: t.yFormatter
|
|
135
|
+
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
136
|
+
]) : a("", !0)
|
|
137
|
+
], 512)
|
|
138
|
+
], 2));
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
export {
|
|
142
|
+
te as default
|
|
143
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { defineComponent as b, computed as v, createElementBlock as r, openBlock as l, createElementVNode as o, toDisplayString as i, Fragment as y, renderList as h, normalizeStyle as n } from "vue";
|
|
2
|
+
const f = {
|
|
3
|
+
class: "capitalize border-b mb-1 pb-1",
|
|
4
|
+
style: {
|
|
5
|
+
color: "var(--tooltip-value-color)",
|
|
6
|
+
borderColor: "rgba(255, 255, 255, 0.05)"
|
|
7
|
+
}
|
|
8
|
+
}, F = /* @__PURE__ */ b({
|
|
9
|
+
__name: "Tooltip",
|
|
10
|
+
props: {
|
|
11
|
+
data: {},
|
|
12
|
+
categories: {},
|
|
13
|
+
toolTipTitle: {},
|
|
14
|
+
yFormatter: { type: Function }
|
|
15
|
+
},
|
|
16
|
+
setup(p) {
|
|
17
|
+
const a = p, d = ["_index", "_stacked", "_ending"], m = v(() => Object.entries(a.data ?? []).filter(
|
|
18
|
+
([e, g]) => !d.includes(e) && Object.keys(a.categories).includes(e)
|
|
19
|
+
));
|
|
20
|
+
return (e, g) => (l(), r("div", null, [
|
|
21
|
+
o("div", f, i(e.toolTipTitle), 1),
|
|
22
|
+
(l(!0), r(y, null, h(m.value, ([t, s], u) => {
|
|
23
|
+
var c;
|
|
24
|
+
return l(), r("div", {
|
|
25
|
+
key: t,
|
|
26
|
+
style: { display: "flex", "align-items": "center", "margin-bottom": "4px" }
|
|
27
|
+
}, [
|
|
28
|
+
o("span", {
|
|
29
|
+
style: n([{ width: "8px", height: "8px", "border-radius": "4px", "margin-right": "8px" }, {
|
|
30
|
+
backgroundColor: (c = e.categories[t]) != null && c.color ? e.categories[t].color : `var(--vis-color${u})`
|
|
31
|
+
}])
|
|
32
|
+
}, null, 4),
|
|
33
|
+
o("div", null, [
|
|
34
|
+
o("span", {
|
|
35
|
+
style: n([{ "font-weight": "600", "margin-right": "8px" }, { color: "var(--tooltip-label-color)" }])
|
|
36
|
+
}, i(e.categories[t].name) + ":", 1),
|
|
37
|
+
o("span", {
|
|
38
|
+
style: n([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
|
|
39
|
+
}, i(e.yFormatter ? e.yFormatter(s) : s), 1)
|
|
40
|
+
])
|
|
41
|
+
]);
|
|
42
|
+
}), 128))
|
|
43
|
+
]));
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
export {
|
|
47
|
+
F as default
|
|
48
|
+
};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as t } from "./components/AreaChart/AreaChart.js";
|
|
2
|
+
import { default as o } from "./components/AreaStackedChart/AreaStackedChart.js";
|
|
3
|
+
import { default as d } from "./components/LineChart/LineChart.js";
|
|
4
|
+
import { default as p } from "./components/BarChart/BarChart.js";
|
|
5
|
+
import { default as u } from "./components/DonutChart/DonutChart.js";
|
|
6
|
+
import { LegendPosition as h } from "./types.js";
|
|
7
|
+
export {
|
|
8
|
+
t as AreaChart,
|
|
9
|
+
o as AreaStackedChart,
|
|
10
|
+
p as BarChart,
|
|
11
|
+
u as DonutChart,
|
|
12
|
+
h as LegendPosition,
|
|
13
|
+
d as LineChart
|
|
14
|
+
};
|
package/dist/types.js
ADDED
package/dist/utils.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
function o(n) {
|
|
2
|
+
if (n && Object.keys(n).length > 0) {
|
|
3
|
+
const e = Object.keys(n)[0];
|
|
4
|
+
return n[e];
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
const u = (n, e, r, t, $) => {
|
|
8
|
+
switch (n) {
|
|
9
|
+
case "circle":
|
|
10
|
+
return `<circle cx="${e / 2}" cy="${e / 2}" r="${(e - r) / 2}" stroke-width="${r}" stroke="${$}" fill="${t}" />`;
|
|
11
|
+
case "square":
|
|
12
|
+
return `<rect x="${r / 2}" y="${r / 2}" width="${e - r}" height="${e - r}" stroke-width="${r}" stroke="${$}" fill="${t}" />`;
|
|
13
|
+
case "triangle":
|
|
14
|
+
return `<polygon points="${e / 2},${r / 2} ${e - r / 2},${e - r / 2} ${r / 2},${e - r / 2}" stroke-width="${r}" stroke="${$}" fill="${t}" />`;
|
|
15
|
+
case "diamond":
|
|
16
|
+
return `<polygon points="${e / 2},${r / 2} ${e - r / 2},${e / 2} ${e / 2},${e - r / 2} ${r / 2},${e / 2}" stroke-width="${r}" stroke="${$}" fill="${t}" />`;
|
|
17
|
+
default:
|
|
18
|
+
return "";
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
function m(n) {
|
|
22
|
+
return Object.entries(n).map(([e, r]) => {
|
|
23
|
+
const t = r.type || "circle", $ = r.size || 10, c = r.strokeWidth || 2, a = r.color || "#000", l = r.strokeColor || r.color || "#000";
|
|
24
|
+
return `<marker id="circle-marker-${e}" viewBox="0 0 ${$} ${$}" refX="${$ / 2}" refY="${$ / 2}" markerWidth="${$ / 2}" markerHeight="${$ / 2}">
|
|
25
|
+
${u(t, $, c, a, l)}
|
|
26
|
+
</marker>`;
|
|
27
|
+
}).join(`
|
|
28
|
+
`);
|
|
29
|
+
}
|
|
30
|
+
function p(n) {
|
|
31
|
+
return n.charAt(0).toUpperCase() + n.slice(1);
|
|
32
|
+
}
|
|
33
|
+
const y = (n, e) => {
|
|
34
|
+
const r = Object.keys(n[0]).filter(($) => $ !== e), t = Object.keys(n[0][r[0]]);
|
|
35
|
+
return n.map(($) => ({
|
|
36
|
+
month: $.month,
|
|
37
|
+
...r.flatMap(
|
|
38
|
+
(c) => t.map((a) => ({
|
|
39
|
+
[`${c}${p(a)}`]: $[c][a]
|
|
40
|
+
}))
|
|
41
|
+
).reduce((c, a) => ({ ...c, ...a }), {})
|
|
42
|
+
}));
|
|
43
|
+
};
|
|
44
|
+
export {
|
|
45
|
+
m as createMarkers,
|
|
46
|
+
y as flattenData,
|
|
47
|
+
o as getFirstPropertyValue,
|
|
48
|
+
u as markerShape
|
|
49
|
+
};
|