Looking for options on how to do this. org chart as is doesn't work
because nodes have to be unique but as we know a function may have more
than one parent I create the array correctly but only the first use of the
node is displayed. Is there something more suited to do what I'm trying to
achieve.
<?php
/*echo "Item sent from post " . $_POST['parent'];*/
$node = $_POST['parent'];
$GLOBALS['i']=0;
$parent="";
function buildBranch($node, $con, $parent) {
$GLOBALS['branchcount']++;
$sql="SELECT Child FROM Links WHERE Parent='$node' ORDER BY
Child ASC";
$branch = mysqli_query($con,$sql);
while($row = mysqli_fetch_array($branch)) {
$GLOBALS['i']++;
$GLOBALS['ROWS'][$GLOBALS['i']] = [$row['Child'],$node];
buildBranch($row['Child'],$con, $node);
}
}
include "connectDB.php";
mysqli_select_db($con,"mapping_demo");
$GLOBALS['ROWS'][$GLOBALS['i']] = [$node,""];
$GLOBALS['prevNode'] = $node;
buildBranch($node,$con,$parent);
mysqli_close($con);
$mySweetJSONString=json_encode($ROWS);
?>
<script type='text/javascript'
src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', {packages:['orgchart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
var myArray = <?php echo "$mySweetJSONString"; ?>;
data.addColumn('string', 'Node');
data.addColumn('string', 'Parent');
data.addRows(myArray);
var chart = new
google.visualization.OrgChart(document.getElementById('chart_div'));
chart.draw(data);
}
</script>
--
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 https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-visualization-api/6ee965e2-4f65-4792-874b-515aad07f2ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.