@@ -693,7 +693,7 @@ angular.module('patternfly.card').directive('pfCard', function () {
693
693
* <li>.units - unit label for values, ex: 'MHz','GB', etc..
694
694
* <li>.thresholds - warning and error percentage thresholds used to determine the Usage Percentage fill color (optional)
695
695
* <li>.tooltipFn(d) - user defined function to customize the tool tip (optional)
696
- * <li>.centerLabelFn - user defined function to customize the center label (optional)
696
+ * <li>.centerLabelFn - user defined function to customize the text of the center label (optional)
697
697
* <li>.onClickFn(d,i) - user defined function to handle when donut arc is clicked upon.
698
698
* </ul>
699
699
*
@@ -885,8 +885,7 @@ angular.module('patternfly.card').directive('pfCard', function () {
885
885
'</span>';
886
886
},
887
887
'centerLabelFn': function () {
888
- return '<tspan dy="0" x="0" class="donut-title-big-pf">' + $scope.custData.available + '</tspan>' +
889
- '<tspan dy="20" x="0" class="donut-title-small-pf">Free</tspan>';
888
+ return $scope.custData.available + " GB";
890
889
},
891
890
'onClickFn': function (d, i) {
892
891
alert("You Clicked On The Donut!");
@@ -1035,23 +1034,20 @@ angular.module('patternfly.charts').directive('pfDonutPctChart', ["c3ChartDefaul
1035
1034
$timeout ( function ( ) {
1036
1035
var donutChartTitle , centerLabelText ;
1037
1036
1038
- donutChartTitle = element [ 0 ] . querySelector ( 'text.c3-chart-arcs-title' ) ;
1037
+ donutChartTitle = d3 . select ( element [ 0 ] ) . select ( 'text.c3-chart-arcs-title' ) ;
1039
1038
if ( ! donutChartTitle ) {
1040
1039
return ;
1041
1040
}
1042
1041
1043
1042
centerLabelText = scope . getCenterLabelText ( ) ;
1044
1043
1044
+ // Remove any existing title.
1045
+ donutChartTitle . selectAll ( '*' ) . remove ( ) ;
1045
1046
if ( centerLabelText . bigText && ! centerLabelText . smText ) {
1046
- donutChartTitle . innerHTML = centerLabelText . bigText ;
1047
+ donutChartTitle . text ( centerLabelText . bigText ) ;
1047
1048
} else {
1048
- donutChartTitle . innerHTML =
1049
- '<tspan dy="0" x="0" class="donut-title-big-pf">' +
1050
- centerLabelText . bigText +
1051
- '</tspan>' +
1052
- '<tspan dy="20" x="0" class="donut-title-small-pf">' +
1053
- centerLabelText . smText +
1054
- '</tspan>' ;
1049
+ donutChartTitle . insert ( 'tspan' ) . text ( centerLabelText . bigText ) . classed ( 'donut-title-big-pf' , true ) . attr ( 'dy' , 0 ) . attr ( 'x' , 0 ) ;
1050
+ donutChartTitle . insert ( 'tspan' ) . text ( centerLabelText . smText ) . classed ( 'donut-title-small-pf' , true ) . attr ( 'dy' , 20 ) . attr ( 'x' , 0 ) ;
1055
1051
}
1056
1052
} , 300 ) ;
1057
1053
} ;
0 commit comments