Gestion de la librairie Artichow
This commit is contained in:
parent
635b67aead
commit
ca7b72519a
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (c) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (c) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (c) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (c) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -46,8 +46,10 @@
|
|||||||
|
|
||||||
class DolGraph
|
class DolGraph
|
||||||
{
|
{
|
||||||
var $type='bars'; // Type de graph
|
//! Type du graphique
|
||||||
var $data; // Tableau de donnees
|
var $type='bars';
|
||||||
|
//! Tableau de donnees
|
||||||
|
var $data;
|
||||||
var $width=380;
|
var $width=380;
|
||||||
var $height=200;
|
var $height=200;
|
||||||
var $MaxValue=0;
|
var $MaxValue=0;
|
||||||
@ -58,15 +60,17 @@ class DolGraph
|
|||||||
var $SetNumXTicks=-1;
|
var $SetNumXTicks=-1;
|
||||||
|
|
||||||
var $graph; // Objet PHPlot
|
var $graph; // Objet PHPlot
|
||||||
|
|
||||||
var $error;
|
var $error;
|
||||||
|
|
||||||
|
var $library;
|
||||||
|
|
||||||
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;
|
||||||
@ -111,16 +115,85 @@ class DolGraph
|
|||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Génère le fichier graphique sur le disque
|
* \brief Génère le fichier graphique sur le disque
|
||||||
* \param file Nom du fichier image
|
* \param file Nom du fichier image
|
||||||
*/
|
*/
|
||||||
function draw($file)
|
function draw($file)
|
||||||
{
|
{
|
||||||
// Prepare parametres
|
$call = "draw_".$this->library;
|
||||||
$this->prepare($file);
|
$this->$call($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
function prepare($file)
|
||||||
|
{
|
||||||
|
$call = "prepare_".$this->library;
|
||||||
|
$this->$call($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
function generate($file)
|
||||||
|
{
|
||||||
|
$call = "generate_".$this->library;
|
||||||
|
$this->$call($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Artichow
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function draw_artichow($file)
|
||||||
|
{
|
||||||
|
require_once DOL_DOCUMENT_ROOT."/../external-libs/Artichow/BarPlot.class.php";
|
||||||
|
|
||||||
|
$graph = new Graph($this->width, $this->height);
|
||||||
|
if (isset($this->title)) $graph->title->set($this->title);
|
||||||
|
|
||||||
|
$graph->border->hide();
|
||||||
|
|
||||||
|
$color = new Color(244,244,244);
|
||||||
|
|
||||||
|
$graph->setAntiAliasing(TRUE);
|
||||||
|
|
||||||
|
$graph->setBackgroundColor( $color );
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
foreach($this->data as $key => $value)
|
||||||
|
{
|
||||||
|
$values[$i] = $value[1];
|
||||||
|
$legends[$i] = $value[0];
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$plot = new BarPlot($values);
|
||||||
|
$plot->setSize(1, 0.96);
|
||||||
|
$plot->setCenter(0.5, 0.52);
|
||||||
|
|
||||||
|
$plot->setBarColor( new LightGreen(25) );
|
||||||
|
|
||||||
|
$plot->xAxis->setLabelText($legends);
|
||||||
|
$plot->xAxis->label->setFont(new Tuffy(7));
|
||||||
|
|
||||||
|
$graph->add($plot);
|
||||||
|
|
||||||
|
$graph->draw($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Génère le fichier graphique sur le disque
|
||||||
|
* \param file Nom du fichier image
|
||||||
|
*/
|
||||||
|
function draw_phplot($file)
|
||||||
|
{
|
||||||
|
// Prepare parametres
|
||||||
|
$this->prepare_phplot($file);
|
||||||
|
|
||||||
|
$this->generate_phplot();
|
||||||
|
}
|
||||||
|
|
||||||
|
function generate_phplot()
|
||||||
|
{
|
||||||
// Génère le fichier $file
|
// Génère le fichier $file
|
||||||
$this->graph->DrawGraph();
|
$this->graph->DrawGraph();
|
||||||
}
|
}
|
||||||
@ -129,7 +202,7 @@ class DolGraph
|
|||||||
* \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($file)
|
function prepare_phplot($file)
|
||||||
{
|
{
|
||||||
// Define the object
|
// Define the object
|
||||||
$this->graph = new PHPlot($this->width, $this->height);
|
$this->graph = new PHPlot($this->width, $this->height);
|
||||||
@ -185,7 +258,7 @@ class DolGraph
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->graph->SetNumVertTicks($maxticks);
|
$this->graph->SetNumVertTicks($maxticks);
|
||||||
// print 'minval='.$minval.' - maxval='.$maxval.' - plage='.$plage.' - maxticks='.$maxticks.'<br>';
|
// print 'minval='.$minval.' - maxval='.$maxval.' - plage='.$plage.' - maxticks='.$maxticks.'<br>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user