Skip to content

Commit

Permalink
only override grid.(x|y)side default for sploms w/o lower half
Browse files Browse the repository at this point in the history
- 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).
  • Loading branch information
etpinard committed May 11, 2018
1 parent e69b7dd commit c947b2c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/components/grid/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ function sizeDefaults(layoutIn, layoutOut) {
var dfltGapY = hasSubplotGrid ? 0.3 : 0.1;

var dfltSideX, dfltSideY;
if(isSplomGenerated) {
dfltSideX = 'bottom';
dfltSideY = 'left';
if(isSplomGenerated && layoutOut._splomGridDflt) {
dfltSideX = layoutOut._splomGridDflt.xside;
dfltSideY = layoutOut._splomGridDflt.yside;
}

gridOut._domains = {
Expand Down
2 changes: 2 additions & 0 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,8 @@ plots.supplyDefaults = function(gd, opts) {
// initialize axis and subplot hash objects for splom-generated grids
var splomAxes = newFullLayout._splomAxes = {x: {}, y: {}};
var splomSubplots = newFullLayout._splomSubplots = {};
// initialize splom grid defaults
newFullLayout._splomGridDflt = {};

// for traces to request a default rangeslider on their x axes
// eg set `_requestRangeslider.x2 = true` for xaxis2
Expand Down
7 changes: 7 additions & 0 deletions src/traces/splom/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ function handleAxisDefaults(traceIn, traceOut, layout, coerce) {
// note that some the entries here may be undefined
diag[i] = [xa, ya];
}

// when lower half is omitted, override grid default
// to make sure axes remain on the left/bottom of the plot area
if(!showLower) {
layout._splomGridDflt.xside = 'bottom';
layout._splomGridDflt.yside = 'left';
}
}

function fillAxisIdArray(axLetter, len) {
Expand Down
17 changes: 16 additions & 1 deletion test/jasmine/tests/splom_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,35 @@ describe('Test splom trace defaults:', function() {
expect(subplots.cartesian).toEqual(['xy', 'xy2', 'x2y', 'x2y2']);
});

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

// base case
_supply({
dimensions: [
{values: [1, 2, 3]},
{values: [2, 1, 2]}
]
});

gridOut = gd._fullLayout.grid;
expect(gridOut.xside).toBe('bottom plot');
expect(gridOut.yside).toBe('left plot');

// w/o lower half case
_supply({
dimensions: [
{values: [1, 2, 3]},
{values: [2, 1, 2]}
],
showlowerhalf: false
});

gridOut = gd._fullLayout.grid;
expect(gridOut.xside).toBe('bottom');
expect(gridOut.yside).toBe('left');

// non-splom generated grid
_supply({
dimensions: [
{values: [1, 2, 3]},
Expand Down

0 comments on commit c947b2c

Please sign in to comment.