-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Layout grids #2399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Layout grids #2399
Changes from 1 commit
001bd9b
606a601
f01db07
82fbae2
cd6e823
1aec7f7
446f9f9
40dd784
670bdd5
6b8d461
4b43e35
794669b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ var extendFlat = require('../lib/extend').extendFlat; | |
* opts.trace: set to true for trace containers | ||
* @param {string} | ||
* opts.editType: editType for all pieces | ||
* @param {boolean} | ||
* opts.noGridCell: set to true to omit `row` and `column` | ||
* | ||
* @param {object} extra | ||
* @param {string} | ||
|
@@ -29,7 +31,7 @@ var extendFlat = require('../lib/extend').extendFlat; | |
* | ||
* @return {object} attributes object containing {x,y} as specified | ||
*/ | ||
module.exports = function(opts, extra) { | ||
exports.attributes = function(opts, extra) { | ||
opts = opts || {}; | ||
extra = extra || {}; | ||
|
||
|
@@ -48,7 +50,7 @@ module.exports = function(opts, extra) { | |
var contPart = opts.trace ? 'trace ' : 'subplot '; | ||
var descPart = extra.description ? ' ' + extra.description : ''; | ||
|
||
return { | ||
var out = { | ||
x: extendFlat({}, base, { | ||
description: [ | ||
'Sets the horizontal domain of this ', | ||
|
@@ -69,4 +71,60 @@ module.exports = function(opts, extra) { | |
}), | ||
editType: opts.editType | ||
}; | ||
|
||
if(!opts.noGridCell) { | ||
out.row = { | ||
valType: 'integer', | ||
min: 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah, makes sense - if you have a grid, by default all subplots should go in it. You can always set explicit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
As discussed offline, I omitted this one (though if you say |
||
role: 'info', | ||
editType: opts.editType, | ||
description: [ | ||
'If there is a layout grid, use the domain ', | ||
'for this row in the grid for this ', | ||
namePart, | ||
contPart, | ||
'.', | ||
descPart | ||
].join('') | ||
}; | ||
out.column = { | ||
valType: 'integer', | ||
min: 0, | ||
role: 'info', | ||
editType: opts.editType, | ||
description: [ | ||
'If there is a layout grid, use the domain ', | ||
'for this column in the grid for this ', | ||
namePart, | ||
contPart, | ||
'.', | ||
descPart | ||
].join('') | ||
}; | ||
} | ||
|
||
return out; | ||
}; | ||
|
||
exports.defaults = function(containerOut, layout, coerce, dfltDomains) { | ||
var dfltX = (dfltDomains && dfltDomains.x) || [0, 1]; | ||
var dfltY = (dfltDomains && dfltDomains.y) || [0, 1]; | ||
|
||
var grid = layout.grid; | ||
if(grid) { | ||
var column = coerce('domain.column'); | ||
if(column !== undefined) { | ||
if(column < grid.columns) dfltX = grid._domains.x[column]; | ||
else delete containerOut.domain.column; | ||
} | ||
|
||
var row = coerce('domain.row'); | ||
if(row !== undefined) { | ||
if(row < grid.rows) dfltY = grid._domains.y[row]; | ||
else delete containerOut.domain.row; | ||
} | ||
} | ||
|
||
coerce('domain.x', dfltX); | ||
coerce('domain.y', dfltY); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any
noGridCell
options being set. 🔪 ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noGridCell
shows up in the domain for the grid itself - you can't put the grid in itself! 😄