I am trying to generate google charts using PHP and ajax.
my php file is returning values as bellow
["India":149,"United States":1375,"Taiwan":22,"Latvia":1,"New Zealand":2,"Argentina":1,"Namibia":4,"Ghana":4,"Mauritania":1,"Sudan":3,"Kazakhstan":2,"Nigeria":3,"Kenya":2,"FYROM":1,"Nepal":4}]
into vribale
jsonData
i am trying to add these values in Google Charts with bellow code
var data = new google.visualization.DataTable(jsonData);
its giving error as i assume that there is no Colums define in value. so i change code to bellow
var data = new google.visualization.DataTable();
data.addColumn('string', 'Country');
data.addColumn('number', 'Value');
data.addRows(jsonData);
this is also giving me error that value must be array.
how to fix this, as i can't change result from PHP file.
Thanks