Skip to content

Commit 4207e65

Browse files
amarie401cdcabrera
authored andcommitted
fix(pfTrendsChart): Updated trend chart and trend card with right (#594)
label config
1 parent c7c7f29 commit 4207e65

File tree

5 files changed

+52
-12
lines changed

5 files changed

+52
-12
lines changed

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

+15-2
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">
@@ -57,7 +60,7 @@
5760
'callBackFn': function () {
5861
alert("Footer Callback Fn Called");
5962
}
60-
}
63+
};
6164
6265
$scope.filterConfig = {
6366
'filters' : [{label:'Last 30 Days', value:'30'},
@@ -67,7 +70,7 @@
6770
alert("Filter Callback Fn Called for '" + f.label + "' value = " + f.value);
6871
},
6972
'defaultFilter' : '1'
70-
}
73+
};
7174
7275
var today = new Date();
7376
var dates = ['dates'];
@@ -84,6 +87,16 @@
8487
'tooltipType' : 'percentage'
8588
};
8689
90+
$scope.configRightLabel = {
91+
'chartId' : 'exampleRightLabelTrendsChart',
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/charts.less

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ pf-c3-chart {
6464
}
6565

6666
.trend-card-compact-pf {
67-
.col-sm-2 {
67+
.col-sm-2:not(.col-sm-push-10) {
6868
padding-right: 0;
6969
}
70-
.col-sm-10 {
70+
.col-sm-10:not(.col-sm-pull-2) {
7171
padding-left: 0;
7272
}
7373
}

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

+21-6
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..
@@ -44,7 +45,7 @@
4445
<div class="col-md-12">
4546
<div class="row">
4647
<div class="col-md-4">
47-
<form role="form"">
48+
<form role="form">
4849
<div class="form-group">
4950
<label>Show</label></br>
5051
<label class="checkbox-inline">
@@ -101,15 +102,28 @@
101102
</div>
102103
</div>
103104
<div class="row">
104-
<div class="col-md-6">
105-
<form role="form"">
105+
<div class="col-md-4">
106+
<form role="form">
106107
<div class="form-group">
107108
<label class="checkbox-inline">
108109
<input type="checkbox" ng-model="data.dataAvailable">Data Available</input>
109110
</label>
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 = {
@@ -134,7 +149,7 @@
134149
callBackFn: function () {
135150
alert("Footer Callback Fn Called");
136151
}
137-
}
152+
};
138153
139154
$scope.filterConfig = {
140155
filters : [{label:'Last 30 Days', value:'30'},
@@ -143,7 +158,7 @@
143158
callBackFn: function (f) {
144159
alert("Filter Callback Fn Called for '" + f.label + "' value = " + f.value);
145160
}
146-
}
161+
};
147162
148163
$scope.layouts = [
149164
{

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-2">
22+
<div class="col-sm-2" ng-class="{'col-sm-push-10': $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-10">
35+
<div class="col-sm-10" ng-class="{'col-sm-pull-2': $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

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

98+
it("should push/pull label to the right when compactLabelPosition is 'right'", function() {
99+
$scope.config.layout = 'compact';
100+
$scope.config.compactLabelPosition = 'right';
101+
$scope.$digest();
102+
103+
trendCard = element.find('.col-sm-2');
104+
expect(trendCard.hasClass('col-sm-push-10')).toEqual(true);
105+
106+
trendCard = element.find('.col-sm-10');
107+
expect(trendCard.hasClass('col-sm-pull-2')).toEqual(true);
108+
});
109+
98110
it("should show inline card layout", function() {
99111
$scope.config.layout = 'inline';
100112
$scope.$digest();

0 commit comments

Comments
 (0)