@@ -645,7 +645,7 @@ angular.module('patternfly.card').directive('pfCard', function () {
645645 * <li>.units - unit label for values, ex: 'MHz','GB', etc..
646646 * <li>.thresholds - warning and error percentage thresholds used to determine the Usage Percentage fill color (optional)
647647 * <li>.tooltipFn - user defined function to customize the tool tip (optional)
648- * <li>.centerLabelFn - user defined function to customize the center label (optional)
648+ * <li>.centerLabelFn - user defined function to customize the text of the center label (optional)
649649 * </ul>
650650 *
651651 * @param {object } data the Total and Used values for the donut chart. Available is calculated as Total - Used.<br/>
@@ -816,8 +816,7 @@ angular.module('patternfly.card').directive('pfCard', function () {
816816 '</span>';
817817 },
818818 'centerLabelFn': function () {
819- return '<tspan dy="0" x="0" class="donut-title-big-pf">' + $scope.custData.available + '</tspan>' +
820- '<tspan dy="20" x="0" class="donut-title-small-pf">Free</tspan>';
819+ return $scope.custData.available + " GB";
821820 }
822821 };
823822
@@ -962,23 +961,20 @@ angular.module('patternfly.charts').directive('pfDonutPctChart', ["c3ChartDefaul
962961 $timeout ( function ( ) {
963962 var donutChartTitle , centerLabelText ;
964963
965- donutChartTitle = element [ 0 ] . querySelector ( 'text.c3-chart-arcs-title' ) ;
964+ donutChartTitle = d3 . select ( element [ 0 ] ) . select ( 'text.c3-chart-arcs-title' ) ;
966965 if ( ! donutChartTitle ) {
967966 return ;
968967 }
969968
970969 centerLabelText = scope . getCenterLabelText ( ) ;
971970
971+ // Remove any existing title.
972+ donutChartTitle . selectAll ( '*' ) . remove ( ) ;
972973 if ( centerLabelText . bigText && ! centerLabelText . smText ) {
973- donutChartTitle . innerHTML = centerLabelText . bigText ;
974+ donutChartTitle . text ( centerLabelText . bigText ) ;
974975 } else {
975- donutChartTitle . innerHTML =
976- '<tspan dy="0" x="0" class="donut-title-big-pf">' +
977- centerLabelText . bigText +
978- '</tspan>' +
979- '<tspan dy="20" x="0" class="donut-title-small-pf">' +
980- centerLabelText . smText +
981- '</tspan>' ;
976+ donutChartTitle . insert ( 'tspan' ) . text ( centerLabelText . bigText ) . classed ( 'donut-title-big-pf' , true ) . attr ( 'dy' , 0 ) . attr ( 'x' , 0 ) ;
977+ donutChartTitle . insert ( 'tspan' ) . text ( centerLabelText . smText ) . classed ( 'donut-title-small-pf' , true ) . attr ( 'dy' , 20 ) . attr ( 'x' , 0 ) ;
982978 }
983979 } , 300 ) ;
984980 } ;
0 commit comments