vue-chrts 0.2.0-test.4 → 0.2.0-test.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/AreaChart/AreaChart.js +3 -3
- package/dist/components/AreaChart/AreaChart2.js +36 -32
- package/dist/components/AreaChart/types.d.ts +8 -0
- package/dist/components/LineChart/LineChart.js +31 -27
- package/dist/components/LineChart/types.d.ts +8 -0
- package/dist/index.js.css +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
const f = /* @__PURE__ */ o
|
|
1
|
+
import o from "./AreaChart2.js";
|
|
2
|
+
import r from "../../_virtual/_plugin-vue_export-helper.js";
|
|
3
|
+
const f = /* @__PURE__ */ r(o, [["__scopeId", "data-v-f08e19f3"]]);
|
|
4
4
|
export {
|
|
5
5
|
f as default
|
|
6
6
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Position as b, CurveType as
|
|
3
|
-
import { createMarkers as
|
|
4
|
-
import
|
|
5
|
-
import { VisXYContainer as z, VisTooltip as I, VisArea as H, VisLine as K, VisAxis as
|
|
1
|
+
import { defineComponent as P, useSlots as W, useTemplateRef as M, ref as U, computed as u, createElementBlock as c, openBlock as a, normalizeClass as T, createVNode as d, createCommentVNode as l, createElementVNode as j, unref as i, withCtx as w, createBlock as m, Fragment as L, renderList as x, mergeProps as R, renderSlot as C } from "vue";
|
|
2
|
+
import { Position as b, CurveType as A } from "@unovis/ts";
|
|
3
|
+
import { createMarkers as X, getFirstPropertyValue as S } from "../../utils.js";
|
|
4
|
+
import Y from "../Tooltip.js";
|
|
5
|
+
import { VisXYContainer as z, VisTooltip as I, VisArea as H, VisLine as K, VisAxis as B, VisCrosshair as q, VisBulletLegend as J } from "@unovis/vue";
|
|
6
6
|
import { LegendPosition as Q } from "../../types.js";
|
|
7
7
|
const Z = {
|
|
8
8
|
ref: "slotWrapper",
|
|
9
9
|
class: "hidden"
|
|
10
|
-
}, y = 24,
|
|
10
|
+
}, y = 24, D = 4, _ = 0.5, V = "#3b82f6", ne = /* @__PURE__ */ P({
|
|
11
11
|
__name: "AreaChart",
|
|
12
12
|
props: {
|
|
13
13
|
data: {},
|
|
@@ -20,10 +20,12 @@ const Z = {
|
|
|
20
20
|
xFormatter: {},
|
|
21
21
|
yFormatter: {},
|
|
22
22
|
curveType: {},
|
|
23
|
-
|
|
23
|
+
lineWidth: { default: 2 },
|
|
24
|
+
lineDashArray: {},
|
|
25
|
+
xNumTicks: { default: (n) => n.data.length > y ? y / D : n.data.length - 1 },
|
|
24
26
|
xExplicitTicks: {},
|
|
25
27
|
minMaxTicksOnly: { type: Boolean },
|
|
26
|
-
yNumTicks: { default: (n) => n.data.length > y ? y /
|
|
28
|
+
yNumTicks: { default: (n) => n.data.length > y ? y / D : n.data.length - 1 },
|
|
27
29
|
hideLegend: { type: Boolean },
|
|
28
30
|
hideTooltip: { type: Boolean },
|
|
29
31
|
legendPosition: {},
|
|
@@ -37,9 +39,9 @@ const Z = {
|
|
|
37
39
|
hideYAxis: { type: Boolean }
|
|
38
40
|
},
|
|
39
41
|
setup(n) {
|
|
40
|
-
const r = n,
|
|
42
|
+
const r = n, F = W(), h = M("slotWrapper"), s = U(), f = u(
|
|
41
43
|
() => Object.values(r.categories).map((e) => e.color)
|
|
42
|
-
),
|
|
44
|
+
), v = u(() => r.legendPosition === Q.Top), $ = u(() => {
|
|
43
45
|
const e = (t, o) => `
|
|
44
46
|
<linearGradient id="gradient${t}-${o}" gradientTransform="rotate(90)">
|
|
45
47
|
<stop offset="0%" stop-color="${o}" stop-opacity="1" />
|
|
@@ -52,54 +54,56 @@ const Z = {
|
|
|
52
54
|
</linearGradient>
|
|
53
55
|
`;
|
|
54
56
|
return f.value.map(
|
|
55
|
-
(t, o) => t != null && t.includes("#") ? e(o, t) : p(o, t ??
|
|
57
|
+
(t, o) => t != null && t.includes("#") ? e(o, t) : p(o, t ?? V)
|
|
56
58
|
).join("");
|
|
57
|
-
}), G =
|
|
59
|
+
}), G = u(() => r.markerConfig ? X(r.markerConfig) : "");
|
|
58
60
|
function O(e) {
|
|
59
61
|
var p;
|
|
60
62
|
return {
|
|
61
63
|
y: (t) => Number(t[e]),
|
|
62
|
-
color: ((p = r.categories[e]) == null ? void 0 : p.color) ??
|
|
64
|
+
color: ((p = r.categories[e]) == null ? void 0 : p.color) ?? V
|
|
63
65
|
};
|
|
64
66
|
}
|
|
65
67
|
function N(e) {
|
|
66
|
-
return typeof window > "u" ? "" :
|
|
68
|
+
return typeof window > "u" ? "" : h.value ? h.value.innerHTML : "";
|
|
67
69
|
}
|
|
68
70
|
function E(e) {
|
|
69
71
|
return s.value = e, N();
|
|
70
72
|
}
|
|
71
|
-
return (e, p) => (a(),
|
|
72
|
-
class:
|
|
73
|
+
return (e, p) => (a(), c("div", {
|
|
74
|
+
class: T(["flex flex-col space-y-4", { "flex-col-reverse": v.value, markers: !!r.markerConfig }])
|
|
73
75
|
}, [
|
|
74
|
-
|
|
76
|
+
d(i(z), {
|
|
75
77
|
data: e.data,
|
|
76
78
|
height: e.height,
|
|
77
79
|
padding: e.padding,
|
|
78
80
|
"svg-defs": $.value + G.value
|
|
79
81
|
}, {
|
|
80
|
-
default:
|
|
82
|
+
default: w(() => [
|
|
81
83
|
e.hideTooltip ? l("", !0) : (a(), m(i(I), {
|
|
82
84
|
key: 0,
|
|
83
85
|
"horizontal-placement": i(b).Right,
|
|
84
86
|
"vertical-placement": i(b).Top
|
|
85
87
|
}, null, 8, ["horizontal-placement", "vertical-placement"])),
|
|
86
|
-
(a(!0),
|
|
87
|
-
|
|
88
|
+
(a(!0), c(L, null, x(Object.keys(r.categories), (t, o) => (a(), c(L, { key: t }, [
|
|
89
|
+
d(i(H), R({
|
|
88
90
|
x: (g, k) => k,
|
|
89
91
|
ref_for: !0
|
|
90
92
|
}, O(t), {
|
|
91
93
|
color: `url(#gradient${o}-${f.value[o]})`,
|
|
92
94
|
opacity: _,
|
|
93
|
-
"curve-type": e.curveType ?? i(
|
|
95
|
+
"curve-type": e.curveType ?? i(A).MonotoneX
|
|
94
96
|
}), null, 16, ["x", "color", "curve-type"]),
|
|
95
|
-
|
|
97
|
+
d(i(K), {
|
|
96
98
|
x: (g, k) => k,
|
|
97
99
|
y: (g) => g[t],
|
|
98
100
|
color: f.value[o],
|
|
99
|
-
"curve-type": e.curveType ?? i(
|
|
100
|
-
|
|
101
|
+
"curve-type": e.curveType ?? i(A).MonotoneX,
|
|
102
|
+
"line-width": e.lineWidth,
|
|
103
|
+
lineDashArray: e.lineDashArray
|
|
104
|
+
}, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"])
|
|
101
105
|
], 64))), 128)),
|
|
102
|
-
e.hideXAxis ? l("", !0) : (a(), m(i(
|
|
106
|
+
e.hideXAxis ? l("", !0) : (a(), m(i(B), {
|
|
103
107
|
key: 1,
|
|
104
108
|
type: "x",
|
|
105
109
|
label: e.xLabel,
|
|
@@ -112,7 +116,7 @@ const Z = {
|
|
|
112
116
|
"tick-line": e.xTickLine,
|
|
113
117
|
"min-max-ticks-only": e.minMaxTicksOnly
|
|
114
118
|
}, null, 8, ["label", "num-ticks", "tick-format", "tick-values", "grid-line", "domain-line", "tick-line", "min-max-ticks-only"])),
|
|
115
|
-
e.hideYAxis ? l("", !0) : (a(), m(i(
|
|
119
|
+
e.hideYAxis ? l("", !0) : (a(), m(i(B), {
|
|
116
120
|
key: 2,
|
|
117
121
|
type: "y",
|
|
118
122
|
label: e.yLabel,
|
|
@@ -130,23 +134,23 @@ const Z = {
|
|
|
130
134
|
]),
|
|
131
135
|
_: 1
|
|
132
136
|
}, 8, ["data", "height", "padding", "svg-defs"]),
|
|
133
|
-
e.hideLegend ? l("", !0) : (a(),
|
|
137
|
+
e.hideLegend ? l("", !0) : (a(), c("div", {
|
|
134
138
|
key: 0,
|
|
135
|
-
class:
|
|
139
|
+
class: T(["flex items-center justify-end", { "pb-4": v.value }])
|
|
136
140
|
}, [
|
|
137
|
-
|
|
141
|
+
d(i(J), {
|
|
138
142
|
items: Object.values(e.categories)
|
|
139
143
|
}, null, 8, ["items"])
|
|
140
144
|
], 2)),
|
|
141
145
|
j("div", Z, [
|
|
142
|
-
i(
|
|
146
|
+
i(F).tooltip ? C(e.$slots, "tooltip", {
|
|
143
147
|
key: 0,
|
|
144
148
|
values: s.value
|
|
145
149
|
}, void 0, !0) : s.value ? C(e.$slots, "fallback", { key: 1 }, () => [
|
|
146
|
-
|
|
150
|
+
d(Y, {
|
|
147
151
|
data: s.value,
|
|
148
152
|
categories: e.categories,
|
|
149
|
-
toolTipTitle: i(
|
|
153
|
+
toolTipTitle: i(S)(s.value) ?? "",
|
|
150
154
|
yFormatter: r.yFormatter
|
|
151
155
|
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
152
156
|
], !0) : l("", !0)
|
|
@@ -57,6 +57,14 @@ export interface AreaChartProps<T> {
|
|
|
57
57
|
* See `CurveType` for available options.
|
|
58
58
|
*/
|
|
59
59
|
curveType?: CurveType;
|
|
60
|
+
/**
|
|
61
|
+
* The width of the line in pixels. Default is 2px.
|
|
62
|
+
*/
|
|
63
|
+
lineWidth?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Line dash array, see SVG's stroke-dasharray. Default: `undefined`
|
|
66
|
+
*/
|
|
67
|
+
lineDashArray?: number[];
|
|
60
68
|
/**
|
|
61
69
|
* The desired number of ticks on the x-axis.
|
|
62
70
|
*/
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Position as
|
|
3
|
-
import { createMarkers as
|
|
4
|
-
import
|
|
5
|
-
import { VisXYContainer as
|
|
1
|
+
import { defineComponent as F, computed as f, useSlots as x, useTemplateRef as N, ref as O, createElementBlock as d, openBlock as n, normalizeClass as k, createVNode as r, createCommentVNode as l, createElementVNode as P, unref as i, withCtx as j, createBlock as s, Fragment as w, renderList as M, renderSlot as g } from "vue";
|
|
2
|
+
import { Position as h, CurveType as W } from "@unovis/ts";
|
|
3
|
+
import { createMarkers as E, getFirstPropertyValue as G } from "../../utils.js";
|
|
4
|
+
import X from "../Tooltip.js";
|
|
5
|
+
import { VisXYContainer as $, VisTooltip as z, VisLine as R, VisAxis as v, VisCrosshair as Y, VisBulletLegend as S } from "@unovis/vue";
|
|
6
6
|
import { LegendPosition as H } from "../../types.js";
|
|
7
7
|
const U = {
|
|
8
8
|
ref: "slotWrapper",
|
|
9
9
|
class: "hidden"
|
|
10
|
-
}, _ = /* @__PURE__ */
|
|
10
|
+
}, _ = /* @__PURE__ */ F({
|
|
11
11
|
__name: "LineChart",
|
|
12
12
|
props: {
|
|
13
13
|
data: {},
|
|
@@ -25,6 +25,8 @@ const U = {
|
|
|
25
25
|
xFormatter: {},
|
|
26
26
|
yFormatter: {},
|
|
27
27
|
curveType: {},
|
|
28
|
+
lineWidth: { default: 2 },
|
|
29
|
+
lineDashArray: {},
|
|
28
30
|
xNumTicks: { default: (o) => o.data.length > 24 ? 24 / 4 : o.data.length - 1 },
|
|
29
31
|
xExplicitTicks: {},
|
|
30
32
|
minMaxTicksOnly: { type: Boolean },
|
|
@@ -42,9 +44,9 @@ const U = {
|
|
|
42
44
|
hideYAxis: { type: Boolean }
|
|
43
45
|
},
|
|
44
46
|
setup(o) {
|
|
45
|
-
const t = o, T = f(() => t.markerConfig ?
|
|
47
|
+
const t = o, T = f(() => t.markerConfig ? E(t.markerConfig) : ""), L = x(), m = N("slotWrapper"), a = O();
|
|
46
48
|
function b(e) {
|
|
47
|
-
return typeof window > "u" ? "" :
|
|
49
|
+
return typeof window > "u" ? "" : m.value ? m.value.innerHTML : "";
|
|
48
50
|
}
|
|
49
51
|
function B(e) {
|
|
50
52
|
return a.value = e, b();
|
|
@@ -53,32 +55,34 @@ const U = {
|
|
|
53
55
|
() => t.legendPosition === H.Top
|
|
54
56
|
), C = Object.values(t.categories).map(
|
|
55
57
|
(e, c) => `var(--vis-color${c})`
|
|
56
|
-
),
|
|
57
|
-
return (e, c) => (n(),
|
|
58
|
+
), D = (e) => Object.values(t.categories)[e].color ?? C[e];
|
|
59
|
+
return (e, c) => (n(), d("div", {
|
|
58
60
|
class: k(["flex flex-col space-y-4", {
|
|
59
61
|
"flex-col-reverse": u.value,
|
|
60
62
|
markers: !!t.markerConfig
|
|
61
63
|
}])
|
|
62
64
|
}, [
|
|
63
|
-
r(i(
|
|
65
|
+
r(i($), {
|
|
64
66
|
data: e.data,
|
|
65
67
|
padding: e.padding,
|
|
66
68
|
height: e.height,
|
|
67
69
|
svgDefs: T.value
|
|
68
70
|
}, {
|
|
69
|
-
default:
|
|
70
|
-
r(i(
|
|
71
|
-
"horizontal-placement": i(
|
|
72
|
-
"vertical-placement": i(
|
|
71
|
+
default: j(() => [
|
|
72
|
+
r(i(z), {
|
|
73
|
+
"horizontal-placement": i(h).Right,
|
|
74
|
+
"vertical-placement": i(h).Top
|
|
73
75
|
}, null, 8, ["horizontal-placement", "vertical-placement"]),
|
|
74
|
-
(n(!0),
|
|
76
|
+
(n(!0), d(w, null, M(Object.keys(t.categories), (V, p) => (n(), s(i(R), {
|
|
75
77
|
key: p,
|
|
76
|
-
x: (y,
|
|
77
|
-
y: (y) => y[
|
|
78
|
-
color:
|
|
79
|
-
"curve-type": e.curveType ?? i(
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
x: (y, A) => A,
|
|
79
|
+
y: (y) => y[V],
|
|
80
|
+
color: D(p),
|
|
81
|
+
"curve-type": e.curveType ?? i(W).MonotoneX,
|
|
82
|
+
"line-width": e.lineWidth,
|
|
83
|
+
lineDashArray: e.lineDashArray
|
|
84
|
+
}, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"]))), 128)),
|
|
85
|
+
e.hideXAxis ? l("", !0) : (n(), s(i(v), {
|
|
82
86
|
key: 0,
|
|
83
87
|
type: "x",
|
|
84
88
|
"tick-format": e.xFormatter,
|
|
@@ -91,7 +95,7 @@ const U = {
|
|
|
91
95
|
"tick-values": e.xExplicitTicks,
|
|
92
96
|
"min-max-ticks-only": e.minMaxTicksOnly
|
|
93
97
|
}, null, 8, ["tick-format", "label", "domain-line", "grid-line", "tick-line", "num-ticks", "tick-values", "min-max-ticks-only"])),
|
|
94
|
-
e.hideYAxis ? l("", !0) : (n(), s(i(
|
|
98
|
+
e.hideYAxis ? l("", !0) : (n(), s(i(v), {
|
|
95
99
|
key: 1,
|
|
96
100
|
type: "y",
|
|
97
101
|
"tick-format": e.yFormatter,
|
|
@@ -109,7 +113,7 @@ const U = {
|
|
|
109
113
|
]),
|
|
110
114
|
_: 1
|
|
111
115
|
}, 8, ["data", "padding", "height", "svgDefs"]),
|
|
112
|
-
e.hideLegend ? l("", !0) : (n(),
|
|
116
|
+
e.hideLegend ? l("", !0) : (n(), d("div", {
|
|
113
117
|
key: 0,
|
|
114
118
|
class: k(["flex items center justify-end", { "pb-4": u.value }])
|
|
115
119
|
}, [
|
|
@@ -117,15 +121,15 @@ const U = {
|
|
|
117
121
|
items: Object.values(e.categories)
|
|
118
122
|
}, null, 8, ["items"])
|
|
119
123
|
], 2)),
|
|
120
|
-
|
|
124
|
+
P("div", U, [
|
|
121
125
|
i(L).tooltip ? g(e.$slots, "tooltip", {
|
|
122
126
|
key: 0,
|
|
123
127
|
values: a.value
|
|
124
128
|
}) : a.value ? g(e.$slots, "fallback", { key: 1 }, () => [
|
|
125
|
-
r(
|
|
129
|
+
r(X, {
|
|
126
130
|
data: a.value,
|
|
127
131
|
categories: e.categories,
|
|
128
|
-
toolTipTitle: i(
|
|
132
|
+
toolTipTitle: i(G)(a.value) ?? "",
|
|
129
133
|
yFormatter: t.yFormatter
|
|
130
134
|
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
131
135
|
]) : l("", !0)
|
|
@@ -56,6 +56,14 @@ export interface LineChartProps<T> {
|
|
|
56
56
|
* See `CurveType` for available options.
|
|
57
57
|
*/
|
|
58
58
|
curveType?: CurveType;
|
|
59
|
+
/**
|
|
60
|
+
* The width of the line in pixels. Default is 2px.
|
|
61
|
+
*/
|
|
62
|
+
lineWidth?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Line dash array, see SVG's stroke-dasharray. Default: `undefined`
|
|
65
|
+
*/
|
|
66
|
+
lineDashArray?: number[];
|
|
59
67
|
/**
|
|
60
68
|
* The desired number of ticks on the x-axis.
|
|
61
69
|
*/
|
package/dist/index.js.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.markers[data-v-
|
|
1
|
+
.markers[data-v-f08e19f3] *[stroke="#156F36"]{marker:url(#circle-marker-desktop)}.markers[data-v-f08e19f3] *[stroke="#4ade80"]{marker:url(#circle-marker-mobile)}
|