Ok, So there's a json table in visualisation APIs.
I got a question to json/js/ajax specialists.
So here's a sample code.
Instead of using json object in the script I wanna have separate json
file (for ease of data maintenance).
So the file would go like this:
cols: [{id: 'name', label: 'Name', type: 'string'},
{id: 'speciality', label: 'Speciality', type:
'string'},
{id: 'address', label: 'Address', type: 'string'},
{id: 'phone', label: 'Phone', type: 'string'}],
rows: [
{c:[{v: 'A'}, {v: 'A'}, v:{'address1'}, v:{'555-1111'}]},
{c:[{v: 'B. '}, {v:'A'}, {v:'address2 '},
{v:'555-3333'}]},
{c:[{v: 'C.'}, , {v:'A'}, {v:'address2'},
{v:'555-0000'}]
How do I properly implement that. (Using the file above from the
server (same server as the document) instead of having to create json
object within the main document like below)?
<script type="text/javascript">
function drawVisualization() {
// Create and populate the data table.
var JSONObject = {
cols: [{id: 'name', label: 'Name', type: 'string'},
{id: 'speciality', label: 'Speciality', type:
'string'},
{id: 'address', label: 'Address', type: 'string'},
{id: 'phone', label: 'Phone', type: 'string'}],
rows: [
{c:[{v: 'A'}, {v: 'A'}, v:{'address1'}, v:{'555-1111'}]},
{c:[{v: 'B. '}, {v:'A'}, {v:'address2 '},
{v:'555-3333'}]},
{c:[{v: 'C.'}, , {v:'A'}, {v:'address2'},
{v:'555-0000'}]}
]};
var data = new google.visualization.DataTable(JSONObject, 0.5);
// Create and draw the visualization.
visualization = new google.visualization.Table
(document.getElementById('table'));
visualization.draw(data, {'allowHtml': true});
}
google.setOnLoadCallback(drawVisualization);
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="table"></div>
</body>
</html>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en
-~----------~----~----~----~------~----~------~--~---