Skip to content

Instantly share code, notes, and snippets.

@ntsh
Created May 15, 2013 16:03
Show Gist options
  • Save ntsh/5585104 to your computer and use it in GitHub Desktop.
Save ntsh/5585104 to your computer and use it in GitHub Desktop.
This function demonstrate how to use Google charts to show json data in data table. http://code.google.com/apis/ajax/playground/?type=visualization#table
function drawVisualization() {
// Create and populate the data table.
var jsonData = {
"count":2,
"customerList":[
{"customerName":"manas","customerID":"manas@example.com"},
{"customerName":"neetesh","customerID":"neetesh@example.com"}
]
};
c = jsonData.customerList;
var data = new google.visualization.DataTable();
data.addColumn('number', 's.no.');
data.addColumn('string', 'Customer Name');
data.addColumn('string', 'Customer email ID');
data.addRows(c.length);
for(var i = 0; i< c.length ; i++)
{
data.setCell(i, 0, i)
data.setCell(i, 1, c[i].customerID);
data.setCell(i, 2, c[i].customerName);
}
visualization = new google.visualization.Table(document.getElementById('table'));
visualization.draw(data, null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment