Attempting to integrate data from a REST API into HighCharts, but encountering an issue:
TypeError: Cannot read property 'series' of undefined
.
This function retrieves the data from the API:
$scope.myData = function(chart) {
HighCharts.query({
},
function(data) {
$scope.highcharts = data;
chart.series[0].setData($scope.getChart(data));
});
};
Below is the getChart
function:
$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;
}
Any insights on what might be incorrect in this code?
Update: A new error has surfaced. The full code can be viewed at https://jsfiddle.net/raq0eg6e/.