@@ -173,36 +173,43 @@ function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks, ax) {
173
173
dv ,
174
174
i ;
175
175
176
- if ( Array . isArray ( arrayIn ) && ! isHist && ( ax . type !== 'category' ) ) {
176
+ var isArrayOfTwoItemsOrMore = Array . isArray ( arrayIn ) && arrayIn . length > 1 ;
177
+
178
+ if ( isArrayOfTwoItemsOrMore && ! isHist && ( ax . type !== 'category' ) ) {
177
179
arrayIn = arrayIn . map ( ax . d2c ) ;
178
180
var len = arrayIn . length ;
179
181
180
182
// given vals are brick centers
181
- // hopefully length== numbricks, but use this method even if too few are supplied
183
+ // hopefully length === numbricks, but use this method even if too few are supplied
182
184
// and extend it linearly based on the last two points
183
185
if ( len <= numbricks ) {
184
186
// contour plots only want the centers
185
187
if ( isContour || isGL2D ) arrayOut = arrayIn . slice ( 0 , numbricks ) ;
186
- else if ( numbricks === 1 ) arrayOut = [ arrayIn [ 0 ] - 0.5 , arrayIn [ 0 ] + 0.5 ] ;
188
+ else if ( numbricks === 1 ) {
189
+ arrayOut = [ arrayIn [ 0 ] - 0.5 , arrayIn [ 0 ] + 0.5 ] ;
190
+ }
187
191
else {
188
192
arrayOut = [ 1.5 * arrayIn [ 0 ] - 0.5 * arrayIn [ 1 ] ] ;
193
+
189
194
for ( i = 1 ; i < len ; i ++ ) {
190
195
arrayOut . push ( ( arrayIn [ i - 1 ] + arrayIn [ i ] ) * 0.5 ) ;
191
196
}
197
+
192
198
arrayOut . push ( 1.5 * arrayIn [ len - 1 ] - 0.5 * arrayIn [ len - 2 ] ) ;
193
199
}
194
200
195
201
if ( len < numbricks ) {
196
202
var lastPt = arrayOut [ arrayOut . length - 1 ] ,
197
203
delta = lastPt - arrayOut [ arrayOut . length - 2 ] ;
204
+
198
205
for ( i = len ; i < numbricks ; i ++ ) {
199
206
lastPt += delta ;
200
207
arrayOut . push ( lastPt ) ;
201
208
}
202
209
}
203
210
}
204
211
else {
205
- // hopefully length== numbricks+1, but do something regardless:
212
+ // hopefully length === numbricks+1, but do something regardless:
206
213
// given vals are brick boundaries
207
214
return isContour ?
208
215
arrayIn . slice ( 0 , numbricks ) : // we must be strict for contours
@@ -211,14 +218,17 @@ function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks, ax) {
211
218
}
212
219
else {
213
220
dv = dvIn || 1 ;
214
- if ( v0In === undefined ) v0 = 0 ;
221
+
222
+ if ( Array . isArray ( arrayIn ) && arrayIn . length === 1 ) v0 = arrayIn [ 0 ] ;
223
+ else if ( v0In === undefined ) v0 = 0 ;
215
224
else if ( isHist || ax . type === 'category' ) v0 = v0In ;
216
225
else v0 = ax . d2c ( v0In ) ;
217
226
218
227
for ( i = ( isContour || isGL2D ) ? 0 : - 0.5 ; i < numbricks ; i ++ ) {
219
228
arrayOut . push ( v0 + dv * i ) ;
220
229
}
221
230
}
231
+
222
232
return arrayOut ;
223
233
}
224
234
0 commit comments