vue-chrts 0.2.5-test.3 → 1.0.0-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.
- package/dist/components/AreaChart/AreaChart.js +49 -48
- package/dist/components/AreaChart/types.d.ts +11 -9
- package/dist/components/BarChart/BarChart.js +62 -57
- package/dist/components/BarChart/stackedGroupedUtils.d.ts +2 -3
- package/dist/components/BarChart/types.d.ts +9 -1
- package/dist/components/BubbleChart/BubbleChart.js +51 -49
- package/dist/components/BubbleChart/BubbleChart.vue.d.ts +1 -1
- package/dist/components/BubbleChart/types.d.ts +11 -17
- package/dist/components/DonutChart/DonutChart.js +53 -43
- package/dist/components/DonutChart/DonutChart.vue.d.ts +1 -1
- package/dist/components/DonutChart/types.d.ts +10 -12
- package/dist/components/LineChart/LineChart.js +11 -9
- package/dist/components/Timeline/Timeline.js +83 -63
- package/dist/components/Timeline/types.d.ts +95 -3
- package/dist/components/Tooltip.js +6 -6
- package/dist/types.d.ts +16 -11
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Timeline as
|
|
3
|
-
import { dateFormatter as S, getFirstPropertyValue as
|
|
4
|
-
import
|
|
5
|
-
import { VisXYContainer as
|
|
6
|
-
import { LegendPosition as
|
|
7
|
-
const
|
|
1
|
+
import { defineComponent as V, useSlots as B, useTemplateRef as w, ref as A, computed as s, createElementBlock as g, openBlock as m, normalizeStyle as c, createVNode as o, createCommentVNode as f, createElementVNode as H, unref as i, withCtx as P, mergeProps as F, renderSlot as h } from "vue";
|
|
2
|
+
import { Timeline as y } from "@unovis/ts";
|
|
3
|
+
import { dateFormatter as S, getFirstPropertyValue as N } from "../../utils.js";
|
|
4
|
+
import j from "../Tooltip.js";
|
|
5
|
+
import { VisXYContainer as O, VisTimeline as $, VisTooltip as D, VisAxis as M, VisBulletLegend as E } from "@unovis/vue";
|
|
6
|
+
import { LegendPosition as G } from "../../types.js";
|
|
7
|
+
const I = /* @__PURE__ */ V({
|
|
8
8
|
__name: "Timeline",
|
|
9
9
|
props: {
|
|
10
10
|
data: {},
|
|
@@ -16,105 +16,125 @@ const G = /* @__PURE__ */ L({
|
|
|
16
16
|
length: {},
|
|
17
17
|
type: {},
|
|
18
18
|
getTooltipText: {},
|
|
19
|
+
xNumTicks: {},
|
|
19
20
|
showLabels: { type: Boolean, default: !0 },
|
|
20
21
|
hideTooltip: { type: Boolean, default: !1 },
|
|
21
22
|
crosshairConfig: {},
|
|
22
23
|
lineWidth: { default: 12 },
|
|
23
24
|
rowHeight: { default: 24 },
|
|
24
|
-
legendPosition: { default:
|
|
25
|
+
legendPosition: { default: G.TopRight },
|
|
25
26
|
legendStyle: {},
|
|
26
|
-
hideLegend: { type: Boolean }
|
|
27
|
+
hideLegend: { type: Boolean },
|
|
28
|
+
xTickLine: { type: Boolean },
|
|
29
|
+
xTickFormat: {},
|
|
30
|
+
xMinMaxTicksOnly: { type: Boolean },
|
|
31
|
+
xTickValues: {},
|
|
32
|
+
xGridLine: { type: Boolean },
|
|
33
|
+
xDomainLine: { type: Boolean },
|
|
34
|
+
xAxisConfig: {},
|
|
35
|
+
yAxisConfig: {}
|
|
27
36
|
},
|
|
28
37
|
emits: ["click", "scroll", "labelHover"],
|
|
29
|
-
setup(
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
setup(T, { emit: k }) {
|
|
39
|
+
const l = T, r = k, v = B(), d = w("slotWrapper"), n = A(), x = s(() => l.legendPosition.startsWith("top")), b = s(() => l.legendPosition.includes("left") ? "flex-start" : l.legendPosition.includes("right") ? "flex-end" : "center");
|
|
40
|
+
y.selectors.label + "";
|
|
41
|
+
function u(e) {
|
|
42
|
+
n.value = e, r("labelHover", e);
|
|
33
43
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
44
|
+
function L(e, a, t) {
|
|
45
|
+
r("click", t, { index: a, item: e });
|
|
36
46
|
}
|
|
37
|
-
function W(
|
|
38
|
-
|
|
47
|
+
function W(e) {
|
|
48
|
+
r("scroll", e.deltaY);
|
|
39
49
|
}
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
(a,
|
|
50
|
+
const C = s(() => {
|
|
51
|
+
const e = Object.values(l.categories).map(
|
|
52
|
+
(a, t) => `var(--vis-color${t})`
|
|
43
53
|
);
|
|
44
|
-
return Object.values(
|
|
45
|
-
(a,
|
|
54
|
+
return Object.values(l.categories).map(
|
|
55
|
+
(a, t) => a.color ?? e[t]
|
|
46
56
|
);
|
|
47
57
|
});
|
|
48
|
-
return (
|
|
49
|
-
style:
|
|
58
|
+
return (e, a) => (m(), g("div", {
|
|
59
|
+
style: c({
|
|
50
60
|
display: "flex",
|
|
51
|
-
flexDirection:
|
|
61
|
+
flexDirection: x.value ? "column-reverse" : "column",
|
|
52
62
|
gap: "var(--vis-legend-spacing)"
|
|
53
63
|
})
|
|
54
64
|
}, [
|
|
55
|
-
i(
|
|
56
|
-
data:
|
|
57
|
-
height:
|
|
65
|
+
o(i(O), {
|
|
66
|
+
data: l.data,
|
|
67
|
+
height: l.height,
|
|
58
68
|
onWheel: W
|
|
59
69
|
}, {
|
|
60
|
-
default:
|
|
61
|
-
i(
|
|
62
|
-
x:
|
|
63
|
-
length:
|
|
64
|
-
lineWidth:
|
|
65
|
-
rowHeight:
|
|
66
|
-
type:
|
|
67
|
-
color:
|
|
68
|
-
labelWidth:
|
|
69
|
-
showLabels:
|
|
70
|
-
onClick:
|
|
70
|
+
default: P(() => [
|
|
71
|
+
o(i($), {
|
|
72
|
+
x: l.x,
|
|
73
|
+
length: l.length,
|
|
74
|
+
lineWidth: l.lineWidth,
|
|
75
|
+
rowHeight: l.rowHeight,
|
|
76
|
+
type: l.type,
|
|
77
|
+
color: C.value,
|
|
78
|
+
labelWidth: l.labelWidth,
|
|
79
|
+
showLabels: l.showLabels,
|
|
80
|
+
onClick: L
|
|
71
81
|
}, null, 8, ["x", "length", "lineWidth", "rowHeight", "type", "color", "labelWidth", "showLabels"]),
|
|
72
|
-
i(
|
|
73
|
-
|
|
82
|
+
o(i(D), {
|
|
83
|
+
triggers: {
|
|
84
|
+
[i(y).selectors.label]: (t) => {
|
|
85
|
+
var p;
|
|
86
|
+
return u(t), t ? (p = d.value) == null ? void 0 : p.innerHTML : "";
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, null, 8, ["triggers"]),
|
|
90
|
+
o(i(M), F({
|
|
74
91
|
type: "x",
|
|
75
|
-
tickFormat:
|
|
76
|
-
numTicks:
|
|
77
|
-
|
|
92
|
+
tickFormat: e.xTickFormat || i(S),
|
|
93
|
+
numTicks: e.xNumTicks,
|
|
94
|
+
"tick-line": e.xTickLine,
|
|
95
|
+
"grid-line": e.xGridLine,
|
|
96
|
+
"domain-line": e.xDomainLine
|
|
97
|
+
}, e.xAxisConfig), null, 16, ["tickFormat", "numTicks", "tick-line", "grid-line", "domain-line"])
|
|
78
98
|
]),
|
|
79
99
|
_: 1
|
|
80
100
|
}, 8, ["data", "height"]),
|
|
81
|
-
|
|
101
|
+
l.hideLegend ? f("", !0) : (m(), g("div", {
|
|
82
102
|
key: 0,
|
|
83
|
-
style:
|
|
103
|
+
style: c({
|
|
84
104
|
display: "flex",
|
|
85
|
-
justifyContent:
|
|
105
|
+
justifyContent: b.value
|
|
86
106
|
})
|
|
87
107
|
}, [
|
|
88
|
-
i(
|
|
89
|
-
style:
|
|
90
|
-
|
|
108
|
+
o(i(E), {
|
|
109
|
+
style: c([
|
|
110
|
+
l.legendStyle,
|
|
91
111
|
"display: flex; gap: var(--vis-legend-spacing);"
|
|
92
112
|
]),
|
|
93
|
-
items: Object.values(
|
|
94
|
-
...
|
|
95
|
-
color: Array.isArray(
|
|
113
|
+
items: Object.values(l.categories).map((t) => ({
|
|
114
|
+
...t,
|
|
115
|
+
color: Array.isArray(t.color) ? t.color[0] : t.color
|
|
96
116
|
}))
|
|
97
117
|
}, null, 8, ["style", "items"])
|
|
98
118
|
], 4)),
|
|
99
119
|
H("div", {
|
|
100
120
|
ref_key: "slotWrapper",
|
|
101
|
-
ref:
|
|
121
|
+
ref: d,
|
|
102
122
|
style: { display: "none" }
|
|
103
123
|
}, [
|
|
104
|
-
|
|
124
|
+
i(v).labelTooltip ? h(e.$slots, "labelTooltip", {
|
|
105
125
|
key: 0,
|
|
106
|
-
values:
|
|
107
|
-
}) :
|
|
108
|
-
|
|
109
|
-
data:
|
|
110
|
-
categories:
|
|
111
|
-
toolTipTitle:
|
|
126
|
+
values: n.value
|
|
127
|
+
}) : n.value ? h(e.$slots, "fallback", { key: 1 }, () => [
|
|
128
|
+
o(j, {
|
|
129
|
+
data: n.value,
|
|
130
|
+
categories: e.categories,
|
|
131
|
+
toolTipTitle: i(N)(n.value) ?? ""
|
|
112
132
|
}, null, 8, ["data", "categories", "toolTipTitle"])
|
|
113
|
-
]) :
|
|
133
|
+
]) : f("", !0)
|
|
114
134
|
], 512)
|
|
115
135
|
], 4));
|
|
116
136
|
}
|
|
117
137
|
});
|
|
118
138
|
export {
|
|
119
|
-
|
|
139
|
+
I as default
|
|
120
140
|
};
|
|
@@ -1,24 +1,116 @@
|
|
|
1
|
-
import { BulletLegendItemInterface, CrosshairConfig, LegendPosition } from '../../types';
|
|
1
|
+
import { BulletLegendItemInterface, CrosshairConfig, LegendPosition, AxisConfig } from '../../types';
|
|
2
2
|
export interface TimelineLegendItem {
|
|
3
3
|
name: string;
|
|
4
4
|
color: string;
|
|
5
5
|
}
|
|
6
|
-
export interface TimelineProps<T
|
|
6
|
+
export interface TimelineProps<T> {
|
|
7
|
+
/**
|
|
8
|
+
* The data to be displayed in the timeline chart.
|
|
9
|
+
* Each element of the array represents a timeline event or item.
|
|
10
|
+
* The structure of 'T' should be compatible with the chart's rendering logic.
|
|
11
|
+
*/
|
|
7
12
|
data: T[];
|
|
13
|
+
/**
|
|
14
|
+
* The width of the label area in pixels.
|
|
15
|
+
* Default: 220
|
|
16
|
+
*/
|
|
8
17
|
labelWidth?: number;
|
|
18
|
+
/**
|
|
19
|
+
* The height of the chart in pixels.
|
|
20
|
+
*/
|
|
9
21
|
height?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Optional title for the timeline chart.
|
|
24
|
+
*/
|
|
10
25
|
title?: string;
|
|
26
|
+
/**
|
|
27
|
+
* A record mapping category keys to `BulletLegendItemInterface` objects.
|
|
28
|
+
* This defines the visual representation and labels for each category in the chart's legend.
|
|
29
|
+
*/
|
|
11
30
|
categories: Record<string, BulletLegendItemInterface>;
|
|
31
|
+
/**
|
|
32
|
+
* Accessor function that returns the x-position (start time/value) for each timeline item.
|
|
33
|
+
* @param {T} d - The data item.
|
|
34
|
+
* @returns {number} The x-position value.
|
|
35
|
+
*/
|
|
12
36
|
x: (d: T) => number;
|
|
37
|
+
/**
|
|
38
|
+
* Accessor function that returns the length (duration) for each timeline item.
|
|
39
|
+
* @param {T} d - The data item.
|
|
40
|
+
* @returns {number} The length/duration value.
|
|
41
|
+
*/
|
|
13
42
|
length: (d: T) => number;
|
|
43
|
+
/**
|
|
44
|
+
* Accessor function that returns the type/category for each timeline item.
|
|
45
|
+
* This determines the color and style of the timeline bar.
|
|
46
|
+
* @param {T} d - The data item.
|
|
47
|
+
* @returns {string} The type/category identifier.
|
|
48
|
+
*/
|
|
14
49
|
type: (d: T) => string;
|
|
50
|
+
/**
|
|
51
|
+
* Optional custom tooltip text generator function.
|
|
52
|
+
* @param {string} label - The label of the item.
|
|
53
|
+
* @param {number} index - The index of the item in the data array.
|
|
54
|
+
* @param {T[]} data - The full data array.
|
|
55
|
+
* @returns {string} The formatted tooltip text.
|
|
56
|
+
*/
|
|
15
57
|
getTooltipText?: (label: string, index: number, data: T[]) => string;
|
|
58
|
+
/**
|
|
59
|
+
* The desired number of ticks on the x-axis.
|
|
60
|
+
*/
|
|
61
|
+
xNumTicks?: number;
|
|
62
|
+
/**
|
|
63
|
+
* If `true`, displays labels for each timeline row.
|
|
64
|
+
* Default: true
|
|
65
|
+
*/
|
|
16
66
|
showLabels?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* If `true`, hides the chart tooltip.
|
|
69
|
+
*/
|
|
17
70
|
hideTooltip?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Crosshair configuration object for customizing the appearance of the crosshair line.
|
|
73
|
+
*/
|
|
18
74
|
crosshairConfig?: CrosshairConfig;
|
|
75
|
+
/**
|
|
76
|
+
* The width of the timeline bars in pixels.
|
|
77
|
+
* Default: 12
|
|
78
|
+
*/
|
|
19
79
|
lineWidth?: number;
|
|
80
|
+
/**
|
|
81
|
+
* The height of each row in the timeline in pixels.
|
|
82
|
+
* Default: 24
|
|
83
|
+
*/
|
|
20
84
|
rowHeight?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Optional position for the legend, if applicable.
|
|
87
|
+
* See `LegendPosition` for available options.
|
|
88
|
+
* Default: LegendPosition.TopRight
|
|
89
|
+
*/
|
|
21
90
|
legendPosition?: LegendPosition;
|
|
22
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Optional style object for the legend container. Allows custom CSS styling.
|
|
93
|
+
*/
|
|
94
|
+
legendStyle?: string | Record<string, string>;
|
|
95
|
+
/**
|
|
96
|
+
* If `true`, hides the chart legend.
|
|
97
|
+
*/
|
|
23
98
|
hideLegend?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* If `true`, displays tick lines on the x-axis.
|
|
101
|
+
*/
|
|
102
|
+
xTickLine?: boolean;
|
|
103
|
+
xTickFormat?: (tick: number | Date, i?: number, ticks?: number[] | Date[]) => string;
|
|
104
|
+
xMinMaxTicksOnly?: boolean;
|
|
105
|
+
xTickValues?: number[] | Date[];
|
|
106
|
+
xGridLine?: boolean;
|
|
107
|
+
xDomainLine?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Axis configuration object for customizing the appearance of the axes.
|
|
110
|
+
*/
|
|
111
|
+
xAxisConfig?: AxisConfig;
|
|
112
|
+
/**
|
|
113
|
+
* Axis configuration object for customizing the appearance of the axes.
|
|
114
|
+
*/
|
|
115
|
+
yAxisConfig?: AxisConfig;
|
|
24
116
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as y, computed as
|
|
2
|
-
const x = { style: { padding: "10px 15px" } },
|
|
1
|
+
import { defineComponent as y, computed as f, createElementBlock as r, openBlock as i, createElementVNode as e, toDisplayString as l, Fragment as h, renderList as b, normalizeStyle as n } from "vue";
|
|
2
|
+
const x = { style: { padding: "10px 15px" } }, _ = { style: {
|
|
3
3
|
color: "var(--tooltip-value-color)",
|
|
4
4
|
textTransform: "capitalize",
|
|
5
|
-
borderBottom: "
|
|
5
|
+
borderBottom: "1px solid var(--tooltip-border-color)",
|
|
6
6
|
marginBottom: "0.25rem",
|
|
7
7
|
paddingBottom: "0.25rem"
|
|
8
8
|
} }, T = /* @__PURE__ */ y({
|
|
@@ -14,12 +14,12 @@ const x = { style: { padding: "10px 15px" } }, B = { style: {
|
|
|
14
14
|
yFormatter: { type: Function }
|
|
15
15
|
},
|
|
16
16
|
setup(d) {
|
|
17
|
-
const a = d, m = ["_index", "_stacked", "_ending"], g =
|
|
17
|
+
const a = d, m = ["_index", "_stacked", "_ending"], g = f(() => Object.entries(a.data ?? []).filter(
|
|
18
18
|
([o, u]) => !m.includes(o) && Object.keys(a.categories).includes(o)
|
|
19
19
|
));
|
|
20
20
|
return (o, u) => (i(), r("div", x, [
|
|
21
|
-
e("div",
|
|
22
|
-
(i(!0), r(
|
|
21
|
+
e("div", _, l(o.toolTipTitle), 1),
|
|
22
|
+
(i(!0), r(h, null, b(g.value, ([t, s], v) => {
|
|
23
23
|
var p, c;
|
|
24
24
|
return i(), r("div", {
|
|
25
25
|
key: t,
|
package/dist/types.d.ts
CHANGED
|
@@ -36,7 +36,6 @@ interface BulletLegendItemInterface {
|
|
|
36
36
|
name: string | number;
|
|
37
37
|
color?: string | Array<string>;
|
|
38
38
|
className?: string;
|
|
39
|
-
shape?: any;
|
|
40
39
|
inactive?: boolean;
|
|
41
40
|
hidden?: boolean;
|
|
42
41
|
pointer?: boolean;
|
|
@@ -47,6 +46,22 @@ declare enum Orientation {
|
|
|
47
46
|
}
|
|
48
47
|
export { LegendPosition, CurveType, Orientation, type AreaChartProps, type BarChartProps, type LineChartProps, type DonutChartProps, type BulletLegendItemInterface, type BubbleChartProps, type TimelineProps, type TimelineLegendItem };
|
|
49
48
|
export type axisFormatter = ((tick: number, i?: number, ticks?: number[]) => string) | ((tick: Date, i?: number, ticks?: Date[]) => string);
|
|
49
|
+
export interface AxisConfig {
|
|
50
|
+
tickLine?: boolean;
|
|
51
|
+
tickTextFontSize?: string;
|
|
52
|
+
tickTextColor?: string;
|
|
53
|
+
tickFormat?: axisFormatter;
|
|
54
|
+
tickTextAlign?: "left" | "right" | "center";
|
|
55
|
+
tickTextAngle?: number;
|
|
56
|
+
tickTextWidth?: number;
|
|
57
|
+
tickTextFitMode?: "wrap" | "trim";
|
|
58
|
+
tickTextTrimType?: "start" | "middle" | "end";
|
|
59
|
+
tickTextForceWordBreak?: boolean;
|
|
60
|
+
tickTextSeparator?: string | readonly string[];
|
|
61
|
+
minMaxTicksOnly?: boolean;
|
|
62
|
+
minMaxTicksOnlyShowGridLines?: boolean;
|
|
63
|
+
tickValues?: readonly number[] | readonly Date[];
|
|
64
|
+
}
|
|
50
65
|
export interface MarkerConfig {
|
|
51
66
|
type?: "circle" | "square" | "triangle" | "diamond";
|
|
52
67
|
size?: number;
|
|
@@ -55,17 +70,7 @@ export interface MarkerConfig {
|
|
|
55
70
|
strokeColor?: string;
|
|
56
71
|
}
|
|
57
72
|
export interface CrosshairConfig {
|
|
58
|
-
/**
|
|
59
|
-
* The color of the crosshair line. Accepts any valid CSS color string.
|
|
60
|
-
* Example: '#f00', 'rgba(0,0,0,0.5)', 'blue'
|
|
61
|
-
*/
|
|
62
73
|
color?: string;
|
|
63
|
-
/**
|
|
64
|
-
* The stroke color of the crosshair line. Accepts any valid CSS color string.
|
|
65
|
-
*/
|
|
66
74
|
strokeColor?: string;
|
|
67
|
-
/**
|
|
68
|
-
* The stroke width of the crosshair line in pixels.
|
|
69
|
-
*/
|
|
70
75
|
strokeWidth?: number;
|
|
71
76
|
}
|