mascot-vis 1.11.1 → 1.12.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/mascot-min.js +21 -21
- package/dist/mascot.js +216 -49
- package/package.json +1 -1
package/dist/mascot.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
// version: 1.
|
|
2
|
+
// version: 1.12.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) :
|
|
@@ -1382,7 +1382,15 @@
|
|
|
1382
1382
|
vy = this.vertices.map(d => d.y);
|
|
1383
1383
|
|
|
1384
1384
|
let left = Math.min(...vx), top = Math.min(...vy), right = Math.max(...vx), btm = Math.max(...vy);
|
|
1385
|
+
|
|
1385
1386
|
this._bounds = new Rectangle(left, top, right - left, btm - top);
|
|
1387
|
+
if (this.type === ItemType.Line || this.type === ItemType.Path) {
|
|
1388
|
+
let sw = this.styles["strokeWidth"] ? this.styles["strokeWidth"] : 1;
|
|
1389
|
+
if (left === right)
|
|
1390
|
+
this._bounds = new Rectangle(left - sw/2, top, right - left + sw, btm - top);
|
|
1391
|
+
else if (top === btm)
|
|
1392
|
+
this._bounds = new Rectangle(left, top - sw/2, right - left, btm - top + sw);
|
|
1393
|
+
}
|
|
1386
1394
|
}
|
|
1387
1395
|
|
|
1388
1396
|
addVertex(x, y, i) {
|
|
@@ -1744,6 +1752,18 @@
|
|
|
1744
1752
|
return undefined;
|
|
1745
1753
|
}
|
|
1746
1754
|
|
|
1755
|
+
function getCellIndexInLayout(item) {
|
|
1756
|
+
let itm = item, parent = item.parent;
|
|
1757
|
+
while (parent && parent.type != ItemType.Scene) {
|
|
1758
|
+
if (parent.layout){
|
|
1759
|
+
return parent.children.findIndex(d => d == itm);
|
|
1760
|
+
}
|
|
1761
|
+
itm = itm.parent;
|
|
1762
|
+
parent = itm.parent;
|
|
1763
|
+
}
|
|
1764
|
+
return undefined;
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1747
1767
|
function getCellBoundsInGridLayout(item) {
|
|
1748
1768
|
let itm = item, parent = item.parent;
|
|
1749
1769
|
while (parent && parent.type != ItemType.Scene) {
|
|
@@ -1789,6 +1809,10 @@
|
|
|
1789
1809
|
}
|
|
1790
1810
|
}
|
|
1791
1811
|
|
|
1812
|
+
function sameClass(item1, item2) {
|
|
1813
|
+
return getEncodingKey(item1).split("_")[0] === getEncodingKey(item2).split("_")[0];
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1792
1816
|
function getParents(items) {
|
|
1793
1817
|
let result = [];
|
|
1794
1818
|
for (let p of items) {
|
|
@@ -2181,9 +2205,12 @@
|
|
|
2181
2205
|
while(item) {
|
|
2182
2206
|
if (item.classId && classIds.indexOf(item.classId) < 0)
|
|
2183
2207
|
classIds.push(item.classId);
|
|
2184
|
-
if (item.
|
|
2208
|
+
if (item.type === ItemType.Glyph) {
|
|
2209
|
+
item.children.forEach(d => classIds.push(d.classId));
|
|
2210
|
+
break;
|
|
2211
|
+
} else if (item.children) {
|
|
2185
2212
|
item = item.children[0];
|
|
2186
|
-
else
|
|
2213
|
+
} else
|
|
2187
2214
|
break;
|
|
2188
2215
|
}
|
|
2189
2216
|
let result = [];
|
|
@@ -2467,6 +2494,10 @@
|
|
|
2467
2494
|
_updateTuples(field, value) {
|
|
2468
2495
|
this._tuples = this._tuples.filter(d => d[field] == value);
|
|
2469
2496
|
}
|
|
2497
|
+
|
|
2498
|
+
get tuples() {
|
|
2499
|
+
return this._tuples;
|
|
2500
|
+
}
|
|
2470
2501
|
}
|
|
2471
2502
|
|
|
2472
2503
|
function repeatItem(scene, compnt, field, datatable, callback) {
|
|
@@ -2753,13 +2784,22 @@
|
|
|
2753
2784
|
run() {
|
|
2754
2785
|
if (this.group == undefined || !this.group.children || this.group.children.length === 0)
|
|
2755
2786
|
return;
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2787
|
+
let leafMark = getLeafMarks(this.group)[0];
|
|
2788
|
+
switch (leafMark.type) {
|
|
2789
|
+
case ItemType.Area:
|
|
2790
|
+
this._stackAreas();
|
|
2791
|
+
break;
|
|
2792
|
+
case ItemType.Arc:
|
|
2793
|
+
case ItemType.Pie:
|
|
2794
|
+
if (leafMark.parent === this.group)
|
|
2795
|
+
this._stackArcs();
|
|
2796
|
+
break;
|
|
2797
|
+
case ItemType.Rect:
|
|
2798
|
+
case ItemType.Image:
|
|
2799
|
+
case ItemType.Circle:
|
|
2800
|
+
this._stackRects();
|
|
2801
|
+
break;
|
|
2802
|
+
}
|
|
2763
2803
|
}
|
|
2764
2804
|
|
|
2765
2805
|
set vertCellAlignment(v) {
|
|
@@ -2815,6 +2855,8 @@
|
|
|
2815
2855
|
switch (compnt.type) {
|
|
2816
2856
|
case ItemType.Line:
|
|
2817
2857
|
return _doLineDivide(scene, compnt, f, datatable);
|
|
2858
|
+
case ItemType.Path:
|
|
2859
|
+
return _doPathDivide(scene, compnt, f, datatable);
|
|
2818
2860
|
case ItemType.Circle:
|
|
2819
2861
|
return _doCircleDivide(scene, compnt, orientation, f, datatable);
|
|
2820
2862
|
case ItemType.Rect:
|
|
@@ -2889,6 +2931,57 @@
|
|
|
2889
2931
|
return toReturn;
|
|
2890
2932
|
}
|
|
2891
2933
|
|
|
2934
|
+
function _doPathDivide(scene, compnt, field, datatable) {
|
|
2935
|
+
let peers = getPeers(compnt, scene);
|
|
2936
|
+
let toReturn;
|
|
2937
|
+
let ds = datatable.getFieldSummary(field).unique.map(d => new DataScope(datatable).cross(field, d));
|
|
2938
|
+
|
|
2939
|
+
let line2Scopes = {}, max = 0;
|
|
2940
|
+
for (let p of peers) {
|
|
2941
|
+
let scopes = ds;
|
|
2942
|
+
if (p.dataScope) {
|
|
2943
|
+
scopes = ds.map(d => d.merge(p.dataScope));
|
|
2944
|
+
scopes = scopes.filter(d => !d.isEmpty());
|
|
2945
|
+
}
|
|
2946
|
+
if (scopes.length > max)
|
|
2947
|
+
max = scopes.length;
|
|
2948
|
+
line2Scopes[p.id] = scopes;
|
|
2949
|
+
}
|
|
2950
|
+
let collClassId;
|
|
2951
|
+
for (let p of peers) {
|
|
2952
|
+
let coll = scene.collection();
|
|
2953
|
+
if (collClassId == undefined)
|
|
2954
|
+
collClassId = coll.id;
|
|
2955
|
+
coll.classId = collClassId;
|
|
2956
|
+
coll.dataScope = p.dataScope;
|
|
2957
|
+
|
|
2958
|
+
let parent = p.parent;
|
|
2959
|
+
//let index = parent.children.indexOf(p) - 1;
|
|
2960
|
+
parent.addChild(coll);
|
|
2961
|
+
|
|
2962
|
+
let scopes = line2Scopes[p.id];
|
|
2963
|
+
let x1 = p.bounds.left, y1 = p.bounds.top, x2 = p.bounds.right, y2 = p.bounds.bottom;
|
|
2964
|
+
|
|
2965
|
+
for (let i = 0; i < scopes.length; i++) {
|
|
2966
|
+
let c = scene.mark("line", {x1: x1 + (x2 - x1) * i /max, x2: x1 + (x2 - x1) * (i + 1)/max, y1: y1 + (y2 - y1) * i /max, y2: y1 + (y2 - y1) * (i + 1)/max});
|
|
2967
|
+
c.classId = compnt.id;
|
|
2968
|
+
c.dataScope = scopes[i];
|
|
2969
|
+
coll.addChild(c);
|
|
2970
|
+
}
|
|
2971
|
+
|
|
2972
|
+
parent.removeChild(p);
|
|
2973
|
+
|
|
2974
|
+
if (p == compnt)
|
|
2975
|
+
toReturn = coll;
|
|
2976
|
+
}
|
|
2977
|
+
|
|
2978
|
+
let f = compnt.firstVertex.dataScope.fields[0];
|
|
2979
|
+
scene.densify(toReturn.firstChild, datatable, {field: f});
|
|
2980
|
+
|
|
2981
|
+
|
|
2982
|
+
return toReturn;
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2892
2985
|
|
|
2893
2986
|
|
|
2894
2987
|
function _doRectDivide(scene, compnt, o, field, datatable) {
|
|
@@ -3277,6 +3370,9 @@
|
|
|
3277
3370
|
let lineDS = p.dataScope ? p.dataScope : new DataScope(datatable);
|
|
3278
3371
|
let ds = datatable.getFieldSummary(field).unique.map(d => lineDS.cross(field, d));
|
|
3279
3372
|
ds = ds.filter(d => !d.isEmpty());
|
|
3373
|
+
if (ds.length === 1) {
|
|
3374
|
+
ds.push(ds[0].clone());
|
|
3375
|
+
}
|
|
3280
3376
|
|
|
3281
3377
|
let args = Object.assign({}, p.styles);
|
|
3282
3378
|
for (let vs of Vertex.styles){
|
|
@@ -3326,6 +3422,9 @@
|
|
|
3326
3422
|
let areaDS = p.dataScope ? p.dataScope : new DataScope(datatable);
|
|
3327
3423
|
let ds = datatable.getFieldSummary(field).unique.map(d => areaDS.cross(field, d));
|
|
3328
3424
|
ds = ft == DataType.Number? ds : ds.filter(d => !d.isEmpty());
|
|
3425
|
+
if (ds.length === 1) {
|
|
3426
|
+
ds.push(ds[0].clone());
|
|
3427
|
+
}
|
|
3329
3428
|
|
|
3330
3429
|
if (ft == DataType.Number || ft == DataType.Date) {
|
|
3331
3430
|
// sorting ds
|
|
@@ -3895,7 +3994,11 @@
|
|
|
3895
3994
|
max = Math.max(...this.data);
|
|
3896
3995
|
domain = [min, max];
|
|
3897
3996
|
if (this.scale) {
|
|
3898
|
-
let domainValues = domain.concat(this.scale.domain);
|
|
3997
|
+
// let domainValues = domain.concat(this.scale.domain);
|
|
3998
|
+
let domainValues = this.data;
|
|
3999
|
+
for (let enc of this.scale.encodings) {
|
|
4000
|
+
domainValues = domainValues.concat(enc.data);
|
|
4001
|
+
}
|
|
3899
4002
|
domain = [Math.min(...domainValues), Math.max(...domainValues)];
|
|
3900
4003
|
//extent = Math.abs(this.scale.map(domain[0]) - this.scale.map(domain[1]));
|
|
3901
4004
|
range = this.scale.range;
|
|
@@ -3933,17 +4036,23 @@
|
|
|
3933
4036
|
|
|
3934
4037
|
if (this.scale) {
|
|
3935
4038
|
//where zero is included depends on the existing scale
|
|
3936
|
-
let domainValues =
|
|
3937
|
-
|
|
3938
|
-
|
|
4039
|
+
let domainValues = this.data;
|
|
4040
|
+
for (let enc of this.scale.encodings) {
|
|
4041
|
+
domainValues = domainValues.concat(enc.data);
|
|
4042
|
+
}
|
|
4043
|
+
// let domainValues = domain.concat(this.scale._scale.domain());
|
|
4044
|
+
domain = [Math.min(...domainValues), Math.max(...domainValues)];
|
|
3939
4045
|
|
|
3940
4046
|
range = this.scale.range;
|
|
3941
4047
|
} else {
|
|
3942
4048
|
this.scale = createScale(this.scaleType);
|
|
3943
4049
|
this.scale.isFlipped = this._flipScale;
|
|
3944
4050
|
this.scale.includeZero = this._includeZero;
|
|
3945
|
-
//domain = this._includeZero ? [0, max] : [min, max];
|
|
3946
4051
|
range = [0, extent];
|
|
4052
|
+
//remember the item that was used to first create this scale,
|
|
4053
|
+
//so that when the scale is reused later, we can refer to the base item
|
|
4054
|
+
//to get absoluate positions
|
|
4055
|
+
this.scale._baseItem = this.anyItem;
|
|
3947
4056
|
}
|
|
3948
4057
|
if (domain[0] == domain[1])
|
|
3949
4058
|
domain[1] = domain[0] * 1.1;
|
|
@@ -3964,9 +4073,26 @@
|
|
|
3964
4073
|
for (let enc of this.scale.encodings)
|
|
3965
4074
|
items = items.concat(enc.items);
|
|
3966
4075
|
if (channel == "x") {
|
|
3967
|
-
let layout = getClosestLayout(this.anyItem, "grid");
|
|
4076
|
+
//let layout = getClosestLayout(this.anyItem, "grid");
|
|
3968
4077
|
//let layout = getTopLevelCollection(this.anyItem) ? getTopLevelCollection(this.anyItem).layout : getClosestLayout(this.anyItem);
|
|
3969
|
-
|
|
4078
|
+
let layout = getClosestLayout(this.anyItem, "grid"), baseLayout = this.scale._baseItem ? getClosestLayout(this.scale._baseItem, "grid"): undefined;
|
|
4079
|
+
if (this.scale._baseItem && !sameClass(this.anyItem, this.scale._baseItem) && layout && baseLayout && layout.numRows === baseLayout.numRows && layout.numCols === baseLayout.numCols) {
|
|
4080
|
+
let tx = baseLayout.group.bounds.left - layout.group.bounds.left,
|
|
4081
|
+
ty = 0;
|
|
4082
|
+
layout.group.getScene().translate(layout.group, tx, ty);
|
|
4083
|
+
layout._colGap = baseLayout.colGap;
|
|
4084
|
+
let cellIndices = this.items.map(d => getCellIndexInLayout(d)),
|
|
4085
|
+
baseCellBounds = baseLayout.cellBounds;
|
|
4086
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
4087
|
+
let itm = this.items[i];
|
|
4088
|
+
let dx = baseCellBounds[cellIndices[i]].left + this.scale.map(this.data[i]) - itm[channel],
|
|
4089
|
+
dy = 0;
|
|
4090
|
+
itm._doTranslate(dx, dy);
|
|
4091
|
+
if (itm.type == "vertex" || itm.type == "segment")
|
|
4092
|
+
itm.parent._updateBounds();
|
|
4093
|
+
}
|
|
4094
|
+
this.anyItem.parent.getScene()._updateAncestorBounds(this.anyItem, this.items);
|
|
4095
|
+
} else if (layout && layout.type == LayoutType.Grid){
|
|
3970
4096
|
//do not use scale.offset, use cell bounds
|
|
3971
4097
|
for (let i = 0; i < this.items.length; i++) {
|
|
3972
4098
|
let itm = this.items[i], itmCb = getCellBoundsInLayout(itm);
|
|
@@ -4015,9 +4141,27 @@
|
|
|
4015
4141
|
}
|
|
4016
4142
|
|
|
4017
4143
|
} else {//channel y
|
|
4018
|
-
let layout = getClosestLayout(this.anyItem, "grid");
|
|
4019
4144
|
//let layout = getTopLevelCollection(this.anyItem) ? getTopLevelCollection(this.anyItem).layout : getClosestLayout(this.anyItem);
|
|
4020
|
-
|
|
4145
|
+
let layout = getClosestLayout(this.anyItem, "grid"), baseLayout = this.scale._baseItem ? getClosestLayout(this.scale._baseItem, "grid"): undefined;
|
|
4146
|
+
if (this.scale._baseItem && !sameClass(this.anyItem, this.scale._baseItem) && layout && baseLayout && layout.numRows === baseLayout.numRows && layout.numCols === baseLayout.numCols) {
|
|
4147
|
+
//if (this.scale._baseItem && !sameClass(this.anyItem, this.scale._baseItem) && baseLayout && baseLayout.numRows === 1) {
|
|
4148
|
+
//let peers = getPeers(this.scale._baseItem, this.scale._baseItem.parent.getScene());
|
|
4149
|
+
let tx = 0,
|
|
4150
|
+
ty = baseLayout.group.bounds.top - layout.group.bounds.top;
|
|
4151
|
+
layout.group.getScene().translate(layout.group, tx, ty);
|
|
4152
|
+
layout._rowGap = baseLayout.rowGap;
|
|
4153
|
+
let cellIndices = this.items.map(d => getCellIndexInLayout(d)),
|
|
4154
|
+
baseCellBounds = baseLayout.cellBounds;
|
|
4155
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
4156
|
+
let itm = this.items[i];
|
|
4157
|
+
let dx = 0,
|
|
4158
|
+
dy = baseCellBounds[cellIndices[i]].bottom - this.scale.map(this.data[i]) - itm[channel];
|
|
4159
|
+
itm._doTranslate(dx, dy);
|
|
4160
|
+
if (itm.type == "vertex" || itm.type == "segment")
|
|
4161
|
+
itm.parent._updateBounds();
|
|
4162
|
+
}
|
|
4163
|
+
this.anyItem.parent.getScene()._updateAncestorBounds(this.anyItem, this.items);
|
|
4164
|
+
} else if (layout && layout.type == LayoutType.Grid){
|
|
4021
4165
|
let cellBounds = this.items.map(d => getCellBoundsInLayout(d));
|
|
4022
4166
|
for (let i = 0; i < this.items.length; i++) {
|
|
4023
4167
|
let itm = this.items[i];
|
|
@@ -4739,7 +4883,7 @@
|
|
|
4739
4883
|
|
|
4740
4884
|
set aggregator(a) {
|
|
4741
4885
|
this._aggregator = a;
|
|
4742
|
-
this.scale = undefined;
|
|
4886
|
+
//this.scale = undefined;
|
|
4743
4887
|
this.run();
|
|
4744
4888
|
}
|
|
4745
4889
|
|
|
@@ -6408,7 +6552,7 @@
|
|
|
6408
6552
|
}
|
|
6409
6553
|
}
|
|
6410
6554
|
|
|
6411
|
-
if (this._item.type
|
|
6555
|
+
if (this._item.type === ItemType.Area || this._item.parent.type === ItemType.Area)
|
|
6412
6556
|
c = getCellBoundsInGridLayout(this._item);
|
|
6413
6557
|
|
|
6414
6558
|
if (c === undefined) {
|
|
@@ -6571,6 +6715,7 @@
|
|
|
6571
6715
|
this._orientation = "orientation" in args ? args["orientation"] :
|
|
6572
6716
|
this._channel === "x" || this._channel == "width" ? "bottom" : "left";
|
|
6573
6717
|
this._posArg = this._channel == "x" || this._channel == "width"? args["pathY"] : args["pathX"];
|
|
6718
|
+
this._padding = [ItemType.Line, ItemType.Path].indexOf(items[0].type) >= 0 ? 10 : 0;
|
|
6574
6719
|
|
|
6575
6720
|
this._item = items[0];
|
|
6576
6721
|
this._items = items;
|
|
@@ -6722,22 +6867,24 @@
|
|
|
6722
6867
|
let num = this._channel == "x" ? this._mlayout.numRows : this._mlayout.numCols;
|
|
6723
6868
|
if (this._channel == "x") {
|
|
6724
6869
|
let left = cb[0].left, numCols = this._mlayout.numCols;
|
|
6870
|
+
let padding = this._orientation === "bottom" ? this._padding : - this._padding;
|
|
6725
6871
|
for (let r = 0; r < num; r++){
|
|
6726
6872
|
this._rules.children[r]._setVertices([
|
|
6727
|
-
[left, this._posArg ? cb[r * numCols][this._orientation] + this._posArg - cb[0][this._orientation] : cb[r * numCols][this._orientation] ],
|
|
6728
|
-
[left + cb[0].width * numCols + this._mlayout.colGap * (numCols - 1), this._posArg ? cb[r * numCols][this._orientation] + this._posArg - cb[0][this._orientation] : cb[r * numCols][this._orientation]]
|
|
6873
|
+
[left, this._posArg ? cb[r * numCols][this._orientation] + this._posArg - cb[0][this._orientation] : cb[r * numCols][this._orientation] + padding],
|
|
6874
|
+
[left + cb[0].width * numCols + this._mlayout.colGap * (numCols - 1), this._posArg ? cb[r * numCols][this._orientation] + this._posArg - cb[0][this._orientation] : cb[r * numCols][this._orientation] + padding]
|
|
6729
6875
|
]);
|
|
6730
6876
|
}
|
|
6731
6877
|
} else {
|
|
6732
6878
|
let top = cb[0].top, numRows = this._mlayout.numRows;
|
|
6879
|
+
let padding = this._orientation === "left" ? this._padding : - this._padding;
|
|
6733
6880
|
for (let c = 0; c < num; c++){
|
|
6734
6881
|
// this._rules.children[c]._setVertices([
|
|
6735
6882
|
// [this._posArg ? cb[c * numRows][this._orientation] + this._posArg - cb[0][this._orientation] : cb[c * numRows][this._orientation], top ],
|
|
6736
6883
|
// [this._posArg ? cb[c * numRows][this._orientation] + this._posArg - cb[0][this._orientation] : cb[c * numRows][this._orientation], top + cb[0].height * numRows + this._mlayout.rowGap * (numRows - 1), ]
|
|
6737
6884
|
// ]);
|
|
6738
6885
|
this._rules.children[c]._setVertices([
|
|
6739
|
-
[this._posArg ? cb[c * numRows][this._orientation] + this._posArg - cb[0][this._orientation] : this._mlayout.group.bounds[this._orientation], top ],
|
|
6740
|
-
[this._posArg ? cb[c * numRows][this._orientation] + this._posArg - cb[0][this._orientation] : this._mlayout.group.bounds[this._orientation], top + cb[0].height * numRows + this._mlayout.rowGap * (numRows - 1)]
|
|
6886
|
+
[this._posArg ? cb[c * numRows][this._orientation] + this._posArg - cb[0][this._orientation] : this._mlayout.group.bounds[this._orientation] - padding, top ],
|
|
6887
|
+
[this._posArg ? cb[c * numRows][this._orientation] + this._posArg - cb[0][this._orientation] : this._mlayout.group.bounds[this._orientation] - padding, top + cb[0].height * numRows + this._mlayout.rowGap * (numRows - 1)]
|
|
6741
6888
|
]);
|
|
6742
6889
|
}
|
|
6743
6890
|
}
|
|
@@ -6764,9 +6911,10 @@
|
|
|
6764
6911
|
let cb = this._mlayout.cellBounds;
|
|
6765
6912
|
if (this._channel == "x") {
|
|
6766
6913
|
let dir = this._orientation == "bottom" ? 1 : -1;
|
|
6914
|
+
let padding = this._orientation === "bottom" ? this._padding : - this._padding;
|
|
6767
6915
|
for (let [i, t] of this._ticks.children.entries()) {
|
|
6768
6916
|
let pos = this._posArg ? cb[i][this._orientation] + this._posArg - cb[0][this._orientation] + this._tickOffset * dir :
|
|
6769
|
-
cb[i][this._orientation] + this._tickOffset * dir;
|
|
6917
|
+
cb[i][this._orientation] + this._tickOffset * dir + padding;
|
|
6770
6918
|
t._setVertices([
|
|
6771
6919
|
[cb[i].x, pos],
|
|
6772
6920
|
[cb[i].x, pos + dir * this._tickSize]
|
|
@@ -6775,11 +6923,12 @@
|
|
|
6775
6923
|
}
|
|
6776
6924
|
} else if (this._channel == "y"){
|
|
6777
6925
|
let dir = this._orientation == "left" ? -1 : 1;
|
|
6926
|
+
let padding = this._orientation === "left" ? this._padding : - this._padding;
|
|
6778
6927
|
for (let [i, t] of this._ticks.children.entries()) {
|
|
6779
6928
|
// let xPos = this._posArg ? cb[i][this._orientation] + this._posArg - cb[0][this._orientation] + this._tickOffset * dir :
|
|
6780
6929
|
// cb[i][this._orientation] + this._tickOffset * dir,
|
|
6781
6930
|
let xPos = this._posArg ? cb[i][this._orientation] + this._posArg - cb[0][this._orientation] + this._tickOffset * dir :
|
|
6782
|
-
this._mlayout.group.bounds[this._orientation] + this._tickOffset * dir,
|
|
6931
|
+
this._mlayout.group.bounds[this._orientation] + this._tickOffset * dir - padding,
|
|
6783
6932
|
yPos = this._tickAnchor == "middle" ? cb[i].y : cb[i][this._tickAnchor];
|
|
6784
6933
|
t._setVertices([
|
|
6785
6934
|
[xPos, yPos],
|
|
@@ -6797,10 +6946,11 @@
|
|
|
6797
6946
|
if (this._channel == "x") {
|
|
6798
6947
|
let anchor = this._orientation == "bottom" ? ["center", "top"] : ["center", "bottom"],
|
|
6799
6948
|
offset = this._orientation == "bottom" ? this._labelOffset : -this._labelOffset;
|
|
6949
|
+
let padding = this._orientation === "bottom" ? this._padding : - this._padding;
|
|
6800
6950
|
for (let [i, l] of this._labels.children.entries()) {
|
|
6801
6951
|
l.x = cb[i].x;
|
|
6802
6952
|
l.y = this._posArg ? cb[i][this._orientation] + this._posArg - cb[0][this._orientation] + offset :
|
|
6803
|
-
cb[i][this._orientation] + offset;
|
|
6953
|
+
cb[i][this._orientation] + offset + padding;
|
|
6804
6954
|
l.anchor = anchor;
|
|
6805
6955
|
if (this._labelRotation){
|
|
6806
6956
|
l._rotate = [this._labelRotation, l.x, l.y];
|
|
@@ -6811,11 +6961,12 @@
|
|
|
6811
6961
|
} else if (this._channel == "y"){
|
|
6812
6962
|
let anchor = this._orientation == "left" ? ["right", "middle"] : ["left", "middle"],
|
|
6813
6963
|
offset = this._orientation == "left" ? - this._labelOffset : this._labelOffset;
|
|
6964
|
+
let padding = this._orientation === "left" ? this._padding : - this._padding;
|
|
6814
6965
|
for (let [i, l] of this._labels.children.entries()) {
|
|
6815
6966
|
// l.x = this._posArg ? cb[i][this._orientation] + this._posArg - cb[0][this._orientation] + offset
|
|
6816
6967
|
// : cb[i][this._orientation] + offset;
|
|
6817
6968
|
l.x = this._posArg ? cb[i][this._orientation] + this._posArg - cb[0][this._orientation] + offset
|
|
6818
|
-
: this._mlayout.group.bounds[this._orientation] + offset;
|
|
6969
|
+
: this._mlayout.group.bounds[this._orientation] + offset - padding;
|
|
6819
6970
|
l.y = this._tickAnchor == "middle" ? cb[i].y : cb[i][this._tickAnchor];
|
|
6820
6971
|
l.anchor = anchor;
|
|
6821
6972
|
if (this._labelRotation) {
|
|
@@ -6855,7 +7006,8 @@
|
|
|
6855
7006
|
}
|
|
6856
7007
|
|
|
6857
7008
|
matches(item) {
|
|
6858
|
-
return
|
|
7009
|
+
return sameClass(this._item, item);
|
|
7010
|
+
//return getEncodingKey(this._item).split("_")[0] === getEncodingKey(item).split("_")[0];
|
|
6859
7011
|
}
|
|
6860
7012
|
}
|
|
6861
7013
|
|
|
@@ -6982,17 +7134,18 @@
|
|
|
6982
7134
|
for (let i = 0; i < uniqueVals.length; i+= Math.ceil(uniqueVals.length/10))
|
|
6983
7135
|
stops.push(uniqueVals[i]);
|
|
6984
7136
|
} else {
|
|
6985
|
-
let
|
|
7137
|
+
let incr = (domain[1] - domain[0])/9;
|
|
6986
7138
|
for (let i = 0; i < 10; i++)
|
|
6987
|
-
stops.push(domain[0] + i *
|
|
6988
|
-
let decimalPlaces = 0;
|
|
6989
|
-
while (interval < 1) {
|
|
6990
|
-
interval *= 10;
|
|
6991
|
-
decimalPlaces++;
|
|
6992
|
-
}
|
|
6993
|
-
stops = stops.map(d => d.toFixed(decimalPlaces));
|
|
7139
|
+
stops.push(domain[0] + i * incr);
|
|
6994
7140
|
}
|
|
6995
7141
|
}
|
|
7142
|
+
//determine decimal places
|
|
7143
|
+
let decimalPlaces = 0, interval = (stops[stops.length - 1] - stops[0])/stops.length;
|
|
7144
|
+
while (interval < 1) {
|
|
7145
|
+
interval *= 10;
|
|
7146
|
+
decimalPlaces++;
|
|
7147
|
+
}
|
|
7148
|
+
stops = stops.map(d => d.toFixed(decimalPlaces));
|
|
6996
7149
|
if (this._orientation == Orientation.Vertical) {
|
|
6997
7150
|
gradient = new LinearGradient({x1: 0, y1: 100, x2: 0, y2: 0});
|
|
6998
7151
|
stops.forEach(d => {
|
|
@@ -8343,7 +8496,7 @@
|
|
|
8343
8496
|
}
|
|
8344
8497
|
|
|
8345
8498
|
for (let enc of scale.encodings) {
|
|
8346
|
-
enc.scene.
|
|
8499
|
+
enc.scene._relayoutAncestors(enc.item, enc.items);
|
|
8347
8500
|
}
|
|
8348
8501
|
//reapply constraints
|
|
8349
8502
|
let items = scale.encodings.map( d => d.anyItem), classId2item = {};
|
|
@@ -9106,7 +9259,7 @@
|
|
|
9106
9259
|
}
|
|
9107
9260
|
|
|
9108
9261
|
if (layout)
|
|
9109
|
-
|
|
9262
|
+
scene.setProperties(c.firstChild, {layout: layout});
|
|
9110
9263
|
//return results;
|
|
9111
9264
|
}
|
|
9112
9265
|
|
|
@@ -9450,7 +9603,7 @@
|
|
|
9450
9603
|
if (!("datatable" in args))
|
|
9451
9604
|
args.datatable = item.dataScope ? item.dataScope.dataTable : item.parent.dataScope.dataTable;
|
|
9452
9605
|
if (!("aggregator" in args))
|
|
9453
|
-
args.aggregator = "
|
|
9606
|
+
args.aggregator = "mean";
|
|
9454
9607
|
if (!("flipScale" in args))
|
|
9455
9608
|
args.flipScale = false;
|
|
9456
9609
|
if (!("includeZero" in args))
|
|
@@ -9595,7 +9748,7 @@
|
|
|
9595
9748
|
axis(channel, field, params) {
|
|
9596
9749
|
//need to figure out if item has the corresponding encoding, or if item position is determined by layout
|
|
9597
9750
|
let args = params ? params : {}, enc = args.item ? this.getEncodingByItem(args.item, channel) : this.getEncodingByField(field, channel);
|
|
9598
|
-
if (enc) {
|
|
9751
|
+
if (enc && enc.field === field) {
|
|
9599
9752
|
if (enc.datatable.getFieldType(field) === DataType.Date && !("labelFormat" in args)) {
|
|
9600
9753
|
args.labelFormat = "%m/%d/%y";
|
|
9601
9754
|
}
|
|
@@ -9627,8 +9780,8 @@
|
|
|
9627
9780
|
let item = args.item? args.item : findItems(this, [{"field": field}])[0];
|
|
9628
9781
|
if (item === undefined) {
|
|
9629
9782
|
console.warn(Warnings.INCORRECT_AXIS_INFO + field);
|
|
9783
|
+
return;
|
|
9630
9784
|
}
|
|
9631
|
-
|
|
9632
9785
|
let layout = getClosestLayout(item);
|
|
9633
9786
|
if (!layout || (layout.type !== LayoutType.Grid && layout.type !== LayoutType.Stack)) return;
|
|
9634
9787
|
|
|
@@ -9674,7 +9827,7 @@
|
|
|
9674
9827
|
let p = c._item, found = false;
|
|
9675
9828
|
while (p.children && p.children.length > 0) {
|
|
9676
9829
|
for (let ic of p.children) {
|
|
9677
|
-
if (ic.classId === item.
|
|
9830
|
+
if (ic.classId === getEncodingKey(item).split("_")[0]) {
|
|
9678
9831
|
found = true;
|
|
9679
9832
|
axes.push(c);
|
|
9680
9833
|
break;
|
|
@@ -10797,6 +10950,8 @@
|
|
|
10797
10950
|
|
|
10798
10951
|
if (this._mapping)
|
|
10799
10952
|
json.mapping = this._mapping;
|
|
10953
|
+
if (this._baseItem)
|
|
10954
|
+
json.baseItem = this._baseItem.id;
|
|
10800
10955
|
return json;
|
|
10801
10956
|
}
|
|
10802
10957
|
|
|
@@ -11808,7 +11963,7 @@
|
|
|
11808
11963
|
return scn;
|
|
11809
11964
|
}
|
|
11810
11965
|
|
|
11811
|
-
_loadScale(s) {
|
|
11966
|
+
_loadScale(s, scn) {
|
|
11812
11967
|
let scale;
|
|
11813
11968
|
// if (s.type === "sequentialColor" && s.scheme) {
|
|
11814
11969
|
if (s.type.indexOf("Color") > 0 && s.scheme) {
|
|
@@ -11826,6 +11981,8 @@
|
|
|
11826
11981
|
scale._mapping = s.mapping;
|
|
11827
11982
|
if ("includeZero" in s)
|
|
11828
11983
|
scale.includeZero = s.includeZero;
|
|
11984
|
+
if ("baseItem" in s)
|
|
11985
|
+
scale._baseItem = scn.getItem(s.baseItem);
|
|
11829
11986
|
this.scales[scale.id] = scale;
|
|
11830
11987
|
//console.log(scale.domain, scale.range);
|
|
11831
11988
|
}
|
|
@@ -11839,6 +11996,7 @@
|
|
|
11839
11996
|
//let item = scene.getItem(enc.anyItem);
|
|
11840
11997
|
let items = enc.items.map(d => scene.getItem(d));
|
|
11841
11998
|
scene._doEncode(items, enc.args);
|
|
11999
|
+
scene._relayoutAncestors(items[0], items);
|
|
11842
12000
|
}
|
|
11843
12001
|
|
|
11844
12002
|
_createGuide(scene, guide) {
|
|
@@ -24115,7 +24273,13 @@
|
|
|
24115
24273
|
}
|
|
24116
24274
|
|
|
24117
24275
|
function canRepeat(compnt) {
|
|
24118
|
-
if ((
|
|
24276
|
+
if (Array.isArray(compnt)) {
|
|
24277
|
+
for (let c of compnt) {
|
|
24278
|
+
if (!isMark(c) || c.dataScope)
|
|
24279
|
+
return false;
|
|
24280
|
+
}
|
|
24281
|
+
return true;
|
|
24282
|
+
} else if ((isMark(compnt) || compnt.type == ItemType.Glyph) && !compnt.dataScope) {
|
|
24119
24283
|
return true;
|
|
24120
24284
|
} else if (compnt.type == ItemType.Collection) {
|
|
24121
24285
|
//TODO: check if repeatable
|
|
@@ -24125,9 +24289,13 @@
|
|
|
24125
24289
|
}
|
|
24126
24290
|
|
|
24127
24291
|
function canDivide(compnt) {
|
|
24128
|
-
if ([ItemType.Line, ItemType.Circle, ItemType.Rect, ItemType.Area, ItemType.Ring, ItemType.Pie].indexOf(compnt.type) < 0) {
|
|
24292
|
+
if ([ItemType.Line, ItemType.Circle, ItemType.Rect, ItemType.Area, ItemType.Ring, ItemType.Pie, ItemType.Path].indexOf(compnt.type) < 0) {
|
|
24129
24293
|
return false;
|
|
24130
24294
|
}
|
|
24295
|
+
|
|
24296
|
+
if (compnt.type === ItemType.Path && (compnt.closed || !compnt.firstVertex.dataScope))
|
|
24297
|
+
return false;
|
|
24298
|
+
|
|
24131
24299
|
if (!compnt.dataScope) {
|
|
24132
24300
|
return true;
|
|
24133
24301
|
} else {
|
|
@@ -24146,8 +24314,7 @@
|
|
|
24146
24314
|
}
|
|
24147
24315
|
if (!compnt.dataScope) {
|
|
24148
24316
|
return true;
|
|
24149
|
-
}
|
|
24150
|
-
else {
|
|
24317
|
+
} else {
|
|
24151
24318
|
let peers = getPeers(compnt, compnt.getScene());
|
|
24152
24319
|
for (let p of peers) {
|
|
24153
24320
|
if (p.dataScope.numTuples > 1)
|