Hey
I want to load a org chart with info from a database, so found this example
https://developers.google.com/chart/interactive/docs/php_example
but that is a piechart example not orgchart..
Somehow my code don't show the org chart. Here is my code:
<script type="text/javascript" src="https://www.google.com/jsapi"
></script>
<script type="text/javascript" src=
"//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1', {'packages':['orgchart']});
//google.load('visualization', '1', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
function drawChart() {
var jsonData = $.ajax({
url: "getData.php",
dataType:"json",
async: false
}).responseText;
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.DataTable(jsonData);
// Instantiate and draw our chart, passing in some options.
//var chart = new
google.visualization.PieChart(document.getElementById('chart_div'));
var chart = new google.visualization.OrgChart(document.getElementById(
'chart_div'));
chart.draw(data, {width: 400, height: 240});
}
</script>
getData.php:
<?php
$return_array = array();
$tmp1 = array("0" => "Mike", "1"'=> Mike', "2" =>"");
$tmp2 = array("0" => "Jim", "1"'=> Mike', "2" =>"test1");
$tmp3 = array("0" => "Bob", "1"'=> Jim', "2" =>"Bob Sponge");
$tmp4 = array("0" => "Carol", "1"'=> Bob', "2" =>"");
array_push($array, $tmp1);
array_push($array, $tmp2);
array_push($array, $tmp3);
array_push($array, $tmp4);
echo json_encode($return_array);
?>
The issue is that when this code executes nothing is displayed. Unsuresure
if naming columns in the array like "0", "1" etc is correct, but the doc
says they are named it (or so I understand the doc)
--
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/d/optout.