@@ -1171,10 +1171,11 @@ 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>.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..
1178+ * <li>.valueType - the format of the latest data point which is shown in the title. Values are 'actual' or 'percentage'
11781179 * </ul>
11791180 *
11801181 * @param {object } chartData the data to be shown in the sparkline charts<br/>
@@ -1211,15 +1212,26 @@ angular.module('patternfly.charts').directive('pfSparklineChart', ["c3ChartDefau
12111212 </div>
12121213 </form>
12131214 </div>
1214- <div class="col-md-4 ">
1215+ <div class="col-md-3 ">
12151216 <form role="form" >
12161217 <div class="form-group">
12171218 <label>Chart Height</label></br>
12181219 <input style="height:25px; width:60px;" type="number" ng-model="custChartHeight"></input>
12191220 </div>
12201221 </form>
12211222 </div>
1222- <div class="col-md-4">
1223+ <div class="col-md-3">
1224+ <form role="form" >
1225+ <div class="form-group">
1226+ <label>Title Value Type</label></br>
1227+ <select pf-select style="height:25px; width:120px;" ng-model="valueType" id="valueType">
1228+ <option value="actual" ng-selected="true" selected>Actual</option>
1229+ <option value="percentage">Percentage</option>
1230+ </select>
1231+ </div>
1232+ </form>
1233+ </div>
1234+ <div class="col-md-2">
12231235 <button ng-click="addDataPoint()">Add Data Point</button>
12241236 </div>
12251237 </div>
@@ -1231,9 +1243,9 @@ angular.module('patternfly.charts').directive('pfSparklineChart', ["c3ChartDefau
12311243 $scope.config = {
12321244 'chartId' : 'exampleTrendsChart',
12331245 'title' : 'Network Utilization Trends',
1246+ 'valueType' : 'actual',
12341247 'timeFrame' : 'Last 15 Minutes',
12351248 'units' : 'MHz',
1236- 'showTopBorder': 'true',
12371249 'tooltipType' : 'percentage'
12381250 };
12391251
@@ -1244,7 +1256,7 @@ angular.module('patternfly.charts').directive('pfSparklineChart', ["c3ChartDefau
12441256 }
12451257
12461258 $scope.data = {
1247- 'total': '100 ',
1259+ 'total': '250 ',
12481260 'xData': dates,
12491261 'yData': ['used', '10', '20', '30', '20', '30', '10', '14', '20', '25', '68', '54', '56', '78', '56', '67', '88', '76', '65', '87', '76']
12501262 };
@@ -1257,6 +1269,11 @@ angular.module('patternfly.charts').directive('pfSparklineChart', ["c3ChartDefau
12571269 $scope.data.xData.push(new Date($scope.data.xData[$scope.data.xData.length - 1].getTime() + (24 * 60 * 60 * 1000)));
12581270 $scope.data.yData.push(Math.round(Math.random() * 100));
12591271 };
1272+
1273+ $scope.$watch('valueType', function (newValue) {
1274+ $scope.config.valueType = newValue;
1275+ });
1276+
12601277 });
12611278 </file>
12621279 </example>
@@ -1274,7 +1291,14 @@ angular.module('patternfly.charts').directive('pfTrendsChart',
12741291 showYAxis : '=?'
12751292 } ,
12761293 replace : true ,
1277- templateUrl : 'charts/trends/trends-chart.html'
1294+ templateUrl : 'charts/trends/trends-chart.html' ,
1295+ controller : [ '$scope' ,
1296+ function ( $scope ) {
1297+ $scope . getPercentage = function ( ) {
1298+ return Math . round ( $scope . chartData . yData [ $scope . chartData . yData . length - 1 ] / $scope . chartData . total * 100.0 ) ;
1299+ } ;
1300+ }
1301+ ]
12781302 } ;
12791303 }
12801304) ;
@@ -3982,7 +4006,7 @@ angular.module('patternfly.views').directive('pfDataToolbar',
39824006
39834007
39844008 $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>"
4009+ "<div><span class=trend-header-pf ng-if=config.title>{{config.title}}</span> <span ng-if=\"!config.valueType || config.valueType === 'actual'\"><span class=trend-title-big-pf>{{chartData.yData[chartData.yData.length-1]}}</span> <span class=trend-title-small-pf>{{config.units}}</span></span> <span ng-if=\"config.valueType === 'percentage'\"><span class=trend-title-big-pf>{{getPercentage() + '%'}}</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=chartHeight show-x-axis=showXAxis show-y-axis=showYAxis></div><span class=trend-footer-pf ng-if=config.timeFrame>{{config.timeFrame}}</span></div>"
39864010 ) ;
39874011
39884012
0 commit comments