Documentation
PHP Hierarchical
Hierarchical is a simple php & mysql program to arrange users based on their rankings, it can also be used to represent data in a chain ranking.
This libery will work very well with Google Organisation chart
Installation
Installation is super-easy via Composer:
composer require peterujah/hierarchical
USAGES
Hierarchical can be use as an array, html or google organizations chart
use Peterujah\NanoBlock\Hierarchical;
$hierarchy = new Hierarchical($conn, Hierarchical::LIST);
$hierarchy = new Hierarchical($conn, Hierarchical::HTML);
$hierarchy = new Hierarchical($conn, Hierarchical::CHART);
Dump array
$hierarchy = new Hierarchical($conn, Hierarchical::LIST);
var_export($hierarchy->run("Peter", "vy7735"));
Display on google Organisation chart
google.charts.load('current', {packages:["orgchart"]});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Name');
data.addColumn('string', 'Manager');
data.addColumn('string', 'ToolTip');
data.addRows(<?php echo $hierarchy->run("Peter", "vy7735");?>);
var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
chart.draw(data, {'allowHtml':true});
}
Initalisation options new Hierarchical($conn, Hierarchical::CHART)
| Options | Description |
|-----------------|-------------------------------------------------------------------------------------|
| LIST | Retrieve result as an array |
| HTML | Retrieve result in HTML list |
| CHART | Retrieve result in json data for google chart |