Google Charts ============= Now that we've established our database connection and can request and retrieve data from our tables, we can focus on our web application. Installing ---------- First, we'll need to grab the Angular-ized Google Charts. Do this: :: cd sdk/ecomp-sdk/epsdk-app-os/src/main/webapp/app/fusion/scripts/myapp/myfirstpage wget https://raw.githubusercontent.com/angular-google-chart/angular-google-chart/development/ng-google-chart.min.js .. note:: The "min" in the file name indicates that any and all unnecessary spaces, newlines, etc. have been removed from the file to "min"imize the size. Now, add a reference to Google Charts in your :code:`sdk/ecomp-sdk/epsdk-app-os/src/main/webapp/app/fusion/scripts/myapp/myfirstpage/myfirstpage.html` file: :: . . . . . . Now, make sure we tell our app that we'll need to use this dependency by adding a reference to it in :code:`sdk/ecomp-sdk/epsdk-app-os/src/main/webapp/app/fusion/scripts/myapp/myfirstpage/app.js`: .. code-block:: javascript var appDS2=angular.module("abs", ['ngRoute', 'ngMessages','modalServices', 'ngCookies', 'b2b.att','gridster','ui.bootstrap','ui.bootstrap.modal','googlechart']); Configuring our chart --------------------- Change the initialization of the :code:`$scope.state` variable by using the following inside the init function in your :code:`sdk/ecomp-sdk/epsdk-app-os/src/main/webapp/app/fusion/scripts/myapp/myfirstpage/controller.js` file: .. code-block:: javascript $scope.state = { // Holds a message string for testing message: "Hello from myFirstPageController", // Holds the desired direction of the chart direction: "download", chart: { type: "LineChart", data: { cols: [{id: "dt", label: "Date", type: "date"}, {id: "c1", label: "Bandwidth", type: "number"}, {type: "string", role: "tooltip"}], rows:[] // These change for every chart }, options: { title: "", hAxis: {title: "Date", format: "MM/dd/yyyy"}, vAxis: {title: "Bandwidth (Mbps)", minValue: 0}, colors: ['blue'], defaultColors: ['blue'], legend: {position: "top", maxLines: 2}, isStacked: false, pointSize: 2 } } }; The configuration options are self-explanatory. Experiment with them to get a better idea of what's possible. Populating our chart -------------------- Add the following function to your :code:`sdk/ecomp-sdk/epsdk-app-os/src/main/webapp/app/fusion/scripts/myapp/myfirstpage/controller.js` file: .. code-block:: javascript $scope.getChartData = function(direction) { dataService.getChartData(encodeURI(direction)).then(function(rv) { var arr = JSON.parse(angular.toJson(rv)); // Clear out our rows $scope.state.chart.data.rows = []; for (var i=0; i

{{state.message}}

Recompile, install, and try it out. .. _Google Charts: https://developers.google.com/chart/interactive/docs/points