You still have to request the data from the JSON file. Here's an example,
using jQuery to handle the AJAX:
function drawChart () {
$.ajax({
url: 'path/to/sampledata.json',
dataType: 'json',
success: function (json) {
var data = new google.visualization.DataTable(json);
var chart = new
google.visualization.OrgChart(document.getElementById('visualization'));
chart.draw(data, {allowHtml: true, allowCollapse: true});
}
});
}
google.load('visualization', '1', {packages: ['orgchart'], callback:
drawChart});
On Wednesday, October 23, 2013 10:38:43 AM UTC-4, Avi Benita wrote:
>
>
> Thanks. *The following is not working.* Certainly a wrong implementation
> of your advice...Any idea?
>
>
> *js script:*
>
>
> <script type="text/javascript">
> function drawVisualization() {
> // Create and populate the data table.
> obj = JSON.parse(sampleData.json);
> var data = google.visualization.arrayToDataTable();
>
> // Create and draw the visualization.
> var chart = new
> google.visualization.OrgChart(document.getElementById('visualization'));
> chart.draw(data, {allowHtml: true, allowCollapse: true});
>
> for (var i = 1; i < data.getNumberOfRows(); i++) {
> chart.collapse(i, true);
> }
> }
>
> *My Json file (sampleData.json):*
>
> [
> ['Name',
> 'Manager', 'Tooltip'],
> ['Mike',
> null, 'The President'],
> [{v: 'Jim', f: 'Jim<br/><font color="red"><i>Vice
> President<i></font>'}, 'Mike', null],
> ['Alice',
> 'Mike', null],
> ['Bob',
> 'Jim', 'Bob Sponge'],
> ['Carol',
> 'Bob', null]
> ]
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.