Skip to content

Commit e66210f

Browse files
committed
Merge pull request #135 from spadgett/ie-donut-title-fix
Don't use innerHTML on SVG elements when setting donut title
2 parents 11357ab + 7d8e367 commit e66210f

File tree

3 files changed

+18
-26
lines changed

3 files changed

+18
-26
lines changed

dist/angular-patternfly.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ angular.module('patternfly.card').directive('pfCard', function () {
700700
* <li>.units - unit label for values, ex: 'MHz','GB', etc..
701701
* <li>.thresholds - warning and error percentage thresholds used to determine the Usage Percentage fill color (optional)
702702
* <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)
704704
* <li>.onClickFn(d,i) - user defined function to handle when donut arc is clicked upon.
705705
* </ul>
706706
*
@@ -892,8 +892,7 @@ angular.module('patternfly.card').directive('pfCard', function () {
892892
'</span>';
893893
},
894894
'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";
897896
},
898897
'onClickFn': function (d, i) {
899898
alert("You Clicked On The Donut!");
@@ -1042,23 +1041,20 @@ angular.module('patternfly.charts').directive('pfDonutPctChart', ["c3ChartDefaul
10421041
$timeout(function () {
10431042
var donutChartTitle, centerLabelText;
10441043

1045-
donutChartTitle = element[0].querySelector('text.c3-chart-arcs-title');
1044+
donutChartTitle = d3.select(element[0]).select('text.c3-chart-arcs-title');
10461045
if (!donutChartTitle) {
10471046
return;
10481047
}
10491048

10501049
centerLabelText = scope.getCenterLabelText();
10511050

1051+
// Remove any existing title.
1052+
donutChartTitle.selectAll('*').remove();
10521053
if (centerLabelText.bigText && !centerLabelText.smText) {
1053-
donutChartTitle.innerHTML = centerLabelText.bigText;
1054+
donutChartTitle.text(centerLabelText.bigText);
10541055
} 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);
10621058
}
10631059
}, 300);
10641060
};

0 commit comments

Comments
 (0)