apexsankey 1.2.4 → 1.3.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 +51 -38
- package/apexsankey.es.min.js +1035 -5876
- package/apexsankey.min.js +1 -9
- package/demo/basic-sankey.html +30 -39
- package/index.d.ts +4 -1
- package/lib/layout/rankAssignment/makeAcyclic.d.ts +1 -1
- package/lib/models/Graph.d.ts +2 -0
- package/lib/models/Paper.d.ts +3 -1
- package/lib/sankey.d.ts +7 -4
- package/package.json +3 -19
- package/.husky/commit-msg +0 -1
- package/.husky/pre-push +0 -1
- package/commitlint.config.js +0 -5
package/demo/basic-sankey.html
CHANGED
|
@@ -1,93 +1,84 @@
|
|
|
1
|
-
<!
|
|
1
|
+
<!doctype html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Document</title>
|
|
7
|
-
<link
|
|
8
|
-
href="https://fonts.googleapis.com/css2?family=Quicksand:wght@400;600&display=swap"
|
|
9
|
-
rel="stylesheet"
|
|
10
|
-
/>
|
|
7
|
+
<link href="https://fonts.googleapis.com/css2?family=Quicksand:wght@400;600&display=swap" rel="stylesheet" />
|
|
11
8
|
<script src="https://cdn.jsdelivr.net/npm/@svgdotjs/svg.js"></script>
|
|
12
9
|
<script src="../apexsankey.min.js"></script>
|
|
13
10
|
</head>
|
|
14
11
|
<body>
|
|
15
|
-
<div
|
|
16
|
-
id="svg-sankey"
|
|
17
|
-
style="margin: 0 auto; width: 800px; height: 600px"
|
|
18
|
-
></div>
|
|
12
|
+
<div id="svg-sankey" style="margin: 0 auto; width: 800px; height: 600px"></div>
|
|
19
13
|
<script>
|
|
20
14
|
const data = {
|
|
21
15
|
nodes: [
|
|
22
16
|
{
|
|
23
|
-
id:
|
|
24
|
-
title:
|
|
17
|
+
id: 'Oil',
|
|
18
|
+
title: 'Oil',
|
|
25
19
|
},
|
|
26
20
|
{
|
|
27
|
-
id:
|
|
28
|
-
title:
|
|
21
|
+
id: 'Natural Gas',
|
|
22
|
+
title: 'Natural Gas',
|
|
29
23
|
},
|
|
30
24
|
{
|
|
31
|
-
id:
|
|
32
|
-
title:
|
|
25
|
+
id: 'Coal',
|
|
26
|
+
title: 'Coal',
|
|
33
27
|
},
|
|
34
28
|
{
|
|
35
|
-
id:
|
|
36
|
-
title:
|
|
29
|
+
id: 'Fossil Fuels',
|
|
30
|
+
title: 'Fossil Fuels',
|
|
37
31
|
},
|
|
38
32
|
{
|
|
39
|
-
id:
|
|
40
|
-
title:
|
|
33
|
+
id: 'Electricity',
|
|
34
|
+
title: 'Electricity',
|
|
41
35
|
},
|
|
42
36
|
{
|
|
43
|
-
id:
|
|
44
|
-
title:
|
|
37
|
+
id: 'Energy',
|
|
38
|
+
title: 'Energy',
|
|
45
39
|
},
|
|
46
40
|
],
|
|
47
41
|
edges: [
|
|
48
42
|
{
|
|
49
|
-
source:
|
|
50
|
-
target:
|
|
43
|
+
source: 'Oil',
|
|
44
|
+
target: 'Fossil Fuels',
|
|
51
45
|
value: 15,
|
|
52
46
|
},
|
|
53
47
|
{
|
|
54
|
-
source:
|
|
55
|
-
target:
|
|
48
|
+
source: 'Natural Gas',
|
|
49
|
+
target: 'Fossil Fuels',
|
|
56
50
|
value: 20,
|
|
57
51
|
},
|
|
58
52
|
{
|
|
59
|
-
source:
|
|
60
|
-
target:
|
|
53
|
+
source: 'Coal',
|
|
54
|
+
target: 'Fossil Fuels',
|
|
61
55
|
value: 25,
|
|
62
56
|
},
|
|
63
57
|
{
|
|
64
|
-
source:
|
|
65
|
-
target:
|
|
58
|
+
source: 'Coal',
|
|
59
|
+
target: 'Electricity',
|
|
66
60
|
value: 25,
|
|
67
61
|
},
|
|
68
62
|
{
|
|
69
|
-
source:
|
|
70
|
-
target:
|
|
63
|
+
source: 'Fossil Fuels',
|
|
64
|
+
target: 'Energy',
|
|
71
65
|
value: 60,
|
|
72
66
|
},
|
|
73
67
|
{
|
|
74
|
-
source:
|
|
75
|
-
target:
|
|
68
|
+
source: 'Electricity',
|
|
69
|
+
target: 'Energy',
|
|
76
70
|
value: 25,
|
|
77
71
|
},
|
|
78
72
|
],
|
|
79
73
|
};
|
|
80
74
|
const graphOptions = {
|
|
81
75
|
nodeWidth: 20,
|
|
82
|
-
fontFamily:
|
|
83
|
-
fontWeight:
|
|
76
|
+
fontFamily: 'Quicksand, sans-serif',
|
|
77
|
+
fontWeight: '600',
|
|
84
78
|
height: 600,
|
|
85
79
|
enableToolbar: true,
|
|
86
80
|
};
|
|
87
|
-
const s = new ApexSankey(
|
|
88
|
-
document.getElementById("svg-sankey"),
|
|
89
|
-
graphOptions
|
|
90
|
-
);
|
|
81
|
+
const s = new ApexSankey(document.getElementById('svg-sankey'), graphOptions);
|
|
91
82
|
s.render(data);
|
|
92
83
|
</script>
|
|
93
84
|
</body>
|
package/index.d.ts
CHANGED
|
@@ -9,4 +9,4 @@ export declare function findSpanningTree(G: any, v0: any): Graph;
|
|
|
9
9
|
* Returns 1 if w is a descendent of v, -1 if v is a descendent of w, and 0 if
|
|
10
10
|
* they are unrelated.
|
|
11
11
|
*/
|
|
12
|
-
export declare function nodeRelationship(tree: any, v: any, w: any):
|
|
12
|
+
export declare function nodeRelationship(tree: any, v: any, w: any): 0 | 1 | -1;
|
package/lib/models/Graph.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Paper } from './Paper';
|
|
|
2
2
|
import { SankeyOptions } from './Options';
|
|
3
3
|
import { Graph } from 'graphlib';
|
|
4
4
|
import { G } from '@svgdotjs/svg.js';
|
|
5
|
+
import { ChartContext } from '../../../../graph-utils/src/index.ts';
|
|
5
6
|
|
|
6
7
|
export interface GraphPoint {
|
|
7
8
|
readonly x: number;
|
|
@@ -26,6 +27,7 @@ export interface GraphData {
|
|
|
26
27
|
export declare class SankeyGraph extends Paper {
|
|
27
28
|
graph: Graph;
|
|
28
29
|
maxRank: number;
|
|
30
|
+
constructor(element: HTMLElement, options: SankeyOptions, chartContext: ChartContext);
|
|
29
31
|
construct(data: GraphData): void;
|
|
30
32
|
render({ keepOldPosition }?: {
|
|
31
33
|
keepOldPosition?: boolean;
|
package/lib/models/Paper.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { SankeyOptions } from './Options';
|
|
2
2
|
import { Element, Svg } from '@svgdotjs/svg.js';
|
|
3
|
+
import { ChartContext } from '../../../../graph-utils/src/index.ts';
|
|
3
4
|
|
|
4
5
|
export declare class Paper {
|
|
5
6
|
element: HTMLElement;
|
|
6
7
|
options: SankeyOptions;
|
|
8
|
+
protected chartContext: ChartContext;
|
|
7
9
|
canvas: Svg;
|
|
8
|
-
constructor(element: HTMLElement, options: SankeyOptions);
|
|
10
|
+
constructor(element: HTMLElement, options: SankeyOptions, chartContext: ChartContext);
|
|
9
11
|
private getYShift;
|
|
10
12
|
add(element: Element): void;
|
|
11
13
|
clear(): void;
|
package/lib/sankey.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { SankeyOptions } from './models/Options';
|
|
2
2
|
import { GraphData, SankeyGraph } from './models/Graph';
|
|
3
|
+
import { BaseChart } from '../../../graph-utils/src/index.ts';
|
|
3
4
|
|
|
4
|
-
export declare class ApexSankey {
|
|
5
|
-
element: HTMLElement;
|
|
6
|
-
options: SankeyOptions;
|
|
5
|
+
export declare class ApexSankey extends BaseChart {
|
|
7
6
|
graph: SankeyGraph;
|
|
8
|
-
|
|
7
|
+
options: SankeyOptions;
|
|
8
|
+
constructor(element: HTMLElement, options?: Partial<SankeyOptions>);
|
|
9
|
+
static setLicense(key: string): void;
|
|
10
|
+
private setupElementDimensions;
|
|
11
|
+
private handleWatermark;
|
|
9
12
|
render(data: GraphData): SankeyGraph;
|
|
10
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apexsankey",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"defined": "^1.0.1",
|
|
6
6
|
"graphlib": "~2.1.0",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"main": "./apexsankey.min.js",
|
|
11
11
|
"module": "./apexsankey.es.min.js",
|
|
12
12
|
"types": "./index.d.ts",
|
|
13
|
-
"license": "See
|
|
13
|
+
"license": "See LICENSE in LICENSE",
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
16
|
"import": {
|
|
@@ -22,21 +22,5 @@
|
|
|
22
22
|
"default": "./apexsankey.min.js"
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
},
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@commitlint/cli": "^19.8.1",
|
|
28
|
-
"@commitlint/config-conventional": "^19.8.1",
|
|
29
|
-
"commitlint": "^19.8.1",
|
|
30
|
-
"husky": "^9.1.7",
|
|
31
|
-
"standard-version": "^9.5.0"
|
|
32
|
-
},
|
|
33
|
-
"scripts": {
|
|
34
|
-
"prepare": "husky",
|
|
35
|
-
"release": "standard-version --no-tag"
|
|
36
|
-
},
|
|
37
|
-
"standard-version": {
|
|
38
|
-
"skip": {
|
|
39
|
-
"tag": true
|
|
40
|
-
}
|
|
41
25
|
}
|
|
42
|
-
}
|
|
26
|
+
}
|
package/.husky/commit-msg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npx --no -- commitlint --edit "$1"
|
package/.husky/pre-push
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npm run release && git push --no-verify
|