Skip to content
Snippets Groups Projects
Commit d9d3a11e authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Doxygen

parent f79d004e
No related branches found
No related tags found
No related merge requests found
<?php <?php
/* Copyright (c) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (c) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (c) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (c) 2004-2011 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
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** /**
* \file htdocs/core/class/dolgraph.class.php * \file htdocs/core/class/dolgraph.class.php
...@@ -42,645 +42,695 @@ ...@@ -42,645 +42,695 @@
*/ */
class DolGraph class DolGraph
{ {
//! Type du graphique //! Type du graphique
var $type='bars'; // bars, lines, ... var $type='bars'; // bars, lines, ...
var $mode='side'; // Mode bars graph: side, depth var $mode='side'; // Mode bars graph: side, depth
//! Tableau de donnees //! Tableau de donnees
var $data; // array(array('abs1',valA1,valB1), array('abs2',valA2,valB2), ...) var $data; // array(array('abs1',valA1,valB1), array('abs2',valA2,valB2), ...)
var $title; var $title;
var $width=380; var $width=380;
var $height=200; var $height=200;
var $MaxValue=0; var $MaxValue=0;
var $MinValue=0; var $MinValue=0;
var $SetShading=0; var $SetShading=0;
var $PrecisionY=-1; var $PrecisionY=-1;
var $horizTickIncrement=-1; var $horizTickIncrement=-1;
var $SetNumXTicks=-1; var $SetNumXTicks=-1;
var $labelInterval=-1; var $labelInterval=-1;
var $hideXGrid=false; var $hideXGrid=false;
var $hideYGrid=false; var $hideYGrid=false;
var $Legend=array(); var $Legend=array();
var $LegendWidthMin=0; var $LegendWidthMin=0;
var $graph; // Objet Graph (Artichow, Phplot...) var $graph; // Objet Graph (Artichow, Phplot...)
var $error; var $error;
var $library='artichow'; // Graphic library to use var $library='artichow'; // Graphic library to use
var $bordercolor; // array(R,G,B) var $bordercolor; // array(R,G,B)
var $bgcolor; // array(R,G,B) var $bgcolor; // array(R,G,B)
var $bgcolorgrid; // array(R,G,B) var $bgcolorgrid; // array(R,G,B)
var $datacolor; // array(array(R,G,B),...) var $datacolor; // array(array(R,G,B),...)
private $stringtoshow; // To store string to output graph into HTML page private $_stringtoshow; // To store string to output graph into HTML page
/** /**
* Constructor * Constructor
*/ */
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;
// Test si module GD present // Test si module GD present
$modules_list = get_loaded_extensions(); $modules_list = get_loaded_extensions();
$isgdinstalled=0; $isgdinstalled=0;
foreach ($modules_list as $module) foreach ($modules_list as $module)
{ {
if ($module == 'gd') { $isgdinstalled=1; } if ($module == 'gd') {
} $isgdinstalled=1;
if (! $isgdinstalled) }
{ }
$this->error="Error: PHP GD module is not available. It is required to build graphics."; if (! $isgdinstalled)
return -1; {
} $this->error="Error: PHP GD module is not available. It is required to build graphics.";
return -1;
$this->bordercolor = array(235,235,224); }
$this->datacolor = array(array(120,130,150), array(160,160,180), array(190,190,220));
$this->bgcolor = 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));
$color_file = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/graph-color.php'; $this->bgcolor = array(235,235,224);
if (is_readable($color_file))
{ $color_file = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/graph-color.php';
include_once($color_file); if (is_readable($color_file))
if (isset($theme_bordercolor)) $this->bordercolor = $theme_bordercolor; {
if (isset($theme_datacolor)) $this->datacolor = $theme_datacolor; include_once($color_file);
if (isset($theme_bgcolor)) $this->bgcolor = $theme_bgcolor; if (isset($theme_bordercolor)) $this->bordercolor = $theme_bordercolor;
} if (isset($theme_datacolor)) $this->datacolor = $theme_datacolor;
//print 'bgcolor: '.join(',',$this->bgcolor).'<br>'; if (isset($theme_bgcolor)) $this->bgcolor = $theme_bgcolor;
return 1; }
} //print 'bgcolor: '.join(',',$this->bgcolor).'<br>';
return 1;
}
/**
* Set Y precision
* /**
* @param float $which_prec * Set Y precision
* @return string *
*/ * @param float $which_prec Precision
function SetPrecisionY($which_prec) * @return string
{ */
$this->PrecisionY = $which_prec; function SetPrecisionY($which_prec)
return true; {
} $this->PrecisionY = $which_prec;
return true;
/** }
* Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2
* /**
* @param float $xi * Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2
*/ *
function SetHorizTickIncrement($xi) * @param float $xi Xi
{ * @return boolean True
$this->horizTickIncrement = $xi; */
return true; function SetHorizTickIncrement($xi)
} {
$this->horizTickIncrement = $xi;
/** return true;
* Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2 }
*
* @param float $xt /**
*/ * Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2
function SetNumXTicks($xt) *
{ * @param float $xt Xt
$this->SetNumXTicks = $xt; * @return boolean True
return true; */
} function SetNumXTicks($xt)
{
/** $this->SetNumXTicks = $xt;
* Set label interval to reduce number of labels return true;
* }
* @param float $x
*/ /**
function SetLabelInterval($x) * Set label interval to reduce number of labels
{ *
$this->labelInterval = $x; * @param float $x Label interval
return true; * @return boolean True
} */
function SetLabelInterval($x)
/** {
* Hide X grid $this->labelInterval = $x;
*/ return true;
function SetHideXGrid($bool) }
{
$this->hideXGrid = $bool; /**
return true; * Hide X grid
} *
* @param boolean $bool XGrid or not
/** * @return boolean true
* Hide Y grid */
*/ function SetHideXGrid($bool)
function SetHideYGrid($bool) {
{ $this->hideXGrid = $bool;
$this->hideYGrid = $bool; return true;
return true; }
}
/**
/** * Hide Y grid
* *
* @param unknown_type $label * @param boolean $bool YGrid or not
*/ * @return boolean true
function SetYLabel($label) */
{ function SetHideYGrid($bool)
$this->YLabel = $label; {
} $this->hideYGrid = $bool;
return true;
/** }
*
* @param $w /**
*/ * Set y label
function SetWidth($w) *
{ * @param string $label Y label
$this->width = $w; * @return boolean True
} */
function SetYLabel($label)
/** {
* $this->YLabel = $label;
* @param $title }
*/
function SetTitle($title) /**
{ * Set width
$this->title = $title; *
} * @param int $w Width
* @return boolean True
/** */
* function SetWidth($w)
* @param $data {
*/ $this->width = $w;
function SetData($data) }
{
$this->data = $data; /**
} * Set title
*
/** * @param string $title Title
* * @return void
* @param $type */
*/ function SetTitle($title)
function SetType($type) {
{ $this->title = $title;
$this->type = $type; }
}
/**
/** * Set data
* *
* @param $legend * @param array $data Data
*/ * @return void
function SetLegend($legend) */
{ function SetData($data)
$this->Legend = $legend; {
} $this->data = $data;
}
/**
* /**
* @param $legendwidthmin * Set type
*/ *
function SetLegendWidthMin($legendwidthmin) * @param string $type Type
{ * @return void
$this->LegendWidthMin = $legendwidthmin; */
} function SetType($type)
{
/** $this->type = $type;
* }
* @param $max
*/ /**
function SetMaxValue($max) * Set legend
{ *
$this->MaxValue = $max; * @param string $legend Legend
} * @return void
*/
/** function SetLegend($legend)
* {
*/ $this->Legend = $legend;
function GetMaxValue() }
{
return $this->MaxValue; /**
} * Set min width
*
/** * @param int $legendwidthmin Min width
* * @return void
* @param $min */
*/ function SetLegendWidthMin($legendwidthmin)
function SetMinValue($min) {
{ $this->LegendWidthMin = $legendwidthmin;
$this->MinValue = $min; }
}
/**
/** * Set max value
* *
*/ * @param int $max Max value
function GetMinValue() * @return void
{ */
return $this->MinValue; function SetMaxValue($max)
} {
$this->MaxValue = $max;
/** }
*
* @param $h /**
*/ * Get max value
function SetHeight($h) *
{ * @return int Max value
$this->height = $h; */
} function GetMaxValue()
{
/** return $this->MaxValue;
* }
* @param $s
*/ /**
function SetShading($s) * Set min value
{ *
$this->SetShading = $s; * @param int $min Min value
} * @return void
*/
/** function SetMinValue($min)
* {
*/ $this->MinValue = $min;
function ResetBgColor() }
{
unset($this->bgcolor); /**
} * Get min value
*
/** * @return int Max value
* */
*/ function GetMinValue()
function ResetBgColorGrid() {
{ return $this->MinValue;
unset($this->bgcolorgrid); }
}
/**
/** * Set height
* *
*/ * @param int $h Height
function isGraphKo() * @return void
{ */
return $this->error; function SetHeight($h)
} {
$this->height = $h;
}
/**
* Definie la couleur de fond de l'image complete /**
* * Set shading
* @param array $bg_color array(R,G,B) ou 'onglet' ou 'default' *
* @return void * @param string $s Shading
*/ * @return void
function SetBgColor($bg_color = array(255,255,255)) */
{ function SetShading($s)
global $theme_bgcolor,$theme_bgcoloronglet; {
if (! is_array($bg_color)) $this->SetShading = $s;
{ }
if ($bg_color == 'onglet')
{ /**
//print 'ee'.join(',',$theme_bgcoloronglet); * Reset bg color
$this->bgcolor = $theme_bgcoloronglet; *
} * @return void
else */
{ function ResetBgColor()
$this->bgcolor = $theme_bgcolor; {
} unset($this->bgcolor);
} }
else
{ /**
$this->bgcolor = $bg_color; * Reset bgcolorgrid
} *
} * @return void
*/
/** function ResetBgColorGrid()
* Definie la couleur de fond de la grille {
* unset($this->bgcolorgrid);
* @param array $bg_colorgrid array(R,G,B) ou 'onglet' ou 'default' }
*/
function SetBgColorGrid($bg_colorgrid = array(255,255,255)) /**
{ * Is graph ko
global $theme_bgcolor,$theme_bgcoloronglet; *
if (! is_array($bg_colorgrid)) * @return string Error
{ */
if ($bg_colorgrid == 'onglet') function isGraphKo()
{ {
//print 'ee'.join(',',$theme_bgcoloronglet); return $this->error;
$this->bgcolorgrid = $theme_bgcoloronglet; }
}
else
{ /**
$this->bgcolorgrid = $theme_bgcolor; * Define background color of complete image
} *
} * @param array $bg_color array(R,G,B) ou 'onglet' ou 'default'
else * @return void
{ */
$this->bgcolorgrid = $bg_colorgrid; function SetBgColor($bg_color = array(255,255,255))
} {
} global $theme_bgcolor,$theme_bgcoloronglet;
if (! is_array($bg_color))
/** {
* if ($bg_color == 'onglet')
*/ {
function ResetDataColor() //print 'ee'.join(',',$theme_bgcoloronglet);
{ $this->bgcolor = $theme_bgcoloronglet;
unset($this->datacolor); }
} else
{
/** $this->bgcolor = $theme_bgcolor;
* }
*/ }
function GetMaxValueInData() else
{ {
$k = 0; $this->bgcolor = $bg_color;
$vals = array(); }
}
$nblines = count($this->data);
$nbvalues = count($this->data[0]) - 1; /**
* Define background color of grid
for ($j = 0 ; $j < $nblines ; $j++) *
{ * @param array $bg_colorgrid array(R,G,B) ou 'onglet' ou 'default'
for ($i = 0 ; $i < $nbvalues ; $i++) * @return void
{ */
$vals[$k] = $this->data[$j][$i+1]; function SetBgColorGrid($bg_colorgrid = array(255,255,255))
$k++; {
} global $theme_bgcolor,$theme_bgcoloronglet;
} if (! is_array($bg_colorgrid))
rsort($vals); {
return $vals[0]; if ($bg_colorgrid == 'onglet')
} {
//print 'ee'.join(',',$theme_bgcoloronglet);
/** $this->bgcolorgrid = $theme_bgcoloronglet;
* }
*/ else
function GetMinValueInData() {
{ $this->bgcolorgrid = $theme_bgcolor;
$k = 0; }
$vals = array(); }
else
$nblines = count($this->data); {
$nbvalues = count($this->data[0]) - 1; $this->bgcolorgrid = $bg_colorgrid;
}
for ($j = 0 ; $j < $nblines ; $j++) }
{
for ($i = 0 ; $i < $nbvalues ; $i++) /**
{ * Reset data color
$vals[$k] = $this->data[$j][$i+1]; *
$k++; * @return void
} */
} function ResetDataColor()
sort($vals); {
return $vals[0]; unset($this->datacolor);
} }
/** /**
* Return max value of all data * Get max value
* *
* @return int Max value of all data * @return int Max value
*/ */
function GetCeilMaxValue() function GetMaxValueInData()
{ {
$max = $this->GetMaxValueInData(); $k = 0;
if ($max != 0) $max++; $vals = array();
$size=dol_strlen(abs(ceil($max)));
$factor=1; $nblines = count($this->data);
for ($i=0; $i < ($size-1); $i++) $nbvalues = count($this->data[0]) - 1;
{
$factor*=10; for ($j = 0 ; $j < $nblines ; $j++)
} {
for ($i = 0 ; $i < $nbvalues ; $i++)
$res=0; {
if (is_numeric($max)) $res=ceil($max/$factor)*$factor; $vals[$k] = $this->data[$j][$i+1];
$k++;
//print "max=".$max." res=".$res; }
return $res; }
} rsort($vals);
return $vals[0];
/** }
* Return min value of all data
* /**
* @return int Max value of all data * Return min value of all data
*/ *
function GetFloorMinValue() * @return int Min value of all data
{ */
$min = $this->GetMinValueInData(); function GetMinValueInData()
if ($min != 0) $min--; {
$size=dol_strlen(abs(floor($min))); $k = 0;
$factor=1; $vals = array();
for ($i=0; $i < ($size-1); $i++)
{ $nblines = count($this->data);
$factor*=10; $nbvalues = count($this->data[0]) - 1;
}
for ($j = 0 ; $j < $nblines ; $j++)
$res=floor($min/$factor)*$factor; {
for ($i = 0 ; $i < $nbvalues ; $i++)
//print "min=".$min." res=".$res; {
return $res; $vals[$k] = $this->data[$j][$i+1];
} $k++;
}
/** }
* Build a graph onto disk using correct library sort($vals);
* return $vals[0];
* @param string $file Image file name to use if we save onto disk }
* @param string $fileurl Url path to show image if saved onto disk
* @return void /**
*/ * Return max value of all data
function draw($file,$fileurl='') *
{ * @return int Max value of all data
if (! is_array($this->data) || count($this->data) < 1) */
{ function GetCeilMaxValue()
$this->error="Call to draw method was made but SetData was not called or called with an empty dataset for parameters"; {
dol_syslog(get_class($this)."::draw ".$this->error, LOG_ERR); $max = $this->GetMaxValueInData();
return -1; if ($max != 0) $max++;
} $size=dol_strlen(abs(ceil($max)));
$call = "draw_".$this->library; $factor=1;
$this->$call($file,$fileurl); for ($i=0; $i < ($size-1); $i++)
} {
$factor*=10;
}
/**
* Build a graph onto disk using Artichow library $res=0;
* if (is_numeric($max)) $res=ceil($max/$factor)*$factor;
* @param string $file Image file name to use if we save onto disk
* @param string $fileurl Url path to show image if saved onto disk //print "max=".$max." res=".$res;
* @return void return $res;
*/ }
private function draw_artichow($file,$fileurl)
{ /**
global $artichow_defaultfont; * Return min value of all data
*
dol_syslog(get_class($this)."::draw_artichow this->type=".$this->type); * @return int Max value of all data
*/
if (! defined('SHADOW_RIGHT_TOP')) define('SHADOW_RIGHT_TOP',3); function GetFloorMinValue()
if (! defined('LEGEND_BACKGROUND')) define('LEGEND_BACKGROUND',2); {
if (! defined('LEGEND_LINE')) define('LEGEND_LINE',1); $min = $this->GetMinValueInData();
if ($min != 0) $min--;
// Create graph $size=dol_strlen(abs(floor($min)));
$classname=''; $factor=1;
if ($this->type == 'bars') $classname='BarPlot'; for ($i=0; $i < ($size-1); $i++)
if ($this->type == 'lines') $classname='LinePlot'; {
include_once(ARTICHOW_PATH.$classname.".class.php"); $factor*=10;
}
// Definition de couleurs
$bgcolor=new Color($this->bgcolor[0],$this->bgcolor[1],$this->bgcolor[2]); $res=floor($min/$factor)*$factor;
$bgcolorgrid=new Color($this->bgcolorgrid[0],$this->bgcolorgrid[1],$this->bgcolorgrid[2]);
$colortrans=new Color(0,0,0,100); //print "min=".$min." res=".$res;
$colorsemitrans=new Color(255,255,255,60); return $res;
$colorgradient= new LinearGradient(new Color(235, 235, 235),new Color(255, 255, 255),0); }
$colorwhite=new Color(255,255,255);
/**
// Graph * Build a graph onto disk using correct library
$graph = new Graph($this->width, $this->height); *
$graph->border->hide(); * @param string $file Image file name to use if we save onto disk
$graph->setAntiAliasing(true); * @param string $fileurl Url path to show image if saved onto disk
if (isset($this->title)) * @return void
{ */
$graph->title->set($this->title); function draw($file,$fileurl='')
//print $artichow_defaultfont;exit; {
$graph->title->setFont(new $artichow_defaultfont(10)); if (! is_array($this->data) || count($this->data) < 1)
} {
$this->error="Call to draw method was made but SetData was not called or called with an empty dataset for parameters";
if (is_array($this->bgcolor)) $graph->setBackgroundColor($bgcolor); dol_syslog(get_class($this)."::draw ".$this->error, LOG_ERR);
else $graph->setBackgroundGradient($colorgradient); return -1;
}
$group = new PlotGroup; $call = "draw_".$this->library;
//$group->setSpace(5, 5, 0, 0); $this->$call($file,$fileurl);
}
$paddleft=50;
$paddright=10;
$strl=dol_strlen(max(abs($this->MaxValue),abs($this->MinValue))); /**
if ($strl > 6) $paddleft += ($strl * 4); * Build a graph onto disk using Artichow library
$group->setPadding($paddleft, $paddright); // Width on left and right for Y axis values *
$group->legend->setSpace(0); * @param string $file Image file name to use if we save onto disk
$group->legend->setPadding(2,2,2,2); * @param string $fileurl Url path to show image if saved onto disk
$group->legend->setPosition(NULL,0.1); * @return void
$group->legend->setBackgroundColor($colorsemitrans); */
private function draw_artichow($file,$fileurl)
if (is_array($this->bgcolorgrid)) $group->grid->setBackgroundColor($bgcolorgrid); {
else $group->grid->setBackgroundColor($colortrans); global $artichow_defaultfont;
if ($this->hideXGrid) $group->grid->hideVertical(true); dol_syslog(get_class($this)."::draw_artichow this->type=".$this->type);
if ($this->hideYGrid) $group->grid->hideHorizontal(true);
if (! defined('SHADOW_RIGHT_TOP')) define('SHADOW_RIGHT_TOP',3);
// On boucle sur chaque lot de donnees if (! defined('LEGEND_BACKGROUND')) define('LEGEND_BACKGROUND',2);
$legends=array(); if (! defined('LEGEND_LINE')) define('LEGEND_LINE',1);
$i=0;
$nblot=count($this->data[0])-1; // Create graph
$classname='';
while ($i < $nblot) if ($this->type == 'bars') $classname='BarPlot';
{ if ($this->type == 'lines') $classname='LinePlot';
$j=0; include_once(ARTICHOW_PATH.$classname.".class.php");
$values=array();
foreach($this->data as $key => $valarray) // Definition de couleurs
{ $bgcolor=new Color($this->bgcolor[0],$this->bgcolor[1],$this->bgcolor[2]);
$legends[$j] = $valarray[0]; $bgcolorgrid=new Color($this->bgcolorgrid[0],$this->bgcolorgrid[1],$this->bgcolorgrid[2]);
$values[$j] = $valarray[$i+1]; $colortrans=new Color(0,0,0,100);
$j++; $colorsemitrans=new Color(255,255,255,60);
} $colorgradient= new LinearGradient(new Color(235, 235, 235),new Color(255, 255, 255),0);
$colorwhite=new Color(255,255,255);
// Artichow ne gere pas les valeurs inconnues
// Donc si inconnu, on la fixe a null // Graph
$newvalues=array(); $graph = new Graph($this->width, $this->height);
foreach($values as $val) $graph->border->hide();
{ $graph->setAntiAliasing(true);
$newvalues[]=(is_numeric($val) ? $val : null); if (isset($this->title))
} {
$graph->title->set($this->title);
//print $artichow_defaultfont;exit;
if ($this->type == 'bars') $graph->title->setFont(new $artichow_defaultfont(10));
{ }
//print "Lot de donnees $i<br>";
//print_r($values); if (is_array($this->bgcolor)) $graph->setBackgroundColor($bgcolor);
//print '<br>'; else $graph->setBackgroundGradient($colorgradient);
$color=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2],20); $group = new PlotGroup;
$colorbis=new Color(min($this->datacolor[$i][0]+50,255),min($this->datacolor[$i][1]+50,255),min($this->datacolor[$i][2]+50,255),50); //$group->setSpace(5, 5, 0, 0);
$colorgrey=new Color(100,100,100); $paddleft=50;
$colorborder=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2]); $paddright=10;
$strl=dol_strlen(max(abs($this->MaxValue),abs($this->MinValue)));
if ($this->mode == 'side') $plot = new BarPlot($newvalues, $i+1, $nblot); if ($strl > 6) $paddleft += ($strl * 4);
if ($this->mode == 'depth') $plot = new BarPlot($newvalues, 1, 1, ($nblot-$i-1)*5); $group->setPadding($paddleft, $paddright); // Width on left and right for Y axis values
$group->legend->setSpace(0);
$plot->barBorder->setColor($colorgrey); $group->legend->setPadding(2,2,2,2);
//$plot->setBarColor($color); $group->legend->setPosition(NULL,0.1);
$plot->setBarGradient(new LinearGradient($colorbis, $color, 90)); $group->legend->setBackgroundColor($colorsemitrans);
if ($this->mode == 'side') $plot->setBarPadding(0.1, 0.1); if (is_array($this->bgcolorgrid)) $group->grid->setBackgroundColor($bgcolorgrid);
if ($this->mode == 'depth') $plot->setBarPadding(0.1, 0.4); else $group->grid->setBackgroundColor($colortrans);
if ($this->mode == 'side') $plot->setBarSpace(5);
if ($this->mode == 'depth') $plot->setBarSpace(2); if ($this->hideXGrid) $group->grid->hideVertical(true);
if ($this->hideYGrid) $group->grid->hideHorizontal(true);
$plot->barShadow->setSize($this->SetShading);
$plot->barShadow->setPosition(SHADOW_RIGHT_TOP); // On boucle sur chaque lot de donnees
$plot->barShadow->setColor(new Color(160, 160, 160, 50)); $legends=array();
$plot->barShadow->smooth(TRUE); $i=0;
//$plot->setSize(1, 0.96); $nblot=count($this->data[0])-1;
//$plot->setCenter(0.5, 0.52);
while ($i < $nblot)
// Le mode automatique est plus efficace {
$plot->SetYMax($this->MaxValue); $j=0;
$plot->SetYMin($this->MinValue); $values=array();
} foreach($this->data as $key => $valarray)
{
if ($this->type == 'lines') $legends[$j] = $valarray[0];
{ $values[$j] = $valarray[$i+1];
$color=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2],20); $j++;
$colorbis=new Color(min($this->datacolor[$i][0]+20,255),min($this->datacolor[$i][1]+20,255),min($this->datacolor[$i][2]+20,255),60); }
$colorter=new Color(min($this->datacolor[$i][0]+50,255),min($this->datacolor[$i][1]+50,255),min($this->datacolor[$i][2]+50,255),90);
// Artichow ne gere pas les valeurs inconnues
$plot = new LinePlot($newvalues); // Donc si inconnu, on la fixe a null
//$plot->setSize(1, 0.96); $newvalues=array();
//$plot->setCenter(0.5, 0.52); foreach($values as $val)
{
$plot->setColor($color); $newvalues[]=(is_numeric($val) ? $val : null);
$plot->setThickness(1); }
// Set line background gradient
$plot->setFillGradient(new LinearGradient($colorter, $colorbis, 90)); if ($this->type == 'bars')
{
$plot->xAxis->setLabelText($legends); //print "Lot de donnees $i<br>";
//print_r($values);
// Le mode automatique est plus efficace //print '<br>';
$plot->SetYMax($this->MaxValue);
$plot->SetYMin($this->MinValue); $color=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2],20);
//$plot->setYAxis(0); $colorbis=new Color(min($this->datacolor[$i][0]+50,255),min($this->datacolor[$i][1]+50,255),min($this->datacolor[$i][2]+50,255),50);
//$plot->hideLine(true);
} $colorgrey=new Color(100,100,100);
$colorborder=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2]);
//$plot->reduce(80); // Evite temps d'affichage trop long et nombre de ticks absisce satures
if ($this->mode == 'side') $plot = new BarPlot($newvalues, $i+1, $nblot);
$group->legend->setTextFont(new $artichow_defaultfont(10)); // This is to force Artichow to use awFileFontDriver to if ($this->mode == 'depth') $plot = new BarPlot($newvalues, 1, 1, ($nblot-$i-1)*5);
// solve a bug in Artichow with UTF8
if (count($this->Legend)) $plot->barBorder->setColor($colorgrey);
{ //$plot->setBarColor($color);
if ($this->type == 'bars') $group->legend->add($plot, $this->Legend[$i], LEGEND_BACKGROUND); $plot->setBarGradient(new LinearGradient($colorbis, $color, 90));
if ($this->type == 'lines') $group->legend->add($plot, $this->Legend[$i], LEGEND_LINE);
} if ($this->mode == 'side') $plot->setBarPadding(0.1, 0.1);
$group->add($plot); if ($this->mode == 'depth') $plot->setBarPadding(0.1, 0.4);
if ($this->mode == 'side') $plot->setBarSpace(5);
$i++; if ($this->mode == 'depth') $plot->setBarSpace(2);
}
$plot->barShadow->setSize($this->SetShading);
$group->axis->bottom->setLabelText($legends); $plot->barShadow->setPosition(SHADOW_RIGHT_TOP);
$group->axis->bottom->label->setFont(new $artichow_defaultfont(7)); $plot->barShadow->setColor(new Color(160, 160, 160, 50));
$plot->barShadow->smooth(TRUE);
//print $group->axis->bottom->getLabelNumber(); //$plot->setSize(1, 0.96);
if ($this->labelInterval > 0) $group->axis->bottom->setLabelInterval($this->labelInterval); //$plot->setCenter(0.5, 0.52);
$graph->add($group); // Le mode automatique est plus efficace
$plot->SetYMax($this->MaxValue);
// Generate file $plot->SetYMin($this->MinValue);
$graph->draw($file); }
$this->stringtoshow='<img src="'.$fileurl.'" title="'.dol_escape_htmltag($this->title?$this->title:$this->YLabel).'" alt="'.dol_escape_htmltag($this->title?$this->title:$this->YLabel).'">'; if ($this->type == 'lines')
} {
$color=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2],20);
$colorbis=new Color(min($this->datacolor[$i][0]+20,255),min($this->datacolor[$i][1]+20,255),min($this->datacolor[$i][2]+20,255),60);
/** $colorter=new Color(min($this->datacolor[$i][0]+50,255),min($this->datacolor[$i][1]+50,255),min($this->datacolor[$i][2]+50,255),90);
* Output HTML string to show graph
* $plot = new LinePlot($newvalues);
* @return string HTML string to show graph //$plot->setSize(1, 0.96);
*/ //$plot->setCenter(0.5, 0.52);
function show()
{ $plot->setColor($color);
return $this->stringtoshow; $plot->setThickness(1);
}
// Set line background gradient
$plot->setFillGradient(new LinearGradient($colorter, $colorbis, 90));
$plot->xAxis->setLabelText($legends);
// Le mode automatique est plus efficace
$plot->SetYMax($this->MaxValue);
$plot->SetYMin($this->MinValue);
//$plot->setYAxis(0);
//$plot->hideLine(true);
}
//$plot->reduce(80); // Evite temps d'affichage trop long et nombre de ticks absisce satures
$group->legend->setTextFont(new $artichow_defaultfont(10)); // This is to force Artichow to use awFileFontDriver to
// solve a bug in Artichow with UTF8
if (count($this->Legend))
{
if ($this->type == 'bars') $group->legend->add($plot, $this->Legend[$i], LEGEND_BACKGROUND);
if ($this->type == 'lines') $group->legend->add($plot, $this->Legend[$i], LEGEND_LINE);
}
$group->add($plot);
$i++;
}
$group->axis->bottom->setLabelText($legends);
$group->axis->bottom->label->setFont(new $artichow_defaultfont(7));
//print $group->axis->bottom->getLabelNumber();
if ($this->labelInterval > 0) $group->axis->bottom->setLabelInterval($this->labelInterval);
$graph->add($group);
// Generate file
$graph->draw($file);
$this->_stringtoshow='<img src="'.$fileurl.'" title="'.dol_escape_htmltag($this->title?$this->title:$this->YLabel).'" alt="'.dol_escape_htmltag($this->title?$this->title:$this->YLabel).'">';
}
/**
* Output HTML string to show graph
*
* @return string HTML string to show graph
*/
function show()
{
return $this->_stringtoshow;
}
} }
?> ?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment