Skip to content

Commit ce379a1

Browse files
committed
1st cut showupperhalf / showlowerhalf
- bug-free version of diagonal.visible still to come
1 parent 92a37c8 commit ce379a1

File tree

7 files changed

+1448
-18
lines changed

7 files changed

+1448
-18
lines changed

src/plots/plots.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ plots.supplyDefaults = function(gd) {
367367
newFullLayout._basePlotModules = [];
368368
var subplots = newFullLayout._subplots = emptySubplotLists();
369369
var splomAxes = newFullLayout._splomAxes = {x: {}, y: {}};
370+
var splomSubplots = newFullLayout._splomSubplots = {}
370371

371372
// then do the data
372373
newFullLayout._globalTransforms = (gd._context || {}).globalTransforms;
@@ -381,10 +382,12 @@ plots.supplyDefaults = function(gd) {
381382

382383
for(i = 0; i < splomXa.length; i++) {
383384
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-
}
385+
}
386+
for(i = 0; i < splomYa.length; i++) {
387+
Lib.pushUnique(subplots.yaxis, splomYa[i]);
388+
}
389+
for(var k in splomSubplots) {
390+
Lib.pushUnique(subplots.cartesian, k);
388391
}
389392
}
390393

src/traces/splom/defaults.js

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,15 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
4747
coerce('marker.line.width', isOpen || isBubble ? 1 : 0);
4848
}
4949

50-
handleAxisDefaults(traceIn, traceOut, layout, coerce);
50+
// TODO if all 3 below are false,
51+
// should we set `visible: false` and exit early?
5152

52-
// TODO not implemented yet
5353
coerce('diagonal.visible');
54-
// more to come
55-
56-
// TODO not implemented yet
5754
coerce('showupperhalf');
5855
coerce('showlowerhalf');
5956

57+
handleAxisDefaults(traceIn, traceOut, layout, coerce);
58+
6059
Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
6160
};
6261

@@ -111,7 +110,15 @@ function handleAxisDefaults(traceIn, traceOut, layout, coerce) {
111110
var dimLength = dimensions.length;
112111
var xaxesDflt = new Array(dimLength);
113112
var yaxesDflt = new Array(dimLength);
114-
var i;
113+
var i, j;
114+
115+
var showUpper = traceOut.showupperhalf;
116+
var showLower = traceOut.showlowerhalf;
117+
var showDiagonal = traceOut.diagonal.visible;
118+
119+
// var axLen = !showDiagonal && (!showUpper || !showLower) ?
120+
// dimLength - 1 :
121+
// dimLength;
115122

116123
for(i = 0; i < dimLength; i++) {
117124
xaxesDflt[i] = 'x' + (i ? i + 1 : '');
@@ -146,4 +153,20 @@ function handleAxisDefaults(traceIn, traceOut, layout, coerce) {
146153
layout._splomAxes.y[ya] = dim.label || '';
147154
}
148155
}
156+
157+
for(i = 0; i < activeLength; i++) {
158+
for(j = 0; j < activeLength; j++) {
159+
var id = [xaxes[i] + yaxes[j]];
160+
161+
if(i > j && showUpper) {
162+
layout._splomSubplots[id] = 1;
163+
} else if(i < j && showLower) {
164+
layout._splomSubplots[id] = 1;
165+
} else if(i === j && showDiagonal) {
166+
layout._splomSubplots[id] = 1;
167+
}
168+
}
169+
}
170+
171+
// console.log(Object.keys(layout._splomSubplots))
149172
}

src/traces/splom/index.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ function calc(gd, trace) {
7474
}
7575
}
7676

77-
// augment options with proper upper/lower halves
78-
if(!trace.showupperhalf) opts.upper = false;
79-
if(!trace.showlowerhalf) opts.lower = false;
80-
if(!trace.diagonal.visible) opts.diagonal = false;
81-
8277
var scene = stash._scene = sceneUpdate(gd, stash);
8378
if(!scene.matrix) scene.matrix = true;
8479
scene.matrixOptions = opts;
@@ -175,13 +170,20 @@ function plotOne(gd, cd0) {
175170
var trace = cd0.trace;
176171
var stash = cd0.t;
177172
var scene = stash._scene;
178-
var matrixData = scene.matrixOptions.data;
173+
var matrixOpts = scene.matrixOptions;
174+
var matrixData = matrixOpts.data;
179175
var regl = fullLayout._glcanvas.data()[0].regl;
180176
var dragmode = fullLayout.dragmode;
181177
var xa, ya;
182178

183179
if(matrixData.length === 0) return;
184180

181+
// augment options with proper upper/lower halves
182+
matrixOpts.upper = trace.showupperhalf;
183+
matrixOpts.lower = trace.showlowerhalf;
184+
matrixOpts.diagonal = trace.diagonal.visible;
185+
186+
console.log(matrixOpts.upper, matrixOpts.lower)
185187

186188
var k = 0, i;
187189
var activeLength = trace._activeLength;
@@ -257,7 +259,7 @@ function plotOne(gd, cd0) {
257259

258260

259261
if(scene.selectBatch) {
260-
scene.matrix.update(scene.matrixOptions, scene.matrixOptions);
262+
scene.matrix.update(matrixOpts, matrixOpts);
261263
scene.matrix.update(scene.unselectedOptions, scene.selectedOptions);
262264
scene.matrix.update(viewOpts, viewOpts);
263265
}
@@ -267,7 +269,7 @@ function plotOne(gd, cd0) {
267269
}
268270
}
269271
else {
270-
scene.matrix.update(scene.matrixOptions);
272+
scene.matrix.update(matrixOpts);
271273
scene.matrix.update(viewOpts);
272274
stash.xpx = stash.ypx = null;
273275
}

test/image/baselines/splom_lower.png

50.7 KB
Loading

test/image/baselines/splom_upper.png

51.2 KB
Loading

0 commit comments

Comments
 (0)