title: highcharts: TypeError: Cannot read property '0' of undefined
body: <p>I'm trying to feed some data from a REST API into HighCharts but I'm getting an error: <code>TypeError: Cannot read property 'series' of undefined</code>.</p>
  
  <p>This gets the data from the API:</p>
  
  <pre><code>$scope.myData = function(chart) {
  
    HighCharts.query({
    }, 
    function(data) {
      $scope.highcharts = data;
      chart.series[0].setData($scope.getChart(data));
    });
  
  };
  </code></pre>
  
  <p>Here's the <code>getChart</code> function:</p>
  
  <pre><code>$scope.getChart = function(data) {
      var response = [];
  
        $scope.highcharts.id.forEach(function(element, index){
          response.push([
            moment(element).toDate().getTime(),
            $scope.highcharts.value[index]
          ]);
        });
  
      return response;
    }
  </code></pre>
  
  <p>Any ideas about what am I doing wrong?</p>
  
  <p>Update: I've updated the question as I'm getting a new error. You can see the full code at <a href="https://jsfiddle.net/raq0eg6e/" rel="nofollow">https://jsfiddle.net/raq0eg6e/</a>.</p>