@hpcc-js/graph 2.86.0 → 3.1.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/dist/index.js +191 -21537
- package/dist/index.js.map +7 -1
- package/package.json +41 -58
- package/src/AdjacencyGraph.ts +3 -3
- package/src/Graph.ts +22 -20
- package/src/GraphData.ts +6 -6
- package/src/GraphLayouts.ts +203 -162
- package/src/Sankey.ts +42 -29
- package/src/Vertex.ts +2 -2
- package/src/__package__.ts +2 -2
- package/src/graph2/dataGraph.ts +109 -69
- package/src/graph2/graph.ts +12 -12
- package/src/graph2/graphReactT.ts +4 -3
- package/src/graph2/graphT.ts +26 -23
- package/src/graph2/index.ts +7 -7
- package/src/graph2/layouts/circle.ts +1 -1
- package/src/graph2/layouts/dagre.ts +3 -3
- package/src/graph2/layouts/dagreWorker.ts +4 -3
- package/src/graph2/layouts/forceDirected.ts +2 -2
- package/src/graph2/layouts/forceDirectedWorker.ts +2 -2
- package/src/graph2/layouts/graphviz.ts +3 -3
- package/src/graph2/layouts/graphvizWorker.ts +1 -1
- package/src/graph2/layouts/index.ts +7 -7
- package/src/graph2/layouts/layout.ts +2 -2
- package/src/graph2/layouts/null.ts +5 -1
- package/src/graph2/layouts/tree.ts +3 -3
- package/src/graph2/liteMap.ts +1 -1
- package/src/graph2/sankeyGraph.ts +85 -56
- package/src/graph2/subgraph.tsx +3 -3
- package/src/graph2/vertex.tsx +4 -4
- package/src/index.ts +8 -8
- package/types/AdjacencyGraph.d.ts +2 -3
- package/types/Edge.d.ts +0 -1
- package/types/Graph.d.ts +10 -10
- package/types/GraphData.d.ts +2 -3
- package/types/GraphLayouts.d.ts +45 -6
- package/types/Sankey.d.ts +27 -46
- package/types/Subgraph.d.ts +0 -1
- package/types/Vertex.d.ts +0 -1
- package/types/__package__.d.ts +2 -3
- package/types/graph2/dataGraph.d.ts +68 -34
- package/types/graph2/graph.d.ts +10 -10
- package/types/graph2/graphReactT.d.ts +3 -3
- package/types/graph2/graphT.d.ts +5 -6
- package/types/graph2/index.d.ts +7 -8
- package/types/graph2/layouts/circle.d.ts +1 -2
- package/types/graph2/layouts/dagre.d.ts +3 -4
- package/types/graph2/layouts/dagreWorker.d.ts +0 -1
- package/types/graph2/layouts/forceDirected.d.ts +2 -3
- package/types/graph2/layouts/forceDirectedWorker.d.ts +0 -1
- package/types/graph2/layouts/geoForceDirected.d.ts +0 -1
- package/types/graph2/layouts/graphviz.d.ts +2 -3
- package/types/graph2/layouts/graphvizWorker.d.ts +0 -1
- package/types/graph2/layouts/index.d.ts +7 -8
- package/types/graph2/layouts/layout.d.ts +2 -3
- package/types/graph2/layouts/null.d.ts +2 -2
- package/types/graph2/layouts/placeholders.d.ts +0 -1
- package/types/graph2/layouts/tree.d.ts +3 -4
- package/types/graph2/sankeyGraph.d.ts +54 -50
- package/types/graph2/subgraph.d.ts +2 -3
- package/types/graph2/vertex.d.ts +2 -3
- package/types/index.d.ts +8 -9
- package/dist/index.es6.js +0 -21516
- package/dist/index.es6.js.map +0 -1
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
- package/types/AdjacencyGraph.d.ts.map +0 -1
- package/types/Edge.d.ts.map +0 -1
- package/types/Graph.d.ts.map +0 -1
- package/types/GraphData.d.ts.map +0 -1
- package/types/GraphLayouts.d.ts.map +0 -1
- package/types/Sankey.d.ts.map +0 -1
- package/types/Subgraph.d.ts.map +0 -1
- package/types/Vertex.d.ts.map +0 -1
- package/types/__package__.d.ts.map +0 -1
- package/types/__tests__/data.d.ts +0 -9
- package/types/__tests__/data.d.ts.map +0 -1
- package/types/__tests__/index.d.ts +0 -2
- package/types/__tests__/index.d.ts.map +0 -1
- package/types/__tests__/test1.d.ts +0 -5
- package/types/__tests__/test1.d.ts.map +0 -1
- package/types/__tests__/test2.d.ts +0 -5
- package/types/__tests__/test2.d.ts.map +0 -1
- package/types/__tests__/test3.d.ts +0 -5
- package/types/__tests__/test3.d.ts.map +0 -1
- package/types/__tests__/test4.d.ts +0 -5
- package/types/__tests__/test4.d.ts.map +0 -1
- package/types/__tests__/test5.d.ts +0 -30
- package/types/__tests__/test5.d.ts.map +0 -1
- package/types/graph2/dataGraph.d.ts.map +0 -1
- package/types/graph2/graph.d.ts.map +0 -1
- package/types/graph2/graphReactT.d.ts.map +0 -1
- package/types/graph2/graphT.d.ts.map +0 -1
- package/types/graph2/index.d.ts.map +0 -1
- package/types/graph2/layouts/circle.d.ts.map +0 -1
- package/types/graph2/layouts/dagre.d.ts.map +0 -1
- package/types/graph2/layouts/dagreWorker.d.ts.map +0 -1
- package/types/graph2/layouts/forceDirected.d.ts.map +0 -1
- package/types/graph2/layouts/forceDirectedWorker.d.ts.map +0 -1
- package/types/graph2/layouts/geoForceDirected.d.ts.map +0 -1
- package/types/graph2/layouts/graphviz.d.ts.map +0 -1
- package/types/graph2/layouts/graphvizWorker.d.ts.map +0 -1
- package/types/graph2/layouts/index.d.ts.map +0 -1
- package/types/graph2/layouts/layout.d.ts.map +0 -1
- package/types/graph2/layouts/null.d.ts.map +0 -1
- package/types/graph2/layouts/placeholders.d.ts.map +0 -1
- package/types/graph2/layouts/tree.d.ts.map +0 -1
- package/types/graph2/liteMap.d.ts +0 -13
- package/types/graph2/liteMap.d.ts.map +0 -1
- package/types/graph2/liteSVGZooom.d.ts +0 -16
- package/types/graph2/liteSVGZooom.d.ts.map +0 -1
- package/types/graph2/sankeyGraph.d.ts.map +0 -1
- package/types/graph2/subgraph.d.ts.map +0 -1
- package/types/graph2/vertex.d.ts.map +0 -1
- package/types/index.d.ts.map +0 -1
- package/types/test.d.ts +0 -17
- package/types/test.d.ts.map +0 -1
- package/types-3.4/AdjacencyGraph.d.ts +0 -69
- package/types-3.4/Edge.d.ts +0 -60
- package/types-3.4/Graph.d.ts +0 -159
- package/types-3.4/GraphData.d.ts +0 -33
- package/types-3.4/GraphLayouts.d.ts +0 -6
- package/types-3.4/Sankey.d.ts +0 -72
- package/types-3.4/Subgraph.d.ts +0 -45
- package/types-3.4/Vertex.d.ts +0 -83
- package/types-3.4/__package__.d.ts +0 -4
- package/types-3.4/__tests__/data.d.ts +0 -9
- package/types-3.4/__tests__/index.d.ts +0 -2
- package/types-3.4/__tests__/test1.d.ts +0 -5
- package/types-3.4/__tests__/test2.d.ts +0 -5
- package/types-3.4/__tests__/test3.d.ts +0 -5
- package/types-3.4/__tests__/test4.d.ts +0 -5
- package/types-3.4/__tests__/test5.d.ts +0 -30
- package/types-3.4/graph2/dataGraph.d.ts +0 -66
- package/types-3.4/graph2/graph.d.ts +0 -55
- package/types-3.4/graph2/graphReactT.d.ts +0 -15
- package/types-3.4/graph2/graphT.d.ts +0 -234
- package/types-3.4/graph2/index.d.ts +0 -8
- package/types-3.4/graph2/layouts/circle.d.ts +0 -7
- package/types-3.4/graph2/layouts/dagre.d.ts +0 -13
- package/types-3.4/graph2/layouts/dagreWorker.d.ts +0 -35
- package/types-3.4/graph2/layouts/forceDirected.d.ts +0 -19
- package/types-3.4/graph2/layouts/forceDirectedWorker.d.ts +0 -32
- package/types-3.4/graph2/layouts/geoForceDirected.d.ts +0 -2
- package/types-3.4/graph2/layouts/graphviz.d.ts +0 -15
- package/types-3.4/graph2/layouts/graphvizWorker.d.ts +0 -59
- package/types-3.4/graph2/layouts/index.d.ts +0 -8
- package/types-3.4/graph2/layouts/layout.d.ts +0 -43
- package/types-3.4/graph2/layouts/null.d.ts +0 -8
- package/types-3.4/graph2/layouts/placeholders.d.ts +0 -83
- package/types-3.4/graph2/layouts/tree.d.ts +0 -51
- package/types-3.4/graph2/liteMap.d.ts +0 -16
- package/types-3.4/graph2/liteSVGZooom.d.ts +0 -16
- package/types-3.4/graph2/sankeyGraph.d.ts +0 -73
- package/types-3.4/graph2/subgraph.d.ts +0 -12
- package/types-3.4/graph2/vertex.d.ts +0 -13
- package/types-3.4/index.d.ts +0 -9
- package/types-3.4/test.d.ts +0 -17
package/package.json
CHANGED
|
@@ -1,81 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hpcc-js/graph",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "hpcc-js - Viz Graph",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
"*": [
|
|
13
|
-
"types-3.4/index.d.ts"
|
|
14
|
-
]
|
|
15
|
-
}
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./types/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./dist/*": "./dist/*"
|
|
16
12
|
},
|
|
13
|
+
"module": "./dist/index.js",
|
|
14
|
+
"browser": "./dist/index.js",
|
|
15
|
+
"types": "./types/index.d.ts",
|
|
17
16
|
"files": [
|
|
18
17
|
"dist/*",
|
|
19
|
-
"
|
|
20
|
-
"types
|
|
21
|
-
"src/*"
|
|
18
|
+
"src/*",
|
|
19
|
+
"types/*"
|
|
22
20
|
],
|
|
23
21
|
"scripts": {
|
|
24
|
-
"clean": "rimraf --glob lib* types dist *.tsbuildinfo
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"bundle": "rollup -c",
|
|
31
|
-
"bundle-workers": "rollup -c ./workers/rollup.config.js",
|
|
32
|
-
"bundle-watch": "npm run bundle -- -w",
|
|
33
|
-
"minimize": "terser dist/index.js -c -m --source-map \"content='dist/index.js.map',url='index.min.js.map'\" -o dist/index.min.js",
|
|
34
|
-
"minimize-workers-forceDirected": "terser workers/dist/forceDirected.js -c -m -o workers/dist/forceDirected.min.js",
|
|
35
|
-
"minimize-workers-dagre": "terser workers/dist/dagre.js -c -m -o workers/dist/dagre.min.js",
|
|
36
|
-
"minimize-workers-graphviz": "terser workers/dist/graphviz.js -c -m -o workers/dist/graphviz.min.js",
|
|
37
|
-
"minimize-workers": "run-p minimize-workers-forceDirected minimize-workers-dagre minimize-workers-graphviz",
|
|
38
|
-
"wrap-workers-forceDirected": "node util/wrapWorker.js forceDirected",
|
|
39
|
-
"wrap-workers-dagre": "node util/wrapWorker.js dagre",
|
|
40
|
-
"wrap-workers-graphviz": "node util/wrapWorker.js graphviz",
|
|
41
|
-
"wrap-workers": "run-p wrap-workers-forceDirected wrap-workers-dagre wrap-workers-graphviz",
|
|
42
|
-
"build-workers": "run-s compile-workers bundle-workers minimize-workers wrap-workers",
|
|
43
|
-
"build-package": "npm run compile-es6 && npm run bundle",
|
|
44
|
-
"gen-legacy-types": "downlevel-dts ./types ./types-3.4",
|
|
45
|
-
"build": "run-s build-workers build-package",
|
|
46
|
-
"watch": "npm-run-all compile-es6 -p compile-es6-watch bundle-watch",
|
|
47
|
-
"stamp": "node ../../node_modules/@hpcc-js/bundle/src/stamp.js",
|
|
22
|
+
"clean": "rimraf --glob lib* types dist *.tsbuildinfo .turbo",
|
|
23
|
+
"bundle": "node esbuild.js",
|
|
24
|
+
"bundle-watch": "npm run bundle -- --development --watch",
|
|
25
|
+
"gen-types": "tsc --project tsconfig.json",
|
|
26
|
+
"gen-types-watch": "npm run gen-types -- --watch",
|
|
27
|
+
"build": "run-p gen-types bundle",
|
|
48
28
|
"lint": "eslint ./src",
|
|
29
|
+
"lint-fix": "eslint --fix src/**/*.ts",
|
|
49
30
|
"docs": "typedoc --options tdoptions.json .",
|
|
50
|
-
"
|
|
51
|
-
"
|
|
31
|
+
"test-browser": "vitest run --project browser",
|
|
32
|
+
"test": "vitest run",
|
|
33
|
+
"coverage": "vitest run --coverage",
|
|
34
|
+
"update": "npx --yes npm-check-updates -u -t minor",
|
|
35
|
+
"update-major": "npx --yes npm-check-updates -u"
|
|
52
36
|
},
|
|
53
37
|
"dependencies": {
|
|
54
|
-
"@hpcc-js/api": "^2.
|
|
55
|
-
"@hpcc-js/common": "^2.
|
|
56
|
-
"@hpcc-js/html": "^
|
|
57
|
-
"@hpcc-js/react": "^
|
|
58
|
-
"@hpcc-js/util": "^2.
|
|
38
|
+
"@hpcc-js/api": "^3.2.0",
|
|
39
|
+
"@hpcc-js/common": "^3.2.0",
|
|
40
|
+
"@hpcc-js/html": "^3.1.0",
|
|
41
|
+
"@hpcc-js/react": "^3.1.0",
|
|
42
|
+
"@hpcc-js/util": "^3.2.0"
|
|
59
43
|
},
|
|
60
44
|
"devDependencies": {
|
|
61
|
-
"@
|
|
62
|
-
"@hpcc-js/
|
|
63
|
-
"@
|
|
64
|
-
"@types/
|
|
65
|
-
"d3-array": "^1",
|
|
66
|
-
"d3-drag": "^1",
|
|
45
|
+
"@dagrejs/dagre": "1.1.4",
|
|
46
|
+
"@hpcc-js/esbuild-plugins": "^1.3.0",
|
|
47
|
+
"@hpcc-js/wasm-graphviz": "1.6.1",
|
|
48
|
+
"@types/d3-transition": "1.3.6",
|
|
67
49
|
"d3-force": "^1",
|
|
68
50
|
"d3-geo": "^1",
|
|
69
51
|
"d3-interpolate-path": "2.3.0",
|
|
70
52
|
"d3-sankey": "^0",
|
|
71
|
-
"d3-scale": "^1",
|
|
72
|
-
"d3-selection": "^1",
|
|
73
53
|
"d3-shape": "^1",
|
|
74
54
|
"d3-tile": "^1",
|
|
75
55
|
"d3-transition": "^1",
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
|
|
56
|
+
"react": "18.3.1",
|
|
57
|
+
"react-dom": "18.3.1"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"react": "^17.0.0 || ^18.0.0",
|
|
61
|
+
"react-dom": "^17.0.0 || ^18.0.0"
|
|
79
62
|
},
|
|
80
63
|
"repository": {
|
|
81
64
|
"type": "git",
|
|
@@ -88,5 +71,5 @@
|
|
|
88
71
|
"url": "https://github.com/hpcc-systems/Visualization/issues"
|
|
89
72
|
},
|
|
90
73
|
"homepage": "https://github.com/hpcc-systems/Visualization",
|
|
91
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "658c50fd965a7744ba8db675ba6878607c44d5e2"
|
|
92
75
|
}
|
package/src/AdjacencyGraph.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PropertyExt } from "@hpcc-js/common";
|
|
2
2
|
import { hashSum } from "@hpcc-js/util";
|
|
3
|
-
import { Edge } from "./Edge";
|
|
4
|
-
import { Graph, IGraphData } from "./Graph";
|
|
5
|
-
import { IAnnotation, Vertex } from "./Vertex";
|
|
3
|
+
import { Edge } from "./Edge.ts";
|
|
4
|
+
import { Graph, IGraphData } from "./Graph.ts";
|
|
5
|
+
import { IAnnotation, Vertex } from "./Vertex.ts";
|
|
6
6
|
|
|
7
7
|
interface IAnnotationIndexes {
|
|
8
8
|
iconCol: number;
|
package/src/Graph.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import { d3Event, drag as d3Drag, ISize, Platform, select as d3Select, Spacer, SVGGlowFilter, SVGZoomWidget, ToggleButton, Utility, Widget } from "@hpcc-js/common";
|
|
3
3
|
|
|
4
4
|
import "d3-transition";
|
|
5
|
-
import { Edge } from "./Edge";
|
|
6
|
-
import { GraphData } from "./GraphData";
|
|
7
|
-
import * as GraphLayouts from "./GraphLayouts";
|
|
8
|
-
import { Subgraph } from "./Subgraph";
|
|
9
|
-
import { Vertex } from "./Vertex";
|
|
5
|
+
import { Edge } from "./Edge.ts";
|
|
6
|
+
import { GraphData } from "./GraphData.ts";
|
|
7
|
+
import * as GraphLayouts from "./GraphLayouts.ts";
|
|
8
|
+
import { Subgraph } from "./Subgraph.ts";
|
|
9
|
+
import { Vertex } from "./Vertex.ts";
|
|
10
10
|
|
|
11
11
|
import "../src/Graph.css";
|
|
12
12
|
|
|
@@ -105,7 +105,7 @@ export class Graph extends SVGZoomWidget {
|
|
|
105
105
|
size(): ISize;
|
|
106
106
|
size(_): this;
|
|
107
107
|
size(_?): ISize | this {
|
|
108
|
-
const retVal = super.size.apply(this, arguments);
|
|
108
|
+
const retVal = super.size.apply(this, arguments as any);
|
|
109
109
|
return retVal;
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -117,7 +117,7 @@ export class Graph extends SVGZoomWidget {
|
|
|
117
117
|
data(): IGraphData;
|
|
118
118
|
data(_: IGraphData, merge?: boolean): this;
|
|
119
119
|
data(_?: IGraphData, merge?: boolean): IGraphData | this {
|
|
120
|
-
const retVal = super.data.apply(this, arguments);
|
|
120
|
+
const retVal = super.data.apply(this, arguments as any);
|
|
121
121
|
if (arguments.length) {
|
|
122
122
|
if (!merge) {
|
|
123
123
|
this._graphData = new GraphData();
|
|
@@ -283,7 +283,7 @@ export class Graph extends SVGZoomWidget {
|
|
|
283
283
|
this._neighborOffsets = [];
|
|
284
284
|
|
|
285
285
|
if (Platform.svgMarkerGlitch) {
|
|
286
|
-
this._graphData.nodeEdges(d.id()).forEach(function (id) {
|
|
286
|
+
this._graphData.nodeEdges(d.id()).forEach(function (this, id) {
|
|
287
287
|
const edge = this._graphData.edge(id);
|
|
288
288
|
this._popMarkers(edge.element());
|
|
289
289
|
});
|
|
@@ -639,7 +639,7 @@ export class Graph extends SVGZoomWidget {
|
|
|
639
639
|
}
|
|
640
640
|
|
|
641
641
|
const context = this;
|
|
642
|
-
const layoutEngine = this.getLayoutEngine();
|
|
642
|
+
const layoutEngine = this.getLayoutEngine() as GraphLayouts.ForceDirected;
|
|
643
643
|
if (this.layout() === "ForceDirected2") {
|
|
644
644
|
this.forceLayout = layoutEngine;
|
|
645
645
|
this.forceLayout.force
|
|
@@ -964,15 +964,6 @@ export class Graph extends SVGZoomWidget {
|
|
|
964
964
|
;
|
|
965
965
|
}
|
|
966
966
|
|
|
967
|
-
// IGraph ---
|
|
968
|
-
edge_click: (_row, _col, _sel, _more) => void;
|
|
969
|
-
edge_dblclick: (_row, _col, _sel, _more) => void;
|
|
970
|
-
|
|
971
|
-
// ITooltip ---
|
|
972
|
-
tooltip;
|
|
973
|
-
tooltipHTML: (_) => string;
|
|
974
|
-
tooltipFormat: (_) => string;
|
|
975
|
-
|
|
976
967
|
// Progess Events ---
|
|
977
968
|
progress(what: "start" | "end" | "layout-start" | "layout-tick" | "layout-end") {
|
|
978
969
|
}
|
|
@@ -988,7 +979,8 @@ export interface Graph {
|
|
|
988
979
|
dragSingleNeighbors(_: boolean): this;
|
|
989
980
|
layout(): GraphLayoutType;
|
|
990
981
|
layout(_: GraphLayoutType): this;
|
|
991
|
-
// scale
|
|
982
|
+
// scale(): string;
|
|
983
|
+
// scale(_: string): this;
|
|
992
984
|
applyScaleOnLayout(): boolean;
|
|
993
985
|
applyScaleOnLayout(_: boolean): this;
|
|
994
986
|
highlightOnMouseOverVertex(): boolean;
|
|
@@ -1034,6 +1026,15 @@ export interface Graph {
|
|
|
1034
1026
|
forceDirectedTheta(_: number): this;
|
|
1035
1027
|
forceDirectedGravity(): number;
|
|
1036
1028
|
forceDirectedGravity(_: number): this;
|
|
1029
|
+
|
|
1030
|
+
// IGraph ---
|
|
1031
|
+
edge_click(_row, _col, _sel, _more): void;
|
|
1032
|
+
edge_dblclick(_row, _col, _sel, _more): void;
|
|
1033
|
+
|
|
1034
|
+
// ITooltip ---
|
|
1035
|
+
tooltip;
|
|
1036
|
+
tooltipHTML(_): string;
|
|
1037
|
+
tooltipFormat(_): string;
|
|
1037
1038
|
}
|
|
1038
1039
|
|
|
1039
1040
|
Graph.prototype.publish("allowDragging", true, "boolean", "Allow Dragging of Vertices", null, { tags: ["Advanced"] });
|
|
@@ -1066,8 +1067,9 @@ Graph.prototype.publish("forceDirectedTheta", 0.8, "number", "Barnes–Hut appro
|
|
|
1066
1067
|
Graph.prototype.publish("forceDirectedGravity", 0.1, "number", "Gravitational strength", null, { tags: ["Advanced"] });
|
|
1067
1068
|
|
|
1068
1069
|
const _origScale = Graph.prototype.scale;
|
|
1070
|
+
//@ts-ignore
|
|
1069
1071
|
Graph.prototype.scale = function (_?, transitionDuration?) {
|
|
1070
|
-
const retVal = _origScale.apply(this, arguments);
|
|
1072
|
+
const retVal = _origScale.apply(this, arguments as any);
|
|
1071
1073
|
if (arguments.length) {
|
|
1072
1074
|
this.zoomTo(_, transitionDuration);
|
|
1073
1075
|
}
|
package/src/GraphData.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Edge as GLEdge, GraphEdge, graphlib, Node } from "dagre";
|
|
2
|
-
import { Vertex } from "./Vertex";
|
|
1
|
+
import { Edge as GLEdge, GraphEdge, graphlib, Node } from "@dagrejs/dagre";
|
|
2
|
+
import { Vertex } from "./Vertex.ts";
|
|
3
3
|
|
|
4
4
|
type GLNode = Node<Vertex>;
|
|
5
5
|
|
|
@@ -40,9 +40,9 @@ export class GraphData {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
eachNode(callback) {
|
|
43
|
-
this._g.nodes().forEach(
|
|
43
|
+
this._g.nodes().forEach(item => {
|
|
44
44
|
callback(item, this.node(item));
|
|
45
|
-
}
|
|
45
|
+
});
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
private filterEdges(pred): GLEdge[] {
|
|
@@ -56,9 +56,9 @@ export class GraphData {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
eachEdge(callback) {
|
|
59
|
-
this._g.edges().forEach(
|
|
59
|
+
this._g.edges().forEach(item => {
|
|
60
60
|
callback(item, item.v, item.w, this.edge(item));
|
|
61
|
-
}
|
|
61
|
+
});
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
setData(subgraphs, vertices, edges, hierarchy, merge) {
|
package/src/GraphLayouts.ts
CHANGED
|
@@ -1,173 +1,214 @@
|
|
|
1
1
|
import { forceCenter as d3ForceCenter, forceLink as d3ForceLink, forceManyBody as d3ForceManyBody, forceSimulation as d3ForceSimulation } from "d3-force";
|
|
2
|
-
import { GraphLabel, graphlib, layout } from "dagre";
|
|
3
|
-
import { GraphData } from "./GraphData";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
currStep
|
|
25
|
-
|
|
2
|
+
import { GraphLabel, graphlib, layout } from "@dagrejs/dagre";
|
|
3
|
+
import { GraphData } from "./GraphData.ts";
|
|
4
|
+
|
|
5
|
+
interface Pos {
|
|
6
|
+
x?: number;
|
|
7
|
+
y?: number;
|
|
8
|
+
width?: number;
|
|
9
|
+
height?: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class Circle {
|
|
13
|
+
|
|
14
|
+
protected pos: { [id: string]: Pos } = {};
|
|
15
|
+
|
|
16
|
+
constructor(graphData: GraphData, width?, height?, radius?) {
|
|
17
|
+
const context = this;
|
|
18
|
+
this.pos = {};
|
|
19
|
+
|
|
20
|
+
// Initial Positions ---
|
|
21
|
+
const padding = 0;
|
|
22
|
+
radius = radius || (width < height ? width - padding : height - padding) / 2;
|
|
23
|
+
const order = graphData.nodeCount();
|
|
24
|
+
let currStep = -Math.PI / 2;
|
|
25
|
+
const step = 2 * Math.PI / order;
|
|
26
|
+
graphData.eachNode(function (u, value) {
|
|
27
|
+
const size = value.getBBox();
|
|
28
|
+
const maxSize = 0; // Math.max(size.width, size.height);
|
|
29
|
+
context.pos[u] = {
|
|
30
|
+
x: value.fixed ? value.x : width / 2 + Math.cos(currStep) * (radius - maxSize),
|
|
31
|
+
y: value.fixed ? value.y : height / 2 + Math.sin(currStep) * (radius - maxSize),
|
|
32
|
+
width: size.width,
|
|
33
|
+
height: size.height
|
|
34
|
+
};
|
|
35
|
+
currStep += step;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
nodePos(u) {
|
|
40
|
+
return this.pos[u];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
edgePoints(_e) {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
|
|
26
47
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
|
|
49
|
+
export class None {
|
|
50
|
+
|
|
51
|
+
protected pos: { [id: string]: Pos } = {};
|
|
52
|
+
|
|
53
|
+
constructor(graphData: GraphData, _width, _height, _radius) {
|
|
54
|
+
const context = this;
|
|
55
|
+
this.pos = {};
|
|
56
|
+
|
|
57
|
+
graphData.eachNode(function (u, value) {
|
|
58
|
+
context.pos[u] = {
|
|
59
|
+
x: value.x,
|
|
60
|
+
y: value.y,
|
|
61
|
+
width: value.width,
|
|
62
|
+
height: value.height
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
nodePos(u) {
|
|
68
|
+
return this.pos[u];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
edgePoints(_e) {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
46
74
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this.edges = [];
|
|
76
|
-
graphData.eachEdge(function (_e, s, t) {
|
|
77
|
-
context.edges.push({
|
|
78
|
-
source: s,
|
|
79
|
-
target: t
|
|
75
|
+
|
|
76
|
+
export class ForceDirected {
|
|
77
|
+
|
|
78
|
+
protected pos: { [id: string]: Pos } = {};
|
|
79
|
+
vertices: any[] = [];
|
|
80
|
+
protected vertexMap: { [id: string]: any } = {};
|
|
81
|
+
protected edges: any[] = [];
|
|
82
|
+
protected force: any;
|
|
83
|
+
|
|
84
|
+
constructor(graphData: GraphData, width, height, options) {
|
|
85
|
+
options = options || {};
|
|
86
|
+
this.pos = {};
|
|
87
|
+
this.vertices = [];
|
|
88
|
+
this.vertexMap = {};
|
|
89
|
+
|
|
90
|
+
graphData.eachNode(u => {
|
|
91
|
+
const vertex = graphData.node(u);
|
|
92
|
+
const size = vertex.getBBox();
|
|
93
|
+
const newItem = {
|
|
94
|
+
id: u,
|
|
95
|
+
x: vertex.pos().x,
|
|
96
|
+
y: vertex.pos().y,
|
|
97
|
+
width: size.width,
|
|
98
|
+
height: size.height,
|
|
99
|
+
value: vertex
|
|
100
|
+
};
|
|
101
|
+
this.vertices.push(newItem);
|
|
102
|
+
this.vertexMap[u] = newItem;
|
|
80
103
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
104
|
+
this.edges = [];
|
|
105
|
+
graphData.eachEdge((_e, s, t) => {
|
|
106
|
+
this.edges.push({
|
|
107
|
+
source: s,
|
|
108
|
+
target: t
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
const forceLink = d3ForceLink()
|
|
112
|
+
.id(function (d: any) {
|
|
113
|
+
return d.id;
|
|
114
|
+
})
|
|
115
|
+
.distance(options.linkDistance)
|
|
116
|
+
.strength(options.linkStrength)
|
|
117
|
+
;
|
|
118
|
+
const forceManyBody = d3ForceManyBody()
|
|
119
|
+
.strength(function (d: any) {
|
|
120
|
+
const cs = d.value.getBBox();
|
|
121
|
+
return options.charge * Math.max(cs.width, cs.height);
|
|
122
|
+
})
|
|
123
|
+
;
|
|
124
|
+
this.force = d3ForceSimulation()
|
|
125
|
+
.force("link", forceLink)
|
|
126
|
+
.force("charge", forceManyBody)
|
|
127
|
+
.force("center", d3ForceCenter(width / 2, height / 2))
|
|
128
|
+
.velocityDecay(options.oneShot ? 0.1 : options.friction)
|
|
129
|
+
.nodes(this.vertices)
|
|
130
|
+
;
|
|
131
|
+
forceLink
|
|
132
|
+
.links(this.edges)
|
|
133
|
+
;
|
|
134
|
+
|
|
135
|
+
if (options.oneShot) {
|
|
136
|
+
this.force.restart();
|
|
137
|
+
let total = graphData.nodeCount();
|
|
138
|
+
total = Math.min(total * total, 500);
|
|
139
|
+
for (let i = 0; i < total; ++i) {
|
|
140
|
+
this.force.tick();
|
|
141
|
+
}
|
|
142
|
+
this.force.stop();
|
|
112
143
|
}
|
|
113
|
-
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
nodePos(u) {
|
|
147
|
+
return this.vertexMap[u];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
edgePoints(_e) {
|
|
151
|
+
return [];
|
|
114
152
|
}
|
|
115
153
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
154
|
+
|
|
155
|
+
export class Hierarchy {
|
|
156
|
+
|
|
157
|
+
protected digraph: any;
|
|
158
|
+
protected dagreLayout: any;
|
|
159
|
+
|
|
160
|
+
constructor(graphData: GraphData, _width, _height, options) {
|
|
161
|
+
this.digraph = new graphlib.Graph({ multigraph: true, compound: true })
|
|
162
|
+
.setGraph(options)
|
|
163
|
+
.setDefaultNodeLabel(function () { return {}; })
|
|
164
|
+
.setDefaultEdgeLabel(function () { return {}; })
|
|
165
|
+
;
|
|
166
|
+
graphData.eachNode(u => {
|
|
167
|
+
const value = graphData.node(u);
|
|
168
|
+
const clientSize = value.getBBox();
|
|
169
|
+
this.digraph.setNode(u, {
|
|
170
|
+
width: clientSize.width,
|
|
171
|
+
height: clientSize.height
|
|
172
|
+
});
|
|
135
173
|
});
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
digraph.setEdge(s, t, {
|
|
140
|
-
weight: value.weight()
|
|
141
|
-
}, value._id);
|
|
142
|
-
if (!options.digraph) {
|
|
143
|
-
digraph.setEdge(t, s, {
|
|
174
|
+
graphData.eachEdge((e, s, t) => {
|
|
175
|
+
const value = graphData.edge(e);
|
|
176
|
+
this.digraph.setEdge(s, t, {
|
|
144
177
|
weight: value.weight()
|
|
145
178
|
}, value._id);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
value.
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
179
|
+
if (!options.digraph) {
|
|
180
|
+
this.digraph.setEdge(t, s, {
|
|
181
|
+
weight: value.weight()
|
|
182
|
+
}, value._id);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
graphData.eachNode(u => {
|
|
186
|
+
this.digraph.setParent(u, graphData.parent(u));
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
this.dagreLayout = layout(this.digraph, { debugTiming: false } as GraphLabel);
|
|
190
|
+
const deltaX = -this.digraph.graph().width / 2;
|
|
191
|
+
const deltaY = -this.digraph.graph().height / 2;
|
|
192
|
+
this.digraph.nodes().forEach(u => {
|
|
193
|
+
const value = this.digraph.node(u);
|
|
194
|
+
value.x += deltaX + _width / 2;
|
|
195
|
+
value.y += deltaY + _height / 2;
|
|
196
|
+
});
|
|
197
|
+
this.digraph.edges().forEach(e => {
|
|
198
|
+
const value = this.digraph.edge(e);
|
|
199
|
+
for (let i = 0; i < value.points.length; ++i) {
|
|
200
|
+
value.points[i].x += deltaX + _width / 2;
|
|
201
|
+
value.points[i].y += deltaY + _height / 2;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
this.digraph = this.digraph;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
nodePos(u) {
|
|
208
|
+
return this.digraph.node(u);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
edgePoints(edge) {
|
|
212
|
+
return this.digraph.edge(edge._sourceVertex.id(), edge._targetVertex.id(), edge._id).points;
|
|
213
|
+
}
|
|
167
214
|
}
|
|
168
|
-
Hierarchy.prototype.nodePos = function (u) {
|
|
169
|
-
return this.digraph.node(u);
|
|
170
|
-
};
|
|
171
|
-
Hierarchy.prototype.edgePoints = function (edge) {
|
|
172
|
-
return this.digraph.edge(edge._sourceVertex.id(), edge._targetVertex.id(), edge._id).points;
|
|
173
|
-
};
|