Packy Packy - 1 year ago 41
jQuery Question

array of numbers to integers

I know there might be an easy way but I can not get this to work. Basically I am striping the values from an Associative Array and just creating another array of those values. Then I need to use those numbers as the data value from my chart.js graph.

Here is what I need:

data: [ 50,0,50,200 ]

This works when I hard code the numbers for the

Here is what I have that doesn't work:

var categoryData = <?php echo (json_encode($categories)) ?>;
var categoryGraph = [];

$.each(categoryData, function (key, data) {

console.log( categoryGraph.join() );

////Then the data I do like this

data: [ categoryGraph.join() ],

Console displays :

I assume that because
outputs a string when
is looking for ints


Use the array itself as the value for data:

data: categoryGraph,