jquery google visual api graph's data rows does not work.

Posted by marharépa on Stack Overflow See other posts from Stack Overflow or by marharépa
Published on 2010-04-25T13:55:24Z Indexed on 2010/04/25 14:03 UTC
Read the original article Hit count: 270

Hi! I'd like to use google drawVisualization API. Example:

 var data = new google.visualization.DataTable();
  data.addColumn('string');
  data.addColumn('number');
  data.addRows([
    ['a', 14],
    ['b', 47],
    ['c', 80],
    ['d', 55],
    ['e', 16],
    ['f', 90],
    ['g', 29],
    ['h', 23],
    ['i', 58],
    ['j', 48]
  ]);

My version gets elements by an other google api, and join them, and after place the variable between ([ and ]), to be like in the example.

var outputGraph = [];

for (var i = 0, entry; entry = entries[i]; ++i) {

var asd = [
entry.getValueOf('ga:pageTitle'),
entry.getValueOf('ga:pageviews')
].join("',");
outputGraph.push(" ['" + asd + "]");
//get the 2 elements and join them to be like ['asd', 2], 

}
// this is fine, the outputgraph is like ['asd', 2], ['asd', 2], ['asd', 2] as seen in the example

var outputGraphFine = ("(["+outputGraph+"])");
// i suggest this is which fails the script.

var data = new google.visualization.DataTable();
 data.addColumn('string', 'Task');
 data.addColumn('number', 'Hours per Day');
 data.addRows = outputGraphFine;

But it doesn't work. Why?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about google-api