vue-chrts 0.2.4 → 0.2.5
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/BarChart/BarChart.js +144 -107
- package/dist/components/BarChart/BarChart.vue.d.ts +1 -1
- package/dist/components/BarChart/types.d.ts +23 -11
- package/dist/components/BubbleChart/BubbleChart.js +59 -56
- package/dist/components/LineChart/LineChart.js +35 -32
- package/package.json +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Orientation as
|
|
3
|
-
import { getFirstPropertyValue as
|
|
4
|
-
import { useStackedGrouped as
|
|
5
|
-
import { VisXYContainer as
|
|
6
|
-
import
|
|
7
|
-
import { LegendPosition as
|
|
8
|
-
const
|
|
1
|
+
import { defineComponent as R, useSlots as W, useTemplateRef as X, ref as Y, computed as b, createElementBlock as v, openBlock as t, normalizeStyle as P, createVNode as k, createCommentVNode as m, createElementVNode as j, unref as o, withCtx as H, createBlock as u, Fragment as $, renderList as q, renderSlot as C } from "vue";
|
|
2
|
+
import { Orientation as p, StackedBar as I, GroupedBar as U } from "@unovis/ts";
|
|
3
|
+
import { getFirstPropertyValue as J } from "../../utils.js";
|
|
4
|
+
import { useStackedGrouped as K } from "./stackedGroupedUtils.js";
|
|
5
|
+
import { VisXYContainer as Q, VisXYLabels as Z, VisTooltip as _, VisStackedBar as F, VisGroupedBar as ee, VisAxis as V, VisBulletLegend as ae } from "@unovis/vue";
|
|
6
|
+
import oe from "../Tooltip.js";
|
|
7
|
+
import { LegendPosition as ie } from "../../types.js";
|
|
8
|
+
const re = {
|
|
9
9
|
ref: "slotWrapper",
|
|
10
10
|
style: { display: "none" }
|
|
11
|
-
},
|
|
11
|
+
}, ce = /* @__PURE__ */ R({
|
|
12
12
|
__name: "BarChart",
|
|
13
13
|
props: {
|
|
14
14
|
data: {},
|
|
@@ -25,17 +25,17 @@ const U = {
|
|
|
25
25
|
categories: {},
|
|
26
26
|
xFormatter: {},
|
|
27
27
|
yFormatter: {},
|
|
28
|
-
yNumTicks: {
|
|
28
|
+
yNumTicks: {},
|
|
29
29
|
minMaxTicksOnly: { type: Boolean },
|
|
30
|
-
xNumTicks: {
|
|
30
|
+
xNumTicks: {},
|
|
31
31
|
xExplicitTicks: {},
|
|
32
32
|
yAxis: {},
|
|
33
|
-
groupPadding: {},
|
|
34
|
-
barPadding: {},
|
|
33
|
+
groupPadding: { default: 0 },
|
|
34
|
+
barPadding: { default: 0.2 },
|
|
35
35
|
radius: {},
|
|
36
36
|
hideLegend: { type: Boolean },
|
|
37
37
|
hideTooltip: { type: Boolean, default: !1 },
|
|
38
|
-
orientation: { default:
|
|
38
|
+
orientation: { default: p.Vertical },
|
|
39
39
|
legendPosition: {},
|
|
40
40
|
xDomainLine: { type: Boolean },
|
|
41
41
|
yDomainLine: { type: Boolean },
|
|
@@ -47,131 +47,168 @@ const U = {
|
|
|
47
47
|
hideYAxis: { type: Boolean },
|
|
48
48
|
stackedGroupedSpacing: { default: 0.1 },
|
|
49
49
|
stackAndGrouped: { type: Boolean },
|
|
50
|
+
valueLabel: {},
|
|
50
51
|
xAxis: {}
|
|
51
52
|
},
|
|
52
53
|
emits: ["click"],
|
|
53
|
-
setup(
|
|
54
|
-
const
|
|
54
|
+
setup(G, { emit: S }) {
|
|
55
|
+
const O = S, a = G, w = W(), L = X("slotWrapper"), s = Y();
|
|
56
|
+
if (a.valueLabel && !a.xAxis)
|
|
57
|
+
throw new Error(
|
|
58
|
+
"BarChart: 'xAxis' prop is required when 'valueLabel' is enabled. Please provide an 'xAxis' to display value labels."
|
|
59
|
+
);
|
|
55
60
|
if (!a.yAxis || a.yAxis.length === 0)
|
|
56
61
|
throw new Error("yAxis is required");
|
|
57
|
-
const
|
|
58
|
-
var
|
|
59
|
-
return (
|
|
60
|
-
},
|
|
61
|
-
() =>
|
|
62
|
+
const h = b(() => a.yAxis.map((e) => (r) => r[e])), x = (e, r) => {
|
|
63
|
+
var i;
|
|
64
|
+
return (i = Object.values(a.categories)[r]) == null ? void 0 : i.color;
|
|
65
|
+
}, c = b(
|
|
66
|
+
() => K({
|
|
62
67
|
data: a.data,
|
|
63
68
|
categories: a.categories,
|
|
64
69
|
stackAndGrouped: a.stackAndGrouped,
|
|
65
70
|
xAxis: a.xAxis,
|
|
66
71
|
spacing: a.stackedGroupedSpacing
|
|
67
72
|
}).value
|
|
68
|
-
),
|
|
69
|
-
() => a.legendPosition ===
|
|
73
|
+
), A = b(
|
|
74
|
+
() => a.legendPosition === ie.Top
|
|
70
75
|
);
|
|
71
|
-
function
|
|
72
|
-
return
|
|
76
|
+
function B(e) {
|
|
77
|
+
return s.value = e, D();
|
|
73
78
|
}
|
|
74
|
-
function
|
|
75
|
-
return typeof window > "u" ? "" :
|
|
79
|
+
function D(e) {
|
|
80
|
+
return typeof window > "u" ? "" : L.value ? L.value.innerHTML : "";
|
|
76
81
|
}
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
const T = a.yAxis.map((e) => (r) => r[e]), E = T.length, N = a.data.flatMap(
|
|
83
|
+
(e, r) => T.map((i, d) => ({
|
|
84
|
+
x: r,
|
|
85
|
+
y: Number(i(e) ?? 0),
|
|
86
|
+
itemIndex: d
|
|
87
|
+
}))
|
|
88
|
+
), z = (e) => {
|
|
89
|
+
if (a.stacked || a.stackAndGrouped) return e.x;
|
|
90
|
+
const r = E;
|
|
91
|
+
if (r <= 1) return e.x;
|
|
92
|
+
const d = 1 - (a.groupPadding ?? 0), g = d / r, y = -d / 2, n = g * e.itemIndex + g / 2, f = 1 - (a.barPadding ?? 0), M = (y + n) * f;
|
|
93
|
+
return e.x + M;
|
|
94
|
+
};
|
|
95
|
+
return (e, r) => (t(), v("div", {
|
|
96
|
+
style: P({
|
|
79
97
|
display: "flex",
|
|
80
|
-
flexDirection:
|
|
98
|
+
flexDirection: A.value ? "column-reverse" : "column",
|
|
81
99
|
gap: "1rem"
|
|
82
100
|
}),
|
|
83
|
-
onClick:
|
|
101
|
+
onClick: r[0] || (r[0] = (i) => O("click", i, s.value))
|
|
84
102
|
}, [
|
|
85
|
-
|
|
103
|
+
k(o(Q), {
|
|
86
104
|
padding: e.padding,
|
|
87
105
|
height: e.height
|
|
88
106
|
}, {
|
|
89
|
-
default:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
"
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
color:
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
107
|
+
default: H(() => {
|
|
108
|
+
var i, d, g, y;
|
|
109
|
+
return [
|
|
110
|
+
e.valueLabel ? (t(), u(o(Z), {
|
|
111
|
+
key: 0,
|
|
112
|
+
data: o(N),
|
|
113
|
+
x: z,
|
|
114
|
+
y: (n) => {
|
|
115
|
+
var l;
|
|
116
|
+
return n.y + (((l = a.valueLabel) == null ? void 0 : l.labelSpacing) ?? 0);
|
|
117
|
+
},
|
|
118
|
+
label: (i = a.valueLabel) == null ? void 0 : i.label,
|
|
119
|
+
backgroundColor: ((d = a.valueLabel) == null ? void 0 : d.backgroundColor) ?? "transparent",
|
|
120
|
+
color: ((g = a.valueLabel) == null ? void 0 : g.color) ?? "red",
|
|
121
|
+
labelFontSize: (y = a.valueLabel) == null ? void 0 : y.labelFontSize
|
|
122
|
+
}, null, 8, ["data", "y", "label", "backgroundColor", "color", "labelFontSize"])) : m("", !0),
|
|
123
|
+
k(o(_), {
|
|
124
|
+
triggers: {
|
|
125
|
+
[o(U).selectors.bar]: B,
|
|
126
|
+
[o(I).selectors.bar]: B
|
|
127
|
+
}
|
|
128
|
+
}, null, 8, ["triggers"]),
|
|
129
|
+
e.stackAndGrouped ? (t(!0), v($, { key: 1 }, q(c.value.states, (n) => (t(), u(o(F), {
|
|
130
|
+
key: n,
|
|
131
|
+
data: c.value.chartData,
|
|
132
|
+
x: (l, f) => f + c.value.positions[n],
|
|
133
|
+
y: c.value.bars[n],
|
|
134
|
+
color: c.value.colorFunctions[n],
|
|
135
|
+
"rounded-corners": e.radius ?? 0,
|
|
136
|
+
"group-padding": e.groupPadding ?? 0,
|
|
137
|
+
"bar-padding": e.barPadding,
|
|
138
|
+
orientation: e.orientation ?? o(p).Vertical
|
|
139
|
+
}, null, 8, ["data", "x", "y", "color", "rounded-corners", "group-padding", "bar-padding", "orientation"]))), 128)) : e.stacked ? (t(), u(o(F), {
|
|
140
|
+
key: 3,
|
|
141
|
+
data: e.data,
|
|
142
|
+
x: (n, l) => l,
|
|
143
|
+
y: h.value,
|
|
144
|
+
color: x,
|
|
145
|
+
"rounded-corners": e.radius ?? 0,
|
|
146
|
+
"group-padding": e.groupPadding ?? 0,
|
|
147
|
+
"bar-padding": e.barPadding ?? 0.2,
|
|
148
|
+
orientation: e.orientation ?? o(p).Vertical
|
|
149
|
+
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (t(), u(o(ee), {
|
|
150
|
+
key: 2,
|
|
151
|
+
data: e.data,
|
|
152
|
+
x: (n, l) => l,
|
|
153
|
+
y: h.value,
|
|
154
|
+
color: x,
|
|
155
|
+
"rounded-corners": e.radius ?? 0,
|
|
156
|
+
"group-padding": e.groupPadding ?? 0,
|
|
157
|
+
"bar-padding": e.barPadding ?? 0.2,
|
|
158
|
+
orientation: e.orientation ?? o(p).Vertical
|
|
159
|
+
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])),
|
|
160
|
+
e.hideXAxis ? m("", !0) : (t(), u(o(V), {
|
|
161
|
+
key: 4,
|
|
162
|
+
type: "x",
|
|
163
|
+
"tick-format": e.xFormatter,
|
|
164
|
+
label: e.xLabel,
|
|
165
|
+
"grid-line": e.xGridLine,
|
|
166
|
+
"domain-line": !!e.xDomainLine,
|
|
167
|
+
"tick-line": e.xTickLine,
|
|
168
|
+
"num-ticks": e.xNumTicks,
|
|
169
|
+
"tick-values": e.xExplicitTicks,
|
|
170
|
+
minMaxTicksOnly: e.minMaxTicksOnly
|
|
171
|
+
}, null, 8, ["tick-format", "label", "grid-line", "domain-line", "tick-line", "num-ticks", "tick-values", "minMaxTicksOnly"])),
|
|
172
|
+
e.hideYAxis ? m("", !0) : (t(), u(o(V), {
|
|
173
|
+
key: 5,
|
|
174
|
+
type: "y",
|
|
175
|
+
label: e.yLabel,
|
|
176
|
+
"grid-line": e.orientation !== o(p).Horizontal && e.yGridLine,
|
|
177
|
+
"domain-line": !!e.yDomainLine,
|
|
178
|
+
"tick-format": e.yFormatter,
|
|
179
|
+
"num-ticks": e.yNumTicks,
|
|
180
|
+
"tick-line": e.yTickLine
|
|
181
|
+
}, null, 8, ["label", "grid-line", "domain-line", "tick-format", "num-ticks", "tick-line"]))
|
|
182
|
+
];
|
|
183
|
+
}),
|
|
150
184
|
_: 1
|
|
151
185
|
}, 8, ["padding", "height"]),
|
|
152
|
-
e.hideLegend ? m("", !0) : (
|
|
186
|
+
e.hideLegend ? m("", !0) : (t(), v("div", {
|
|
153
187
|
key: 0,
|
|
154
|
-
style:
|
|
188
|
+
style: P({
|
|
155
189
|
display: "flex",
|
|
156
190
|
alignItems: "center",
|
|
157
191
|
justifyContent: "flex-end",
|
|
158
|
-
paddingBottom:
|
|
192
|
+
paddingBottom: A.value ? "1rem" : void 0
|
|
159
193
|
})
|
|
160
194
|
}, [
|
|
161
|
-
|
|
162
|
-
items: Object.values(a.categories)
|
|
195
|
+
k(o(ae), {
|
|
196
|
+
items: Object.values(a.categories).map((i) => ({
|
|
197
|
+
...i,
|
|
198
|
+
color: Array.isArray(i.color) ? i.color[0] : i.color
|
|
199
|
+
}))
|
|
163
200
|
}, null, 8, ["items"])
|
|
164
201
|
], 4)),
|
|
165
|
-
|
|
166
|
-
|
|
202
|
+
j("div", re, [
|
|
203
|
+
o(w).tooltip ? C(e.$slots, "tooltip", {
|
|
167
204
|
key: 0,
|
|
168
|
-
values:
|
|
169
|
-
}) :
|
|
170
|
-
|
|
171
|
-
data:
|
|
205
|
+
values: s.value
|
|
206
|
+
}) : s.value ? C(e.$slots, "fallback", { key: 1 }, () => [
|
|
207
|
+
k(oe, {
|
|
208
|
+
data: s.value,
|
|
172
209
|
categories: a.categories,
|
|
173
|
-
toolTipTitle:
|
|
174
|
-
yFormatter: a.orientation ===
|
|
210
|
+
toolTipTitle: o(J)(s.value) ?? "",
|
|
211
|
+
yFormatter: a.orientation === o(p).Horizontal ? a.xFormatter : a.yFormatter
|
|
175
212
|
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
176
213
|
]) : m("", !0)
|
|
177
214
|
], 512)
|
|
@@ -179,5 +216,5 @@ const U = {
|
|
|
179
216
|
}
|
|
180
217
|
});
|
|
181
218
|
export {
|
|
182
|
-
|
|
219
|
+
ce as default
|
|
183
220
|
};
|
|
@@ -133,23 +133,35 @@ type BarChartPropsBase<T> = {
|
|
|
133
133
|
* If `true`, hide the y-axis.
|
|
134
134
|
*/
|
|
135
135
|
hideYAxis?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Specific spacing between stacked and grouped bars in pixels.
|
|
138
|
+
* Only applicable if `stackAndGrouped` is `true`.
|
|
139
|
+
*/
|
|
136
140
|
stackedGroupedSpacing?: number;
|
|
137
141
|
};
|
|
138
|
-
type
|
|
139
|
-
stackAndGrouped: true;
|
|
142
|
+
export type BarChartProps<T> = BarChartPropsBase<T> & {
|
|
140
143
|
/**
|
|
141
|
-
*
|
|
142
|
-
*
|
|
144
|
+
* Whether the bars should be stacked and grouped.
|
|
145
|
+
* If true, `valueLabel` is optional and `xAxis` is required.
|
|
143
146
|
*/
|
|
144
|
-
|
|
145
|
-
};
|
|
146
|
-
type BarChartPropsNormal<T> = BarChartPropsBase<T> & {
|
|
147
|
-
stackAndGrouped?: false;
|
|
147
|
+
stackAndGrouped?: boolean;
|
|
148
148
|
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
149
|
+
* Configuration for the value label display.
|
|
150
|
+
* Required if `stackAndGrouped` is false and `xAxis` is present.
|
|
151
|
+
* Optional otherwise.
|
|
152
|
+
*/
|
|
153
|
+
valueLabel?: ValueLabel;
|
|
154
|
+
/**
|
|
155
|
+
* The data key for the X-axis.
|
|
156
|
+
* Required if `stackAndGrouped` is true, or if `stackAndGrouped` is false AND `valueLabel` is present.
|
|
151
157
|
*/
|
|
152
158
|
xAxis?: keyof T;
|
|
153
159
|
};
|
|
154
|
-
export type
|
|
160
|
+
export type ValueLabel = {
|
|
161
|
+
label: (d: any, index: number) => string | number;
|
|
162
|
+
labelSpacing?: number;
|
|
163
|
+
backgroundColor?: string;
|
|
164
|
+
color?: string;
|
|
165
|
+
labelFontSize?: number;
|
|
166
|
+
};
|
|
155
167
|
export {};
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Scatter as
|
|
3
|
-
import { VisBulletLegend as
|
|
4
|
-
import { LegendPosition as
|
|
5
|
-
import { getFirstPropertyValue as
|
|
6
|
-
import
|
|
7
|
-
const
|
|
1
|
+
import { defineComponent as C, useSlots as z, useTemplateRef as P, ref as _, createElementBlock as m, openBlock as n, Fragment as N, createCommentVNode as l, createVNode as s, createElementVNode as O, unref as t, withCtx as R, createBlock as c, renderSlot as p } from "vue";
|
|
2
|
+
import { Scatter as w, Position as D } from "@unovis/ts";
|
|
3
|
+
import { VisBulletLegend as K, VisXYContainer as M, VisTooltip as S, VisScatter as E, VisAxis as f } from "@unovis/vue";
|
|
4
|
+
import { LegendPosition as g } from "../../types.js";
|
|
5
|
+
import { getFirstPropertyValue as G } from "../../utils.js";
|
|
6
|
+
import $ from "../Tooltip.js";
|
|
7
|
+
const j = {
|
|
8
8
|
key: 0,
|
|
9
9
|
class: "flex items-center justify-end pb-4"
|
|
10
|
-
},
|
|
11
|
-
key: 1,
|
|
12
|
-
class: "flex items-center justify-end pt-4"
|
|
13
|
-
}, q = {
|
|
10
|
+
}, W = {
|
|
14
11
|
ref: "slotWrapper",
|
|
15
12
|
class: "hidden"
|
|
16
|
-
},
|
|
13
|
+
}, J = /* @__PURE__ */ C({
|
|
17
14
|
__name: "BubbleChart",
|
|
18
15
|
props: {
|
|
19
16
|
xAccessor: {},
|
|
@@ -34,7 +31,7 @@ const X = {
|
|
|
34
31
|
categoryKey: {},
|
|
35
32
|
xFormatter: {},
|
|
36
33
|
yFormatter: {},
|
|
37
|
-
legendPosition: { default:
|
|
34
|
+
legendPosition: { default: g.Bottom },
|
|
38
35
|
sizeOptions: {},
|
|
39
36
|
xDomainLine: { type: Boolean, default: !0 },
|
|
40
37
|
yDomainLine: { type: Boolean, default: !0 },
|
|
@@ -52,51 +49,60 @@ const X = {
|
|
|
52
49
|
}) }
|
|
53
50
|
},
|
|
54
51
|
emits: ["click"],
|
|
55
|
-
setup(
|
|
56
|
-
const e =
|
|
57
|
-
var
|
|
52
|
+
setup(k, { emit: x }) {
|
|
53
|
+
const e = k, L = z(), u = P("slotWrapper"), a = _(), T = e.xAccessor, h = e.yAccessor, b = e.sizeAccessor || ((o) => typeof o.comments == "number" ? o.comments : 1), B = (o) => {
|
|
54
|
+
var d, y;
|
|
58
55
|
if (!e.categories || !e.categoryKey)
|
|
59
|
-
return console.warn(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
return console.warn(
|
|
57
|
+
"BubbleChart: categories and categoryKey are required for color mapping"
|
|
58
|
+
), "#cccccc";
|
|
59
|
+
const r = String(o[e.categoryKey]);
|
|
60
|
+
let i = (d = e.categories[r]) == null ? void 0 : d.color;
|
|
61
|
+
return Object.keys(e.categories).length === 1 && (i = (y = e.categories[e.categoryKey]) == null ? void 0 : y.color), i || (console.warn(
|
|
62
|
+
`BubbleChart: No color defined for category "${r}"`
|
|
63
|
+
), "#cccccc");
|
|
64
|
+
}, v = x;
|
|
65
|
+
function A(o) {
|
|
66
|
+
return a.value = o, F();
|
|
66
67
|
}
|
|
67
|
-
function
|
|
68
|
-
return typeof window > "u" ? "" :
|
|
68
|
+
function F(o) {
|
|
69
|
+
return typeof window > "u" ? "" : u.value ? u.value.innerHTML : "";
|
|
69
70
|
}
|
|
70
|
-
const
|
|
71
|
-
[
|
|
71
|
+
const V = {
|
|
72
|
+
[w.selectors.point]: A
|
|
72
73
|
};
|
|
73
|
-
return (
|
|
74
|
-
!e.hideLegend && e.legendPosition === t(
|
|
75
|
-
s(t(
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
return (o, r) => (n(), m(N, null, [
|
|
75
|
+
!e.hideLegend && e.legendPosition === t(g).Top ? (n(), m("div", j, [
|
|
76
|
+
s(t(K), {
|
|
77
|
+
items: Object.values(e.categories).map((i) => ({
|
|
78
|
+
...i,
|
|
79
|
+
color: Array.isArray(i.color) ? i.color[0] : i.color
|
|
80
|
+
}))
|
|
81
|
+
}, null, 8, ["items"])
|
|
82
|
+
])) : l("", !0),
|
|
83
|
+
s(t(M), {
|
|
78
84
|
data: e.data,
|
|
79
85
|
height: e.height || 600,
|
|
80
86
|
padding: e.padding,
|
|
81
87
|
scaleByDomain: !0,
|
|
82
|
-
onClick:
|
|
88
|
+
onClick: r[0] || (r[0] = (i) => v("click", i, a.value))
|
|
83
89
|
}, {
|
|
84
|
-
default:
|
|
85
|
-
e.hideTooltip ?
|
|
90
|
+
default: R(() => [
|
|
91
|
+
e.hideTooltip ? l("", !0) : (n(), c(t(S), {
|
|
86
92
|
key: 0,
|
|
87
|
-
triggers:
|
|
93
|
+
triggers: V
|
|
88
94
|
})),
|
|
89
|
-
s(t(
|
|
90
|
-
x: t(
|
|
91
|
-
y: t(
|
|
92
|
-
color:
|
|
93
|
-
size: t(
|
|
94
|
-
labelPosition: e.labelPosition || t(
|
|
95
|
+
s(t(E), {
|
|
96
|
+
x: t(T),
|
|
97
|
+
y: t(h),
|
|
98
|
+
color: B,
|
|
99
|
+
size: t(b),
|
|
100
|
+
labelPosition: e.labelPosition || t(D).Bottom,
|
|
95
101
|
sizeRange: e.sizeRange || [1, 20],
|
|
96
102
|
opacity: e.opacity,
|
|
97
103
|
cursor: "pointer"
|
|
98
104
|
}, null, 8, ["x", "y", "size", "labelPosition", "sizeRange", "opacity"]),
|
|
99
|
-
e.hideXAxis ?
|
|
105
|
+
e.hideXAxis ? l("", !0) : (n(), c(t(f), {
|
|
100
106
|
key: 1,
|
|
101
107
|
type: "x",
|
|
102
108
|
label: e.xLabel,
|
|
@@ -108,7 +114,7 @@ const X = {
|
|
|
108
114
|
tickValues: e.xExplicitTicks,
|
|
109
115
|
minMaxTicksOnly: e.minMaxTicksOnly
|
|
110
116
|
}, null, 8, ["label", "tickFormat", "gridLine", "domainLine", "tickLine", "numTicks", "tickValues", "minMaxTicksOnly"])),
|
|
111
|
-
e.hideYAxis ?
|
|
117
|
+
e.hideYAxis ? l("", !0) : (n(), c(t(f), {
|
|
112
118
|
key: 2,
|
|
113
119
|
type: "y",
|
|
114
120
|
label: e.yLabel,
|
|
@@ -121,25 +127,22 @@ const X = {
|
|
|
121
127
|
]),
|
|
122
128
|
_: 1
|
|
123
129
|
}, 8, ["data", "height", "padding"]),
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
])) : r("", !0),
|
|
127
|
-
w("div", q, [
|
|
128
|
-
t(T).tooltip ? g(i.$slots, "tooltip", {
|
|
130
|
+
O("div", W, [
|
|
131
|
+
t(L).tooltip ? p(o.$slots, "tooltip", {
|
|
129
132
|
key: 0,
|
|
130
|
-
values:
|
|
131
|
-
}) :
|
|
132
|
-
s(
|
|
133
|
-
data:
|
|
133
|
+
values: a.value
|
|
134
|
+
}) : a.value ? p(o.$slots, "fallback", { key: 1 }, () => [
|
|
135
|
+
s($, {
|
|
136
|
+
data: a.value,
|
|
134
137
|
categories: e.categories || {},
|
|
135
|
-
toolTipTitle: t(
|
|
138
|
+
toolTipTitle: t(G)(a.value) ?? "",
|
|
136
139
|
yFormatter: e.yFormatter
|
|
137
140
|
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
138
|
-
]) :
|
|
141
|
+
]) : l("", !0)
|
|
139
142
|
], 512)
|
|
140
143
|
], 64));
|
|
141
144
|
}
|
|
142
145
|
});
|
|
143
146
|
export {
|
|
144
|
-
|
|
147
|
+
J as default
|
|
145
148
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as N, computed as f, useSlots as P, useTemplateRef as O, ref as j, createElementBlock as p, openBlock as
|
|
1
|
+
import { defineComponent as N, computed as f, useSlots as P, useTemplateRef as O, ref as j, createElementBlock as p, openBlock as a, normalizeClass as w, normalizeStyle as k, createVNode as m, createCommentVNode as r, createElementVNode as M, unref as i, withCtx as W, createBlock as d, Fragment as z, renderList as E, mergeProps as G, renderSlot as h } from "vue";
|
|
2
2
|
import { Position as v, CurveType as X } from "@unovis/ts";
|
|
3
3
|
import { createMarkers as $, getFirstPropertyValue as R } from "../../utils.js";
|
|
4
4
|
import S from "../Tooltip.js";
|
|
@@ -27,10 +27,10 @@ const Q = {
|
|
|
27
27
|
curveType: {},
|
|
28
28
|
lineWidth: { default: 2 },
|
|
29
29
|
lineDashArray: {},
|
|
30
|
-
xNumTicks: { default: (
|
|
30
|
+
xNumTicks: { default: (n) => n.data.length > 24 ? 24 / 4 : n.data.length - 1 },
|
|
31
31
|
xExplicitTicks: {},
|
|
32
32
|
minMaxTicksOnly: { type: Boolean },
|
|
33
|
-
yNumTicks: { default: (
|
|
33
|
+
yNumTicks: { default: (n) => n.data.length > 24 ? 24 / 4 : n.data.length - 1 },
|
|
34
34
|
hideTooltip: { type: Boolean },
|
|
35
35
|
hideLegend: { type: Boolean },
|
|
36
36
|
legendPosition: {},
|
|
@@ -49,29 +49,29 @@ const Q = {
|
|
|
49
49
|
xDomain: {}
|
|
50
50
|
},
|
|
51
51
|
emits: ["click"],
|
|
52
|
-
setup(
|
|
53
|
-
const D = L, o =
|
|
52
|
+
setup(n, { emit: L }) {
|
|
53
|
+
const D = L, o = n, C = f(() => o.markerConfig ? $(o.markerConfig) : ""), B = P(), c = O("slotWrapper"), l = j();
|
|
54
54
|
function b(e) {
|
|
55
|
-
return typeof window > "u" ? "" :
|
|
55
|
+
return typeof window > "u" ? "" : c.value ? c.value.innerHTML : "";
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
return
|
|
57
|
+
function A(e) {
|
|
58
|
+
return l.value = e, b();
|
|
59
59
|
}
|
|
60
|
-
const
|
|
60
|
+
const y = f(
|
|
61
61
|
() => o.legendPosition === J.Top
|
|
62
|
-
),
|
|
63
|
-
(e,
|
|
64
|
-
), F = (e) => Object.values(o.categories)[e].color ??
|
|
65
|
-
return (e,
|
|
62
|
+
), V = Object.values(o.categories).map(
|
|
63
|
+
(e, s) => `var(--vis-color${s})`
|
|
64
|
+
), F = (e) => Object.values(o.categories)[e].color ?? V[e];
|
|
65
|
+
return (e, s) => (a(), p("div", {
|
|
66
66
|
style: k({
|
|
67
67
|
display: "flex",
|
|
68
|
-
flexDirection:
|
|
68
|
+
flexDirection: y.value ? "column-reverse" : "column",
|
|
69
69
|
gap: "1rem"
|
|
70
70
|
}),
|
|
71
71
|
class: w({ markers: !!o.markerConfig }),
|
|
72
|
-
onClick:
|
|
72
|
+
onClick: s[0] || (s[0] = (t) => D("click", t, l.value))
|
|
73
73
|
}, [
|
|
74
|
-
|
|
74
|
+
m(i(Y), {
|
|
75
75
|
data: e.data,
|
|
76
76
|
padding: e.padding,
|
|
77
77
|
height: e.height,
|
|
@@ -80,20 +80,20 @@ const Q = {
|
|
|
80
80
|
xDomain: e.xDomain
|
|
81
81
|
}, {
|
|
82
82
|
default: W(() => [
|
|
83
|
-
|
|
83
|
+
m(i(H), {
|
|
84
84
|
"horizontal-placement": i(v).Right,
|
|
85
85
|
"vertical-placement": i(v).Top
|
|
86
86
|
}, null, 8, ["horizontal-placement", "vertical-placement"]),
|
|
87
|
-
(
|
|
87
|
+
(a(!0), p(z, null, E(Object.keys(o.categories), (t, u) => (a(), d(i(I), {
|
|
88
88
|
key: u,
|
|
89
89
|
x: (g, x) => x,
|
|
90
|
-
y: (g) => g[
|
|
90
|
+
y: (g) => g[t],
|
|
91
91
|
color: F(u),
|
|
92
92
|
"curve-type": e.curveType ?? i(X).MonotoneX,
|
|
93
93
|
"line-width": e.lineWidth,
|
|
94
94
|
lineDashArray: e.lineDashArray ? e.lineDashArray[u] : void 0
|
|
95
95
|
}, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"]))), 128)),
|
|
96
|
-
e.hideXAxis ?
|
|
96
|
+
e.hideXAxis ? r("", !0) : (a(), d(i(T), {
|
|
97
97
|
key: 0,
|
|
98
98
|
type: "x",
|
|
99
99
|
"tick-format": e.xFormatter,
|
|
@@ -106,7 +106,7 @@ const Q = {
|
|
|
106
106
|
"tick-values": e.xExplicitTicks,
|
|
107
107
|
"min-max-ticks-only": e.minMaxTicksOnly
|
|
108
108
|
}, null, 8, ["tick-format", "label", "domain-line", "grid-line", "tick-line", "num-ticks", "tick-values", "min-max-ticks-only"])),
|
|
109
|
-
e.hideYAxis ?
|
|
109
|
+
e.hideYAxis ? r("", !0) : (a(), d(i(T), {
|
|
110
110
|
key: 1,
|
|
111
111
|
type: "y",
|
|
112
112
|
"tick-format": e.yFormatter,
|
|
@@ -116,35 +116,38 @@ const Q = {
|
|
|
116
116
|
"grid-line": e.yGridLine,
|
|
117
117
|
"tick-line": e.yTickLine
|
|
118
118
|
}, null, 8, ["tick-format", "label", "num-ticks", "domain-line", "grid-line", "tick-line"])),
|
|
119
|
-
e.hideTooltip ?
|
|
119
|
+
e.hideTooltip ? r("", !0) : (a(), d(i(U), G({ key: 2 }, e.crosshairConfig, { template: A }), null, 16))
|
|
120
120
|
]),
|
|
121
121
|
_: 1
|
|
122
122
|
}, 8, ["data", "padding", "height", "svgDefs", "yDomain", "xDomain"]),
|
|
123
|
-
e.hideLegend ?
|
|
123
|
+
e.hideLegend ? r("", !0) : (a(), p("div", {
|
|
124
124
|
key: 0,
|
|
125
125
|
style: k({
|
|
126
126
|
display: "flex",
|
|
127
127
|
alignItems: "center",
|
|
128
128
|
justifyContent: "flex-end",
|
|
129
|
-
paddingBottom:
|
|
129
|
+
paddingBottom: y.value ? "1rem" : void 0
|
|
130
130
|
})
|
|
131
131
|
}, [
|
|
132
|
-
|
|
133
|
-
items: Object.values(
|
|
132
|
+
m(i(q), {
|
|
133
|
+
items: Object.values(o.categories).map((t) => ({
|
|
134
|
+
...t,
|
|
135
|
+
color: Array.isArray(t.color) ? t.color[0] : t.color
|
|
136
|
+
}))
|
|
134
137
|
}, null, 8, ["items"])
|
|
135
138
|
], 4)),
|
|
136
139
|
M("div", Q, [
|
|
137
140
|
i(B).tooltip ? h(e.$slots, "tooltip", {
|
|
138
141
|
key: 0,
|
|
139
|
-
values:
|
|
140
|
-
}) :
|
|
141
|
-
|
|
142
|
-
data:
|
|
142
|
+
values: l.value
|
|
143
|
+
}) : l.value ? h(e.$slots, "fallback", { key: 1 }, () => [
|
|
144
|
+
m(S, {
|
|
145
|
+
data: l.value,
|
|
143
146
|
categories: e.categories,
|
|
144
|
-
toolTipTitle: i(R)(
|
|
147
|
+
toolTipTitle: i(R)(l.value) ?? "",
|
|
145
148
|
yFormatter: o.yFormatter
|
|
146
149
|
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
147
|
-
]) :
|
|
150
|
+
]) : r("", !0)
|
|
148
151
|
], 512)
|
|
149
152
|
], 6));
|
|
150
153
|
}
|