mascot-vis 1.11.0 → 1.11.2
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 +21 -21
- package/dist/mascot.js +100 -21
- package/package.json +1 -1
package/dist/mascot.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
// version: 1.11.
|
|
2
|
+
// version: 1.11.2
|
|
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) :
|
|
@@ -260,6 +260,18 @@
|
|
|
260
260
|
CANNOT_CLASSIFY: "Cannot classify items in "
|
|
261
261
|
};
|
|
262
262
|
|
|
263
|
+
const categoricalColorSchemes = [
|
|
264
|
+
"schemeCategory10", "schemeAccent", "schemeDark2", "schemePaired", "schemePastel1", "schemePastel2", "schemeSet1", "schemeSet2", "schemeSet3", "schemeTableau10"
|
|
265
|
+
];
|
|
266
|
+
|
|
267
|
+
const divergingColorSchemes = [
|
|
268
|
+
"schemeBrBG", "schemePRGn", "schemePiYG", "schemePuOr", "schemeRdBu", "schemeRdGy", "schemeRdYlBu", "schemeRdYlGn", "schemeSpectral"
|
|
269
|
+
];
|
|
270
|
+
|
|
271
|
+
const sequentialColorSchemes = [
|
|
272
|
+
"schemeBlues", "schemeGreens", "schemeGreys", "schemeOranges", "schemePurples", "schemeReds", "schemeBuGn", "schemeBuPu", "schemeGnBu", "schemeOrRd", "schemePuBuGn", "schemePuBu", "schemePuRd", "schemeRdPu", "schemeYlGnBu", "schemeYlGn", "schemeYlOrBr", "schemeYlOrRd"
|
|
273
|
+
];
|
|
274
|
+
|
|
263
275
|
class Layout {
|
|
264
276
|
|
|
265
277
|
constructor(args){
|
|
@@ -2169,9 +2181,12 @@
|
|
|
2169
2181
|
while(item) {
|
|
2170
2182
|
if (item.classId && classIds.indexOf(item.classId) < 0)
|
|
2171
2183
|
classIds.push(item.classId);
|
|
2172
|
-
if (item.
|
|
2184
|
+
if (item.type === ItemType.Glyph) {
|
|
2185
|
+
item.children.forEach(d => classIds.push(d.classId));
|
|
2186
|
+
break;
|
|
2187
|
+
} else if (item.children) {
|
|
2173
2188
|
item = item.children[0];
|
|
2174
|
-
else
|
|
2189
|
+
} else
|
|
2175
2190
|
break;
|
|
2176
2191
|
}
|
|
2177
2192
|
let result = [];
|
|
@@ -3265,6 +3280,9 @@
|
|
|
3265
3280
|
let lineDS = p.dataScope ? p.dataScope : new DataScope(datatable);
|
|
3266
3281
|
let ds = datatable.getFieldSummary(field).unique.map(d => lineDS.cross(field, d));
|
|
3267
3282
|
ds = ds.filter(d => !d.isEmpty());
|
|
3283
|
+
if (ds.length === 1) {
|
|
3284
|
+
ds.push(ds[0].clone());
|
|
3285
|
+
}
|
|
3268
3286
|
|
|
3269
3287
|
let args = Object.assign({}, p.styles);
|
|
3270
3288
|
for (let vs of Vertex.styles){
|
|
@@ -3314,6 +3332,9 @@
|
|
|
3314
3332
|
let areaDS = p.dataScope ? p.dataScope : new DataScope(datatable);
|
|
3315
3333
|
let ds = datatable.getFieldSummary(field).unique.map(d => areaDS.cross(field, d));
|
|
3316
3334
|
ds = ft == DataType.Number? ds : ds.filter(d => !d.isEmpty());
|
|
3335
|
+
if (ds.length === 1) {
|
|
3336
|
+
ds.push(ds[0].clone());
|
|
3337
|
+
}
|
|
3317
3338
|
|
|
3318
3339
|
if (ft == DataType.Number || ft == DataType.Date) {
|
|
3319
3340
|
// sorting ds
|
|
@@ -3883,7 +3904,11 @@
|
|
|
3883
3904
|
max = Math.max(...this.data);
|
|
3884
3905
|
domain = [min, max];
|
|
3885
3906
|
if (this.scale) {
|
|
3886
|
-
let domainValues = domain.concat(this.scale.domain);
|
|
3907
|
+
// let domainValues = domain.concat(this.scale.domain);
|
|
3908
|
+
let domainValues = this.data;
|
|
3909
|
+
for (let enc of this.scale.encodings) {
|
|
3910
|
+
domainValues = domainValues.concat(enc.data);
|
|
3911
|
+
}
|
|
3887
3912
|
domain = [Math.min(...domainValues), Math.max(...domainValues)];
|
|
3888
3913
|
//extent = Math.abs(this.scale.map(domain[0]) - this.scale.map(domain[1]));
|
|
3889
3914
|
range = this.scale.range;
|
|
@@ -3921,9 +3946,12 @@
|
|
|
3921
3946
|
|
|
3922
3947
|
if (this.scale) {
|
|
3923
3948
|
//where zero is included depends on the existing scale
|
|
3924
|
-
let domainValues =
|
|
3925
|
-
|
|
3926
|
-
|
|
3949
|
+
let domainValues = this.data;
|
|
3950
|
+
for (let enc of this.scale.encodings) {
|
|
3951
|
+
domainValues = domainValues.concat(enc.data);
|
|
3952
|
+
}
|
|
3953
|
+
// let domainValues = domain.concat(this.scale._scale.domain());
|
|
3954
|
+
domain = [Math.min(...domainValues), Math.max(...domainValues)];
|
|
3927
3955
|
|
|
3928
3956
|
range = this.scale.range;
|
|
3929
3957
|
} else {
|
|
@@ -4161,7 +4189,16 @@
|
|
|
4161
4189
|
if (this.scale) {
|
|
4162
4190
|
this.scale.domain = Array.from(new Set(this.scale.domain.concat(this.data)));
|
|
4163
4191
|
} else {
|
|
4164
|
-
|
|
4192
|
+
let args = {scheme: "schemeCategory10"};
|
|
4193
|
+
if (this._scheme) {
|
|
4194
|
+
if (categoricalColorSchemes.indexOf(this._scheme) >= 0) {
|
|
4195
|
+
args.scheme = this._scheme;
|
|
4196
|
+
} else if (divergingColorSchemes.indexOf(this._scheme) >= 0 || sequentialColorSchemes.indexOf(this._scheme) >= 0) {
|
|
4197
|
+
args.scheme = this._scheme;
|
|
4198
|
+
args.size = this.data.length;
|
|
4199
|
+
}
|
|
4200
|
+
}
|
|
4201
|
+
this.scale = createScale("ordinalColor", args);
|
|
4165
4202
|
this.scale.domain = this.data;
|
|
4166
4203
|
if (this._mapping) {
|
|
4167
4204
|
let range = this.scale.domain.map(d => d in this._mapping ? this._mapping[d] : "black");
|
|
@@ -4718,7 +4755,7 @@
|
|
|
4718
4755
|
|
|
4719
4756
|
set aggregator(a) {
|
|
4720
4757
|
this._aggregator = a;
|
|
4721
|
-
this.scale = undefined;
|
|
4758
|
+
//this.scale = undefined;
|
|
4722
4759
|
this.run();
|
|
4723
4760
|
}
|
|
4724
4761
|
|
|
@@ -6387,7 +6424,7 @@
|
|
|
6387
6424
|
}
|
|
6388
6425
|
}
|
|
6389
6426
|
|
|
6390
|
-
if (this._item.type
|
|
6427
|
+
if (this._item.type === ItemType.Area || this._item.parent.type === ItemType.Area)
|
|
6391
6428
|
c = getCellBoundsInGridLayout(this._item);
|
|
6392
6429
|
|
|
6393
6430
|
if (c === undefined) {
|
|
@@ -7073,6 +7110,12 @@
|
|
|
7073
7110
|
return false;
|
|
7074
7111
|
}
|
|
7075
7112
|
|
|
7113
|
+
_doTranslate(dx, dy) {
|
|
7114
|
+
super._doTranslate(dx, dy);
|
|
7115
|
+
this._x += dx;
|
|
7116
|
+
this._y += dy;
|
|
7117
|
+
}
|
|
7118
|
+
|
|
7076
7119
|
}
|
|
7077
7120
|
|
|
7078
7121
|
class Glyph extends Group {
|
|
@@ -7335,7 +7378,13 @@
|
|
|
7335
7378
|
this.direction = d;
|
|
7336
7379
|
this.items = items;
|
|
7337
7380
|
this.type = ConstraintType.Align;
|
|
7338
|
-
this.
|
|
7381
|
+
this._orientation = [Alignment.Top, Alignment.Middle, Alignment.Bottom].indexOf(d) >= 0 ? Orientation.Vertical : Orientation.Horizontal;
|
|
7382
|
+
this._itemIds = this.items.map(d => d.classId).sort().join("_");
|
|
7383
|
+
this.id = this.type + "_" + this._itemIds + "_" + this._orientation;
|
|
7384
|
+
}
|
|
7385
|
+
|
|
7386
|
+
get orientation() {
|
|
7387
|
+
return this._orientation;
|
|
7339
7388
|
}
|
|
7340
7389
|
|
|
7341
7390
|
apply() {
|
|
@@ -7348,7 +7397,7 @@
|
|
|
7348
7397
|
baseline = d3__namespace.mean(this.items.map(d => d.bounds[dir]));
|
|
7349
7398
|
|
|
7350
7399
|
let delta = this.items.map(d => baseline - d.bounds[dir]),
|
|
7351
|
-
axis = dir == Alignment.
|
|
7400
|
+
axis = dir == Alignment.Top || dir == Alignment.Middle || dir == Alignment.Bottom ? "y" : "x";
|
|
7352
7401
|
this.items.forEach((d,i) => {
|
|
7353
7402
|
if (d.parent && d.parent.layout && d.parent.layout.type == LayoutType.Stack){
|
|
7354
7403
|
let dx = axis == "x" ? delta[i] : 0,
|
|
@@ -8310,7 +8359,7 @@
|
|
|
8310
8359
|
}
|
|
8311
8360
|
|
|
8312
8361
|
for (let enc of scale.encodings) {
|
|
8313
|
-
enc.scene.
|
|
8362
|
+
enc.scene._relayoutAncestors(enc.item, enc.items);
|
|
8314
8363
|
}
|
|
8315
8364
|
//reapply constraints
|
|
8316
8365
|
let items = scale.encodings.map( d => d.anyItem), classId2item = {};
|
|
@@ -9417,7 +9466,7 @@
|
|
|
9417
9466
|
if (!("datatable" in args))
|
|
9418
9467
|
args.datatable = item.dataScope ? item.dataScope.dataTable : item.parent.dataScope.dataTable;
|
|
9419
9468
|
if (!("aggregator" in args))
|
|
9420
|
-
args.aggregator = "
|
|
9469
|
+
args.aggregator = "mean";
|
|
9421
9470
|
if (!("flipScale" in args))
|
|
9422
9471
|
args.flipScale = false;
|
|
9423
9472
|
if (!("includeZero" in args))
|
|
@@ -9524,6 +9573,24 @@
|
|
|
9524
9573
|
this.constraints = {};
|
|
9525
9574
|
}
|
|
9526
9575
|
|
|
9576
|
+
removeConstraint(c) {
|
|
9577
|
+
delete this.constraints[c.id];
|
|
9578
|
+
}
|
|
9579
|
+
|
|
9580
|
+
getRelatedConstraints(items) {
|
|
9581
|
+
let cstrs = [];
|
|
9582
|
+
for (let cid in this.constraints) {
|
|
9583
|
+
let c = this.constraints[cid];
|
|
9584
|
+
switch (c.type) {
|
|
9585
|
+
case ConstraintType.Align:
|
|
9586
|
+
if (c._itemIds === items.map(d => d.classId).sort().join("_"))
|
|
9587
|
+
cstrs.push(c);
|
|
9588
|
+
break;
|
|
9589
|
+
}
|
|
9590
|
+
}
|
|
9591
|
+
return cstrs;
|
|
9592
|
+
}
|
|
9593
|
+
|
|
9527
9594
|
// alignInCell(item, direction) {
|
|
9528
9595
|
// //TODO replace grid.vertCellAlignment and grid.horzCellAlignment
|
|
9529
9596
|
// }
|
|
@@ -9544,7 +9611,7 @@
|
|
|
9544
9611
|
axis(channel, field, params) {
|
|
9545
9612
|
//need to figure out if item has the corresponding encoding, or if item position is determined by layout
|
|
9546
9613
|
let args = params ? params : {}, enc = args.item ? this.getEncodingByItem(args.item, channel) : this.getEncodingByField(field, channel);
|
|
9547
|
-
if (enc) {
|
|
9614
|
+
if (enc && enc.field === field) {
|
|
9548
9615
|
if (enc.datatable.getFieldType(field) === DataType.Date && !("labelFormat" in args)) {
|
|
9549
9616
|
args.labelFormat = "%m/%d/%y";
|
|
9550
9617
|
}
|
|
@@ -9576,8 +9643,8 @@
|
|
|
9576
9643
|
let item = args.item? args.item : findItems(this, [{"field": field}])[0];
|
|
9577
9644
|
if (item === undefined) {
|
|
9578
9645
|
console.warn(Warnings.INCORRECT_AXIS_INFO + field);
|
|
9646
|
+
return;
|
|
9579
9647
|
}
|
|
9580
|
-
|
|
9581
9648
|
let layout = getClosestLayout(item);
|
|
9582
9649
|
if (!layout || (layout.type !== LayoutType.Grid && layout.type !== LayoutType.Stack)) return;
|
|
9583
9650
|
|
|
@@ -9623,7 +9690,7 @@
|
|
|
9623
9690
|
let p = c._item, found = false;
|
|
9624
9691
|
while (p.children && p.children.length > 0) {
|
|
9625
9692
|
for (let ic of p.children) {
|
|
9626
|
-
if (ic.classId === item.
|
|
9693
|
+
if (ic.classId === getEncodingKey(item).split("_")[0]) {
|
|
9627
9694
|
found = true;
|
|
9628
9695
|
axes.push(c);
|
|
9629
9696
|
break;
|
|
@@ -10639,7 +10706,7 @@
|
|
|
10639
10706
|
this._scale = d3__namespace.scaleOrdinal();
|
|
10640
10707
|
break;
|
|
10641
10708
|
case "ordinalColor":
|
|
10642
|
-
this._scale = d3__namespace.scaleOrdinal(args
|
|
10709
|
+
this._scale = d3__namespace.scaleOrdinal(args? args.size ? d3__namespace[args.scheme][args.size] : d3__namespace[args.scheme] : d3__namespace.schemeCategory10);
|
|
10643
10710
|
break;
|
|
10644
10711
|
case "power":
|
|
10645
10712
|
this._scale = d3__namespace.scalePow().exponent(2);
|
|
@@ -11788,6 +11855,7 @@
|
|
|
11788
11855
|
//let item = scene.getItem(enc.anyItem);
|
|
11789
11856
|
let items = enc.items.map(d => scene.getItem(d));
|
|
11790
11857
|
scene._doEncode(items, enc.args);
|
|
11858
|
+
scene._relayoutAncestors(items[0], items);
|
|
11791
11859
|
}
|
|
11792
11860
|
|
|
11793
11861
|
_createGuide(scene, guide) {
|
|
@@ -24040,8 +24108,13 @@
|
|
|
24040
24108
|
if (!item.children || item.children.length == 0) {
|
|
24041
24109
|
return item.contains(x, y) && item.type !== ItemType.Scene ? item : null
|
|
24042
24110
|
}
|
|
24043
|
-
|
|
24044
|
-
|
|
24111
|
+
let children = item.children;
|
|
24112
|
+
if (item.type === ItemType.Scene) {
|
|
24113
|
+
children = children.slice();
|
|
24114
|
+
children.sort((a,b) => isGuide(a) ? 1 : isGuide(b) ? -1 : 0 );
|
|
24115
|
+
}
|
|
24116
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
24117
|
+
let c = children[i];
|
|
24045
24118
|
if (c.contains(x, y))
|
|
24046
24119
|
return c;
|
|
24047
24120
|
}
|
|
@@ -24059,7 +24132,13 @@
|
|
|
24059
24132
|
}
|
|
24060
24133
|
|
|
24061
24134
|
function canRepeat(compnt) {
|
|
24062
|
-
if ((
|
|
24135
|
+
if (Array.isArray(compnt)) {
|
|
24136
|
+
for (let c of compnt) {
|
|
24137
|
+
if (!isMark(c) || c.dataScope)
|
|
24138
|
+
return false;
|
|
24139
|
+
}
|
|
24140
|
+
return true;
|
|
24141
|
+
} else if ((isMark(compnt) || compnt.type == ItemType.Glyph) && !compnt.dataScope) {
|
|
24063
24142
|
return true;
|
|
24064
24143
|
} else if (compnt.type == ItemType.Collection) {
|
|
24065
24144
|
//TODO: check if repeatable
|