@@ -7,19 +7,12 @@ require('d3-tip')(d3);
77
88module . exports = function ( data , g , width , height , options ) {
99
10- // if legend present, save some space
11- var scaleWidth = 40 ;
12-
1310 options = _ . defaults ( options || { } , {
1411 bgbars : false ,
1512 scale : false ,
1613 labels : false // label defaults will be set further below
1714 } ) ;
1815
19- // if (options.scale) {
20- // width = width - scaleWidth;
21- // }
22-
2316 var x = d3 . scale . ordinal ( )
2417 . domain ( _ . pluck ( data , 'label' ) )
2518 . rangeBands ( [ 0 , width ] , 0.3 , 0.0 ) ;
@@ -62,49 +55,49 @@ module.exports = function(data, g, width, height, options) {
6255
6356 legend . append ( 'text' )
6457 . attr ( 'class' , 'legend' )
65- . attr ( 'x' , width )
66- . attr ( 'dx' , '1em' )
58+ . attr ( 'x' , 0 )
59+ . attr ( 'dx' , '- 1em' )
6760 . attr ( 'y' , 0 )
6861 . attr ( 'dy' , '0.3em' )
69- . attr ( 'text-anchor' , 'start ' )
62+ . attr ( 'text-anchor' , 'end ' )
7063 . text ( d3 . max ( y . domain ( ) ) + '%' ) ;
7164
7265 legend . append ( 'text' )
7366 . attr ( 'class' , 'legend' )
74- . attr ( 'x' , width )
75- . attr ( 'dx' , '1em' )
67+ . attr ( 'x' , 0 )
68+ . attr ( 'dx' , '- 1em' )
7669 . attr ( 'y' , height / 2 )
7770 . attr ( 'dy' , '0.3em' )
78- . attr ( 'text-anchor' , 'start ' )
71+ . attr ( 'text-anchor' , 'end ' )
7972 . text ( d3 . max ( y . domain ( ) ) / 2 + '%' ) ;
8073
8174 legend . append ( 'text' )
8275 . attr ( 'class' , 'legend' )
83- . attr ( 'x' , width )
84- . attr ( 'dx' , '1em' )
76+ . attr ( 'x' , 0 )
77+ . attr ( 'dx' , '- 1em' )
8578 . attr ( 'y' , height )
8679 . attr ( 'dy' , '0.3em' )
87- . attr ( 'text-anchor' , 'start ' )
88- . text ( '0 %' ) ;
80+ . attr ( 'text-anchor' , 'end ' )
81+ . text ( '99.9 %' ) ;
8982
9083 legend . append ( 'line' )
9184 . attr ( 'class' , 'bg legend' )
92- . attr ( 'x1' , 0 )
93- . attr ( 'x2' , width + 5 )
85+ . attr ( 'x1' , - 5 )
86+ . attr ( 'x2' , width )
9487 . attr ( 'y1' , 0 )
9588 . attr ( 'y2' , 0 ) ;
9689
9790 legend . append ( 'line' )
9891 . attr ( 'class' , 'bg legend' )
99- . attr ( 'x1' , 0 )
100- . attr ( 'x2' , width + 5 )
92+ . attr ( 'x1' , - 5 )
93+ . attr ( 'x2' , width )
10194 . attr ( 'y1' , height / 2 )
10295 . attr ( 'y2' , height / 2 ) ;
10396
10497 legend . append ( 'line' )
10598 . attr ( 'class' , 'bg legend' )
106- . attr ( 'x1' , 0 )
107- . attr ( 'x2' , width + 5 )
99+ . attr ( 'x1' , - 5 )
100+ . attr ( 'x2' , width )
108101 . attr ( 'y1' , height )
109102 . attr ( 'y2' , height ) ;
110103 }
0 commit comments