vue-chrts 0.2.0-beta.2 → 0.2.0-beta.3
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 +19 -19
- package/dist/components/AreaChart/types.d.ts +3 -17
- package/dist/components/LineChart/LineChart.js +24 -24
- package/dist/components/LineChart/types.d.ts +3 -17
- package/dist/index.d.ts +2 -2
- package/dist/types.d.ts +15 -0
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as U, useSlots as j, useTemplateRef as w, ref as R, computed as d, createElementBlock as c, openBlock as a, normalizeClass as T, createVNode as u, createCommentVNode as p, createElementVNode as X, unref as i, withCtx as
|
|
2
|
-
import { Position as
|
|
3
|
-
import { createMarkers as
|
|
4
|
-
import
|
|
5
|
-
import { VisXYContainer as H, VisTooltip as K, VisArea as q, VisLine as J, VisAxis as
|
|
1
|
+
import { defineComponent as U, useSlots as j, useTemplateRef as w, ref as R, computed as d, createElementBlock as c, openBlock as a, normalizeClass as T, createVNode as u, createCommentVNode as p, createElementVNode as X, unref as i, withCtx as S, createBlock as m, Fragment as L, renderList as Y, mergeProps as C, renderSlot as A } from "vue";
|
|
2
|
+
import { Position as b, CurveType as D } from "@unovis/ts";
|
|
3
|
+
import { createMarkers as z, getFirstPropertyValue as I } from "../../utils.js";
|
|
4
|
+
import x from "../Tooltip.js";
|
|
5
|
+
import { VisXYContainer as H, VisTooltip as K, VisArea as q, VisLine as J, VisAxis as B, VisCrosshair as Q, VisBulletLegend as Z } from "@unovis/vue";
|
|
6
6
|
import { LegendPosition as _ } from "../../types.js";
|
|
7
7
|
const ee = {
|
|
8
8
|
ref: "slotWrapper",
|
|
@@ -45,7 +45,7 @@ const ee = {
|
|
|
45
45
|
setup(n, { emit: $ }) {
|
|
46
46
|
const G = $, r = n, O = j(), h = w("slotWrapper"), s = R(), f = d(
|
|
47
47
|
() => Object.values(r.categories).map((e) => e.color)
|
|
48
|
-
), N = d(() => r.markerConfig ?
|
|
48
|
+
), N = d(() => r.markerConfig ? z(r.markerConfig) : ""), g = d(() => r.legendPosition === _.Top), E = d(() => {
|
|
49
49
|
const e = (t, o) => `
|
|
50
50
|
<linearGradient id="gradient${t}-${o}" gradientTransform="rotate(90)">
|
|
51
51
|
<stop offset="0%" stop-color="${o}" stop-opacity="1" />
|
|
@@ -84,30 +84,30 @@ const ee = {
|
|
|
84
84
|
padding: e.padding,
|
|
85
85
|
"svg-defs": E.value + N.value
|
|
86
86
|
}, {
|
|
87
|
-
default:
|
|
87
|
+
default: S(() => [
|
|
88
88
|
e.hideTooltip ? p("", !0) : (a(), m(i(K), {
|
|
89
89
|
key: 0,
|
|
90
|
-
"horizontal-placement": i(
|
|
91
|
-
"vertical-placement": i(
|
|
90
|
+
"horizontal-placement": i(b).Right,
|
|
91
|
+
"vertical-placement": i(b).Top
|
|
92
92
|
}, null, 8, ["horizontal-placement", "vertical-placement"])),
|
|
93
|
-
(a(!0), c(L, null,
|
|
93
|
+
(a(!0), c(L, null, Y(Object.keys(r.categories), (t, o) => (a(), c(L, { key: t }, [
|
|
94
94
|
u(i(q), C({
|
|
95
95
|
x: (k, v) => v
|
|
96
96
|
}, { ref_for: !0 }, P(t), {
|
|
97
97
|
color: `url(#gradient${o}-${f.value[o]})`,
|
|
98
98
|
opacity: te,
|
|
99
|
-
"curve-type": e.curveType ?? i(
|
|
99
|
+
"curve-type": e.curveType ?? i(D).MonotoneX
|
|
100
100
|
}), null, 16, ["x", "color", "curve-type"]),
|
|
101
101
|
u(i(J), {
|
|
102
102
|
x: (k, v) => v,
|
|
103
103
|
y: (k) => k[t],
|
|
104
104
|
color: f.value[o],
|
|
105
|
-
"curve-type": e.curveType ?? i(
|
|
105
|
+
"curve-type": e.curveType ?? i(D).MonotoneX,
|
|
106
106
|
"line-width": e.lineWidth,
|
|
107
|
-
lineDashArray: e.lineDashArray
|
|
107
|
+
lineDashArray: e.lineDashArray ? e.lineDashArray[o] : void 0
|
|
108
108
|
}, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"])
|
|
109
109
|
], 64))), 128)),
|
|
110
|
-
e.hideXAxis ? p("", !0) : (a(), m(i(
|
|
110
|
+
e.hideXAxis ? p("", !0) : (a(), m(i(B), {
|
|
111
111
|
key: 1,
|
|
112
112
|
type: "x",
|
|
113
113
|
label: e.xLabel,
|
|
@@ -120,7 +120,7 @@ const ee = {
|
|
|
120
120
|
"tick-line": e.xTickLine,
|
|
121
121
|
"min-max-ticks-only": e.minMaxTicksOnly
|
|
122
122
|
}, null, 8, ["label", "num-ticks", "tick-format", "tick-values", "grid-line", "domain-line", "tick-line", "min-max-ticks-only"])),
|
|
123
|
-
e.hideYAxis ? p("", !0) : (a(), m(i(
|
|
123
|
+
e.hideYAxis ? p("", !0) : (a(), m(i(B), {
|
|
124
124
|
key: 2,
|
|
125
125
|
type: "y",
|
|
126
126
|
label: e.yLabel,
|
|
@@ -143,14 +143,14 @@ const ee = {
|
|
|
143
143
|
}, null, 8, ["items"])
|
|
144
144
|
], 2)),
|
|
145
145
|
X("div", ee, [
|
|
146
|
-
i(O).tooltip ?
|
|
146
|
+
i(O).tooltip ? A(e.$slots, "tooltip", {
|
|
147
147
|
key: 0,
|
|
148
148
|
values: s.value
|
|
149
|
-
}) : s.value ?
|
|
150
|
-
u(
|
|
149
|
+
}) : s.value ? A(e.$slots, "fallback", { key: 1 }, () => [
|
|
150
|
+
u(x, {
|
|
151
151
|
data: s.value,
|
|
152
152
|
categories: e.categories,
|
|
153
|
-
toolTipTitle: i(
|
|
153
|
+
toolTipTitle: i(I)(s.value) ?? "",
|
|
154
154
|
yFormatter: r.yFormatter
|
|
155
155
|
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
156
156
|
]) : p("", !0)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { axisFormatter, LegendPosition, MarkerConfig } from '../../types';
|
|
1
|
+
import { axisFormatter, CrosshairConfig, LegendPosition, MarkerConfig } from '../../types';
|
|
2
2
|
import { BulletLegendItemInterface, CurveType } from '@unovis/ts';
|
|
3
3
|
export interface AreaChartProps<T> {
|
|
4
4
|
/**
|
|
@@ -64,7 +64,7 @@ export interface AreaChartProps<T> {
|
|
|
64
64
|
/**
|
|
65
65
|
* Line dash array, see SVG's stroke-dasharray. Default: `undefined`
|
|
66
66
|
*/
|
|
67
|
-
lineDashArray?: number[];
|
|
67
|
+
lineDashArray?: number[][];
|
|
68
68
|
/**
|
|
69
69
|
* The desired number of ticks on the x-axis.
|
|
70
70
|
*/
|
|
@@ -129,19 +129,5 @@ export interface AreaChartProps<T> {
|
|
|
129
129
|
/**
|
|
130
130
|
* Crosshair configuration object for customizing the appearance of the crosshair line.
|
|
131
131
|
*/
|
|
132
|
-
crosshairConfig?:
|
|
133
|
-
/**
|
|
134
|
-
* The color of the crosshair line. Accepts any valid CSS color string.
|
|
135
|
-
* Example: '#f00', 'rgba(0,0,0,0.5)', 'blue'
|
|
136
|
-
*/
|
|
137
|
-
color?: string;
|
|
138
|
-
/**
|
|
139
|
-
* The stroke color of the crosshair line. Accepts any valid CSS color string.
|
|
140
|
-
*/
|
|
141
|
-
strokeColor?: string;
|
|
142
|
-
/**
|
|
143
|
-
* The stroke width of the crosshair line in pixels.
|
|
144
|
-
*/
|
|
145
|
-
strokeWidth?: number;
|
|
146
|
-
};
|
|
132
|
+
crosshairConfig?: CrosshairConfig;
|
|
147
133
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as P, computed as k, useSlots as
|
|
1
|
+
import { defineComponent as P, computed as k, useSlots as O, useTemplateRef as j, ref as w, createElementBlock as c, openBlock as n, normalizeClass as g, createVNode as s, createCommentVNode as l, createElementVNode as x, unref as i, withCtx as M, createBlock as d, Fragment as W, 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 z } from "../../utils.js";
|
|
4
4
|
import R from "../Tooltip.js";
|
|
@@ -48,24 +48,24 @@ const J = {
|
|
|
48
48
|
},
|
|
49
49
|
emits: ["click"],
|
|
50
50
|
setup(o, { emit: L }) {
|
|
51
|
-
const C = L, t = o, b = k(() => t.markerConfig ? $(t.markerConfig) : ""), B =
|
|
51
|
+
const C = L, t = o, b = k(() => t.markerConfig ? $(t.markerConfig) : ""), B = O(), p = j("slotWrapper"), a = w();
|
|
52
52
|
function D(e) {
|
|
53
|
-
return typeof window > "u" ? "" :
|
|
53
|
+
return typeof window > "u" ? "" : p.value ? p.value.innerHTML : "";
|
|
54
54
|
}
|
|
55
55
|
function V(e) {
|
|
56
|
-
return
|
|
56
|
+
return a.value = e, D();
|
|
57
57
|
}
|
|
58
|
-
const
|
|
58
|
+
const y = k(
|
|
59
59
|
() => t.legendPosition === I.Top
|
|
60
60
|
), A = Object.values(t.categories).map(
|
|
61
61
|
(e, r) => `var(--vis-color${r})`
|
|
62
62
|
), F = (e) => Object.values(t.categories)[e].color ?? A[e];
|
|
63
|
-
return (e, r) => (n(),
|
|
63
|
+
return (e, r) => (n(), c("div", {
|
|
64
64
|
class: g(["flex flex-col space-y-4", {
|
|
65
|
-
"flex-col-reverse":
|
|
65
|
+
"flex-col-reverse": y.value,
|
|
66
66
|
markers: !!t.markerConfig
|
|
67
67
|
}]),
|
|
68
|
-
onClick: r[0] || (r[0] = (
|
|
68
|
+
onClick: r[0] || (r[0] = (m) => C("click", m, a.value))
|
|
69
69
|
}, [
|
|
70
70
|
s(i(Y), {
|
|
71
71
|
data: e.data,
|
|
@@ -78,16 +78,16 @@ const J = {
|
|
|
78
78
|
"horizontal-placement": i(v).Right,
|
|
79
79
|
"vertical-placement": i(v).Top
|
|
80
80
|
}, null, 8, ["horizontal-placement", "vertical-placement"]),
|
|
81
|
-
(n(!0),
|
|
82
|
-
key:
|
|
81
|
+
(n(!0), c(W, null, E(Object.keys(t.categories), (m, u) => (n(), d(i(H), {
|
|
82
|
+
key: u,
|
|
83
83
|
x: (f, N) => N,
|
|
84
|
-
y: (f) => f[
|
|
85
|
-
color: F(
|
|
84
|
+
y: (f) => f[m],
|
|
85
|
+
color: F(u),
|
|
86
86
|
"curve-type": e.curveType ?? i(X).MonotoneX,
|
|
87
87
|
"line-width": e.lineWidth,
|
|
88
|
-
lineDashArray: e.lineDashArray
|
|
88
|
+
lineDashArray: e.lineDashArray ? e.lineDashArray[u] : void 0
|
|
89
89
|
}, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"]))), 128)),
|
|
90
|
-
e.hideXAxis ?
|
|
90
|
+
e.hideXAxis ? l("", !0) : (n(), d(i(T), {
|
|
91
91
|
key: 0,
|
|
92
92
|
type: "x",
|
|
93
93
|
"tick-format": e.xFormatter,
|
|
@@ -100,7 +100,7 @@ const J = {
|
|
|
100
100
|
"tick-values": e.xExplicitTicks,
|
|
101
101
|
"min-max-ticks-only": e.minMaxTicksOnly
|
|
102
102
|
}, null, 8, ["tick-format", "label", "domain-line", "grid-line", "tick-line", "num-ticks", "tick-values", "min-max-ticks-only"])),
|
|
103
|
-
e.hideYAxis ?
|
|
103
|
+
e.hideYAxis ? l("", !0) : (n(), d(i(T), {
|
|
104
104
|
key: 1,
|
|
105
105
|
type: "y",
|
|
106
106
|
"tick-format": e.yFormatter,
|
|
@@ -110,30 +110,30 @@ const J = {
|
|
|
110
110
|
"grid-line": e.yGridLine,
|
|
111
111
|
"tick-line": e.yTickLine
|
|
112
112
|
}, null, 8, ["tick-format", "label", "num-ticks", "domain-line", "grid-line", "tick-line"])),
|
|
113
|
-
e.hideTooltip ?
|
|
113
|
+
e.hideTooltip ? l("", !0) : (n(), d(i(U), G({ key: 2 }, e.crosshairConfig, { template: V }), null, 16))
|
|
114
114
|
]),
|
|
115
115
|
_: 1
|
|
116
116
|
}, 8, ["data", "padding", "height", "svgDefs"]),
|
|
117
|
-
e.hideLegend ?
|
|
117
|
+
e.hideLegend ? l("", !0) : (n(), c("div", {
|
|
118
118
|
key: 0,
|
|
119
|
-
class: g(["flex items center justify-end", { "pb-4":
|
|
119
|
+
class: g(["flex items center justify-end", { "pb-4": y.value }])
|
|
120
120
|
}, [
|
|
121
121
|
s(i(q), {
|
|
122
122
|
items: Object.values(e.categories)
|
|
123
123
|
}, null, 8, ["items"])
|
|
124
124
|
], 2)),
|
|
125
|
-
|
|
125
|
+
x("div", J, [
|
|
126
126
|
i(B).tooltip ? h(e.$slots, "tooltip", {
|
|
127
127
|
key: 0,
|
|
128
|
-
values:
|
|
129
|
-
}) :
|
|
128
|
+
values: a.value
|
|
129
|
+
}) : a.value ? h(e.$slots, "fallback", { key: 1 }, () => [
|
|
130
130
|
s(R, {
|
|
131
|
-
data:
|
|
131
|
+
data: a.value,
|
|
132
132
|
categories: e.categories,
|
|
133
|
-
toolTipTitle: i(z)(
|
|
133
|
+
toolTipTitle: i(z)(a.value) ?? "",
|
|
134
134
|
yFormatter: t.yFormatter
|
|
135
135
|
}, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
|
|
136
|
-
]) :
|
|
136
|
+
]) : l("", !0)
|
|
137
137
|
], 512)
|
|
138
138
|
], 2));
|
|
139
139
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { axisFormatter, BulletLegendItemInterface, CurveType, LegendPosition, MarkerConfig } from '../../types';
|
|
1
|
+
import { axisFormatter, BulletLegendItemInterface, CrosshairConfig, CurveType, LegendPosition, MarkerConfig } from '../../types';
|
|
2
2
|
export interface LineChartProps<T> {
|
|
3
3
|
/**
|
|
4
4
|
* The data to be displayed in the line chart.
|
|
@@ -63,7 +63,7 @@ export interface LineChartProps<T> {
|
|
|
63
63
|
/**
|
|
64
64
|
* Line dash array, see SVG's stroke-dasharray. Default: `undefined`
|
|
65
65
|
*/
|
|
66
|
-
lineDashArray?: number[];
|
|
66
|
+
lineDashArray?: number[][];
|
|
67
67
|
/**
|
|
68
68
|
* The desired number of ticks on the x-axis.
|
|
69
69
|
*/
|
|
@@ -128,19 +128,5 @@ export interface LineChartProps<T> {
|
|
|
128
128
|
/**
|
|
129
129
|
* Crosshair configuration object for customizing the appearance of the crosshair line.
|
|
130
130
|
*/
|
|
131
|
-
crosshairConfig?:
|
|
132
|
-
/**
|
|
133
|
-
* The color of the crosshair line. Accepts any valid CSS color string.
|
|
134
|
-
* Example: '#f00', 'rgba(0,0,0,0.5)', 'blue'
|
|
135
|
-
*/
|
|
136
|
-
color?: string;
|
|
137
|
-
/**
|
|
138
|
-
* The stroke color of the crosshair line. Accepts any valid CSS color string.
|
|
139
|
-
*/
|
|
140
|
-
strokeColor?: string;
|
|
141
|
-
/**
|
|
142
|
-
* The stroke width of the crosshair line in pixels.
|
|
143
|
-
*/
|
|
144
|
-
strokeWidth?: number;
|
|
145
|
-
};
|
|
131
|
+
crosshairConfig?: CrosshairConfig;
|
|
146
132
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ import { default as AreaStackedChart } from './components/AreaStackedChart/AreaS
|
|
|
3
3
|
import { default as LineChart } from './components/LineChart/LineChart.vue';
|
|
4
4
|
import { default as BarChart } from './components/BarChart/BarChart.vue';
|
|
5
5
|
import { default as DonutChart } from './components/DonutChart/DonutChart.vue';
|
|
6
|
-
import { LegendPosition, CurveType, Orientation, BulletLegendItemInterface } from './types';
|
|
6
|
+
import { LegendPosition, CurveType, Orientation, BulletLegendItemInterface, MarkerConfig, CrosshairConfig } from './types';
|
|
7
7
|
export { AreaChart, AreaStackedChart, LineChart, BarChart, DonutChart, Orientation, CurveType, LegendPosition };
|
|
8
|
-
export type { BulletLegendItemInterface, };
|
|
8
|
+
export type { BulletLegendItemInterface, MarkerConfig, CrosshairConfig };
|
package/dist/types.d.ts
CHANGED
|
@@ -48,3 +48,18 @@ export interface MarkerConfig {
|
|
|
48
48
|
color?: string;
|
|
49
49
|
strokeColor?: string;
|
|
50
50
|
}
|
|
51
|
+
export interface CrosshairConfig {
|
|
52
|
+
/**
|
|
53
|
+
* The color of the crosshair line. Accepts any valid CSS color string.
|
|
54
|
+
* Example: '#f00', 'rgba(0,0,0,0.5)', 'blue'
|
|
55
|
+
*/
|
|
56
|
+
color?: string;
|
|
57
|
+
/**
|
|
58
|
+
* The stroke color of the crosshair line. Accepts any valid CSS color string.
|
|
59
|
+
*/
|
|
60
|
+
strokeColor?: string;
|
|
61
|
+
/**
|
|
62
|
+
* The stroke width of the crosshair line in pixels.
|
|
63
|
+
*/
|
|
64
|
+
strokeWidth?: number;
|
|
65
|
+
}
|