Using chartjs in ionic framework with firebase


#1

I’m new at ionic framework.I want to use chartjs in my application
based on data stored in firebase. here is my code which I retrieve data
in list:

       <ion-list>
        <ion-item ng-repeat="item in items |reverse |limitTo:3">
          <b>  {{item.bg}}</b>
          <p> {{item.time}}</p>
          <p>  {{item.dayOfWeek}}</p
        </ion-item>
    </ion-list>

and have a canvas to show the data in chart:

also in my controller I have:

.factory(“Items”, function ($firebaseArray) {
var itemsRef = new Firebase(“https://[my-firebase- app].firebaseio.com/items”);
return $firebaseArray(itemsRef);

})

.controller(“ListCtrl”, function ($scope, Items) {

$scope.items = Items;

$scope.addItem = function () {

$scope.items.$add({

  "bg": $scope.newBG,
  "dayOfWeek":dw,
  "date":dd,
  "time":hh 

})

}

};

the chart only work with static array data in controller, like this:

$scope.graph = {};
$scope.graph.data =
[
[16, 15, 20, 12, 16, 12, 8],

[8, 9, 4, 12, 8, 12, 14]
];

but I want to use dynamic data from firebase and when a data add in it, it shows in chart.
How Can I use that data and bind them to my chart where they are n Json format?
Is it right to use it like
$scope.graph.data=Items.bg;

but it doesn’t work.
in other word,How to retrieve json data stored in firebase, to an array in angularjs to show in chart.
Thank you for helping me