Amélioration graphs

This commit is contained in:
Michael RICOIS 2009-04-01 07:32:24 +00:00
parent be480f0395
commit 7bbad14fb6
3 changed files with 43 additions and 30 deletions

View File

@ -4,13 +4,12 @@ require_once './lib/phpchartdir.php';
# The data for the line chart
$data = unserialize(urldecode($_REQUEST['data']));
$unite = isset($_REQUEST['unite']) ? $_REQUEST['unite'] : 'KEUROS';
$firephp->log($data,'data');
foreach($data as $value){
if ($unite=='KEUROS'){ $dataX[] = $value['value']/1000; }
else { $dataX[] = $value['value']; }
$dataX[] = $value['value'];
//$jour = substr($value['date'],6,2);
//$mois = substr($value['date'],4,2);
$annee = substr($value['date'],0,4);
//$annee = substr($value['date'],0,4);
$labelsX[] = substr($value['date'],0,4);
}

View File

@ -1,13 +1,13 @@
<?php
//Graphique style linecompare / CA / FR / BFR
require_once './lib/phpchartdir.php';
require_once realpath(dirname(__FILE__)).'/lib/phpchartdir.php';
//Définition des valeurs pour le graph
$dataBFR = array();
$dataFR = array();
$dataCA = array();
$data = unserialize(urldecode($_REQUEST['data']));
$data = unserialize(file_get_contents(realpath(dirname(__FILE__)).'/../../cache/'.$_REQUEST['d']));
$firephp->log($data, 'data');
$i=0;
//Parcourir les années
@ -16,10 +16,10 @@ foreach($data as $item){
//$mois = substr($item['date'],4,2);
$annee = substr($item['date'],0,4);
$dataBFR['x'][$i] = $dataFR['x'][$i] = $dataCA['x'][$i] = $dataEBE['x'][$i] = chartTime((int)$annee, 1, 1);
$dataBFR['y'][$i] = $item['r236']/1000;
$dataFR['y'][$i] = $item['r235']/1000;
$dataCA['y'][$i] = $item['r6']/1000;
$dataEBE['y'][$i] = $item['r140']/1000;
$dataBFR['y'][$i] = $item['r236'];
$dataFR['y'][$i] = $item['r235'];
$dataCA['y'][$i] = $item['r6'];
$dataEBE['y'][$i] = $item['r146'];
$i++;
}
@ -41,7 +41,7 @@ $c->addTitle("Synth
$c->addText(60, 320, "* Elements financier rapportés à 12 mois" );
$c->setPlotArea(60, 80, 500, 200, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
$c->yAxis->setTitle("KEUROS");
$c->yAxis->setTitle("KEUROS","timesbi.ttf",10);
$c->xAxis->setTitle( "<*block,valign=absmiddle*>Années<*/*>");
$c->xAxis->setWidth(2);
$c->yAxis->setWidth(2);
@ -80,5 +80,4 @@ $c->addInterLineLayer($layer0->getLine(0), $layer1->getLine(0), Transparent, 0x8
// output the chart
header("Content-type: image/png");
print($c->makeChart2(PNG));
?>

View File

@ -56,57 +56,73 @@ function dEvol($nAnnee,$nRatio){
print $ratio.' %';
}
$nbrAnnees=5;
$nbrAnnees=count($bilansInfos)-1;
$i=0;
foreach($bilansInfos as $dateCloture){
//Données pour le graphique
if(isset($dateCloture['dateCloture'])){
$dataGraph[$i]['date'] = $dateCloture['dateCloture'];
$dataGraph[$i]['r236'] = $ratiosEntrep[$i]['r236'];
$dataGraph[$i]['r235'] = $ratiosEntrep[$i]['r235'];
$dataGraph[$i]['r6'] = $ratiosEntrep[$i]['r6'];
$dataGraph[$i]['r146'] = $ratiosEntrep[$i]['r146'];
$dataGraph[$i]['r236'] = $ratiosEntrep[$i]['r236']/1000;
$dataGraph[$i]['r235'] = $ratiosEntrep[$i]['r235']/1000;
$dataGraph[$i]['r6'] = $ratiosEntrep[$i]['r6']/1000;
$dataGraph[$i]['r146'] = $ratiosEntrep[$i]['r146']/1000;
}
//Données pour les graphiques évolutions
if ($nbrAnnees-$i!=$nbrAnnees){
if(isset($bilansInfos[$nbrAnnees-$i]['dateCloture'])){
//Données pour les graphiques évolutions
$evol_r5[] = array( 'date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r6']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r6'] : 0 )
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r6']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r6']/1000 : 0 )
);
$evol_r7[] = array( 'date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r8']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r8'] : 0 )
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r8']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r8']/1000 : 0 )
);
$evol_r10[] = array('date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r11']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r11'] : 0 )
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r11']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r11']/1000 : 0 )
);
$evol_r18[] = array('date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r19']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r19'] : 0 )
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r19']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r19']/1000 : 0 )
);
$evol_r22[] = array('date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r23']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r23']: 0 )
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r23']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r23']/1000 : 0 )
);
$evol_r231[] = array( 'date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r235']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r235'] : 0 )
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r235']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r235']/1000 : 0 )
);
$evol_r232[] = array( 'date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r236']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r236'] : 0 )
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r236']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r236']/1000 : 0 )
);
$evol_r63[] = array('date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r64']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r64'] : 0 )
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r64']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r64']/1000 : 0 )
);
$evol_r24[] = array('date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r24']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r24'] : 0 )
);
}
$i++;
}
$firephp->log($evol_r63,'$evol_r63');
//Création du fichier image
//<img src="./graphs/synthese_graph_linecompare.php?d=<?=urlencode(serialize($dataGraph));>" />
//Générer un nom de fichier pour le cache et l'export des fichiers
if (($siret*1)==0 || ($siren*1)<100){
$fileName = $page2.'-'.$idEntreprise;
}else{
$fileName = $page2.'-'.$siret;
}
$fileName.= '-graph-linecompare.tmp';
$path = '../cache/';
file_put_contents($path.$fileName, serialize($dataGraph));
?>
<script type="text/javascript" src="./js/jquery.simpletip.js"></script>
@ -133,6 +149,7 @@ $(document).ready(function(){
}
#synthese
{
clear:both;
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size: 12px;
margin: 0px;
@ -194,7 +211,6 @@ $(document).ready(function(){
font-weight:bold;
}
/* ----- add selectors here for font sizing ----- */
#JT_close_left, #JT_close_right{font-size: 12px;}
#JT_copy p, #JT_copy ul{font-size: 12px;}
@ -351,8 +367,7 @@ if (count($ratiosEntrep)==0 || !isset($ratiosEntrep)){
</tbody>
</table>
<br/><br/>
<img src="./graphs/synthese_graph_linecompare.php?data=<?=urlencode(serialize($dataGraph))?>" />
<img src="./graphs/synthese_graph_linecompare.php?d=<?=$fileName?>" />
<?php
}
?>