Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/grid/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function sizeDefaults(layoutIn, layoutOut) {
if(hasXaxes) dfltColumns = xAxes.length;
}

var gridOut = layoutOut.grid = {};
var gridOut = {};

function coerce(attr, dflt) {
return Lib.coerce(gridIn, gridOut, gridAttrs, attr, dflt);
Expand Down Expand Up @@ -234,6 +234,8 @@ function sizeDefaults(layoutIn, layoutOut) {
x: fillGridPositions('x', coerce, dfltGapX, dfltSideX, columns),
y: fillGridPositions('y', coerce, dfltGapY, dfltSideY, rows, reversed)
};

layoutOut.grid = gridOut;
}

// coerce x or y sizing attributes and return an array of domains for this direction
Expand Down
29 changes: 29 additions & 0 deletions test/jasmine/tests/plots_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,35 @@ describe('grids', function() {
});
}

it('does not barf on invalid grid objects', function(done) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Can you also check that Plotly.validate([], {grid: true}) does the right thing? It barfs too on master.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also check that Plotly.validate([], {grid: true}) does the right thing?

good call -> 09ee26e

Plotly.newPlot(gd, makeData(['xy']), {grid: true})
.then(function() {
expect(gd._fullLayout.grid).toBeUndefined();

return Plotly.newPlot(gd, makeData(['xy']), {grid: {}});
})
.then(function() {
expect(gd._fullLayout.grid).toBeUndefined();

return Plotly.newPlot(gd, makeData(['xy']), {grid: {rows: 1, columns: 1}});
})
.then(function() {
expect(gd._fullLayout.grid).toBeUndefined();

// check Plotly.validate on the same grids too
[true, {}, {rows: 1, columns: 1}].forEach(function(gridVal) {
var validation = Plotly.validate([], {grid: gridVal});
expect(validation.length).toBe(1);
expect(validation[0]).toEqual(jasmine.objectContaining({
astr: 'grid',
code: 'unused'
}));
});
})
.catch(failTest)
.then(done);
});

it('defaults to a coupled layout', function(done) {
Plotly.newPlot(gd,
// leave some empty rows/columns
Expand Down