@@ -24,11 +24,25 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks,
24
24
// contour plots only want the centers
25
25
if ( isContour || isGL2D ) arrayOut = Array . from ( arrayIn ) . slice ( 0 , numbricks ) ;
26
26
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 ) ) ;
28
41
} else {
29
42
arrayOut = [ 1.5 * arrayIn [ 0 ] - 0.5 * arrayIn [ 1 ] ] ;
30
43
31
44
for ( i = 1 ; i < len ; i ++ ) {
45
+ // Arithmetic mean
32
46
arrayOut . push ( ( arrayIn [ i - 1 ] + arrayIn [ i ] ) * 0.5 ) ;
33
47
}
34
48
@@ -37,11 +51,21 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks,
37
51
38
52
if ( len < numbricks ) {
39
53
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 ] ;
41
64
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
+ }
45
69
}
46
70
}
47
71
} else {
0 commit comments