@@ -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,55 @@ 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+ } ) ;
4141
42- Drawing . pointStyle ( pts , trace , gd ) ;
43- Drawing . selectedPointStyle ( pts , trace ) ;
42+ Registry . getComponentMethod ( 'errorbars' , 'style' ) ( s ) ;
43+ }
4444
45- txs . each ( function ( d ) {
46- var tx = d3 . select ( this ) ;
47- var textFont ;
45+ function stylePoints ( sel , trace , gd ) {
46+ var pts = sel . selectAll ( 'path' ) ;
47+ var txs = sel . selectAll ( 'text' ) ;
4848
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 ;
49+ Drawing . pointStyle ( pts , trace , gd ) ;
50+ Drawing . selectedPointStyle ( pts , trace ) ;
5551
56- function cast ( k ) {
57- var cont = textFont [ k ] ;
58- return Array . isArray ( cont ) ? cont [ d . i ] : cont ;
59- }
52+ txs . each ( function ( d ) {
53+ var tx = d3 . select ( this ) ;
54+ var textFont ;
6055
61- Drawing . font ( tx , cast ( 'family' ) , cast ( 'size' ) , cast ( 'color' ) ) ;
62- } ) ;
56+ if ( tx . classed ( 'bartext-inside' ) ) {
57+ textFont = trace . insidetextfont ;
58+ } else if ( tx . classed ( 'bartext-outside' ) ) {
59+ textFont = trace . outsidetextfont ;
60+ }
61+ if ( ! textFont ) textFont = trace . textfont ;
62+
63+ function cast ( k ) {
64+ var cont = textFont [ k ] ;
65+ return Array . isArray ( cont ) ? cont [ d . i ] : cont ;
66+ }
6367
64- Drawing . selectedTextStyle ( txs , trace ) ;
68+ Drawing . font ( tx , cast ( 'family' ) , cast ( 'size' ) , cast ( 'color' ) ) ;
6569 } ) ;
6670
67- Registry . getComponentMethod ( 'errorbars' , 'style' ) ( s ) ;
71+ Drawing . selectedTextStyle ( txs , trace ) ;
72+ }
73+
74+ function styleOnSelect ( gd , cd ) {
75+ var s = cd [ 0 ] . node3 ;
76+ var trace = cd [ 0 ] . trace ;
77+
78+ if ( trace . selectedpoints ) {
79+ Drawing . selectedPointStyle ( s . selectAll ( 'path' ) , trace , gd ) ;
80+ Drawing . selectedPointStyle ( s . selectAll ( 'text' ) , trace , gd ) ;
81+ } else {
82+ stylePoints ( s , trace , gd ) ;
83+ }
84+ }
85+
86+ module . exports = {
87+ style : style ,
88+ styleOnSelect : styleOnSelect
6889} ;
0 commit comments