mascot-vis 1.12.2 → 2.0.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/README.md +6 -1
- package/dist/mascot-min.js +14 -14
- package/dist/mascot.js +58 -22
- package/package.json +1 -1
package/dist/mascot.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
// version:
|
|
2
|
+
// version: 2.0.0
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3'), require('pixi.js')) :
|
|
5
5
|
typeof define === 'function' && define.amd ? define(['exports', 'd3', 'pixi.js'], factory) :
|
|
@@ -2555,7 +2555,7 @@
|
|
|
2555
2555
|
|
|
2556
2556
|
function repeatNodeLink(scene, node, link, data) {
|
|
2557
2557
|
let nodeDS = data.nodeTable.getFieldSummary(nodeId).unique.map(d => node.dataScope ? node.dataScope.cross(nodeId, d) : new DataScope(data.nodeTable).cross(nodeId, d));
|
|
2558
|
-
let nodeColl = scene.collection(), id2node = {};
|
|
2558
|
+
let linkColl = scene.collection(), nodeColl = scene.collection(), id2node = {};
|
|
2559
2559
|
nodeColl.dataScope = node.dataScope ? node.dataScope.clone() : new DataScope(data.nodeTable);
|
|
2560
2560
|
|
|
2561
2561
|
//do not initialize classId here, initialize in scene.mark/glyph/new Collection()
|
|
@@ -2572,7 +2572,6 @@
|
|
|
2572
2572
|
});
|
|
2573
2573
|
|
|
2574
2574
|
let linkDS = data.linkTable.getFieldSummary(atlas_rowId).unique.map(d => link.dataScope ? link.dataScope.cross(atlas_rowId, d) : new DataScope(data.linkTable).cross(atlas_rowId, d));
|
|
2575
|
-
let linkColl = scene.collection();
|
|
2576
2575
|
linkColl.dataScope = link.dataScope ? link.dataScope.clone() : new DataScope(data.linkTable);
|
|
2577
2576
|
|
|
2578
2577
|
linkColl.addChild(link);
|
|
@@ -2590,8 +2589,6 @@
|
|
|
2590
2589
|
l.target = id2node[tid];
|
|
2591
2590
|
l._updateBounds();
|
|
2592
2591
|
}
|
|
2593
|
-
scene.addChild(linkColl);
|
|
2594
|
-
scene.addChild(nodeColl);
|
|
2595
2592
|
|
|
2596
2593
|
return [nodeColl, linkColl];
|
|
2597
2594
|
}
|
|
@@ -7041,15 +7038,19 @@
|
|
|
7041
7038
|
this._x = ("x" in args) ? args["x"] : 0;
|
|
7042
7039
|
this._y = ("y" in args) ? args["y"] : 0;
|
|
7043
7040
|
this._showTitle = ("showTitle" in args) ? args["showTitle"] : true;
|
|
7041
|
+
this._orientation = ("orientation" in args) ? args["orientation"] : Orientation.Vertical;
|
|
7042
|
+
|
|
7044
7043
|
//for categorical legend
|
|
7045
7044
|
if (!("numCols" in args) && !("numRows" in args)) {
|
|
7046
|
-
this.
|
|
7045
|
+
if (this._orientation === Orientation.Vertical)
|
|
7046
|
+
this._numCols = 1;
|
|
7047
|
+
else
|
|
7048
|
+
this._numRows = 1;
|
|
7047
7049
|
}
|
|
7048
7050
|
else {
|
|
7049
7051
|
this._numCols = args["numCols"];
|
|
7050
7052
|
this._numRows = args["numRows"];
|
|
7051
7053
|
}
|
|
7052
|
-
this._orientation = ("orientation" in args) ? args["orientation"] : Orientation.Vertical;
|
|
7053
7054
|
this._initialize();
|
|
7054
7055
|
}
|
|
7055
7056
|
|
|
@@ -7225,21 +7226,35 @@
|
|
|
7225
7226
|
}
|
|
7226
7227
|
|
|
7227
7228
|
_createCategoricalColorLegend(scene, f) {
|
|
7228
|
-
let titleSize = 0;
|
|
7229
|
-
if (this._showTitle) {
|
|
7230
|
-
this.addChild(new PointText({fillColor: this._textColor, "fontSize": this._fontSize, "text": f, x: this._x, y: this._y, "anchor": ["left", "top"]}));
|
|
7231
|
-
titleSize = parseFloat(this._fontSize) + 5;
|
|
7232
|
-
}
|
|
7233
|
-
let rect = scene.mark("rect", {"top": this._y + 2 + titleSize, "left": this._x, "width": 10, "height": 10, "strokeWidth": 0, opacity: this.encoding.anyItem.opacity});
|
|
7234
|
-
let text = scene.mark("text", {fillColor: this._textColor, "fontSize": this._fontSize, x: this._x + 20, y: this._y + titleSize, "anchor": ["left", "top"]});
|
|
7235
|
-
let glyph = scene.glyph(rect, text);
|
|
7236
7229
|
let scale = this.encoding.scale;
|
|
7237
7230
|
let dt = new DataTable(scale.domain.map(d => ({"category": d, "value": scale.map(d)})));
|
|
7238
|
-
let
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7231
|
+
let longestText = dt.getUniqueFieldValues("category").sort((a,b) => b.length - a.length)[0];
|
|
7232
|
+
if (this._orientation === Orientation.Vertical) {
|
|
7233
|
+
let titleSize = 0;
|
|
7234
|
+
if (this._showTitle) {
|
|
7235
|
+
this.addChild(new PointText({fillColor: this._textColor, "fontSize": this._fontSize, "text": f, x: this._x, y: this._y, "anchor": ["left", "top"]}));
|
|
7236
|
+
titleSize = parseFloat(this._fontSize) + 5;
|
|
7237
|
+
}
|
|
7238
|
+
let rect = scene.mark("rect", {"top": this._y + 2 + titleSize, "left": this._x, "width": 10, "height": 10, "strokeWidth": 0, opacity: this.encoding.anyItem.opacity});
|
|
7239
|
+
let text = scene.mark("text", {text: longestText, fillColor: this._textColor, "fontSize": this._fontSize, x: this._x + 20, y: this._y + titleSize, "anchor": ["left", "top"]});
|
|
7240
|
+
let glyph = scene.glyph(rect, text);
|
|
7241
|
+
let coll = scene.repeat(glyph, dt);
|
|
7242
|
+
scene.encode(text, {"channel": "text", "field": "category", "_remember": false});
|
|
7243
|
+
scene.encode(rect, {"channel": "fillColor", "field": "category", "_remember": false, scale: scale});
|
|
7244
|
+
coll.layout = layout("grid", {"numCols": this._numCols, "numRows": this._numRows});
|
|
7245
|
+
this.addChild(coll);
|
|
7246
|
+
} else {
|
|
7247
|
+
//do not show title for now
|
|
7248
|
+
let rect = scene.mark("rect", {"top": this._y, "left": this._x, "width": 10, "height": 10, "strokeWidth": 0, opacity: this.encoding.anyItem.opacity});
|
|
7249
|
+
let text = scene.mark("text", {text: longestText, fillColor: this._textColor, "fontSize": this._fontSize, x: this._x + 15, y: this._y, "anchor": ["left", "top"]});
|
|
7250
|
+
let glyph = scene.glyph(rect, text);
|
|
7251
|
+
let coll = scene.repeat(glyph, dt);
|
|
7252
|
+
scene.encode(text, {"channel": "text", "field": "category", "_remember": false});
|
|
7253
|
+
scene.encode(rect, {"channel": "fillColor", "field": "category", "_remember": false, scale: scale});
|
|
7254
|
+
coll.layout = layout("grid", {"numCols": this._numCols, "numRows": this._numRows, "colGap": 15});
|
|
7255
|
+
this.addChild(coll);
|
|
7256
|
+
}
|
|
7257
|
+
|
|
7243
7258
|
}
|
|
7244
7259
|
|
|
7245
7260
|
pathHitTest(x, y) {
|
|
@@ -8229,6 +8244,7 @@
|
|
|
8229
8244
|
|
|
8230
8245
|
this.source = undefined;
|
|
8231
8246
|
this.target = undefined;
|
|
8247
|
+
this.directed = "directed" in args ? args.directed : false;
|
|
8232
8248
|
|
|
8233
8249
|
this.sourceAnchor = "sourceAnchor" in args ? args.sourceAnchor : ["center", "middle"];
|
|
8234
8250
|
this.targetAnchor = "targetAnchor" in args ? args.targetAnchor : ["center", "middle"];
|
|
@@ -8263,6 +8279,21 @@
|
|
|
8263
8279
|
return `M ${r0[0]} ${r0[1]} C ${r1[0]} ${r1[1]} ${r2[0]} ${r2[1]} ${r3[0]} ${r3[1]}`
|
|
8264
8280
|
}
|
|
8265
8281
|
|
|
8282
|
+
arc(x1, y1, x2, y2, clockwise) {
|
|
8283
|
+
let sx = x1, ex = x2, sy = y1, ey = y2;
|
|
8284
|
+
if (!this.directed && x1 > x2) {
|
|
8285
|
+
sx = x2;
|
|
8286
|
+
ex = x1;
|
|
8287
|
+
sy = y2;
|
|
8288
|
+
ey = y1;
|
|
8289
|
+
}
|
|
8290
|
+
let rx = Math.abs(sx-ex)/2,
|
|
8291
|
+
ry = Math.abs(sy-ey)/2,
|
|
8292
|
+
r = Math.max(rx, ry),
|
|
8293
|
+
sweep_flag = clockwise ? 1 : 0;
|
|
8294
|
+
return `M ${sx} ${sy} A ${r} ${r} 0 0 ${sweep_flag} ${ex} ${ey}`
|
|
8295
|
+
}
|
|
8296
|
+
|
|
8266
8297
|
_updateBounds() {
|
|
8267
8298
|
if (this.source != undefined && this.target != undefined){
|
|
8268
8299
|
let x1 = this.source.bounds[this.sourceAnchor[0]] + this.sourceOffset[0],
|
|
@@ -8288,6 +8319,10 @@
|
|
|
8288
8319
|
return this.bezierCurveHorizontal(x1, y1, x2, y2);
|
|
8289
8320
|
case "curveVertical":
|
|
8290
8321
|
return this.bezierCurveVertical(x1, y1, x2, y2);
|
|
8322
|
+
case "arcClockwise":
|
|
8323
|
+
return this.arc(x1, y1, x2, y2, true);
|
|
8324
|
+
case "arcAntiClockwise":
|
|
8325
|
+
return this.arc(x1, y1, x2, y2, false);
|
|
8291
8326
|
case "linear":
|
|
8292
8327
|
default:
|
|
8293
8328
|
return `M ${x1} ${y1} L ${x2} ${y2}`;
|
|
@@ -8774,7 +8809,7 @@
|
|
|
8774
8809
|
this._nodeTable.tree = this;
|
|
8775
8810
|
this._linkTable.tree = this;
|
|
8776
8811
|
this._data = data;
|
|
8777
|
-
this.aggregateFromLeaves("value", "average");
|
|
8812
|
+
//this.aggregateFromLeaves("value", "average");
|
|
8778
8813
|
}
|
|
8779
8814
|
|
|
8780
8815
|
get type() {
|
|
@@ -23884,6 +23919,7 @@
|
|
|
23884
23919
|
this._height = "height" in args ? args["height"] : 300;
|
|
23885
23920
|
this._top = "top" in args ? args["top"] : 0;
|
|
23886
23921
|
this._left = "left" in args ? args["left"] : 0;
|
|
23922
|
+
this._edgeSep = "edgeSep" in args? args["edgeSep"] : 50;
|
|
23887
23923
|
}
|
|
23888
23924
|
|
|
23889
23925
|
toJSON() {
|
|
@@ -23897,7 +23933,7 @@
|
|
|
23897
23933
|
if (!graph) return;
|
|
23898
23934
|
|
|
23899
23935
|
var g = new dagre_1.Graph();
|
|
23900
|
-
g.setGraph({edgesep:
|
|
23936
|
+
g.setGraph({edgesep: this._edgeSep});
|
|
23901
23937
|
g.setDefaultEdgeLabel(function() { return {}; });
|
|
23902
23938
|
|
|
23903
23939
|
//in case the node ids in the input graph file are integers
|