Sunday, 15 January 2012

Dynamic array for googlechart json javascript -



Dynamic array for googlechart json javascript -

i want create line chart whith googlechart ( https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart ). i'm not able format array chart.

the array must looks :

var info = google.visualization.arraytodatatable([ ['year', 'sales', 'expenses'], ['2004', 1000, 400], ['2005', 1170, 460], ['2006', 660, 1120], ['2007', 1030, 540] ]);

and i'm trying create way :

var info = google.visualization.arraytodatatable([['year', 'marque1', 'marque2', 'marque3', 'marque4']]); var i=1; msg.foreach(function(entry) { data.addrows([ ['2004', i-1, 0, i, 6], ['2004', i, 0, i, 6], ['2004', i+1, 0, i, 6] ]); i++; });

it's not real values i'll set them when i'll able create array.

i have error in browser console when run :

uncaught error: type mismatch. value 0 not match type string in column index 1

when set strings instead, google send me error message instead of chart :

data column(s) axis #0 cannot of type string

i don't know if got mean, seek this:

var rows = new array(); rows.push(new array('year', 'marque1', 'marque2', 'marque3', 'marque4')); var = 1; msg.foreach(function(entry) { rows.push(new array(5, 5, 5, 5, 5)); // replace values } var info = google.visualization.arraytodatatable(rows);

javascript arrays json google-visualization

No comments:

Post a Comment