I am using google charts and the code to generate a chart is indicated as:
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([
['Mushrooms', 3],
['Onions', 4],
['Olives', 3],
['Zucchini', 1],
['Pepperoni', 2],
]);
I am using php and I get result from a web service with ajax as string. For example I get a result as:
"[['Mushrooms', 3],['Onions', 4],['Olives', 3],['Zucchini', 1],['Pepperoni', 2],]"
I am trying to put this result in data.addRows(); for eg.
data.addRows(result);
However, it fails and generates no result. How can I append these data to the code? Thanks in advance.