@@ -44,7 +44,7 @@ function donutChart() {
4444 . attr ( 'height' , height + margin . top + margin . bottom )
4545 . attr ( 'class' , 'backColorChart' )
4646 . append ( 'g' )
47- . attr ( 'transform' , 'translate(' + width / 2 + ',' + height / 2 + ')' ) ;
47+ . attr ( 'transform' , 'translate(' + ( width / 2 + 30 ) + ',' + ( height / 2 + 30 ) + ')' ) ;
4848 // ===========================================================================================
4949
5050 // ===========================================================================================
@@ -83,6 +83,12 @@ function donutChart() {
8383
8484 // changes the point to be on left or right depending on where label is.
8585 pos [ 0 ] = radius * 0.95 * ( midAngle ( d ) < Math . PI ? 1 : - 1 ) ;
86+
87+ if ( d . data . percentage < 0.10 || d . data . url == 'Others' ) {
88+ pos [ 0 ] = pos [ 0 ] * 1.1 ;
89+ pos [ 1 ] = pos [ 1 ] * 1.15 ;
90+ }
91+
8692 return 'translate(' + pos + ')' ;
8793 } )
8894 . style ( 'text-anchor' , function ( d ) {
@@ -98,10 +104,14 @@ function donutChart() {
98104 . data ( pie )
99105 . enter ( ) . append ( 'polyline' )
100106 . attr ( 'points' , function ( d ) {
101-
102107 // see label transform function for explanations of these three lines.
103108 var pos = outerArc . centroid ( d ) ;
104109 pos [ 0 ] = radius * 0.95 * ( midAngle ( d ) < Math . PI ? 1 : - 1 ) ;
110+
111+ if ( d . data . percentage < 0.10 || d . data . url == 'Others' ) {
112+ pos [ 0 ] = pos [ 0 ] * 1.1 ;
113+ pos [ 1 ] = pos [ 1 ] * 1.15 ;
114+ }
105115 return [ arc . centroid ( d ) , outerArc . centroid ( d ) , pos ]
106116 } ) ;
107117 // ===========================================================================================
0 commit comments