Hi all,
I am trying to populate a data table from two arrays that I have (one
for each column). I am passing the arrays from php via json encoding.
var name = <?php echo json_encode($col0); ?>;
var rank = <?php echo json_encode($col1); ?>;
var data = new google.visualization.DataTable();
data.addColumn('string', 'name');
data.addColumn('number', 'rank');
data.addRows(5);
for( var i=0; i<5; i++)
{
data.setCell(i, 0, name[i]);
data.setCell(i, 1, rank[i]);
}
This does not work, and I can't figure out why not. I have already
checked that the arrays were properly created by writing them to the
web page:
document.write(name);
document.write(rank);
When I run the above code the arrays print to the web page just fine,
so I know that the json encoding is working and the arrays have been
created. Can anyone tell me what I am doing wrong?
I should mention that I am VERY new to both php and javascript, so
please keep technical language to an absolute minimum and spell things
out for me as if I were stupid. It would be most helpful if you could
actually write the corrected code out for me. Thanks!
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.