@@ -13,7 +13,7 @@ var d3 = require('d3');
13
13
var Drawing = require ( '../../components/drawing' ) ;
14
14
var Registry = require ( '../../registry' ) ;
15
15
16
- module . exports = function style ( gd , cd ) {
16
+ function style ( gd , cd ) {
17
17
var s = cd ? cd [ 0 ] . node3 : d3 . select ( gd ) . selectAll ( 'g.trace.bars' ) ;
18
18
var barcount = s . size ( ) ;
19
19
var fullLayout = gd . _fullLayout ;
@@ -35,34 +35,52 @@ module.exports = function style(gd, cd) {
35
35
36
36
s . selectAll ( 'g.points' ) . each ( function ( d ) {
37
37
var sel = d3 . select ( this ) ;
38
- var pts = sel . selectAll ( 'path' ) ;
39
- var txs = sel . selectAll ( 'text' ) ;
40
38
var trace = d [ 0 ] . trace ;
39
+ stylePoints ( sel , trace , gd ) ;
40
+ } ) ;
41
+
42
+ Registry . getComponentMethod ( 'errorbars' , 'style' ) ( s ) ;
43
+ }
41
44
42
- Drawing . pointStyle ( pts , trace , gd ) ;
43
- Drawing . selectedPointStyle ( pts , trace ) ;
45
+ function stylePoints ( sel , trace , gd ) {
46
+ var pts = sel . selectAll ( 'path' ) ;
47
+ var txs = sel . selectAll ( 'text' ) ;
44
48
45
- txs . each ( function ( d ) {
46
- var tx = d3 . select ( this ) ;
47
- var textFont ;
49
+ Drawing . pointStyle ( pts , trace , gd ) ;
48
50
49
- if ( tx . classed ( 'bartext-inside' ) ) {
50
- textFont = trace . insidetextfont ;
51
- } else if ( tx . classed ( 'bartext-outside' ) ) {
52
- textFont = trace . outsidetextfont ;
53
- }
54
- if ( ! textFont ) textFont = trace . textfont ;
51
+ txs . each ( function ( d ) {
52
+ var tx = d3 . select ( this ) ;
53
+ var textFont ;
55
54
56
- function cast ( k ) {
57
- var cont = textFont [ k ] ;
58
- return Array . isArray ( cont ) ? cont [ d . i ] : cont ;
59
- }
55
+ if ( tx . classed ( 'bartext-inside' ) ) {
56
+ textFont = trace . insidetextfont ;
57
+ } else if ( tx . classed ( 'bartext-outside' ) ) {
58
+ textFont = trace . outsidetextfont ;
59
+ }
60
+ if ( ! textFont ) textFont = trace . textfont ;
60
61
61
- Drawing . font ( tx , cast ( 'family' ) , cast ( 'size' ) , cast ( 'color' ) ) ;
62
- } ) ;
62
+ function cast ( k ) {
63
+ var cont = textFont [ k ] ;
64
+ return Array . isArray ( cont ) ? cont [ d . i ] : cont ;
65
+ }
63
66
64
- Drawing . selectedTextStyle ( txs , trace ) ;
67
+ Drawing . font ( tx , cast ( 'family' ) , cast ( 'size' ) , cast ( 'color' ) ) ;
65
68
} ) ;
69
+ }
66
70
67
- Registry . getComponentMethod ( 'errorbars' , 'style' ) ( s ) ;
71
+ function styleOnSelect ( gd , cd ) {
72
+ var s = cd [ 0 ] . node3 ;
73
+ var trace = cd [ 0 ] . trace ;
74
+
75
+ if ( trace . selectedpoints ) {
76
+ Drawing . selectedPointStyle ( s . selectAll ( 'path' ) , trace ) ;
77
+ Drawing . selectedTextStyle ( s . selectAll ( 'text' ) , trace ) ;
78
+ } else {
79
+ stylePoints ( s , trace , gd ) ;
80
+ }
81
+ }
82
+
83
+ module . exports = {
84
+ style : style ,
85
+ styleOnSelect : styleOnSelect
68
86
} ;
0 commit comments