@@ -7,19 +7,12 @@ require('d3-tip')(d3);
7
7
8
8
module . exports = function ( data , g , width , height , options ) {
9
9
10
- // if legend present, save some space
11
- var scaleWidth = 40 ;
12
-
13
10
options = _ . defaults ( options || { } , {
14
11
bgbars : false ,
15
12
scale : false ,
16
13
labels : false // label defaults will be set further below
17
14
} ) ;
18
15
19
- // if (options.scale) {
20
- // width = width - scaleWidth;
21
- // }
22
-
23
16
var x = d3 . scale . ordinal ( )
24
17
. domain ( _ . pluck ( data , 'label' ) )
25
18
. rangeBands ( [ 0 , width ] , 0.3 , 0.0 ) ;
@@ -62,49 +55,49 @@ module.exports = function(data, g, width, height, options) {
62
55
63
56
legend . append ( 'text' )
64
57
. attr ( 'class' , 'legend' )
65
- . attr ( 'x' , width )
66
- . attr ( 'dx' , '1em' )
58
+ . attr ( 'x' , 0 )
59
+ . attr ( 'dx' , '- 1em' )
67
60
. attr ( 'y' , 0 )
68
61
. attr ( 'dy' , '0.3em' )
69
- . attr ( 'text-anchor' , 'start ' )
62
+ . attr ( 'text-anchor' , 'end ' )
70
63
. text ( d3 . max ( y . domain ( ) ) + '%' ) ;
71
64
72
65
legend . append ( 'text' )
73
66
. attr ( 'class' , 'legend' )
74
- . attr ( 'x' , width )
75
- . attr ( 'dx' , '1em' )
67
+ . attr ( 'x' , 0 )
68
+ . attr ( 'dx' , '- 1em' )
76
69
. attr ( 'y' , height / 2 )
77
70
. attr ( 'dy' , '0.3em' )
78
- . attr ( 'text-anchor' , 'start ' )
71
+ . attr ( 'text-anchor' , 'end ' )
79
72
. text ( d3 . max ( y . domain ( ) ) / 2 + '%' ) ;
80
73
81
74
legend . append ( 'text' )
82
75
. attr ( 'class' , 'legend' )
83
- . attr ( 'x' , width )
84
- . attr ( 'dx' , '1em' )
76
+ . attr ( 'x' , 0 )
77
+ . attr ( 'dx' , '- 1em' )
85
78
. attr ( 'y' , height )
86
79
. attr ( 'dy' , '0.3em' )
87
- . attr ( 'text-anchor' , 'start ' )
88
- . text ( '0 %' ) ;
80
+ . attr ( 'text-anchor' , 'end ' )
81
+ . text ( '99.9 %' ) ;
89
82
90
83
legend . append ( 'line' )
91
84
. attr ( 'class' , 'bg legend' )
92
- . attr ( 'x1' , 0 )
93
- . attr ( 'x2' , width + 5 )
85
+ . attr ( 'x1' , - 5 )
86
+ . attr ( 'x2' , width )
94
87
. attr ( 'y1' , 0 )
95
88
. attr ( 'y2' , 0 ) ;
96
89
97
90
legend . append ( 'line' )
98
91
. attr ( 'class' , 'bg legend' )
99
- . attr ( 'x1' , 0 )
100
- . attr ( 'x2' , width + 5 )
92
+ . attr ( 'x1' , - 5 )
93
+ . attr ( 'x2' , width )
101
94
. attr ( 'y1' , height / 2 )
102
95
. attr ( 'y2' , height / 2 ) ;
103
96
104
97
legend . append ( 'line' )
105
98
. attr ( 'class' , 'bg legend' )
106
- . attr ( 'x1' , 0 )
107
- . attr ( 'x2' , width + 5 )
99
+ . attr ( 'x1' , - 5 )
100
+ . attr ( 'x2' , width )
108
101
. attr ( 'y1' , height )
109
102
. attr ( 'y2' , height ) ;
110
103
}
0 commit comments