@hpcc-js/graph 2.69.0 → 2.73.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 +424 -26
- package/dist/index.es6.js.map +1 -1
- package/dist/index.js +425 -25
- 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 +9 -8
- package/src/Sankey.ts +35 -14
- package/src/__package__.ts +2 -2
- package/src/graph2/dataGraph.ts +34 -13
- package/src/graph2/graph.ts +38 -30
- package/src/graph2/index.ts +1 -0
- package/src/graph2/layouts/graphviz.ts +33 -1
- package/src/graph2/layouts/placeholders.ts +1 -0
- package/src/graph2/sankeyGraph.css +45 -0
- package/src/graph2/sankeyGraph.ts +322 -0
- 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 +3 -0
- package/types/graph2/dataGraph.d.ts.map +1 -1
- package/types/graph2/graph.d.ts +3 -1
- package/types/graph2/graph.d.ts.map +1 -1
- package/types/graph2/index.d.ts +1 -0
- package/types/graph2/index.d.ts.map +1 -1
- package/types/graph2/layouts/graphviz.d.ts +6 -1
- package/types/graph2/layouts/graphviz.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 +73 -0
- package/types/graph2/sankeyGraph.d.ts.map +1 -0
- 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 +3 -0
- package/types-3.4/graph2/graph.d.ts +3 -1
- package/types-3.4/graph2/index.d.ts +1 -0
- package/types-3.4/graph2/layouts/graphviz.d.ts +6 -1
- package/types-3.4/graph2/layouts/placeholders.d.ts +1 -0
- package/types-3.4/graph2/sankeyGraph.d.ts +73 -0
- package/types-3.4/test.d.ts +6 -1
package/dist/index.es6.js
CHANGED
|
@@ -5,8 +5,8 @@ import { render, Subgraph as Subgraph$1, Icons, Vertex as Vertex$1, Vertex3, Cen
|
|
|
5
5
|
import { HTMLTooltip } from '@hpcc-js/html';
|
|
6
6
|
|
|
7
7
|
var PKG_NAME = "@hpcc-js/graph";
|
|
8
|
-
var PKG_VERSION = "2.
|
|
9
|
-
var BUILD_VERSION = "2.
|
|
8
|
+
var PKG_VERSION = "2.73.0";
|
|
9
|
+
var BUILD_VERSION = "2.94.0";
|
|
10
10
|
|
|
11
11
|
/*! *****************************************************************************
|
|
12
12
|
Copyright (c) Microsoft Corporation.
|
|
@@ -14462,6 +14462,7 @@ var Sankey$1 = /** @class */ (function (_super) {
|
|
|
14462
14462
|
if (this.data().length === 0)
|
|
14463
14463
|
return retVal;
|
|
14464
14464
|
var vertexIndex = {};
|
|
14465
|
+
var valueIdx = 2;
|
|
14465
14466
|
var mappings = this.mappings().filter(function (mapping) { return mapping.valid(); });
|
|
14466
14467
|
mappings.forEach(function (mapping, idx) {
|
|
14467
14468
|
var view = this._db.rollupView([mapping.column()]);
|
|
@@ -14472,7 +14473,8 @@ var Sankey$1 = /** @class */ (function (_super) {
|
|
|
14472
14473
|
__id: id,
|
|
14473
14474
|
__category: mapping.column(),
|
|
14474
14475
|
name: row.key,
|
|
14475
|
-
origRow: row.
|
|
14476
|
+
origRow: row.value,
|
|
14477
|
+
value: row.value[idx][valueIdx]
|
|
14476
14478
|
});
|
|
14477
14479
|
vertexIndex[id] = retVal.vertices.length - 1;
|
|
14478
14480
|
}
|
|
@@ -14490,7 +14492,7 @@ var Sankey$1 = /** @class */ (function (_super) {
|
|
|
14490
14492
|
__id: sourceID + "_" + targetID,
|
|
14491
14493
|
source: vertexIndex[sourceID],
|
|
14492
14494
|
target: vertexIndex[targetID],
|
|
14493
|
-
value:
|
|
14495
|
+
value: value.value[0][valueIdx]
|
|
14494
14496
|
});
|
|
14495
14497
|
});
|
|
14496
14498
|
});
|
|
@@ -14506,12 +14508,20 @@ var Sankey$1 = /** @class */ (function (_super) {
|
|
|
14506
14508
|
Sankey$1.prototype.update = function (domNode, element) {
|
|
14507
14509
|
_super.prototype.update.call(this, domNode, element);
|
|
14508
14510
|
this._palette = this._palette.switch(this.paletteID());
|
|
14511
|
+
var strokeWidth = this.vertexStrokeWidth();
|
|
14509
14512
|
var sankeyData = this.sankeyData();
|
|
14513
|
+
var sw2 = strokeWidth * 2;
|
|
14510
14514
|
this._d3Sankey
|
|
14511
|
-
.extent([
|
|
14515
|
+
.extent([
|
|
14516
|
+
[strokeWidth, strokeWidth],
|
|
14517
|
+
[this.width() - sw2, this.height() - sw2]
|
|
14518
|
+
])
|
|
14512
14519
|
.nodeWidth(this.vertexWidth())
|
|
14513
14520
|
.nodePadding(this.vertexPadding());
|
|
14514
|
-
this._d3Sankey({
|
|
14521
|
+
this._d3Sankey({
|
|
14522
|
+
nodes: sankeyData.vertices,
|
|
14523
|
+
links: sankeyData.edges
|
|
14524
|
+
});
|
|
14515
14525
|
var context = this;
|
|
14516
14526
|
// Links ---
|
|
14517
14527
|
var link = element.selectAll(".link").data(sankeyData.edges);
|
|
@@ -14523,8 +14533,10 @@ var Sankey$1 = /** @class */ (function (_super) {
|
|
|
14523
14533
|
})
|
|
14524
14534
|
.merge(link)
|
|
14525
14535
|
.attr("d", d3SankeyLinkHorizontal())
|
|
14526
|
-
.style("stroke-width", function (d) {
|
|
14527
|
-
.
|
|
14536
|
+
.style("stroke-width", function (d) {
|
|
14537
|
+
return Math.max(1, d.width);
|
|
14538
|
+
})
|
|
14539
|
+
.sort(function (a, b) { return b.width - a.width; })
|
|
14528
14540
|
.select("title")
|
|
14529
14541
|
.text(function (d) {
|
|
14530
14542
|
return d.source.name + " → " + d.target.name + "\n" + d.value;
|
|
@@ -14557,23 +14569,33 @@ var Sankey$1 = /** @class */ (function (_super) {
|
|
|
14557
14569
|
*/
|
|
14558
14570
|
.merge(node)
|
|
14559
14571
|
.attr("transform", function (d) {
|
|
14560
|
-
|
|
14572
|
+
var _x = 0;
|
|
14573
|
+
var _y = 0;
|
|
14574
|
+
if (d.x0)
|
|
14575
|
+
_x = d.x0;
|
|
14576
|
+
if (d.y0)
|
|
14577
|
+
_y = d.y0;
|
|
14578
|
+
return "translate(" + (_x + strokeWidth) + "," + (_y + strokeWidth) + ")";
|
|
14561
14579
|
})
|
|
14562
14580
|
.each(function () {
|
|
14563
14581
|
var n = select(this);
|
|
14564
14582
|
n.select("rect")
|
|
14565
|
-
.attr("height", function (d) { return d.
|
|
14583
|
+
.attr("height", function (d) { return d.y1 - d.y0; })
|
|
14566
14584
|
.attr("width", context._d3Sankey.nodeWidth())
|
|
14567
14585
|
.style("fill", function (d) { return context._palette(d.name); })
|
|
14586
|
+
.style("stroke", function (d) { return context.vertexStrokeColor(); })
|
|
14587
|
+
.style("stroke-width", function (d) { return strokeWidth; })
|
|
14568
14588
|
.style("cursor", (context.xAxisMovement() || context.yAxisMovement()) ? null : "default");
|
|
14569
14589
|
n.select("text")
|
|
14570
14590
|
.attr("x", -6)
|
|
14571
|
-
.attr("y", function (d) {
|
|
14591
|
+
.attr("y", function (d) {
|
|
14592
|
+
return (d.y1 - d.y0) / 2;
|
|
14593
|
+
})
|
|
14572
14594
|
.attr("dy", ".35em")
|
|
14573
14595
|
.attr("text-anchor", "end")
|
|
14574
14596
|
.attr("transform", null)
|
|
14575
14597
|
.text(function (d) { return d.name; })
|
|
14576
|
-
.filter(function (d) { return d.
|
|
14598
|
+
.filter(function (d) { return d.x0 < context.width() / 2; })
|
|
14577
14599
|
.attr("x", 6 + context._d3Sankey.nodeWidth())
|
|
14578
14600
|
.attr("text-anchor", "start");
|
|
14579
14601
|
});
|
|
@@ -14623,6 +14645,8 @@ Sankey$1.prototype.mixin(Utility.SimpleSelectionMixin);
|
|
|
14623
14645
|
Sankey$1.prototype._palette = Palette.ordinal("default");
|
|
14624
14646
|
Sankey$1.prototype.publish("paletteID", "default", "set", "Color palette for this widget", Sankey$1.prototype._palette.switch());
|
|
14625
14647
|
Sankey$1.prototype.publish("mappings", [], "propertyArray", "Source Columns", null, { autoExpand: SankeyColumn });
|
|
14648
|
+
Sankey$1.prototype.publish("vertexStrokeWidth", 1, "number", "Vertex Stroke Width");
|
|
14649
|
+
Sankey$1.prototype.publish("vertexStrokeColor", "darkgray", "string", "Vertex Stroke Color");
|
|
14626
14650
|
Sankey$1.prototype.publish("vertexWidth", 36, "number", "Vertex Width");
|
|
14627
14651
|
Sankey$1.prototype.publish("vertexPadding", 40, "number", "Vertex Padding");
|
|
14628
14652
|
Sankey$1.prototype.publish("xAxisMovement", false, "boolean", "Enable x-axis movement");
|
|
@@ -14966,6 +14990,10 @@ function graphviz(data, options) {
|
|
|
14966
14990
|
};
|
|
14967
14991
|
}
|
|
14968
14992
|
|
|
14993
|
+
var lineBasis$2 = d3Line()
|
|
14994
|
+
.x(function (d) { return d[0]; })
|
|
14995
|
+
.y(function (d) { return d[1]; })
|
|
14996
|
+
.curve(d3CurveBasis);
|
|
14969
14997
|
var Graphviz = /** @class */ (function (_super) {
|
|
14970
14998
|
__extends(Graphviz, _super);
|
|
14971
14999
|
function Graphviz(graph, engine, wasmFolder) {
|
|
@@ -15042,6 +15070,28 @@ var Graphviz = /** @class */ (function (_super) {
|
|
|
15042
15070
|
return _this;
|
|
15043
15071
|
});
|
|
15044
15072
|
};
|
|
15073
|
+
Graphviz.prototype.edgePath = function (ep, curveDepth) {
|
|
15074
|
+
var _this = this;
|
|
15075
|
+
var points = [];
|
|
15076
|
+
var hasNaN = false;
|
|
15077
|
+
if (ep.points) {
|
|
15078
|
+
points = ep.points.map(function (p) {
|
|
15079
|
+
var x = _this._graph.project(p[0], false);
|
|
15080
|
+
var y = _this._graph.project(p[1], false);
|
|
15081
|
+
if (isNaN(x) || isNaN(y)) {
|
|
15082
|
+
hasNaN = true;
|
|
15083
|
+
}
|
|
15084
|
+
return [x, y];
|
|
15085
|
+
});
|
|
15086
|
+
}
|
|
15087
|
+
if (hasNaN || points.length < 2) {
|
|
15088
|
+
return _super.prototype.edgePath.call(this, ep, curveDepth);
|
|
15089
|
+
}
|
|
15090
|
+
return {
|
|
15091
|
+
path: lineBasis$2(points),
|
|
15092
|
+
labelPos: this.center(points)
|
|
15093
|
+
};
|
|
15094
|
+
};
|
|
15045
15095
|
return Graphviz;
|
|
15046
15096
|
}(Layout));
|
|
15047
15097
|
|
|
@@ -16174,6 +16224,7 @@ var Graph2 = /** @class */ (function (_super) {
|
|
|
16174
16224
|
};
|
|
16175
16225
|
Graph2.prototype.resetLayout = function () {
|
|
16176
16226
|
delete this._prevLayout;
|
|
16227
|
+
return this;
|
|
16177
16228
|
};
|
|
16178
16229
|
Graph2.prototype.layoutRunning = function () {
|
|
16179
16230
|
return this._layoutAlgo && this._layoutAlgo.running();
|
|
@@ -16487,6 +16538,7 @@ var Graph2 = /** @class */ (function (_super) {
|
|
|
16487
16538
|
}, this._svgDefsAnn.node());
|
|
16488
16539
|
};
|
|
16489
16540
|
Graph2.prototype.updateEdges = function () {
|
|
16541
|
+
var _this = this;
|
|
16490
16542
|
var context = this;
|
|
16491
16543
|
this._edgeG.selectAll(".graphEdge")
|
|
16492
16544
|
.data(this._graphData.allEdges(), function (d) { return d.id; })
|
|
@@ -16522,7 +16574,10 @@ var Graph2 = /** @class */ (function (_super) {
|
|
|
16522
16574
|
delete d.element;
|
|
16523
16575
|
})
|
|
16524
16576
|
.remove(); })
|
|
16525
|
-
.style("stroke",
|
|
16577
|
+
.style("stroke", function (d) {
|
|
16578
|
+
var _a, _b;
|
|
16579
|
+
return (_b = (_a = d.props) === null || _a === void 0 ? void 0 : _a.color) !== null && _b !== void 0 ? _b : _this.edgeColor();
|
|
16580
|
+
})
|
|
16526
16581
|
.style("stroke-width", this.edgeStrokeWidth() + "px");
|
|
16527
16582
|
return this;
|
|
16528
16583
|
};
|
|
@@ -16724,7 +16779,7 @@ var Graph2 = /** @class */ (function (_super) {
|
|
|
16724
16779
|
};
|
|
16725
16780
|
case "Tree":
|
|
16726
16781
|
case "Dendrogram":
|
|
16727
|
-
return { rankdir:
|
|
16782
|
+
return { rankdir: this.treeRankDirection() };
|
|
16728
16783
|
case "DOT":
|
|
16729
16784
|
case "Neato":
|
|
16730
16785
|
case "FDP":
|
|
@@ -16965,6 +17020,7 @@ Graph2.prototype.publish("forceDirectedPinCentroid", false, "boolean", "Pin cent
|
|
|
16965
17020
|
Graph2.prototype.publish("forceDirectedForceStrength", 0, "number", "Strength of center force", null, { disable: function (w) { return w.layout().indexOf("ForceDirected") !== 0; } });
|
|
16966
17021
|
Graph2.prototype.publish("forceDirectedMinDistance", 1, "number", "Min distance between nodes", null, { disable: function (w) { return w.layout().indexOf("ForceDirected") !== 0; } });
|
|
16967
17022
|
Graph2.prototype.publish("forceDirectedMaxDistance", Infinity, "number", "Max distance between nodes", null, { disable: function (w) { return w.layout().indexOf("ForceDirected") !== 0; } });
|
|
17023
|
+
Graph2.prototype.publish("treeRankDirection", "LR", "set", "Direction for Rank Nodes", ["TB", "LR"], { disable: function (w) { return w.layout() !== "Tree" && w.layout() !== "Dendrogram"; } });
|
|
16968
17024
|
Graph2.prototype.publish("wasmFolder", null, "string", "WASM Folder", null, { optional: true, disable: function (w) { return ["DOT", "Neato", "FDP", "TwoPI", "Circo"].indexOf(w.layout()) < 0; } });
|
|
16969
17025
|
var _origScale$1 = Graph2.prototype.scale;
|
|
16970
17026
|
Graph2.prototype.scale = function (_, transitionDuration) {
|
|
@@ -17029,6 +17085,7 @@ var DataGraph = /** @class */ (function (_super) {
|
|
|
17029
17085
|
_this._masterVerticesMap = {};
|
|
17030
17086
|
_this._prevEdges = [];
|
|
17031
17087
|
_this._masterEdges = [];
|
|
17088
|
+
_this._masterEdgesMap = {};
|
|
17032
17089
|
_this._prevHierarchy = [];
|
|
17033
17090
|
_this._masterHierarchy = [];
|
|
17034
17091
|
_this._masterHierarchyMap = {};
|
|
@@ -17065,19 +17122,24 @@ var DataGraph = /** @class */ (function (_super) {
|
|
|
17065
17122
|
var columns = this.subgraphColumns();
|
|
17066
17123
|
var idIdx = this.indexOf(columns, this.subgraphIDColumn(), "id");
|
|
17067
17124
|
var labelIdx = this.indexOf(columns, this.subgraphLabelColumn(), "label");
|
|
17068
|
-
var subgraphs = this.subgraphs()
|
|
17069
|
-
|
|
17125
|
+
var subgraphs = this.subgraphs().map(function (sg) {
|
|
17126
|
+
return {
|
|
17127
|
+
id: "" + sg[idIdx],
|
|
17128
|
+
text: "" + sg[labelIdx],
|
|
17129
|
+
origData: toJsonObj(sg, columns)
|
|
17130
|
+
};
|
|
17131
|
+
});
|
|
17132
|
+
var diff = compare2(this._prevSubgraphs, subgraphs, function (d) { return d.id; });
|
|
17070
17133
|
diff.exit.forEach(function (item) {
|
|
17071
|
-
_this._masterSubgraphs = _this._masterSubgraphs.filter(function (i) { return i.id !== item
|
|
17134
|
+
_this._masterSubgraphs = _this._masterSubgraphs.filter(function (i) { return i.id !== item.id; });
|
|
17135
|
+
delete _this._masterSubgraphsMap[item.id];
|
|
17072
17136
|
});
|
|
17073
17137
|
diff.enter.forEach(function (item) {
|
|
17074
|
-
|
|
17075
|
-
|
|
17076
|
-
|
|
17077
|
-
|
|
17078
|
-
|
|
17079
|
-
_this._masterSubgraphs.push(sg);
|
|
17080
|
-
_this._masterSubgraphsMap[sg.id] = sg;
|
|
17138
|
+
_this._masterSubgraphs.push(item);
|
|
17139
|
+
_this._masterSubgraphsMap[item.id] = item;
|
|
17140
|
+
});
|
|
17141
|
+
diff.update.forEach(function (item) {
|
|
17142
|
+
_this._masterSubgraphsMap[item.id].origData = item.origData;
|
|
17081
17143
|
});
|
|
17082
17144
|
this._prevSubgraphs = subgraphs;
|
|
17083
17145
|
};
|
|
@@ -17109,11 +17171,15 @@ var DataGraph = /** @class */ (function (_super) {
|
|
|
17109
17171
|
var diff = compare2(this._prevVertices, vertices, function (d) { return d.id; });
|
|
17110
17172
|
diff.exit.forEach(function (item) {
|
|
17111
17173
|
_this._masterVertices = _this._masterVertices.filter(function (i) { return i.id !== item.id; });
|
|
17174
|
+
delete _this._masterVerticesMap[item.id];
|
|
17112
17175
|
});
|
|
17113
17176
|
diff.enter.forEach(function (item) {
|
|
17114
17177
|
_this._masterVertices.push(item);
|
|
17115
17178
|
_this._masterVerticesMap[item.id] = item;
|
|
17116
17179
|
});
|
|
17180
|
+
diff.update.forEach(function (item) {
|
|
17181
|
+
_this._masterVerticesMap[item.id].origData = item.origData;
|
|
17182
|
+
});
|
|
17117
17183
|
this._prevVertices = vertices;
|
|
17118
17184
|
};
|
|
17119
17185
|
DataGraph.prototype.mergeEdges = function () {
|
|
@@ -17124,6 +17190,7 @@ var DataGraph = /** @class */ (function (_super) {
|
|
|
17124
17190
|
var targetIdx = this.indexOf(columns, this.edgeTargetColumn(), "target");
|
|
17125
17191
|
var labelIdx = this.indexOf(columns, this.edgeLabelColumn(), "label");
|
|
17126
17192
|
var weightIdx = this.indexOf(columns, this.edgeWeightColumn(), "weight");
|
|
17193
|
+
var colorIdx = this.indexOf(columns, this.edgeColorColumn(), "color");
|
|
17127
17194
|
var edges = this.edges().map(function (e) {
|
|
17128
17195
|
var source = _this._masterVerticesMap["" + e[sourceIdx]];
|
|
17129
17196
|
if (!source)
|
|
@@ -17137,6 +17204,7 @@ var DataGraph = /** @class */ (function (_super) {
|
|
|
17137
17204
|
source: source,
|
|
17138
17205
|
target: target,
|
|
17139
17206
|
weight: +e[weightIdx] || 1,
|
|
17207
|
+
color: e[colorIdx],
|
|
17140
17208
|
label: labelIdx >= 0 ? ("" + e[labelIdx]) : "",
|
|
17141
17209
|
origData: toJsonObj(e, columns)
|
|
17142
17210
|
};
|
|
@@ -17144,9 +17212,14 @@ var DataGraph = /** @class */ (function (_super) {
|
|
|
17144
17212
|
var diff = compare2(this._masterEdges, edges, function (d) { return d.id; });
|
|
17145
17213
|
diff.exit.forEach(function (item) {
|
|
17146
17214
|
_this._masterEdges = _this._masterEdges.filter(function (i) { return i.id !== item.id; });
|
|
17215
|
+
delete _this._masterEdgesMap[item.id];
|
|
17147
17216
|
});
|
|
17148
17217
|
diff.enter.forEach(function (item) {
|
|
17149
17218
|
_this._masterEdges.push(item);
|
|
17219
|
+
_this._masterEdgesMap[item.id] = item;
|
|
17220
|
+
});
|
|
17221
|
+
diff.update.forEach(function (item) {
|
|
17222
|
+
_this._masterEdgesMap[item.id].origData = item.origData;
|
|
17150
17223
|
});
|
|
17151
17224
|
this._prevEdges = edges;
|
|
17152
17225
|
};
|
|
@@ -17165,6 +17238,7 @@ var DataGraph = /** @class */ (function (_super) {
|
|
|
17165
17238
|
var diff = compare2(this._prevHierarchy, hierarchy, function (d) { return d.id; });
|
|
17166
17239
|
diff.exit.forEach(function (item) {
|
|
17167
17240
|
_this._masterHierarchy = _this._masterHierarchy.filter(function (i) { return i.id !== item.id; });
|
|
17241
|
+
delete _this._masterHierarchyMap[item.id];
|
|
17168
17242
|
});
|
|
17169
17243
|
diff.enter.forEach(function (item) {
|
|
17170
17244
|
_this._masterHierarchy.push(item);
|
|
@@ -17269,9 +17343,13 @@ var DataGraph = /** @class */ (function (_super) {
|
|
|
17269
17343
|
__metadata("design:type", Function)
|
|
17270
17344
|
], DataGraph.prototype, "edgeTargetColumn", void 0);
|
|
17271
17345
|
__decorate([
|
|
17272
|
-
publish("", "set", "Edge
|
|
17346
|
+
publish("", "set", "Edge weight column", function () { return this.edgeColumns(); }, { optional: true }),
|
|
17273
17347
|
__metadata("design:type", Function)
|
|
17274
17348
|
], DataGraph.prototype, "edgeWeightColumn", void 0);
|
|
17349
|
+
__decorate([
|
|
17350
|
+
publish("", "set", "Edge color column", function () { return this.edgeColumns(); }, { optional: true }),
|
|
17351
|
+
__metadata("design:type", Function)
|
|
17352
|
+
], DataGraph.prototype, "edgeColorColumn", void 0);
|
|
17275
17353
|
__decorate([
|
|
17276
17354
|
publish([], "any", "Subgraph Columns"),
|
|
17277
17355
|
__metadata("design:type", Function)
|
|
@@ -17292,5 +17370,325 @@ var DataGraph = /** @class */ (function (_super) {
|
|
|
17292
17370
|
}(Graph2));
|
|
17293
17371
|
DataGraph.prototype._class += " graph_DataGraph";
|
|
17294
17372
|
|
|
17295
|
-
|
|
17373
|
+
var css_248z$6 = ".graph_SankeyGraph .node rect{cursor:move;fill-opacity:.9;shape-rendering:crispEdges;stroke:#a9a9a9}.graph_SankeyGraph .node.selected rect{stroke:red}.graph_SankeyGraph .node.over rect{stroke:orange}.graph_SankeyGraph .node.selected.over rect{stroke:red}.graph_SankeyGraph .node text{pointer-events:none;text-shadow:0 1px 0 #fff}.graph_SankeyGraph .node.selected text{fill:red}.graph_SankeyGraph .node.over text{fill:orange}.graph_SankeyGraph .node.selected.over text{fill:red}.graph_SankeyGraph .link{fill:none;stroke:#000;stroke-opacity:.2}.graph_SankeyGraph .link:hover{stroke-opacity:.5}";
|
|
17374
|
+
styleInject(css_248z$6);
|
|
17375
|
+
|
|
17376
|
+
var SankeyGraph = /** @class */ (function (_super) {
|
|
17377
|
+
__extends(SankeyGraph, _super);
|
|
17378
|
+
function SankeyGraph() {
|
|
17379
|
+
var _this = _super.call(this) || this;
|
|
17380
|
+
_this._prevVertices = [];
|
|
17381
|
+
_this._masterVertices = [];
|
|
17382
|
+
_this._masterVerticesMap = {};
|
|
17383
|
+
_this._prevEdges = [];
|
|
17384
|
+
_this._masterEdges = [];
|
|
17385
|
+
Utility.SimpleSelectionMixin.call(_this);
|
|
17386
|
+
_this._drawStartPos = "origin";
|
|
17387
|
+
return _this;
|
|
17388
|
+
}
|
|
17389
|
+
SankeyGraph.prototype.mergeVertices = function () {
|
|
17390
|
+
var _this = this;
|
|
17391
|
+
var columns = this.vertexColumns();
|
|
17392
|
+
var annotationColumns = this.vertexAnnotationColumns();
|
|
17393
|
+
var catIdx = this.indexOf(columns, this.vertexCategoryColumn(), "category");
|
|
17394
|
+
var idIdx = this.indexOf(columns, this.vertexIDColumn(), "id");
|
|
17395
|
+
var labelIdx = this.indexOf(columns, this.vertexLabelColumn(), "label");
|
|
17396
|
+
var centroidIdx = this.indexOf(columns, this.vertexCentroidColumn(), "centroid");
|
|
17397
|
+
var faCharIdx = this.indexOf(columns, this.vertexFACharColumn(), "faChar");
|
|
17398
|
+
var vertexTooltipIdx = this.indexOf(columns, this.vertexTooltipColumn(), "tooltip");
|
|
17399
|
+
var annotationIdxs = annotationColumns.map(function (ac) { return _this.indexOf(columns, ac.columnID(), ""); });
|
|
17400
|
+
var vertices = this.vertices().map(function (v) {
|
|
17401
|
+
return {
|
|
17402
|
+
categoryID: "" + v[catIdx],
|
|
17403
|
+
id: "" + v[idIdx],
|
|
17404
|
+
text: "" + v[labelIdx],
|
|
17405
|
+
tooltip: "" + v[vertexTooltipIdx],
|
|
17406
|
+
origData: toJsonObj(v, columns),
|
|
17407
|
+
centroid: !!v[centroidIdx],
|
|
17408
|
+
icon: {
|
|
17409
|
+
imageChar: "" + (v[faCharIdx] || _this.vertexFAChar())
|
|
17410
|
+
},
|
|
17411
|
+
annotationIDs: annotationIdxs.map(function (ai, i) { return !!v[ai] ? annotationColumns[i].annotationID() : undefined; }).filter(function (a) { return !!a; })
|
|
17412
|
+
};
|
|
17413
|
+
});
|
|
17414
|
+
var diff = compare2(this._prevVertices, vertices, function (d) { return d.id; });
|
|
17415
|
+
diff.exit.forEach(function (item) {
|
|
17416
|
+
_this._masterVertices = _this._masterVertices.filter(function (i) { return i.id !== item.id; });
|
|
17417
|
+
});
|
|
17418
|
+
diff.enter.forEach(function (item) {
|
|
17419
|
+
_this._masterVertices.push(item);
|
|
17420
|
+
_this._masterVerticesMap[item.id] = item;
|
|
17421
|
+
});
|
|
17422
|
+
this._prevVertices = vertices;
|
|
17423
|
+
};
|
|
17424
|
+
SankeyGraph.prototype.indexOf = function (columns, column, defColumn) {
|
|
17425
|
+
if (defColumn === void 0) { defColumn = ""; }
|
|
17426
|
+
var retVal = columns.indexOf(column);
|
|
17427
|
+
return retVal >= 0 ? retVal : columns.indexOf(defColumn);
|
|
17428
|
+
};
|
|
17429
|
+
SankeyGraph.prototype.mergeEdges = function () {
|
|
17430
|
+
var _this = this;
|
|
17431
|
+
var columns = this.edgeColumns();
|
|
17432
|
+
var idIdx = this.indexOf(columns, this.edgeIDColumn(), "id");
|
|
17433
|
+
var sourceIdx = this.indexOf(columns, this.edgeSourceColumn(), "source");
|
|
17434
|
+
var targetIdx = this.indexOf(columns, this.edgeTargetColumn(), "target");
|
|
17435
|
+
var labelIdx = this.indexOf(columns, this.edgeLabelColumn(), "label");
|
|
17436
|
+
var weightIdx = this.indexOf(columns, this.edgeWeightColumn(), "weight");
|
|
17437
|
+
var edges = this.edges().map(function (e) {
|
|
17438
|
+
var source = _this._masterVerticesMap["" + e[sourceIdx]];
|
|
17439
|
+
if (!source)
|
|
17440
|
+
console.error("Invalid edge source entity \"" + e[sourceIdx] + "\" does not exist.");
|
|
17441
|
+
var target = _this._masterVerticesMap["" + e[targetIdx]];
|
|
17442
|
+
if (!target)
|
|
17443
|
+
console.error("Invalid edge target entity \"" + e[targetIdx] + "\" does not exist.");
|
|
17444
|
+
return {
|
|
17445
|
+
type: "edge",
|
|
17446
|
+
id: idIdx >= 0 ? "" + e[idIdx] : "" + e[sourceIdx] + "->" + e[targetIdx],
|
|
17447
|
+
source: source,
|
|
17448
|
+
target: target,
|
|
17449
|
+
value: +e[weightIdx] || 0,
|
|
17450
|
+
label: labelIdx >= 0 ? ("" + e[labelIdx]) : "",
|
|
17451
|
+
origData: toJsonObj(e, columns)
|
|
17452
|
+
};
|
|
17453
|
+
}).filter(function (e) { return e.source && e.target; });
|
|
17454
|
+
var diff = compare2(this._masterEdges, edges, function (d) { return d.id; });
|
|
17455
|
+
diff.exit.forEach(function (item) {
|
|
17456
|
+
_this._masterEdges = _this._masterEdges.filter(function (i) { return i.id !== item.id; });
|
|
17457
|
+
});
|
|
17458
|
+
diff.enter.forEach(function (item) {
|
|
17459
|
+
_this._masterEdges.push(item);
|
|
17460
|
+
});
|
|
17461
|
+
this._prevEdges = edges;
|
|
17462
|
+
};
|
|
17463
|
+
SankeyGraph.prototype.sankeyData = function () {
|
|
17464
|
+
this.mergeVertices();
|
|
17465
|
+
this.mergeEdges();
|
|
17466
|
+
return {
|
|
17467
|
+
vertices: this._masterVertices,
|
|
17468
|
+
edges: this._masterEdges
|
|
17469
|
+
};
|
|
17470
|
+
};
|
|
17471
|
+
SankeyGraph.prototype.enter = function (domNode, element) {
|
|
17472
|
+
_super.prototype.enter.call(this, domNode, element);
|
|
17473
|
+
this._d3Sankey = Sankey();
|
|
17474
|
+
this._selection.widgetElement(element);
|
|
17475
|
+
};
|
|
17476
|
+
SankeyGraph.prototype.update = function (domNode, element) {
|
|
17477
|
+
_super.prototype.update.call(this, domNode, element);
|
|
17478
|
+
this._palette = this._palette.switch(this.paletteID());
|
|
17479
|
+
var strokeWidth = this.vertexStrokeWidth();
|
|
17480
|
+
var sankeyData = this.sankeyData();
|
|
17481
|
+
this._d3Sankey
|
|
17482
|
+
.nodeId(function (d) { return d.id; })
|
|
17483
|
+
.extent([
|
|
17484
|
+
[0, 0],
|
|
17485
|
+
[this.width(), this.height()]
|
|
17486
|
+
]);
|
|
17487
|
+
if (sankeyData.vertices.length > 0) {
|
|
17488
|
+
this._d3Sankey({
|
|
17489
|
+
nodes: sankeyData.vertices,
|
|
17490
|
+
links: sankeyData.edges
|
|
17491
|
+
});
|
|
17492
|
+
}
|
|
17493
|
+
var context = this;
|
|
17494
|
+
// Links ---
|
|
17495
|
+
var link = element.selectAll(".link").data(sankeyData.edges);
|
|
17496
|
+
link.enter().append("path")
|
|
17497
|
+
.attr("class", "link")
|
|
17498
|
+
.each(function () {
|
|
17499
|
+
select(this)
|
|
17500
|
+
.append("title");
|
|
17501
|
+
})
|
|
17502
|
+
.merge(link)
|
|
17503
|
+
.attr("d", d3SankeyLinkHorizontal())
|
|
17504
|
+
.style("stroke-width", function (d) { return Math.max(1, d.width); })
|
|
17505
|
+
// .sort(function (a, b) { return b.width - a.width; })
|
|
17506
|
+
.select("title")
|
|
17507
|
+
.text(function (d) {
|
|
17508
|
+
return d.source.text + " → " + d.target.text + "\n" + d.value;
|
|
17509
|
+
});
|
|
17510
|
+
link.exit().remove();
|
|
17511
|
+
// Nodes ---
|
|
17512
|
+
var node = element.selectAll(".node").data(sankeyData.vertices);
|
|
17513
|
+
node.enter().append("g")
|
|
17514
|
+
.attr("class", "node")
|
|
17515
|
+
.call(this._selection.enter.bind(this._selection))
|
|
17516
|
+
.on("click", function (d) {
|
|
17517
|
+
context.click(d.origData, "", context._selection.selected(this));
|
|
17518
|
+
})
|
|
17519
|
+
.on("dblclick", function (d) {
|
|
17520
|
+
context.dblclick(d.origData, "", context._selection.selected(this));
|
|
17521
|
+
})
|
|
17522
|
+
.each(function () {
|
|
17523
|
+
var gElement = select(this);
|
|
17524
|
+
gElement.append("rect");
|
|
17525
|
+
gElement.append("text");
|
|
17526
|
+
})
|
|
17527
|
+
/*
|
|
17528
|
+
.call(d3.behavior.drag()
|
|
17529
|
+
.origin(function (d) { return d; })
|
|
17530
|
+
.on("dragstart", function () {
|
|
17531
|
+
this.parentNode.appendChild(this);
|
|
17532
|
+
})
|
|
17533
|
+
.on("drag", dragmove)
|
|
17534
|
+
)
|
|
17535
|
+
*/
|
|
17536
|
+
.merge(node)
|
|
17537
|
+
.attr("transform", function (d) {
|
|
17538
|
+
var _x = 0;
|
|
17539
|
+
var _y = 0;
|
|
17540
|
+
if (d.x0)
|
|
17541
|
+
_x = d.x0;
|
|
17542
|
+
if (d.y0)
|
|
17543
|
+
_y = d.y0;
|
|
17544
|
+
return "translate(" + (_x + strokeWidth) + "," + (_y + strokeWidth) + ")";
|
|
17545
|
+
})
|
|
17546
|
+
.each(function () {
|
|
17547
|
+
var n = select(this);
|
|
17548
|
+
n.select("rect")
|
|
17549
|
+
.attr("height", function (d) {
|
|
17550
|
+
return d.y1 - d.y0;
|
|
17551
|
+
})
|
|
17552
|
+
.attr("width", function (d) { return d.x1 - d.x0; })
|
|
17553
|
+
.style("fill", function (d) { return context._palette(d.categoryID); })
|
|
17554
|
+
.style("stroke", function (d) { return context.vertexStrokeColor(); })
|
|
17555
|
+
.style("stroke-width", function (d) { return strokeWidth; })
|
|
17556
|
+
.style("cursor", (context.xAxisMovement() || context.yAxisMovement()) ? null : "default");
|
|
17557
|
+
n.select("text")
|
|
17558
|
+
.attr("x", -6)
|
|
17559
|
+
.attr("y", function (d) {
|
|
17560
|
+
return (d.y1 - d.y0) / 2;
|
|
17561
|
+
})
|
|
17562
|
+
.attr("dy", ".35em")
|
|
17563
|
+
.attr("text-anchor", "end")
|
|
17564
|
+
.attr("transform", null)
|
|
17565
|
+
.text(function (d) {
|
|
17566
|
+
return d.text;
|
|
17567
|
+
})
|
|
17568
|
+
.filter(function (d) {
|
|
17569
|
+
return d.x0 < context.width() / 2;
|
|
17570
|
+
})
|
|
17571
|
+
.attr("x", 6 + context._d3Sankey.nodeWidth())
|
|
17572
|
+
.attr("text-anchor", "start");
|
|
17573
|
+
});
|
|
17574
|
+
node.exit().remove();
|
|
17575
|
+
/*
|
|
17576
|
+
function dragmove(d) {
|
|
17577
|
+
var gElement = d3.select(this);
|
|
17578
|
+
if (context.xAxisMovement()) {
|
|
17579
|
+
d.x = Math.max(0, Math.min(context.width() - d.dx, d3.event.x));
|
|
17580
|
+
}
|
|
17581
|
+
if (context.yAxisMovement()) {
|
|
17582
|
+
d.y = Math.max(0, Math.min(context.height() - d.dy, d3.event.y));
|
|
17583
|
+
}
|
|
17584
|
+
gElement.attr("transform", "translate(" + d.x + "," + d.y + ")");
|
|
17585
|
+
context._d3Sankey.relayout();
|
|
17586
|
+
link.attr("d", context._d3SankeyPath);
|
|
17587
|
+
|
|
17588
|
+
gElement.select("text")
|
|
17589
|
+
.attr("x", -6)
|
|
17590
|
+
.attr("y", function (d) { return d.dy / 2; })
|
|
17591
|
+
.attr("dy", ".35em")
|
|
17592
|
+
.attr("text-anchor", "end")
|
|
17593
|
+
.attr("transform", null)
|
|
17594
|
+
.text(function (d) { return d.name; })
|
|
17595
|
+
.filter(function (d) { return d.x < context.width() / 2; })
|
|
17596
|
+
.attr("x", 6 + context._d3Sankey.nodeWidth())
|
|
17597
|
+
.attr("text-anchor", "start")
|
|
17598
|
+
;
|
|
17599
|
+
}
|
|
17600
|
+
*/
|
|
17601
|
+
};
|
|
17602
|
+
SankeyGraph.prototype.exit = function (domNode, element) {
|
|
17603
|
+
_super.prototype.exit.call(this, domNode, element);
|
|
17604
|
+
};
|
|
17605
|
+
// Events ---
|
|
17606
|
+
SankeyGraph.prototype.click = function (row, column, selected) {
|
|
17607
|
+
console.log("Click: " + JSON.stringify(row) + ", " + column + "," + selected);
|
|
17608
|
+
};
|
|
17609
|
+
SankeyGraph.prototype.dblclick = function (row, column, selected) {
|
|
17610
|
+
console.log("Double Click: " + JSON.stringify(row) + ", " + column + "," + selected);
|
|
17611
|
+
};
|
|
17612
|
+
__decorate([
|
|
17613
|
+
publish([], "any", "Vertex Columns", null, { internal: true }),
|
|
17614
|
+
__metadata("design:type", Function)
|
|
17615
|
+
], SankeyGraph.prototype, "vertexColumns", void 0);
|
|
17616
|
+
__decorate([
|
|
17617
|
+
publish([], "any", "Vertices (Nodes)", null, { internal: true }),
|
|
17618
|
+
__metadata("design:type", Function)
|
|
17619
|
+
], SankeyGraph.prototype, "vertices", void 0);
|
|
17620
|
+
__decorate([
|
|
17621
|
+
publish("", "set", "Vertex Category ID column", function () { return this.vertexColumns(); }, { optional: true }),
|
|
17622
|
+
__metadata("design:type", Function)
|
|
17623
|
+
], SankeyGraph.prototype, "vertexCategoryColumn", void 0);
|
|
17624
|
+
__decorate([
|
|
17625
|
+
publish("", "set", "Vertex ID column", function () { return this.vertexColumns(); }, { optional: true }),
|
|
17626
|
+
__metadata("design:type", Function)
|
|
17627
|
+
], SankeyGraph.prototype, "vertexIDColumn", void 0);
|
|
17628
|
+
__decorate([
|
|
17629
|
+
publish("", "set", "Vertex label column", function () { return this.vertexColumns(); }, { optional: true }),
|
|
17630
|
+
__metadata("design:type", Function)
|
|
17631
|
+
], SankeyGraph.prototype, "vertexLabelColumn", void 0);
|
|
17632
|
+
__decorate([
|
|
17633
|
+
publish("", "set", "Vertex centroid column (boolean)", function () { return this.vertexColumns(); }, { optional: true }),
|
|
17634
|
+
__metadata("design:type", Function)
|
|
17635
|
+
], SankeyGraph.prototype, "vertexCentroidColumn", void 0);
|
|
17636
|
+
__decorate([
|
|
17637
|
+
publish("?", "string", "Vertex default FAChar"),
|
|
17638
|
+
__metadata("design:type", Function)
|
|
17639
|
+
], SankeyGraph.prototype, "vertexFAChar", void 0);
|
|
17640
|
+
__decorate([
|
|
17641
|
+
publish("", "set", "Vertex FAChar column", function () { return this.vertexColumns(); }, { optional: true }),
|
|
17642
|
+
__metadata("design:type", Function)
|
|
17643
|
+
], SankeyGraph.prototype, "vertexFACharColumn", void 0);
|
|
17644
|
+
__decorate([
|
|
17645
|
+
publish("", "set", "Vertex tooltip column", function () { return this.vertexColumns(); }, { optional: true }),
|
|
17646
|
+
__metadata("design:type", Function)
|
|
17647
|
+
], SankeyGraph.prototype, "vertexTooltipColumn", void 0);
|
|
17648
|
+
__decorate([
|
|
17649
|
+
publish([], "propertyArray", "Annotations", null, { autoExpand: AnnotationColumn }),
|
|
17650
|
+
__metadata("design:type", Function)
|
|
17651
|
+
], SankeyGraph.prototype, "vertexAnnotationColumns", void 0);
|
|
17652
|
+
__decorate([
|
|
17653
|
+
publish([], "any", "Edge columns", null, { internal: true }),
|
|
17654
|
+
__metadata("design:type", Function)
|
|
17655
|
+
], SankeyGraph.prototype, "edgeColumns", void 0);
|
|
17656
|
+
__decorate([
|
|
17657
|
+
publish([], "any", "Edges (Edges)", null, { internal: true }),
|
|
17658
|
+
__metadata("design:type", Function)
|
|
17659
|
+
], SankeyGraph.prototype, "edges", void 0);
|
|
17660
|
+
__decorate([
|
|
17661
|
+
publish("", "set", "Edge ID column", function () { return this.edgeColumns(); }, { optional: true }),
|
|
17662
|
+
__metadata("design:type", Function)
|
|
17663
|
+
], SankeyGraph.prototype, "edgeIDColumn", void 0);
|
|
17664
|
+
__decorate([
|
|
17665
|
+
publish("", "set", "Edge label column", function () { return this.edgeColumns(); }, { optional: true }),
|
|
17666
|
+
__metadata("design:type", Function)
|
|
17667
|
+
], SankeyGraph.prototype, "edgeLabelColumn", void 0);
|
|
17668
|
+
__decorate([
|
|
17669
|
+
publish("", "set", "Edge source ID column", function () { return this.edgeColumns(); }, { optional: true }),
|
|
17670
|
+
__metadata("design:type", Function)
|
|
17671
|
+
], SankeyGraph.prototype, "edgeSourceColumn", void 0);
|
|
17672
|
+
__decorate([
|
|
17673
|
+
publish("", "set", "Edge target ID column", function () { return this.edgeColumns(); }, { optional: true }),
|
|
17674
|
+
__metadata("design:type", Function)
|
|
17675
|
+
], SankeyGraph.prototype, "edgeTargetColumn", void 0);
|
|
17676
|
+
__decorate([
|
|
17677
|
+
publish("", "set", "Edge target ID column", function () { return this.edgeColumns(); }, { optional: true }),
|
|
17678
|
+
__metadata("design:type", Function)
|
|
17679
|
+
], SankeyGraph.prototype, "edgeWeightColumn", void 0);
|
|
17680
|
+
return SankeyGraph;
|
|
17681
|
+
}(SVGWidget));
|
|
17682
|
+
SankeyGraph.prototype._class += " graph_SankeyGraph";
|
|
17683
|
+
SankeyGraph.prototype.mixin(Utility.SimpleSelectionMixin);
|
|
17684
|
+
SankeyGraph.prototype._palette = Palette.ordinal("category10");
|
|
17685
|
+
SankeyGraph.prototype.publish("paletteID", "category10", "set", "Color palette for this widget", SankeyGraph.prototype._palette.switch());
|
|
17686
|
+
SankeyGraph.prototype.publish("vertexStrokeWidth", 1, "number", "Vertex Stroke Width");
|
|
17687
|
+
SankeyGraph.prototype.publish("vertexStrokeColor", "darkgray", "string", "Vertex Stroke Color");
|
|
17688
|
+
SankeyGraph.prototype.publish("vertexWidth", 36, "number", "Vertex Width");
|
|
17689
|
+
SankeyGraph.prototype.publish("vertexPadding", 20, "number", "Vertex Padding");
|
|
17690
|
+
SankeyGraph.prototype.publish("xAxisMovement", false, "boolean", "Enable x-axis movement");
|
|
17691
|
+
SankeyGraph.prototype.publish("yAxisMovement", false, "boolean", "Enable y-axis movement");
|
|
17692
|
+
|
|
17693
|
+
export { AdjacencyGraph, Annotation, AnnotationColumn, BUILD_VERSION, DataGraph, Edge, Graph$9 as Graph, Graph2, PKG_NAME, PKG_VERSION, Sankey$1 as Sankey, SankeyColumn, SankeyGraph, Subgraph, Vertex, graphviz$1 as graphviz, toJsonObj };
|
|
17296
17694
|
//# sourceMappingURL=index.es6.js.map
|