New: On définit la constante MAIN_GRAPH_LIBRARY qui pourra etre utilisé pour choisir la librairie graphique utilisée.

This commit is contained in:
Laurent Destailleur 2006-12-06 00:28:04 +00:00
parent 41ee95bab4
commit bd2524521d
2 changed files with 479 additions and 467 deletions

View File

@ -426,6 +426,13 @@ class Conf
$this->adherent->email_new_subject=MAIN_MAIL_NEW_SUBJECT; $this->adherent->email_new_subject=MAIN_MAIL_NEW_SUBJECT;
} }
// Defini MAIN_GRAPH_LIBRARY
if (! in_array($this->global->MAIN_GRAPH_LIBRARY, array('phplot','artichow')))
{
$this->global->MAIN_GRAPH_LIBRARY='phplot';
// $this->global->MAIN_GRAPH_LIBRARY = 'artichow';
}
// Format de la date // Format de la date
// \todo Mettre les 4 formats dans fichier langue // \todo Mettre les 4 formats dans fichier langue
$this->format_date_short="%d/%m/%Y"; $this->format_date_short="%d/%m/%Y";

View File

@ -59,18 +59,17 @@ class DolGraph
var $SetHorizTickIncrement=-1; var $SetHorizTickIncrement=-1;
var $SetNumXTicks=-1; var $SetNumXTicks=-1;
var $graph; // Objet PHPlot var $graph; // Objet Graph (PHPlot ou Artichow...)
var $error; var $error;
var $library; var $library=''; // Par defaut on utiliser PHPlot
function DolGraph() function DolGraph()
{ {
global $conf; global $conf;
global $theme_bordercolor, $theme_datacolor, $theme_bgcolor, $theme_bgcoloronglet; global $theme_bordercolor, $theme_datacolor, $theme_bgcolor, $theme_bgcoloronglet;
$this->library = 'phplot';
// Test si module GD présent // Test si module GD présent
$modules_list = get_loaded_extensions(); $modules_list = get_loaded_extensions();
$isgdinstalled=0; $isgdinstalled=0;
@ -78,21 +77,15 @@ class DolGraph
{ {
if ($module == 'gd') { $isgdinstalled=1; } if ($module == 'gd') { $isgdinstalled=1; }
} }
if (! $isgdinstalled) { if (! $isgdinstalled)
{
$this->error="Erreur: Le module GD pour php ne semble pas disponible. Il est requis pour générer les graphiques."; $this->error="Erreur: Le module GD pour php ne semble pas disponible. Il est requis pour générer les graphiques.";
return -1; return -1;
} }
// Vérifie que chemin vers PHPLOT_PATH est connu et definie $graphpath
$graphpathdir=DOL_DOCUMENT_ROOT."/includes/phplot";
if (defined('PHPLOT_PATH')) $graphpathdir=PHPLOT_PATH;
if ($conf->global->PHPLOT_PATH) $graphpathdir=$conf->global->PHPLOT_PATH;
if (! eregi('[\\\/]$',$graphpathdir)) $graphpathdir.='/';
include_once($graphpathdir.'phplot.php');
// Défini propriétés de l'objet graphe // Défini propriétés de l'objet graphe
$this->library=$conf->global->MAIN_GRAPH_LIBRARY;
$this->bordercolor = array(235,235,224); $this->bordercolor = array(235,235,224);
$this->datacolor = array(array(120,130,150), array(160,160,180), array(190,190,220)); $this->datacolor = array(array(120,130,150), array(160,160,180), array(190,190,220));
$this->bgcolor = array(235,235,224); $this->bgcolor = array(235,235,224);
@ -192,18 +185,19 @@ class DolGraph
$this->generate_phplot(); $this->generate_phplot();
} }
function generate_phplot()
{
// Génère le fichier $file
$this->graph->DrawGraph();
}
/** /**
* \brief Prépare l'objet PHPlot * \brief Prépare l'objet PHPlot
* \param file Nom du fichier image à générer * \param file Nom du fichier image à générer
*/ */
function prepare_phplot($file) function prepare_phplot($file)
{ {
// Vérifie que chemin vers PHPLOT_PATH est connu et on definie $graphpathdir
$graphpathdir=DOL_DOCUMENT_ROOT."/includes/phplot";
if (defined('PHPLOT_PATH')) $graphpathdir=PHPLOT_PATH;
if ($conf->global->PHPLOT_PATH) $graphpathdir=$conf->global->PHPLOT_PATH;
if (! eregi('[\\\/]$',$graphpathdir)) $graphpathdir.='/';
include_once($graphpathdir.'phplot.php');
// Define the object // Define the object
$this->graph = new PHPlot($this->width, $this->height); $this->graph = new PHPlot($this->width, $this->height);
@ -320,7 +314,7 @@ class DolGraph
} }
if ($this->SetHorizTickIncrement > -1) if ($this->SetHorizTickIncrement > -1)
{ {
// Les ticks sont en mode forcé // Les ticks sont en mode forc
$this->graph->SetHorizTickIncrement($this->SetHorizTickIncrement); $this->graph->SetHorizTickIncrement($this->SetHorizTickIncrement);
if ($phplotversion >= 5) // If PHPlot 5, for compatibility if ($phplotversion >= 5) // If PHPlot 5, for compatibility
{ {
@ -350,6 +344,17 @@ class DolGraph
$this->graph->SetOutputFile($file); $this->graph->SetOutputFile($file);
} }
/**
* \brief Génère le graph dans fichier préparer dans $graph
* \param file Nom du fichier image
*/
function generate_phplot()
{
$this->graph->DrawGraph();
}
function SetPrecisionY($which_prec) function SetPrecisionY($which_prec)
{ {
$this->PrecisionY = $which_prec; $this->PrecisionY = $which_prec;