Created
May 15, 2013 16:03
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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