@hpcc-js/graph 3.7.4 → 3.7.5
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/LICENSE +43 -43
- package/README.md +256 -256
- package/dist/assets/dagre-B-z4SP0u.js.map +1 -1
- package/dist/assets/graphviz-BK7FEJlA.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +7 -7
- package/src/AdjacencyGraph.ts +224 -224
- package/src/Edge.css +22 -22
- package/src/Edge.ts +257 -257
- package/src/Graph.css +18 -18
- package/src/Graph.ts +1077 -1077
- package/src/GraphData.ts +187 -187
- package/src/GraphLayouts.ts +214 -214
- package/src/Sankey.css +44 -44
- package/src/Sankey.ts +304 -304
- package/src/Subgraph.css +9 -9
- package/src/Subgraph.ts +165 -165
- package/src/Vertex.css +2 -2
- package/src/Vertex.ts +282 -282
- package/src/__package__.ts +3 -3
- package/src/__tests__/data.ts +444 -444
- package/src/__tests__/index.ts +1 -1
- package/src/__tests__/test1.ts +18 -18
- package/src/__tests__/test2.ts +80 -80
- package/src/__tests__/test3.ts +46 -46
- package/src/__tests__/test4.ts +66 -66
- package/src/__tests__/test5.ts +85 -85
- package/src/common/graphT.css +38 -38
- package/src/common/graphT.ts +1363 -1363
- package/src/common/index.ts +3 -3
- package/src/common/layouts/circle.ts +37 -37
- package/src/common/layouts/dagre.ts +145 -145
- package/src/common/layouts/dagreWorker.ts +24 -24
- package/src/common/layouts/forceDirected.ts +117 -117
- package/src/common/layouts/forceDirectedWorker.ts +22 -22
- package/src/common/layouts/geoForceDirected.ts +112 -112
- package/src/common/layouts/graphviz.ts +137 -137
- package/src/common/layouts/graphvizWorker.ts +27 -27
- package/src/common/layouts/index.ts +7 -7
- package/src/common/layouts/layout.ts +147 -147
- package/src/common/layouts/null.ts +39 -39
- package/src/common/layouts/placeholders.ts +113 -113
- package/src/common/layouts/tree.ts +326 -326
- package/src/common/layouts/workers/dagre.ts +46 -46
- package/src/common/layouts/workers/dagreOptions.ts +35 -35
- package/src/common/layouts/workers/forceDirected.ts +38 -38
- package/src/common/layouts/workers/forceDirectedOptions.ts +30 -30
- package/src/common/layouts/workers/graphviz.ts +225 -225
- package/src/common/layouts/workers/graphvizOptions.ts +70 -70
- package/src/common/liteMap.ts +72 -72
- package/src/common/liteSVGZooom.ts +61 -61
- package/src/common/sankeyGraph.css +44 -44
- package/src/common/sankeyGraph.ts +345 -345
- package/src/html/annotation.ts +71 -71
- package/src/html/component.ts +18 -18
- package/src/html/edge.ts +15 -15
- package/src/html/graphHtml.ts +11 -11
- package/src/html/graphHtmlT.ts +117 -117
- package/src/html/icon.ts +64 -64
- package/src/html/image.ts +26 -26
- package/src/html/imageChar.ts +18 -18
- package/src/html/index.ts +8 -8
- package/src/html/intersection.ts +110 -110
- package/src/html/shape.ts +141 -141
- package/src/html/text.ts +59 -59
- package/src/html/textBox.ts +45 -45
- package/src/html/vertex.ts +67 -67
- package/src/index.ts +10 -10
- package/src/react/dataGraph.ts +345 -345
- package/src/react/graphReact.ts +177 -177
- package/src/react/graphReactT.ts +44 -44
- package/src/react/index.ts +4 -4
- package/src/react/subgraph.tsx +30 -30
- package/src/react/vertex.tsx +31 -31
|
@@ -1,147 +1,147 @@
|
|
|
1
|
-
import { Graph2 as GraphCollection } from "@hpcc-js/util";
|
|
2
|
-
import { curveBasis as d3CurveBasis, curveCardinal as d3CurveCardinal, line as d3Line } from "d3-shape";
|
|
3
|
-
import { EdgePlaceholder, SubgraphPlaceholder, VertexPlaceholder } from "./placeholders.ts";
|
|
4
|
-
import { EdgeLayout } from "./tree.ts";
|
|
5
|
-
|
|
6
|
-
export type Point = [number, number];
|
|
7
|
-
|
|
8
|
-
interface Position {
|
|
9
|
-
x: number;
|
|
10
|
-
y: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface Line {
|
|
14
|
-
source: Position;
|
|
15
|
-
target: Position;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const lineBasis = d3Line<Point>()
|
|
19
|
-
.x(d => d[0])
|
|
20
|
-
.y(d => d[1])
|
|
21
|
-
.curve(d3CurveBasis)
|
|
22
|
-
;
|
|
23
|
-
|
|
24
|
-
const lineCardinal = d3Line<Point>()
|
|
25
|
-
.x(d => d[0])
|
|
26
|
-
.y(d => d[1])
|
|
27
|
-
.curve(d3CurveCardinal)
|
|
28
|
-
;
|
|
29
|
-
|
|
30
|
-
export interface ILayout {
|
|
31
|
-
start(): Promise<this>;
|
|
32
|
-
stop(): this;
|
|
33
|
-
running(): boolean;
|
|
34
|
-
|
|
35
|
-
edgePath(e: EdgePlaceholder, curveDepth: number): EdgeLayout;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type Size = { width: number, height: number };
|
|
39
|
-
export interface IGraph {
|
|
40
|
-
id(): string;
|
|
41
|
-
size(): Size;
|
|
42
|
-
graphData(): GraphCollection<VertexPlaceholder, EdgePlaceholder, SubgraphPlaceholder>;
|
|
43
|
-
|
|
44
|
-
project(pos: number, clip?: boolean);
|
|
45
|
-
rproject(pos: number);
|
|
46
|
-
|
|
47
|
-
projectPlacholder(vp: VertexPlaceholder);
|
|
48
|
-
rprojectPlacholder(vp: VertexPlaceholder);
|
|
49
|
-
|
|
50
|
-
moveSubgraphs(transition: boolean): this;
|
|
51
|
-
|
|
52
|
-
moveVertexPlaceholder(vp: VertexPlaceholder, transition: boolean, moveEdges: boolean): this;
|
|
53
|
-
moveVertices(transition: boolean): this;
|
|
54
|
-
|
|
55
|
-
moveEdgePlaceholder(ep: EdgePlaceholder, transition: boolean): this;
|
|
56
|
-
moveEdges(transition: boolean): this;
|
|
57
|
-
|
|
58
|
-
progress(what: "start" | "stop" | "layout-start" | "layout-tick" | "layout-stop");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export class Layout implements ILayout {
|
|
62
|
-
|
|
63
|
-
protected _graph: IGraph;
|
|
64
|
-
protected _running = false;
|
|
65
|
-
|
|
66
|
-
constructor(graph: IGraph) {
|
|
67
|
-
this._graph = graph;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
start(): Promise<this> {
|
|
71
|
-
this._running = true;
|
|
72
|
-
this._graph.progress("layout-start");
|
|
73
|
-
return Promise.resolve(this);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
stop() {
|
|
77
|
-
this._running = false;
|
|
78
|
-
this._graph.progress("layout-stop");
|
|
79
|
-
return this;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
running(): boolean {
|
|
83
|
-
return this._running;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
protected center(points: Point[]): Point {
|
|
87
|
-
if (points.length % 2 === 1) {
|
|
88
|
-
return points[Math.floor(points.length / 2)];
|
|
89
|
-
}
|
|
90
|
-
const p1 = points[points.length / 2 - 1];
|
|
91
|
-
const p2 = points[points.length / 2];
|
|
92
|
-
return [(p1[0] + p2[0]) / 2, (p1[1] + p2[1]) / 2];
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
vertexSize(vp: VertexPlaceholder): { width: number, height: number } {
|
|
96
|
-
const size = vp.renderResult?.extent ? vp.renderResult.extent : vp.element.node().getBBox();
|
|
97
|
-
const retVal = {
|
|
98
|
-
width: this._graph.rproject(size.width),
|
|
99
|
-
height: this._graph.rproject(size.height)
|
|
100
|
-
};
|
|
101
|
-
return retVal;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
edgeLine(ep: EdgePlaceholder): Line {
|
|
105
|
-
const sPos = { ...this._graph.projectPlacholder(ep.source), w: ep.source?.renderResult?.extent?.width ?? 0, h: ep.source?.renderResult?.extent?.height ?? 0 };
|
|
106
|
-
const tPos = { ...this._graph.projectPlacholder(ep.target), w: ep.target?.renderResult?.extent?.width ?? 0, h: ep.target?.renderResult?.extent?.height ?? 0 };
|
|
107
|
-
const sIntersect = ep.source.renderResult?.intersection ? ep.source.renderResult.intersection(sPos, { start: sPos, end: tPos }) : null;
|
|
108
|
-
const tIntersect = ep.target.renderResult?.intersection ? ep.target.renderResult.intersection(tPos, { start: sPos, end: tPos }) : null;
|
|
109
|
-
return {
|
|
110
|
-
source: {
|
|
111
|
-
x: sIntersect ? sIntersect.x : sPos.x,
|
|
112
|
-
y: sIntersect ? sIntersect.y : sPos.y
|
|
113
|
-
},
|
|
114
|
-
target: {
|
|
115
|
-
x: tIntersect ? tIntersect.x : tPos.x,
|
|
116
|
-
y: tIntersect ? tIntersect.y : tPos.y
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
edgePath(ep: EdgePlaceholder, curveDepth: number): { path: string, labelPos: Point } {
|
|
122
|
-
const line = this.edgeLine(ep);
|
|
123
|
-
const points: Point[] = [
|
|
124
|
-
[line.source.x, line.source.y],
|
|
125
|
-
[line.target.x, line.target.y]
|
|
126
|
-
];
|
|
127
|
-
|
|
128
|
-
if (curveDepth) {
|
|
129
|
-
const dx = points[0][0] - points[1][0];
|
|
130
|
-
const dy = points[0][1] - points[1][1];
|
|
131
|
-
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
132
|
-
if (dist) {
|
|
133
|
-
const midX = (points[0][0] + points[1][0]) / 2 - dy * curveDepth / 100;
|
|
134
|
-
const midY = (points[0][1] + points[1][1]) / 2 + dx * curveDepth / 100;
|
|
135
|
-
return {
|
|
136
|
-
path: lineCardinal([points[0], [midX, midY], points[1]]),
|
|
137
|
-
labelPos: [midX, midY],
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return {
|
|
143
|
-
path: lineBasis(points),
|
|
144
|
-
labelPos: this.center(points)
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
}
|
|
1
|
+
import { Graph2 as GraphCollection } from "@hpcc-js/util";
|
|
2
|
+
import { curveBasis as d3CurveBasis, curveCardinal as d3CurveCardinal, line as d3Line } from "d3-shape";
|
|
3
|
+
import { EdgePlaceholder, SubgraphPlaceholder, VertexPlaceholder } from "./placeholders.ts";
|
|
4
|
+
import { EdgeLayout } from "./tree.ts";
|
|
5
|
+
|
|
6
|
+
export type Point = [number, number];
|
|
7
|
+
|
|
8
|
+
interface Position {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface Line {
|
|
14
|
+
source: Position;
|
|
15
|
+
target: Position;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const lineBasis = d3Line<Point>()
|
|
19
|
+
.x(d => d[0])
|
|
20
|
+
.y(d => d[1])
|
|
21
|
+
.curve(d3CurveBasis)
|
|
22
|
+
;
|
|
23
|
+
|
|
24
|
+
const lineCardinal = d3Line<Point>()
|
|
25
|
+
.x(d => d[0])
|
|
26
|
+
.y(d => d[1])
|
|
27
|
+
.curve(d3CurveCardinal)
|
|
28
|
+
;
|
|
29
|
+
|
|
30
|
+
export interface ILayout {
|
|
31
|
+
start(): Promise<this>;
|
|
32
|
+
stop(): this;
|
|
33
|
+
running(): boolean;
|
|
34
|
+
|
|
35
|
+
edgePath(e: EdgePlaceholder, curveDepth: number): EdgeLayout;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type Size = { width: number, height: number };
|
|
39
|
+
export interface IGraph {
|
|
40
|
+
id(): string;
|
|
41
|
+
size(): Size;
|
|
42
|
+
graphData(): GraphCollection<VertexPlaceholder, EdgePlaceholder, SubgraphPlaceholder>;
|
|
43
|
+
|
|
44
|
+
project(pos: number, clip?: boolean);
|
|
45
|
+
rproject(pos: number);
|
|
46
|
+
|
|
47
|
+
projectPlacholder(vp: VertexPlaceholder);
|
|
48
|
+
rprojectPlacholder(vp: VertexPlaceholder);
|
|
49
|
+
|
|
50
|
+
moveSubgraphs(transition: boolean): this;
|
|
51
|
+
|
|
52
|
+
moveVertexPlaceholder(vp: VertexPlaceholder, transition: boolean, moveEdges: boolean): this;
|
|
53
|
+
moveVertices(transition: boolean): this;
|
|
54
|
+
|
|
55
|
+
moveEdgePlaceholder(ep: EdgePlaceholder, transition: boolean): this;
|
|
56
|
+
moveEdges(transition: boolean): this;
|
|
57
|
+
|
|
58
|
+
progress(what: "start" | "stop" | "layout-start" | "layout-tick" | "layout-stop");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export class Layout implements ILayout {
|
|
62
|
+
|
|
63
|
+
protected _graph: IGraph;
|
|
64
|
+
protected _running = false;
|
|
65
|
+
|
|
66
|
+
constructor(graph: IGraph) {
|
|
67
|
+
this._graph = graph;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
start(): Promise<this> {
|
|
71
|
+
this._running = true;
|
|
72
|
+
this._graph.progress("layout-start");
|
|
73
|
+
return Promise.resolve(this);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
stop() {
|
|
77
|
+
this._running = false;
|
|
78
|
+
this._graph.progress("layout-stop");
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
running(): boolean {
|
|
83
|
+
return this._running;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
protected center(points: Point[]): Point {
|
|
87
|
+
if (points.length % 2 === 1) {
|
|
88
|
+
return points[Math.floor(points.length / 2)];
|
|
89
|
+
}
|
|
90
|
+
const p1 = points[points.length / 2 - 1];
|
|
91
|
+
const p2 = points[points.length / 2];
|
|
92
|
+
return [(p1[0] + p2[0]) / 2, (p1[1] + p2[1]) / 2];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
vertexSize(vp: VertexPlaceholder): { width: number, height: number } {
|
|
96
|
+
const size = vp.renderResult?.extent ? vp.renderResult.extent : vp.element.node().getBBox();
|
|
97
|
+
const retVal = {
|
|
98
|
+
width: this._graph.rproject(size.width),
|
|
99
|
+
height: this._graph.rproject(size.height)
|
|
100
|
+
};
|
|
101
|
+
return retVal;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
edgeLine(ep: EdgePlaceholder): Line {
|
|
105
|
+
const sPos = { ...this._graph.projectPlacholder(ep.source), w: ep.source?.renderResult?.extent?.width ?? 0, h: ep.source?.renderResult?.extent?.height ?? 0 };
|
|
106
|
+
const tPos = { ...this._graph.projectPlacholder(ep.target), w: ep.target?.renderResult?.extent?.width ?? 0, h: ep.target?.renderResult?.extent?.height ?? 0 };
|
|
107
|
+
const sIntersect = ep.source.renderResult?.intersection ? ep.source.renderResult.intersection(sPos, { start: sPos, end: tPos }) : null;
|
|
108
|
+
const tIntersect = ep.target.renderResult?.intersection ? ep.target.renderResult.intersection(tPos, { start: sPos, end: tPos }) : null;
|
|
109
|
+
return {
|
|
110
|
+
source: {
|
|
111
|
+
x: sIntersect ? sIntersect.x : sPos.x,
|
|
112
|
+
y: sIntersect ? sIntersect.y : sPos.y
|
|
113
|
+
},
|
|
114
|
+
target: {
|
|
115
|
+
x: tIntersect ? tIntersect.x : tPos.x,
|
|
116
|
+
y: tIntersect ? tIntersect.y : tPos.y
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
edgePath(ep: EdgePlaceholder, curveDepth: number): { path: string, labelPos: Point } {
|
|
122
|
+
const line = this.edgeLine(ep);
|
|
123
|
+
const points: Point[] = [
|
|
124
|
+
[line.source.x, line.source.y],
|
|
125
|
+
[line.target.x, line.target.y]
|
|
126
|
+
];
|
|
127
|
+
|
|
128
|
+
if (curveDepth) {
|
|
129
|
+
const dx = points[0][0] - points[1][0];
|
|
130
|
+
const dy = points[0][1] - points[1][1];
|
|
131
|
+
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
132
|
+
if (dist) {
|
|
133
|
+
const midX = (points[0][0] + points[1][0]) / 2 - dy * curveDepth / 100;
|
|
134
|
+
const midY = (points[0][1] + points[1][1]) / 2 + dx * curveDepth / 100;
|
|
135
|
+
return {
|
|
136
|
+
path: lineCardinal([points[0], [midX, midY], points[1]]),
|
|
137
|
+
labelPos: [midX, midY],
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
path: lineBasis(points),
|
|
144
|
+
labelPos: this.center(points)
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { Layout } from "./layout.ts";
|
|
2
|
-
|
|
3
|
-
export class Null extends Layout {
|
|
4
|
-
|
|
5
|
-
constructor(graph) {
|
|
6
|
-
super(graph);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
start(): Promise<this> {
|
|
10
|
-
return super.start().then(() => {
|
|
11
|
-
this.stop();
|
|
12
|
-
return this;
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class Initial extends Layout {
|
|
18
|
-
|
|
19
|
-
start(): Promise<this> {
|
|
20
|
-
return super.start().then(() => {
|
|
21
|
-
const size = this._graph.size();
|
|
22
|
-
const data = this._graph.graphData();
|
|
23
|
-
data.allEdges().forEach(e => delete e.points);
|
|
24
|
-
// Avoid edges of 0 length ---
|
|
25
|
-
data.allVertices().forEach(v => {
|
|
26
|
-
delete v.fx;
|
|
27
|
-
delete v.fy;
|
|
28
|
-
v.x = size.width / 2 + Math.random() * 5 - 2.5;
|
|
29
|
-
v.y = size.height / 2 + Math.random() * 5 - 2.5;
|
|
30
|
-
});
|
|
31
|
-
this._graph
|
|
32
|
-
.moveVertices(true)
|
|
33
|
-
.moveEdges(true)
|
|
34
|
-
;
|
|
35
|
-
this.stop();
|
|
36
|
-
return this;
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
1
|
+
import { Layout } from "./layout.ts";
|
|
2
|
+
|
|
3
|
+
export class Null extends Layout {
|
|
4
|
+
|
|
5
|
+
constructor(graph) {
|
|
6
|
+
super(graph);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
start(): Promise<this> {
|
|
10
|
+
return super.start().then(() => {
|
|
11
|
+
this.stop();
|
|
12
|
+
return this;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class Initial extends Layout {
|
|
18
|
+
|
|
19
|
+
start(): Promise<this> {
|
|
20
|
+
return super.start().then(() => {
|
|
21
|
+
const size = this._graph.size();
|
|
22
|
+
const data = this._graph.graphData();
|
|
23
|
+
data.allEdges().forEach(e => delete e.points);
|
|
24
|
+
// Avoid edges of 0 length ---
|
|
25
|
+
data.allVertices().forEach(v => {
|
|
26
|
+
delete v.fx;
|
|
27
|
+
delete v.fy;
|
|
28
|
+
v.x = size.width / 2 + Math.random() * 5 - 2.5;
|
|
29
|
+
v.y = size.height / 2 + Math.random() * 5 - 2.5;
|
|
30
|
+
});
|
|
31
|
+
this._graph
|
|
32
|
+
.moveVertices(true)
|
|
33
|
+
.moveEdges(true)
|
|
34
|
+
;
|
|
35
|
+
this.stop();
|
|
36
|
+
return this;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
import { Selection } from "@hpcc-js/common";
|
|
2
|
-
|
|
3
|
-
export interface BaseProps {
|
|
4
|
-
id: string | number;
|
|
5
|
-
origData?: any;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface VertexBaseProps extends BaseProps {
|
|
9
|
-
text: string;
|
|
10
|
-
categoryID?: string;
|
|
11
|
-
centroid?: boolean;
|
|
12
|
-
hidden?: boolean;
|
|
13
|
-
tooltip?: string;
|
|
14
|
-
annotationIDs?: string[];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface SubgraphBaseProps extends BaseProps {
|
|
18
|
-
text: string;
|
|
19
|
-
width?: number;
|
|
20
|
-
height?: number;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type Point = [number, number];
|
|
24
|
-
|
|
25
|
-
export interface EdgeBaseProps<V extends VertexBaseProps = VertexBaseProps> extends BaseProps {
|
|
26
|
-
source: V;
|
|
27
|
-
target: V;
|
|
28
|
-
label?: string;
|
|
29
|
-
labelPos?: Point;
|
|
30
|
-
weight?: number;
|
|
31
|
-
strokeDasharray?: string;
|
|
32
|
-
strokeWidth?: number;
|
|
33
|
-
stroke?: string;
|
|
34
|
-
path?: string;
|
|
35
|
-
fontFamily?: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface HierarchyBase<SG extends SubgraphBaseProps, V extends VertexBaseProps> {
|
|
39
|
-
id: string | number;
|
|
40
|
-
parent: SG;
|
|
41
|
-
child: SG | V;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface GraphDataProps<SG extends SubgraphBaseProps, V extends VertexBaseProps, E extends EdgeBaseProps<V>> {
|
|
45
|
-
subgraphs?: SG[];
|
|
46
|
-
vertices: V[];
|
|
47
|
-
edges: E[];
|
|
48
|
-
hierarchy?: HierarchyBase<SG, V>[];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export interface SubgraphPlaceholder<SG extends SubgraphBaseProps = SubgraphBaseProps> {
|
|
52
|
-
id: string | number;
|
|
53
|
-
element?: Selection<SVGGElement, SubgraphPlaceholder<SG>, SVGGElement, any>;
|
|
54
|
-
props: SG;
|
|
55
|
-
|
|
56
|
-
// render result properties ---
|
|
57
|
-
renderResult?: unknown;
|
|
58
|
-
|
|
59
|
-
// Dagre / Graphviz Properties ---
|
|
60
|
-
x?: number; // The node’s current x-position
|
|
61
|
-
y?: number; // The node’s current y-position
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface VertexPlaceholder<V extends VertexBaseProps = VertexBaseProps> {
|
|
65
|
-
id: string | number;
|
|
66
|
-
element?: Selection<SVGGElement, VertexPlaceholder<V>, SVGGElement, any>;
|
|
67
|
-
props: V;
|
|
68
|
-
|
|
69
|
-
// render result properties ---
|
|
70
|
-
renderResult?: any;
|
|
71
|
-
|
|
72
|
-
// D3 Assigned Properties ---
|
|
73
|
-
index?: number; // The node’s zero-based index into nodes
|
|
74
|
-
x?: number; // The node’s current x-position
|
|
75
|
-
y?: number; // The node’s current y-position
|
|
76
|
-
fx?: number; // The node’s fixed x-position
|
|
77
|
-
fy?: number; // The node’s fixed y-position
|
|
78
|
-
vx?: number; // The node’s current x-velocity
|
|
79
|
-
vy?: number; // The node’s current y-velocity
|
|
80
|
-
|
|
81
|
-
// HPCC Drag /Drop Assigned Properties ---
|
|
82
|
-
sx?: number; // The node’s drag start x
|
|
83
|
-
sy?: number; // The node’s drag start y
|
|
84
|
-
|
|
85
|
-
// Dagre / Graphviz Properties ---
|
|
86
|
-
|
|
87
|
-
// Geo Locations ---
|
|
88
|
-
lat?: number;
|
|
89
|
-
lng?: number;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export interface EdgePlaceholder<V extends VertexBaseProps = VertexBaseProps, E extends EdgeBaseProps<V> = EdgeBaseProps<V>> {
|
|
93
|
-
id: string | number;
|
|
94
|
-
element?: Selection<SVGGElement, EdgePlaceholder<V, E>, SVGGElement, any>;
|
|
95
|
-
elementPath?: Selection<SVGPathElement, EdgePlaceholder<V, E>, SVGGElement, any>;
|
|
96
|
-
elementText?: Selection<SVGTextElement, EdgePlaceholder<V, E>, SVGGElement, any>;
|
|
97
|
-
props: E;
|
|
98
|
-
source: VertexPlaceholder<V>; // The link’s source node
|
|
99
|
-
target: VertexPlaceholder<V>; // The link’s target node
|
|
100
|
-
|
|
101
|
-
// render result properties ---
|
|
102
|
-
renderResult?: any;
|
|
103
|
-
|
|
104
|
-
// D3 Assigned Properties ---
|
|
105
|
-
index?: number; // The zero-based index into links, assigned by this method
|
|
106
|
-
|
|
107
|
-
// Dagre Assigned Properties ---
|
|
108
|
-
points?: Array<[number, number]>;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export function isEdgePlaceholder<V extends VertexBaseProps = VertexBaseProps, E extends EdgeBaseProps<V> = EdgeBaseProps<V>>(item): item is EdgePlaceholder<V, E> {
|
|
112
|
-
return item.id !== undefined && item.props !== undefined && item.source !== undefined && item.target !== undefined;
|
|
113
|
-
}
|
|
1
|
+
import { Selection } from "@hpcc-js/common";
|
|
2
|
+
|
|
3
|
+
export interface BaseProps {
|
|
4
|
+
id: string | number;
|
|
5
|
+
origData?: any;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface VertexBaseProps extends BaseProps {
|
|
9
|
+
text: string;
|
|
10
|
+
categoryID?: string;
|
|
11
|
+
centroid?: boolean;
|
|
12
|
+
hidden?: boolean;
|
|
13
|
+
tooltip?: string;
|
|
14
|
+
annotationIDs?: string[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface SubgraphBaseProps extends BaseProps {
|
|
18
|
+
text: string;
|
|
19
|
+
width?: number;
|
|
20
|
+
height?: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type Point = [number, number];
|
|
24
|
+
|
|
25
|
+
export interface EdgeBaseProps<V extends VertexBaseProps = VertexBaseProps> extends BaseProps {
|
|
26
|
+
source: V;
|
|
27
|
+
target: V;
|
|
28
|
+
label?: string;
|
|
29
|
+
labelPos?: Point;
|
|
30
|
+
weight?: number;
|
|
31
|
+
strokeDasharray?: string;
|
|
32
|
+
strokeWidth?: number;
|
|
33
|
+
stroke?: string;
|
|
34
|
+
path?: string;
|
|
35
|
+
fontFamily?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface HierarchyBase<SG extends SubgraphBaseProps, V extends VertexBaseProps> {
|
|
39
|
+
id: string | number;
|
|
40
|
+
parent: SG;
|
|
41
|
+
child: SG | V;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface GraphDataProps<SG extends SubgraphBaseProps, V extends VertexBaseProps, E extends EdgeBaseProps<V>> {
|
|
45
|
+
subgraphs?: SG[];
|
|
46
|
+
vertices: V[];
|
|
47
|
+
edges: E[];
|
|
48
|
+
hierarchy?: HierarchyBase<SG, V>[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface SubgraphPlaceholder<SG extends SubgraphBaseProps = SubgraphBaseProps> {
|
|
52
|
+
id: string | number;
|
|
53
|
+
element?: Selection<SVGGElement, SubgraphPlaceholder<SG>, SVGGElement, any>;
|
|
54
|
+
props: SG;
|
|
55
|
+
|
|
56
|
+
// render result properties ---
|
|
57
|
+
renderResult?: unknown;
|
|
58
|
+
|
|
59
|
+
// Dagre / Graphviz Properties ---
|
|
60
|
+
x?: number; // The node’s current x-position
|
|
61
|
+
y?: number; // The node’s current y-position
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface VertexPlaceholder<V extends VertexBaseProps = VertexBaseProps> {
|
|
65
|
+
id: string | number;
|
|
66
|
+
element?: Selection<SVGGElement, VertexPlaceholder<V>, SVGGElement, any>;
|
|
67
|
+
props: V;
|
|
68
|
+
|
|
69
|
+
// render result properties ---
|
|
70
|
+
renderResult?: any;
|
|
71
|
+
|
|
72
|
+
// D3 Assigned Properties ---
|
|
73
|
+
index?: number; // The node’s zero-based index into nodes
|
|
74
|
+
x?: number; // The node’s current x-position
|
|
75
|
+
y?: number; // The node’s current y-position
|
|
76
|
+
fx?: number; // The node’s fixed x-position
|
|
77
|
+
fy?: number; // The node’s fixed y-position
|
|
78
|
+
vx?: number; // The node’s current x-velocity
|
|
79
|
+
vy?: number; // The node’s current y-velocity
|
|
80
|
+
|
|
81
|
+
// HPCC Drag /Drop Assigned Properties ---
|
|
82
|
+
sx?: number; // The node’s drag start x
|
|
83
|
+
sy?: number; // The node’s drag start y
|
|
84
|
+
|
|
85
|
+
// Dagre / Graphviz Properties ---
|
|
86
|
+
|
|
87
|
+
// Geo Locations ---
|
|
88
|
+
lat?: number;
|
|
89
|
+
lng?: number;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface EdgePlaceholder<V extends VertexBaseProps = VertexBaseProps, E extends EdgeBaseProps<V> = EdgeBaseProps<V>> {
|
|
93
|
+
id: string | number;
|
|
94
|
+
element?: Selection<SVGGElement, EdgePlaceholder<V, E>, SVGGElement, any>;
|
|
95
|
+
elementPath?: Selection<SVGPathElement, EdgePlaceholder<V, E>, SVGGElement, any>;
|
|
96
|
+
elementText?: Selection<SVGTextElement, EdgePlaceholder<V, E>, SVGGElement, any>;
|
|
97
|
+
props: E;
|
|
98
|
+
source: VertexPlaceholder<V>; // The link’s source node
|
|
99
|
+
target: VertexPlaceholder<V>; // The link’s target node
|
|
100
|
+
|
|
101
|
+
// render result properties ---
|
|
102
|
+
renderResult?: any;
|
|
103
|
+
|
|
104
|
+
// D3 Assigned Properties ---
|
|
105
|
+
index?: number; // The zero-based index into links, assigned by this method
|
|
106
|
+
|
|
107
|
+
// Dagre Assigned Properties ---
|
|
108
|
+
points?: Array<[number, number]>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function isEdgePlaceholder<V extends VertexBaseProps = VertexBaseProps, E extends EdgeBaseProps<V> = EdgeBaseProps<V>>(item): item is EdgePlaceholder<V, E> {
|
|
112
|
+
return item.id !== undefined && item.props !== undefined && item.source !== undefined && item.target !== undefined;
|
|
113
|
+
}
|