Skip to content

Commit 38d1691

Browse files
committed
Don't use innerHTML on SVG elements when setting donut title
Fixes an issue on IE where the donut title is not set.
1 parent 6195ed7 commit 38d1691

File tree

3 files changed

+18
-26
lines changed

3 files changed

+18
-26
lines changed

Diff for: dist/angular-patternfly.js

+8-12
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ angular.module('patternfly.card').directive('pfCard', function () {
693693
* <li>.units - unit label for values, ex: 'MHz','GB', etc..
694694
* <li>.thresholds - warning and error percentage thresholds used to determine the Usage Percentage fill color (optional)
695695
* <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)
697697
* <li>.onClickFn(d,i) - user defined function to handle when donut arc is clicked upon.
698698
* </ul>
699699
*
@@ -885,8 +885,7 @@ angular.module('patternfly.card').directive('pfCard', function () {
885885
'</span>';
886886
},
887887
'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";
890889
},
891890
'onClickFn': function (d, i) {
892891
alert("You Clicked On The Donut!");
@@ -1035,23 +1034,20 @@ angular.module('patternfly.charts').directive('pfDonutPctChart', ["c3ChartDefaul
10351034
$timeout(function () {
10361035
var donutChartTitle, centerLabelText;
10371036

1038-
donutChartTitle = element[0].querySelector('text.c3-chart-arcs-title');
1037+
donutChartTitle = d3.select(element[0]).select('text.c3-chart-arcs-title');
10391038
if (!donutChartTitle) {
10401039
return;
10411040
}
10421041

10431042
centerLabelText = scope.getCenterLabelText();
10441043

1044+
// Remove any existing title.
1045+
donutChartTitle.selectAll('*').remove();
10451046
if (centerLabelText.bigText && !centerLabelText.smText) {
1046-
donutChartTitle.innerHTML = centerLabelText.bigText;
1047+
donutChartTitle.text(centerLabelText.bigText);
10471048
} 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);
10551051
}
10561052
}, 300);
10571053
};

0 commit comments

Comments
 (0)