@hpcc-js/graph 2.84.2 → 2.84.4
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.es6.js +24 -24
- package/dist/index.es6.js.map +1 -1
- package/dist/index.js +22 -23
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +10 -11
- package/src/__package__.ts +2 -2
- package/src/__tests__/index.ts +1 -1
- package/src/__tests__/test5.ts +8 -4
- package/src/graph2/dataGraph.ts +9 -7
- package/src/graph2/graph.ts +12 -4
- package/src/graph2/graphReactT.ts +3 -3
- package/src/graph2/graphT.ts +37 -27
- package/src/graph2/index.ts +0 -1
- package/src/graph2/layouts/graphviz.ts +1 -2
- package/src/graph2/layouts/graphvizWorker.ts +1 -9
- package/src/graph2/layouts/placeholders.ts +15 -15
- package/src/graph2/sankeyGraph.ts +8 -8
- package/src/graph2/subgraph.tsx +2 -2
- package/src/graph2/vertex.tsx +2 -2
- package/types/__package__.d.ts +2 -2
- package/types/__tests__/index.d.ts +1 -1
- package/types/__tests__/test5.d.ts +25 -0
- package/types/__tests__/test5.d.ts.map +1 -1
- package/types/graph2/dataGraph.d.ts +4 -3
- package/types/graph2/dataGraph.d.ts.map +1 -1
- package/types/graph2/graph.d.ts +8 -3
- package/types/graph2/graph.d.ts.map +1 -1
- package/types/graph2/graphReactT.d.ts +3 -3
- package/types/graph2/graphReactT.d.ts.map +1 -1
- package/types/graph2/graphT.d.ts +11 -10
- package/types/graph2/graphT.d.ts.map +1 -1
- package/types/graph2/index.d.ts +0 -1
- package/types/graph2/index.d.ts.map +1 -1
- package/types/graph2/layouts/graphviz.d.ts.map +1 -1
- package/types/graph2/layouts/graphvizWorker.d.ts +0 -1
- package/types/graph2/layouts/graphvizWorker.d.ts.map +1 -1
- package/types/graph2/layouts/placeholders.d.ts +15 -15
- package/types/graph2/layouts/placeholders.d.ts.map +1 -1
- package/types/graph2/sankeyGraph.d.ts +5 -5
- package/types/graph2/sankeyGraph.d.ts.map +1 -1
- package/types/graph2/subgraph.d.ts +2 -2
- package/types/graph2/subgraph.d.ts.map +1 -1
- package/types/graph2/vertex.d.ts +2 -2
- package/types/graph2/vertex.d.ts.map +1 -1
- package/types-3.4/__package__.d.ts +2 -2
- package/types-3.4/__tests__/index.d.ts +1 -1
- package/types-3.4/__tests__/test5.d.ts +25 -0
- package/types-3.4/graph2/dataGraph.d.ts +4 -3
- package/types-3.4/graph2/graph.d.ts +8 -3
- package/types-3.4/graph2/graphReactT.d.ts +3 -3
- package/types-3.4/graph2/graphT.d.ts +11 -10
- package/types-3.4/graph2/index.d.ts +0 -1
- package/types-3.4/graph2/layouts/graphvizWorker.d.ts +0 -1
- package/types-3.4/graph2/layouts/placeholders.d.ts +15 -15
- package/types-3.4/graph2/sankeyGraph.d.ts +5 -5
- package/types-3.4/graph2/subgraph.d.ts +2 -2
- package/types-3.4/graph2/vertex.d.ts +2 -2
- package/dist/graphvizlib.wasm +0 -0
- package/src/graph2/edge.tsx +0 -30
- package/types/graph2/edge.d.ts +0 -9
- package/types/graph2/edge.d.ts.map +0 -1
- package/types-3.4/graph2/edge.d.ts +0 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hpcc-js/graph",
|
|
3
|
-
"version": "2.84.
|
|
3
|
+
"version": "2.84.4",
|
|
4
4
|
"description": "hpcc-js - Viz Graph",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.es6",
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
24
|
"clean": "rimraf lib* types dist *.tsbuildinfo workers/lib-* workers/dist workers/types workers/*.tsbuildinfo",
|
|
25
|
-
"copy-resources": "cpx \"../../node_modules/@hpcc-js/wasm/dist/graphvizlib.wasm\" \"./dist\"",
|
|
26
25
|
"compile-es6": "tsc --module es6 --outDir ./lib-es6",
|
|
27
26
|
"compile-es6-watch": "npm run compile-es6 -- -w",
|
|
28
27
|
"compile-umd": "tsc --module umd --outDir ./lib-umd",
|
|
@@ -43,7 +42,7 @@
|
|
|
43
42
|
"build-workers": "run-s compile-workers bundle-workers minimize-workers wrap-workers",
|
|
44
43
|
"build-package": "npm run compile-es6 && npm run bundle",
|
|
45
44
|
"gen-legacy-types": "downlevel-dts ./types ./types-3.4",
|
|
46
|
-
"build": "run-s build-workers
|
|
45
|
+
"build": "run-s build-workers build-package",
|
|
47
46
|
"watch": "npm-run-all compile-es6 -p compile-es6-watch bundle-watch",
|
|
48
47
|
"stamp": "node ../../node_modules/@hpcc-js/bundle/src/stamp.js",
|
|
49
48
|
"lint": "eslint ./src",
|
|
@@ -52,15 +51,15 @@
|
|
|
52
51
|
"update": "npx --yes npm-check-updates -u -t minor"
|
|
53
52
|
},
|
|
54
53
|
"dependencies": {
|
|
55
|
-
"@hpcc-js/api": "^2.12.
|
|
56
|
-
"@hpcc-js/common": "^2.71.
|
|
57
|
-
"@hpcc-js/html": "^2.42.
|
|
58
|
-
"@hpcc-js/react": "^2.53.
|
|
59
|
-
"@hpcc-js/util": "^2.50.
|
|
54
|
+
"@hpcc-js/api": "^2.12.7",
|
|
55
|
+
"@hpcc-js/common": "^2.71.7",
|
|
56
|
+
"@hpcc-js/html": "^2.42.8",
|
|
57
|
+
"@hpcc-js/react": "^2.53.3",
|
|
58
|
+
"@hpcc-js/util": "^2.50.2"
|
|
60
59
|
},
|
|
61
60
|
"devDependencies": {
|
|
62
61
|
"@hpcc-js/bundle": "^2.11.3",
|
|
63
|
-
"@hpcc-js/wasm": "1.
|
|
62
|
+
"@hpcc-js/wasm": "2.1.0",
|
|
64
63
|
"@types/d3-transition": "1.3.2",
|
|
65
64
|
"@types/dagre": "0.7.48",
|
|
66
65
|
"d3-array": "^1",
|
|
@@ -76,7 +75,7 @@
|
|
|
76
75
|
"d3-transition": "^1",
|
|
77
76
|
"dagre": "0.8.5",
|
|
78
77
|
"es6-promise": "4.2.8",
|
|
79
|
-
"tslib": "2.4.
|
|
78
|
+
"tslib": "2.4.1"
|
|
80
79
|
},
|
|
81
80
|
"repository": {
|
|
82
81
|
"type": "git",
|
|
@@ -89,5 +88,5 @@
|
|
|
89
88
|
"url": "https://github.com/hpcc-systems/Visualization/issues"
|
|
90
89
|
},
|
|
91
90
|
"homepage": "https://github.com/hpcc-systems/Visualization",
|
|
92
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "cec45fe4a28dff27d43cf0bb9238d751534c8e88"
|
|
93
92
|
}
|
package/src/__package__.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export const PKG_NAME = "@hpcc-js/graph";
|
|
2
|
-
export const PKG_VERSION = "2.84.
|
|
3
|
-
export const BUILD_VERSION = "2.104.
|
|
2
|
+
export const PKG_VERSION = "2.84.4";
|
|
3
|
+
export const BUILD_VERSION = "2.104.14";
|
package/src/__tests__/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Test4 as Test } from "./test4";
|
package/src/__tests__/test5.ts
CHANGED
|
@@ -42,7 +42,7 @@ const VERTEX_ARR_UPDATED = [{
|
|
|
42
42
|
text: "Vertex Three",
|
|
43
43
|
}];
|
|
44
44
|
|
|
45
|
-
const EDGE_ARR_UPDATE = [{
|
|
45
|
+
export const EDGE_ARR_UPDATE = [{
|
|
46
46
|
id: 0,
|
|
47
47
|
source: VERTEX_ARR_UPDATED[1],
|
|
48
48
|
target: VERTEX_ARR_UPDATED[2]
|
|
@@ -73,9 +73,13 @@ export class Test5 extends Graph2 {
|
|
|
73
73
|
.edgeArcDepth(0)
|
|
74
74
|
.layout("ForceDirected")
|
|
75
75
|
.on("vertex_click", (vertex, col, sel, anno) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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);
|
|
79
83
|
})
|
|
80
84
|
;
|
|
81
85
|
}
|
package/src/graph2/dataGraph.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { PropertyExt, publish, Widget } from "@hpcc-js/common";
|
|
2
|
-
import { CentroidVertex3,
|
|
2
|
+
import { Vertex3, CentroidVertex3, Vertex3Props, EdgeProps, SubgraphProps } from "@hpcc-js/react";
|
|
3
3
|
import { compare2 } from "@hpcc-js/util";
|
|
4
4
|
import { Graph2 } from "./graph";
|
|
5
5
|
import { HierarchyBase } from "./layouts/placeholders";
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
// Backward compatibility layer ---
|
|
8
|
+
export type IVertex3 = Vertex3Props;
|
|
7
9
|
|
|
8
10
|
export function toJsonObj<T>(row, columns): T {
|
|
9
11
|
const retVal: T = {} as T;
|
|
@@ -206,9 +208,9 @@ export class DataGraph extends Graph2 {
|
|
|
206
208
|
this._prevVertices = vertices;
|
|
207
209
|
}
|
|
208
210
|
|
|
209
|
-
protected _prevEdges: readonly
|
|
210
|
-
protected _masterEdges:
|
|
211
|
-
private _masterEdgesMap: { [key: string]:
|
|
211
|
+
protected _prevEdges: readonly EdgeProps<IVertex3>[] = [];
|
|
212
|
+
protected _masterEdges: EdgeProps<IVertex3>[] = [];
|
|
213
|
+
private _masterEdgesMap: { [key: string]: EdgeProps<IVertex3> } = {};
|
|
212
214
|
mergeEdges() {
|
|
213
215
|
const columns = this.edgeColumns();
|
|
214
216
|
const idIdx = this.indexOf(columns, this.edgeIDColumn(), "id");
|
|
@@ -217,7 +219,7 @@ export class DataGraph extends Graph2 {
|
|
|
217
219
|
const labelIdx = this.indexOf(columns, this.edgeLabelColumn(), "label");
|
|
218
220
|
const weightIdx = this.indexOf(columns, this.edgeWeightColumn(), "weight");
|
|
219
221
|
const colorIdx = this.indexOf(columns, this.edgeColorColumn(), "color");
|
|
220
|
-
const edges:
|
|
222
|
+
const edges: EdgeProps<IVertex3>[] = this.edges().map((e): EdgeProps<IVertex3> => {
|
|
221
223
|
const source = this._masterVerticesMap["" + e[sourceIdx]];
|
|
222
224
|
if (!source) console.error(`Invalid edge source entity "${e[sourceIdx]}" does not exist.`);
|
|
223
225
|
const target = this._masterVerticesMap["" + e[targetIdx]];
|
|
@@ -227,7 +229,7 @@ export class DataGraph extends Graph2 {
|
|
|
227
229
|
source,
|
|
228
230
|
target,
|
|
229
231
|
weight: +e[weightIdx] || 1,
|
|
230
|
-
|
|
232
|
+
stroke: e[colorIdx] as string,
|
|
231
233
|
label: labelIdx >= 0 ? ("" + e[labelIdx]) : "",
|
|
232
234
|
origData: toJsonObj(e, columns),
|
|
233
235
|
labelPos: [0, 0],
|
package/src/graph2/graph.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import { React, Subgraph, SubgraphProps, Vertex, VertexProps } from "@hpcc-js/react";
|
|
2
|
-
import {
|
|
1
|
+
import { React, Subgraph, SubgraphProps, Vertex, VertexProps, Edge, EdgeProps } from "@hpcc-js/react";
|
|
2
|
+
// import { IVertexEdgeProps, VertexEdge } from "./edge";
|
|
3
3
|
import { GraphReactT } from "./graphReactT";
|
|
4
|
+
import { GraphDataProps, HierarchyBase } from "./graphT";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
// Backward compatibility layer ---
|
|
7
|
+
export type ISubgraph = SubgraphProps;
|
|
8
|
+
export type IVertex = VertexProps;
|
|
9
|
+
export type IEdge = EdgeProps;
|
|
10
|
+
export type IHierarchy = HierarchyBase<ISubgraph, IVertex>;
|
|
11
|
+
export type IGraphData2 = GraphDataProps<ISubgraph, IVertex, IEdge>;
|
|
12
|
+
|
|
13
|
+
export class Graph2 extends GraphReactT<ISubgraph, IVertex, IEdge> {
|
|
6
14
|
|
|
7
15
|
constructor() {
|
|
8
|
-
super(Subgraph, Vertex,
|
|
16
|
+
super(Subgraph, Vertex, Edge);
|
|
9
17
|
this._reactCentroidRenderer = Vertex;
|
|
10
18
|
this._reactVertexRenderer2 = Vertex;
|
|
11
19
|
super.vertexRenderer((props) => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { render, React, SubgraphProps, VertexProps } from "@hpcc-js/react";
|
|
2
|
-
import {
|
|
1
|
+
import { render, React, SubgraphProps, VertexProps, EdgeProps } from "@hpcc-js/react";
|
|
2
|
+
import { GraphT, RendererT } from "./graphT";
|
|
3
3
|
|
|
4
4
|
function adapter<T>(reactRenderer: React.FunctionComponent<T>): RendererT<T> {
|
|
5
5
|
return (props: T, element: SVGGElement) => render(reactRenderer, props, element);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export class GraphReactT<SG extends SubgraphProps, V extends VertexProps, E extends EdgeProps
|
|
8
|
+
export class GraphReactT<SG extends SubgraphProps, V extends VertexProps, E extends EdgeProps<V>> extends GraphT<SG, V, E> {
|
|
9
9
|
|
|
10
10
|
constructor(subgraphRenderer: React.FunctionComponent<SG>, vertexRenderer: React.FunctionComponent<V>, edgeRenderer: React.FunctionComponent<E>) {
|
|
11
11
|
super(adapter(subgraphRenderer), adapter(vertexRenderer), adapter(edgeRenderer));
|
package/src/graph2/graphT.ts
CHANGED
|
@@ -7,7 +7,7 @@ import "d3-transition";
|
|
|
7
7
|
import { interpolatePath as d3InterpolatePath } from "d3-interpolate-path";
|
|
8
8
|
import { Circle, Dagre, ForceDirected, ForceDirectedAnimated, Graphviz, ILayout, Null } from "./layouts/index";
|
|
9
9
|
import { Options as FDOptions } from "./layouts/forceDirectedWorker";
|
|
10
|
-
import type {
|
|
10
|
+
import type { VertexBaseProps, EdgeBaseProps, GraphDataProps, HierarchyBase, SubgraphBaseProps } from "./layouts/placeholders";
|
|
11
11
|
import { EdgePlaceholder, SubgraphPlaceholder, VertexPlaceholder, isEdgePlaceholder } from "./layouts/placeholders";
|
|
12
12
|
import { Engine, graphviz as gvWorker } from "./layouts/graphvizWorker";
|
|
13
13
|
import { Tree, RadialTree, Dendrogram, RadialDendrogram } from "./layouts/tree";
|
|
@@ -18,25 +18,25 @@ let scriptDir = (globalThis?.document?.currentScript as HTMLScriptElement)?.src
|
|
|
18
18
|
scriptDir = scriptDir.substring(0, scriptDir.replace(/[?#].*/, "").lastIndexOf("/") + 1);
|
|
19
19
|
|
|
20
20
|
export {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
GraphDataProps,
|
|
22
|
+
SubgraphBaseProps,
|
|
23
|
+
VertexBaseProps,
|
|
24
|
+
EdgeBaseProps,
|
|
25
25
|
HierarchyBase
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
type GraphLayoutType = "Hierarchy" | "DOT" | "Tree" | "Dendrogram" | "RadialTree" | "RadialDendrogram" | "ForceDirected" | "ForceDirected2" | "ForceDirectedHybrid" | "Neato" | "FDP" | "Circle" | "TwoPI" | "Circo" | "None";
|
|
29
29
|
const GraphLayoutTypeSet = ["Hierarchy", "DOT", "Tree", "Dendrogram", "RadialTree", "RadialDendrogram", "ForceDirected", "ForceDirected2", "ForceDirectedHybrid", "Neato", "FDP", "Circle", "TwoPI", "Circo", "None"];
|
|
30
30
|
|
|
31
|
-
function dragStart<V extends
|
|
31
|
+
function dragStart<V extends VertexBaseProps>(n: VertexPlaceholder<V>) {
|
|
32
32
|
n.fx = n.sx = n.x;
|
|
33
33
|
n.fy = n.sy = n.y;
|
|
34
34
|
}
|
|
35
|
-
function dragTick(n: VertexPlaceholder<
|
|
35
|
+
function dragTick(n: VertexPlaceholder<VertexBaseProps>, d: VertexPlaceholder<VertexBaseProps>) {
|
|
36
36
|
n.fx = n.sx + d.fx - d.sx;
|
|
37
37
|
n.fy = n.sy + d.fy - d.sy;
|
|
38
38
|
}
|
|
39
|
-
function dragEnd<V extends
|
|
39
|
+
function dragEnd<V extends VertexBaseProps>(n: VertexPlaceholder<V>) {
|
|
40
40
|
n.x = n.fx;
|
|
41
41
|
n.y = n.fy;
|
|
42
42
|
n.fx = n.sx = undefined;
|
|
@@ -45,7 +45,7 @@ function dragEnd<V extends VertexProps>(n: VertexPlaceholder<V>) {
|
|
|
45
45
|
|
|
46
46
|
export type RendererT<T> = (props: T, element: SVGGElement) => void;
|
|
47
47
|
|
|
48
|
-
export class GraphT<SG extends
|
|
48
|
+
export class GraphT<SG extends SubgraphBaseProps, V extends VertexBaseProps, E extends EdgeBaseProps<V>> extends SVGZoomWidget {
|
|
49
49
|
|
|
50
50
|
protected _centroidFilter: SVGGlowFilter;
|
|
51
51
|
|
|
@@ -63,11 +63,11 @@ export class GraphT<SG extends SubgraphProps, V extends VertexProps, E extends E
|
|
|
63
63
|
private _toggleD = new ToggleButton().faChar("fa-sitemap fa-rotate-270").tooltip("Dendrogram").on("click", () => this.layoutClick("Dendrogram"));
|
|
64
64
|
private _toggleRD = new ToggleButton().faChar("fa-asterisk").tooltip("Radial Dendrogram").on("click", () => this.layoutClick("RadialDendrogram"));
|
|
65
65
|
|
|
66
|
-
protected _graphData = new GraphCollection<VertexPlaceholder<V>, EdgePlaceholder<
|
|
66
|
+
protected _graphData = new GraphCollection<VertexPlaceholder<V>, EdgePlaceholder<V, E>, SubgraphPlaceholder<SG>>()
|
|
67
67
|
.idFunc(d => d.id)
|
|
68
68
|
.sourceFunc(e => e.source.id)
|
|
69
69
|
.targetFunc(e => e.target.id)
|
|
70
|
-
.updateFunc((b: VertexPlaceholder<V> | EdgePlaceholder<
|
|
70
|
+
.updateFunc((b: VertexPlaceholder<V> | EdgePlaceholder<V, E> | SubgraphPlaceholder<SG>, a: VertexPlaceholder<V> | EdgePlaceholder<V, E> | SubgraphPlaceholder<SG>) => {
|
|
71
71
|
b.props = a.props;
|
|
72
72
|
if (isEdgePlaceholder(a) && isEdgePlaceholder(b)) {
|
|
73
73
|
b.source = a.source;
|
|
@@ -192,14 +192,19 @@ export class GraphT<SG extends SubgraphProps, V extends VertexProps, E extends E
|
|
|
192
192
|
d3Select(this).classed("grabbed", false);
|
|
193
193
|
}
|
|
194
194
|
if (doClick) {
|
|
195
|
+
const event = d3Event();
|
|
195
196
|
context._selection.click({
|
|
196
197
|
_id: String(d.id),
|
|
197
198
|
element: () => d.element
|
|
198
|
-
},
|
|
199
|
+
}, event.sourceEvent);
|
|
199
200
|
context.selectionChanged();
|
|
200
201
|
const selected = d.element.classed("selected");
|
|
201
202
|
const eventOrigin = context.resolveEventOrigin();
|
|
202
|
-
|
|
203
|
+
if (event?.sourceEvent?.button === 2) {
|
|
204
|
+
context.vertex_contextmenu(d.props.origData || d.props, "", selected, eventOrigin);
|
|
205
|
+
} else {
|
|
206
|
+
context.vertex_click(d.props.origData || d.props, "", selected, eventOrigin);
|
|
207
|
+
}
|
|
203
208
|
const doClickTime = Date.now();
|
|
204
209
|
if (doClickTime - context._prevDoClickTime < context.doubleClickMaxDelay()) {
|
|
205
210
|
context.vertex_dblclick(d.props.origData || d.props, "", selected, eventOrigin);
|
|
@@ -254,15 +259,15 @@ export class GraphT<SG extends SubgraphProps, V extends VertexProps, E extends E
|
|
|
254
259
|
return this;
|
|
255
260
|
}
|
|
256
261
|
|
|
257
|
-
private _origData:
|
|
262
|
+
private _origData: GraphDataProps<SG, V, E> = {
|
|
258
263
|
subgraphs: [],
|
|
259
264
|
vertices: [],
|
|
260
265
|
edges: [],
|
|
261
266
|
hierarchy: []
|
|
262
267
|
};
|
|
263
|
-
data():
|
|
264
|
-
data(_:
|
|
265
|
-
data(_?:
|
|
268
|
+
data(): GraphDataProps<SG, V, E>;
|
|
269
|
+
data(_: GraphDataProps<SG, V, E>, merge?: boolean): this;
|
|
270
|
+
data(_?: GraphDataProps<SG, V, E>, merge?: boolean): GraphDataProps<SG, V, E> | this {
|
|
266
271
|
if (_ === void 0) return this._origData;
|
|
267
272
|
this._origData = _;
|
|
268
273
|
|
|
@@ -320,7 +325,7 @@ export class GraphT<SG extends SubgraphProps, V extends VertexProps, E extends E
|
|
|
320
325
|
return this;
|
|
321
326
|
}
|
|
322
327
|
|
|
323
|
-
graphData(): GraphCollection<VertexPlaceholder<V>, EdgePlaceholder<
|
|
328
|
+
graphData(): GraphCollection<VertexPlaceholder<V>, EdgePlaceholder<V, E>> {
|
|
324
329
|
return this._graphData;
|
|
325
330
|
}
|
|
326
331
|
|
|
@@ -504,7 +509,7 @@ export class GraphT<SG extends SubgraphProps, V extends VertexProps, E extends E
|
|
|
504
509
|
|
|
505
510
|
highlightEdges(edgeMap?: { [id: string]: boolean }) {
|
|
506
511
|
const context = this;
|
|
507
|
-
const edgeElements = this._edgeG.selectAll<SVGGElement, EdgePlaceholder<
|
|
512
|
+
const edgeElements = this._edgeG.selectAll<SVGGElement, EdgePlaceholder<V, E>>(".graphEdge");
|
|
508
513
|
edgeElements
|
|
509
514
|
.classed("graphEdge-highlighted", d => !edgeMap || edgeMap[d.id])
|
|
510
515
|
.style("stroke-width", function (o) {
|
|
@@ -538,7 +543,7 @@ export class GraphT<SG extends SubgraphProps, V extends VertexProps, E extends E
|
|
|
538
543
|
}
|
|
539
544
|
}
|
|
540
545
|
|
|
541
|
-
highlightEdge(_element, d?: EdgePlaceholder<
|
|
546
|
+
highlightEdge(_element, d?: EdgePlaceholder<V, E>) {
|
|
542
547
|
if (this.highlightOnMouseOverEdge()) {
|
|
543
548
|
if (d) {
|
|
544
549
|
const vertices = {};
|
|
@@ -572,7 +577,7 @@ export class GraphT<SG extends SubgraphProps, V extends VertexProps, E extends E
|
|
|
572
577
|
return this;
|
|
573
578
|
}
|
|
574
579
|
|
|
575
|
-
moveEdgePlaceholder(ep: EdgePlaceholder<
|
|
580
|
+
moveEdgePlaceholder(ep: EdgePlaceholder<V, E>, transition: boolean): this {
|
|
576
581
|
const edgeLayout = {
|
|
577
582
|
...this._layoutAlgo.edgePath(ep, this.edgeArcDepth())
|
|
578
583
|
};
|
|
@@ -589,7 +594,7 @@ export class GraphT<SG extends SubgraphProps, V extends VertexProps, E extends E
|
|
|
589
594
|
path: pathInterpolator(t),
|
|
590
595
|
labelPos: labelPosInterpolator(t),
|
|
591
596
|
strokeWidth: ep.props.strokeWidth ?? context.edgeStrokeWidth(),
|
|
592
|
-
color: ep.props.
|
|
597
|
+
color: ep.props.stroke ?? context.edgeColor()
|
|
593
598
|
};
|
|
594
599
|
context._edgeRenderer({ ...edgeLayout, ...ep.props, ...updated }, ep.element.node());
|
|
595
600
|
};
|
|
@@ -600,7 +605,7 @@ export class GraphT<SG extends SubgraphProps, V extends VertexProps, E extends E
|
|
|
600
605
|
|
|
601
606
|
moveVertexPlaceholder(vp: VertexPlaceholder<V>, transition: boolean, moveNeighbours: boolean): this {
|
|
602
607
|
const { x, y } = this.projectPlacholder(vp);
|
|
603
|
-
vp.element && (transition ? vp.element.transition().duration(this.transitionDuration()) as unknown as Selection<SVGPathElement, EdgePlaceholder<
|
|
608
|
+
vp.element && (transition ? vp.element.transition().duration(this.transitionDuration()) as unknown as Selection<SVGPathElement, EdgePlaceholder<V, E>, SVGGElement, any> : vp.element)
|
|
604
609
|
.attr("transform", `translate(${x} ${y})`)
|
|
605
610
|
;
|
|
606
611
|
if (moveNeighbours) {
|
|
@@ -690,7 +695,7 @@ export class GraphT<SG extends SubgraphProps, V extends VertexProps, E extends E
|
|
|
690
695
|
updateEdges(): this {
|
|
691
696
|
const context = this;
|
|
692
697
|
this._edgeG.selectAll(".graphEdge")
|
|
693
|
-
.data(this._graphData.allEdges(), (d: EdgePlaceholder<
|
|
698
|
+
.data(this._graphData.allEdges(), (d: EdgePlaceholder<V, E>) => d.id)
|
|
694
699
|
.join(
|
|
695
700
|
enter => enter.append("g")
|
|
696
701
|
.attr("class", "graphEdge")
|
|
@@ -763,6 +768,9 @@ export class GraphT<SG extends SubgraphProps, V extends VertexProps, E extends E
|
|
|
763
768
|
.on("dblclick", function (this: SVGElement, d) {
|
|
764
769
|
d3Event().stopPropagation();
|
|
765
770
|
})
|
|
771
|
+
.on("contextmenu", function (this: SVGElement, d) {
|
|
772
|
+
d3Event().preventDefault();
|
|
773
|
+
})
|
|
766
774
|
.on("mousein", function (d) {
|
|
767
775
|
Utility.safeRaise(this);
|
|
768
776
|
context.highlightVertex(d3Select(this), d);
|
|
@@ -1132,6 +1140,9 @@ export class GraphT<SG extends SubgraphProps, V extends VertexProps, E extends E
|
|
|
1132
1140
|
vertex_dblclick(row, _col, sel, data) {
|
|
1133
1141
|
}
|
|
1134
1142
|
|
|
1143
|
+
vertex_contextmenu(row, _col, sel, data) {
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1135
1146
|
vertex_mousein(row, _col, sel, data) {
|
|
1136
1147
|
}
|
|
1137
1148
|
|
|
@@ -1157,7 +1168,7 @@ export class GraphT<SG extends SubgraphProps, V extends VertexProps, E extends E
|
|
|
1157
1168
|
}
|
|
1158
1169
|
GraphT.prototype._class += " graph_GraphT";
|
|
1159
1170
|
|
|
1160
|
-
export interface GraphT<SG extends
|
|
1171
|
+
export interface GraphT<SG extends SubgraphBaseProps = any, V extends VertexBaseProps = any, E extends EdgeBaseProps<V> = any> {
|
|
1161
1172
|
allowDragging(): boolean;
|
|
1162
1173
|
allowDragging(_: boolean): this;
|
|
1163
1174
|
dragSingleNeighbors(): boolean;
|
|
@@ -1314,7 +1325,6 @@ export function graphviz(dot: string, engine: Engine = "dot", _scriptDir: string
|
|
|
1314
1325
|
links: [],
|
|
1315
1326
|
raw: dot
|
|
1316
1327
|
}, {
|
|
1317
|
-
engine: engine
|
|
1318
|
-
wasmFolder: new URL(scriptDir, document.baseURI).href
|
|
1328
|
+
engine: engine
|
|
1319
1329
|
});
|
|
1320
1330
|
}
|
package/src/graph2/index.ts
CHANGED