I'm using ChartJS to build a line graph. The data is coming from an API. I take the data points from the API and use the push
method to build an array to be used in the parameters of ChartJS data: { data: dataFromAPI
. I'm using AJAX to GET
data from the API.
When I do this:
var someArray = [23,49,39,59];
and input it into the data: { data:
parameter, it works. In the console, someArray
looks like this
Array(4) [23,49,39,59]
When I use the push
method in the AJAX call, the array looks like this in the console:
Array []
Both array variables are being declared globally.
The array that I'm using the push
method to build in the AJAX call does not work with ChartJS. It produces this error:
Uncaught TypeError: n[a]._view is undefined
What is the difference between, what I would refer to as a manually typed array, and the array that push
built? And how come ChartJS does not want to accept push
array?
I would also like to note that Array []
does have elements inside.