@@ -143,7 +143,7 @@ var gridAttrs = {
143
143
values : [ 'bottom' , 'bottom plot' , 'top plot' , 'top' ] ,
144
144
dflt : 'bottom plot' ,
145
145
role : 'info' ,
146
- editType : 'ticks ' ,
146
+ editType : 'plot ' ,
147
147
description : [
148
148
'Sets where the x axis labels and titles go. *bottom* means' ,
149
149
'the very bottom of the grid. *bottom plot* is the lowest plot' ,
@@ -155,7 +155,7 @@ var gridAttrs = {
155
155
values : [ 'left' , 'left plot' , 'right plot' , 'right' ] ,
156
156
dflt : 'left plot' ,
157
157
role : 'info' ,
158
- editType : 'ticks ' ,
158
+ editType : 'plot ' ,
159
159
description : [
160
160
'Sets where the y axis labels and titles go. *left* means' ,
161
161
'the very left edge of the grid. *left plot* is the leftmost plot' ,
@@ -165,15 +165,30 @@ var gridAttrs = {
165
165
editType : 'plot'
166
166
} ;
167
167
168
+ function getAxes ( layout , grid , axLetter ) {
169
+ var gridVal = grid [ axLetter + 'axes' ] ;
170
+ var splomVal = Object . keys ( ( layout . _splomAxes || { } ) [ axLetter ] || { } ) ;
171
+
172
+ if ( Array . isArray ( gridVal ) ) return gridVal ;
173
+ if ( splomVal . length ) return splomVal ;
174
+ }
175
+
168
176
// the shape of the grid - this needs to be done BEFORE supplyDataDefaults
169
177
// so that non-subplot traces can place themselves in the grid
170
178
function sizeDefaults ( layoutIn , layoutOut ) {
171
- var gridIn = layoutIn . grid ;
172
- if ( ! gridIn ) return ;
179
+ var gridIn = layoutIn . grid || { } ;
180
+ var xAxes = getAxes ( layoutOut , gridIn , 'x' ) ;
181
+ var yAxes = getAxes ( layoutOut , gridIn , 'y' ) ;
182
+
183
+ if ( ! layoutIn . grid && ! xAxes && ! yAxes ) return ;
173
184
174
185
var hasSubplotGrid = Array . isArray ( gridIn . subplots ) && Array . isArray ( gridIn . subplots [ 0 ] ) ;
175
- var hasXaxes = Array . isArray ( gridIn . xaxes ) ;
176
- var hasYaxes = Array . isArray ( gridIn . yaxes ) ;
186
+ var hasXaxes = Array . isArray ( xAxes ) ;
187
+ var hasYaxes = Array . isArray ( yAxes ) ;
188
+ var isSplomGenerated = (
189
+ hasXaxes && xAxes !== gridIn . xaxes &&
190
+ hasYaxes && yAxes !== gridIn . yaxes
191
+ ) ;
177
192
178
193
var dfltRows , dfltColumns ;
179
194
@@ -182,8 +197,8 @@ function sizeDefaults(layoutIn, layoutOut) {
182
197
dfltColumns = gridIn . subplots [ 0 ] . length ;
183
198
}
184
199
else {
185
- if ( hasYaxes ) dfltRows = gridIn . yaxes . length ;
186
- if ( hasXaxes ) dfltColumns = gridIn . xaxes . length ;
200
+ if ( hasYaxes ) dfltRows = yAxes . length ;
201
+ if ( hasXaxes ) dfltColumns = xAxes . length ;
187
202
}
188
203
189
204
var gridOut = layoutOut . grid = { } ;
@@ -206,17 +221,26 @@ function sizeDefaults(layoutIn, layoutOut) {
206
221
var rowOrder = coerce ( 'roworder' ) ;
207
222
var reversed = rowOrder === 'top to bottom' ;
208
223
224
+ var dfltGapX = hasSubplotGrid ? 0.2 : 0.1 ;
225
+ var dfltGapY = hasSubplotGrid ? 0.3 : 0.1 ;
226
+
227
+ var dfltSideX , dfltSideY ;
228
+ if ( isSplomGenerated ) {
229
+ dfltSideX = 'bottom' ;
230
+ dfltSideY = 'left' ;
231
+ }
232
+
209
233
gridOut . _domains = {
210
- x : fillGridPositions ( 'x' , coerce , hasSubplotGrid ? 0.2 : 0.1 , columns ) ,
211
- y : fillGridPositions ( 'y' , coerce , hasSubplotGrid ? 0.3 : 0.1 , rows , reversed )
234
+ x : fillGridPositions ( 'x' , coerce , dfltGapX , dfltSideX , columns ) ,
235
+ y : fillGridPositions ( 'y' , coerce , dfltGapY , dfltSideY , rows , reversed )
212
236
} ;
213
237
}
214
238
215
239
// coerce x or y sizing attributes and return an array of domains for this direction
216
- function fillGridPositions ( axLetter , coerce , dfltGap , len , reversed ) {
240
+ function fillGridPositions ( axLetter , coerce , dfltGap , dfltSide , len , reversed ) {
217
241
var dirGap = coerce ( axLetter + 'gap' , dfltGap ) ;
218
242
var domain = coerce ( 'domain.' + axLetter ) ;
219
- coerce ( axLetter + 'side' ) ;
243
+ coerce ( axLetter + 'side' , dfltSide ) ;
220
244
221
245
var out = new Array ( len ) ;
222
246
var start = domain [ 0 ] ;
@@ -236,7 +260,7 @@ function contentDefaults(layoutIn, layoutOut) {
236
260
// make sure we got to the end of handleGridSizing
237
261
if ( ! gridOut || ! gridOut . _domains ) return ;
238
262
239
- var gridIn = layoutIn . grid ;
263
+ var gridIn = layoutIn . grid || { } ;
240
264
var subplots = layoutOut . _subplots ;
241
265
var hasSubplotGrid = gridOut . _hasSubplotGrid ;
242
266
var rows = gridOut . rows ;
@@ -282,8 +306,10 @@ function contentDefaults(layoutIn, layoutOut) {
282
306
}
283
307
}
284
308
else {
285
- gridOut . xaxes = fillGridAxes ( gridIn . xaxes , subplots . xaxis , columns , axisMap , 'x' ) ;
286
- gridOut . yaxes = fillGridAxes ( gridIn . yaxes , subplots . yaxis , rows , axisMap , 'y' ) ;
309
+ var xAxes = getAxes ( layoutOut , gridIn , 'x' ) ;
310
+ var yAxes = getAxes ( layoutOut , gridIn , 'y' ) ;
311
+ gridOut . xaxes = fillGridAxes ( xAxes , subplots . xaxis , columns , axisMap , 'x' ) ;
312
+ gridOut . yaxes = fillGridAxes ( yAxes , subplots . yaxis , rows , axisMap , 'y' ) ;
287
313
}
288
314
289
315
var anchors = gridOut . _anchors = { } ;
0 commit comments