Skip to content

Don't use innerHTML on SVG elements when setting donut title #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions dist/angular-patternfly.js
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ angular.module('patternfly.card').directive('pfCard', function () {
* <li>.units - unit label for values, ex: 'MHz','GB', etc..
* <li>.thresholds - warning and error percentage thresholds used to determine the Usage Percentage fill color (optional)
* <li>.tooltipFn(d) - user defined function to customize the tool tip (optional)
* <li>.centerLabelFn - user defined function to customize the center label (optional)
* <li>.centerLabelFn - user defined function to customize the text of the center label (optional)
* <li>.onClickFn(d,i) - user defined function to handle when donut arc is clicked upon.
* </ul>
*
Expand Down Expand Up @@ -892,8 +892,7 @@ angular.module('patternfly.card').directive('pfCard', function () {
'</span>';
},
'centerLabelFn': function () {
return '<tspan dy="0" x="0" class="donut-title-big-pf">' + $scope.custData.available + '</tspan>' +
'<tspan dy="20" x="0" class="donut-title-small-pf">Free</tspan>';
return $scope.custData.available + " GB";
},
'onClickFn': function (d, i) {
alert("You Clicked On The Donut!");
Expand Down Expand Up @@ -1042,23 +1041,20 @@ angular.module('patternfly.charts').directive('pfDonutPctChart', ["c3ChartDefaul
$timeout(function () {
var donutChartTitle, centerLabelText;

donutChartTitle = element[0].querySelector('text.c3-chart-arcs-title');
donutChartTitle = d3.select(element[0]).select('text.c3-chart-arcs-title');
if (!donutChartTitle) {
return;
}

centerLabelText = scope.getCenterLabelText();

// Remove any existing title.
donutChartTitle.selectAll('*').remove();
if (centerLabelText.bigText && !centerLabelText.smText) {
donutChartTitle.innerHTML = centerLabelText.bigText;
donutChartTitle.text(centerLabelText.bigText);
} else {
donutChartTitle.innerHTML =
'<tspan dy="0" x="0" class="donut-title-big-pf">' +
centerLabelText.bigText +
'</tspan>' +
'<tspan dy="20" x="0" class="donut-title-small-pf">' +
centerLabelText.smText +
'</tspan>';
donutChartTitle.insert('tspan').text(centerLabelText.bigText).classed('donut-title-big-pf', true).attr('dy', 0).attr('x', 0);
donutChartTitle.insert('tspan').text(centerLabelText.smText).classed('donut-title-small-pf', true).attr('dy', 20).attr('x', 0);
}
}, 300);
};
Expand Down
Loading