@@ -34,6 +34,7 @@ module.exports = function style(s, gd, legend) {
3434 var constantItemSizing = legend . itemsizing === 'constant' ;
3535 var itemWidth = legend . itemwidth ;
3636 var centerPos = ( itemWidth + constants . itemGap * 2 ) / 2 ;
37+ var centerTransform = 'translate(' + centerPos + ',0)' ;
3738
3839 var boundLineWidth = function ( mlw , cont , max , cst ) {
3940 var v ;
@@ -275,7 +276,7 @@ module.exports = function style(s, gd, legend) {
275276 // make sure marker is on the bottom, in case it enters after text
276277 pts . enter ( ) . insert ( 'path' , ':first-child' )
277278 . classed ( 'scatterpts' , true )
278- . attr ( 'transform' , 'translate(' + centerPos + ',0)' ) ;
279+ . attr ( 'transform' , centerTransform ) ;
279280 pts . exit ( ) . remove ( ) ;
280281 pts . call ( Drawing . pointStyle , tMod , gd ) ;
281282
@@ -287,7 +288,7 @@ module.exports = function style(s, gd, legend) {
287288 . data ( showText ? dMod : [ ] ) ;
288289 txt . enter ( )
289290 . append ( 'g' ) . classed ( 'pointtext' , true )
290- . append ( 'text' ) . attr ( 'transform' , 'translate(' + centerPos + ',0)' ) ;
291+ . append ( 'text' ) . attr ( 'transform' , centerTransform ) ;
291292 txt . exit ( ) . remove ( ) ;
292293 txt . selectAll ( 'text' ) . call ( Drawing . textPointStyle , tMod , gd ) ;
293294 }
@@ -315,7 +316,7 @@ module.exports = function style(s, gd, legend) {
315316 . selectAll ( 'path.legendwaterfall' )
316317 . data ( ptsData ) ;
317318 pts . enter ( ) . append ( 'path' ) . classed ( 'legendwaterfall' , true )
318- . attr ( 'transform' , 'translate(' + centerPos + ',0)' )
319+ . attr ( 'transform' , centerTransform )
319320 . style ( 'stroke-miterlimit' , 1 ) ;
320321 pts . exit ( ) . remove ( ) ;
321322
@@ -355,7 +356,7 @@ module.exports = function style(s, gd, legend) {
355356 . data ( isVisible ? [ d ] : [ ] ) ;
356357 barpath . enter ( ) . append ( 'path' ) . classed ( 'legend' + desiredType , true )
357358 . attr ( 'd' , 'M6,6H-6V-6H6Z' )
358- . attr ( 'transform' , 'translate(' + centerPos + ',0)' ) ;
359+ . attr ( 'transform' , centerTransform ) ;
359360 barpath . exit ( ) . remove ( ) ;
360361
361362 barpath . each ( function ( d ) {
@@ -379,7 +380,7 @@ module.exports = function style(s, gd, legend) {
379380 pts . enter ( ) . append ( 'path' ) . classed ( 'legendbox' , true )
380381 // if we want the median bar, prepend M6,0H-6
381382 . attr ( 'd' , 'M6,6H-6V-6H6Z' )
382- . attr ( 'transform' , 'translate(' + centerPos + ',0)' ) ;
383+ . attr ( 'transform' , centerTransform ) ;
383384 pts . exit ( ) . remove ( ) ;
384385
385386 pts . each ( function ( ) {
@@ -419,7 +420,7 @@ module.exports = function style(s, gd, legend) {
419420 if ( i ) return 'M-15,0H-8M-8,6V-6H8Z' ; // increasing
420421 return 'M15,0H8M8,-6V6H-8Z' ; // decreasing
421422 } )
422- . attr ( 'transform' , 'translate(' + centerPos + ',0)' )
423+ . attr ( 'transform' , centerTransform )
423424 . style ( 'stroke-miterlimit' , 1 ) ;
424425 pts . exit ( ) . remove ( ) ;
425426
@@ -446,7 +447,7 @@ module.exports = function style(s, gd, legend) {
446447 if ( i ) return 'M-15,0H0M-8,-6V0' ; // increasing
447448 return 'M15,0H0M8,6V0' ; // decreasing
448449 } )
449- . attr ( 'transform' , 'translate(' + centerPos + ',0)' )
450+ . attr ( 'transform' , centerTransform )
450451 . style ( 'stroke-miterlimit' , 1 ) ;
451452 pts . exit ( ) . remove ( ) ;
452453
@@ -482,7 +483,7 @@ module.exports = function style(s, gd, legend) {
482483 . data ( isVisible ? [ d ] : [ ] ) ;
483484 pts . enter ( ) . append ( 'path' ) . classed ( 'legend' + desiredType , true )
484485 . attr ( 'd' , 'M6,6H-6V-6H6Z' )
485- . attr ( 'transform' , 'translate(' + centerPos + ',0)' ) ;
486+ . attr ( 'transform' , centerTransform ) ;
486487 pts . exit ( ) . remove ( ) ;
487488
488489 if ( pts . size ( ) ) {
@@ -580,7 +581,7 @@ module.exports = function style(s, gd, legend) {
580581 . selectAll ( 'path.legend3dandfriends' )
581582 . data ( ptsData ) ;
582583 pts . enter ( ) . append ( 'path' ) . classed ( 'legend3dandfriends' , true )
583- . attr ( 'transform' , 'translate(' + centerPos + ',0)' )
584+ . attr ( 'transform' , centerTransform )
584585 . style ( 'stroke-miterlimit' , 1 ) ;
585586 pts . exit ( ) . remove ( ) ;
586587
0 commit comments