Hi. The quickest option to initialize a DataTable from Javascript is using the json constructor as described in the data table section here<http://code.google.com/apis/visualization/documentation/reference.html#DataTable>. You also have other alternatives documented there.
Best, Viz Kid On Tue, Nov 24, 2009 at 11:02 AM, Daniele <[email protected]> wrote: > Hi, > > I'm completely new to Google Visualization API and I'm trying to > populate it using a JavaScript variable > is it possible? > I'm trying to do something very weird ? > Any suggestions are welcome. > Thanks > > here the example: > > function drawVisualization() { > // Create and populate the data table. > var data = new google.visualization.DataTable(); > data.addColumn('number', 'Name'); > data.addColumn('string', 'Height'); > data.addColumn('boolean', 'Smokes'); > > //I'd like to use a JavaScript variable so I could populate it using > xmlhttp.responseText > // I think addRows is trying to add test as value.. > var test = "[[6,'test', false]]"; > data.addRows(test); > > // this is working but it's hard coded or generated by a "server > side script" > //data.addRows([[4,'test',true]]); > > > // Create and draw the visualization. > visualization = new google.visualization.Table > (document.getElementById('table')); > visualization.draw(data, null); > } > > -- > > 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]<google-visualization-api%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-visualization-api?hl=en. > > > -- 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.
