2
0
forked from Wavyzz/dolibarr
Files
dolibarr-fork/htdocs/graph.class.php
2003-11-07 13:32:04 +00:00

109 lines
2.2 KiB
PHP

<?PHP
/* Copyright (c) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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$
*/
class Graph
{
var $db;
var $errorstr;
Function Graph()
{
include_once(DOL_DOCUMENT_ROOT."/includes/phplot/phplot.php");
$this->bgcolor = array(235,235,224);
$this->bordercolor = array(235,235,224);
$this->datacolor = array(array(204,204,179),
array(187,187,136),
array(235,235,224));
$this->precision_y = 0;
$this->width = 400;
$this->height = 200;
return 1;
}
/*
*
*
*
*/
Function draw($file, $data, $title='')
{
//Define the object
$graph = new PHPlot($this->width, $this->height);
$graph->SetIsInline(1);
$graph->SetPlotType('bars');
$graph->SetPlotAreaPixels(60, 10, $this->width-10, $this->height - 30) ;
$graph->SetBackgroundColor($this->bgcolor);
// TODO
//$graph->SetPrecisionY($this->precision_Y);
$graph->SetDataColors($this->datacolor, $this->bordercolor);
$graph->SetOutputFile($file);
//Set some data
$graph->SetDataValues($data);
$graph->SetVertTickIncrement(0);
//
if (strlen($title))
{
$graph->SetTitle = $title;
}
//Draw it
$graph->DrawGraph();
}
Function SetPrecisionY($which_prec)
{
$this->precision_y = $which_prec;
return true;
}
Function SetYLabel($label)
{
$this->YLabel = $label;
}
Function SetWidth($w)
{
$this->width = $w;
}
Function SetHeight($h)
{
$this->height = $h;
}
}
?>