Skip to content

Commit b2ee736

Browse files
committed
Merge branch 'splom-feature' into splom-zoom-perf
2 parents f9090b7 + 129e1f2 commit b2ee736

26 files changed

+3283
-191
lines changed

package-lock.json

Lines changed: 3 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"regl": "^1.3.1",
101101
"regl-error2d": "^2.0.3",
102102
"regl-line2d": "github:dy/regl-line2d",
103-
"regl-scatter2d": "^3.0.0",
103+
"regl-scatter2d": "github:dy/regl-scatter2d",
104104
"regl-scattermatrix": "github:dy/regl-scattermatrix",
105105
"right-now": "^1.0.0",
106106
"robust-orientation": "^1.1.3",

src/components/grid/index.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ function sizeDefaults(layoutIn, layoutOut) {
185185
var hasSubplotGrid = Array.isArray(gridIn.subplots) && Array.isArray(gridIn.subplots[0]);
186186
var hasXaxes = Array.isArray(xAxes);
187187
var hasYaxes = Array.isArray(yAxes);
188+
var isSplomGenerated = (
189+
hasXaxes && xAxes !== gridIn.xaxes &&
190+
hasYaxes && yAxes !== gridIn.yaxes
191+
);
188192

189193
var dfltRows, dfltColumns;
190194

@@ -217,17 +221,26 @@ function sizeDefaults(layoutIn, layoutOut) {
217221
var rowOrder = coerce('roworder');
218222
var reversed = rowOrder === 'top to bottom';
219223

224+
var dfltGapX = hasSubplotGrid ? 0.2 : 0.1;
225+
var dfltGapY = hasSubplotGrid ? 0.3 : 0.1;
226+
227+
var dfltSideX, dfltSideY;
228+
if(isSplomGenerated) {
229+
dfltSideX = 'bottom';
230+
dfltSideY = 'left';
231+
}
232+
220233
gridOut._domains = {
221-
x: fillGridPositions('x', coerce, hasSubplotGrid ? 0.2 : 0.1, columns),
222-
y: fillGridPositions('y', coerce, hasSubplotGrid ? 0.3 : 0.1, rows, reversed)
234+
x: fillGridPositions('x', coerce, dfltGapX, dfltSideX, columns),
235+
y: fillGridPositions('y', coerce, dfltGapY, dfltSideY, rows, reversed)
223236
};
224237
}
225238

226239
// coerce x or y sizing attributes and return an array of domains for this direction
227-
function fillGridPositions(axLetter, coerce, dfltGap, len, reversed) {
240+
function fillGridPositions(axLetter, coerce, dfltGap, dfltSide, len, reversed) {
228241
var dirGap = coerce(axLetter + 'gap', dfltGap);
229242
var domain = coerce('domain.' + axLetter);
230-
coerce(axLetter + 'side');
243+
coerce(axLetter + 'side', dfltSide);
231244

232245
var out = new Array(len);
233246
var start = domain[0];

src/components/legend/style.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ module.exports = function style(s, gd) {
8383
function stylePoints(d) {
8484
var d0 = d[0],
8585
trace = d0.trace,
86-
showMarkers = subTypes.hasMarkers(trace),
86+
showMarkers = subTypes.hasMarkers(trace) || trace.type === 'splom',
8787
showText = subTypes.hasText(trace),
8888
showLines = subTypes.hasLines(trace);
8989

src/plots/cartesian/select.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
4545
yAxisIds = dragOptions.yaxes.map(getAxId),
4646
allAxes = dragOptions.xaxes.concat(dragOptions.yaxes),
4747
filterPoly, testPoly, mergedPolygons, currentPolygon,
48-
subtract = e.altKey;
48+
subtract = e.altKey,
49+
i, cd, trace, searchInfo, eventData;
4950

5051

5152
// take over selection polygons from prev mode, if any
@@ -63,6 +64,20 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
6364
if(mode === 'lasso') {
6465
filterPoly = filteredPolygon([[x0, y0]], constants.BENDPX);
6566
}
67+
68+
// FIXME: find a better way to clear selection outlines for splom
69+
if(!e.shiftKey && !e.altKey) {
70+
for(i = 0; i < gd.calcdata.length; i++) {
71+
cd = gd.calcdata[i];
72+
trace = cd[0].trace;
73+
74+
if(trace.type === 'splom') {
75+
zoomLayer.selectAll('.select-outline').remove();
76+
break;
77+
}
78+
}
79+
}
80+
6681
var outlines = zoomLayer.selectAll('path.select-outline-' + plotinfo.id).data([1, 2]);
6782

6883
outlines.enter()
@@ -86,7 +101,6 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
86101
var searchTraces = [];
87102
var throttleID = fullLayout._uid + constants.SELECTID;
88103
var selection = [];
89-
var i, cd, trace, searchInfo, eventData;
90104

91105
for(i = 0; i < gd.calcdata.length; i++) {
92106
cd = gd.calcdata[i];
@@ -355,6 +369,9 @@ function updateSelectedState(gd, searchTraces, eventData) {
355369
searchTraces[i].cd[0].t.scene.clearSelect();
356370
}
357371
}
372+
373+
// FIXME: make sure there is no better way to clear selection for sploms
374+
gd._fullLayout._zoomlayer.selectAll('.select-outline').remove();
358375
}
359376

360377
for(i = 0; i < searchTraces.length; i++) {

src/plots/plots.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ plots.supplyDefaults = function(gd) {
291291

292292
var context = gd._context || {};
293293

294-
var i, j;
294+
var i;
295295

296296
// Create all the storage space for frames, but only if doesn't already exist
297297
if(!gd._transitionData) plots.createTransitionData(gd);
@@ -366,7 +366,10 @@ plots.supplyDefaults = function(gd) {
366366
newFullLayout._modules = [];
367367
newFullLayout._basePlotModules = [];
368368
var subplots = newFullLayout._subplots = emptySubplotLists();
369+
370+
// initialize axis and subplot hash objects for splom-generated grids
369371
var splomAxes = newFullLayout._splomAxes = {x: {}, y: {}};
372+
var splomSubplots = newFullLayout._splomSubplots = {};
370373

371374
// then do the data
372375
newFullLayout._globalTransforms = (gd._context || {}).globalTransforms;
@@ -381,10 +384,12 @@ plots.supplyDefaults = function(gd) {
381384

382385
for(i = 0; i < splomXa.length; i++) {
383386
Lib.pushUnique(subplots.xaxis, splomXa[i]);
384-
for(j = 0; j < splomYa.length; j++) {
385-
if(i === 0) Lib.pushUnique(subplots.yaxis, splomYa[j]);
386-
Lib.pushUnique(subplots.cartesian, splomXa[i] + splomYa[j]);
387-
}
387+
}
388+
for(i = 0; i < splomYa.length; i++) {
389+
Lib.pushUnique(subplots.yaxis, splomYa[i]);
390+
}
391+
for(var k in splomSubplots) {
392+
Lib.pushUnique(subplots.cartesian, k);
388393
}
389394
}
390395

src/traces/scattergl/convert.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ function convertStyle(gd, trace) {
5050
opts.unselected.opacity[i] = DESELECTDIM * mo[i];
5151
}
5252
}
53+
54+
// FIXME: if only trace.selected provided, trace.unselected remains empty
55+
// cc @etienne
5356
}
5457

5558
if(subTypes.hasLines(trace)) {
@@ -402,6 +405,7 @@ function convertErrorBarPositions(gd, trace, positions) {
402405
module.exports = {
403406
convertStyle: convertStyle,
404407
convertMarkerStyle: convertMarkerStyle,
408+
convertMarkerSelection: convertMarkerSelection,
405409
convertLinePositions: convertLinePositions,
406410
convertErrorBarPositions: convertErrorBarPositions
407411
};

src/traces/splom/attributes.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,11 @@ module.exports = {
6868
editType: 'calc+clearAxisTypes'
6969
},
7070

71-
mode: scatterGlAttrs.mode,
72-
text: scatterGlAttrs.text,
71+
// mode: {}, (only 'markers' for now)
7372

73+
text: scatterGlAttrs.text,
7474
marker: scatterGlAttrs.marker,
7575

76-
line: scatterGlAttrs.line,
77-
connectgaps: scatterGlAttrs.connectgaps,
78-
7976
xaxes: makeAxesValObject('x'),
8077
yaxes: makeAxesValObject('y'),
8178

@@ -84,7 +81,7 @@ module.exports = {
8481
valType: 'boolean',
8582
role: 'info',
8683
dflt: true,
87-
editType: 'plot',
84+
editType: 'calc',
8885
description: [
8986
'Determines whether or not subplots on the diagonal are displayed.'
9087
].join(' ')
@@ -101,7 +98,7 @@ module.exports = {
10198
valType: 'boolean',
10299
role: 'info',
103100
dflt: true,
104-
editType: 'plot',
101+
editType: 'calc',
105102
description: [
106103
'Determines whether or not subplots on the upper half',
107104
'from the diagonal are displayed.'
@@ -111,15 +108,19 @@ module.exports = {
111108
valType: 'boolean',
112109
role: 'info',
113110
dflt: true,
114-
editType: 'plot',
111+
editType: 'calc',
115112
description: [
116113
'Determines whether or not subplots on the lower half',
117114
'from the diagonal are displayed.'
118115
].join(' ')
119116
},
120117

121-
selected: scatterGlAttrs.selected,
122-
unselected: scatterGlAttrs.unselected,
118+
selected: {
119+
marker: scatterGlAttrs.selected.marker
120+
},
121+
unselected: {
122+
marker: scatterGlAttrs.unselected.marker
123+
},
123124

124125
opacity: scatterGlAttrs.opacity
125126
};

src/traces/splom/base_plot.js

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,52 @@ function drag(gd) {
3737
var cd = gd.calcdata;
3838
var fullLayout = gd._fullLayout;
3939

40+
if(fullLayout._hasOnlyLargeSploms) {
41+
drawGrid(gd);
42+
}
43+
4044
for(var i = 0; i < cd.length; i++) {
4145
var cd0 = cd[i][0];
4246
var trace = cd0.trace;
4347
var scene = cd0.t._scene;
4448

4549
if(trace.type === 'splom' && scene && scene.matrix) {
46-
var activeLength = trace._activeLength;
47-
var visibleLength = scene.matrixOptions.data.length;
48-
var ranges = new Array(visibleLength);
49-
var k = 0;
50-
51-
for(var j = 0; j < activeLength; j++) {
52-
if(trace.dimensions[j].visible) {
53-
var xrng = AxisIDs.getFromId(gd, trace.xaxes[j]).range;
54-
var yrng = AxisIDs.getFromId(gd, trace.yaxes[j]).range;
55-
ranges[k++] = [xrng[0], yrng[0], xrng[1], yrng[1]];
56-
}
50+
dragOne(gd, trace, scene);
51+
}
52+
}
53+
}
54+
55+
function dragOne(gd, trace, scene) {
56+
var dimensions = trace.dimensions;
57+
var visibleLength = scene.matrixOptions.data.length;
58+
var ranges = new Array(visibleLength);
59+
60+
for(var i = 0, k = 0; i < dimensions.length; i++) {
61+
if(dimensions[i].visible) {
62+
var rng = ranges[k] = new Array(4);
63+
64+
var xa = AxisIDs.getFromId(gd, trace._diag[i][0]);
65+
if(xa) {
66+
rng[0] = xa.range[0];
67+
rng[2] = xa.range[1];
5768
}
5869

59-
scene.matrix.update({ranges: ranges});
60-
scene.matrix.draw();
70+
var ya = AxisIDs.getFromId(gd, trace._diag[i][1]);
71+
if(ya) {
72+
rng[1] = ya.range[0];
73+
rng[3] = ya.range[1];
74+
}
75+
76+
k++;
6177
}
6278
}
6379

64-
if(fullLayout._hasOnlyLargeSploms) {
65-
drawGrid(gd);
80+
if(scene.selectBatch) {
81+
scene.matrix.update({ranges: ranges}, {ranges: ranges});
82+
scene.matrix.draw(scene.unselectBatch, scene.selectBatch);
83+
} else {
84+
scene.matrix.update({ranges: ranges});
85+
scene.matrix.draw();
6686
}
6787
}
6888

0 commit comments

Comments
 (0)