mascot-vis 1.9.3 → 1.10.1
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/mascot-min.js +2 -2
- package/dist/mascot.js +116 -52
- package/package.json +1 -1
package/dist/mascot.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
// version: 1.
|
|
2
|
+
// version: 1.10.1
|
|
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) :
|
|
@@ -2832,16 +2832,17 @@
|
|
|
2832
2832
|
let scopes = line2Scopes[p.id];
|
|
2833
2833
|
let x1 = p.vertices[0].x, y1 = p.vertices[0].y, x2 = p.vertices[1].x, y2 = p.vertices[1].y;
|
|
2834
2834
|
|
|
2835
|
-
p.classId = compnt.id;
|
|
2836
|
-
p.vertices[0].x = x1;
|
|
2837
|
-
p.vertices[0].y = y1;
|
|
2838
|
-
p.vertices[1].x = x1 + (x2 - x1)/max;
|
|
2839
|
-
p.vertices[1].y = y1 + (y2 - y1)/max;
|
|
2840
|
-
p.dataScope = scopes[0];
|
|
2841
|
-
coll.addChild(p);
|
|
2835
|
+
// p.classId = compnt.id;
|
|
2836
|
+
// p.vertices[0].x = x1;
|
|
2837
|
+
// p.vertices[0].y = y1;
|
|
2838
|
+
// p.vertices[1].x = x1 + (x2 - x1)/max;
|
|
2839
|
+
// p.vertices[1].y = y1 + (y2 - y1)/max;
|
|
2840
|
+
// p.dataScope = scopes[0];
|
|
2841
|
+
// coll.addChild(p);
|
|
2842
2842
|
|
|
2843
|
-
for (let i =
|
|
2843
|
+
for (let i = 0; i < scopes.length; i++) {
|
|
2844
2844
|
let c = p.duplicate();
|
|
2845
|
+
c.classId = compnt.id;
|
|
2845
2846
|
c.vertices[0].x = x1 + (x2 - x1) * i /max;
|
|
2846
2847
|
c.vertices[0].y = y1 + (y2 - y1) * i /max;
|
|
2847
2848
|
c.vertices[1].x = x1 + (x2 - x1) * (i + 1)/max;
|
|
@@ -2850,6 +2851,8 @@
|
|
|
2850
2851
|
coll.addChild(c);
|
|
2851
2852
|
}
|
|
2852
2853
|
|
|
2854
|
+
parent.removeChild(p);
|
|
2855
|
+
|
|
2853
2856
|
if (p == compnt)
|
|
2854
2857
|
toReturn = coll;
|
|
2855
2858
|
}
|
|
@@ -2896,13 +2899,14 @@
|
|
|
2896
2899
|
|
|
2897
2900
|
let wd = orientation == Orientation.Horizontal ? bounds.width/max : bounds.width,
|
|
2898
2901
|
ht = orientation == Orientation.Horizontal ? bounds.height : bounds.height/max;
|
|
2899
|
-
p.classId = compnt.id;
|
|
2900
|
-
p.resize(wd, ht);
|
|
2901
|
-
p.dataScope = scopes[0];
|
|
2902
|
-
coll.addChild(p);
|
|
2902
|
+
// p.classId = compnt.id;
|
|
2903
|
+
//p.resize(wd, ht);
|
|
2904
|
+
//p.dataScope = scopes[0];
|
|
2905
|
+
//coll.addChild(p);
|
|
2903
2906
|
|
|
2904
|
-
for (let i =
|
|
2907
|
+
for (let i = 0; i < scopes.length; i++) {
|
|
2905
2908
|
let c = p.duplicate();
|
|
2909
|
+
c.classId = compnt.id;
|
|
2906
2910
|
c.resize(wd, ht);
|
|
2907
2911
|
c.dataScope = scopes[i];
|
|
2908
2912
|
coll.addChild(c);
|
|
@@ -2910,21 +2914,14 @@
|
|
|
2910
2914
|
|
|
2911
2915
|
coll.layout = new StackLayout({orientation: orientation, left: left, top: top});
|
|
2912
2916
|
|
|
2917
|
+
parent.removeChild(p);
|
|
2918
|
+
|
|
2913
2919
|
if (p == compnt)
|
|
2914
2920
|
toReturn = coll;
|
|
2915
2921
|
}
|
|
2916
2922
|
|
|
2917
2923
|
scene._reapplySizeBindings(toReturn);
|
|
2918
2924
|
|
|
2919
|
-
//update axis item argument
|
|
2920
|
-
let axes = scene.getRelatedAxes(compnt);
|
|
2921
|
-
for (let a of axes) {
|
|
2922
|
-
if (a._item.classId === compnt.classId) {
|
|
2923
|
-
a._item = toReturn;
|
|
2924
|
-
a._items = getPeers(toReturn, scene);
|
|
2925
|
-
}
|
|
2926
|
-
}
|
|
2927
|
-
|
|
2928
2925
|
return toReturn;
|
|
2929
2926
|
}
|
|
2930
2927
|
|
|
@@ -2956,17 +2953,19 @@
|
|
|
2956
2953
|
|
|
2957
2954
|
let wd = orientation == Orientation.Horizontal ? p.width/ds.length : p.width,
|
|
2958
2955
|
ht = orientation == Orientation.Horizontal ? p.height : p.height/ds.length;
|
|
2959
|
-
|
|
2960
|
-
p.
|
|
2961
|
-
|
|
2962
|
-
coll.addChild(p);
|
|
2956
|
+
// p.classId = compnt.id;
|
|
2957
|
+
// p.resizeArea(wd, ht);
|
|
2958
|
+
// coll.addChild(p);
|
|
2963
2959
|
|
|
2964
|
-
for (let i =
|
|
2960
|
+
for (let i = 0; i < ds.length; i++) {
|
|
2965
2961
|
let c = p.duplicate();
|
|
2962
|
+
c.classId = compnt.id;
|
|
2966
2963
|
c.resizeArea(wd, ht);
|
|
2967
2964
|
coll.addChild(c);
|
|
2968
2965
|
}
|
|
2969
2966
|
|
|
2967
|
+
parent.removeChild(p);
|
|
2968
|
+
|
|
2970
2969
|
for (let i = 0; i < coll.children.length; i++) {
|
|
2971
2970
|
let child = coll.children[i];
|
|
2972
2971
|
if (child.dataScope) {
|
|
@@ -3156,7 +3155,7 @@
|
|
|
3156
3155
|
coll.addChild(pie);
|
|
3157
3156
|
}
|
|
3158
3157
|
|
|
3159
|
-
coll.layout = layout("stack", {direction: Direction.Clockwise});
|
|
3158
|
+
coll.layout = layout("stack", {orientation: Orientation.Angular, direction: Direction.Clockwise});
|
|
3160
3159
|
// Replace original circle w/ coll of pies
|
|
3161
3160
|
parent.removeChild(p);
|
|
3162
3161
|
parent.addChild(coll);
|
|
@@ -3521,6 +3520,11 @@
|
|
|
3521
3520
|
this._updateBounds();
|
|
3522
3521
|
}
|
|
3523
3522
|
|
|
3523
|
+
set area(a) {
|
|
3524
|
+
this.attrs["radius"] = Math.sqrt(a);
|
|
3525
|
+
this._updateBounds();
|
|
3526
|
+
}
|
|
3527
|
+
|
|
3524
3528
|
// set width(w) {
|
|
3525
3529
|
// this.attrs["radius"] = w/2;
|
|
3526
3530
|
// this._updateBounds();
|
|
@@ -3607,7 +3611,7 @@
|
|
|
3607
3611
|
|
|
3608
3612
|
//TODO: check if item width has already been encoded with a different field
|
|
3609
3613
|
//the code below assumes width hasn't been bound to data
|
|
3610
|
-
scale._setRange([0, Math.max(...(items.map(d => d.width)))]);
|
|
3614
|
+
scale._setRange([0, this.rangeExtent ? this.rangeExtent : Math.max(...(items.map(d => d.width)))]);
|
|
3611
3615
|
} else {
|
|
3612
3616
|
// let top = Math.min(...(items.map(d => d.bounds.top))),
|
|
3613
3617
|
// bottom = Math.max(...(items.map(d => d.bounds.bottom)));
|
|
@@ -3615,7 +3619,7 @@
|
|
|
3615
3619
|
|
|
3616
3620
|
//TODO: check if item height has already been encoded with a different field
|
|
3617
3621
|
//the code below assumes height hasn't been bound to data
|
|
3618
|
-
scale._setRange([0, Math.max(...(items.map(d => d.height)))]);
|
|
3622
|
+
scale._setRange([0, this.rangeExtent ? this.rangeExtent : Math.max(...(items.map(d => d.height)))]);
|
|
3619
3623
|
}
|
|
3620
3624
|
} else {
|
|
3621
3625
|
scale.domain = [0, Math.max(...data)];
|
|
@@ -3971,6 +3975,8 @@
|
|
|
3971
3975
|
} else {
|
|
3972
3976
|
if (this.scale.offset === undefined)
|
|
3973
3977
|
this.scale.offset = Math.min(...items.map(d => d[channel]));
|
|
3978
|
+
if (this.items[0].type === ItemType.PointText)
|
|
3979
|
+
this.items.forEach(d => d.horzAnchor = "center");
|
|
3974
3980
|
for (let i = 0; i < this.items.length; i++) {
|
|
3975
3981
|
let peer = this.items[i];
|
|
3976
3982
|
let dx = this.scale.offset + this.scale.map(this.data[i]) - peer[channel],
|
|
@@ -4015,6 +4021,8 @@
|
|
|
4015
4021
|
} else {
|
|
4016
4022
|
if (this.scale.offset === undefined)
|
|
4017
4023
|
this.scale.offset = Math.min(...items.map(d => d.bounds.y));
|
|
4024
|
+
if (this.items[0].type === ItemType.PointText)
|
|
4025
|
+
this.items.forEach(d => d.vertAnchor = "middle");
|
|
4018
4026
|
for (let i = 0; i < this.items.length; i++) {
|
|
4019
4027
|
let peer = this.items[i];
|
|
4020
4028
|
let dx = 0,
|
|
@@ -4386,6 +4394,9 @@
|
|
|
4386
4394
|
extent = Math.max(...this.areas.map(d => d.bounds.height));
|
|
4387
4395
|
}
|
|
4388
4396
|
}
|
|
4397
|
+
|
|
4398
|
+
if (this.rangeExtent)
|
|
4399
|
+
extent = this.rangeExtent;
|
|
4389
4400
|
|
|
4390
4401
|
if (min < 0) {
|
|
4391
4402
|
scale._scale.domain([min, max]);
|
|
@@ -4759,12 +4770,12 @@
|
|
|
4759
4770
|
let layout = getTopLevelLayout(enc.anyItem, "stack");
|
|
4760
4771
|
if (layout) {
|
|
4761
4772
|
let c = layout.group, colls = getPeers(c, enc.scene);
|
|
4762
|
-
r = Math.max(...colls.map(d => d.
|
|
4773
|
+
r = Math.max(...colls.map(d => d.refBounds[enc.channel]));
|
|
4763
4774
|
domain[1] = enc.scale.invert(r); // Math.ceil(enc.scale.invert(r)); do not ceil, it can amplify small difference in invert calculation due to imprecision/roundoff in bounding box calculation
|
|
4764
4775
|
}
|
|
4765
4776
|
}
|
|
4766
4777
|
minPxInterval = enc.channel == "width" || enc.channel == "x" ? 45 : 30;
|
|
4767
|
-
let n = Math.floor(r/minPxInterval)
|
|
4778
|
+
let n = Math.max(2, Math.floor(r/minPxInterval));
|
|
4768
4779
|
let ticks;
|
|
4769
4780
|
if (enc.scale.type === "log") {
|
|
4770
4781
|
ticks = [];
|
|
@@ -4940,9 +4951,10 @@
|
|
|
4940
4951
|
return [offset, offset + this.scale.rangeExtent];
|
|
4941
4952
|
}
|
|
4942
4953
|
} else if (this.channel == "height") {
|
|
4943
|
-
let
|
|
4944
|
-
|
|
4945
|
-
|
|
4954
|
+
let c = getTopLevelCollection(item);
|
|
4955
|
+
//let layout = getTopLevelLayout(item, "grid");
|
|
4956
|
+
if (c && c.layout && ["grid", "stack"].indexOf(c.layout.type) >= 0){
|
|
4957
|
+
let cellBounds = c.layout.cellBounds;
|
|
4946
4958
|
let parentPeers = item.parent.parent.children;
|
|
4947
4959
|
let idx = parentPeers.findIndex(d => item.parent === d || item.parent.parent === d );
|
|
4948
4960
|
//return [cellBounds[idx].bottom, cellBounds[idx].bottom - this.scale.rangeExtent];
|
|
@@ -4951,7 +4963,7 @@
|
|
|
4951
4963
|
} else {
|
|
4952
4964
|
let items = getPeers(item, this.scene);
|
|
4953
4965
|
//TODO: handle cases where items are aligned top
|
|
4954
|
-
let offset = Math.max(...items.map(d => d.
|
|
4966
|
+
let offset = Math.max(...items.map(d => d.refBounds.bottom));
|
|
4955
4967
|
return [offset, offset - this.scale.rangeExtent];
|
|
4956
4968
|
}
|
|
4957
4969
|
} else if (this.channel == "radialDistance") {
|
|
@@ -5184,6 +5196,7 @@
|
|
|
5184
5196
|
case "radius":
|
|
5185
5197
|
case "fillColor":
|
|
5186
5198
|
case "strokeColor":
|
|
5199
|
+
case "text":
|
|
5187
5200
|
return this.numericFields.concat(this.nonNumericFields);
|
|
5188
5201
|
case "area":
|
|
5189
5202
|
case "strokeWidth":
|
|
@@ -5591,6 +5604,24 @@
|
|
|
5591
5604
|
this._updateBounds();
|
|
5592
5605
|
}
|
|
5593
5606
|
|
|
5607
|
+
get horzAnchor() {
|
|
5608
|
+
return this.attrs["anchor"][0];
|
|
5609
|
+
}
|
|
5610
|
+
|
|
5611
|
+
get vertAnchor() {
|
|
5612
|
+
return this.attrs["anchor"][1];
|
|
5613
|
+
}
|
|
5614
|
+
|
|
5615
|
+
set horzAnchor(a) {
|
|
5616
|
+
this.attrs["anchor"][0] = a;
|
|
5617
|
+
this._updateBounds();
|
|
5618
|
+
}
|
|
5619
|
+
|
|
5620
|
+
set vertAnchor(a) {
|
|
5621
|
+
this.attrs["anchor"][1] = a;
|
|
5622
|
+
this._updateBounds();
|
|
5623
|
+
}
|
|
5624
|
+
|
|
5594
5625
|
//return integer
|
|
5595
5626
|
get fontSize() {
|
|
5596
5627
|
return parseFloat(this.styles["fontSize"]);
|
|
@@ -7108,6 +7139,7 @@
|
|
|
7108
7139
|
copyPropertiesTo(target) {
|
|
7109
7140
|
super.copyPropertiesTo(target);
|
|
7110
7141
|
target._baseline = this._baseline;
|
|
7142
|
+
target._orientation = this._orientation;
|
|
7111
7143
|
}
|
|
7112
7144
|
|
|
7113
7145
|
resizeArea(wd, ht) {
|
|
@@ -7658,14 +7690,17 @@
|
|
|
7658
7690
|
}
|
|
7659
7691
|
|
|
7660
7692
|
contains(x, y) {
|
|
7661
|
-
let
|
|
7662
|
-
if (
|
|
7663
|
-
let
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7693
|
+
let irregular2Ds = [ItemType.Arc, ItemType.Pie, ItemType.Polygon, ItemType.Area];
|
|
7694
|
+
if (irregular2Ds.indexOf(this.firstChild.type) >= 0) {
|
|
7695
|
+
let svgData = this.getSVGPathData();
|
|
7696
|
+
if (svgData !== "") {
|
|
7697
|
+
let ctx = CanvasProvider.getContext(),
|
|
7698
|
+
p = new Path2D(svgData);
|
|
7699
|
+
ctx.lineWidth = Math.max(this.strokeWidth, 2.5);
|
|
7700
|
+
ctx.stroke(p);
|
|
7701
|
+
return ctx.isPointInPath(p, x, y);
|
|
7702
|
+
}
|
|
7703
|
+
}
|
|
7669
7704
|
if (!this._bounds) {
|
|
7670
7705
|
this._updateBounds();
|
|
7671
7706
|
}
|
|
@@ -8204,8 +8239,8 @@
|
|
|
8204
8239
|
let axes = enc.scene.getRelatedAxes(item);
|
|
8205
8240
|
for (let a of axes) {
|
|
8206
8241
|
if (a.encoding && a.encoding.scale === scale) {
|
|
8207
|
-
a.tickValues = enc.
|
|
8208
|
-
a.labelValues = enc.
|
|
8242
|
+
a.tickValues = enc._inferTickValues(enc);
|
|
8243
|
+
a.labelValues = enc._inferTickValues(enc);
|
|
8209
8244
|
a._positionPath();
|
|
8210
8245
|
if (a._showTitle)
|
|
8211
8246
|
a._positionTitle();
|
|
@@ -8260,7 +8295,17 @@
|
|
|
8260
8295
|
},
|
|
8261
8296
|
|
|
8262
8297
|
markDivided: function(path, collection) {
|
|
8298
|
+
//update axis item argument
|
|
8263
8299
|
let scene = collection.getScene();
|
|
8300
|
+
let axes = scene.getRelatedAxes(path);
|
|
8301
|
+
for (let a of axes) {
|
|
8302
|
+
if (a._item.classId === path.classId) {
|
|
8303
|
+
a._item = collection;
|
|
8304
|
+
a._items = getPeers(collection, scene);
|
|
8305
|
+
}
|
|
8306
|
+
}
|
|
8307
|
+
|
|
8308
|
+
//update encoding item
|
|
8264
8309
|
let e = scene.encodings[getEncodingKey(path)];
|
|
8265
8310
|
if (e) {
|
|
8266
8311
|
scene.encodings[getEncodingKey(collection)] = {};
|
|
@@ -8273,7 +8318,7 @@
|
|
|
8273
8318
|
scene.encodings[getEncodingKey(collection)][channel] = enc;
|
|
8274
8319
|
delete scene.encodings[getEncodingKey(path)][channel];
|
|
8275
8320
|
}
|
|
8276
|
-
if (Object.keys(e) === 0)
|
|
8321
|
+
if (Object.keys(e).length === 0)
|
|
8277
8322
|
delete scene.encodings[getEncodingKey(path)];
|
|
8278
8323
|
}
|
|
8279
8324
|
//TODO: update constraints
|
|
@@ -8442,7 +8487,8 @@
|
|
|
8442
8487
|
encoding._apply = function() {
|
|
8443
8488
|
//sort items by centroid
|
|
8444
8489
|
this.items.sort((a, b) => (a.innerRadius+a.outerRadius)/2 - (b.innerRadius+b.outerRadius)/2);
|
|
8445
|
-
let
|
|
8490
|
+
let outer = Math.min(...this.items.map(d => d.innerRadius));
|
|
8491
|
+
let tree = {item: new ArcPath({outerRadius: outer, startAngle: 0, endAngle: 360}), children: []};
|
|
8446
8492
|
for (let itm of this.items) {
|
|
8447
8493
|
addToTree(tree, itm);
|
|
8448
8494
|
}
|
|
@@ -9227,8 +9273,15 @@
|
|
|
9227
9273
|
let arr = Array.isArray(itm) ? itm : [itm];
|
|
9228
9274
|
let encs = [], scale;
|
|
9229
9275
|
for (let item of arr) {
|
|
9230
|
-
this._validateEncodeArgs(item, args);
|
|
9231
9276
|
let items;
|
|
9277
|
+
if ([ItemType.Pie, ItemType.Arc].indexOf(itm.type) >= 0 && args.channel === "angle") {
|
|
9278
|
+
let parent = itm.parent;
|
|
9279
|
+
if (parent.type === ItemType.Collection && parent.layout && parent.layout.orientation === Orientation.Angular) {
|
|
9280
|
+
encs.push(this._encodeWithinCollection(item, args));
|
|
9281
|
+
continue;
|
|
9282
|
+
}
|
|
9283
|
+
}
|
|
9284
|
+
this._validateEncodeArgs(item, args);
|
|
9232
9285
|
if (item.type == "vertex" && item.parent.type == ItemType.Area){
|
|
9233
9286
|
let areas = getPeers(item.parent, this);
|
|
9234
9287
|
items = [];
|
|
@@ -9333,7 +9386,7 @@
|
|
|
9333
9386
|
return encoding;
|
|
9334
9387
|
}
|
|
9335
9388
|
|
|
9336
|
-
|
|
9389
|
+
_encodeWithinCollection(item, args) {
|
|
9337
9390
|
this._validateEncodeArgs(item, args);
|
|
9338
9391
|
let peersByGroup = getPeersGroupedByParent(item, this);
|
|
9339
9392
|
let encs = [];
|
|
@@ -9389,11 +9442,20 @@
|
|
|
9389
9442
|
//optional arguments include orientation, x-coordinate, y-coordinate, tickFormat, strokeColor,
|
|
9390
9443
|
axis(channel, field, params) {
|
|
9391
9444
|
//need to figure out if item has the corresponding encoding, or if item position is determined by layout
|
|
9392
|
-
let
|
|
9445
|
+
let args = params ? params : {}, enc = args.item ? this.getEncodingByItem(args.item, channel) : this.getEncodingByField(field, channel);
|
|
9393
9446
|
if (enc) {
|
|
9394
9447
|
if (enc.datatable.getFieldType(field) === DataType.Date && !("labelFormat" in args)) {
|
|
9395
9448
|
args.labelFormat = "%m/%d/%y";
|
|
9396
9449
|
}
|
|
9450
|
+
if (enc.channel === "width") {
|
|
9451
|
+
let existingChannels = this.children.filter(d => d.type === ItemType.Axis).map(d => d.channel);
|
|
9452
|
+
if (!("orientation" in args))
|
|
9453
|
+
args.orientation = existingChannels.indexOf("x") >= 0? "top" : "bottom";
|
|
9454
|
+
} else if (enc.channel === "height") {
|
|
9455
|
+
let existingChannels = this.children.filter(d => d.type === ItemType.Axis).map(d => d.channel);
|
|
9456
|
+
if (!("orientation" in args))
|
|
9457
|
+
args.orientation = existingChannels.indexOf("y") >= 0? "right" : "left";
|
|
9458
|
+
}
|
|
9397
9459
|
let axis = new EncodingAxis(enc, args.item? args.item : enc.anyItem, args);
|
|
9398
9460
|
if ("tickValues" in args) {
|
|
9399
9461
|
axis.tickValues = args["tickValues"];
|
|
@@ -9555,6 +9617,8 @@
|
|
|
9555
9617
|
removeEncoding(enc) {
|
|
9556
9618
|
let key = getEncodingKey(enc.anyItem);
|
|
9557
9619
|
delete this.encodings[key][enc.channel];
|
|
9620
|
+
if (Object.keys(this.encodings[key]).length === 0)
|
|
9621
|
+
delete this.encodings[key];
|
|
9558
9622
|
let toRemove = [];
|
|
9559
9623
|
for (let c of this.children) {
|
|
9560
9624
|
if (isGuide(c) && c.encoding && c.encoding === enc){
|