Skip to content

Commit b88e2e6

Browse files
Merge pull request #63 from dtaylor113/trendChart
Created pfTrendsChart directive, ngdocs and unit tests
2 parents b69ffdf + d49b30b commit b88e2e6

File tree

11 files changed

+376
-10
lines changed

11 files changed

+376
-10
lines changed

dist/angular-patternfly.js

Lines changed: 129 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ angular.module('patternfly.autofocus', []).directive('pfFocused', ["$timeout", f
109109
}]);
110110
;/**
111111
* @ngdoc directive
112-
* @name patternfly.card:pfAggregateStatusCard
112+
* @name patternfly.card.directive:pfAggregateStatusCard
113113
* @restrict A
114114
* @element ANY
115115
* @param {object} status Status configuration information<br/>
@@ -206,7 +206,7 @@ angular.module( 'patternfly.card' ).directive('pfAggregateStatusCard', function
206206
});
207207
;/**
208208
* @ngdoc directive
209-
* @name patternfly.card:pfCard
209+
* @name patternfly.card.directive:pfCard
210210
* @restrict A
211211
* @element ANY
212212
* @param {headTitle=} Title for the card - required
@@ -1139,6 +1139,126 @@ angular.module('patternfly.charts').directive('pfSparklineChart', ["c3ChartDefau
11391139
};
11401140
}]
11411141
);
1142+
;/**
1143+
* @ngdoc directive
1144+
* @name patternfly.charts.directive:pfTrendsChart
1145+
*
1146+
* @description
1147+
* Directive for rendering a trend chart. The trend chart combines overall data with a
1148+
* pfSparklineChart.
1149+
* <br><br>
1150+
* See http://c3js.org/reference.html for a full list of C3 chart options.<br>
1151+
* See also: {@link patternfly.charts.directive:pfSparklineChart}
1152+
*
1153+
* @param {object} config configuration settings for the trends chart:<br/>
1154+
* <ul style='list-style-type: none'>
1155+
* <li>.chartId - the unique id of this trends chart
1156+
* <li>.title - (optional) title of the Trends chart
1157+
* <li>.timeFrame - (optional) the time frame for the data in the pfSparklineChart, ex: 'Last 30 Days'
1158+
* <li>.units - unit label for values, ex: 'MHz','GB', etc..
1159+
* </ul>
1160+
*
1161+
* @param {object} chartData the data to be shown in the sparkline charts<br/>
1162+
* <ul style='list-style-type: none'>
1163+
* <li>.total - number representing the total amount
1164+
* <li>.xData - Array, X values for the data points, first element must be the name of the data
1165+
* <li>.yData - Array, Y Values for the data points, first element must be the name of the data
1166+
* </ul>
1167+
*
1168+
* @param {int=} chartHeight height of the sparkline chart
1169+
* @param {boolean=} showXAxis override sparkline config settings for showing the X Axis
1170+
* @param {boolean=} showYAxis override sparkline config settings for showing the Y Axis
1171+
* @example
1172+
<example module="patternfly.charts">
1173+
<file name="index.html">
1174+
<div ng-controller="ChartCtrl" class="row" style="display:inline-block; width: 100%;">
1175+
<div class="col-md-12">
1176+
<div pf-trends-chart config="config" chart-data="data" chart-height="custChartHeight"
1177+
show-x-axis="custShowXAxis" show-y-axis="custShowYAxis"></div>
1178+
</div>
1179+
<hr class="col-md-12">
1180+
<div class="col-md-12">
1181+
<div class="row">
1182+
<div class="col-md-4">
1183+
<form role="form"">
1184+
<div class="form-group">
1185+
<label>Show</label></br>
1186+
<label class="checkbox-inline">
1187+
<input type="checkbox" ng-model="custShowXAxis">X Axis</input>
1188+
</label>
1189+
<label class="checkbox-inline">
1190+
<input type="checkbox" ng-model="custShowYAxis">Y Axis</input>
1191+
</label>
1192+
</div>
1193+
</form>
1194+
</div>
1195+
<div class="col-md-4">
1196+
<form role="form" >
1197+
<div class="form-group">
1198+
<label>Chart Height</label></br>
1199+
<input style="height:25px; width:60px;" type="number" ng-model="custChartHeight"></input>
1200+
</div>
1201+
</form>
1202+
</div>
1203+
<div class="col-md-4">
1204+
<button ng-click="addDataPoint()">Add Data Point</button>
1205+
</div>
1206+
</div>
1207+
</div>
1208+
</file>
1209+
<file name="script.js">
1210+
angular.module( 'patternfly.charts' ).controller( 'ChartCtrl', function( $scope ) {
1211+
1212+
$scope.config = {
1213+
'chartId' : 'exampleTrendsChart',
1214+
'title' : 'Network Utilization Trends',
1215+
'timeFrame' : 'Last 15 Minutes',
1216+
'units' : 'MHz',
1217+
'showTopBorder': 'true',
1218+
'tooltipType' : 'percentage'
1219+
};
1220+
1221+
var today = new Date();
1222+
var dates = ['dates'];
1223+
for (var d = 20 - 1; d >= 0; d--) {
1224+
dates.push(new Date(today.getTime() - (d * 24 * 60 * 60 * 1000)));
1225+
}
1226+
1227+
$scope.data = {
1228+
'total': '100',
1229+
'xData': dates,
1230+
'yData': ['used', '10', '20', '30', '20', '30', '10', '14', '20', '25', '68', '54', '56', '78', '56', '67', '88', '76', '65', '87', '76']
1231+
};
1232+
1233+
$scope.custShowXAxis = false;
1234+
$scope.custShowYAxis = false;
1235+
$scope.custChartHeight = 60;
1236+
1237+
$scope.addDataPoint = function () {
1238+
$scope.data.xData.push(new Date($scope.data.xData[$scope.data.xData.length - 1].getTime() + (24 * 60 * 60 * 1000)));
1239+
$scope.data.yData.push(Math.round(Math.random() * 100));
1240+
};
1241+
});
1242+
</file>
1243+
</example>
1244+
*/
1245+
angular.module('patternfly.charts').directive('pfTrendsChart',
1246+
function () {
1247+
'use strict';
1248+
return {
1249+
restrict: 'A',
1250+
scope: {
1251+
config: '=',
1252+
chartData: '=',
1253+
chartHeight: '=?',
1254+
showXAxis: '=?',
1255+
showYAxis: '=?'
1256+
},
1257+
replace: true,
1258+
templateUrl: 'charts/trends/trends-chart.html'
1259+
};
1260+
}
1261+
);
11421262
;/**
11431263
* @ngdoc directive
11441264
* @name patternfly.charts.directive:pfUtilizationChart
@@ -1813,7 +1933,7 @@ angular.module('patternfly.notification', []).provider('Notifications', function
18131933

18141934
/**
18151935
* @ngdoc directive
1816-
* @name patternfly.notification:pfNotification
1936+
* @name patternfly.notification.directive:pfNotification
18171937
* @restrict E
18181938
* @scope
18191939
*
@@ -1896,7 +2016,7 @@ angular.module( 'patternfly.notification' ).directive('pfNotification', function
18962016
});
18972017
/**
18982018
* @ngdoc directive
1899-
* @name patternfly.notification:pfNotificationList
2019+
* @name patternfly.notification.directive:pfNotificationList
19002020
* @restrict E
19012021
*
19022022
* @description
@@ -3049,6 +3169,11 @@ angular.module('patternfly.views').directive('pfDataTiles', [
30493169
);
30503170

30513171

3172+
$templateCache.put('charts/trends/trends-chart.html',
3173+
"<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>"
3174+
);
3175+
3176+
30523177
$templateCache.put('charts/utilization/utilization-chart.html',
30533178
"<div class=utilization-chart-pf><h3>{{config.title}}</h3><div class=current-values><h1 class=\"available-count pull-left\"><span>{{currentValue}}</span></h1><div class=\"available-text pull-left\"><div><span>{{currentText}}</span></div><div><span>of {{chartData.total}} {{config.units}}</span></div></div></div><div pf-donut-pct-chart config=donutConfig data=chartData center-label=centerLabel></div><div pf-sparkline-chart config=sparklineConfig chart-data=chartData chart-height=sparklineChartHeight show-x-axis=showSparklineXAxis show-y-axis=showSparklineYAxis></div><span class=\"pull-left legend-text\">{{legendLeftText}}</span> <span class=\"pull-right legend-text\">{{legendRightText}}</span></div>"
30543179
);

dist/angular-patternfly.min.js

Lines changed: 1 addition & 1 deletion
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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,31 @@
244244
-moz-box-shadow: none;
245245
box-shadow: none;
246246
}
247+
248+
.trend-title-big-pf {
249+
font-size: 24px;
250+
font-weight: 300;
251+
color: #333;
252+
margin-left: 10px;
253+
}
254+
255+
.trend-title-small-pf {
256+
font-size: 12px;
257+
font-weight: 400;
258+
color: #333;
259+
}
260+
261+
.trend-header-pf {
262+
display: block;
263+
font-size: 18px;
264+
font-weight: 400;
265+
color: #333;
266+
margin-left: 10px;
267+
}
268+
269+
.trend-footer-pf {
270+
font-size: 12px;
271+
font-weight: 400;
272+
color: #333;
273+
margin-left: 10px;
274+
}

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.

src/card/aggregate-status/aggregate-status-card.directive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @ngdoc directive
3-
* @name patternfly.card:pfAggregateStatusCard
3+
* @name patternfly.card.directive:pfAggregateStatusCard
44
* @restrict A
55
* @element ANY
66
* @param {object} status Status configuration information<br/>

src/card/basic/card.directive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @ngdoc directive
3-
* @name patternfly.card:pfCard
3+
* @name patternfly.card.directive:pfCard
44
* @restrict A
55
* @element ANY
66
* @param {headTitle=} Title for the card - required

0 commit comments

Comments
 (0)