6
6
* LICENSE file in the root directory of this source tree.
7
7
*/
8
8
9
-
10
9
'use strict' ;
11
10
12
11
var Registry = require ( '../../registry' ) ;
@@ -15,8 +14,9 @@ var Lib = require('../../lib');
15
14
16
15
var layoutAttributes = require ( './layout_attributes' ) ;
17
16
18
-
19
17
module . exports = function ( layoutIn , layoutOut , fullData ) {
18
+ var i , trace ;
19
+
20
20
function coerce ( attr , dflt ) {
21
21
return Lib . coerce ( layoutIn , layoutOut , layoutAttributes , attr , dflt ) ;
22
22
}
@@ -25,9 +25,10 @@ module.exports = function(layoutIn, layoutOut, fullData) {
25
25
var shouldBeGapless = false ;
26
26
var gappedAnyway = false ;
27
27
var usedSubplots = { } ;
28
+ var tracesWithGroupAttrs = [ ] ;
28
29
29
- for ( var i = 0 ; i < fullData . length ; i ++ ) {
30
- var trace = fullData [ i ] ;
30
+ for ( i = 0 ; i < fullData . length ; i ++ ) {
31
+ trace = fullData [ i ] ;
31
32
if ( Registry . traceIs ( trace , 'bar' ) && trace . visible ) hasBars = true ;
32
33
else continue ;
33
34
@@ -44,6 +45,10 @@ module.exports = function(layoutIn, layoutOut, fullData) {
44
45
trace [ trace . orientation === 'v' ? 'xaxis' : 'yaxis' ] ) ;
45
46
if ( pa . type !== 'category' ) shouldBeGapless = true ;
46
47
}
48
+
49
+ if ( trace . alignmentgroup || trace . offsetgroup ) {
50
+ tracesWithGroupAttrs . push ( trace ) ;
51
+ }
47
52
}
48
53
49
54
if ( ! hasBars ) return ;
@@ -53,4 +58,12 @@ module.exports = function(layoutIn, layoutOut, fullData) {
53
58
54
59
coerce ( 'bargap' , ( shouldBeGapless && ! gappedAnyway ) ? 0 : 0.2 ) ;
55
60
coerce ( 'bargroupgap' ) ;
61
+
62
+ if ( mode !== 'group' ) {
63
+ for ( i = 0 ; i < tracesWithGroupAttrs . length ; i ++ ) {
64
+ trace = tracesWithGroupAttrs [ i ] ;
65
+ delete trace . alignmentgroup ;
66
+ delete trace . offsetgroup ;
67
+ }
68
+ }
56
69
} ;
0 commit comments