Skip to content

Commit f20a02d

Browse files
author
Amineta Lo
committed
Created trend chart and trend card with right label config
1 parent fd9214b commit f20a02d

File tree

4 files changed

+43
-5
lines changed

4 files changed

+43
-5
lines changed

Diff for: src/card/examples/card-trend.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
<pf-card head-title="Cluster Utilization" show-top-border="true" footer="footerConfig" filter="filterConfig" style="width: 50%">
3939
<pf-trends-chart config="configSingle" chart-data="dataSingle"></pf-trends-chart>
4040
</pf-card>
41+
<pf-card head-title="Cluster Utilization" show-top-border="true" footer="footerConfig" filter="filterConfig" style="width: 50%">
42+
<pf-trends-chart config="configRightLabel" chart-data="dataSingle"></pf-trends-chart>
43+
</pf-card>
4144
<label class="label-title">Card with Multiple Trends</label>
4245
<pf-card head-title="Performance" sub-title="Last 30 Days" show-top-border="false"
4346
show-titles-separator="false" style="width: 65%" footer="actionBarConfig">
@@ -81,9 +84,19 @@
8184
'layout' : 'compact',
8285
'valueType' : 'actual',
8386
'units' : 'TB',
84-
'tooltipType' : 'percentage'
87+
'tooltipType' : 'percentage',
8588
};
8689
90+
$scope.configRightLabel = {
91+
'chartId' : 'exampleAltLabelTrendsChart',
92+
'title' : 'Storage Capacity',
93+
'layout' : 'compact',
94+
'valueType' : 'actual',
95+
'units' : 'TB',
96+
'tooltipType' : 'percentage',
97+
'compactLabelPosition' : 'right'
98+
}
99+
87100
$scope.dataSingle = {
88101
'total': '250',
89102
'xData': dates,

Diff for: src/charts/trends/trends-chart.component.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* <li>.chartId - the unique id of this trends chart
1616
* <li>.title - (optional) title of the Trends chart
1717
* <li>.layout - (optional) the layout and sizes of titles and chart. Values are 'large' (default), 'small', 'compact', and 'inline'
18+
* <li>.compactLabelPosition - (optional) the trend label positioning when the layout value is 'compact'. Values are 'left' (default) or 'right'
1819
* <li>.trendLabel - (optional) the trend label used in the 'inline' layout
1920
* <li>.timeFrame - (optional) the time frame for the data in the pfSparklineChart, ex: 'Last 30 Days'
2021
* <li>.units - unit label for values, ex: 'MHz','GB', etc..
@@ -101,7 +102,7 @@
101102
</div>
102103
</div>
103104
<div class="row">
104-
<div class="col-md-6">
105+
<div class="col-md-4">
105106
<form role="form"">
106107
<div class="form-group">
107108
<label class="checkbox-inline">
@@ -110,6 +111,19 @@
110111
</div>
111112
</form>
112113
</div>
114+
<div class="col-md-4" ng-if="config.layout === 'compact'">
115+
<form role="form"">
116+
<div class="form-group">
117+
<label>Compact Label Position</label></br>
118+
<label class="radio-inline">
119+
<input type="radio" ng-model="config.compactLabelPosition" value="left">Left</input>
120+
</label>
121+
<label class="radio-inline">
122+
<input type="radio" ng-model="config.compactLabelPosition" value="right">Right</input>
123+
</label>
124+
</div>
125+
</form>
126+
</div>
113127
</div>
114128
</div>
115129
</div>
@@ -125,7 +139,8 @@
125139
valueType : 'actual',
126140
timeFrame : 'Last 15 Minutes',
127141
units : 'MHz',
128-
tooltipType : 'percentage'
142+
tooltipType : 'percentage',
143+
compactLabelPosition : 'left'
129144
};
130145
131146
$scope.footerConfig = {

Diff for: src/charts/trends/trends-chart.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</div>
2020
<div ng-switch-when="compact" class="trend-card-compact-pf">
2121
<div class="row trend-row">
22-
<div class="col-sm-4 col-md-4">
22+
<div class="col-sm-4 col-md-4" ng-class="{'col-sm-push-8 col-md-push-8': $ctrl.config.compactLabelPosition === 'right'}">
2323
<div class="trend-compact-details">
2424
<span ng-if="$ctrl.showActualValue">
2525
<span class="trend-title-compact-big-pf">{{$ctrl.getLatestValue()}}</span>
@@ -32,7 +32,7 @@
3232
<span class="trend-header-compact-pf" ng-if="$ctrl.config.title">{{$ctrl.config.title}}</span>
3333
</div>
3434
</div>
35-
<div class="col-sm-8 col-md-8">
35+
<div class="col-sm-8 col-md-8" ng-class="{'col-sm-pull-4 col-md-pull-4': $ctrl.config.compactLabelPosition === 'right'}">
3636
<pf-sparkline-chart ng-if="$ctrl.chartData.dataAvailable !== false" config="$ctrl.config" chart-data="$ctrl.chartData" chart-height="$ctrl.getChartHeight()"
3737
show-x-axis="$ctrl.showXAxis" show-y-axis="$ctrl.showYAxis"></pf-sparkline-chart>
3838
<pf-empty-chart ng-if="$ctrl.chartData.dataAvailable === false" chart-height="$ctrl.getChartHeight()"></pf-empty-chart>

Diff for: test/charts/trends/trends-chart.spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@ describe('Directive: pfTrendsChart', function() {
9595
expect(trendCard.length).toBe(1);
9696
});
9797

98+
it("should push/pull label to the right", function() {
99+
$scope.config.compactLabelPosition = 'right';
100+
$scope.$digest();
101+
102+
trendCard = element.find('.col-sm-4 .col-md-4');
103+
expect(trendCard.hasClass('.col-sm-push-8 .col-md-push-8'));
104+
trendCard = element.find('.col-sm-8 .col-md-8');
105+
expect(trendCard.hasClass('.col-sm-pull-4 .col-md-pull-4'));
106+
});
107+
98108
it("should show inline card layout", function() {
99109
$scope.config.layout = 'inline';
100110
$scope.$digest();

0 commit comments

Comments
 (0)