10
10
'use strict' ;
11
11
12
12
var d3 = require ( 'd3' ) ;
13
-
14
- var Color = require ( '../../components/color' ) ;
15
13
var Drawing = require ( '../../components/drawing' ) ;
16
14
var ErrorBars = require ( '../../components/errorbars' ) ;
17
15
18
-
19
- module . exports = function style ( gd ) {
20
- var s = d3 . select ( gd ) . selectAll ( 'g.trace.bars' ) ,
21
- barcount = s . size ( ) ,
22
- fullLayout = gd . _fullLayout ;
16
+ module . exports = function style ( gd , cd ) {
17
+ var s = cd ? cd [ 0 ] . node3 : d3 . select ( gd ) . selectAll ( 'g.trace.bars' ) ;
18
+ var barcount = s . size ( ) ;
19
+ var fullLayout = gd . _fullLayout ;
23
20
24
21
// trace styling
25
22
s . style ( 'opacity' , function ( d ) { return d [ 0 ] . trace . opacity ; } )
@@ -36,38 +33,13 @@ module.exports = function style(gd) {
36
33
}
37
34
} ) ;
38
35
39
- // then style the individual bars
40
36
s . selectAll ( 'g.points' ) . each ( function ( d ) {
41
- var trace = d [ 0 ] . trace ,
42
- marker = trace . marker ,
43
- markerLine = marker . line ,
44
- markerScale = Drawing . tryColorscale ( marker , '' ) ,
45
- lineScale = Drawing . tryColorscale ( marker , 'line' ) ;
46
-
47
- d3 . select ( this ) . selectAll ( 'path' ) . each ( function ( d ) {
48
- // allow all marker and marker line colors to be scaled
49
- // by given max and min to colorscales
50
- var fillColor ,
51
- lineColor ,
52
- lineWidth = ( d . mlw + 1 || markerLine . width + 1 ) - 1 ,
53
- p = d3 . select ( this ) ;
54
-
55
- if ( 'mc' in d ) fillColor = d . mcc = markerScale ( d . mc ) ;
56
- else if ( Array . isArray ( marker . color ) ) fillColor = Color . defaultLine ;
57
- else fillColor = marker . color ;
58
-
59
- p . style ( 'stroke-width' , lineWidth + 'px' )
60
- . call ( Color . fill , fillColor ) ;
61
- if ( lineWidth ) {
62
- if ( 'mlc' in d ) lineColor = d . mlcc = lineScale ( d . mlc ) ;
63
- // weird case: array wasn't long enough to apply to every point
64
- else if ( Array . isArray ( markerLine . color ) ) lineColor = Color . defaultLine ;
65
- else lineColor = markerLine . color ;
37
+ var sel = d3 . select ( this ) ;
38
+ var pts = sel . selectAll ( '.point' ) ;
39
+ var trace = d [ 0 ] . trace ;
66
40
67
- p . call ( Color . stroke , lineColor ) ;
68
- }
69
- } ) ;
41
+ Drawing . pointStyle ( pts , trace , gd ) ;
70
42
} ) ;
71
43
72
- s . call ( ErrorBars . style ) ;
44
+ ErrorBars . style ( s ) ;
73
45
} ;
0 commit comments