title: angular-chart.js: How do I use dynamic data from a variable instead of static values for my charts?
body: <p>I am using this framework to draw charts with angularjs:<a href="http://jtblin.github.io/angular-chart.js/" rel="nofollow noreferrer">http://jtblin.github.io/angular-chart.js/</a>. I already searched stackoverflow but no question could really solve my problem.</p>
  
  <p>I have no problem drawing charts with static data, for example $scope.data = [50,30,70]</p>
  
  <p>I want the chart to use the values stored in a variable instead, and I assumed I could simply put my values in an array and do something like $scope.data = myArray; or put my variable in the array like $scpe.data = [myData]; but this doesn't work and I have no clue what else to try. I am new to angularJS and Chart.js btw.</p>
  
  <p>As a test I just wanted to read my cpuload and put it into a chart.</p>
  
  <p>Here is my html:</p>
  
  <pre><code>   &lt;div style="width:300px; height:300px" ng-controller="BarCtrl"&gt;   
          &lt;canvas id="bar" class="chart chart-bar"
              chart-data="data" chart-labels="labels"&gt; chart-series="series"
          &lt;/canvas&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>Here are my angular controllers:</p>
  
  <pre><code>app.controller('MonitorController', ['$scope', function ($scope) {
  var vm = this;
  setInterval(function(){
      si.currentLoad(function(data) {
      vm.cpuLoad = Math.round(data.currentload); 
  
      $scope.$apply();
  
   }); }, 1000);
  }])
  
  app.controller("BarCtrl", function ($scope) {
  
  $scope.labels = ['2017'];
  $scope.series = ['Series A'];
  
  $scope.data = [50]; });
  </code></pre>
  
  <p>I want $scope.data to use the value from vm.cpuLoad. </p>
  
  <p>Can anyone help me how to do that? You can also ignore the intervall if you want. Just tell me how to apply the data from a variable in another controller in this.</p>
  
  <p>Thanks in advance.</p>