Skip to content

Commit c947b2c

Browse files
committed
only override grid.(x|y)side default for sploms w/o lower half
- this way, the Grid component can generate axes with set 'anchor' for all sploms except when `showlowerhalf: false`. Having set anchored axes is a performance boost (~40ms at 50 dimensions).
1 parent e69b7dd commit c947b2c

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

Diff for: src/components/grid/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,9 @@ function sizeDefaults(layoutIn, layoutOut) {
225225
var dfltGapY = hasSubplotGrid ? 0.3 : 0.1;
226226

227227
var dfltSideX, dfltSideY;
228-
if(isSplomGenerated) {
229-
dfltSideX = 'bottom';
230-
dfltSideY = 'left';
228+
if(isSplomGenerated && layoutOut._splomGridDflt) {
229+
dfltSideX = layoutOut._splomGridDflt.xside;
230+
dfltSideY = layoutOut._splomGridDflt.yside;
231231
}
232232

233233
gridOut._domains = {

Diff for: src/plots/plots.js

+2
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,8 @@ plots.supplyDefaults = function(gd, opts) {
382382
// initialize axis and subplot hash objects for splom-generated grids
383383
var splomAxes = newFullLayout._splomAxes = {x: {}, y: {}};
384384
var splomSubplots = newFullLayout._splomSubplots = {};
385+
// initialize splom grid defaults
386+
newFullLayout._splomGridDflt = {};
385387

386388
// for traces to request a default rangeslider on their x axes
387389
// eg set `_requestRangeslider.x2 = true` for xaxis2

Diff for: src/traces/splom/defaults.js

+7
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ function handleAxisDefaults(traceIn, traceOut, layout, coerce) {
150150
// note that some the entries here may be undefined
151151
diag[i] = [xa, ya];
152152
}
153+
154+
// when lower half is omitted, override grid default
155+
// to make sure axes remain on the left/bottom of the plot area
156+
if(!showLower) {
157+
layout._splomGridDflt.xside = 'bottom';
158+
layout._splomGridDflt.yside = 'left';
159+
}
153160
}
154161

155162
function fillAxisIdArray(axLetter, len) {

Diff for: test/jasmine/tests/splom_test.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,35 @@ describe('Test splom trace defaults:', function() {
100100
expect(subplots.cartesian).toEqual(['xy', 'xy2', 'x2y', 'x2y2']);
101101
});
102102

103-
it('should use special `grid.xside` and `grid.yside` defaults on splom generated grids', function() {
103+
it('should use special `grid.xside` and `grid.yside` defaults on splom w/o lower half generated grids', function() {
104104
var gridOut;
105105

106+
// base case
106107
_supply({
107108
dimensions: [
108109
{values: [1, 2, 3]},
109110
{values: [2, 1, 2]}
110111
]
111112
});
112113

114+
gridOut = gd._fullLayout.grid;
115+
expect(gridOut.xside).toBe('bottom plot');
116+
expect(gridOut.yside).toBe('left plot');
117+
118+
// w/o lower half case
119+
_supply({
120+
dimensions: [
121+
{values: [1, 2, 3]},
122+
{values: [2, 1, 2]}
123+
],
124+
showlowerhalf: false
125+
});
126+
113127
gridOut = gd._fullLayout.grid;
114128
expect(gridOut.xside).toBe('bottom');
115129
expect(gridOut.yside).toBe('left');
116130

131+
// non-splom generated grid
117132
_supply({
118133
dimensions: [
119134
{values: [1, 2, 3]},

0 commit comments

Comments
 (0)