Skip to content

Commit 23959e0

Browse files
author
Walden Raines
committed
Merge pull request #82 from dtaylor113/trendCardUpdates
Trend Chart Card updates
2 parents b213b8d + 3585cbb commit 23959e0

File tree

10 files changed

+248
-70
lines changed

10 files changed

+248
-70
lines changed

Gruntfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ module.exports = function (grunt) {
201201
files: ['Gruntfile.js'],
202202
tasks: ['eslint']
203203
},
204-
js: {
205-
files: ['Gruntfile.js', 'src/**/*.js'],
204+
all: {
205+
files: ['Gruntfile.js', 'src/**/*.js', 'src/**/*.html', 'styles/**/*.css'],
206206
tasks: ['build']
207207
}
208208
}

dist/angular-patternfly.js

Lines changed: 66 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,10 +1171,12 @@ angular.module('patternfly.charts').directive('pfSparklineChart', ["c3ChartDefau
11711171
*
11721172
* @param {object} config configuration settings for the trends chart:<br/>
11731173
* <ul style='list-style-type: none'>
1174-
* <li>.chartId - the unique id of this trends chart
1175-
* <li>.title - (optional) title of the Trends chart
1176-
* <li>.timeFrame - (optional) the time frame for the data in the pfSparklineChart, ex: 'Last 30 Days'
1177-
* <li>.units - unit label for values, ex: 'MHz','GB', etc..
1174+
* <li>.chartId - the unique id of this trends chart
1175+
* <li>.title - (optional) title of the Trends chart
1176+
* <li>.layout - (optional) the layout and sizes of titles and chart. Values are 'large' (default), and 'small'
1177+
* <li>.timeFrame - (optional) the time frame for the data in the pfSparklineChart, ex: 'Last 30 Days'
1178+
* <li>.units - unit label for values, ex: 'MHz','GB', etc..
1179+
* <li>.valueType - (optional) the format of the latest data point which is shown in the title. Values are 'actual'(default) or 'percentage'
11781180
* </ul>
11791181
*
11801182
* @param {object} chartData the data to be shown in the sparkline charts<br/>
@@ -1192,7 +1194,7 @@ angular.module('patternfly.charts').directive('pfSparklineChart', ["c3ChartDefau
11921194
<file name="index.html">
11931195
<div ng-controller="ChartCtrl" class="row" style="display:inline-block; width: 100%;">
11941196
<div class="col-md-12">
1195-
<div pf-trends-chart config="config" chart-data="data" chart-height="custChartHeight"
1197+
<div pf-trends-chart config="config" chart-data="data"
11961198
show-x-axis="custShowXAxis" show-y-axis="custShowYAxis"></div>
11971199
</div>
11981200
<hr class="col-md-12">
@@ -1211,15 +1213,29 @@ angular.module('patternfly.charts').directive('pfSparklineChart', ["c3ChartDefau
12111213
</div>
12121214
</form>
12131215
</div>
1214-
<div class="col-md-4">
1216+
<div class="col-md-3">
12151217
<form role="form" >
12161218
<div class="form-group">
1217-
<label>Chart Height</label></br>
1218-
<input style="height:25px; width:60px;" type="number" ng-model="custChartHeight"></input>
1219+
<label>Title Value Type</label></br>
1220+
<select pf-select class="pf-select-sm" ng-model="valueType" id="valueType">
1221+
<option value="actual" ng-selected="true" selected>Actual</option>
1222+
<option value="percentage">Percentage</option>
1223+
</select>
12191224
</div>
12201225
</form>
12211226
</div>
1222-
<div class="col-md-4">
1227+
<div class="col-md-3">
1228+
<form role="form" >
1229+
<div class="form-group">
1230+
<label>Layout</label></br>
1231+
<select pf-select class="pf-select-sm" ng-model="layout" id="layout">
1232+
<option value="large" ng-selected="true" selected>Large</option>
1233+
<option value="small">Small</option>
1234+
</select>
1235+
</div>
1236+
</form>
1237+
</div>
1238+
<div class="col-md-2">
12231239
<button ng-click="addDataPoint()">Add Data Point</button>
12241240
</div>
12251241
</div>
@@ -1231,9 +1247,10 @@ angular.module('patternfly.charts').directive('pfSparklineChart', ["c3ChartDefau
12311247
$scope.config = {
12321248
'chartId' : 'exampleTrendsChart',
12331249
'title' : 'Network Utilization Trends',
1250+
'layout' : 'large',
1251+
'valueType' : 'actual',
12341252
'timeFrame' : 'Last 15 Minutes',
12351253
'units' : 'MHz',
1236-
'showTopBorder': 'true',
12371254
'tooltipType' : 'percentage'
12381255
};
12391256
@@ -1244,19 +1261,27 @@ angular.module('patternfly.charts').directive('pfSparklineChart', ["c3ChartDefau
12441261
}
12451262
12461263
$scope.data = {
1247-
'total': '100',
1264+
'total': '250',
12481265
'xData': dates,
12491266
'yData': ['used', '10', '20', '30', '20', '30', '10', '14', '20', '25', '68', '54', '56', '78', '56', '67', '88', '76', '65', '87', '76']
12501267
};
12511268
12521269
$scope.custShowXAxis = false;
12531270
$scope.custShowYAxis = false;
1254-
$scope.custChartHeight = 60;
12551271
12561272
$scope.addDataPoint = function () {
12571273
$scope.data.xData.push(new Date($scope.data.xData[$scope.data.xData.length - 1].getTime() + (24 * 60 * 60 * 1000)));
12581274
$scope.data.yData.push(Math.round(Math.random() * 100));
12591275
};
1276+
1277+
$scope.$watch('valueType', function (newValue) {
1278+
$scope.config.valueType = newValue;
1279+
});
1280+
1281+
$scope.$watch('layout', function (newValue) {
1282+
$scope.config.layout = newValue;
1283+
});
1284+
12601285
});
12611286
</file>
12621287
</example>
@@ -1274,7 +1299,34 @@ angular.module('patternfly.charts').directive('pfTrendsChart',
12741299
showYAxis: '=?'
12751300
},
12761301
replace: true,
1277-
templateUrl: 'charts/trends/trends-chart.html'
1302+
templateUrl: 'charts/trends/trends-chart.html',
1303+
controller: ["$scope", function ($scope) {
1304+
var SMALL = 30, LARGE = 60;
1305+
1306+
$scope.getPercentageValue = function () {
1307+
return Math.round($scope.getLatestValue() / $scope.chartData.total * 100.0);
1308+
};
1309+
$scope.getLatestValue = function () {
1310+
return $scope.chartData.yData[$scope.chartData.yData.length - 1];
1311+
};
1312+
$scope.getChartHeight = function () {
1313+
var retValue = LARGE;
1314+
if ($scope.chartHeight) {
1315+
retValue = $scope.chartHeight;
1316+
} else if ($scope.config.layout === 'small') {
1317+
retValue = SMALL;
1318+
}
1319+
return retValue;
1320+
};
1321+
}],
1322+
link: function (scope) {
1323+
scope.$watch('config', function () {
1324+
scope.showLargeCardLayout = (!scope.config.layout || scope.config.layout === 'large');
1325+
scope.showSmallCardLayout = (scope.config.layout === 'small');
1326+
scope.showActualValue = (!scope.config.valueType || scope.config.valueType === 'actual');
1327+
scope.showPercentageValue = (scope.config.valueType === 'percentage');
1328+
}, true);
1329+
}
12781330
};
12791331
}
12801332
);
@@ -3982,7 +4034,7 @@ angular.module('patternfly.views').directive('pfDataToolbar',
39824034

39834035

39844036
$templateCache.put('charts/trends/trends-chart.html',
3985-
"<div><span class=trend-header-pf ng-if=config.title>{{config.title}}</span> <span class=trend-title-big-pf>{{chartData.yData[chartData.yData.length-1]}}</span> <span class=trend-title-small-pf>{{config.units}}</span><div pf-sparkline-chart config=config chart-data=chartData chart-height=chartHeight show-x-axis=showXAxis show-y-axis=showYAxis></div><span class=trend-footer-pf ng-if=config.timeFrame>{{config.timeFrame}}</span></div>"
4037+
"<span><div ng-class=\"{'trend-card-large-pf': showLargeCardLayout,'trend-card-small-pf': showSmallCardLayout}\"><span class=trend-header-pf ng-if=config.title>{{config.title}}</span> <span ng-if=showActualValue><span class=trend-title-big-pf>{{getLatestValue()}}</span> <span class=trend-title-small-pf>{{config.units}}</span></span> <span ng-if=showPercentageValue><span class=trend-title-big-pf>{{getPercentageValue() + '%'}}</span> <span class=trend-title-small-pf>of {{chartData.total + ' ' + config.units}}</span></span><div pf-sparkline-chart config=config chart-data=chartData chart-height=getChartHeight() show-x-axis=showXAxis show-y-axis=showYAxis></div><span class=trend-footer-pf ng-if=config.timeFrame>{{config.timeFrame}}</span></div></span>"
39864038
);
39874039

39884040

dist/angular-patternfly.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/styles/angular-patternfly.css

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,30 +246,45 @@
246246
box-shadow: none;
247247
}
248248

249-
.trend-title-big-pf {
250-
font-size: 24px;
251-
font-weight: 300;
252-
color: #333;
249+
.trend-card-large-pf .trend-header-pf {
250+
font-size: 16px;
251+
font-weight: 400;
252+
display: block;
253253
margin-left: 10px;
254254
}
255255

256-
.trend-title-small-pf {
256+
.trend-card-small-pf .trend-header-pf {
257257
font-size: 12px;
258258
font-weight: 400;
259-
color: #333;
259+
display: block;
260+
margin-left: 10px;
260261
}
261262

262-
.trend-header-pf {
263-
display: block;
264-
font-size: 18px;
263+
.trend-card-large-pf .trend-title-big-pf {
264+
font-size: 26px;
265+
font-weight: 300;
266+
margin-left: 10px;
267+
}
268+
269+
.trend-card-small-pf .trend-title-big-pf {
270+
font-size: 17px;
265271
font-weight: 400;
266-
color: #333;
267272
margin-left: 10px;
268273
}
269274

270-
.trend-footer-pf {
275+
.trend-card-large-pf .trend-title-small-pf {
271276
font-size: 12px;
272277
font-weight: 400;
278+
}
279+
280+
.trend-card-small-pf .trend-title-small-pf {
281+
font-size: 10px;
282+
font-weight: 400;
283+
}
284+
285+
.trend-footer-pf {
286+
font-size: 10px;
287+
font-weight: 400;
273288
color: #333;
274289
margin-left: 10px;
275290
}

dist/styles/angular-patternfly.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

misc/demo.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,8 @@ hr {
7070
.dropdown-menu > li > a:hover {
7171
background-image: none;
7272
}
73+
74+
.pf-select-sm {
75+
height :25px;
76+
width :120px;
77+
}

0 commit comments

Comments
 (0)