@@ -83,13 +83,23 @@ module.exports = function style(s, gd) {
8383 }
8484 }
8585
86+ // with fill and no markers or text, move the line and fill up a bit
87+ // so it's more centered
88+ var markersOrText = subTypes . hasMarkers ( trace ) || subTypes . hasText ( trace ) ;
89+ var anyFill = showFill || showGradientFill ;
90+ var anyLine = showLine || showGradientLine ;
91+ var pathStart = ( markersOrText || ! anyFill ) ? 'M5,0' :
92+ // with a line leave it slightly below center, to leave room for the
93+ // line thickness and because the line is usually more prominent
94+ anyLine ? 'M5,-2' : 'M5,-3' ;
95+
8696 var this3 = d3 . select ( this ) ;
8797
8898 var fill = this3 . select ( '.legendfill' ) . selectAll ( 'path' )
8999 . data ( showFill || showGradientFill ? [ d ] : [ ] ) ;
90100 fill . enter ( ) . append ( 'path' ) . classed ( 'js-fill' , true ) ;
91101 fill . exit ( ) . remove ( ) ;
92- fill . attr ( 'd' , 'M5,0h30v6h -30z')
102+ fill . attr ( 'd' , pathStart + 'h30v6h -30z')
93103 . call ( showFill ? Drawing . fillGroupStyle : fillGradient ) ;
94104
95105 var line = this3 . select ( '.legendlines' ) . selectAll ( 'path' )
@@ -103,7 +113,7 @@ module.exports = function style(s, gd) {
103113 // though there *is* no vertical variation in this case.
104114 // so add an invisibly small angle to the line
105115 // This issue (and workaround) exist across (Mac) Chrome, FF, and Safari
106- line . attr ( 'd' , showGradientLine ? 'M5,0l30, 0.0001' : 'M5,0h30' )
116+ line . attr ( 'd' , pathStart + ( showGradientLine ? 'l30, 0.0001' : 'h30' ) )
107117 . call ( showLine ? Drawing . lineGroupStyle : lineGradient ) ;
108118
109119 function fillGradient ( s ) {
0 commit comments