integration radar

This commit is contained in:
Michael RICOIS 2010-04-01 16:33:24 +00:00
parent 3817f7c31f
commit 4bd9ac0cc7

View File

@ -67,28 +67,38 @@ function commentaires_lien($content){
}
function commentaires_graph($id, $titre, $ratios = array() ){
$pattern = '/(Rs?)\[(.*)]#(.{1})/';
$data = array();
$data['x'] = commentaires_graph_x();
$pattern = '/(Rs?)\[(.*)]#(.{1})/';
foreach($ratios as $ratio){
FB::log($ratio, 'ratio');
//FB::log($ratio, 'ratio');
if( preg_match($pattern, $ratio, $matches) ){
$typeRatio = $matches[1];
$numRatio = $matches[2];
$typeElement = $matches[3];
$titreRatio = commentaires_graph_lib($numRatio);
switch($typeRatio){
case 'R' : $titreRatio.= ' - Entreprise'; break;
case 'Rs' : $titreRatio.= ' - Secteur'; break;
if ($typeElement != 'R'){
switch($typeRatio){
case 'R' : $titreRatio.= ' - Entreprise'; break;
case 'Rs' : $titreRatio.= ' - Secteur'; break;
}
}else{
$supPattern = '/\(.*?\)/';
$titreRatio = preg_replace($supPattern, '', $titreRatio);
}
$data['y'][] = array(
'titre' => $titreRatio,
'data' => commentaires_graph_y($typeRatio, $numRatio),
'style' => $typeElement,
);
//FB::log($data['y'], 'data');
}
}
$output = commentaires_graph_xy($id, $titre, $data);
$data['x'] = commentaires_graph_x();
if ($typeElement == 'R'){
$output = commentaires_graph_radar($id, $titre, $data);
} else {
$output = commentaires_graph_xy($id, $titre, $data);
}
return $output;
}
@ -110,19 +120,59 @@ function commentaires_graph_x(){
function commentaires_graph_y($typeRatio, $numRatio){
global $ratiosEntrep, $ratiosSecteur;
FB::log($typeRatio, 'typeRatio');
//FB::log($typeRatio, 'typeRatio');
switch($typeRatio){
case 'R' : $tabRatio = $ratiosEntrep; break;
case 'Rs' : $tabRatio = $ratiosSecteur; break;
}
$output = array();
foreach($tabRatio as $key => $val){
FB::log($val['r'.$numRatio], 'val');
//FB::log($val['r'.$numRatio], 'val');
$output[$key] = $val['r'.$numRatio];
}
return $output;
}
function commentaires_graph_radar($id, $titre, $data){
require_once 'phpchartdir/phpchartdir.php';
$path = PATH_SITE.'/cache/imgcache/';
$file = $id.'.png';
if(count($data)<=1){
$output = 0;
}else{
FB::log($data, 'data');
//Tri des données
foreach($data['y'] as $yKey => $y){
$i = 0;
foreach($y['data'] as $val){
$dataTri[$data['x'][$i]] = $val;
$i++;
}
ksort($dataTri);
$data['y'][$yKey]['data'] = array_values($dataTri);
}
sort($data['x']);
FB::log($data, 'data');
foreach($data['y'] as $val){
$num = count($val['data'])-1;
$gdata[] = $val['data'][$num];
$labels[] = $val['titre'];
}
}
FB::log($gdata, 'gdata');
$c = new PolarChart(500, 350);
$c->setPlotArea(250, 175, 150);
$c->addAreaLayer($gdata, 0x9999ff);
$c->angularAxis->setLabels($labels);
if( $c->makeChart($path.$file) === true ){
$output = $file;
}else{
$output = false;
}
return $output;
}
function commentaires_graph_xy($id, $titre, $data){
require_once 'phpchartdir/phpchartdir.php';
$path = PATH_SITE.'/cache/imgcache/';