@@ -14,10 +14,13 @@ var Lib = require('../../lib');
14
14
15
15
16
16
module . exports = function setPositions ( gd , plotinfo ) {
17
- var fullLayout = gd . _fullLayout ,
18
- xa = plotinfo . xaxis ,
19
- ya = plotinfo . yaxis ,
20
- orientations = [ 'v' , 'h' ] ;
17
+ var fullLayout = gd . _fullLayout ;
18
+ var xa = plotinfo . xaxis ;
19
+ var ya = plotinfo . yaxis ;
20
+ var orientations = [ 'v' , 'h' ] ;
21
+
22
+ var numKey = '_numBoxes' ;
23
+
21
24
var posAxis , i , j , k ;
22
25
23
26
for ( i = 0 ; i < orientations . length ; ++ i ) {
@@ -63,12 +66,14 @@ module.exports = function setPositions(gd, plotinfo) {
63
66
// box plots - update dPos based on multiple traces
64
67
// and then use for posAxis autorange
65
68
66
- var boxdv = Lib . distinctVals ( boxpointlist ) ,
67
- dPos = boxdv . minDiff / 2 ;
69
+ var boxdv = Lib . distinctVals ( boxpointlist ) ;
70
+ var dPos = boxdv . minDiff / 2 ;
68
71
69
72
// if there's no duplication of x points,
70
- // disable 'group' mode by setting numboxes=1
71
- if ( boxpointlist . length === boxdv . vals . length ) gd . numboxes = 1 ;
73
+ // disable 'group' mode by setting counter to 1
74
+ if ( boxpointlist . length === boxdv . vals . length ) {
75
+ fullLayout [ numKey ] = 1 ;
76
+ }
72
77
73
78
// check for forced minimum dtick
74
79
Axes . minDtick ( posAxis , boxdv . minDiff , boxdv . vals [ 0 ] , true ) ;
@@ -79,11 +84,13 @@ module.exports = function setPositions(gd, plotinfo) {
79
84
gd . calcdata [ boxListIndex ] [ 0 ] . t . dPos = dPos ;
80
85
}
81
86
87
+ var gap = fullLayout . boxgap ;
88
+ var groupgap = fullLayout . boxgroupgap ;
89
+
82
90
// autoscale the x axis - including space for points if they're off the side
83
91
// TODO: this will overdo it if the outermost boxes don't have
84
92
// their points as far out as the other boxes
85
- var padfactor = ( 1 - fullLayout . boxgap ) * ( 1 - fullLayout . boxgroupgap ) *
86
- dPos / gd . numboxes ;
93
+ var padfactor = ( 1 - gap ) * ( 1 - groupgap ) * dPos / fullLayout [ numKey ] ;
87
94
Axes . expand ( posAxis , boxdv . vals , {
88
95
vpadminus : dPos + minPad * padfactor ,
89
96
vpadplus : dPos + maxPad * padfactor
0 commit comments