@@ -57,52 +57,57 @@ function setGroupPositions(gd, pa, sa, calcTraces) {
57
57
if ( ! calcTraces . length ) return ;
58
58
59
59
var barmode = gd . _fullLayout . barmode ;
60
- var overlay = ( barmode === 'overlay' ) ;
61
- var group = ( barmode === 'group' ) ;
62
60
var excluded ;
63
61
var included ;
64
62
var i , calcTrace , fullTrace ;
65
63
66
64
initBase ( gd , pa , sa , calcTraces ) ;
67
65
68
- if ( overlay ) {
69
- setGroupPositionsInOverlayMode ( gd , pa , sa , calcTraces ) ;
70
- } else if ( group ) {
71
- // exclude from the group those traces for which the user set an offset
72
- excluded = [ ] ;
73
- included = [ ] ;
74
- for ( i = 0 ; i < calcTraces . length ; i ++ ) {
75
- calcTrace = calcTraces [ i ] ;
76
- fullTrace = calcTrace [ 0 ] . trace ;
77
-
78
- if ( fullTrace . offset === undefined ) included . push ( calcTrace ) ;
79
- else excluded . push ( calcTrace ) ;
80
- }
66
+ switch ( barmode ) {
67
+ case 'overlay' :
68
+ setGroupPositionsInOverlayMode ( gd , pa , sa , calcTraces ) ;
69
+ break ;
70
+
71
+ case 'group' :
72
+ // exclude from the group those traces for which the user set an offset
73
+ excluded = [ ] ;
74
+ included = [ ] ;
75
+ for ( i = 0 ; i < calcTraces . length ; i ++ ) {
76
+ calcTrace = calcTraces [ i ] ;
77
+ fullTrace = calcTrace [ 0 ] . trace ;
78
+
79
+ if ( fullTrace . offset === undefined ) included . push ( calcTrace ) ;
80
+ else excluded . push ( calcTrace ) ;
81
+ }
81
82
82
- if ( included . length ) {
83
- setGroupPositionsInGroupMode ( gd , pa , sa , included ) ;
84
- }
85
- if ( excluded . length ) {
86
- setGroupPositionsInOverlayMode ( gd , pa , sa , excluded ) ;
87
- }
88
- } else {
89
- // exclude from the stack those traces for which the user set a base
90
- excluded = [ ] ;
91
- included = [ ] ;
92
- for ( i = 0 ; i < calcTraces . length ; i ++ ) {
93
- calcTrace = calcTraces [ i ] ;
94
- fullTrace = calcTrace [ 0 ] . trace ;
95
-
96
- if ( fullTrace . base === undefined ) included . push ( calcTrace ) ;
97
- else excluded . push ( calcTrace ) ;
98
- }
83
+ if ( included . length ) {
84
+ setGroupPositionsInGroupMode ( gd , pa , sa , included ) ;
85
+ }
86
+ if ( excluded . length ) {
87
+ setGroupPositionsInOverlayMode ( gd , pa , sa , excluded ) ;
88
+ }
89
+ break ;
90
+
91
+ case 'stack' :
92
+ case 'relative' :
93
+ // exclude from the stack those traces for which the user set a base
94
+ excluded = [ ] ;
95
+ included = [ ] ;
96
+ for ( i = 0 ; i < calcTraces . length ; i ++ ) {
97
+ calcTrace = calcTraces [ i ] ;
98
+ fullTrace = calcTrace [ 0 ] . trace ;
99
+
100
+ if ( fullTrace . base === undefined ) included . push ( calcTrace ) ;
101
+ else excluded . push ( calcTrace ) ;
102
+ }
99
103
100
- if ( included . length ) {
101
- setGroupPositionsInStackOrRelativeMode ( gd , pa , sa , included ) ;
102
- }
103
- if ( excluded . length ) {
104
- setGroupPositionsInOverlayMode ( gd , pa , sa , excluded ) ;
105
- }
104
+ if ( included . length ) {
105
+ setGroupPositionsInStackOrRelativeMode ( gd , pa , sa , included ) ;
106
+ }
107
+ if ( excluded . length ) {
108
+ setGroupPositionsInOverlayMode ( gd , pa , sa , excluded ) ;
109
+ }
110
+ break ;
106
111
}
107
112
108
113
collectExtents ( calcTraces , pa ) ;
@@ -154,13 +159,15 @@ function initBase(gd, pa, sa, calcTraces) {
154
159
155
160
function setGroupPositionsInOverlayMode ( gd , pa , sa , calcTraces ) {
156
161
var barnorm = gd . _fullLayout . barnorm ;
157
- var separateNegativeValues = false ;
158
- var dontMergeOverlappingData = ! barnorm ;
159
162
160
163
// update position axis and set bar offsets and widths
161
164
for ( var i = 0 ; i < calcTraces . length ; i ++ ) {
162
165
var calcTrace = calcTraces [ i ] ;
163
- var sieve = new Sieve ( [ calcTrace ] , separateNegativeValues , dontMergeOverlappingData ) ;
166
+
167
+ var sieve = new Sieve ( [ calcTrace ] , {
168
+ separateNegativeValues : false ,
169
+ dontMergeOverlappingData : ! barnorm
170
+ } ) ;
164
171
165
172
// set bar offsets and widths, and update position axis
166
173
setOffsetAndWidth ( gd , pa , sieve ) ;
@@ -182,9 +189,11 @@ function setGroupPositionsInOverlayMode(gd, pa, sa, calcTraces) {
182
189
function setGroupPositionsInGroupMode ( gd , pa , sa , calcTraces ) {
183
190
var fullLayout = gd . _fullLayout ;
184
191
var barnorm = fullLayout . barnorm ;
185
- var separateNegativeValues = false ;
186
- var dontMergeOverlappingData = ! barnorm ;
187
- var sieve = new Sieve ( calcTraces , separateNegativeValues , dontMergeOverlappingData ) ;
192
+
193
+ var sieve = new Sieve ( calcTraces , {
194
+ separateNegativeValues : false ,
195
+ dontMergeOverlappingData : ! barnorm
196
+ } ) ;
188
197
189
198
// set bar offsets and widths, and update position axis
190
199
setOffsetAndWidthInGroupMode ( gd , pa , sieve ) ;
@@ -201,12 +210,12 @@ function setGroupPositionsInGroupMode(gd, pa, sa, calcTraces) {
201
210
function setGroupPositionsInStackOrRelativeMode ( gd , pa , sa , calcTraces ) {
202
211
var fullLayout = gd . _fullLayout ;
203
212
var barmode = fullLayout . barmode ;
204
- var stack = barmode === 'stack' ;
205
- var relative = barmode === 'relative' ;
206
213
var barnorm = fullLayout . barnorm ;
207
- var separateNegativeValues = relative ;
208
- var dontMergeOverlappingData = ! ( barnorm || stack || relative ) ;
209
- var sieve = new Sieve ( calcTraces , separateNegativeValues , dontMergeOverlappingData ) ;
214
+
215
+ var sieve = new Sieve ( calcTraces , {
216
+ separateNegativeValues : barmode === 'relative' ,
217
+ dontMergeOverlappingData : ! ( barnorm || barmode === 'stack' || barmode === 'relative' )
218
+ } ) ;
210
219
211
220
// set bar offsets and widths, and update position axis
212
221
setOffsetAndWidth ( gd , pa , sieve ) ;
@@ -562,7 +571,9 @@ function sieveBars(gd, sa, sieve) {
562
571
for ( var j = 0 ; j < calcTrace . length ; j ++ ) {
563
572
var bar = calcTrace [ j ] ;
564
573
565
- if ( bar . s !== BADNUM ) sieve . put ( bar . p , bar . b + bar . s ) ;
574
+ if ( bar . s !== BADNUM ) {
575
+ sieve . put ( bar . p , bar . b + bar . s ) ;
576
+ }
566
577
}
567
578
}
568
579
}
0 commit comments