@@ -24,11 +24,25 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks,
2424 // contour plots only want the centers
2525 if ( isContour || isGL2D ) arrayOut = Array . from ( arrayIn ) . slice ( 0 , numbricks ) ;
2626 else if ( numbricks === 1 ) {
27- arrayOut = [ arrayIn [ 0 ] - 0.5 , arrayIn [ 0 ] + 0.5 ] ;
27+ if ( ax . type === 'log' ) {
28+ arrayOut = [ 0.5 * arrayIn [ 0 ] , 2 * arrayIn [ 0 ] ] ;
29+ } else {
30+ arrayOut = [ arrayIn [ 0 ] - 0.5 , arrayIn [ 0 ] + 0.5 ] ;
31+ }
32+ } else if ( ax . type === 'log' ) {
33+ arrayOut = [ Math . pow ( arrayIn [ 0 ] , 1.5 ) / Math . pow ( arrayIn [ 1 ] , 0.5 ) ] ;
34+
35+ for ( i = 1 ; i < len ; i ++ ) {
36+ // Geomean
37+ arrayOut . push ( Math . sqrt ( arrayIn [ i - 1 ] * arrayIn [ i ] ) ) ;
38+ }
39+
40+ arrayOut . push ( Math . pow ( arrayIn [ len - 1 ] , 1.5 ) / Math . pow ( arrayIn [ len - 2 ] , 0.5 ) ) ;
2841 } else {
2942 arrayOut = [ 1.5 * arrayIn [ 0 ] - 0.5 * arrayIn [ 1 ] ] ;
3043
3144 for ( i = 1 ; i < len ; i ++ ) {
45+ // Arithmetic mean
3246 arrayOut . push ( ( arrayIn [ i - 1 ] + arrayIn [ i ] ) * 0.5 ) ;
3347 }
3448
@@ -37,11 +51,21 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks,
3751
3852 if ( len < numbricks ) {
3953 var lastPt = arrayOut [ arrayOut . length - 1 ] ;
40- var delta = lastPt - arrayOut [ arrayOut . length - 2 ] ;
54+ var delta ; // either multiplicative delta (log axis type) or arithmetic delta (all other axis types)
55+ if ( ax . type === 'log' ) {
56+ delta = lastPt / arrayOut [ arrayOut . length - 2 ] ;
57+
58+ for ( i = len ; i < numbricks ; i ++ ) {
59+ lastPt *= delta ;
60+ arrayOut . push ( lastPt ) ;
61+ }
62+ } else {
63+ delta = lastPt - arrayOut [ arrayOut . length - 2 ] ;
4164
42- for ( i = len ; i < numbricks ; i ++ ) {
43- lastPt += delta ;
44- arrayOut . push ( lastPt ) ;
65+ for ( i = len ; i < numbricks ; i ++ ) {
66+ lastPt += delta ;
67+ arrayOut . push ( lastPt ) ;
68+ }
4569 }
4670 }
4771 } else {
0 commit comments