@@ -700,7 +700,7 @@ angular.module('patternfly.card').directive('pfCard', function () {
700
700
* <li>.units - unit label for values, ex: 'MHz','GB', etc..
701
701
* <li>.thresholds - warning and error percentage thresholds used to determine the Usage Percentage fill color (optional)
702
702
* <li>.tooltipFn(d) - user defined function to customize the tool tip (optional)
703
- * <li>.centerLabelFn - user defined function to customize the center label (optional)
703
+ * <li>.centerLabelFn - user defined function to customize the text of the center label (optional)
704
704
* <li>.onClickFn(d,i) - user defined function to handle when donut arc is clicked upon.
705
705
* </ul>
706
706
*
@@ -892,8 +892,7 @@ angular.module('patternfly.card').directive('pfCard', function () {
892
892
'</span>';
893
893
},
894
894
'centerLabelFn': function () {
895
- return '<tspan dy="0" x="0" class="donut-title-big-pf">' + $scope.custData.available + '</tspan>' +
896
- '<tspan dy="20" x="0" class="donut-title-small-pf">Free</tspan>';
895
+ return $scope.custData.available + " GB";
897
896
},
898
897
'onClickFn': function (d, i) {
899
898
alert("You Clicked On The Donut!");
@@ -1042,23 +1041,20 @@ angular.module('patternfly.charts').directive('pfDonutPctChart', ["c3ChartDefaul
1042
1041
$timeout ( function ( ) {
1043
1042
var donutChartTitle , centerLabelText ;
1044
1043
1045
- donutChartTitle = element [ 0 ] . querySelector ( 'text.c3-chart-arcs-title' ) ;
1044
+ donutChartTitle = d3 . select ( element [ 0 ] ) . select ( 'text.c3-chart-arcs-title' ) ;
1046
1045
if ( ! donutChartTitle ) {
1047
1046
return ;
1048
1047
}
1049
1048
1050
1049
centerLabelText = scope . getCenterLabelText ( ) ;
1051
1050
1051
+ // Remove any existing title.
1052
+ donutChartTitle . selectAll ( '*' ) . remove ( ) ;
1052
1053
if ( centerLabelText . bigText && ! centerLabelText . smText ) {
1053
- donutChartTitle . innerHTML = centerLabelText . bigText ;
1054
+ donutChartTitle . text ( centerLabelText . bigText ) ;
1054
1055
} else {
1055
- donutChartTitle . innerHTML =
1056
- '<tspan dy="0" x="0" class="donut-title-big-pf">' +
1057
- centerLabelText . bigText +
1058
- '</tspan>' +
1059
- '<tspan dy="20" x="0" class="donut-title-small-pf">' +
1060
- centerLabelText . smText +
1061
- '</tspan>' ;
1056
+ donutChartTitle . insert ( 'tspan' ) . text ( centerLabelText . bigText ) . classed ( 'donut-title-big-pf' , true ) . attr ( 'dy' , 0 ) . attr ( 'x' , 0 ) ;
1057
+ donutChartTitle . insert ( 'tspan' ) . text ( centerLabelText . smText ) . classed ( 'donut-title-small-pf' , true ) . attr ( 'dy' , 20 ) . attr ( 'x' , 0 ) ;
1062
1058
}
1063
1059
} , 300 ) ;
1064
1060
} ;
0 commit comments