@@ -199,18 +199,25 @@ function needsAutorange(ax) {
199
199
return ax . autorange || ! ! ( ax . rangeslider || { } ) . autorange ;
200
200
}
201
201
202
- // expand: if autoranging, include new data in the outer limits
203
- // for this axis
204
- // data is an array of numbers (ie already run through ax.d2c)
205
- // available options:
206
- // vpad: (number or number array) pad values (data value +-vpad)
207
- // ppad: (number or number array) pad pixels (pixel location +-ppad)
208
- // ppadplus, ppadminus, vpadplus, vpadminus:
209
- // separate padding for each side, overrides symmetric
210
- // padded: (boolean) add 5% padding to both ends
211
- // (unless one end is overridden by tozero)
212
- // tozero: (boolean) make sure to include zero if axis is linear,
213
- // and make it a tight bound if possible
202
+ /*
203
+ * expand: if autoranging, include new data in the outer limits for this axis.
204
+ * Note that `expand` is called during `calc`, when we don't yet know the axis
205
+ * length; all the inputs should be based solely on the trace data, nothing
206
+ * about the axis layout.
207
+ *
208
+ * @param {object } ax: the axis being expanded. The result will be more entries
209
+ * in ax._min and ax._max if necessary to include the new data
210
+ * @param {array } data: an array of numbers (ie already run through ax.d2c)
211
+ * @param {object } options: available keys are:
212
+ * vpad: (number or number array) pad values (data value +-vpad)
213
+ * ppad: (number or number array) pad pixels (pixel location +-ppad)
214
+ * ppadplus, ppadminus, vpadplus, vpadminus:
215
+ * separate padding for each side, overrides symmetric
216
+ * padded: (boolean) add 5% padding to both ends
217
+ * (unless one end is overridden by tozero)
218
+ * tozero: (boolean) make sure to include zero if axis is linear,
219
+ * and make it a tight bound if possible
220
+ */
214
221
function expand ( ax , data , options ) {
215
222
if ( ! needsAutorange ( ax ) || ! data ) return ;
216
223
@@ -225,7 +232,7 @@ function expand(ax, data, options) {
225
232
226
233
var i , j , k , v , di , dmin , dmax , ppadiplus , ppadiminus , includeThis , vmin , vmax ;
227
234
228
- function getPad ( item ) {
235
+ function makePadAccessor ( item ) {
229
236
if ( Array . isArray ( item ) ) {
230
237
return function ( i ) { return Math . max ( Number ( item [ i ] || 0 ) , 0 ) ; } ;
231
238
}
@@ -234,12 +241,12 @@ function expand(ax, data, options) {
234
241
return function ( ) { return v ; } ;
235
242
}
236
243
}
237
- var ppadplus = getPad ( ( ax . _m > 0 ?
244
+ var ppadplus = makePadAccessor ( ( ax . _m > 0 ?
238
245
options . ppadplus : options . ppadminus ) || options . ppad || 0 ) ,
239
- ppadminus = getPad ( ( ax . _m > 0 ?
246
+ ppadminus = makePadAccessor ( ( ax . _m > 0 ?
240
247
options . ppadminus : options . ppadplus ) || options . ppad || 0 ) ,
241
- vpadplus = getPad ( options . vpadplus || options . vpad ) ,
242
- vpadminus = getPad ( options . vpadminus || options . vpad ) ;
248
+ vpadplus = makePadAccessor ( options . vpadplus || options . vpad ) ,
249
+ vpadminus = makePadAccessor ( options . vpadminus || options . vpad ) ;
243
250
244
251
function addItem ( i ) {
245
252
di = data [ i ] ;
0 commit comments