@hpcc-js/graph 3.6.3 → 3.6.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-CjmNyQgU.js.map → graphviz-DQ0E8zfY.js.map} +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +2 -2
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +8 -8
- package/src/AdjacencyGraph.ts +224 -224
- package/src/Edge.css +23 -23
- 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 +46 -46
- package/src/Sankey.ts +304 -304
- package/src/Subgraph.css +10 -10
- package/src/Subgraph.ts +165 -165
- package/src/Vertex.css +3 -3
- 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 +45 -45
- 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
package/src/__tests__/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Test2 as Test } from "./test2";
|
|
1
|
+
export { Test2 as Test } from "./test2";
|
package/src/__tests__/test1.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Graph } from "../Graph";
|
|
2
|
-
import { createData } from "./data";
|
|
3
|
-
|
|
4
|
-
export class Test extends Graph {
|
|
5
|
-
|
|
6
|
-
constructor() {
|
|
7
|
-
super();
|
|
8
|
-
this
|
|
9
|
-
.data(createData())
|
|
10
|
-
.layout("ForceDirected")
|
|
11
|
-
.applyScaleOnLayout(true)
|
|
12
|
-
.centroidColor("darkgreen")
|
|
13
|
-
.dragSingleNeighbors(true)
|
|
14
|
-
.highlightSelectedPathToCentroid(true)
|
|
15
|
-
;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
1
|
+
import { Graph } from "../Graph";
|
|
2
|
+
import { createData } from "./data";
|
|
3
|
+
|
|
4
|
+
export class Test extends Graph {
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this
|
|
9
|
+
.data(createData())
|
|
10
|
+
.layout("ForceDirected")
|
|
11
|
+
.applyScaleOnLayout(true)
|
|
12
|
+
.centroidColor("darkgreen")
|
|
13
|
+
.dragSingleNeighbors(true)
|
|
14
|
+
.highlightSelectedPathToCentroid(true)
|
|
15
|
+
;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
package/src/__tests__/test2.ts
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import { DataGraph } from "../graph2/dataGraph";
|
|
2
|
-
import { genData2 } from "./data";
|
|
3
|
-
|
|
4
|
-
export class Test2 extends DataGraph {
|
|
5
|
-
|
|
6
|
-
constructor() {
|
|
7
|
-
super();
|
|
8
|
-
const g = genData2();
|
|
9
|
-
this
|
|
10
|
-
.layout("ForceDirected")
|
|
11
|
-
.forceDirectedRepulsionStrength(-3500)
|
|
12
|
-
.forceDirectedLinkDistance(150)
|
|
13
|
-
.forceDirectedLinkStrength(1.5)
|
|
14
|
-
.forceDirectedPinCentroid(true)
|
|
15
|
-
.hierarchyDigraph(false)
|
|
16
|
-
|
|
17
|
-
.centroidColor("#777777")
|
|
18
|
-
|
|
19
|
-
.selectionGlowColor("#555555")
|
|
20
|
-
.highlightOnMouseOverEdge(true)
|
|
21
|
-
.highlightOnMouseOverVertex(true)
|
|
22
|
-
.showVertexLabels(true)
|
|
23
|
-
|
|
24
|
-
.applyScaleOnLayout(true)
|
|
25
|
-
.zoomToFitLimit(1)
|
|
26
|
-
|
|
27
|
-
.edgeArcDepth(8)
|
|
28
|
-
.edgeStrokeWidth(2)
|
|
29
|
-
.edgeColor("#287EC4")
|
|
30
|
-
|
|
31
|
-
.allowDragging(true)
|
|
32
|
-
|
|
33
|
-
.annotations([{
|
|
34
|
-
id: "0",
|
|
35
|
-
imageChar: "fa-plus",
|
|
36
|
-
fill: "white",
|
|
37
|
-
stroke: "whitesmoke",
|
|
38
|
-
imageCharFill: "red"
|
|
39
|
-
}, {
|
|
40
|
-
id: "1",
|
|
41
|
-
imageChar: "fa-star",
|
|
42
|
-
fill: "navy",
|
|
43
|
-
imageCharFill: "white"
|
|
44
|
-
}])
|
|
45
|
-
|
|
46
|
-
.vertexColumns(["id", "label", "fachar", "centroid", "ann1", "ann2", "expandedFAChar", "imageUrl"])
|
|
47
|
-
.vertexCentroidColumn("centroid")
|
|
48
|
-
.vertexImageUrlColumn("imageUrl")
|
|
49
|
-
.vertexFACharColumn("fachar")
|
|
50
|
-
.vertexIDColumn("id")
|
|
51
|
-
.vertexLabelColumn("label")
|
|
52
|
-
.vertexAnnotationColumns([
|
|
53
|
-
{ columnID: "ann1", annotationID: "0" } as any,
|
|
54
|
-
{ columnID: "ann2", annotationID: "1" } as any
|
|
55
|
-
])
|
|
56
|
-
.vertexExpansionFACharColumn("expandedFAChar")
|
|
57
|
-
.vertices(g.vertices)
|
|
58
|
-
|
|
59
|
-
.edgeColumns(["source", "target", "label", "weightXXX"])
|
|
60
|
-
// .edgeIDColumn("id")
|
|
61
|
-
.edgeSourceColumn("source")
|
|
62
|
-
.edgeTargetColumn("target")
|
|
63
|
-
.edgeLabelColumn("label")
|
|
64
|
-
// .edgeWeightColumn("weight")
|
|
65
|
-
.edges(g.edges)
|
|
66
|
-
|
|
67
|
-
// Events ---
|
|
68
|
-
.on("vertex_mousein", (vertex, col, sel, anno) => console.info("vertex_mousein", vertex, anno))
|
|
69
|
-
.on("vertex_mouseout", (vertex, col, sel, anno) => console.info("vertex_mouseout", vertex, anno))
|
|
70
|
-
.on("vertex_mouseover", (vertex, col, sel, anno) => console.info("vertex_mouseover", vertex, anno))
|
|
71
|
-
.on("vertex_click", (vertex, col, sel, anno) => console.info("vertex_click", vertex, anno))
|
|
72
|
-
.on("vertex_dblclick", (vertex, col, sel, anno) => console.info("vertex_dblclick", vertex, anno))
|
|
73
|
-
;
|
|
74
|
-
|
|
75
|
-
setTimeout(() => {
|
|
76
|
-
// this.downloadPNG();
|
|
77
|
-
}, 3000);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
1
|
+
import { DataGraph } from "../graph2/dataGraph";
|
|
2
|
+
import { genData2 } from "./data";
|
|
3
|
+
|
|
4
|
+
export class Test2 extends DataGraph {
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
const g = genData2();
|
|
9
|
+
this
|
|
10
|
+
.layout("ForceDirected")
|
|
11
|
+
.forceDirectedRepulsionStrength(-3500)
|
|
12
|
+
.forceDirectedLinkDistance(150)
|
|
13
|
+
.forceDirectedLinkStrength(1.5)
|
|
14
|
+
.forceDirectedPinCentroid(true)
|
|
15
|
+
.hierarchyDigraph(false)
|
|
16
|
+
|
|
17
|
+
.centroidColor("#777777")
|
|
18
|
+
|
|
19
|
+
.selectionGlowColor("#555555")
|
|
20
|
+
.highlightOnMouseOverEdge(true)
|
|
21
|
+
.highlightOnMouseOverVertex(true)
|
|
22
|
+
.showVertexLabels(true)
|
|
23
|
+
|
|
24
|
+
.applyScaleOnLayout(true)
|
|
25
|
+
.zoomToFitLimit(1)
|
|
26
|
+
|
|
27
|
+
.edgeArcDepth(8)
|
|
28
|
+
.edgeStrokeWidth(2)
|
|
29
|
+
.edgeColor("#287EC4")
|
|
30
|
+
|
|
31
|
+
.allowDragging(true)
|
|
32
|
+
|
|
33
|
+
.annotations([{
|
|
34
|
+
id: "0",
|
|
35
|
+
imageChar: "fa-plus",
|
|
36
|
+
fill: "white",
|
|
37
|
+
stroke: "whitesmoke",
|
|
38
|
+
imageCharFill: "red"
|
|
39
|
+
}, {
|
|
40
|
+
id: "1",
|
|
41
|
+
imageChar: "fa-star",
|
|
42
|
+
fill: "navy",
|
|
43
|
+
imageCharFill: "white"
|
|
44
|
+
}])
|
|
45
|
+
|
|
46
|
+
.vertexColumns(["id", "label", "fachar", "centroid", "ann1", "ann2", "expandedFAChar", "imageUrl"])
|
|
47
|
+
.vertexCentroidColumn("centroid")
|
|
48
|
+
.vertexImageUrlColumn("imageUrl")
|
|
49
|
+
.vertexFACharColumn("fachar")
|
|
50
|
+
.vertexIDColumn("id")
|
|
51
|
+
.vertexLabelColumn("label")
|
|
52
|
+
.vertexAnnotationColumns([
|
|
53
|
+
{ columnID: "ann1", annotationID: "0" } as any,
|
|
54
|
+
{ columnID: "ann2", annotationID: "1" } as any
|
|
55
|
+
])
|
|
56
|
+
.vertexExpansionFACharColumn("expandedFAChar")
|
|
57
|
+
.vertices(g.vertices)
|
|
58
|
+
|
|
59
|
+
.edgeColumns(["source", "target", "label", "weightXXX"])
|
|
60
|
+
// .edgeIDColumn("id")
|
|
61
|
+
.edgeSourceColumn("source")
|
|
62
|
+
.edgeTargetColumn("target")
|
|
63
|
+
.edgeLabelColumn("label")
|
|
64
|
+
// .edgeWeightColumn("weight")
|
|
65
|
+
.edges(g.edges)
|
|
66
|
+
|
|
67
|
+
// Events ---
|
|
68
|
+
.on("vertex_mousein", (vertex, col, sel, anno) => console.info("vertex_mousein", vertex, anno))
|
|
69
|
+
.on("vertex_mouseout", (vertex, col, sel, anno) => console.info("vertex_mouseout", vertex, anno))
|
|
70
|
+
.on("vertex_mouseover", (vertex, col, sel, anno) => console.info("vertex_mouseover", vertex, anno))
|
|
71
|
+
.on("vertex_click", (vertex, col, sel, anno) => console.info("vertex_click", vertex, anno))
|
|
72
|
+
.on("vertex_dblclick", (vertex, col, sel, anno) => console.info("vertex_dblclick", vertex, anno))
|
|
73
|
+
;
|
|
74
|
+
|
|
75
|
+
setTimeout(() => {
|
|
76
|
+
// this.downloadPNG();
|
|
77
|
+
}, 3000);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
package/src/__tests__/test3.ts
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { SankeyGraph } from "../graph2/sankeyGraph";
|
|
2
|
-
|
|
3
|
-
export class Test3 extends SankeyGraph {
|
|
4
|
-
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
|
-
this
|
|
8
|
-
.vertexColumns(["category", "id", "label"])
|
|
9
|
-
.vertices([
|
|
10
|
-
[0, 0, "A"],
|
|
11
|
-
[0, 1, "B"],
|
|
12
|
-
[0, 2, "C"],
|
|
13
|
-
[0, 3, "D"],
|
|
14
|
-
[0, 4, "F"],
|
|
15
|
-
[1, 5, "Math"],
|
|
16
|
-
[2, 6, "English"],
|
|
17
|
-
[3, 7, "Geometry"],
|
|
18
|
-
[4, 8, "Science"],
|
|
19
|
-
])
|
|
20
|
-
.edgeColumns(["source", "target", "weight"])
|
|
21
|
-
.edges([
|
|
22
|
-
[0, 5, 48],
|
|
23
|
-
[0, 6, 28],
|
|
24
|
-
[0, 7, 26],
|
|
25
|
-
[0, 8, 38],
|
|
26
|
-
[1, 5, 63],
|
|
27
|
-
[1, 6, 39],
|
|
28
|
-
[1, 7, 36],
|
|
29
|
-
[1, 8, 58],
|
|
30
|
-
[2, 5, 42],
|
|
31
|
-
[2, 6, 36],
|
|
32
|
-
[2, 7, 27],
|
|
33
|
-
[2, 8, 68],
|
|
34
|
-
[3, 5, 90],
|
|
35
|
-
[3, 6, 59],
|
|
36
|
-
[3, 7, 15],
|
|
37
|
-
[3, 8, 35],
|
|
38
|
-
[4, 5, 10],
|
|
39
|
-
[4, 6, 3],
|
|
40
|
-
[4, 7, 6],
|
|
41
|
-
[4, 8, 4],
|
|
42
|
-
])
|
|
43
|
-
;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
1
|
+
import { SankeyGraph } from "../graph2/sankeyGraph";
|
|
2
|
+
|
|
3
|
+
export class Test3 extends SankeyGraph {
|
|
4
|
+
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
this
|
|
8
|
+
.vertexColumns(["category", "id", "label"])
|
|
9
|
+
.vertices([
|
|
10
|
+
[0, 0, "A"],
|
|
11
|
+
[0, 1, "B"],
|
|
12
|
+
[0, 2, "C"],
|
|
13
|
+
[0, 3, "D"],
|
|
14
|
+
[0, 4, "F"],
|
|
15
|
+
[1, 5, "Math"],
|
|
16
|
+
[2, 6, "English"],
|
|
17
|
+
[3, 7, "Geometry"],
|
|
18
|
+
[4, 8, "Science"],
|
|
19
|
+
])
|
|
20
|
+
.edgeColumns(["source", "target", "weight"])
|
|
21
|
+
.edges([
|
|
22
|
+
[0, 5, 48],
|
|
23
|
+
[0, 6, 28],
|
|
24
|
+
[0, 7, 26],
|
|
25
|
+
[0, 8, 38],
|
|
26
|
+
[1, 5, 63],
|
|
27
|
+
[1, 6, 39],
|
|
28
|
+
[1, 7, 36],
|
|
29
|
+
[1, 8, 58],
|
|
30
|
+
[2, 5, 42],
|
|
31
|
+
[2, 6, 36],
|
|
32
|
+
[2, 7, 27],
|
|
33
|
+
[2, 8, 68],
|
|
34
|
+
[3, 5, 90],
|
|
35
|
+
[3, 6, 59],
|
|
36
|
+
[3, 7, 15],
|
|
37
|
+
[3, 8, 35],
|
|
38
|
+
[4, 5, 10],
|
|
39
|
+
[4, 6, 3],
|
|
40
|
+
[4, 7, 6],
|
|
41
|
+
[4, 8, 4],
|
|
42
|
+
])
|
|
43
|
+
;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
package/src/__tests__/test4.ts
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import { Vertex4, CentroidVertex4 } from "@hpcc-js/react";
|
|
2
|
-
import { Test2 } from "./test2";
|
|
3
|
-
|
|
4
|
-
export class Test4 extends Test2 {
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
|
-
this
|
|
8
|
-
.vertexRenderer(Vertex4)
|
|
9
|
-
.centroidRenderer(CentroidVertex4)
|
|
10
|
-
;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// 8
|
|
15
|
-
let seed = 8;
|
|
16
|
-
function random() {
|
|
17
|
-
const x = Math.sin(seed++) * 10000;
|
|
18
|
-
return x - Math.floor(x);
|
|
19
|
-
}
|
|
20
|
-
function rand() {
|
|
21
|
-
return Math.round(random() * 32767);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function make_pair<T>(a: T, b: T): [T, T] {
|
|
25
|
-
return [a, b];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
function genData(MAX_VERTICES = 200, MAX_EDGES = 200) {
|
|
30
|
-
const edges: [number, number][] = [];
|
|
31
|
-
function edges_has(p: [number, number]): boolean {
|
|
32
|
-
return edges.some(row => row[0] === p[0] && row[1] === p[1]);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const NUM = 1 + rand() % MAX_VERTICES;
|
|
36
|
-
let NUMEDGE = 1 + rand() % MAX_EDGES;
|
|
37
|
-
|
|
38
|
-
while (NUMEDGE > NUM * (NUM - 1) / 2) {
|
|
39
|
-
NUMEDGE = 1 + rand() % MAX_EDGES;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
for (let j = 1; j <= NUMEDGE; j++) {
|
|
43
|
-
let a = 1 + rand() % NUM;
|
|
44
|
-
let b = 1 + rand() % NUM;
|
|
45
|
-
let p = make_pair(a, b);
|
|
46
|
-
|
|
47
|
-
while (edges_has(p) || a == b) {
|
|
48
|
-
a = 1 + rand() % NUM;
|
|
49
|
-
b = 1 + rand() % NUM;
|
|
50
|
-
p = make_pair(a, b);
|
|
51
|
-
}
|
|
52
|
-
edges.push(p);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const vertices: { [id: number]: boolean } = {};
|
|
56
|
-
for (const it of edges) {
|
|
57
|
-
vertices[it[0]] = true;
|
|
58
|
-
vertices[it[1]] = true;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const icons = ["fa-at", "fa-user-o", "fa-address-card-o", "fa-globe", "fa-phone"];
|
|
62
|
-
return {
|
|
63
|
-
vertices: Object.keys(vertices).map(v => [v, `Node-${v}`, icons[Math.floor(Math.random() * icons.length)]]),
|
|
64
|
-
edges: edges.map(e => [e[0], e[1], "", 1])
|
|
65
|
-
};
|
|
66
|
-
}
|
|
1
|
+
import { Vertex4, CentroidVertex4 } from "@hpcc-js/react";
|
|
2
|
+
import { Test2 } from "./test2";
|
|
3
|
+
|
|
4
|
+
export class Test4 extends Test2 {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
this
|
|
8
|
+
.vertexRenderer(Vertex4)
|
|
9
|
+
.centroidRenderer(CentroidVertex4)
|
|
10
|
+
;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// 8
|
|
15
|
+
let seed = 8;
|
|
16
|
+
function random() {
|
|
17
|
+
const x = Math.sin(seed++) * 10000;
|
|
18
|
+
return x - Math.floor(x);
|
|
19
|
+
}
|
|
20
|
+
function rand() {
|
|
21
|
+
return Math.round(random() * 32767);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function make_pair<T>(a: T, b: T): [T, T] {
|
|
25
|
+
return [a, b];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
function genData(MAX_VERTICES = 200, MAX_EDGES = 200) {
|
|
30
|
+
const edges: [number, number][] = [];
|
|
31
|
+
function edges_has(p: [number, number]): boolean {
|
|
32
|
+
return edges.some(row => row[0] === p[0] && row[1] === p[1]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const NUM = 1 + rand() % MAX_VERTICES;
|
|
36
|
+
let NUMEDGE = 1 + rand() % MAX_EDGES;
|
|
37
|
+
|
|
38
|
+
while (NUMEDGE > NUM * (NUM - 1) / 2) {
|
|
39
|
+
NUMEDGE = 1 + rand() % MAX_EDGES;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
for (let j = 1; j <= NUMEDGE; j++) {
|
|
43
|
+
let a = 1 + rand() % NUM;
|
|
44
|
+
let b = 1 + rand() % NUM;
|
|
45
|
+
let p = make_pair(a, b);
|
|
46
|
+
|
|
47
|
+
while (edges_has(p) || a == b) {
|
|
48
|
+
a = 1 + rand() % NUM;
|
|
49
|
+
b = 1 + rand() % NUM;
|
|
50
|
+
p = make_pair(a, b);
|
|
51
|
+
}
|
|
52
|
+
edges.push(p);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const vertices: { [id: number]: boolean } = {};
|
|
56
|
+
for (const it of edges) {
|
|
57
|
+
vertices[it[0]] = true;
|
|
58
|
+
vertices[it[1]] = true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const icons = ["fa-at", "fa-user-o", "fa-address-card-o", "fa-globe", "fa-phone"];
|
|
62
|
+
return {
|
|
63
|
+
vertices: Object.keys(vertices).map(v => [v, `Node-${v}`, icons[Math.floor(Math.random() * icons.length)]]),
|
|
64
|
+
edges: edges.map(e => [e[0], e[1], "", 1])
|
|
65
|
+
};
|
|
66
|
+
}
|
package/src/__tests__/test5.ts
CHANGED
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
import { Vertex4, CentroidVertex4 } from "@hpcc-js/react";
|
|
2
|
-
import { GraphReact } from "../react/graphReact.ts";
|
|
3
|
-
|
|
4
|
-
const VERTEX_ARR = [{
|
|
5
|
-
id: 0,
|
|
6
|
-
centroid: true,
|
|
7
|
-
text: "Vertex One",
|
|
8
|
-
iconFontFamily: "'Font Awesome 5 Free'",
|
|
9
|
-
}, {
|
|
10
|
-
id: 1,
|
|
11
|
-
centroid: false,
|
|
12
|
-
text: "Vertex Two",
|
|
13
|
-
|
|
14
|
-
}, {
|
|
15
|
-
id: 2,
|
|
16
|
-
centroid: false,
|
|
17
|
-
text: "Vertex Three",
|
|
18
|
-
}];
|
|
19
|
-
|
|
20
|
-
const EDGE_ARR = [{
|
|
21
|
-
id: 0,
|
|
22
|
-
source: VERTEX_ARR[0],
|
|
23
|
-
target: VERTEX_ARR[1]
|
|
24
|
-
}, {
|
|
25
|
-
id: 1,
|
|
26
|
-
source: VERTEX_ARR[0],
|
|
27
|
-
target: VERTEX_ARR[2]
|
|
28
|
-
}];
|
|
29
|
-
|
|
30
|
-
const VERTEX_ARR_UPDATED = [{
|
|
31
|
-
id: 0,
|
|
32
|
-
text: "Vertex One",
|
|
33
|
-
iconFontFamily: "'Font Awesome 5 Free'",
|
|
34
|
-
}, {
|
|
35
|
-
centroid: true,
|
|
36
|
-
id: 1,
|
|
37
|
-
text: "Vertex Two",
|
|
38
|
-
|
|
39
|
-
}, {
|
|
40
|
-
id: 2,
|
|
41
|
-
centroid: false,
|
|
42
|
-
text: "Vertex Three",
|
|
43
|
-
}];
|
|
44
|
-
|
|
45
|
-
export const EDGE_ARR_UPDATE = [{
|
|
46
|
-
id: 0,
|
|
47
|
-
source: VERTEX_ARR_UPDATED[1],
|
|
48
|
-
target: VERTEX_ARR_UPDATED[2]
|
|
49
|
-
}];
|
|
50
|
-
|
|
51
|
-
export class Test5 extends Graph2 {
|
|
52
|
-
|
|
53
|
-
constructor() {
|
|
54
|
-
super();
|
|
55
|
-
this
|
|
56
|
-
.minScale(0.1)
|
|
57
|
-
.layout("ForceDirected")
|
|
58
|
-
.centroidRenderer(CentroidVertex4)
|
|
59
|
-
.vertexRenderer(Vertex4)
|
|
60
|
-
.data({
|
|
61
|
-
vertices: VERTEX_ARR,
|
|
62
|
-
edges: EDGE_ARR
|
|
63
|
-
})
|
|
64
|
-
.transitionDuration(200)
|
|
65
|
-
.forceDirectedIterations(800)
|
|
66
|
-
.forceDirectedLinkDistance(100)
|
|
67
|
-
.forceDirectedAlphaDecay(0.014)
|
|
68
|
-
.applyScaleOnLayout(true)
|
|
69
|
-
.centroidColor("#ffffff")
|
|
70
|
-
.edgeStrokeWidth(2)
|
|
71
|
-
.edgeColor("#227AC2")
|
|
72
|
-
.minScale(0.1)
|
|
73
|
-
.edgeArcDepth(0)
|
|
74
|
-
.layout("ForceDirected")
|
|
75
|
-
.on("vertex_click", (vertex, col, sel, anno) => {
|
|
76
|
-
console.info("vertex_click", vertex);
|
|
77
|
-
})
|
|
78
|
-
.on("vertex_dblclick", (vertex, col, sel, anno) => {
|
|
79
|
-
console.info("vertex_dblclick", vertex);
|
|
80
|
-
})
|
|
81
|
-
.on("vertex_contextmenu", (vertex, col, sel, anno) => {
|
|
82
|
-
console.info("vertex_contextmenu", vertex);
|
|
83
|
-
})
|
|
84
|
-
;
|
|
85
|
-
}
|
|
1
|
+
import { Vertex4, CentroidVertex4 } from "@hpcc-js/react";
|
|
2
|
+
import { GraphReact } from "../react/graphReact.ts";
|
|
3
|
+
|
|
4
|
+
const VERTEX_ARR = [{
|
|
5
|
+
id: 0,
|
|
6
|
+
centroid: true,
|
|
7
|
+
text: "Vertex One",
|
|
8
|
+
iconFontFamily: "'Font Awesome 5 Free'",
|
|
9
|
+
}, {
|
|
10
|
+
id: 1,
|
|
11
|
+
centroid: false,
|
|
12
|
+
text: "Vertex Two",
|
|
13
|
+
|
|
14
|
+
}, {
|
|
15
|
+
id: 2,
|
|
16
|
+
centroid: false,
|
|
17
|
+
text: "Vertex Three",
|
|
18
|
+
}];
|
|
19
|
+
|
|
20
|
+
const EDGE_ARR = [{
|
|
21
|
+
id: 0,
|
|
22
|
+
source: VERTEX_ARR[0],
|
|
23
|
+
target: VERTEX_ARR[1]
|
|
24
|
+
}, {
|
|
25
|
+
id: 1,
|
|
26
|
+
source: VERTEX_ARR[0],
|
|
27
|
+
target: VERTEX_ARR[2]
|
|
28
|
+
}];
|
|
29
|
+
|
|
30
|
+
const VERTEX_ARR_UPDATED = [{
|
|
31
|
+
id: 0,
|
|
32
|
+
text: "Vertex One",
|
|
33
|
+
iconFontFamily: "'Font Awesome 5 Free'",
|
|
34
|
+
}, {
|
|
35
|
+
centroid: true,
|
|
36
|
+
id: 1,
|
|
37
|
+
text: "Vertex Two",
|
|
38
|
+
|
|
39
|
+
}, {
|
|
40
|
+
id: 2,
|
|
41
|
+
centroid: false,
|
|
42
|
+
text: "Vertex Three",
|
|
43
|
+
}];
|
|
44
|
+
|
|
45
|
+
export const EDGE_ARR_UPDATE = [{
|
|
46
|
+
id: 0,
|
|
47
|
+
source: VERTEX_ARR_UPDATED[1],
|
|
48
|
+
target: VERTEX_ARR_UPDATED[2]
|
|
49
|
+
}];
|
|
50
|
+
|
|
51
|
+
export class Test5 extends Graph2 {
|
|
52
|
+
|
|
53
|
+
constructor() {
|
|
54
|
+
super();
|
|
55
|
+
this
|
|
56
|
+
.minScale(0.1)
|
|
57
|
+
.layout("ForceDirected")
|
|
58
|
+
.centroidRenderer(CentroidVertex4)
|
|
59
|
+
.vertexRenderer(Vertex4)
|
|
60
|
+
.data({
|
|
61
|
+
vertices: VERTEX_ARR,
|
|
62
|
+
edges: EDGE_ARR
|
|
63
|
+
})
|
|
64
|
+
.transitionDuration(200)
|
|
65
|
+
.forceDirectedIterations(800)
|
|
66
|
+
.forceDirectedLinkDistance(100)
|
|
67
|
+
.forceDirectedAlphaDecay(0.014)
|
|
68
|
+
.applyScaleOnLayout(true)
|
|
69
|
+
.centroidColor("#ffffff")
|
|
70
|
+
.edgeStrokeWidth(2)
|
|
71
|
+
.edgeColor("#227AC2")
|
|
72
|
+
.minScale(0.1)
|
|
73
|
+
.edgeArcDepth(0)
|
|
74
|
+
.layout("ForceDirected")
|
|
75
|
+
.on("vertex_click", (vertex, col, sel, anno) => {
|
|
76
|
+
console.info("vertex_click", vertex);
|
|
77
|
+
})
|
|
78
|
+
.on("vertex_dblclick", (vertex, col, sel, anno) => {
|
|
79
|
+
console.info("vertex_dblclick", vertex);
|
|
80
|
+
})
|
|
81
|
+
.on("vertex_contextmenu", (vertex, col, sel, anno) => {
|
|
82
|
+
console.info("vertex_contextmenu", vertex);
|
|
83
|
+
})
|
|
84
|
+
;
|
|
85
|
+
}
|
|
86
86
|
}
|
package/src/common/graphT.css
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
.graph_GraphT .graphVertex {
|
|
2
|
-
cursor: pointer;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.graph_GraphT .allowDragging .graphVertex {
|
|
6
|
-
cursor: pointer;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.graph_GraphT .allowDragging .graphVertex.grabbed {
|
|
10
|
-
cursor: grabbing;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.graph_GraphT .graphEdge {
|
|
14
|
-
stroke: darkgray;
|
|
15
|
-
fill: none;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.graph_GraphT .graphEdge>text {
|
|
19
|
-
stroke: none;
|
|
20
|
-
fill: black;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.graph_GraphT .graphEdge.hide-text>text {
|
|
24
|
-
display: none;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.graph_GraphT g.selected rect {
|
|
28
|
-
stroke: navy !important;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.graph_GraphT g.selected circle {
|
|
32
|
-
stroke: navy !important;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.graph_GraphT .graphVertex:focus,
|
|
36
|
-
.graph_GraphT .graphVertex:focus-visible {
|
|
37
|
-
outline: 2px solid #0078d4;
|
|
38
|
-
outline-offset: 2px;
|
|
1
|
+
.graph_GraphT .graphVertex {
|
|
2
|
+
cursor: pointer;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.graph_GraphT .allowDragging .graphVertex {
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.graph_GraphT .allowDragging .graphVertex.grabbed {
|
|
10
|
+
cursor: grabbing;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.graph_GraphT .graphEdge {
|
|
14
|
+
stroke: darkgray;
|
|
15
|
+
fill: none;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.graph_GraphT .graphEdge>text {
|
|
19
|
+
stroke: none;
|
|
20
|
+
fill: black;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.graph_GraphT .graphEdge.hide-text>text {
|
|
24
|
+
display: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.graph_GraphT g.selected rect {
|
|
28
|
+
stroke: navy !important;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.graph_GraphT g.selected circle {
|
|
32
|
+
stroke: navy !important;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.graph_GraphT .graphVertex:focus,
|
|
36
|
+
.graph_GraphT .graphVertex:focus-visible {
|
|
37
|
+
outline: 2px solid #0078d4;
|
|
38
|
+
outline-offset: 2px;
|
|
39
39
|
}
|