vue-chrts 0.2.4 → 0.2.5-test.2
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 +107 -79
- package/dist/components/AreaChart/types.d.ts +15 -0
- package/dist/components/BarChart/BarChart.js +160 -122
- package/dist/components/BarChart/BarChart.vue.d.ts +1 -1
- package/dist/components/BarChart/types.d.ts +27 -11
- package/dist/components/BubbleChart/BubbleChart.js +74 -56
- package/dist/components/BubbleChart/types.d.ts +4 -0
- package/dist/components/DonutChart/DonutChart.js +81 -75
- package/dist/components/DonutChart/types.d.ts +10 -0
- package/dist/components/LineChart/LineChart.js +26 -127
- package/dist/components/LineChart/LineChart.vue.d.ts +3 -10
- package/dist/components/LineChart/types.d.ts +2 -140
- package/dist/components/Tooltip.js +24 -24
- package/dist/index.d.ts +1 -2
- package/dist/index.js +14 -16
- package/dist/types.d.ts +6 -2
- package/dist/types.js +4 -4
- 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
|
@@ -101,6 +101,10 @@ type BarChartPropsBase<T> = {
|
|
|
101
101
|
* See `LegendPosition` for available options.
|
|
102
102
|
*/
|
|
103
103
|
legendPosition?: LegendPosition;
|
|
104
|
+
/**
|
|
105
|
+
* Optional style object for the legend container. Allows custom CSS styling.
|
|
106
|
+
*/
|
|
107
|
+
legendStyle?: string | Record<string, string>;
|
|
104
108
|
/**
|
|
105
109
|
* If `true`, displays a domain line (axis line) along the x-axis.
|
|
106
110
|
*/
|
|
@@ -133,23 +137,35 @@ type BarChartPropsBase<T> = {
|
|
|
133
137
|
* If `true`, hide the y-axis.
|
|
134
138
|
*/
|
|
135
139
|
hideYAxis?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Specific spacing between stacked and grouped bars in pixels.
|
|
142
|
+
* Only applicable if `stackAndGrouped` is `true`.
|
|
143
|
+
*/
|
|
136
144
|
stackedGroupedSpacing?: number;
|
|
137
145
|
};
|
|
138
|
-
type
|
|
139
|
-
stackAndGrouped: true;
|
|
146
|
+
export type BarChartProps<T> = BarChartPropsBase<T> & {
|
|
140
147
|
/**
|
|
141
|
-
*
|
|
142
|
-
*
|
|
148
|
+
* Whether the bars should be stacked and grouped.
|
|
149
|
+
* If true, `valueLabel` is optional and `xAxis` is required.
|
|
143
150
|
*/
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
stackAndGrouped?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Configuration for the value label display.
|
|
154
|
+
* Required if `stackAndGrouped` is false and `xAxis` is present.
|
|
155
|
+
* Optional otherwise.
|
|
156
|
+
*/
|
|
157
|
+
valueLabel?: ValueLabel;
|
|
148
158
|
/**
|
|
149
|
-
* The
|
|
150
|
-
*
|
|
159
|
+
* The data key for the X-axis.
|
|
160
|
+
* Required if `stackAndGrouped` is true, or if `stackAndGrouped` is false AND `valueLabel` is present.
|
|
151
161
|
*/
|
|
152
162
|
xAxis?: keyof T;
|
|
153
163
|
};
|
|
154
|
-
export type
|
|
164
|
+
export type ValueLabel = {
|
|
165
|
+
label: (d: any, index: number) => string | number;
|
|
166
|
+
labelSpacing?: number;
|
|
167
|
+
backgroundColor?: string;
|
|
168
|
+
color?: string;
|
|
169
|
+
labelFontSize?: number;
|
|
170
|
+
};
|
|
155
171
|
export {};
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Scatter as
|
|
3
|
-
import {
|
|
4
|
-
import { LegendPosition as
|
|
5
|
-
import { getFirstPropertyValue as
|
|
6
|
-
import
|
|
7
|
-
const
|
|
8
|
-
key: 0,
|
|
9
|
-
class: "flex items-center justify-end pb-4"
|
|
10
|
-
}, Y = {
|
|
11
|
-
key: 1,
|
|
12
|
-
class: "flex items-center justify-end pt-4"
|
|
13
|
-
}, q = {
|
|
1
|
+
import { defineComponent as N, useSlots as O, useTemplateRef as S, ref as _, computed as m, createElementBlock as f, openBlock as l, normalizeStyle as c, createVNode as s, createCommentVNode as r, createElementVNode as D, unref as t, withCtx as R, createBlock as d, renderSlot as g } from "vue";
|
|
2
|
+
import { Scatter as w, Position as K } from "@unovis/ts";
|
|
3
|
+
import { VisXYContainer as M, VisTooltip as E, VisScatter as G, VisAxis as k, VisBulletLegend as W } from "@unovis/vue";
|
|
4
|
+
import { LegendPosition as $ } from "../../types.js";
|
|
5
|
+
import { getFirstPropertyValue as j } from "../../utils.js";
|
|
6
|
+
import X from "../Tooltip.js";
|
|
7
|
+
const Y = {
|
|
14
8
|
ref: "slotWrapper",
|
|
15
9
|
class: "hidden"
|
|
16
|
-
},
|
|
10
|
+
}, Z = /* @__PURE__ */ N({
|
|
17
11
|
__name: "BubbleChart",
|
|
18
12
|
props: {
|
|
19
13
|
xAccessor: {},
|
|
@@ -34,7 +28,8 @@ const X = {
|
|
|
34
28
|
categoryKey: {},
|
|
35
29
|
xFormatter: {},
|
|
36
30
|
yFormatter: {},
|
|
37
|
-
legendPosition: { default:
|
|
31
|
+
legendPosition: { default: $.BottomCenter },
|
|
32
|
+
legendStyle: { default: void 0 },
|
|
38
33
|
sizeOptions: {},
|
|
39
34
|
xDomainLine: { type: Boolean, default: !0 },
|
|
40
35
|
yDomainLine: { type: Boolean, default: !0 },
|
|
@@ -52,51 +47,58 @@ const X = {
|
|
|
52
47
|
}) }
|
|
53
48
|
},
|
|
54
49
|
emits: ["click"],
|
|
55
|
-
setup(
|
|
56
|
-
const e =
|
|
57
|
-
var
|
|
50
|
+
setup(x, { emit: L }) {
|
|
51
|
+
const e = x, T = O(), u = S("slotWrapper"), a = _(), h = e.xAccessor, v = e.yAccessor, b = e.sizeAccessor || ((i) => typeof i.comments == "number" ? i.comments : 1), B = (i) => {
|
|
52
|
+
var y, p;
|
|
58
53
|
if (!e.categories || !e.categoryKey)
|
|
59
|
-
return console.warn(
|
|
54
|
+
return console.warn(
|
|
55
|
+
"BubbleChart: categories and categoryKey are required for color mapping"
|
|
56
|
+
), "#cccccc";
|
|
60
57
|
const n = String(i[e.categoryKey]);
|
|
61
|
-
let
|
|
62
|
-
return Object.keys(e.categories).length === 1 && (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
58
|
+
let o = (y = e.categories[n]) == null ? void 0 : y.color;
|
|
59
|
+
return Object.keys(e.categories).length === 1 && (o = (p = e.categories[e.categoryKey]) == null ? void 0 : p.color), o || (console.warn(
|
|
60
|
+
`BubbleChart: No color defined for category "${n}"`
|
|
61
|
+
), "#cccccc");
|
|
62
|
+
}, A = L;
|
|
67
63
|
function C(i) {
|
|
68
|
-
return
|
|
64
|
+
return a.value = i, V();
|
|
65
|
+
}
|
|
66
|
+
function V(i) {
|
|
67
|
+
return typeof window > "u" ? "" : u.value ? u.value.innerHTML : "";
|
|
69
68
|
}
|
|
70
|
-
const
|
|
71
|
-
[
|
|
72
|
-
};
|
|
73
|
-
return (i, n) => (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
69
|
+
const F = {
|
|
70
|
+
[w.selectors.point]: C
|
|
71
|
+
}, z = m(() => e.legendPosition.startsWith("top")), P = m(() => e.legendPosition.includes("left") ? "flex-start" : e.legendPosition.includes("right") ? "flex-end" : "center");
|
|
72
|
+
return (i, n) => (l(), f("div", {
|
|
73
|
+
style: c({
|
|
74
|
+
display: "flex",
|
|
75
|
+
flexDirection: z.value ? "column-reverse" : "column",
|
|
76
|
+
gap: "var(--vis-legend-spacing)"
|
|
77
|
+
})
|
|
78
|
+
}, [
|
|
79
|
+
s(t(M), {
|
|
78
80
|
data: e.data,
|
|
79
81
|
height: e.height || 600,
|
|
80
82
|
padding: e.padding,
|
|
81
83
|
scaleByDomain: !0,
|
|
82
|
-
onClick: n[0] || (n[0] = (
|
|
84
|
+
onClick: n[0] || (n[0] = (o) => A("click", o, a.value))
|
|
83
85
|
}, {
|
|
84
|
-
default:
|
|
85
|
-
e.hideTooltip ? r("", !0) : (
|
|
86
|
+
default: R(() => [
|
|
87
|
+
e.hideTooltip ? r("", !0) : (l(), d(t(E), {
|
|
86
88
|
key: 0,
|
|
87
|
-
triggers:
|
|
89
|
+
triggers: F
|
|
88
90
|
})),
|
|
89
91
|
s(t(G), {
|
|
90
|
-
x: t(
|
|
91
|
-
y: t(
|
|
92
|
-
color:
|
|
93
|
-
size: t(
|
|
94
|
-
labelPosition: e.labelPosition || t(
|
|
92
|
+
x: t(h),
|
|
93
|
+
y: t(v),
|
|
94
|
+
color: B,
|
|
95
|
+
size: t(b),
|
|
96
|
+
labelPosition: e.labelPosition || t(K).Bottom,
|
|
95
97
|
sizeRange: e.sizeRange || [1, 20],
|
|
96
98
|
opacity: e.opacity,
|
|
97
99
|
cursor: "pointer"
|
|
98
100
|
}, null, 8, ["x", "y", "size", "labelPosition", "sizeRange", "opacity"]),
|
|
99
|
-
e.hideXAxis ? r("", !0) : (
|
|
101
|
+
e.hideXAxis ? r("", !0) : (l(), d(t(k), {
|
|
100
102
|
key: 1,
|
|
101
103
|
type: "x",
|
|
102
104
|
label: e.xLabel,
|
|
@@ -108,7 +110,7 @@ const X = {
|
|
|
108
110
|
tickValues: e.xExplicitTicks,
|
|
109
111
|
minMaxTicksOnly: e.minMaxTicksOnly
|
|
110
112
|
}, null, 8, ["label", "tickFormat", "gridLine", "domainLine", "tickLine", "numTicks", "tickValues", "minMaxTicksOnly"])),
|
|
111
|
-
e.hideYAxis ? r("", !0) : (
|
|
113
|
+
e.hideYAxis ? r("", !0) : (l(), d(t(k), {
|
|
112
114
|
key: 2,
|
|
113
115
|
type: "y",
|
|
114
116
|
label: e.yLabel,
|
|
@@ -121,25 +123,41 @@ const X = {
|
|
|
121
123
|
]),
|
|
122
124
|
_: 1
|
|
123
125
|
}, 8, ["data", "height", "padding"]),
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
e.hideLegend ? r("", !0) : (l(), f("div", {
|
|
127
|
+
key: 0,
|
|
128
|
+
style: c({
|
|
129
|
+
display: "flex",
|
|
130
|
+
justifyContent: P.value
|
|
131
|
+
})
|
|
132
|
+
}, [
|
|
133
|
+
s(t(W), {
|
|
134
|
+
class: "bulletLegendOverrides",
|
|
135
|
+
style: c([
|
|
136
|
+
e.legendStyle,
|
|
137
|
+
"display: flex; gap: var(--vis-legend-spacing);"
|
|
138
|
+
]),
|
|
139
|
+
items: Object.values(e.categories).map((o) => ({
|
|
140
|
+
...o,
|
|
141
|
+
color: Array.isArray(o.color) ? o.color[0] : o.color
|
|
142
|
+
}))
|
|
143
|
+
}, null, 8, ["style", "items"])
|
|
144
|
+
], 4)),
|
|
145
|
+
D("div", Y, [
|
|
128
146
|
t(T).tooltip ? g(i.$slots, "tooltip", {
|
|
129
147
|
key: 0,
|
|
130
|
-
values:
|
|
131
|
-
}) :
|
|
132
|
-
s(
|
|
133
|
-
data:
|
|
148
|
+
values: a.value
|
|
149
|
+
}) : a.value ? g(i.$slots, "fallback", { key: 1 }, () => [
|
|
150
|
+
s(X, {
|
|
151
|
+
data: a.value,
|
|
134
152
|
categories: e.categories || {},
|
|
135
|
-
toolTipTitle: t(
|
|
153
|
+
toolTipTitle: t(j)(a.value) ?? "",
|
|
136
154
|
yFormatter: e.yFormatter
|
|
137
155
|
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
138
156
|
]) : r("", !0)
|
|
139
157
|
], 512)
|
|
140
|
-
],
|
|
158
|
+
], 4));
|
|
141
159
|
}
|
|
142
160
|
});
|
|
143
161
|
export {
|
|
144
|
-
|
|
162
|
+
Z as default
|
|
145
163
|
};
|
|
@@ -107,6 +107,10 @@ export interface BubbleChartProps<T> {
|
|
|
107
107
|
* See `LegendPosition` for available options.
|
|
108
108
|
*/
|
|
109
109
|
legendPosition?: LegendPosition;
|
|
110
|
+
/**
|
|
111
|
+
* Optional inline CSS styles for the legend container.
|
|
112
|
+
*/
|
|
113
|
+
legendStyle?: Record<string, string>;
|
|
110
114
|
/** Options for controlling bubble sizes. */
|
|
111
115
|
sizeOptions?: SizeOptions;
|
|
112
116
|
/**
|
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Donut as
|
|
1
|
+
import { defineComponent as w, useSlots as D, useTemplateRef as L, ref as T, computed as g, createElementBlock as p, openBlock as f, normalizeStyle as o, createVNode as r, createCommentVNode as m, renderSlot as d, createElementVNode as a, unref as i, withCtx as B, toDisplayString as P } from "vue";
|
|
2
|
+
import { Donut as W } from "@unovis/ts";
|
|
3
3
|
import { DonutType as R } from "./types.js";
|
|
4
|
-
import { VisSingleContainer as
|
|
5
|
-
|
|
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
|
-
}, M = /* @__PURE__ */ V({
|
|
9
|
+
}, j = { style: { display: "flex", "align-items": "center", padding: "10px 15px" } }, I = /* @__PURE__ */ w({
|
|
17
10
|
__name: "DonutChart",
|
|
18
11
|
props: {
|
|
19
12
|
type: {},
|
|
@@ -22,78 +15,91 @@ const z = {
|
|
|
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
|
|
24
|
+
setup(l, { emit: h }) {
|
|
25
|
+
const v = h, e = l, y = D(), u = L("slotWrapper"), n = T(), x = (t) => t, C = e.type === R.Half;
|
|
26
|
+
function k(t) {
|
|
27
|
+
return n.value = t, V();
|
|
33
28
|
}
|
|
34
|
-
function
|
|
35
|
-
return typeof window > "u" ? "" :
|
|
29
|
+
function V(t) {
|
|
30
|
+
return typeof window > "u" ? "" : u.value ? u.value.innerHTML : "";
|
|
36
31
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
const b = g(() => e.legendPosition.includes("top")), S = g(() => e.legendPosition.includes("left") ? "flex-start" : e.legendPosition.includes("right") ? "flex-end" : "center");
|
|
33
|
+
return (t, c) => (f(), p("div", {
|
|
34
|
+
style: o({
|
|
35
|
+
display: "flex",
|
|
36
|
+
flexDirection: b.value ? "column-reverse" : "column",
|
|
37
|
+
gap: "var(--vis-legend-spacing)"
|
|
38
|
+
}),
|
|
39
|
+
onClick: c[0] || (c[0] = (s) => v("click", s, n.value))
|
|
40
|
+
}, [
|
|
41
|
+
r(i(A), {
|
|
42
|
+
data: l.data,
|
|
43
|
+
height: l.height,
|
|
44
|
+
margin: {}
|
|
45
|
+
}, {
|
|
46
|
+
default: B(() => [
|
|
47
|
+
r(i(H), {
|
|
48
|
+
"horizontal-shift": 20,
|
|
49
|
+
"vertical-shift": 20,
|
|
50
|
+
triggers: {
|
|
51
|
+
[i(W).selectors.segment]: k
|
|
52
|
+
}
|
|
53
|
+
}, null, 8, ["triggers"]),
|
|
54
|
+
r(i(N), {
|
|
55
|
+
value: x,
|
|
56
|
+
"corner-radius": l.radius,
|
|
57
|
+
"arc-width": l.arcWidth ?? 20,
|
|
58
|
+
color: e.labels.map((s) => s.color),
|
|
59
|
+
"angle-range": C ? [-1.5707963267948966, 1.5707963267948966] : [],
|
|
60
|
+
"pad-angle": e.padAngle || 0
|
|
61
|
+
}, null, 8, ["corner-radius", "arc-width", "color", "angle-range", "pad-angle"])
|
|
62
|
+
]),
|
|
63
|
+
_: 1
|
|
64
|
+
}, 8, ["data", "height"]),
|
|
65
|
+
e.hideLegend ? m("", !0) : (f(), p("div", {
|
|
66
|
+
key: 0,
|
|
67
|
+
style: o({
|
|
40
68
|
display: "flex",
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
onClick: d[0] || (d[0] = (a) => f("click", a, t.value))
|
|
69
|
+
justifyContent: S.value
|
|
70
|
+
})
|
|
45
71
|
}, [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}, {
|
|
51
|
-
default: S(() => [
|
|
52
|
-
o(l(N), {
|
|
53
|
-
"horizontal-shift": 20,
|
|
54
|
-
"vertical-shift": 20,
|
|
55
|
-
triggers: {
|
|
56
|
-
[l(L).selectors.segment]: C
|
|
57
|
-
}
|
|
58
|
-
}, null, 8, ["triggers"]),
|
|
59
|
-
o(l($), {
|
|
60
|
-
value: y,
|
|
61
|
-
"corner-radius": e.radius,
|
|
62
|
-
"arc-width": e.arcWidth ?? 20,
|
|
63
|
-
color: r.labels.map((a) => a.color),
|
|
64
|
-
"angle-range": v ? [-1.5707963267948966, 1.5707963267948966] : [],
|
|
65
|
-
"pad-angle": r.padAngle || 0
|
|
66
|
-
}, null, 8, ["corner-radius", "arc-width", "color", "angle-range", "pad-angle"])
|
|
72
|
+
r(i($), {
|
|
73
|
+
style: o([
|
|
74
|
+
e.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
|
-
o(l(j), { items: e.labels }, null, 8, ["items"])
|
|
93
|
-
]))
|
|
94
|
-
], 64));
|
|
77
|
+
items: l.labels
|
|
78
|
+
}, null, 8, ["style", "items"])
|
|
79
|
+
], 4)),
|
|
80
|
+
d(t.$slots, "default"),
|
|
81
|
+
a("div", E, [
|
|
82
|
+
i(y).tooltip ? d(t.$slots, "tooltip", {
|
|
83
|
+
key: 0,
|
|
84
|
+
values: n.value
|
|
85
|
+
}) : n.value ? d(t.$slots, "fallback", { key: 1 }, () => [
|
|
86
|
+
a("div", j, [
|
|
87
|
+
a("div", {
|
|
88
|
+
style: o({
|
|
89
|
+
width: "0.5rem",
|
|
90
|
+
height: "0.5rem",
|
|
91
|
+
borderRadius: "9999px",
|
|
92
|
+
marginRight: "0.5rem",
|
|
93
|
+
backgroundColor: e.labels[n.value.index].color
|
|
94
|
+
})
|
|
95
|
+
}, null, 4),
|
|
96
|
+
a("div", null, P(n.value.data), 1)
|
|
97
|
+
])
|
|
98
|
+
]) : m("", !0)
|
|
99
|
+
], 512)
|
|
100
|
+
], 4));
|
|
95
101
|
}
|
|
96
102
|
});
|
|
97
103
|
export {
|
|
98
|
-
|
|
104
|
+
I 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,154 +1,53 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { VisXYContainer as Y, VisTooltip as H, VisLine as I, VisAxis as T, VisCrosshair as U, VisBulletLegend as q } from "@unovis/vue";
|
|
6
|
-
import { LegendPosition as J } from "../../types.js";
|
|
7
|
-
const Q = {
|
|
8
|
-
ref: "slotWrapper",
|
|
9
|
-
style: { display: "none" }
|
|
10
|
-
}, te = /* @__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: {
|
|
34
|
-
hideTooltip: { type: Boolean },
|
|
22
|
+
yNumTicks: {},
|
|
35
23
|
hideLegend: { type: Boolean },
|
|
24
|
+
hideTooltip: { type: Boolean },
|
|
36
25
|
legendPosition: {},
|
|
37
|
-
|
|
26
|
+
legendStyle: {},
|
|
38
27
|
xDomainLine: { type: Boolean },
|
|
39
|
-
yGridLine: { type: Boolean },
|
|
40
28
|
yDomainLine: { type: Boolean },
|
|
41
29
|
xTickLine: { type: Boolean },
|
|
42
30
|
yTickLine: { type: Boolean },
|
|
31
|
+
xGridLine: { type: Boolean },
|
|
32
|
+
yGridLine: { type: Boolean },
|
|
43
33
|
hideXAxis: { type: Boolean },
|
|
44
34
|
hideYAxis: { type: Boolean },
|
|
45
|
-
crosshairConfig: {
|
|
46
|
-
color: "#666"
|
|
47
|
-
}) },
|
|
35
|
+
crosshairConfig: {},
|
|
48
36
|
yDomain: {},
|
|
49
37
|
xDomain: {}
|
|
50
38
|
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
() => o.legendPosition === J.Top
|
|
62
|
-
), A = Object.values(o.categories).map(
|
|
63
|
-
(e, r) => `var(--vis-color${r})`
|
|
64
|
-
), F = (e) => Object.values(o.categories)[e].color ?? A[e];
|
|
65
|
-
return (e, r) => (n(), p("div", {
|
|
66
|
-
style: k({
|
|
67
|
-
display: "flex",
|
|
68
|
-
flexDirection: c.value ? "column-reverse" : "column",
|
|
69
|
-
gap: "1rem"
|
|
70
|
-
}),
|
|
71
|
-
class: w({ markers: !!o.markerConfig }),
|
|
72
|
-
onClick: r[0] || (r[0] = (d) => D("click", d, a.value))
|
|
73
|
-
}, [
|
|
74
|
-
s(i(Y), {
|
|
75
|
-
data: e.data,
|
|
76
|
-
padding: e.padding,
|
|
77
|
-
height: e.height,
|
|
78
|
-
svgDefs: C.value,
|
|
79
|
-
yDomain: e.yDomain,
|
|
80
|
-
xDomain: e.xDomain
|
|
81
|
-
}, {
|
|
82
|
-
default: W(() => [
|
|
83
|
-
s(i(H), {
|
|
84
|
-
"horizontal-placement": i(v).Right,
|
|
85
|
-
"vertical-placement": i(v).Top
|
|
86
|
-
}, null, 8, ["horizontal-placement", "vertical-placement"]),
|
|
87
|
-
(n(!0), p(z, null, E(Object.keys(o.categories), (d, u) => (n(), m(i(I), {
|
|
88
|
-
key: u,
|
|
89
|
-
x: (g, x) => x,
|
|
90
|
-
y: (g) => g[d],
|
|
91
|
-
color: F(u),
|
|
92
|
-
"curve-type": e.curveType ?? i(X).MonotoneX,
|
|
93
|
-
"line-width": e.lineWidth,
|
|
94
|
-
lineDashArray: e.lineDashArray ? e.lineDashArray[u] : void 0
|
|
95
|
-
}, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"]))), 128)),
|
|
96
|
-
e.hideXAxis ? l("", !0) : (n(), m(i(T), {
|
|
97
|
-
key: 0,
|
|
98
|
-
type: "x",
|
|
99
|
-
"tick-format": e.xFormatter,
|
|
100
|
-
label: e.xLabel,
|
|
101
|
-
"label-margin": 8,
|
|
102
|
-
"domain-line": e.xDomainLine,
|
|
103
|
-
"grid-line": e.xGridLine,
|
|
104
|
-
"tick-line": e.xTickLine,
|
|
105
|
-
"num-ticks": e.xNumTicks,
|
|
106
|
-
"tick-values": e.xExplicitTicks,
|
|
107
|
-
"min-max-ticks-only": e.minMaxTicksOnly
|
|
108
|
-
}, null, 8, ["tick-format", "label", "domain-line", "grid-line", "tick-line", "num-ticks", "tick-values", "min-max-ticks-only"])),
|
|
109
|
-
e.hideYAxis ? l("", !0) : (n(), m(i(T), {
|
|
110
|
-
key: 1,
|
|
111
|
-
type: "y",
|
|
112
|
-
"tick-format": e.yFormatter,
|
|
113
|
-
label: e.yLabel,
|
|
114
|
-
"num-ticks": e.yNumTicks,
|
|
115
|
-
"domain-line": e.yDomainLine,
|
|
116
|
-
"grid-line": e.yGridLine,
|
|
117
|
-
"tick-line": e.yTickLine
|
|
118
|
-
}, null, 8, ["tick-format", "label", "num-ticks", "domain-line", "grid-line", "tick-line"])),
|
|
119
|
-
e.hideTooltip ? l("", !0) : (n(), m(i(U), G({ key: 2 }, e.crosshairConfig, { template: V }), null, 16))
|
|
120
|
-
]),
|
|
121
|
-
_: 1
|
|
122
|
-
}, 8, ["data", "padding", "height", "svgDefs", "yDomain", "xDomain"]),
|
|
123
|
-
e.hideLegend ? l("", !0) : (n(), p("div", {
|
|
124
|
-
key: 0,
|
|
125
|
-
style: k({
|
|
126
|
-
display: "flex",
|
|
127
|
-
alignItems: "center",
|
|
128
|
-
justifyContent: "flex-end",
|
|
129
|
-
paddingBottom: c.value ? "1rem" : void 0
|
|
130
|
-
})
|
|
131
|
-
}, [
|
|
132
|
-
s(i(q), {
|
|
133
|
-
items: Object.values(e.categories)
|
|
134
|
-
}, null, 8, ["items"])
|
|
135
|
-
], 4)),
|
|
136
|
-
M("div", Q, [
|
|
137
|
-
i(B).tooltip ? h(e.$slots, "tooltip", {
|
|
138
|
-
key: 0,
|
|
139
|
-
values: a.value
|
|
140
|
-
}) : a.value ? h(e.$slots, "fallback", { key: 1 }, () => [
|
|
141
|
-
s(S, {
|
|
142
|
-
data: a.value,
|
|
143
|
-
categories: e.categories,
|
|
144
|
-
toolTipTitle: i(R)(a.value) ?? "",
|
|
145
|
-
yFormatter: o.yFormatter
|
|
146
|
-
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
147
|
-
]) : l("", !0)
|
|
148
|
-
], 512)
|
|
149
|
-
], 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));
|
|
150
49
|
}
|
|
151
50
|
});
|
|
152
51
|
export {
|
|
153
|
-
|
|
52
|
+
g as default
|
|
154
53
|
};
|