66 *
77 */
88angular . module ( 'patternfly.card' , [ ] ) ;
9+ ; /**
10+ * @name patternfly
11+ *
12+ * @description
13+ * Charts module for patternfly. Must Include d3.js and c3.js to use
14+ *
15+ */
16+ angular . module ( 'patternfly.charts' , [ ] ) ;
17+
918; /**
1019 * @name patternfly.form
1120 *
@@ -25,7 +34,7 @@ angular.module('patternfly', [
2534 'patternfly.form' ,
2635 'patternfly.notification' ,
2736 'patternfly.select' ,
28- 'patternfly.validation' ,
37+ 'patternfly.validation'
2938] ) ;
3039
3140; 'use strict' ;
@@ -124,6 +133,101 @@ angular.module('patternfly.card').directive('pfCard', function() {
124133} ) ;
125134
126135
136+ ; /**
137+ * @ngdoc directive
138+ * @name patternfly.charts.directive:pfC3Chart
139+ *
140+ * @description
141+ * Directive for wrapping c3 library
142+ *
143+ * Note: The 'patternfly.charts' module is not a dependency in the default angular 'patternfly' module.
144+ * In order to use patternfly charts you must add 'patternfly.charts' as a dependency in your application.
145+ *
146+ *
147+ * @param {string } id the ID of the container that the chart should bind to
148+ * @param {expression } config the c3 configuration options for the chart
149+ *
150+ * @example
151+ <example module="patternfly.charts">
152+ <file name="index.html">
153+ <div ng-controller="ChartCtrl">
154+ <div pf-c3-chart id="chartId" config="chartConfig"></div>
155+
156+ <form role="form" style="width:300px">
157+ Total = {{total}}, Used = {{used}}, Available = {{available}}
158+ <div class="form-group">
159+ <label>Used</label>
160+ <input type="text" class="form-control" ng-model="newUsed">
161+ </div>
162+ <input type="button" ng-click="submitform(newUsed)" value="Go" />
163+ </form>
164+ </div>
165+ </file>
166+
167+ <file name="script.js">
168+ function ChartCtrl($scope) {
169+ $scope.used = 950;
170+ $scope.total = 1000;
171+ $scope.available = $scope.total - $scope.used;
172+
173+ $scope.chartConfig = {"donut":
174+ {"title":"MHz Used",
175+ "label":{"show":false},
176+ "width":10
177+ },
178+ "size":{"height":130},
179+ "legend":{"show":false},
180+ "color":{"pattern":["#0088CE","#D1D1D1"]},
181+ "tooltip":{},
182+ "data":{"columns":[["Used","950"],["Available",50]],
183+ "type":"donut",
184+ "donut":{
185+ "label":{"show":false}
186+ },
187+ "groups":[["used","available"]],
188+ "order":null
189+ }
190+ };
191+
192+ $scope.updateAvailable = function(val){
193+ $scope.available = $scope.total - $scope.used;
194+ }
195+
196+ $scope.submitform = function(val){
197+ $scope.used = val;
198+ $scope.updateAvailable();
199+ $scope.chartConfig.data.columns = [["Used",$scope.used],["Available",$scope.available]];
200+ };
201+ }
202+ </file>
203+ </example>
204+ */
205+ ( function ( c3 ) {
206+ 'use strict' ;
207+
208+ angular . module ( 'patternfly.charts' )
209+ . directive ( 'pfC3Chart' , [ '$timeout' , function ( $timeout ) {
210+
211+ return {
212+ restrict : 'A' ,
213+ scope : {
214+ config : '='
215+ } ,
216+ template : '<div id=""></div>' ,
217+ replace : true ,
218+ link : function ( scope , element , attrs ) {
219+ scope . $watch ( 'config' , function ( ) {
220+ $timeout ( function ( ) {
221+ //generate c3 chart data
222+ var chartData = scope . config ;
223+ chartData . bindto = '#' + attrs . id ;
224+ c3 . generate ( chartData ) ;
225+ } ) ;
226+ } , true ) ;
227+ }
228+ } ;
229+ } ] ) ;
230+ } ( c3 ) ) ;
127231; /**
128232 * @ngdoc directive
129233 * @name patternfly.form.directive:pfDatepicker
@@ -990,7 +1094,7 @@ angular.module('patternfly.validation', []).directive('pfValidation', function($
9901094 ) ;
9911095
9921096} ] ) ;
993- ; angular . module ( 'patternfly.form' ) . run ( [ '$templateCache' , function ( $templateCache ) {
1097+ ; ; angular . module ( 'patternfly.form' ) . run ( [ '$templateCache' , function ( $templateCache ) {
9941098 'use strict' ;
9951099
9961100 $templateCache . put ( 'form/datepicker/datepicker.html' ,
0 commit comments