vue-chrts 0.2.2-test.0 → 0.2.2-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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as C, useSlots as
|
|
1
|
+
import { defineComponent as C, useSlots as S, useTemplateRef as D, ref as N, computed as c, createElementBlock as y, openBlock as n, normalizeStyle as T, createVNode as g, createCommentVNode as m, createElementVNode as O, unref as i, withCtx as w, createBlock as u, Fragment as E, renderList as M, renderSlot as B } from "vue";
|
|
2
2
|
import { Orientation as l, StackedBar as j, GroupedBar as z } from "@unovis/ts";
|
|
3
3
|
import { getFirstPropertyValue as H } from "../../utils.js";
|
|
4
4
|
import { useStackedGrouped as W } from "./stackedGroupedUtils.js";
|
|
@@ -8,7 +8,7 @@ import { LegendPosition as I } from "../../types.js";
|
|
|
8
8
|
const U = {
|
|
9
9
|
ref: "slotWrapper",
|
|
10
10
|
style: { display: "none" }
|
|
11
|
-
},
|
|
11
|
+
}, ae = /* @__PURE__ */ C({
|
|
12
12
|
__name: "BarChart",
|
|
13
13
|
props: {
|
|
14
14
|
data: {},
|
|
@@ -45,38 +45,42 @@ const U = {
|
|
|
45
45
|
yGridLine: { type: Boolean, default: !0 },
|
|
46
46
|
hideXAxis: { type: Boolean },
|
|
47
47
|
hideYAxis: { type: Boolean },
|
|
48
|
+
stackedGroupedSpacing: { default: 0.1 },
|
|
48
49
|
stackAndGrouped: { type: Boolean },
|
|
49
50
|
xAxis: {}
|
|
50
51
|
},
|
|
51
52
|
emits: ["click"],
|
|
52
53
|
setup(t, { emit: V }) {
|
|
53
|
-
const x = V,
|
|
54
|
-
if (!
|
|
54
|
+
const x = V, a = t, G = S(), k = D("slotWrapper"), r = N();
|
|
55
|
+
if (!a.yAxis || a.yAxis.length === 0)
|
|
55
56
|
throw new Error("yAxis is required");
|
|
56
|
-
const
|
|
57
|
-
var
|
|
58
|
-
return (
|
|
59
|
-
}, s =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
const f = c(() => a.yAxis.map((e) => (d) => d[e])), v = (e, d) => {
|
|
58
|
+
var o;
|
|
59
|
+
return (o = Object.values(a.categories)[d]) == null ? void 0 : o.color;
|
|
60
|
+
}, s = c(
|
|
61
|
+
() => W({
|
|
62
|
+
data: a.data,
|
|
63
|
+
categories: a.categories,
|
|
64
|
+
stackAndGrouped: a.stackAndGrouped,
|
|
65
|
+
xAxis: a.xAxis,
|
|
66
|
+
spacing: a.stackedGroupedSpacing
|
|
67
|
+
}).value
|
|
68
|
+
), h = c(
|
|
69
|
+
() => a.legendPosition === I.Top
|
|
66
70
|
);
|
|
67
71
|
function b(e) {
|
|
68
|
-
return r.value = e,
|
|
72
|
+
return r.value = e, P();
|
|
69
73
|
}
|
|
70
|
-
function
|
|
71
|
-
return typeof window > "u" ? "" :
|
|
74
|
+
function P(e) {
|
|
75
|
+
return typeof window > "u" ? "" : k.value ? k.value.innerHTML : "";
|
|
72
76
|
}
|
|
73
77
|
return (e, d) => (n(), y("div", {
|
|
74
|
-
style:
|
|
78
|
+
style: T({
|
|
75
79
|
display: "flex",
|
|
76
80
|
flexDirection: h.value ? "column-reverse" : "column",
|
|
77
81
|
gap: "1rem"
|
|
78
82
|
}),
|
|
79
|
-
onClick: d[0] || (d[0] = (
|
|
83
|
+
onClick: d[0] || (d[0] = (o) => x("click", o, r.value))
|
|
80
84
|
}, [
|
|
81
85
|
g(i(X), {
|
|
82
86
|
padding: e.padding,
|
|
@@ -89,22 +93,22 @@ const U = {
|
|
|
89
93
|
[i(j).selectors.bar]: b
|
|
90
94
|
}
|
|
91
95
|
}, null, 8, ["triggers"]),
|
|
92
|
-
e.stackAndGrouped ? (n(!0), y(E, { key: 0 }, M(
|
|
93
|
-
key:
|
|
94
|
-
data:
|
|
95
|
-
x: (p, F) => F +
|
|
96
|
-
y:
|
|
97
|
-
color:
|
|
96
|
+
e.stackAndGrouped ? (n(!0), y(E, { key: 0 }, M(s.value.states, (o) => (n(), u(i(L), {
|
|
97
|
+
key: o,
|
|
98
|
+
data: s.value.chartData,
|
|
99
|
+
x: (p, F) => F + s.value.positions[o],
|
|
100
|
+
y: s.value.bars[o],
|
|
101
|
+
color: s.value.colorFunctions[o],
|
|
98
102
|
"rounded-corners": e.radius ?? 0,
|
|
99
103
|
"group-padding": e.groupPadding ?? 0,
|
|
100
|
-
"bar-padding": e.barPadding
|
|
104
|
+
"bar-padding": e.barPadding,
|
|
101
105
|
orientation: e.orientation ?? i(l).Vertical
|
|
102
106
|
}, null, 8, ["data", "x", "y", "color", "rounded-corners", "group-padding", "bar-padding", "orientation"]))), 128)) : e.stacked ? (n(), u(i(L), {
|
|
103
107
|
key: 2,
|
|
104
108
|
data: e.data,
|
|
105
|
-
x: (
|
|
106
|
-
y:
|
|
107
|
-
color:
|
|
109
|
+
x: (o, p) => p,
|
|
110
|
+
y: f.value,
|
|
111
|
+
color: v,
|
|
108
112
|
"rounded-corners": e.radius ?? 0,
|
|
109
113
|
"group-padding": e.groupPadding ?? 0,
|
|
110
114
|
"bar-padding": e.barPadding ?? 0.2,
|
|
@@ -112,9 +116,9 @@ const U = {
|
|
|
112
116
|
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (n(), u(i($), {
|
|
113
117
|
key: 1,
|
|
114
118
|
data: e.data,
|
|
115
|
-
x: (
|
|
116
|
-
y:
|
|
117
|
-
color:
|
|
119
|
+
x: (o, p) => p,
|
|
120
|
+
y: f.value,
|
|
121
|
+
color: v,
|
|
118
122
|
"rounded-corners": e.radius ?? 0,
|
|
119
123
|
"group-padding": e.groupPadding ?? 0,
|
|
120
124
|
"bar-padding": e.barPadding ?? 0.2,
|
|
@@ -147,7 +151,7 @@ const U = {
|
|
|
147
151
|
}, 8, ["padding", "height"]),
|
|
148
152
|
e.hideLegend ? m("", !0) : (n(), y("div", {
|
|
149
153
|
key: 0,
|
|
150
|
-
style:
|
|
154
|
+
style: T({
|
|
151
155
|
display: "flex",
|
|
152
156
|
alignItems: "center",
|
|
153
157
|
justifyContent: "flex-end",
|
|
@@ -155,19 +159,19 @@ const U = {
|
|
|
155
159
|
})
|
|
156
160
|
}, [
|
|
157
161
|
g(i(R), {
|
|
158
|
-
items: Object.values(
|
|
162
|
+
items: Object.values(a.categories)
|
|
159
163
|
}, null, 8, ["items"])
|
|
160
164
|
], 4)),
|
|
161
|
-
|
|
162
|
-
i(
|
|
165
|
+
O("div", U, [
|
|
166
|
+
i(G).tooltip ? B(e.$slots, "tooltip", {
|
|
163
167
|
key: 0,
|
|
164
168
|
values: r.value
|
|
165
169
|
}) : r.value ? B(e.$slots, "fallback", { key: 1 }, () => [
|
|
166
170
|
g(q, {
|
|
167
171
|
data: r.value,
|
|
168
|
-
categories:
|
|
172
|
+
categories: a.categories,
|
|
169
173
|
toolTipTitle: i(H)(r.value) ?? "",
|
|
170
|
-
yFormatter:
|
|
174
|
+
yFormatter: a.orientation === i(l).Horizontal ? a.xFormatter : a.yFormatter
|
|
171
175
|
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
172
176
|
]) : m("", !0)
|
|
173
177
|
], 512)
|
|
@@ -175,5 +179,5 @@ const U = {
|
|
|
175
179
|
}
|
|
176
180
|
});
|
|
177
181
|
export {
|
|
178
|
-
|
|
182
|
+
ae as default
|
|
179
183
|
};
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { computed as u } from "vue";
|
|
2
2
|
import { flattenData as i } from "../../utils.js";
|
|
3
|
-
function
|
|
3
|
+
function g(t) {
|
|
4
4
|
return u(() => {
|
|
5
|
-
const
|
|
6
|
-
console.log(t, "config");
|
|
7
|
-
const a = t.stackAndGrouped ? i(t.data, t.xAxis) : t.data;
|
|
5
|
+
const e = p(t.categories), o = f(t.categories, e), r = d(o, t.categories), c = l(o), n = m(r), s = h(e, t.spacing), a = t.stackAndGrouped ? i(t.data, t.xAxis) : t.data;
|
|
8
6
|
return {
|
|
9
|
-
states:
|
|
10
|
-
groupedByState:
|
|
7
|
+
states: e,
|
|
8
|
+
groupedByState: o,
|
|
11
9
|
colors: r,
|
|
12
10
|
bars: c,
|
|
13
11
|
colorFunctions: n,
|
|
@@ -16,52 +14,52 @@ function b(t) {
|
|
|
16
14
|
};
|
|
17
15
|
});
|
|
18
16
|
}
|
|
19
|
-
function
|
|
20
|
-
const
|
|
17
|
+
function p(t) {
|
|
18
|
+
const e = /* @__PURE__ */ new Set();
|
|
21
19
|
return Object.keys(t).forEach((r) => {
|
|
22
20
|
const c = r.match(/([A-Z][a-z]+)$/);
|
|
23
|
-
c &&
|
|
24
|
-
}), Array.from(
|
|
21
|
+
c && e.add(c[1]);
|
|
22
|
+
}), Array.from(e);
|
|
25
23
|
}
|
|
26
|
-
function
|
|
27
|
-
const
|
|
28
|
-
return
|
|
29
|
-
|
|
24
|
+
function f(t, e) {
|
|
25
|
+
const o = {};
|
|
26
|
+
return e.forEach((r) => {
|
|
27
|
+
o[r] = Object.keys(t).filter(
|
|
30
28
|
(c) => c.endsWith(r)
|
|
31
29
|
);
|
|
32
|
-
}),
|
|
30
|
+
}), o;
|
|
33
31
|
}
|
|
34
|
-
function
|
|
35
|
-
const
|
|
32
|
+
function d(t, e) {
|
|
33
|
+
const o = {};
|
|
36
34
|
return Object.entries(t).forEach(([r, c]) => {
|
|
37
|
-
|
|
35
|
+
o[r] = c.map((n) => {
|
|
38
36
|
var s;
|
|
39
|
-
return ((s =
|
|
37
|
+
return ((s = e[n]) == null ? void 0 : s.color) ?? "#ccc";
|
|
40
38
|
});
|
|
41
|
-
}),
|
|
39
|
+
}), o;
|
|
42
40
|
}
|
|
43
|
-
function
|
|
44
|
-
const
|
|
45
|
-
return Object.entries(t).forEach(([
|
|
46
|
-
o
|
|
47
|
-
const n = c.replace(
|
|
48
|
-
return (s) => s[n +
|
|
41
|
+
function l(t) {
|
|
42
|
+
const e = {};
|
|
43
|
+
return Object.entries(t).forEach(([o, r]) => {
|
|
44
|
+
e[o] = r.map((c) => {
|
|
45
|
+
const n = c.replace(o, "").toLowerCase();
|
|
46
|
+
return (s) => s[n + o];
|
|
49
47
|
});
|
|
50
|
-
}),
|
|
48
|
+
}), e;
|
|
51
49
|
}
|
|
52
50
|
function m(t) {
|
|
53
|
-
const
|
|
54
|
-
return Object.entries(t).forEach(([
|
|
55
|
-
o
|
|
56
|
-
}),
|
|
51
|
+
const e = {};
|
|
52
|
+
return Object.entries(t).forEach(([o, r]) => {
|
|
53
|
+
e[o] = (c, n) => r[n] ?? "#ccc";
|
|
54
|
+
}), e;
|
|
57
55
|
}
|
|
58
|
-
function h(t) {
|
|
59
|
-
const o = t.length,
|
|
56
|
+
function h(t, e = 0.4) {
|
|
57
|
+
const o = t.length, r = {};
|
|
60
58
|
return t.forEach((c, n) => {
|
|
61
59
|
const s = (n - (o - 1) / 2) * e;
|
|
62
60
|
r[c] = s;
|
|
63
61
|
}), r;
|
|
64
62
|
}
|
|
65
63
|
export {
|
|
66
|
-
|
|
64
|
+
g as useStackedGrouped
|
|
67
65
|
};
|