apexsankey 1.0.0
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/README.md +167 -0
- package/apexsankey.es.min.js +17000 -0
- package/apexsankey.min.js +9 -0
- package/demo/demo.html +93 -0
- package/demo/demo2.html +165 -0
- package/demo/demo3.html +82 -0
- package/index.d.ts +1 -0
- package/lib/layout/edgeOrdering/index.d.ts +1 -0
- package/lib/layout/edgeOrdering/linkDirection.d.ts +1 -0
- package/lib/layout/edgeOrdering/linkTypeOrder.d.ts +1 -0
- package/lib/layout/edgeOrdering/orderEdges.d.ts +13 -0
- package/lib/layout/edgePositioning/index.d.ts +1 -0
- package/lib/layout/edgePositioning/linkLayout.d.ts +7 -0
- package/lib/layout/edgePositioning/utils.d.ts +7 -0
- package/lib/layout/layout.d.ts +49 -0
- package/lib/layout/nodeOrdering/addDummyNodes.d.ts +1 -0
- package/lib/layout/nodeOrdering/countCrossings.d.ts +30 -0
- package/lib/layout/nodeOrdering/index.d.ts +2 -0
- package/lib/layout/nodeOrdering/initialOrdering.d.ts +1 -0
- package/lib/layout/nodeOrdering/ordering.d.ts +11 -0
- package/lib/layout/nodeOrdering/swapNodes.d.ts +1 -0
- package/lib/layout/nodeOrdering/weightedMedian.d.ts +7 -0
- package/lib/layout/nodePositioning/horizontal.d.ts +2 -0
- package/lib/layout/nodePositioning/index.d.ts +2 -0
- package/lib/layout/nodePositioning/justified.d.ts +15 -0
- package/lib/layout/rankAssignment/assignRanks.d.ts +4 -0
- package/lib/layout/rankAssignment/groupedGraph.d.ts +9 -0
- package/lib/layout/rankAssignment/index.d.ts +1 -0
- package/lib/layout/rankAssignment/initialRank.d.ts +4 -0
- package/lib/layout/rankAssignment/makeAcyclic.d.ts +11 -0
- package/lib/layout/utils.d.ts +2 -0
- package/lib/models/ColorPalette.d.ts +1 -0
- package/lib/models/Edge.d.ts +1 -0
- package/lib/models/Graph.d.ts +34 -0
- package/lib/models/GraphUtils.d.ts +5 -0
- package/lib/models/Node.d.ts +3 -0
- package/lib/models/Options.d.ts +30 -0
- package/lib/models/Paper.d.ts +13 -0
- package/lib/models/svgUtils.d.ts +36 -0
- package/lib/sankey.d.ts +9 -0
- package/package.json +21 -0
package/demo/demo.html
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Document</title>
|
|
7
|
+
<link href="https://fonts.googleapis.com/css2?family=Quicksand:wght@400;600&display=swap" rel="stylesheet" />
|
|
8
|
+
<script src="../apexsankey.min.js"></script>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id="svg-tree" style="display: flex; justify-content: center"></div>
|
|
12
|
+
<script>
|
|
13
|
+
const data = {
|
|
14
|
+
nodes: [
|
|
15
|
+
{
|
|
16
|
+
id: 'a',
|
|
17
|
+
title: 'AAA',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: 'b',
|
|
21
|
+
title: 'BBB',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: 'c',
|
|
25
|
+
title: 'CCC',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: 'd',
|
|
29
|
+
title: 'DDD',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 'e',
|
|
33
|
+
title: 'EEE',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: 'f',
|
|
37
|
+
title: 'Node in bottom band',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 'g',
|
|
41
|
+
title: 'Node in bottom band',
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
edges: [
|
|
45
|
+
{
|
|
46
|
+
source: 'a',
|
|
47
|
+
target: 'c',
|
|
48
|
+
value: 1,
|
|
49
|
+
type: '11',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
source: 'b',
|
|
53
|
+
target: 'c',
|
|
54
|
+
value: 2,
|
|
55
|
+
type: '11',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
source: 'c',
|
|
59
|
+
target: 'd',
|
|
60
|
+
value: 0.9,
|
|
61
|
+
type: '22',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
source: 'c',
|
|
65
|
+
target: 'e',
|
|
66
|
+
value: 2.1,
|
|
67
|
+
type: '22',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
source: 'b',
|
|
71
|
+
target: 'f',
|
|
72
|
+
value: 0.5,
|
|
73
|
+
type: '11',
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
options: {
|
|
77
|
+
order: [
|
|
78
|
+
[['a', 'b'], []],
|
|
79
|
+
[['c'], ['f']],
|
|
80
|
+
[['d', 'e'], []],
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
const graphOptions = {
|
|
85
|
+
nodeWidth: 20,
|
|
86
|
+
fontFamily: 'Quicksand, sans-serif',
|
|
87
|
+
fontWeight: 600,
|
|
88
|
+
};
|
|
89
|
+
const s = new ApexSankey(document.getElementById('svg-tree'), graphOptions);
|
|
90
|
+
s.render(data);
|
|
91
|
+
</script>
|
|
92
|
+
</body>
|
|
93
|
+
</html>
|
package/demo/demo2.html
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Document</title>
|
|
7
|
+
<script src="../apexsankey.min.js"></script>
|
|
8
|
+
</head>
|
|
9
|
+
|
|
10
|
+
<body>
|
|
11
|
+
<div id="svg-tree" style="display: flex; justify-content: center"></div>
|
|
12
|
+
<script>
|
|
13
|
+
const data = {
|
|
14
|
+
nodes: [
|
|
15
|
+
{id: 'Berlin', title: 'Berlin'},
|
|
16
|
+
{id: 'Job Applications', title: 'Job Applications'},
|
|
17
|
+
{id: 'Barcelona', title: 'Barcelona'},
|
|
18
|
+
{id: 'Madrid', title: 'Madrid'},
|
|
19
|
+
{id: 'Amsterdam', title: 'Amsterdam'},
|
|
20
|
+
{id: 'Paris', title: 'Paris'},
|
|
21
|
+
{id: 'London', title: 'London'},
|
|
22
|
+
{id: 'Munich', title: 'Munich'},
|
|
23
|
+
{id: 'Brussels', title: 'Brussels'},
|
|
24
|
+
{id: 'Dubai', title: 'Dubai'},
|
|
25
|
+
{id: 'Dublin', title: 'Dublin'},
|
|
26
|
+
{id: 'Other Cities', title: 'Other Cities'},
|
|
27
|
+
{id: 'No Response', title: 'No Response'},
|
|
28
|
+
{id: 'Responded', title: 'Responded'},
|
|
29
|
+
{id: 'Rejected', title: 'Rejected'},
|
|
30
|
+
{id: 'Interviewed', title: 'Interviewed'},
|
|
31
|
+
{id: 'No Offer', title: 'No Offer'},
|
|
32
|
+
{id: 'Declined Offer', title: 'Declined Offer'},
|
|
33
|
+
{id: 'Accepted Offer', title: 'Accepted Offer'},
|
|
34
|
+
],
|
|
35
|
+
edges: [
|
|
36
|
+
{
|
|
37
|
+
source: 'Berlin',
|
|
38
|
+
target: 'Job Applications',
|
|
39
|
+
value: 102,
|
|
40
|
+
color: '#dddddd',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
source: 'Barcelona',
|
|
44
|
+
target: 'Job Applications',
|
|
45
|
+
value: 39,
|
|
46
|
+
color: '#dddddd',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
source: 'Madrid',
|
|
50
|
+
target: 'Job Applications',
|
|
51
|
+
value: 35,
|
|
52
|
+
color: '#dddddd',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
source: 'Amsterdam',
|
|
56
|
+
target: 'Job Applications',
|
|
57
|
+
value: 15,
|
|
58
|
+
color: '#dddddd',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
source: 'Paris',
|
|
62
|
+
target: 'Job Applications',
|
|
63
|
+
value: 14,
|
|
64
|
+
color: '#dddddd',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
source: 'London',
|
|
68
|
+
target: 'Job Applications',
|
|
69
|
+
value: 6,
|
|
70
|
+
color: '#dddddd',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
source: 'Munich',
|
|
74
|
+
target: 'Job Applications',
|
|
75
|
+
value: 5,
|
|
76
|
+
color: '#dddddd',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
source: 'Brussels',
|
|
80
|
+
target: 'Job Applications',
|
|
81
|
+
value: 4,
|
|
82
|
+
color: '#dddddd',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
source: 'Dubai',
|
|
86
|
+
target: 'Job Applications',
|
|
87
|
+
value: 3,
|
|
88
|
+
color: '#dddddd',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
source: 'Dublin',
|
|
92
|
+
target: 'Job Applications',
|
|
93
|
+
value: 3,
|
|
94
|
+
color: '#dddddd',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
source: 'Other Cities',
|
|
98
|
+
target: 'Job Applications',
|
|
99
|
+
value: 12,
|
|
100
|
+
color: '#dddddd',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
source: 'Job Applications',
|
|
104
|
+
target: 'No Response',
|
|
105
|
+
value: 189,
|
|
106
|
+
color: '#dddddd',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
source: 'Job Applications',
|
|
110
|
+
target: 'Responded',
|
|
111
|
+
value: 49,
|
|
112
|
+
color: 'orange',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
source: 'Responded',
|
|
116
|
+
target: 'Rejected',
|
|
117
|
+
value: 38,
|
|
118
|
+
color: '#dddddd',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
source: 'Responded',
|
|
122
|
+
target: 'Interviewed',
|
|
123
|
+
value: 11,
|
|
124
|
+
color: 'orange',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
source: 'Interviewed',
|
|
128
|
+
target: 'No Offer',
|
|
129
|
+
value: 8,
|
|
130
|
+
color: '#dddddd',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
source: 'Interviewed',
|
|
134
|
+
target: 'Declined Offer',
|
|
135
|
+
value: 2,
|
|
136
|
+
color: '#dddddd',
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
source: 'Interviewed',
|
|
140
|
+
target: 'Accepted Offer',
|
|
141
|
+
value: 1,
|
|
142
|
+
color: 'orange',
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
options: {
|
|
146
|
+
order: [
|
|
147
|
+
[
|
|
148
|
+
['Berlin', 'Barcelona', 'Madrid', 'Amsterdam', 'Paris', 'London'],
|
|
149
|
+
['Munich', 'Brussels', 'Dubai', 'Dublin', 'Other Cities'],
|
|
150
|
+
],
|
|
151
|
+
[['Job Applications']],
|
|
152
|
+
[['Responded'], ['No Response']],
|
|
153
|
+
[['Interviewed'], ['Rejected']],
|
|
154
|
+
[['Accepted Offer', 'Declined Offer', 'No Offer'], []],
|
|
155
|
+
],
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
const graphOptions = {
|
|
159
|
+
nodeWidth: 10,
|
|
160
|
+
};
|
|
161
|
+
const s = new ApexSankey(document.getElementById('svg-tree'), graphOptions);
|
|
162
|
+
s.render(data);
|
|
163
|
+
</script>
|
|
164
|
+
</body>
|
|
165
|
+
</html>
|
package/demo/demo3.html
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Document</title>
|
|
7
|
+
<link href="https://fonts.googleapis.com/css2?family=Quicksand:wght@400;600&display=swap" rel="stylesheet" />
|
|
8
|
+
<script src="../apexsankey.min.js"></script>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id="svg-tree" style="display: flex; justify-content: center"></div>
|
|
12
|
+
<script>
|
|
13
|
+
const data = {
|
|
14
|
+
nodes: [
|
|
15
|
+
{
|
|
16
|
+
id: 'Oil',
|
|
17
|
+
title: 'Oil',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: 'Natural Gas',
|
|
21
|
+
title: 'Natural Gas',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: 'Coal',
|
|
25
|
+
title: 'Coal',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: 'Fossil Fuels',
|
|
29
|
+
title: 'Fossil Fuels',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 'Electricity',
|
|
33
|
+
title: 'Electricity',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: 'Energy',
|
|
37
|
+
title: 'Energy',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
edges: [
|
|
41
|
+
{
|
|
42
|
+
source: 'Oil',
|
|
43
|
+
target: 'Fossil Fuels',
|
|
44
|
+
value: 15,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
source: 'Natural Gas',
|
|
48
|
+
target: 'Fossil Fuels',
|
|
49
|
+
value: 20,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
source: 'Coal',
|
|
53
|
+
target: 'Fossil Fuels',
|
|
54
|
+
value: 25,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
source: 'Coal',
|
|
58
|
+
target: 'Electricity',
|
|
59
|
+
value: 25,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
source: 'Fossil Fuels',
|
|
63
|
+
target: 'Energy',
|
|
64
|
+
value: 60,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
source: 'Electricity',
|
|
68
|
+
target: 'Energy',
|
|
69
|
+
value: 25,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
const graphOptions = {
|
|
74
|
+
nodeWidth: 20,
|
|
75
|
+
fontFamily: 'Quicksand, sans-serif',
|
|
76
|
+
fontWeight: 600,
|
|
77
|
+
};
|
|
78
|
+
const s = new ApexSankey(document.getElementById('svg-tree'), graphOptions);
|
|
79
|
+
s.render(data);
|
|
80
|
+
</script>
|
|
81
|
+
</body>
|
|
82
|
+
</html>
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ApexSankey as default } from './lib/sankey';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { orderEdges } from './orderEdges';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function linkDirection(G: any, link: any): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function linkTypeOrder(G: any, u: any): any[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @module edge-ordering */
|
|
2
|
+
/**
|
|
3
|
+
* Order the edges in the graph G, with node positions already set.
|
|
4
|
+
*
|
|
5
|
+
* Assigns each node a list `incoming` and `outgoing`, containing the incoming
|
|
6
|
+
* and outgoing edges in order.
|
|
7
|
+
*
|
|
8
|
+
* @param {Graph} G - The graph. Nodes must have `x` and `y` attributes.
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export declare function orderEdges(G: any, { alignLinkTypes }?: {
|
|
12
|
+
alignLinkTypes?: boolean;
|
|
13
|
+
}): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { linkLayout } from './linkLayout';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function findFirst(links: any, p: any): any;
|
|
2
|
+
/**
|
|
3
|
+
* Adjust radii of curvature to avoid overlaps, as much as possible.
|
|
4
|
+
* @param links - the list of links, ordered from outside to inside of bend
|
|
5
|
+
* @param rr - "r0" or "r1", the side to work on
|
|
6
|
+
*/
|
|
7
|
+
export declare function sweepCurvatureInwards(links: any, rr: any): void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sankey layout
|
|
3
|
+
*
|
|
4
|
+
* @module layout
|
|
5
|
+
*/
|
|
6
|
+
/// <reference types="graphlib" />
|
|
7
|
+
import { SankeyOptions } from '../models/Options';
|
|
8
|
+
/**
|
|
9
|
+
* Sankey layout
|
|
10
|
+
* @constructor sankey
|
|
11
|
+
*/
|
|
12
|
+
export declare function sankey(options: Partial<SankeyOptions>): {
|
|
13
|
+
(linksIn?: any, nodesIn?: any, data?: any): import("graphlib").Graph;
|
|
14
|
+
nodes(): any[];
|
|
15
|
+
links(): any[];
|
|
16
|
+
order(): any;
|
|
17
|
+
/**
|
|
18
|
+
* Set size of layout.
|
|
19
|
+
* @method size
|
|
20
|
+
* @param size {[width, height]} - size
|
|
21
|
+
* @returns {sankeyLayout|Number[]}
|
|
22
|
+
*/
|
|
23
|
+
size(x: any): {
|
|
24
|
+
(G: any, order: any): any[];
|
|
25
|
+
scaleToFit(G: any, order: any): void;
|
|
26
|
+
size(x?: any): any | number[];
|
|
27
|
+
separation(x?: any): any | ((a: any, b: any, c: any) => number);
|
|
28
|
+
whitespace(x?: number): number | any;
|
|
29
|
+
scale(x?: number): any;
|
|
30
|
+
} | any | number[];
|
|
31
|
+
separation(x: any): {
|
|
32
|
+
(G: any, order: any): any[];
|
|
33
|
+
scaleToFit(G: any, order: any): void;
|
|
34
|
+
size(x?: any): any | number[];
|
|
35
|
+
separation(x?: any): any | ((a: any, b: any, c: any) => number);
|
|
36
|
+
whitespace(x?: number): number | any;
|
|
37
|
+
scale(x?: number): any;
|
|
38
|
+
} | any | ((a: any, b: any, c: any) => number);
|
|
39
|
+
whitespace(x: any): number | {
|
|
40
|
+
(G: any, order: any): any[];
|
|
41
|
+
scaleToFit(G: any, order: any): void;
|
|
42
|
+
size(x?: any): any | number[];
|
|
43
|
+
separation(x?: any): any | ((a: any, b: any, c: any) => number);
|
|
44
|
+
whitespace(x?: number): number | any;
|
|
45
|
+
scale(x?: number): any;
|
|
46
|
+
} | any;
|
|
47
|
+
edgeValue(_x: any): any;
|
|
48
|
+
scale(x: any): any;
|
|
49
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function addDummyNodes(G: any): any;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** @module node-ordering/count-crossings */
|
|
2
|
+
/**
|
|
3
|
+
* Count the total number of crossings between 2 layers.
|
|
4
|
+
*
|
|
5
|
+
* This is the sum of the countBetweenCrossings and countLoopCrossings.
|
|
6
|
+
*
|
|
7
|
+
* @param {Graph} G - The graph.
|
|
8
|
+
* @param {Array} orderA - List of node ids on left side.
|
|
9
|
+
* @param {Array} orderB - List of node ids on right side.
|
|
10
|
+
*/
|
|
11
|
+
export declare function countCrossings(G: any, orderA: any, orderB: any): number;
|
|
12
|
+
/**
|
|
13
|
+
* Count the number of crossings of edges passing between 2 layers.
|
|
14
|
+
*
|
|
15
|
+
* Algorithm from
|
|
16
|
+
* http://jgaa.info/accepted/2004/BarthMutzelJuenger2004.8.2.pdf
|
|
17
|
+
*
|
|
18
|
+
* @param {Graph} G - The graph.
|
|
19
|
+
* @param {Array} orderA - List of node ids on left side.
|
|
20
|
+
* @param {Array} orderB - List of node ids on right side.
|
|
21
|
+
*/
|
|
22
|
+
export declare function countBetweenCrossings(G: any, orderA: any, orderB: any): number;
|
|
23
|
+
/**
|
|
24
|
+
* Count the number of crossings from within-layer edges.
|
|
25
|
+
*
|
|
26
|
+
* @param {Graph} G - The graph.
|
|
27
|
+
* @param {Array} orderA - List of node ids on left side.
|
|
28
|
+
* @param {Array} orderB - List of node ids on right side.
|
|
29
|
+
*/
|
|
30
|
+
export declare function countLoopCrossings(G: any, orderA: any, orderB: any): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function initialOrdering(G: any): any[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** @module node-ordering */
|
|
2
|
+
/**
|
|
3
|
+
* Return an ordering for the graph G.
|
|
4
|
+
*
|
|
5
|
+
* The ordering is a list of lists of node ids, corresponding to the ranks of
|
|
6
|
+
* the graphs, and the order of nodes within each rank.
|
|
7
|
+
*
|
|
8
|
+
* @param {Graph} G - The graph. Nodes must have a `rank` attribute.
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export declare function ordering(G: any, maxIterations?: number): any[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function swapNodes(G: any, order: any): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function medianValue(positions: any): any;
|
|
2
|
+
export declare function sortNodes(G: any, order: any, sweepDirection?: number, includeLoops?: boolean): void;
|
|
3
|
+
export declare function neighbourPositions(G: any, order: any, i: any, j: any, u: any, includeLoops?: boolean): any[];
|
|
4
|
+
/**
|
|
5
|
+
* Sort arr according to order. -1 in order means stay in same position.
|
|
6
|
+
*/
|
|
7
|
+
export declare function sortByPositions(arr: any, order: any): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Original, full-width node positioning.
|
|
3
|
+
*
|
|
4
|
+
* Uses spacing and whitespace fraction to position nodes within layers.
|
|
5
|
+
*
|
|
6
|
+
* @module node-positioning/justified
|
|
7
|
+
*/
|
|
8
|
+
export declare function justifiedPositioning(): {
|
|
9
|
+
(G: any, order: any): any[];
|
|
10
|
+
scaleToFit(G: any, order: any): void;
|
|
11
|
+
size(x?: any): any | number[];
|
|
12
|
+
separation(x?: any): any | ((a: any, b: any, c: any) => number);
|
|
13
|
+
whitespace(x?: number): number | any;
|
|
14
|
+
scale(x?: number): any;
|
|
15
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Graph } from 'graphlib';
|
|
2
|
+
/**
|
|
3
|
+
* Create a new graph where nodes in the same rank set are merged into one node.
|
|
4
|
+
*
|
|
5
|
+
* Depends on the "direction" attribute of the nodes in G, and the "delta"
|
|
6
|
+
* atribute of the edges.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export declare function groupedGraph(G: any, rankSets: any): Graph;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { assignRanks } from './assignRanks';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Graph } from 'graphlib';
|
|
2
|
+
/**
|
|
3
|
+
* Reverse edges in G to make it acyclic
|
|
4
|
+
*/
|
|
5
|
+
export declare function makeAcyclic(G: any, v0: any): any;
|
|
6
|
+
export declare function findSpanningTree(G: any, v0: any): Graph;
|
|
7
|
+
/**
|
|
8
|
+
* Returns 1 if w is a descendent of v, -1 if v is a descendent of w, and 0 if
|
|
9
|
+
* they are unrelated.
|
|
10
|
+
*/
|
|
11
|
+
export declare function nodeRelationship(tree: any, v: any, w: any): 0 | 1 | -1;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DefaultPalette: string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generatePath(edge: any): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { G } from '@svgdotjs/svg.js';
|
|
2
|
+
import { Paper } from './Paper';
|
|
3
|
+
import { SankeyOptions } from './Options';
|
|
4
|
+
export interface GraphPoint {
|
|
5
|
+
readonly x: number;
|
|
6
|
+
readonly y: number;
|
|
7
|
+
}
|
|
8
|
+
export interface Node {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly title: string;
|
|
11
|
+
readonly color?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface Edge {
|
|
14
|
+
readonly source: string;
|
|
15
|
+
readonly target: string;
|
|
16
|
+
readonly type: string;
|
|
17
|
+
readonly value: number;
|
|
18
|
+
}
|
|
19
|
+
export interface Graph {
|
|
20
|
+
readonly nodes: Node[];
|
|
21
|
+
readonly edges: Edge[];
|
|
22
|
+
readonly options: SankeyOptions;
|
|
23
|
+
}
|
|
24
|
+
export declare class SankeyGraph extends Paper {
|
|
25
|
+
graph: any;
|
|
26
|
+
element: HTMLElement;
|
|
27
|
+
options: SankeyOptions;
|
|
28
|
+
constructor(element: HTMLElement, options: SankeyOptions);
|
|
29
|
+
construct(data: Graph): void;
|
|
30
|
+
renderEdge(edgeObj: any, group: G): void;
|
|
31
|
+
render({ keepOldPosition }?: {
|
|
32
|
+
keepOldPosition?: boolean;
|
|
33
|
+
}): void;
|
|
34
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const getTooltip: (tooltipId?: string) => HTMLElement;
|
|
2
|
+
export declare const updateTooltip: (id?: string, styles?: string | undefined, content?: string) => void;
|
|
3
|
+
export declare const getTooltipStyles: (x: number, y: number, borderColor: string, bgColor: string) => ReadonlyArray<string>;
|
|
4
|
+
export declare const generateStyles: (styleObject?: Record<string, number | string>) => string;
|
|
5
|
+
export declare const camelToKebabCase: (str: string) => string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface CommonOptions {
|
|
2
|
+
readonly width: number;
|
|
3
|
+
readonly height: number;
|
|
4
|
+
readonly canvasStyle: string;
|
|
5
|
+
readonly spacing: number;
|
|
6
|
+
}
|
|
7
|
+
export interface NodeOptions {
|
|
8
|
+
readonly nodeWidth: number;
|
|
9
|
+
readonly nodeBorderWidth: number;
|
|
10
|
+
readonly nodeBorderColor: string;
|
|
11
|
+
readonly onNodeClick?: (node: any) => void;
|
|
12
|
+
}
|
|
13
|
+
export interface EdgeOptions {
|
|
14
|
+
readonly edgeOpacity: number;
|
|
15
|
+
}
|
|
16
|
+
export interface FontOptions {
|
|
17
|
+
readonly fontSize: string;
|
|
18
|
+
readonly fontFamily: string;
|
|
19
|
+
readonly fontWeight: number;
|
|
20
|
+
readonly fontColor: string;
|
|
21
|
+
}
|
|
22
|
+
export interface TooltipOptions {
|
|
23
|
+
readonly enableTooltip: boolean;
|
|
24
|
+
readonly tooltipId: string;
|
|
25
|
+
readonly tooltipTemplate?: (content: any) => any;
|
|
26
|
+
readonly tooltipBorderColor: string;
|
|
27
|
+
readonly tooltipBGColor: string;
|
|
28
|
+
}
|
|
29
|
+
export type SankeyOptions = CommonOptions & NodeOptions & TooltipOptions & EdgeOptions & FontOptions;
|
|
30
|
+
export declare const DefaultOptions: SankeyOptions;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Element, Svg } from '@svgdotjs/svg.js';
|
|
2
|
+
export declare class Paper {
|
|
3
|
+
private readonly width;
|
|
4
|
+
private readonly height;
|
|
5
|
+
private readonly spacing;
|
|
6
|
+
canvas: Svg;
|
|
7
|
+
constructor(element: HTMLElement, width: number, height: number, canvasStyle: string, spacing: number);
|
|
8
|
+
add(element: Element): void;
|
|
9
|
+
resetViewBox(): void;
|
|
10
|
+
updateViewBox(x: number, y: number, width: number, height: number): void;
|
|
11
|
+
zoom(zoomFactor: number): void;
|
|
12
|
+
clear(): void;
|
|
13
|
+
}
|