Skip to content

Commit edc2393

Browse files
authored
Merge pull request #336 from huerlisi/fixes/utilization-bar-arianow
Improve aria support in utilization bar chart
2 parents 696d90a + 638b2d9 commit edc2393

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/charts/utilization-bar/utilization-bar-chart.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
<span ng-if="!layout || layout.type === 'regular'">
33
<div ng-if="chartTitle" class="progress-description">{{chartTitle}}</div>
44
<div class="progress progress-label-top-right" ng-if="chartData.dataAvailable !== false">
5-
<div class="progress-bar" role="progressbar" ng-class="{'animate': animate,
5+
<div class="progress-bar" aria-valuenow="{{chartData.percentageUsed}}" aria-valuemin="0" aria-valuemax="100" ng-class="{'animate': animate,
66
'progress-bar-success': isOk, 'progress-bar-danger': isError, 'progress-bar-warning': isWarn}"
77
ng-style="{width:chartData.percentageUsed + '%'}" tooltip="{{chartData.percentageUsed}}% Used" >
88
<span ng-if="chartFooter" ng-bind-html="chartFooter"></span>
99
<span ng-if="!chartFooter && (!footerLabelFormat || footerLabelFormat === 'actual')"><strong>{{chartData.used}} of {{chartData.total}} {{units}}</strong> Used</span>
1010
<span ng-if="!chartFooter && footerLabelFormat === 'percent'"><strong>{{chartData.percentageUsed}}%</strong> Used</span>
1111
</div>
12-
<div class="progress-bar progress-bar-remaining" role="progressbar" aria-valuenow="5" aria-valuemin="0" aria-valuemax="100"
12+
<div class="progress-bar progress-bar-remaining"
1313
ng-style="{width:(100 - chartData.percentageUsed) + '%'}" tooltip="{{100 - chartData.percentageUsed}}% Available">
1414
</div>
1515
</div>
@@ -19,14 +19,14 @@
1919
ng-style="{'padding-left':layout.titleLabelWidth, 'padding-right':layout.footerLabelWidth}">
2020
<div ng-if="chartTitle" class="progress-description" ng-style="{'max-width':layout.titleLabelWidth}">{{chartTitle}}</div>
2121
<div class="progress" ng-if="chartData.dataAvailable !== false">
22-
<div class="progress-bar" role="progressbar" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"
22+
<div class="progress-bar" aria-valuenow="{{chartData.percentageUsed}}" aria-valuemin="0" aria-valuemax="100"
2323
ng-class="{'animate': animate, 'progress-bar-success': isOk, 'progress-bar-danger': isError, 'progress-bar-warning': isWarn}"
2424
ng-style="{width:chartData.percentageUsed + '%'}" tooltip="{{chartData.percentageUsed}}% Used">
2525
<span ng-if="chartFooter" ng-bind-html="chartFooter"></span>
2626
<span ng-if="(!chartFooter) && (!footerLabelFormat || footerLabelFormat === 'actual')" ng-style="{'max-width':layout.footerLabelWidth}"><strong>{{chartData.used}} {{units}}</strong> Used</span>
2727
<span ng-if="(!chartFooter) && footerLabelFormat === 'percent'" ng-style="{'max-width':layout.footerLabelWidth}"><strong>{{chartData.percentageUsed}}%</strong> Used</span>
2828
</div>
29-
<div class="progress-bar progress-bar-remaining" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100"
29+
<div class="progress-bar progress-bar-remaining"
3030
ng-style="{width:(100 - chartData.percentageUsed) + '%'}" tooltip="{{100 - chartData.percentageUsed}}% Available">
3131
</div>
3232
</div>

test/charts/utilization-bar/utilization-bar.spec.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('Directive: pfUtilizationBarChart', function() {
1717

1818
$scope.data = {
1919
'used': '8',
20-
'total': '16'
20+
'total': '10'
2121
};
2222

2323
$scope.title = 'CPU Usage';
@@ -33,22 +33,27 @@ describe('Directive: pfUtilizationBarChart', function() {
3333
return el;
3434
};
3535

36-
it("should set the width of the inner bar to be 50%", function() {
36+
it("should set the width of the inner bar to be 80%", function() {
3737
utilizationBar = angular.element(element).find('.progress-bar').css('width');
38-
expect(utilizationBar).toBe("50%");
38+
expect(utilizationBar).toBe("80%");
39+
});
40+
41+
it("should set aria-valuenow values", function() {
42+
used = angular.element(element).find('.progress-bar').not('.progress-bar-remaining');
43+
expect(used.attr('aria-valuenow')).toBe("80");
3944
});
4045

4146
it("should set the charts title and usage label", function() {
4247
title = angular.element(element).find('.progress-description').html();
4348
expect(title).toBe("CPU Usage");
4449

4550
subTitle = angular.element(element).find('.progress-bar span').text();
46-
expect(subTitle).toBe("8 of 16 GB Used");
51+
expect(subTitle).toBe("8 of 10 GB Used");
4752

4853
//test 'percent' used-label-format
4954
element = compileChart("<div pf-utilization-bar-chart chart-data=data footer-label-format='percent' chart-title=title units=units></div>", $scope);
5055
subTitle = angular.element(element).find('.progress-bar span').text();
51-
expect(subTitle).toBe("50% Used");
56+
expect(subTitle).toBe("80% Used");
5257
});
5358

5459
it("should set the layout to be 'inline', and use custom widths", function() {

0 commit comments

Comments
 (0)