Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Well, turns out camp_amount wasn't setup properly and returned "NaN"... Thanks anyway! You guys made me look past the array syntax, which turns out to be fine. Sometimes I just get a bit lost in code.

For use with highcharts I have the following array:

dashboardData = [[tableData[1], parseFloat(tableData[12])],[tableData[14], parseFloat(tableData[25])]];

I can literally just paste that as highcharts series data:

data: dashboardData

However, I need to build the array in a for loop because the length of the array will vary. So I need to build an array that ends up with the same structure as above, which would be something like:

0: Array[2]
0: "a string"
1: 312

1: Array[2]
0: "another string"
1: 1668

How do I build this up? I tried the following but it doesn't work...

var dashboardData = [];
for (var i = 1; i <= camp_amount.length; i++) {
    dashboardData.push([tableData[i], tableData[i + 1]]);
}
share|improve this question
1  
if that didnt work. there should be something in your firebug console to check when you run it. –  mithunsatheesh May 8 at 7:43
2  
What's in 'camp_amount' and what's the relation to 'tableData' since you are using its as one array –  drinchev May 8 at 7:44
 
camp_amount is the amount of campaigns found, it then runs through the tableData to fetch the name and a value (users) per campaign. Is the manner I build up the array correct in your opinion? Because that would help a lot already: to know it's not a syntax error. –  Galadre May 8 at 7:50
 
So, is issue resolved? :) –  Paweł Fus May 8 at 12:16
 
@PawełFus: It appears to be... This should be closed or removed by the author. –  Qantas 94 Heavy May 8 at 12:41
show 1 more comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.