vue-chrts 2.0.0 → 2.1.0-beta-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 +116 -107
- package/dist/components/AreaChart/types.d.ts +1 -2
- package/dist/components/DagreGraph/DagreGraph.js +162 -0
- package/dist/components/DagreGraph/DagreGraph.vue.d.ts +33 -0
- package/dist/components/DagreGraph/DagreGraph2.js +4 -0
- package/dist/components/DagreGraph/types.d.ts +249 -0
- package/dist/components/DualChart/DualChart.js +206 -0
- package/dist/components/DualChart/DualChart.vue.d.ts +21 -0
- package/dist/components/DualChart/DualChart2.js +4 -0
- package/dist/components/DualChart/types.d.ts +186 -0
- package/dist/components/SankeyChart/SankeyChart.js +123 -0
- package/dist/components/SankeyChart/SankeyChart.vue.d.ts +22 -0
- package/dist/components/SankeyChart/SankeyChart2.js +4 -0
- package/dist/components/SankeyChart/types.d.ts +103 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.js +25 -16
- package/dist/types.d.ts +13 -40
- package/dist/types.js +6 -4
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +35 -31
- package/package.json +9 -9
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { BulletLegendItemInterface, LegendPosition } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Dagre layout direction options
|
|
4
|
+
*/
|
|
5
|
+
export type DagreRankDir = "TB" | "BT" | "LR" | "RL";
|
|
6
|
+
/**
|
|
7
|
+
* Dagre layout alignment options
|
|
8
|
+
*/
|
|
9
|
+
export type DagreAlign = "UL" | "UR" | "DL" | "DR";
|
|
10
|
+
/**
|
|
11
|
+
* Dagre ranking algorithm options
|
|
12
|
+
*/
|
|
13
|
+
export type DagreRanker = "network-simplex" | "tight-tree" | "longest-path";
|
|
14
|
+
/**
|
|
15
|
+
* Node shape options
|
|
16
|
+
*/
|
|
17
|
+
export type NodeShape = "circle" | "square" | "triangle" | "diamond";
|
|
18
|
+
/**
|
|
19
|
+
* Link arrow position options
|
|
20
|
+
*/
|
|
21
|
+
export type LinkArrowPosition = "start" | "end" | "both" | "none";
|
|
22
|
+
/**
|
|
23
|
+
* Configuration for Dagre layout algorithm
|
|
24
|
+
*/
|
|
25
|
+
export interface DagreLayoutSettings {
|
|
26
|
+
/**
|
|
27
|
+
* Direction of the layout: 'TB' (top-to-bottom), 'BT' (bottom-to-top),
|
|
28
|
+
* 'LR' (left-to-right), 'RL' (right-to-left)
|
|
29
|
+
* @default 'TB'
|
|
30
|
+
*/
|
|
31
|
+
rankdir?: DagreRankDir;
|
|
32
|
+
/**
|
|
33
|
+
* Alignment of nodes: 'UL' (up-left), 'UR' (up-right), 'DL' (down-left), 'DR' (down-right)
|
|
34
|
+
*/
|
|
35
|
+
align?: DagreAlign;
|
|
36
|
+
/**
|
|
37
|
+
* Horizontal spacing between nodes in pixels
|
|
38
|
+
* @default 50
|
|
39
|
+
*/
|
|
40
|
+
nodesep?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Spacing between edges in pixels
|
|
43
|
+
* @default 10
|
|
44
|
+
*/
|
|
45
|
+
edgesep?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Vertical spacing between ranks in pixels
|
|
48
|
+
* @default 50
|
|
49
|
+
*/
|
|
50
|
+
ranksep?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Algorithm to use for ranking nodes
|
|
53
|
+
* @default 'network-simplex'
|
|
54
|
+
*/
|
|
55
|
+
ranker?: DagreRanker;
|
|
56
|
+
/**
|
|
57
|
+
* Horizontal margin in pixels
|
|
58
|
+
* @default 0
|
|
59
|
+
*/
|
|
60
|
+
marginx?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Vertical margin in pixels
|
|
63
|
+
* @default 0
|
|
64
|
+
*/
|
|
65
|
+
marginy?: number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Node data structure for the graph
|
|
69
|
+
*/
|
|
70
|
+
export interface GraphNodeDatum {
|
|
71
|
+
/**
|
|
72
|
+
* Unique identifier for the node
|
|
73
|
+
*/
|
|
74
|
+
id: string;
|
|
75
|
+
/**
|
|
76
|
+
* Display label for the node
|
|
77
|
+
*/
|
|
78
|
+
label?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Node level (for hierarchical data)
|
|
81
|
+
*/
|
|
82
|
+
level?: number;
|
|
83
|
+
/**
|
|
84
|
+
* Additional data associated with the node
|
|
85
|
+
*/
|
|
86
|
+
[key: string]: any;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Link/Edge data structure for the graph
|
|
90
|
+
*/
|
|
91
|
+
export interface GraphLinkDatum {
|
|
92
|
+
/**
|
|
93
|
+
* Source node ID
|
|
94
|
+
*/
|
|
95
|
+
source: string;
|
|
96
|
+
/**
|
|
97
|
+
* Target node ID
|
|
98
|
+
*/
|
|
99
|
+
target: string;
|
|
100
|
+
/**
|
|
101
|
+
* Label for the link
|
|
102
|
+
*/
|
|
103
|
+
label?: string;
|
|
104
|
+
/**
|
|
105
|
+
* Additional data associated with the link
|
|
106
|
+
*/
|
|
107
|
+
[key: string]: any;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Graph data structure containing nodes and links
|
|
111
|
+
*/
|
|
112
|
+
export interface GraphData<N = GraphNodeDatum, L = GraphLinkDatum> {
|
|
113
|
+
/**
|
|
114
|
+
* Array of node data
|
|
115
|
+
*/
|
|
116
|
+
nodes: N[];
|
|
117
|
+
/**
|
|
118
|
+
* Array of link data
|
|
119
|
+
*/
|
|
120
|
+
links: L[];
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Props for the DagreGraph component
|
|
124
|
+
*/
|
|
125
|
+
export interface DagreGraphProps<N = GraphNodeDatum, L = GraphLinkDatum> {
|
|
126
|
+
/**
|
|
127
|
+
* The graph data containing nodes and links
|
|
128
|
+
*/
|
|
129
|
+
data: GraphData<N, L>;
|
|
130
|
+
/**
|
|
131
|
+
* The height of the graph container in pixels
|
|
132
|
+
* @default 600
|
|
133
|
+
*/
|
|
134
|
+
height?: number;
|
|
135
|
+
/**
|
|
136
|
+
* The width of the graph container in pixels
|
|
137
|
+
* @default undefined (auto)
|
|
138
|
+
*/
|
|
139
|
+
width?: number;
|
|
140
|
+
/**
|
|
141
|
+
* Dagre layout configuration
|
|
142
|
+
*/
|
|
143
|
+
dagreLayoutSettings?: DagreLayoutSettings;
|
|
144
|
+
/**
|
|
145
|
+
* Function or value to determine node size
|
|
146
|
+
* @default 40
|
|
147
|
+
*/
|
|
148
|
+
nodeSize?: number | ((node: N, index: number) => number);
|
|
149
|
+
/**
|
|
150
|
+
* Function to extract node label
|
|
151
|
+
*/
|
|
152
|
+
nodeLabel?: (node: N, index: number) => string;
|
|
153
|
+
/**
|
|
154
|
+
* Function or value to determine node shape
|
|
155
|
+
*/
|
|
156
|
+
nodeShape?: NodeShape | ((node: N, index: number) => NodeShape);
|
|
157
|
+
/**
|
|
158
|
+
* Function or value to determine node fill color
|
|
159
|
+
*/
|
|
160
|
+
nodeFill?: string | ((node: N, index: number) => string);
|
|
161
|
+
/**
|
|
162
|
+
* Function or value to determine node stroke color
|
|
163
|
+
*/
|
|
164
|
+
nodeStroke?: string | ((node: N, index: number) => string);
|
|
165
|
+
/**
|
|
166
|
+
* Function or value to determine node stroke width
|
|
167
|
+
*/
|
|
168
|
+
nodeStrokeWidth?: number | ((node: N, index: number) => number);
|
|
169
|
+
/**
|
|
170
|
+
* Link arrow configuration
|
|
171
|
+
* @default 'end'
|
|
172
|
+
*/
|
|
173
|
+
linkArrow?: LinkArrowPosition;
|
|
174
|
+
/**
|
|
175
|
+
* Function to extract link label
|
|
176
|
+
*/
|
|
177
|
+
linkLabel?: (link: L, index: number) => string;
|
|
178
|
+
/**
|
|
179
|
+
* Function or value to determine link color
|
|
180
|
+
*/
|
|
181
|
+
linkStroke?: string | ((link: L, index: number) => string);
|
|
182
|
+
/**
|
|
183
|
+
* Function or value to determine link width
|
|
184
|
+
*/
|
|
185
|
+
linkWidth?: number | ((link: L, index: number) => number);
|
|
186
|
+
/**
|
|
187
|
+
* Link curvature amount (0-1)
|
|
188
|
+
* @default 0
|
|
189
|
+
*/
|
|
190
|
+
linkCurvature?: number;
|
|
191
|
+
/**
|
|
192
|
+
* Optional padding applied to the graph
|
|
193
|
+
*/
|
|
194
|
+
padding?: {
|
|
195
|
+
top: number;
|
|
196
|
+
right: number;
|
|
197
|
+
bottom: number;
|
|
198
|
+
left: number;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* If true, hides the tooltip
|
|
202
|
+
*/
|
|
203
|
+
hideTooltip?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Enable zoom and pan controls
|
|
206
|
+
* @default true
|
|
207
|
+
*/
|
|
208
|
+
zoomEnabled?: boolean;
|
|
209
|
+
/**
|
|
210
|
+
* Zoom scale extent [min, max]
|
|
211
|
+
* @default [0.1, 10]
|
|
212
|
+
*/
|
|
213
|
+
zoomScaleExtent?: [number, number];
|
|
214
|
+
/**
|
|
215
|
+
* Enable node dragging
|
|
216
|
+
* @default false
|
|
217
|
+
*/
|
|
218
|
+
nodeDraggingEnabled?: boolean;
|
|
219
|
+
/**
|
|
220
|
+
* If true, hides the legend
|
|
221
|
+
*/
|
|
222
|
+
hideLegend?: boolean;
|
|
223
|
+
/**
|
|
224
|
+
* Legend position
|
|
225
|
+
* @default LegendPosition.BottomCenter
|
|
226
|
+
*/
|
|
227
|
+
legendPosition?: LegendPosition;
|
|
228
|
+
/**
|
|
229
|
+
* Legend style
|
|
230
|
+
*/
|
|
231
|
+
legendStyle?: string | Record<string, string>;
|
|
232
|
+
/**
|
|
233
|
+
* Legend items configuration
|
|
234
|
+
*/
|
|
235
|
+
legendItems?: BulletLegendItemInterface[];
|
|
236
|
+
/**
|
|
237
|
+
* Custom formatter for tooltip titles
|
|
238
|
+
*/
|
|
239
|
+
tooltipTitleFormatter?: (node: N) => string | number;
|
|
240
|
+
/**
|
|
241
|
+
* Custom formatter for tooltip content
|
|
242
|
+
*/
|
|
243
|
+
tooltipContentFormatter?: (node: N) => string;
|
|
244
|
+
/**
|
|
245
|
+
* Animation duration in milliseconds
|
|
246
|
+
* @default 600
|
|
247
|
+
*/
|
|
248
|
+
duration?: number;
|
|
249
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { defineComponent as N, useSlots as W, useTemplateRef as E, ref as G, computed as c, createElementBlock as m, openBlock as o, normalizeStyle as f, createVNode as x, createCommentVNode as u, createElementVNode as z, unref as a, withCtx as H, createBlock as d, Fragment as X, renderList as j, mergeProps as k, renderSlot as p } from "vue";
|
|
2
|
+
import { Orientation as y, CurveType as A, Position as L, StackedBar as q, GroupedBar as $ } from "@unovis/ts";
|
|
3
|
+
import { VisXYContainer as R, VisTooltip as U, VisGroupedBar as I, VisStackedBar as J, VisLine as K, VisAxis as B, VisCrosshair as Q, VisBulletLegend as Z } from "@unovis/vue";
|
|
4
|
+
import _ from "../Tooltip.js";
|
|
5
|
+
import { LegendPosition as ee } from "../../types.js";
|
|
6
|
+
const te = {
|
|
7
|
+
ref: "slotWrapper",
|
|
8
|
+
style: { display: "none" }
|
|
9
|
+
}, de = /* @__PURE__ */ N({
|
|
10
|
+
__name: "DualChart",
|
|
11
|
+
props: {
|
|
12
|
+
data: {},
|
|
13
|
+
height: {},
|
|
14
|
+
xLabel: {},
|
|
15
|
+
yLabel: {},
|
|
16
|
+
yLabelSecondary: {},
|
|
17
|
+
padding: { default: () => ({
|
|
18
|
+
top: 5,
|
|
19
|
+
right: 5,
|
|
20
|
+
bottom: 5,
|
|
21
|
+
left: 5
|
|
22
|
+
}) },
|
|
23
|
+
barCategories: {},
|
|
24
|
+
lineCategories: {},
|
|
25
|
+
barYAxis: {},
|
|
26
|
+
lineYAxis: {},
|
|
27
|
+
xFormatter: {},
|
|
28
|
+
yFormatter: {},
|
|
29
|
+
tooltipTitleFormatter: {},
|
|
30
|
+
curveType: { default: A.MonotoneX },
|
|
31
|
+
lineWidth: { default: 2 },
|
|
32
|
+
xNumTicks: {},
|
|
33
|
+
xExplicitTicks: {},
|
|
34
|
+
minMaxTicksOnly: { type: Boolean },
|
|
35
|
+
yNumTicks: {},
|
|
36
|
+
hideLegend: { type: Boolean, default: !1 },
|
|
37
|
+
hideTooltip: { type: Boolean, default: !1 },
|
|
38
|
+
legendPosition: { default: ee.BottomCenter },
|
|
39
|
+
legendStyle: { default: void 0 },
|
|
40
|
+
xDomainLine: { type: Boolean },
|
|
41
|
+
yDomainLine: { type: Boolean },
|
|
42
|
+
xTickLine: { type: Boolean },
|
|
43
|
+
yTickLine: { type: Boolean },
|
|
44
|
+
xGridLine: { type: Boolean },
|
|
45
|
+
yGridLine: { type: Boolean, default: !0 },
|
|
46
|
+
hideXAxis: { type: Boolean },
|
|
47
|
+
hideYAxis: { type: Boolean },
|
|
48
|
+
crosshairConfig: {},
|
|
49
|
+
xAxisConfig: {},
|
|
50
|
+
yAxisConfig: {},
|
|
51
|
+
yDomain: {},
|
|
52
|
+
xDomain: {},
|
|
53
|
+
stacked: { type: Boolean },
|
|
54
|
+
groupPadding: { default: 0 },
|
|
55
|
+
barPadding: { default: 0.2 },
|
|
56
|
+
radius: {},
|
|
57
|
+
orientation: { default: y.Vertical }
|
|
58
|
+
},
|
|
59
|
+
emits: ["click"],
|
|
60
|
+
setup(e, { emit: Y }) {
|
|
61
|
+
const P = Y, t = e, V = W(), g = E("slotWrapper"), s = G();
|
|
62
|
+
if (!t.barYAxis || t.barYAxis.length === 0)
|
|
63
|
+
throw console.error("[DualChart] barYAxis prop is required and must contain at least one field key"), new Error("DualChart: 'barYAxis' is required and must contain at least one field key. Provide an array of property keys from your data type (e.g., ['revenue', 'costs'])");
|
|
64
|
+
if (!t.lineYAxis || t.lineYAxis.length === 0)
|
|
65
|
+
throw console.error("[DualChart] lineYAxis prop is required and must contain at least one field key"), new Error("DualChart: 'lineYAxis' is required and must contain at least one field key. Provide an array of property keys from your data type (e.g., ['profit', 'target'])");
|
|
66
|
+
const h = c(() => t.barYAxis.map((n) => (l) => l[n])), D = c(() => t.lineYAxis.map((n) => (l) => l[n])), v = (n, l) => {
|
|
67
|
+
var i;
|
|
68
|
+
return (i = Object.values(t.barCategories)[l]) == null ? void 0 : i.color;
|
|
69
|
+
}, b = c(() => ({
|
|
70
|
+
...t.barCategories,
|
|
71
|
+
...t.lineCategories
|
|
72
|
+
})), F = c(() => t.legendPosition.startsWith("top")), w = c(() => t.legendPosition.includes("left") ? "flex-start" : t.legendPosition.includes("right") ? "flex-end" : "center");
|
|
73
|
+
function C(n) {
|
|
74
|
+
s.value = n;
|
|
75
|
+
}
|
|
76
|
+
function M(n) {
|
|
77
|
+
return typeof window > "u" ? "" : g.value ? g.value.innerHTML : "";
|
|
78
|
+
}
|
|
79
|
+
function O(n) {
|
|
80
|
+
return s.value = n, M();
|
|
81
|
+
}
|
|
82
|
+
return (n, l) => (o(), m("div", {
|
|
83
|
+
style: f({
|
|
84
|
+
display: "flex",
|
|
85
|
+
flexDirection: F.value ? "column-reverse" : "column",
|
|
86
|
+
gap: "var(--vis-legend-spacing)"
|
|
87
|
+
}),
|
|
88
|
+
onClick: l[0] || (l[0] = (i) => P("click", i, s.value))
|
|
89
|
+
}, [
|
|
90
|
+
x(a(R), {
|
|
91
|
+
padding: e.padding,
|
|
92
|
+
height: e.height,
|
|
93
|
+
data: e.data
|
|
94
|
+
}, {
|
|
95
|
+
default: H(() => [
|
|
96
|
+
e.hideTooltip ? u("", !0) : (o(), d(a(U), {
|
|
97
|
+
key: 0,
|
|
98
|
+
triggers: {
|
|
99
|
+
[a($).selectors.bar]: (i) => {
|
|
100
|
+
var r;
|
|
101
|
+
return C(i), i ? (r = g.value) == null ? void 0 : r.innerHTML : "";
|
|
102
|
+
},
|
|
103
|
+
[a(q).selectors.bar]: (i) => {
|
|
104
|
+
var r;
|
|
105
|
+
return C(i), i ? (r = g.value) == null ? void 0 : r.innerHTML : "";
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"horizontal-placement": a(L).Right,
|
|
109
|
+
"vertical-placement": a(L).Top
|
|
110
|
+
}, null, 8, ["triggers", "horizontal-placement", "vertical-placement"])),
|
|
111
|
+
e.stacked ? (o(), d(a(J), {
|
|
112
|
+
key: 2,
|
|
113
|
+
data: e.data,
|
|
114
|
+
x: (i, r) => r,
|
|
115
|
+
y: h.value,
|
|
116
|
+
color: v,
|
|
117
|
+
"rounded-corners": e.radius ?? 0,
|
|
118
|
+
"group-padding": e.groupPadding ?? 0,
|
|
119
|
+
"bar-padding": e.barPadding ?? 0.2,
|
|
120
|
+
orientation: e.orientation ?? a(y).Vertical
|
|
121
|
+
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (o(), d(a(I), {
|
|
122
|
+
key: 1,
|
|
123
|
+
data: e.data,
|
|
124
|
+
x: (i, r) => r,
|
|
125
|
+
y: h.value,
|
|
126
|
+
color: v,
|
|
127
|
+
"rounded-corners": e.radius ?? 0,
|
|
128
|
+
"group-padding": e.groupPadding ?? 0,
|
|
129
|
+
"bar-padding": e.barPadding ?? 0.2,
|
|
130
|
+
orientation: e.orientation ?? a(y).Vertical
|
|
131
|
+
}, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])),
|
|
132
|
+
(o(!0), m(X, null, j(D.value, (i, r) => {
|
|
133
|
+
var T;
|
|
134
|
+
return o(), d(a(K), {
|
|
135
|
+
key: `line-${r}`,
|
|
136
|
+
data: e.data,
|
|
137
|
+
x: (ie, S) => S,
|
|
138
|
+
y: i,
|
|
139
|
+
color: (T = Object.values(t.lineCategories)[r]) == null ? void 0 : T.color,
|
|
140
|
+
"curve-type": e.curveType ?? a(A).MonotoneX,
|
|
141
|
+
"line-width": e.lineWidth
|
|
142
|
+
}, null, 8, ["data", "x", "y", "color", "curve-type", "line-width"]);
|
|
143
|
+
}), 128)),
|
|
144
|
+
e.hideXAxis ? u("", !0) : (o(), d(a(B), k({
|
|
145
|
+
key: 3,
|
|
146
|
+
type: "x",
|
|
147
|
+
"tick-format": e.xFormatter,
|
|
148
|
+
label: e.xLabel,
|
|
149
|
+
"grid-line": e.xGridLine,
|
|
150
|
+
"domain-line": !!e.xDomainLine,
|
|
151
|
+
"tick-line": e.xTickLine,
|
|
152
|
+
"num-ticks": e.xNumTicks,
|
|
153
|
+
"tick-values": e.xExplicitTicks,
|
|
154
|
+
minMaxTicksOnly: e.minMaxTicksOnly
|
|
155
|
+
}, e.xAxisConfig), null, 16, ["tick-format", "label", "grid-line", "domain-line", "tick-line", "num-ticks", "tick-values", "minMaxTicksOnly"])),
|
|
156
|
+
e.hideYAxis ? u("", !0) : (o(), d(a(B), k({
|
|
157
|
+
key: 4,
|
|
158
|
+
type: "y",
|
|
159
|
+
label: e.yLabel,
|
|
160
|
+
"grid-line": e.orientation !== a(y).Horizontal && e.yGridLine,
|
|
161
|
+
"domain-line": !!e.yDomainLine,
|
|
162
|
+
"tick-format": e.yFormatter,
|
|
163
|
+
"num-ticks": e.yNumTicks,
|
|
164
|
+
"tick-line": e.yTickLine
|
|
165
|
+
}, e.yAxisConfig), null, 16, ["label", "grid-line", "domain-line", "tick-format", "num-ticks", "tick-line"])),
|
|
166
|
+
e.hideTooltip ? u("", !0) : (o(), d(a(Q), k({ key: 5 }, e.crosshairConfig, { template: O }), null, 16))
|
|
167
|
+
]),
|
|
168
|
+
_: 1
|
|
169
|
+
}, 8, ["padding", "height", "data"]),
|
|
170
|
+
t.hideLegend ? u("", !0) : (o(), m("div", {
|
|
171
|
+
key: 0,
|
|
172
|
+
style: f({
|
|
173
|
+
display: "flex",
|
|
174
|
+
justifyContent: w.value
|
|
175
|
+
})
|
|
176
|
+
}, [
|
|
177
|
+
x(a(Z), {
|
|
178
|
+
style: f([
|
|
179
|
+
t.legendStyle,
|
|
180
|
+
"display: flex; gap: var(--vis-legend-spacing);"
|
|
181
|
+
]),
|
|
182
|
+
items: Object.values(b.value).map((i) => ({
|
|
183
|
+
...i,
|
|
184
|
+
color: Array.isArray(i.color) ? i.color[0] : i.color
|
|
185
|
+
}))
|
|
186
|
+
}, null, 8, ["style", "items"])
|
|
187
|
+
], 4)),
|
|
188
|
+
z("div", te, [
|
|
189
|
+
a(V).tooltip ? p(n.$slots, "tooltip", {
|
|
190
|
+
key: 0,
|
|
191
|
+
values: s.value
|
|
192
|
+
}) : s.value ? p(n.$slots, "fallback", { key: 1 }, () => [
|
|
193
|
+
x(_, {
|
|
194
|
+
data: s.value,
|
|
195
|
+
categories: b.value,
|
|
196
|
+
"title-formatter": t.tooltipTitleFormatter,
|
|
197
|
+
yFormatter: t.orientation === a(y).Horizontal ? t.xFormatter : t.yFormatter
|
|
198
|
+
}, null, 8, ["data", "categories", "title-formatter", "yFormatter"])
|
|
199
|
+
]) : u("", !0)
|
|
200
|
+
], 512)
|
|
201
|
+
], 4));
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
export {
|
|
205
|
+
de as default
|
|
206
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DualChartProps } from './types';
|
|
2
|
+
declare const _default: <T extends {}>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
3
|
+
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
4
|
+
readonly onClick?: ((event: MouseEvent, values?: T | undefined) => any) | undefined;
|
|
5
|
+
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onClick"> & DualChartProps<T> & Partial<{}>> & import('vue').PublicProps;
|
|
6
|
+
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
7
|
+
attrs: any;
|
|
8
|
+
slots: {
|
|
9
|
+
tooltip?(_: {
|
|
10
|
+
values: T | undefined;
|
|
11
|
+
}): any;
|
|
12
|
+
fallback?(_: {}): any;
|
|
13
|
+
};
|
|
14
|
+
emit: (e: "click", event: MouseEvent, values?: T) => void;
|
|
15
|
+
}>) => import('vue').VNode & {
|
|
16
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
17
|
+
};
|
|
18
|
+
export default _default;
|
|
19
|
+
type __VLS_PrettifyLocal<T> = {
|
|
20
|
+
[K in keyof T]: T[K];
|
|
21
|
+
} & {};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { axisFormatter, CrosshairConfig, LegendPosition, AxisConfig, BulletLegendItemInterface, Orientation, CurveType } from '../../types';
|
|
2
|
+
export interface DualChartProps<T> {
|
|
3
|
+
/**
|
|
4
|
+
* The data to be displayed in the dual chart.
|
|
5
|
+
* Each element of the array represents a data point.
|
|
6
|
+
* The structure of 'T' should be compatible with the chart's rendering logic.
|
|
7
|
+
*/
|
|
8
|
+
data: T[];
|
|
9
|
+
/**
|
|
10
|
+
* The height of the chart in pixels.
|
|
11
|
+
*/
|
|
12
|
+
height: number;
|
|
13
|
+
/**
|
|
14
|
+
* Optional label for the x-axis.
|
|
15
|
+
*/
|
|
16
|
+
xLabel?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Optional label for the y-axis (used for both bar and line by default).
|
|
19
|
+
*/
|
|
20
|
+
yLabel?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Optional label for the secondary y-axis (line chart).
|
|
23
|
+
*/
|
|
24
|
+
yLabelSecondary?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Optional padding applied to the chart.
|
|
27
|
+
* Allows specifying individual padding values for the top, right, bottom, and left sides.
|
|
28
|
+
*/
|
|
29
|
+
padding?: {
|
|
30
|
+
top: number;
|
|
31
|
+
right: number;
|
|
32
|
+
bottom: number;
|
|
33
|
+
left: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* A record mapping bar category keys to `BulletLegendItemInterface` objects.
|
|
37
|
+
* This defines the visual representation and labels for bar categories in the chart's legend.
|
|
38
|
+
*/
|
|
39
|
+
barCategories: Record<string, BulletLegendItemInterface>;
|
|
40
|
+
/**
|
|
41
|
+
* A record mapping line category keys to `BulletLegendItemInterface` objects.
|
|
42
|
+
* This defines the visual representation and labels for line categories in the chart's legend.
|
|
43
|
+
*/
|
|
44
|
+
lineCategories: Record<string, BulletLegendItemInterface>;
|
|
45
|
+
/**
|
|
46
|
+
* An array of property keys from the data object type 'T' to be used for the bar chart y-axis values.
|
|
47
|
+
*/
|
|
48
|
+
barYAxis: (keyof T)[];
|
|
49
|
+
/**
|
|
50
|
+
* An array of property keys from the data object type 'T' to be used for the line chart y-axis values.
|
|
51
|
+
*/
|
|
52
|
+
lineYAxis: (keyof T)[];
|
|
53
|
+
/**
|
|
54
|
+
* @param {number|Date} tick - The value of the tick. This can be a number or a Date object depending on the scale of the x-axis.
|
|
55
|
+
* @param {number} i - The index of the tick in the `ticks` array.
|
|
56
|
+
* @param {(number[]|Date[])} ticks - An array of all tick values for the x-axis.
|
|
57
|
+
* @returns {string} The formatted string representation of the tick.
|
|
58
|
+
*/
|
|
59
|
+
xFormatter?: axisFormatter;
|
|
60
|
+
/**
|
|
61
|
+
* @param {number|Date} tick - The value of the tick. This can be a number or a Date object depending on the scale of the y-axis.
|
|
62
|
+
* @param {number} i - The index of the tick in the `ticks` array.
|
|
63
|
+
* @param {(number[]|Date[])} ticks - An array of all tick values for the y-axis.
|
|
64
|
+
* @returns {string} The formatted string representation of the tick.
|
|
65
|
+
*/
|
|
66
|
+
yFormatter?: axisFormatter;
|
|
67
|
+
/**
|
|
68
|
+
* Use custom formatter for tooltip titles
|
|
69
|
+
*/
|
|
70
|
+
tooltipTitleFormatter?: (data: T) => string | number;
|
|
71
|
+
/**
|
|
72
|
+
* The type of curve to use for the line chart lines.
|
|
73
|
+
* See `CurveType` for available options.
|
|
74
|
+
*/
|
|
75
|
+
curveType?: CurveType;
|
|
76
|
+
/**
|
|
77
|
+
* The width of the line in pixels. Default is 2px.
|
|
78
|
+
*/
|
|
79
|
+
lineWidth?: number;
|
|
80
|
+
/**
|
|
81
|
+
* The desired number of ticks on the x-axis.
|
|
82
|
+
*/
|
|
83
|
+
xNumTicks?: number;
|
|
84
|
+
/**
|
|
85
|
+
* Force specific ticks on the x-axis.
|
|
86
|
+
*/
|
|
87
|
+
xExplicitTicks?: (number | string | Date)[];
|
|
88
|
+
/**
|
|
89
|
+
* Force only first and last ticks on the x-axis.
|
|
90
|
+
*/
|
|
91
|
+
minMaxTicksOnly?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* The desired number of ticks on the y-axis.
|
|
94
|
+
*/
|
|
95
|
+
yNumTicks?: number;
|
|
96
|
+
/**
|
|
97
|
+
* If `true`, hides the chart legend.
|
|
98
|
+
*/
|
|
99
|
+
hideLegend?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* If `true`, hides the chart tooltip.
|
|
102
|
+
*/
|
|
103
|
+
hideTooltip?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Optional position for the legend, if applicable.
|
|
106
|
+
* See `LegendPosition` for available options.
|
|
107
|
+
*/
|
|
108
|
+
legendPosition?: LegendPosition;
|
|
109
|
+
/**
|
|
110
|
+
* Optional style object for the legend container. Allows custom CSS styling.
|
|
111
|
+
*/
|
|
112
|
+
legendStyle?: string | Record<string, string>;
|
|
113
|
+
/**
|
|
114
|
+
* If `true`, displays a domain line (axis line) along the x-axis.
|
|
115
|
+
*/
|
|
116
|
+
xDomainLine?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* If `true`, displays a domain line (axis line) along the y-axis.
|
|
119
|
+
*/
|
|
120
|
+
yDomainLine?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* If `true`, displays tick lines on the x-axis.
|
|
123
|
+
*/
|
|
124
|
+
xTickLine?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* If `true`, displays tick lines on the y-axis.
|
|
127
|
+
*/
|
|
128
|
+
yTickLine?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* If `true`, displays grid lines along the x-axis.
|
|
131
|
+
*/
|
|
132
|
+
xGridLine?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* If `true`, displays grid lines along the y-axis.
|
|
135
|
+
*/
|
|
136
|
+
yGridLine?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* If `true`, hide the x-axis.
|
|
139
|
+
*/
|
|
140
|
+
hideXAxis?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* If `true`, hide the y-axis.
|
|
143
|
+
*/
|
|
144
|
+
hideYAxis?: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Crosshair configuration object for customizing the appearance of the crosshair line.
|
|
147
|
+
*/
|
|
148
|
+
crosshairConfig?: CrosshairConfig;
|
|
149
|
+
/**
|
|
150
|
+
* Axis configuration object for customizing the appearance of the axes.
|
|
151
|
+
*/
|
|
152
|
+
xAxisConfig?: AxisConfig;
|
|
153
|
+
/**
|
|
154
|
+
* Axis configuration object for customizing the appearance of the axes.
|
|
155
|
+
*/
|
|
156
|
+
yAxisConfig?: AxisConfig;
|
|
157
|
+
/**
|
|
158
|
+
* The domain for the y-axis, specified as a tuple of two values.
|
|
159
|
+
*/
|
|
160
|
+
yDomain?: [number | undefined, number | undefined];
|
|
161
|
+
/**
|
|
162
|
+
* The domain for the x-axis, specified as a tuple of two values.
|
|
163
|
+
*/
|
|
164
|
+
xDomain?: [number | undefined, number | undefined];
|
|
165
|
+
/**
|
|
166
|
+
* If `true`, creates stacked bars.
|
|
167
|
+
*/
|
|
168
|
+
stacked?: boolean;
|
|
169
|
+
/**
|
|
170
|
+
* The padding between groups of bars in pixels.
|
|
171
|
+
*/
|
|
172
|
+
groupPadding?: number;
|
|
173
|
+
/**
|
|
174
|
+
* Fractional padding between the bars in the range of [0,1). Default: 0.2
|
|
175
|
+
*/
|
|
176
|
+
barPadding?: number;
|
|
177
|
+
/**
|
|
178
|
+
* Rounded corners for top bars. Boolean or number (to set the radius in pixels). Default: 2
|
|
179
|
+
*/
|
|
180
|
+
radius?: number;
|
|
181
|
+
/**
|
|
182
|
+
* The orientation of the bars (vertical or horizontal).
|
|
183
|
+
* See `Orientation` for available options.
|
|
184
|
+
*/
|
|
185
|
+
orientation?: Orientation;
|
|
186
|
+
}
|