title: How to use angular charts for ionic along with Data taken from database
body: <p>My controller.js is as follows:</p>
  
  <pre><code>.controller('dashboardCtrl', function($scope,TestMethod,$cordovaSQLite) {
        var dis_stime = [];
        var dis_steps = [];
        $scope.select = function() {
          console.log("check1");
          var lastSynced = localStorage.getItem('lastSynced');
          if (lastSynced != undefined) {
                console.log("check2");
           // alert("lastSynced time is "+lastSynced);
          //  alert("query written");
            try {
                  db = $cordovaSQLite.openDB({name:"health.db",location:'default'});
                //  alert("inside create");
                  } catch (error) {
                    alert(error);
                  }
            lastSynced = lastSynced * 1000000;
            startTime = lastSynced - (86400 * 1000000000);
            for (var i = 1; i &lt; (PERIOD +1); i++) {
                  $cordovaSQLite.execute(db,"SELECT SUM(stepcount) AS total FROM activity WHERE startTime BETWEEN ? AND ?", [startTime,lastSynced])
                    .then(function (resultSet)
                    {
                        dis_stime[i] = lastSynced;
                        dis_steps[i] = resultSet.rows.item(0).total;
                        alert("total  is " + resultSet.rows.item(0).total);
                       // alert("Total is : " +resultSet.rows.item(0).total);
                      //  alert("total entries" + resultSet.rows.length);
                    }, function(error) {
                        alert('SELECT error: ' + error.message);
                      });
                      lastSynced = startTime;
                      startTime = startTime - (86400 * 1000000000);
                    }
                  }
              else
              {
                alert("Please sync the device to see the data");
              }
              alert("steps: "+dis_steps+" times: "+dis_stime);
              $scope.labels = dis_stime;
              $scope.series = ['steps'];
              $scope.data = dis_steps;
            }
      })
  </code></pre>
  
  <p>I am fetching the data from sqlite plugin and then i want to display it on graph.</p>
  
  <p>The problem is that the graph doesnt get loaded when select function is called.</p>
  
  <p>where and how should i call the select function so that data is loaded when i open the page??</p>