2016-05-25 17:29:47 +00:00
|
|
|
|
<?php define('__ROOT__', dirname(dirname(__FILE__)) );
|
|
|
|
|
|
|
|
|
|
require_once __ROOT__.'/manager/autoloader.php';
|
|
|
|
|
|
|
|
|
|
use \manager\ModuleRequest;
|
|
|
|
|
use \manager\ManagerError;
|
|
|
|
|
|
|
|
|
|
debug();
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
2016-05-25 17:03:13 +00:00
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html>
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="utf-8">
|
|
|
|
|
<title>Chart réseau</title>
|
|
|
|
|
<script type='text/javascript' src='/f/js/api-min/js/lib'></script> <!-- Gestion des transactions avec le serveur -->
|
|
|
|
|
</head>
|
|
|
|
|
<body style='display: flex; flex-direction: row; justify-content: space-around; flex-wrap: wrap;'>
|
2016-05-25 17:29:47 +00:00
|
|
|
|
<?php
|
|
|
|
|
/* [1] On récupère les données
|
|
|
|
|
=========================================================*/
|
2016-05-26 09:47:02 +00:00
|
|
|
|
$req = new ModuleRequest('chart/network', array('subject'=>1/*273*/));
|
2016-05-25 17:29:47 +00:00
|
|
|
|
$res = $req->dispatch();
|
2016-05-25 17:03:13 +00:00
|
|
|
|
|
2016-05-25 17:29:47 +00:00
|
|
|
|
if( $res->error != ManagerError::Success )
|
|
|
|
|
var_dump( ManagerError::explicit($res->error) );
|
2016-05-25 17:03:13 +00:00
|
|
|
|
|
2016-05-25 17:29:47 +00:00
|
|
|
|
var_dump($res->getAll());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* [2] Gestion spatiale
|
|
|
|
|
=========================================================*/
|
2016-05-26 09:47:02 +00:00
|
|
|
|
function dot(&$node, $x, $y){
|
|
|
|
|
$node['x'] = $x;
|
|
|
|
|
$node['y'] = $y;
|
|
|
|
|
return "<circle cx='$x' cy='$y' r='5' fill='".(($node['type']=='phone')?'#1db247':'#4891df')."'/>";
|
|
|
|
|
}
|
2016-05-25 17:29:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* [3] On affiche le contenu
|
|
|
|
|
=========================================================*/
|
2016-05-25 17:03:13 +00:00
|
|
|
|
echo "<?xml version='1.0' encoding='UTF-8' standalone='no'?>";
|
2016-05-25 17:29:47 +00:00
|
|
|
|
echo "<svg version='1.1' width='1000' height='1000' style='width: 40em; height: 40em;border:1px solid black'>";
|
|
|
|
|
|
2016-05-26 09:47:02 +00:00
|
|
|
|
$nodes = $res->get('nodes');
|
|
|
|
|
|
|
|
|
|
foreach($nodes as $n=>$node){
|
|
|
|
|
$r = array( floor(rand(10, 990)), floor(rand(10, 990)) );
|
|
|
|
|
|
|
|
|
|
echo dot($nodes[$n], $r[0], $r[1]);
|
|
|
|
|
}
|
2016-05-25 17:03:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "</svg>";
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|