Skip to content

Commit d44fcea

Browse files
committedOct 26, 2015
Merge pull request #139 from erundle/branch-2.3.x
Don't use innerHTML on SVG elements when setting donut title
2 parents 1587afb + 721f872 commit d44fcea

File tree

5 files changed

+20
-28
lines changed

5 files changed

+20
-28
lines changed
 

Diff for: ‎bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-patternfly",
3-
"version": "2.3.2",
3+
"version": "2.3.3",
44
"authors": [
55
"Red Hat"
66
],

Diff for: ‎dist/angular-patternfly.js

+8-12
Original file line numberDiff line numberDiff line change
@@ -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
};

Diff for: ‎dist/angular-patternfly.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"author": "Red Hat",
33
"name": "angular-patternfly",
4-
"version": "2.3.2",
4+
"version": "2.3.3",
55
"description": "Angular extension of the PatternFly project.",
66
"homepage": "https://github.com/patternfly/angular-patternfly",
77
"dependencies": {},

Diff for: ‎src/charts/donut/donut-pct-chart-directive.js

+8-12
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* <li>.units - unit label for values, ex: 'MHz','GB', etc..
2424
* <li>.thresholds - warning and error percentage thresholds used to determine the Usage Percentage fill color (optional)
2525
* <li>.tooltipFn - user defined function to customize the tool tip (optional)
26-
* <li>.centerLabelFn - user defined function to customize the center label (optional)
26+
* <li>.centerLabelFn - user defined function to customize the text of the center label (optional)
2727
* </ul>
2828
*
2929
* @param {object} data the Total and Used values for the donut chart. Available is calculated as Total - Used.<br/>
@@ -194,8 +194,7 @@
194194
'</span>';
195195
},
196196
'centerLabelFn': function () {
197-
return '<tspan dy="0" x="0" class="donut-title-big-pf">' + $scope.custData.available + '</tspan>' +
198-
'<tspan dy="20" x="0" class="donut-title-small-pf">Free</tspan>';
197+
return $scope.custData.available + " GB";
199198
}
200199
};
201200
@@ -340,23 +339,20 @@ angular.module('patternfly.charts').directive('pfDonutPctChart', function (c3Cha
340339
$timeout(function () {
341340
var donutChartTitle, centerLabelText;
342341

343-
donutChartTitle = element[0].querySelector('text.c3-chart-arcs-title');
342+
donutChartTitle = d3.select(element[0]).select('text.c3-chart-arcs-title');
344343
if (!donutChartTitle) {
345344
return;
346345
}
347346

348347
centerLabelText = scope.getCenterLabelText();
349348

349+
// Remove any existing title.
350+
donutChartTitle.selectAll('*').remove();
350351
if (centerLabelText.bigText && !centerLabelText.smText) {
351-
donutChartTitle.innerHTML = centerLabelText.bigText;
352+
donutChartTitle.text(centerLabelText.bigText);
352353
} else {
353-
donutChartTitle.innerHTML =
354-
'<tspan dy="0" x="0" class="donut-title-big-pf">' +
355-
centerLabelText.bigText +
356-
'</tspan>' +
357-
'<tspan dy="20" x="0" class="donut-title-small-pf">' +
358-
centerLabelText.smText +
359-
'</tspan>';
354+
donutChartTitle.insert('tspan').text(centerLabelText.bigText).classed('donut-title-big-pf', true).attr('dy', 0).attr('x', 0);
355+
donutChartTitle.insert('tspan').text(centerLabelText.smText).classed('donut-title-small-pf', true).attr('dy', 20).attr('x', 0);
360356
}
361357
}, 300);
362358
};

0 commit comments

Comments
 (0)