33var d3 = require ( '@plotly/d3' ) ;
44
55var Drawing = require ( '../../components/drawing' ) ;
6+ var Color = require ( '../../components/color' ) ;
7+ var DESELECTDIM = require ( '../../constants/interactions' ) . DESELECTDIM ;
68
79function style ( gd ) {
810 var s = d3 . select ( gd ) . selectAll ( 'g.trace.quiver' ) ;
@@ -22,9 +24,36 @@ function styleOnSelect(gd, cd, sel) {
2224
2325 if ( ! sel ) return ;
2426
25- // Style the line paths based on selection state
26- sel . selectAll ( 'path.js-line' )
27- . call ( Drawing . lineGroupStyle , line . width , line . color , line . dash ) ;
27+ if ( trace . selectedpoints ) {
28+ var selectedAttrs = trace . selected || { } ;
29+ var unselectedAttrs = trace . unselected || { } ;
30+ var selectedLine = selectedAttrs . line || { } ;
31+ var unselectedLine = unselectedAttrs . line || { } ;
32+
33+ sel . selectAll ( 'path.js-line' ) . each ( function ( d ) {
34+ var path = d3 . select ( this ) ;
35+
36+ if ( d . selected ) {
37+ var sc = selectedLine . color || line . color ;
38+ var sw = selectedLine . width !== undefined ? selectedLine . width : line . width ;
39+ Drawing . lineGroupStyle ( path , sw , sc , line . dash ) ;
40+ } else {
41+ var uc = unselectedLine . color ;
42+ var uw = unselectedLine . width ;
43+ if ( ! uc ) {
44+ uc = line . color ? Color . addOpacity ( line . color , DESELECTDIM ) : undefined ;
45+ }
46+ if ( uw === undefined ) uw = line . width ;
47+ Drawing . lineGroupStyle ( path , uw , uc , line . dash ) ;
48+ }
49+ } ) ;
50+
51+ Drawing . selectedTextStyle ( sel . selectAll ( 'text' ) , trace ) ;
52+ } else {
53+ sel . selectAll ( 'path.js-line' )
54+ . call ( Drawing . lineGroupStyle , line . width , line . color , line . dash ) ;
55+ Drawing . textPointStyle ( sel . selectAll ( 'text' ) , trace , gd ) ;
56+ }
2857}
2958
3059module . exports = {
0 commit comments