@hpcc-js/graph 3.7.4 → 3.7.6
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-BkFKgQ-y.js.map +1 -0
- package/dist/index.js +26 -26
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +22 -22
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +12 -10
- 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
- package/dist/assets/graphviz-BK7FEJlA.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hpcc-js/graph",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.6",
|
|
4
4
|
"description": "hpcc-js - Viz Graph",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.umd.cjs",
|
|
@@ -24,10 +24,12 @@
|
|
|
24
24
|
"clean": "rimraf --glob lib* types dist *.tsbuildinfo .turbo ./workers/dist ./workers/lib-es6 ./workers/types",
|
|
25
25
|
"bundle": "vite build",
|
|
26
26
|
"bundle-workers": "vite build -c ./workers/vite.config.ts",
|
|
27
|
-
"bundle-watch": "vite --
|
|
27
|
+
"bundle-watch": "vite build --watch",
|
|
28
|
+
"bundle-serve": "vite --port 5509",
|
|
28
29
|
"gen-types": "tsc --project tsconfig.json",
|
|
29
30
|
"gen-types-watch": "npm run gen-types -- --watch",
|
|
30
31
|
"build": "run-p gen-types bundle",
|
|
32
|
+
"watch": "run-p gen-types-watch bundle-watch",
|
|
31
33
|
"lint": "eslint ./src",
|
|
32
34
|
"lint-fix": "eslint --fix src/**/*.ts",
|
|
33
35
|
"docs": "typedoc --options tdoptions.json .",
|
|
@@ -38,18 +40,18 @@
|
|
|
38
40
|
"update-major": "npx --yes npm-check-updates -u"
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
|
-
"@hpcc-js/api": "^3.4.
|
|
42
|
-
"@hpcc-js/common": "^3.7.
|
|
43
|
-
"@hpcc-js/html": "^3.3.
|
|
44
|
-
"@hpcc-js/react": "^3.4.
|
|
45
|
-
"@hpcc-js/util": "^3.5.
|
|
43
|
+
"@hpcc-js/api": "^3.4.17",
|
|
44
|
+
"@hpcc-js/common": "^3.7.7",
|
|
45
|
+
"@hpcc-js/html": "^3.3.17",
|
|
46
|
+
"@hpcc-js/react": "^3.4.17",
|
|
47
|
+
"@hpcc-js/util": "^3.5.6"
|
|
46
48
|
},
|
|
47
49
|
"optionalPeerDependencies": {
|
|
48
50
|
"react": ">=17.0.0"
|
|
49
51
|
},
|
|
50
52
|
"devDependencies": {
|
|
51
|
-
"@hpcc-js/esbuild-plugins": "^1.8.
|
|
52
|
-
"@hpcc-js/wasm-graphviz": "1.21.
|
|
53
|
+
"@hpcc-js/esbuild-plugins": "^1.8.8",
|
|
54
|
+
"@hpcc-js/wasm-graphviz": "1.21.4",
|
|
53
55
|
"@types/d3-transition": "1.3.6",
|
|
54
56
|
"@types/dagre": "0.7.54",
|
|
55
57
|
"d3-force": "^1",
|
|
@@ -73,5 +75,5 @@
|
|
|
73
75
|
"url": "https://github.com/hpcc-systems/Visualization/issues"
|
|
74
76
|
},
|
|
75
77
|
"homepage": "https://github.com/hpcc-systems/Visualization",
|
|
76
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "630e839917f1cc38f6e3324db5a9ac991234599a"
|
|
77
79
|
}
|
package/src/AdjacencyGraph.ts
CHANGED
|
@@ -1,224 +1,224 @@
|
|
|
1
|
-
import { PropertyExt } from "@hpcc-js/common";
|
|
2
|
-
import { hashSum } from "@hpcc-js/util";
|
|
3
|
-
import { Edge } from "./Edge.ts";
|
|
4
|
-
import { Graph, IGraphData } from "./Graph.ts";
|
|
5
|
-
import { IAnnotation, Vertex } from "./Vertex.ts";
|
|
6
|
-
|
|
7
|
-
interface IAnnotationIndexes {
|
|
8
|
-
iconCol: number;
|
|
9
|
-
iconFillCol: number;
|
|
10
|
-
tooltipCol: number;
|
|
11
|
-
shapeStrokeCol: number;
|
|
12
|
-
shapeFillCol: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class Annotation extends PropertyExt {
|
|
16
|
-
protected _owner: AdjacencyGraph;
|
|
17
|
-
|
|
18
|
-
owner(): AdjacencyGraph;
|
|
19
|
-
owner(_: AdjacencyGraph): this;
|
|
20
|
-
owner(_?: AdjacencyGraph): AdjacencyGraph | this {
|
|
21
|
-
if (!arguments.length) return this._owner;
|
|
22
|
-
this._owner = _;
|
|
23
|
-
return this;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
valid(): boolean {
|
|
27
|
-
return !!this.iconColumn();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
indexes(): IAnnotationIndexes {
|
|
31
|
-
const columns = this._owner.columns();
|
|
32
|
-
return {
|
|
33
|
-
iconCol: columns.indexOf(this.iconColumn()),
|
|
34
|
-
iconFillCol: columns.indexOf(this.iconFillColumn()),
|
|
35
|
-
tooltipCol: columns.indexOf(this.tooltipColumn()),
|
|
36
|
-
shapeStrokeCol: columns.indexOf(this.shapeStrokeColumn()),
|
|
37
|
-
shapeFillCol: columns.indexOf(this.shapeFillColumn())
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
mapper(): (row) => IAnnotation {
|
|
42
|
-
const indexes = this.indexes();
|
|
43
|
-
return (row) => ({
|
|
44
|
-
faChar: row[indexes.iconCol],
|
|
45
|
-
tooltip: row[indexes.tooltipCol],
|
|
46
|
-
shape_colorFill: row[indexes.shapeFillCol] || this.shapeFillDefault(),
|
|
47
|
-
shape_colorStroke: row[indexes.shapeStrokeCol] || this.shapeStrokeDefault(),
|
|
48
|
-
image_colorFill: row[indexes.iconFillCol] || this.iconFillDefault()
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
Annotation.prototype._class += " graph_Annotation";
|
|
53
|
-
export interface Annotation {
|
|
54
|
-
iconColumn(): string;
|
|
55
|
-
iconColumn(_: string): this;
|
|
56
|
-
iconFillDefault(): string;
|
|
57
|
-
iconFillDefault(_: string): this;
|
|
58
|
-
iconFillColumn(): string;
|
|
59
|
-
iconFillColumn(_: string): this;
|
|
60
|
-
tooltipColumn(): string;
|
|
61
|
-
tooltipColumn(_: string): this;
|
|
62
|
-
shapeStrokeDefault(): string;
|
|
63
|
-
shapeStrokeDefault(_: string): this;
|
|
64
|
-
shapeStrokeColumn(): string;
|
|
65
|
-
shapeStrokeColumn(_: string): this;
|
|
66
|
-
shapeFillDefault(): string;
|
|
67
|
-
shapeFillDefault(_: string): this;
|
|
68
|
-
shapeFillColumn(): string;
|
|
69
|
-
shapeFillColumn(_: string): this;
|
|
70
|
-
}
|
|
71
|
-
Annotation.prototype.publish("iconColumn", "", "set", "Icon column", function (this: Annotation) { return this._owner.columns(); }, { optional: true });
|
|
72
|
-
Annotation.prototype.publish("iconFillDefault", "white", "html-color", "Icon fill default color");
|
|
73
|
-
Annotation.prototype.publish("iconFillColumn", "", "set", "Icon fill color column", function (this: Annotation) { return this._owner.columns(); }, { optional: true });
|
|
74
|
-
Annotation.prototype.publish("tooltipColumn", "", "set", "Tooltip column", function (this: Annotation) { return this._owner.columns(); }, { optional: true });
|
|
75
|
-
Annotation.prototype.publish("shapeStrokeDefault", "darkred", "html-color", "Shape stroke default color");
|
|
76
|
-
Annotation.prototype.publish("shapeStrokeColumn", "", "set", "Shape stroke color column", function (this: Annotation) { return this._owner.columns(); }, { optional: true });
|
|
77
|
-
Annotation.prototype.publish("shapeFillDefault", "red", "html-color", "Shape fill default color");
|
|
78
|
-
Annotation.prototype.publish("shapeFillColumn", "", "set", "Shape fill color column", function (this: Annotation) { return this._owner.columns(); }, { optional: true });
|
|
79
|
-
|
|
80
|
-
export class AdjacencyGraph extends Graph {
|
|
81
|
-
|
|
82
|
-
private _vertexMap: { [key: string]: Vertex } = {};
|
|
83
|
-
private _edgeMap: { [key: string]: Edge } = {};
|
|
84
|
-
private _prevAdjacencyDataHash: string;
|
|
85
|
-
private _merge: boolean = false;
|
|
86
|
-
private _adjacencyData: object[] = [];
|
|
87
|
-
|
|
88
|
-
constructor() {
|
|
89
|
-
super();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
linksColumns(): string[] {
|
|
93
|
-
const linksCol: number = this.columns().indexOf(this.linksColumn());
|
|
94
|
-
const linksField = this._db.field(linksCol);
|
|
95
|
-
if (linksField) {
|
|
96
|
-
return linksField.children().map(field => field.label());
|
|
97
|
-
}
|
|
98
|
-
return [];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
validAnnotations() {
|
|
102
|
-
return this.annotations().filter(a => a.valid());
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
updateData() {
|
|
106
|
-
const prevAdjacencyDataHash = hashSum([this._adjacencyData, this.uidColumn(), this.labelColumn(), this.iconColumn(), this.linksColumn(), this.linkUidColumn(), this.linkLabelColumn(), this.validAnnotations().map(a => a.hashSum())]);
|
|
107
|
-
if (this._prevAdjacencyDataHash !== prevAdjacencyDataHash) {
|
|
108
|
-
this._prevAdjacencyDataHash = prevAdjacencyDataHash;
|
|
109
|
-
|
|
110
|
-
const columns = this.columns();
|
|
111
|
-
const uidCol: number = columns.indexOf(this.uidColumn());
|
|
112
|
-
const labelCol: number = columns.indexOf(this.labelColumn());
|
|
113
|
-
const iconCol: number = columns.indexOf(this.iconColumn());
|
|
114
|
-
const linksCol: number = columns.indexOf(this.linksColumn());
|
|
115
|
-
|
|
116
|
-
const linksColumns = this.linksColumns();
|
|
117
|
-
const linksUidCol: number = linksColumns.indexOf(this.linkUidColumn());
|
|
118
|
-
const linksLabelCol: number = linksColumns.indexOf(this.linkLabelColumn());
|
|
119
|
-
|
|
120
|
-
const annotationMappers = this.validAnnotations().map(a => a.mapper());
|
|
121
|
-
|
|
122
|
-
const vertexMap: { [key: string]: Vertex } = {};
|
|
123
|
-
const edgeMap: { [key: string]: Edge } = {};
|
|
124
|
-
const graphData: IGraphData = {
|
|
125
|
-
vertices: this._adjacencyData.map(row => {
|
|
126
|
-
const uid = row[uidCol];
|
|
127
|
-
if (uid !== undefined) {
|
|
128
|
-
let retVal = vertexMap[uid] || this._vertexMap[uid];
|
|
129
|
-
if (!retVal) {
|
|
130
|
-
retVal = new Vertex();
|
|
131
|
-
}
|
|
132
|
-
vertexMap[uid] = retVal;
|
|
133
|
-
|
|
134
|
-
retVal
|
|
135
|
-
.text(row[labelCol])
|
|
136
|
-
.data(row)
|
|
137
|
-
.faChar(row[iconCol])
|
|
138
|
-
.annotationIcons(annotationMappers.map(am => am(row)))
|
|
139
|
-
;
|
|
140
|
-
|
|
141
|
-
return retVal;
|
|
142
|
-
}
|
|
143
|
-
}).filter(v => !!v),
|
|
144
|
-
edges: []
|
|
145
|
-
};
|
|
146
|
-
for (const row of this._adjacencyData) {
|
|
147
|
-
const uid = row[uidCol];
|
|
148
|
-
const links = row[linksCol];
|
|
149
|
-
if (uid !== undefined && links !== undefined) {
|
|
150
|
-
for (const childRow of links) {
|
|
151
|
-
const linkUid = childRow[linksUidCol];
|
|
152
|
-
const linkLabel = childRow[linksLabelCol];
|
|
153
|
-
const edgeID = `${uid}->${linkUid}`;
|
|
154
|
-
let retVal = edgeMap[edgeID] || this._edgeMap[edgeID];
|
|
155
|
-
if (!retVal) {
|
|
156
|
-
if (vertexMap[uid] && vertexMap[linkUid]) {
|
|
157
|
-
retVal = new Edge()
|
|
158
|
-
.sourceVertex(vertexMap[uid])
|
|
159
|
-
.targetVertex(vertexMap[linkUid])
|
|
160
|
-
.data(childRow)
|
|
161
|
-
;
|
|
162
|
-
} else {
|
|
163
|
-
console.warn("Missing vertices for edge: " + edgeID);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
if (retVal) {
|
|
167
|
-
retVal.text(linkLabel);
|
|
168
|
-
edgeMap[edgeID] = retVal;
|
|
169
|
-
graphData.edges.push(retVal);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
this._vertexMap = vertexMap;
|
|
175
|
-
this._edgeMap = edgeMap;
|
|
176
|
-
super.data(graphData, this._merge);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
data(): IGraphData;
|
|
181
|
-
data(_: IGraphData, merge?: boolean): this;
|
|
182
|
-
data(_?: IGraphData | object[], merge?: boolean): IGraphData | object[] | this {
|
|
183
|
-
if (!arguments.length) return this._adjacencyData;
|
|
184
|
-
if (_ instanceof Array) {
|
|
185
|
-
this._merge = merge;
|
|
186
|
-
this._adjacencyData = _;
|
|
187
|
-
return this;
|
|
188
|
-
}
|
|
189
|
-
throw new Error("Invalid data shape.");
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
update(domNode, element) {
|
|
193
|
-
this.updateData();
|
|
194
|
-
super.update(domNode, element);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
click(row, col, sel) {
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
AdjacencyGraph.prototype._class += " graph_AdjacencyGraph";
|
|
201
|
-
|
|
202
|
-
export interface AdjacencyGraph {
|
|
203
|
-
uidColumn(): string;
|
|
204
|
-
uidColumn(_: string): this;
|
|
205
|
-
labelColumn(): string;
|
|
206
|
-
labelColumn(_: string): this;
|
|
207
|
-
iconColumn(): string;
|
|
208
|
-
iconColumn(_: string): this;
|
|
209
|
-
linksColumn(): string;
|
|
210
|
-
linksColumn(_: string): this;
|
|
211
|
-
linkUidColumn(): string;
|
|
212
|
-
linkUidColumn(_: string): this;
|
|
213
|
-
linkLabelColumn(): string;
|
|
214
|
-
linkLabelColumn(_: string): this;
|
|
215
|
-
annotations(): Annotation[];
|
|
216
|
-
annotations(_: Annotation[]): this;
|
|
217
|
-
}
|
|
218
|
-
AdjacencyGraph.prototype.publish("uidColumn", "", "set", "UID column", function (this: AdjacencyGraph) { return this.columns(); }, { optional: true });
|
|
219
|
-
AdjacencyGraph.prototype.publish("labelColumn", "", "set", "Label column", function (this: AdjacencyGraph) { return this.columns(); }, { optional: true });
|
|
220
|
-
AdjacencyGraph.prototype.publish("iconColumn", "", "set", "Icon column", function (this: AdjacencyGraph) { return this.columns(); }, { optional: true });
|
|
221
|
-
AdjacencyGraph.prototype.publish("linksColumn", "", "set", "Links column", function (this: AdjacencyGraph) { return this.columns(); }, { optional: true });
|
|
222
|
-
AdjacencyGraph.prototype.publish("linkUidColumn", "", "set", "Link UID column", function (this: AdjacencyGraph) { return this.linksColumns(); }, { optional: true });
|
|
223
|
-
AdjacencyGraph.prototype.publish("linkLabelColumn", "", "set", "Link Label column", function (this: AdjacencyGraph) { return this.linksColumns(); }, { optional: true });
|
|
224
|
-
AdjacencyGraph.prototype.publish("annotations", [], "propertyArray", "Annotations", null, { autoExpand: Annotation });
|
|
1
|
+
import { PropertyExt } from "@hpcc-js/common";
|
|
2
|
+
import { hashSum } from "@hpcc-js/util";
|
|
3
|
+
import { Edge } from "./Edge.ts";
|
|
4
|
+
import { Graph, IGraphData } from "./Graph.ts";
|
|
5
|
+
import { IAnnotation, Vertex } from "./Vertex.ts";
|
|
6
|
+
|
|
7
|
+
interface IAnnotationIndexes {
|
|
8
|
+
iconCol: number;
|
|
9
|
+
iconFillCol: number;
|
|
10
|
+
tooltipCol: number;
|
|
11
|
+
shapeStrokeCol: number;
|
|
12
|
+
shapeFillCol: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class Annotation extends PropertyExt {
|
|
16
|
+
protected _owner: AdjacencyGraph;
|
|
17
|
+
|
|
18
|
+
owner(): AdjacencyGraph;
|
|
19
|
+
owner(_: AdjacencyGraph): this;
|
|
20
|
+
owner(_?: AdjacencyGraph): AdjacencyGraph | this {
|
|
21
|
+
if (!arguments.length) return this._owner;
|
|
22
|
+
this._owner = _;
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
valid(): boolean {
|
|
27
|
+
return !!this.iconColumn();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
indexes(): IAnnotationIndexes {
|
|
31
|
+
const columns = this._owner.columns();
|
|
32
|
+
return {
|
|
33
|
+
iconCol: columns.indexOf(this.iconColumn()),
|
|
34
|
+
iconFillCol: columns.indexOf(this.iconFillColumn()),
|
|
35
|
+
tooltipCol: columns.indexOf(this.tooltipColumn()),
|
|
36
|
+
shapeStrokeCol: columns.indexOf(this.shapeStrokeColumn()),
|
|
37
|
+
shapeFillCol: columns.indexOf(this.shapeFillColumn())
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
mapper(): (row) => IAnnotation {
|
|
42
|
+
const indexes = this.indexes();
|
|
43
|
+
return (row) => ({
|
|
44
|
+
faChar: row[indexes.iconCol],
|
|
45
|
+
tooltip: row[indexes.tooltipCol],
|
|
46
|
+
shape_colorFill: row[indexes.shapeFillCol] || this.shapeFillDefault(),
|
|
47
|
+
shape_colorStroke: row[indexes.shapeStrokeCol] || this.shapeStrokeDefault(),
|
|
48
|
+
image_colorFill: row[indexes.iconFillCol] || this.iconFillDefault()
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
Annotation.prototype._class += " graph_Annotation";
|
|
53
|
+
export interface Annotation {
|
|
54
|
+
iconColumn(): string;
|
|
55
|
+
iconColumn(_: string): this;
|
|
56
|
+
iconFillDefault(): string;
|
|
57
|
+
iconFillDefault(_: string): this;
|
|
58
|
+
iconFillColumn(): string;
|
|
59
|
+
iconFillColumn(_: string): this;
|
|
60
|
+
tooltipColumn(): string;
|
|
61
|
+
tooltipColumn(_: string): this;
|
|
62
|
+
shapeStrokeDefault(): string;
|
|
63
|
+
shapeStrokeDefault(_: string): this;
|
|
64
|
+
shapeStrokeColumn(): string;
|
|
65
|
+
shapeStrokeColumn(_: string): this;
|
|
66
|
+
shapeFillDefault(): string;
|
|
67
|
+
shapeFillDefault(_: string): this;
|
|
68
|
+
shapeFillColumn(): string;
|
|
69
|
+
shapeFillColumn(_: string): this;
|
|
70
|
+
}
|
|
71
|
+
Annotation.prototype.publish("iconColumn", "", "set", "Icon column", function (this: Annotation) { return this._owner.columns(); }, { optional: true });
|
|
72
|
+
Annotation.prototype.publish("iconFillDefault", "white", "html-color", "Icon fill default color");
|
|
73
|
+
Annotation.prototype.publish("iconFillColumn", "", "set", "Icon fill color column", function (this: Annotation) { return this._owner.columns(); }, { optional: true });
|
|
74
|
+
Annotation.prototype.publish("tooltipColumn", "", "set", "Tooltip column", function (this: Annotation) { return this._owner.columns(); }, { optional: true });
|
|
75
|
+
Annotation.prototype.publish("shapeStrokeDefault", "darkred", "html-color", "Shape stroke default color");
|
|
76
|
+
Annotation.prototype.publish("shapeStrokeColumn", "", "set", "Shape stroke color column", function (this: Annotation) { return this._owner.columns(); }, { optional: true });
|
|
77
|
+
Annotation.prototype.publish("shapeFillDefault", "red", "html-color", "Shape fill default color");
|
|
78
|
+
Annotation.prototype.publish("shapeFillColumn", "", "set", "Shape fill color column", function (this: Annotation) { return this._owner.columns(); }, { optional: true });
|
|
79
|
+
|
|
80
|
+
export class AdjacencyGraph extends Graph {
|
|
81
|
+
|
|
82
|
+
private _vertexMap: { [key: string]: Vertex } = {};
|
|
83
|
+
private _edgeMap: { [key: string]: Edge } = {};
|
|
84
|
+
private _prevAdjacencyDataHash: string;
|
|
85
|
+
private _merge: boolean = false;
|
|
86
|
+
private _adjacencyData: object[] = [];
|
|
87
|
+
|
|
88
|
+
constructor() {
|
|
89
|
+
super();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
linksColumns(): string[] {
|
|
93
|
+
const linksCol: number = this.columns().indexOf(this.linksColumn());
|
|
94
|
+
const linksField = this._db.field(linksCol);
|
|
95
|
+
if (linksField) {
|
|
96
|
+
return linksField.children().map(field => field.label());
|
|
97
|
+
}
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
validAnnotations() {
|
|
102
|
+
return this.annotations().filter(a => a.valid());
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
updateData() {
|
|
106
|
+
const prevAdjacencyDataHash = hashSum([this._adjacencyData, this.uidColumn(), this.labelColumn(), this.iconColumn(), this.linksColumn(), this.linkUidColumn(), this.linkLabelColumn(), this.validAnnotations().map(a => a.hashSum())]);
|
|
107
|
+
if (this._prevAdjacencyDataHash !== prevAdjacencyDataHash) {
|
|
108
|
+
this._prevAdjacencyDataHash = prevAdjacencyDataHash;
|
|
109
|
+
|
|
110
|
+
const columns = this.columns();
|
|
111
|
+
const uidCol: number = columns.indexOf(this.uidColumn());
|
|
112
|
+
const labelCol: number = columns.indexOf(this.labelColumn());
|
|
113
|
+
const iconCol: number = columns.indexOf(this.iconColumn());
|
|
114
|
+
const linksCol: number = columns.indexOf(this.linksColumn());
|
|
115
|
+
|
|
116
|
+
const linksColumns = this.linksColumns();
|
|
117
|
+
const linksUidCol: number = linksColumns.indexOf(this.linkUidColumn());
|
|
118
|
+
const linksLabelCol: number = linksColumns.indexOf(this.linkLabelColumn());
|
|
119
|
+
|
|
120
|
+
const annotationMappers = this.validAnnotations().map(a => a.mapper());
|
|
121
|
+
|
|
122
|
+
const vertexMap: { [key: string]: Vertex } = {};
|
|
123
|
+
const edgeMap: { [key: string]: Edge } = {};
|
|
124
|
+
const graphData: IGraphData = {
|
|
125
|
+
vertices: this._adjacencyData.map(row => {
|
|
126
|
+
const uid = row[uidCol];
|
|
127
|
+
if (uid !== undefined) {
|
|
128
|
+
let retVal = vertexMap[uid] || this._vertexMap[uid];
|
|
129
|
+
if (!retVal) {
|
|
130
|
+
retVal = new Vertex();
|
|
131
|
+
}
|
|
132
|
+
vertexMap[uid] = retVal;
|
|
133
|
+
|
|
134
|
+
retVal
|
|
135
|
+
.text(row[labelCol])
|
|
136
|
+
.data(row)
|
|
137
|
+
.faChar(row[iconCol])
|
|
138
|
+
.annotationIcons(annotationMappers.map(am => am(row)))
|
|
139
|
+
;
|
|
140
|
+
|
|
141
|
+
return retVal;
|
|
142
|
+
}
|
|
143
|
+
}).filter(v => !!v),
|
|
144
|
+
edges: []
|
|
145
|
+
};
|
|
146
|
+
for (const row of this._adjacencyData) {
|
|
147
|
+
const uid = row[uidCol];
|
|
148
|
+
const links = row[linksCol];
|
|
149
|
+
if (uid !== undefined && links !== undefined) {
|
|
150
|
+
for (const childRow of links) {
|
|
151
|
+
const linkUid = childRow[linksUidCol];
|
|
152
|
+
const linkLabel = childRow[linksLabelCol];
|
|
153
|
+
const edgeID = `${uid}->${linkUid}`;
|
|
154
|
+
let retVal = edgeMap[edgeID] || this._edgeMap[edgeID];
|
|
155
|
+
if (!retVal) {
|
|
156
|
+
if (vertexMap[uid] && vertexMap[linkUid]) {
|
|
157
|
+
retVal = new Edge()
|
|
158
|
+
.sourceVertex(vertexMap[uid])
|
|
159
|
+
.targetVertex(vertexMap[linkUid])
|
|
160
|
+
.data(childRow)
|
|
161
|
+
;
|
|
162
|
+
} else {
|
|
163
|
+
console.warn("Missing vertices for edge: " + edgeID);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (retVal) {
|
|
167
|
+
retVal.text(linkLabel);
|
|
168
|
+
edgeMap[edgeID] = retVal;
|
|
169
|
+
graphData.edges.push(retVal);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
this._vertexMap = vertexMap;
|
|
175
|
+
this._edgeMap = edgeMap;
|
|
176
|
+
super.data(graphData, this._merge);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
data(): IGraphData;
|
|
181
|
+
data(_: IGraphData, merge?: boolean): this;
|
|
182
|
+
data(_?: IGraphData | object[], merge?: boolean): IGraphData | object[] | this {
|
|
183
|
+
if (!arguments.length) return this._adjacencyData;
|
|
184
|
+
if (_ instanceof Array) {
|
|
185
|
+
this._merge = merge;
|
|
186
|
+
this._adjacencyData = _;
|
|
187
|
+
return this;
|
|
188
|
+
}
|
|
189
|
+
throw new Error("Invalid data shape.");
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
update(domNode, element) {
|
|
193
|
+
this.updateData();
|
|
194
|
+
super.update(domNode, element);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
click(row, col, sel) {
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
AdjacencyGraph.prototype._class += " graph_AdjacencyGraph";
|
|
201
|
+
|
|
202
|
+
export interface AdjacencyGraph {
|
|
203
|
+
uidColumn(): string;
|
|
204
|
+
uidColumn(_: string): this;
|
|
205
|
+
labelColumn(): string;
|
|
206
|
+
labelColumn(_: string): this;
|
|
207
|
+
iconColumn(): string;
|
|
208
|
+
iconColumn(_: string): this;
|
|
209
|
+
linksColumn(): string;
|
|
210
|
+
linksColumn(_: string): this;
|
|
211
|
+
linkUidColumn(): string;
|
|
212
|
+
linkUidColumn(_: string): this;
|
|
213
|
+
linkLabelColumn(): string;
|
|
214
|
+
linkLabelColumn(_: string): this;
|
|
215
|
+
annotations(): Annotation[];
|
|
216
|
+
annotations(_: Annotation[]): this;
|
|
217
|
+
}
|
|
218
|
+
AdjacencyGraph.prototype.publish("uidColumn", "", "set", "UID column", function (this: AdjacencyGraph) { return this.columns(); }, { optional: true });
|
|
219
|
+
AdjacencyGraph.prototype.publish("labelColumn", "", "set", "Label column", function (this: AdjacencyGraph) { return this.columns(); }, { optional: true });
|
|
220
|
+
AdjacencyGraph.prototype.publish("iconColumn", "", "set", "Icon column", function (this: AdjacencyGraph) { return this.columns(); }, { optional: true });
|
|
221
|
+
AdjacencyGraph.prototype.publish("linksColumn", "", "set", "Links column", function (this: AdjacencyGraph) { return this.columns(); }, { optional: true });
|
|
222
|
+
AdjacencyGraph.prototype.publish("linkUidColumn", "", "set", "Link UID column", function (this: AdjacencyGraph) { return this.linksColumns(); }, { optional: true });
|
|
223
|
+
AdjacencyGraph.prototype.publish("linkLabelColumn", "", "set", "Link Label column", function (this: AdjacencyGraph) { return this.linksColumns(); }, { optional: true });
|
|
224
|
+
AdjacencyGraph.prototype.publish("annotations", [], "propertyArray", "Annotations", null, { autoExpand: Annotation });
|
package/src/Edge.css
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
.graph_Edge {
|
|
2
|
-
fill: none;
|
|
3
|
-
stroke: #656565;
|
|
4
|
-
stroke-width: 1.0px;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.graph_Edge .common_TextBox .common_Text {
|
|
8
|
-
fill: black;
|
|
9
|
-
stroke: none;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.graph_Edge .common_TextBox .common_Shape {
|
|
13
|
-
fill: white;
|
|
14
|
-
stroke: none;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.graph_Edge.selected {
|
|
18
|
-
stroke: red !important;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.graph_Edge.selected .common_Text {
|
|
22
|
-
fill: red !important;
|
|
1
|
+
.graph_Edge {
|
|
2
|
+
fill: none;
|
|
3
|
+
stroke: #656565;
|
|
4
|
+
stroke-width: 1.0px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.graph_Edge .common_TextBox .common_Text {
|
|
8
|
+
fill: black;
|
|
9
|
+
stroke: none;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.graph_Edge .common_TextBox .common_Shape {
|
|
13
|
+
fill: white;
|
|
14
|
+
stroke: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.graph_Edge.selected {
|
|
18
|
+
stroke: red !important;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.graph_Edge.selected .common_Text {
|
|
22
|
+
fill: red !important;
|
|
23
23
|
}
|