2004-10-20 23:06:45 +02:00
|
|
|
|
<?php
|
2004-07-21 17:05:34 +02:00
|
|
|
|
/* Copyright (c) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2005-07-16 16:03:27 +02:00
|
|
|
|
* Copyright (c) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
2003-11-24 13:28:34 +01:00
|
|
|
|
*
|
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
*
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
*
|
|
|
|
|
|
* $Id$
|
|
|
|
|
|
* $Source$
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2004-12-04 19:16:32 +01:00
|
|
|
|
/**
|
|
|
|
|
|
\file htdocs/bargraph.class.php
|
|
|
|
|
|
\brief Fichier de la classe de gestion de graphs phplot
|
|
|
|
|
|
\version $Revision$
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
include_once(DOL_DOCUMENT_ROOT."/graph.class.php");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
\class BarGraph
|
2005-07-16 16:07:55 +02:00
|
|
|
|
\brief Classe permettant la gestion des graphs Bar a travers de PHPlot
|
|
|
|
|
|
\remarks Usage:
|
2005-07-16 16:03:27 +02:00
|
|
|
|
$graph_data = array("1"=>10,"2"=>20);
|
2005-07-16 16:07:55 +02:00
|
|
|
|
$px = new BarGraph();
|
2005-07-16 16:03:27 +02:00
|
|
|
|
$px->SetData($graph_data);
|
|
|
|
|
|
$px->SetTitle("title");
|
|
|
|
|
|
$px->SetLegend(array("Val1","Val2"));
|
2005-07-16 16:07:55 +02:00
|
|
|
|
$px->SetWidth(width);
|
|
|
|
|
|
$px->SetHeight(height);
|
|
|
|
|
|
$px->draw("file.png");
|
2004-12-04 19:16:32 +01:00
|
|
|
|
*/
|
2003-11-24 13:28:34 +01:00
|
|
|
|
|
|
|
|
|
|
class BarGraph extends Graph
|
|
|
|
|
|
{
|
2005-07-16 16:03:27 +02:00
|
|
|
|
var $db;
|
|
|
|
|
|
var $error;
|
2004-06-08 22:26:55 +02:00
|
|
|
|
|
2004-12-04 19:16:32 +01:00
|
|
|
|
|
2005-07-16 16:03:27 +02:00
|
|
|
|
/**
|
|
|
|
|
|
* \brief Initialisation graphe
|
|
|
|
|
|
* \return int <0 si ko, >0 si ok
|
|
|
|
|
|
*/
|
|
|
|
|
|
function BarGraph()
|
|
|
|
|
|
{
|
2005-07-16 16:26:36 +02:00
|
|
|
|
global $conf;
|
|
|
|
|
|
|
2005-07-16 16:03:27 +02:00
|
|
|
|
// Test si module GD pr<70>sent
|
|
|
|
|
|
$modules_list = get_loaded_extensions();
|
|
|
|
|
|
$isgdinstalled=0;
|
|
|
|
|
|
foreach ($modules_list as $module)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($module == 'gd') { $isgdinstalled=1; }
|
|
|
|
|
|
}
|
|
|
|
|
|
if (! $isgdinstalled) {
|
|
|
|
|
|
$this->error="Erreur: Le module GD pour php ne semble pas disponible. Il est requis pour g<>n<EFBFBD>rer les graphiques.";
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
}
|
2004-06-08 22:26:55 +02:00
|
|
|
|
|
2005-07-16 16:03:27 +02:00
|
|
|
|
// D<>fini propri<72>t<EFBFBD>s de l'objet graphe
|
|
|
|
|
|
$this->data = $data; // En general data non defini qd on cr<63>e objet
|
2003-11-24 13:28:34 +01:00
|
|
|
|
|
2005-07-16 16:03:27 +02:00
|
|
|
|
$this->bordercolor = array(235,235,224);
|
|
|
|
|
|
$this->datacolor = array(array(204,204,179), array(187,187,136), array(235,235,224));
|
|
|
|
|
|
$this->bgcolor = array(235,235,224);
|
2004-07-21 17:05:34 +02:00
|
|
|
|
|
2005-07-16 16:03:27 +02:00
|
|
|
|
$color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/graph-color.php";
|
|
|
|
|
|
if (is_readable($color_file))
|
|
|
|
|
|
{
|
|
|
|
|
|
include($color_file);
|
2005-07-16 16:26:36 +02:00
|
|
|
|
if (isset($theme_bordercolor)) $this->bordercolor = $theme_bordercolor;
|
|
|
|
|
|
if (isset($theme_datacolor)) $this->datacolor = $theme_datacolor;
|
|
|
|
|
|
if (isset($theme_bgcolor)) $this->bgcolor = $theme_bgcolor;
|
2005-07-16 16:03:27 +02:00
|
|
|
|
}
|
2004-07-21 17:05:34 +02:00
|
|
|
|
|
2005-07-16 16:03:27 +02:00
|
|
|
|
$this->precision_y = 0;
|
2003-11-24 13:28:34 +01:00
|
|
|
|
|
2005-07-16 16:03:27 +02:00
|
|
|
|
$this->width = 400;
|
|
|
|
|
|
$this->height = 200;
|
|
|
|
|
|
|
|
|
|
|
|
$this->PlotType = 'bars';
|
|
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
2003-11-24 13:28:34 +01:00
|
|
|
|
|
2004-06-08 22:26:55 +02:00
|
|
|
|
|
2005-07-16 16:03:27 +02:00
|
|
|
|
function isGraphKo()
|
|
|
|
|
|
{
|
|
|
|
|
|
return $this->error;
|
|
|
|
|
|
}
|
2003-11-24 13:28:34 +01:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|