@hpcc-js/graph 2.71.0 → 2.75.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es6.js +860 -8416
- package/dist/index.es6.js.map +1 -1
- package/dist/index.js +865 -8421
- 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 +23 -22
- package/src/Sankey.ts +35 -14
- package/src/__package__.ts +2 -2
- package/src/graph2/dataGraph.ts +33 -12
- package/src/graph2/graph.ts +6 -2
- package/src/graph2/layouts/dagreWorker.ts +1 -1
- package/src/graph2/layouts/forceDirectedWorker.ts +8 -1
- package/src/graph2/layouts/graphvizWorker.ts +22 -1
- package/src/graph2/layouts/placeholders.ts +1 -0
- package/src/graph2/sankeyGraph.css +45 -0
- package/src/graph2/sankeyGraph.ts +11 -9
- package/src/test.ts +49 -4
- package/types/Sankey.d.ts +8 -0
- package/types/Sankey.d.ts.map +1 -1
- package/types/__package__.d.ts +2 -2
- package/types/graph2/dataGraph.d.ts +2 -0
- package/types/graph2/dataGraph.d.ts.map +1 -1
- package/types/graph2/graph.d.ts.map +1 -1
- package/types/graph2/layouts/forceDirectedWorker.d.ts.map +1 -1
- package/types/graph2/layouts/graphvizWorker.d.ts.map +1 -1
- package/types/graph2/layouts/placeholders.d.ts +1 -0
- package/types/graph2/layouts/placeholders.d.ts.map +1 -1
- package/types/graph2/sankeyGraph.d.ts +1 -1
- package/types/graph2/sankeyGraph.d.ts.map +1 -1
- package/types/test.d.ts +6 -1
- package/types/test.d.ts.map +1 -1
- package/types-3.4/Sankey.d.ts +8 -0
- package/types-3.4/__package__.d.ts +2 -2
- package/types-3.4/graph2/dataGraph.d.ts +2 -0
- package/types-3.4/graph2/layouts/placeholders.d.ts +1 -0
- package/types-3.4/graph2/sankeyGraph.d.ts +1 -1
- package/types-3.4/test.d.ts +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hpcc-js/graph",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.75.0",
|
|
4
4
|
"description": "hpcc-js - Viz Graph",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.es6",
|
|
@@ -51,22 +51,22 @@
|
|
|
51
51
|
"ddd": "downlevel-dts . ts3.4"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@hpcc-js/api": "^2.8.
|
|
55
|
-
"@hpcc-js/common": "^2.
|
|
56
|
-
"@hpcc-js/html": "^2.
|
|
57
|
-
"@hpcc-js/react": "^2.
|
|
58
|
-
"@hpcc-js/util": "^2.
|
|
54
|
+
"@hpcc-js/api": "^2.8.57",
|
|
55
|
+
"@hpcc-js/common": "^2.62.0",
|
|
56
|
+
"@hpcc-js/html": "^2.37.0",
|
|
57
|
+
"@hpcc-js/react": "^2.45.0",
|
|
58
|
+
"@hpcc-js/util": "^2.42.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@hpcc-js/bundle": "^2.10.
|
|
61
|
+
"@hpcc-js/bundle": "^2.10.21",
|
|
62
62
|
"@hpcc-js/wasm": "1.7.1",
|
|
63
|
-
"@rollup/plugin-alias": "3.1.
|
|
64
|
-
"@rollup/plugin-commonjs": "
|
|
65
|
-
"@rollup/plugin-node-resolve": "
|
|
63
|
+
"@rollup/plugin-alias": "3.1.9",
|
|
64
|
+
"@rollup/plugin-commonjs": "21.0.1",
|
|
65
|
+
"@rollup/plugin-node-resolve": "13.1.3",
|
|
66
66
|
"@types/d3-transition": "1.3.2",
|
|
67
67
|
"@types/dagre": "0.7.41",
|
|
68
|
-
"@typescript-eslint/eslint-plugin": "
|
|
69
|
-
"@typescript-eslint/parser": "
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "5.10.1",
|
|
69
|
+
"@typescript-eslint/parser": "5.10.1",
|
|
70
70
|
"cpx": "1.5.0",
|
|
71
71
|
"d3-array": "^1",
|
|
72
72
|
"d3-drag": "^1",
|
|
@@ -81,16 +81,17 @@
|
|
|
81
81
|
"dagre": "0.8.5",
|
|
82
82
|
"downlevel-dts": "0.6.0",
|
|
83
83
|
"es6-promise": "4.2.8",
|
|
84
|
-
"eslint": "
|
|
84
|
+
"eslint": "8.8.0",
|
|
85
|
+
"eslint-plugin-react-hooks": "^4.3.0",
|
|
85
86
|
"npm-run-all": "4.1.5",
|
|
86
|
-
"rimraf": "
|
|
87
|
-
"rollup": "2.
|
|
88
|
-
"rollup-plugin-postcss": "
|
|
89
|
-
"rollup-plugin-sourcemaps": "0.6.
|
|
90
|
-
"terser": "
|
|
91
|
-
"tslib": "2.3.
|
|
92
|
-
"typedoc": "0.
|
|
93
|
-
"typescript": "4.
|
|
87
|
+
"rimraf": "3.0.2",
|
|
88
|
+
"rollup": "2.66.1",
|
|
89
|
+
"rollup-plugin-postcss": "4.0.2",
|
|
90
|
+
"rollup-plugin-sourcemaps": "0.6.3",
|
|
91
|
+
"terser": "5.10.0",
|
|
92
|
+
"tslib": "2.3.1",
|
|
93
|
+
"typedoc": "0.22.11",
|
|
94
|
+
"typescript": "4.5.5"
|
|
94
95
|
},
|
|
95
96
|
"repository": {
|
|
96
97
|
"type": "git",
|
|
@@ -103,5 +104,5 @@
|
|
|
103
104
|
"url": "https://github.com/hpcc-systems/Visualization/issues"
|
|
104
105
|
},
|
|
105
106
|
"homepage": "https://github.com/hpcc-systems/Visualization",
|
|
106
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "481c2fc2b4389cb32900bf2735bed31e7bfb7dfd"
|
|
107
108
|
}
|
package/src/Sankey.ts
CHANGED
|
@@ -68,7 +68,6 @@ export class Sankey extends SVGWidget {
|
|
|
68
68
|
constructor() {
|
|
69
69
|
super();
|
|
70
70
|
Utility.SimpleSelectionMixin.call(this);
|
|
71
|
-
|
|
72
71
|
this._drawStartPos = "origin";
|
|
73
72
|
}
|
|
74
73
|
|
|
@@ -79,6 +78,7 @@ export class Sankey extends SVGWidget {
|
|
|
79
78
|
};
|
|
80
79
|
if (this.data().length === 0) return retVal;
|
|
81
80
|
const vertexIndex = {};
|
|
81
|
+
const valueIdx = 2;
|
|
82
82
|
const mappings = this.mappings().filter(mapping => mapping.valid());
|
|
83
83
|
mappings.forEach(function (mapping, idx) {
|
|
84
84
|
const view = this._db.rollupView([mapping.column()]);
|
|
@@ -89,7 +89,8 @@ export class Sankey extends SVGWidget {
|
|
|
89
89
|
__id: id,
|
|
90
90
|
__category: mapping.column(),
|
|
91
91
|
name: row.key,
|
|
92
|
-
origRow: row.
|
|
92
|
+
origRow: row.value,
|
|
93
|
+
value: row.value[idx][valueIdx]
|
|
93
94
|
});
|
|
94
95
|
vertexIndex[id] = retVal.vertices.length - 1;
|
|
95
96
|
}
|
|
@@ -107,7 +108,7 @@ export class Sankey extends SVGWidget {
|
|
|
107
108
|
__id: sourceID + "_" + targetID,
|
|
108
109
|
source: vertexIndex[sourceID],
|
|
109
110
|
target: vertexIndex[targetID],
|
|
110
|
-
value:
|
|
111
|
+
value: value.value[0][valueIdx]
|
|
111
112
|
});
|
|
112
113
|
});
|
|
113
114
|
});
|
|
@@ -116,7 +117,6 @@ export class Sankey extends SVGWidget {
|
|
|
116
117
|
|
|
117
118
|
return retVal;
|
|
118
119
|
}
|
|
119
|
-
|
|
120
120
|
enter(domNode, element) {
|
|
121
121
|
super.enter(domNode, element);
|
|
122
122
|
|
|
@@ -129,14 +129,22 @@ export class Sankey extends SVGWidget {
|
|
|
129
129
|
|
|
130
130
|
this._palette = this._palette.switch(this.paletteID());
|
|
131
131
|
|
|
132
|
+
const strokeWidth = this.vertexStrokeWidth();
|
|
133
|
+
|
|
132
134
|
const sankeyData = this.sankeyData();
|
|
135
|
+
const sw2 = strokeWidth * 2;
|
|
133
136
|
this._d3Sankey
|
|
134
|
-
.extent([
|
|
137
|
+
.extent([
|
|
138
|
+
[strokeWidth, strokeWidth],
|
|
139
|
+
[this.width() - sw2, this.height() - sw2]
|
|
140
|
+
])
|
|
135
141
|
.nodeWidth(this.vertexWidth())
|
|
136
142
|
.nodePadding(this.vertexPadding())
|
|
137
143
|
;
|
|
138
|
-
|
|
139
|
-
|
|
144
|
+
this._d3Sankey({
|
|
145
|
+
nodes: sankeyData.vertices,
|
|
146
|
+
links: sankeyData.edges
|
|
147
|
+
});
|
|
140
148
|
const context = this;
|
|
141
149
|
|
|
142
150
|
// Links ---
|
|
@@ -150,15 +158,16 @@ export class Sankey extends SVGWidget {
|
|
|
150
158
|
})
|
|
151
159
|
.merge(link)
|
|
152
160
|
.attr("d", d3SankeyLinkHorizontal())
|
|
153
|
-
.style("stroke-width", function (d) {
|
|
154
|
-
|
|
161
|
+
.style("stroke-width", function (d) {
|
|
162
|
+
return Math.max(1, d.width);
|
|
163
|
+
})
|
|
164
|
+
.sort(function (a, b) { return b.width - a.width; })
|
|
155
165
|
.select("title")
|
|
156
166
|
.text(function (d) {
|
|
157
167
|
return d.source.name + " → " + d.target.name + "\n" + d.value;
|
|
158
168
|
})
|
|
159
169
|
;
|
|
160
170
|
link.exit().remove();
|
|
161
|
-
|
|
162
171
|
// Nodes ---
|
|
163
172
|
const node = element.selectAll(".node").data(sankeyData.vertices);
|
|
164
173
|
node.enter().append("g")
|
|
@@ -186,24 +195,32 @@ export class Sankey extends SVGWidget {
|
|
|
186
195
|
*/
|
|
187
196
|
.merge(node)
|
|
188
197
|
.attr("transform", function (d) {
|
|
189
|
-
|
|
198
|
+
let _x = 0;
|
|
199
|
+
let _y = 0;
|
|
200
|
+
if(d.x0)_x=d.x0;
|
|
201
|
+
if(d.y0)_y=d.y0;
|
|
202
|
+
return "translate(" + (_x+strokeWidth) + "," + (_y+strokeWidth) + ")";
|
|
190
203
|
})
|
|
191
204
|
.each(function () {
|
|
192
205
|
const n = d3Select(this);
|
|
193
206
|
n.select("rect")
|
|
194
|
-
.attr("height", function (d: any) { return d.
|
|
207
|
+
.attr("height", function (d: any) { return d.y1 - d.y0; })
|
|
195
208
|
.attr("width", context._d3Sankey.nodeWidth())
|
|
196
209
|
.style("fill", function (d: any) { return context._palette(d.name); })
|
|
210
|
+
.style("stroke", function (d: any) { return context.vertexStrokeColor(); })
|
|
211
|
+
.style("stroke-width", function (d: any) { return strokeWidth; })
|
|
197
212
|
.style("cursor", (context.xAxisMovement() || context.yAxisMovement()) ? null : "default")
|
|
198
213
|
;
|
|
199
214
|
n.select("text")
|
|
200
215
|
.attr("x", -6)
|
|
201
|
-
.attr("y", function (d: any) {
|
|
216
|
+
.attr("y", function (d: any) {
|
|
217
|
+
return (d.y1 - d.y0)/2;
|
|
218
|
+
})
|
|
202
219
|
.attr("dy", ".35em")
|
|
203
220
|
.attr("text-anchor", "end")
|
|
204
221
|
.attr("transform", null)
|
|
205
222
|
.text(function (d: any) { return d.name; })
|
|
206
|
-
.filter(function (d: any) { return d.
|
|
223
|
+
.filter(function (d: any) { return d.x0 < context.width() / 2; })
|
|
207
224
|
.attr("x", 6 + context._d3Sankey.nodeWidth())
|
|
208
225
|
.attr("text-anchor", "start")
|
|
209
226
|
;
|
|
@@ -240,6 +257,8 @@ export class Sankey extends SVGWidget {
|
|
|
240
257
|
|
|
241
258
|
paletteID: { (): string; (_: string): Sankey; };
|
|
242
259
|
mappings: { (): SankeyColumn[]; (_: SankeyColumn[]): Sankey; };
|
|
260
|
+
vertexStrokeWidth: { (): number; (_: number): Sankey; };
|
|
261
|
+
vertexStrokeColor: { (): string; (_: string): Sankey; };
|
|
243
262
|
vertexWidth: { (): number; (_: number): Sankey; };
|
|
244
263
|
vertexPadding: { (): number; (_: number): Sankey; };
|
|
245
264
|
xAxisMovement: { (): boolean; (_: boolean): Sankey; };
|
|
@@ -266,6 +285,8 @@ Sankey.prototype._palette = Palette.ordinal("default");
|
|
|
266
285
|
|
|
267
286
|
Sankey.prototype.publish("paletteID", "default", "set", "Color palette for this widget", Sankey.prototype._palette.switch());
|
|
268
287
|
Sankey.prototype.publish("mappings", [], "propertyArray", "Source Columns", null, { autoExpand: SankeyColumn });
|
|
288
|
+
Sankey.prototype.publish("vertexStrokeWidth", 1, "number", "Vertex Stroke Width");
|
|
289
|
+
Sankey.prototype.publish("vertexStrokeColor", "darkgray", "string", "Vertex Stroke Color");
|
|
269
290
|
Sankey.prototype.publish("vertexWidth", 36, "number", "Vertex Width");
|
|
270
291
|
Sankey.prototype.publish("vertexPadding", 40, "number", "Vertex Padding");
|
|
271
292
|
Sankey.prototype.publish("xAxisMovement", false, "boolean", "Enable x-axis movement");
|
package/src/__package__.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export const PKG_NAME = "@hpcc-js/graph";
|
|
2
|
-
export const PKG_VERSION = "2.
|
|
3
|
-
export const BUILD_VERSION = "2.
|
|
2
|
+
export const PKG_VERSION = "2.75.0";
|
|
3
|
+
export const BUILD_VERSION = "2.97.0";
|
package/src/graph2/dataGraph.ts
CHANGED
|
@@ -76,8 +76,10 @@ export class DataGraph extends Graph2 {
|
|
|
76
76
|
edgeSourceColumn: publish<this, string>;
|
|
77
77
|
@publish("", "set", "Edge target ID column", function (this: DataGraph) { return this.edgeColumns(); }, { optional: true })
|
|
78
78
|
edgeTargetColumn: publish<this, string>;
|
|
79
|
-
@publish("", "set", "Edge
|
|
79
|
+
@publish("", "set", "Edge weight column", function (this: DataGraph) { return this.edgeColumns(); }, { optional: true })
|
|
80
80
|
edgeWeightColumn: publish<this, string>;
|
|
81
|
+
@publish("", "set", "Edge color column", function (this: DataGraph) { return this.edgeColumns(); }, { optional: true })
|
|
82
|
+
edgeColorColumn: publish<this, string>;
|
|
81
83
|
|
|
82
84
|
@publish([], "any", "Subgraph Columns")
|
|
83
85
|
hierarchyColumns: publish<this, string[]>;
|
|
@@ -124,26 +126,31 @@ export class DataGraph extends Graph2 {
|
|
|
124
126
|
return retVal >= 0 ? retVal : columns.indexOf(defColumn);
|
|
125
127
|
}
|
|
126
128
|
|
|
127
|
-
private _prevSubgraphs:
|
|
129
|
+
private _prevSubgraphs: readonly ISubgraph[] = [];
|
|
128
130
|
private _masterSubgraphs: ISubgraph[] = [];
|
|
129
131
|
private _masterSubgraphsMap: { [key: string]: ISubgraph } = {};
|
|
130
132
|
mergeSubgraphs() {
|
|
131
133
|
const columns = this.subgraphColumns();
|
|
132
134
|
const idIdx = this.indexOf(columns, this.subgraphIDColumn(), "id");
|
|
133
135
|
const labelIdx = this.indexOf(columns, this.subgraphLabelColumn(), "label");
|
|
134
|
-
const subgraphs = this.subgraphs()
|
|
135
|
-
|
|
136
|
+
const subgraphs = this.subgraphs().map((sg): ISubgraph => {
|
|
137
|
+
return {
|
|
138
|
+
id: "" + sg[idIdx],
|
|
139
|
+
text: "" + sg[labelIdx],
|
|
140
|
+
origData: toJsonObj(sg, columns)
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
const diff = compare2(this._prevSubgraphs, subgraphs, d => d.id);
|
|
136
144
|
diff.exit.forEach(item => {
|
|
137
|
-
this._masterSubgraphs = this._masterSubgraphs.filter(i => i.id !== item
|
|
145
|
+
this._masterSubgraphs = this._masterSubgraphs.filter(i => i.id !== item.id);
|
|
146
|
+
delete this._masterSubgraphsMap[item.id];
|
|
138
147
|
});
|
|
139
148
|
diff.enter.forEach(item => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
this._masterSubgraphs.push(sg);
|
|
146
|
-
this._masterSubgraphsMap[sg.id] = sg;
|
|
149
|
+
this._masterSubgraphs.push(item);
|
|
150
|
+
this._masterSubgraphsMap[item.id] = item;
|
|
151
|
+
});
|
|
152
|
+
diff.update.forEach(item => {
|
|
153
|
+
this._masterSubgraphsMap[item.id].origData = item.origData;
|
|
147
154
|
});
|
|
148
155
|
this._prevSubgraphs = subgraphs;
|
|
149
156
|
}
|
|
@@ -178,16 +185,21 @@ export class DataGraph extends Graph2 {
|
|
|
178
185
|
const diff = compare2(this._prevVertices, vertices, d => d.id);
|
|
179
186
|
diff.exit.forEach(item => {
|
|
180
187
|
this._masterVertices = this._masterVertices.filter(i => i.id !== item.id);
|
|
188
|
+
delete this._masterVerticesMap[item.id];
|
|
181
189
|
});
|
|
182
190
|
diff.enter.forEach(item => {
|
|
183
191
|
this._masterVertices.push(item);
|
|
184
192
|
this._masterVerticesMap[item.id] = item;
|
|
185
193
|
});
|
|
194
|
+
diff.update.forEach(item => {
|
|
195
|
+
this._masterVerticesMap[item.id].origData = item.origData;
|
|
196
|
+
});
|
|
186
197
|
this._prevVertices = vertices;
|
|
187
198
|
}
|
|
188
199
|
|
|
189
200
|
protected _prevEdges: readonly IEdge[] = [];
|
|
190
201
|
protected _masterEdges: IEdge[] = [];
|
|
202
|
+
private _masterEdgesMap: { [key: string]: IEdge } = {};
|
|
191
203
|
mergeEdges() {
|
|
192
204
|
const columns = this.edgeColumns();
|
|
193
205
|
const idIdx = this.indexOf(columns, this.edgeIDColumn(), "id");
|
|
@@ -195,6 +207,7 @@ export class DataGraph extends Graph2 {
|
|
|
195
207
|
const targetIdx = this.indexOf(columns, this.edgeTargetColumn(), "target");
|
|
196
208
|
const labelIdx = this.indexOf(columns, this.edgeLabelColumn(), "label");
|
|
197
209
|
const weightIdx = this.indexOf(columns, this.edgeWeightColumn(), "weight");
|
|
210
|
+
const colorIdx = this.indexOf(columns, this.edgeColorColumn(), "color");
|
|
198
211
|
const edges: IEdge[] = this.edges().map(e => {
|
|
199
212
|
const source = this._masterVerticesMap["" + e[sourceIdx]];
|
|
200
213
|
if (!source) console.error(`Invalid edge source entity "${e[sourceIdx]}" does not exist.`);
|
|
@@ -206,6 +219,7 @@ export class DataGraph extends Graph2 {
|
|
|
206
219
|
source,
|
|
207
220
|
target,
|
|
208
221
|
weight: +e[weightIdx] || 1,
|
|
222
|
+
color: e[colorIdx] as string,
|
|
209
223
|
label: labelIdx >= 0 ? ("" + e[labelIdx]) : "",
|
|
210
224
|
origData: toJsonObj(e, columns)
|
|
211
225
|
};
|
|
@@ -213,9 +227,15 @@ export class DataGraph extends Graph2 {
|
|
|
213
227
|
const diff = compare2(this._masterEdges, edges, d => d.id);
|
|
214
228
|
diff.exit.forEach(item => {
|
|
215
229
|
this._masterEdges = this._masterEdges.filter(i => i.id !== item.id);
|
|
230
|
+
delete this._masterEdgesMap[item.id];
|
|
216
231
|
});
|
|
217
232
|
diff.enter.forEach(item => {
|
|
218
233
|
this._masterEdges.push(item);
|
|
234
|
+
this._masterEdgesMap[item.id] = item;
|
|
235
|
+
|
|
236
|
+
});
|
|
237
|
+
diff.update.forEach(item => {
|
|
238
|
+
this._masterEdgesMap[item.id].origData = item.origData;
|
|
219
239
|
});
|
|
220
240
|
this._prevEdges = edges;
|
|
221
241
|
}
|
|
@@ -237,6 +257,7 @@ export class DataGraph extends Graph2 {
|
|
|
237
257
|
const diff = compare2(this._prevHierarchy, hierarchy, d => d.id);
|
|
238
258
|
diff.exit.forEach(item => {
|
|
239
259
|
this._masterHierarchy = this._masterHierarchy.filter(i => i.id !== item.id);
|
|
260
|
+
delete this._masterHierarchyMap[item.id];
|
|
240
261
|
});
|
|
241
262
|
diff.enter.forEach(item => {
|
|
242
263
|
this._masterHierarchy.push(item);
|
package/src/graph2/graph.ts
CHANGED
|
@@ -281,7 +281,9 @@ export class Graph2 extends SVGZoomWidget {
|
|
|
281
281
|
const vp = this._graphData.item(item.id);
|
|
282
282
|
return {
|
|
283
283
|
_id: vp.id,
|
|
284
|
-
element: () =>
|
|
284
|
+
element: () => {
|
|
285
|
+
return vp.element;
|
|
286
|
+
}
|
|
285
287
|
};
|
|
286
288
|
}));
|
|
287
289
|
return this;
|
|
@@ -701,7 +703,9 @@ export class Graph2 extends SVGZoomWidget {
|
|
|
701
703
|
})
|
|
702
704
|
.remove()
|
|
703
705
|
)
|
|
704
|
-
.style("stroke",
|
|
706
|
+
.style("stroke", d => {
|
|
707
|
+
return d.props?.color ?? this.edgeColor();
|
|
708
|
+
})
|
|
705
709
|
.style("stroke-width", this.edgeStrokeWidth() + "px")
|
|
706
710
|
;
|
|
707
711
|
return this;
|