@@ -34,6 +34,7 @@ module.exports = function style(s, gd, legend) {
34
34
var constantItemSizing = legend . itemsizing === 'constant' ;
35
35
var itemWidth = legend . itemwidth ;
36
36
var centerPos = ( itemWidth + constants . itemGap * 2 ) / 2 ;
37
+ var centerTransform = 'translate(' + centerPos + ',0)' ;
37
38
38
39
var boundLineWidth = function ( mlw , cont , max , cst ) {
39
40
var v ;
@@ -275,7 +276,7 @@ module.exports = function style(s, gd, legend) {
275
276
// make sure marker is on the bottom, in case it enters after text
276
277
pts . enter ( ) . insert ( 'path' , ':first-child' )
277
278
. classed ( 'scatterpts' , true )
278
- . attr ( 'transform' , 'translate(' + centerPos + ',0)' ) ;
279
+ . attr ( 'transform' , centerTransform ) ;
279
280
pts . exit ( ) . remove ( ) ;
280
281
pts . call ( Drawing . pointStyle , tMod , gd ) ;
281
282
@@ -287,7 +288,7 @@ module.exports = function style(s, gd, legend) {
287
288
. data ( showText ? dMod : [ ] ) ;
288
289
txt . enter ( )
289
290
. append ( 'g' ) . classed ( 'pointtext' , true )
290
- . append ( 'text' ) . attr ( 'transform' , 'translate(' + centerPos + ',0)' ) ;
291
+ . append ( 'text' ) . attr ( 'transform' , centerTransform ) ;
291
292
txt . exit ( ) . remove ( ) ;
292
293
txt . selectAll ( 'text' ) . call ( Drawing . textPointStyle , tMod , gd ) ;
293
294
}
@@ -315,7 +316,7 @@ module.exports = function style(s, gd, legend) {
315
316
. selectAll ( 'path.legendwaterfall' )
316
317
. data ( ptsData ) ;
317
318
pts . enter ( ) . append ( 'path' ) . classed ( 'legendwaterfall' , true )
318
- . attr ( 'transform' , 'translate(' + centerPos + ',0)' )
319
+ . attr ( 'transform' , centerTransform )
319
320
. style ( 'stroke-miterlimit' , 1 ) ;
320
321
pts . exit ( ) . remove ( ) ;
321
322
@@ -355,7 +356,7 @@ module.exports = function style(s, gd, legend) {
355
356
. data ( isVisible ? [ d ] : [ ] ) ;
356
357
barpath . enter ( ) . append ( 'path' ) . classed ( 'legend' + desiredType , true )
357
358
. attr ( 'd' , 'M6,6H-6V-6H6Z' )
358
- . attr ( 'transform' , 'translate(' + centerPos + ',0)' ) ;
359
+ . attr ( 'transform' , centerTransform ) ;
359
360
barpath . exit ( ) . remove ( ) ;
360
361
361
362
barpath . each ( function ( d ) {
@@ -379,7 +380,7 @@ module.exports = function style(s, gd, legend) {
379
380
pts . enter ( ) . append ( 'path' ) . classed ( 'legendbox' , true )
380
381
// if we want the median bar, prepend M6,0H-6
381
382
. attr ( 'd' , 'M6,6H-6V-6H6Z' )
382
- . attr ( 'transform' , 'translate(' + centerPos + ',0)' ) ;
383
+ . attr ( 'transform' , centerTransform ) ;
383
384
pts . exit ( ) . remove ( ) ;
384
385
385
386
pts . each ( function ( ) {
@@ -419,7 +420,7 @@ module.exports = function style(s, gd, legend) {
419
420
if ( i ) return 'M-15,0H-8M-8,6V-6H8Z' ; // increasing
420
421
return 'M15,0H8M8,-6V6H-8Z' ; // decreasing
421
422
} )
422
- . attr ( 'transform' , 'translate(' + centerPos + ',0)' )
423
+ . attr ( 'transform' , centerTransform )
423
424
. style ( 'stroke-miterlimit' , 1 ) ;
424
425
pts . exit ( ) . remove ( ) ;
425
426
@@ -446,7 +447,7 @@ module.exports = function style(s, gd, legend) {
446
447
if ( i ) return 'M-15,0H0M-8,-6V0' ; // increasing
447
448
return 'M15,0H0M8,6V0' ; // decreasing
448
449
} )
449
- . attr ( 'transform' , 'translate(' + centerPos + ',0)' )
450
+ . attr ( 'transform' , centerTransform )
450
451
. style ( 'stroke-miterlimit' , 1 ) ;
451
452
pts . exit ( ) . remove ( ) ;
452
453
@@ -482,7 +483,7 @@ module.exports = function style(s, gd, legend) {
482
483
. data ( isVisible ? [ d ] : [ ] ) ;
483
484
pts . enter ( ) . append ( 'path' ) . classed ( 'legend' + desiredType , true )
484
485
. attr ( 'd' , 'M6,6H-6V-6H6Z' )
485
- . attr ( 'transform' , 'translate(' + centerPos + ',0)' ) ;
486
+ . attr ( 'transform' , centerTransform ) ;
486
487
pts . exit ( ) . remove ( ) ;
487
488
488
489
if ( pts . size ( ) ) {
@@ -580,7 +581,7 @@ module.exports = function style(s, gd, legend) {
580
581
. selectAll ( 'path.legend3dandfriends' )
581
582
. data ( ptsData ) ;
582
583
pts . enter ( ) . append ( 'path' ) . classed ( 'legend3dandfriends' , true )
583
- . attr ( 'transform' , 'translate(' + centerPos + ',0)' )
584
+ . attr ( 'transform' , centerTransform )
584
585
. style ( 'stroke-miterlimit' , 1 ) ;
585
586
pts . exit ( ) . remove ( ) ;
586
587
0 commit comments