@@ -13,7 +13,7 @@ var d3 = require('d3');
1313var Drawing = require ( '../../components/drawing' ) ;
1414var Registry = require ( '../../registry' ) ;
1515
16- module . exports = function style ( gd , cd ) {
16+ function style ( gd , cd ) {
1717 var s = cd ? cd [ 0 ] . node3 : d3 . select ( gd ) . selectAll ( 'g.trace.bars' ) ;
1818 var barcount = s . size ( ) ;
1919 var fullLayout = gd . _fullLayout ;
@@ -35,34 +35,52 @@ module.exports = function style(gd, cd) {
3535
3636 s . selectAll ( 'g.points' ) . each ( function ( d ) {
3737 var sel = d3 . select ( this ) ;
38- var pts = sel . selectAll ( 'path' ) ;
39- var txs = sel . selectAll ( 'text' ) ;
4038 var trace = d [ 0 ] . trace ;
39+ stylePoints ( sel , trace , gd ) ;
40+ } ) ;
41+
42+ Registry . getComponentMethod ( 'errorbars' , 'style' ) ( s ) ;
43+ }
4144
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' ) ;
4448
45- txs . each ( function ( d ) {
46- var tx = d3 . select ( this ) ;
47- var textFont ;
49+ Drawing . pointStyle ( pts , trace , gd ) ;
4850
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 ;
5554
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 ;
6061
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+ }
6366
64- Drawing . selectedTextStyle ( txs , trace ) ;
67+ Drawing . font ( tx , cast ( 'family' ) , cast ( 'size' ) , cast ( 'color' ) ) ;
6568 } ) ;
69+ }
6670
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
6886} ;
0 commit comments