dolibarr  13.0.2
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | List of all members
DolGraph Class Reference

Class to build graphs. More...

Public Member Functions

 __construct ($library= 'auto')
 Constructor. More...
 
 SetHorizTickIncrement ($xi)
 Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2. More...
 
 SetNumXTicks ($xt)
 Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2. More...
 
 SetLabelInterval ($x)
 Set label interval to reduce number of labels. More...
 
 SetHideXGrid ($bool)
 Hide X grid. More...
 
 SetHideYGrid ($bool)
 Hide Y grid. More...
 
 SetYLabel ($label)
 Set y label. More...
 
 SetWidth ($w)
 Set width. More...
 
 SetTitle ($title)
 Set title. More...
 
 SetData ($data)
 Set data. More...
 
 SetDataColor ($datacolor)
 Set data. More...
 
 SetType ($type)
 Set type. More...
 
 SetLegend ($legend)
 Set legend. More...
 
 SetLegendWidthMin ($legendwidthmin)
 Set min width. More...
 
 SetMaxValue ($max)
 Set max value. More...
 
 GetMaxValue ()
 Get max value. More...
 
 SetMinValue ($min)
 Set min value. More...
 
 GetMinValue ()
 Get min value. More...
 
 SetHeight ($h)
 Set height. More...
 
 SetShading ($s)
 Set shading. More...
 
 SetCssPrefix ($s)
 Set shading. More...
 
 ResetBgColor ()
 Reset bg color. More...
 
 ResetBgColorGrid ()
 Reset bgcolorgrid. More...
 
 isGraphKo ()
 Is graph ko. More...
 
 setShowLegend ($showlegend)
 Show legend or not. More...
 
 setShowPointValue ($showpointvalue)
 Show pointvalue or not. More...
 
 setShowPercent ($showpercent)
 Show percent or not. More...
 
 SetBgColor ($bg_color=array(255, 255, 255))
 Define background color of complete image. More...
 
 SetBgColorGrid ($bg_colorgrid=array(255, 255, 255))
 Define background color of grid. More...
 
 ResetDataColor ()
 Reset data color. More...
 
 GetMaxValueInData ()
 Get max value. More...
 
 GetMinValueInData ()
 Return min value of all data. More...
 
 GetCeilMaxValue ()
 Return max value of all data. More...
 
 GetFloorMinValue ()
 Return min value of all data. More...
 
 draw ($file, $fileurl= '')
 Build a graph into memory using correct library (may also be wrote on disk, depending on library used) More...
 
 total ()
 Output HTML string to total value. More...
 
 show ($shownographyet=0)
 Output HTML string to show graph. More...
 

Static Public Member Functions

static getDefaultGraphSizeForStats ($direction, $defaultsize= '')
 getDefaultGraphSizeForStats More...
 

Public Attributes

 $data
 Array of data.
 

Private Member Functions

 draw_jflot ($file, $fileurl)
 Build a graph using JFlot library. More...
 
 draw_chart ($file, $fileurl)
 Build a graph using Chart library. More...
 

Detailed Description

Class to build graphs.

Usage is: $dolgraph=new DolGraph(); $dolgraph->SetTitle($langs->transnoentities('MyTitle').'
'.$langs->transnoentities('MyTitlePercent').''); $dolgraph->SetMaxValue(50); $dolgraph->SetData($data); $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); $dolgraph->SetType(array('pie')); $dolgraph->setHeight('200'); $dolgraph->draw('idofgraph'); print $dolgraph->show($total?0:1);

Definition at line 40 of file dolgraph.class.php.

Constructor & Destructor Documentation

DolGraph::__construct (   $library = 'auto')

Constructor.

Parameters
string$library'auto' (default)

Definition at line 97 of file dolgraph.class.php.

Member Function Documentation

DolGraph::draw (   $file,
  $fileurl = '' 
)

Build a graph into memory using correct library (may also be wrote on disk, depending on library used)

Parameters
string$fileImage file name to use to save onto disk (also used as javascript unique id)
string$fileurlUrl path to show image if saved onto disk
Returns
integer|null

Definition at line 625 of file dolgraph.class.php.

References dol_syslog().

DolGraph::draw_chart (   $file,
  $fileurl 
)
private

Build a graph using Chart library.

Input when calling this method should be: $this->data = array(array(0=>'labelxA',1=>yA), array('labelxB',yB)); $this->data = array(array(0=>'labelxA',1=>yA1,...,n=>yAn), array('labelxB',yB1,...yBn)); // or when there is n series to show for each x $this->data = array(array('label'=>'labelxA','data'=>yA), array('labelxB',yB)); // Syntax deprecated $this->legend= array("Val1",...,"Valn"); // list of n series name $this->type = array('bars',...'lines', 'linesnopoint'); or array('pie') or array('polar') or array('piesemicircle'); $this->mode = 'depth' ??? $this->bgcolorgrid $this->datacolor $this->shownodatagraph

Parameters
string$fileImage file name to use to save onto disk (also used as javascript unique id)
string$fileurlUrl path to show image if saved onto disk. Never used here.
Returns
void

Definition at line 921 of file dolgraph.class.php.

References dol_escape_htmltag(), dol_escape_js(), dol_string_nohtmltag(), dol_string_nospecial(), dol_string_unaccent(), dol_syslog(), print, and type.

DolGraph::draw_jflot (   $file,
  $fileurl 
)
private

Build a graph using JFlot library.

Input when calling this method should be: $this->data = array(array(0=>'labelxA',1=>yA), array('labelxB',yB)); $this->data = array(array(0=>'labelxA',1=>yA1,...,n=>yAn), array('labelxB',yB1,...yBn)); // or when there is n series to show for each x $this->data = array(array('label'=>'labelxA','data'=>yA), array('labelxB',yB)); // Syntax deprecated $this->legend= array("Val1",...,"Valn"); // list of n series name $this->type = array('bars',...'lines','linesnopoint'); or array('pie') or array('polar') $this->mode = 'depth' ??? $this->bgcolorgrid $this->datacolor $this->shownodatagraph

Parameters
string$fileImage file name to use to save onto disk (also used as javascript unique id)
string$fileurlUrl path to show image if saved onto disk. Never used here.
Returns
void

Definition at line 662 of file dolgraph.class.php.

References $data, dol_escape_htmltag(), dol_escape_js(), dol_string_nospecial(), dol_string_unaccent(), dol_syslog(), print, and type.

DolGraph::GetCeilMaxValue ( )

Return max value of all data.

Returns
int Max value of all data

Definition at line 576 of file dolgraph.class.php.

References dol_strlen(), and GetMaxValueInData().

static DolGraph::getDefaultGraphSizeForStats (   $direction,
  $defaultsize = '' 
)
static

getDefaultGraphSizeForStats

Parameters
string$direction'width' or 'height'
string$defaultsizeValue we want as default size
Returns
int Value of width or height to use by default

Definition at line 1360 of file dolgraph.class.php.

DolGraph::GetFloorMinValue ( )

Return min value of all data.

Returns
double Max value of all data

Definition at line 600 of file dolgraph.class.php.

References dol_strlen(), and GetMinValueInData().

DolGraph::GetMaxValue ( )

Get max value.

Returns
int Max value

Definition at line 317 of file dolgraph.class.php.

DolGraph::GetMaxValueInData ( )

Get max value.

Returns
int Max value

Definition at line 522 of file dolgraph.class.php.

Referenced by GetCeilMaxValue().

DolGraph::GetMinValue ( )

Get min value.

Returns
int Max value

Definition at line 342 of file dolgraph.class.php.

DolGraph::GetMinValueInData ( )

Return min value of all data.

Returns
int Min value of all data

Definition at line 549 of file dolgraph.class.php.

Referenced by GetFloorMinValue().

DolGraph::isGraphKo ( )

Is graph ko.

Returns
string Error

Definition at line 416 of file dolgraph.class.php.

DolGraph::ResetBgColor ( )

Reset bg color.

Returns
void

Definition at line 393 of file dolgraph.class.php.

DolGraph::ResetBgColorGrid ( )

Reset bgcolorgrid.

Returns
void

Definition at line 405 of file dolgraph.class.php.

DolGraph::ResetDataColor ( )

Reset data color.

Returns
void

Definition at line 510 of file dolgraph.class.php.

DolGraph::SetBgColor (   $bg_color = array(255, 255, 255))

Define background color of complete image.

Parameters
array$bg_colorarray(R,G,B) ou 'onglet' ou 'default'
Returns
void

Definition at line 463 of file dolgraph.class.php.

DolGraph::SetBgColorGrid (   $bg_colorgrid = array(255, 255, 255))

Define background color of grid.

Parameters
array$bg_colorgridarray(R,G,B) ou 'onglet' ou 'default'
Returns
void

Definition at line 487 of file dolgraph.class.php.

DolGraph::SetCssPrefix (   $s)

Set shading.

Parameters
string$sShading
Returns
void

Definition at line 381 of file dolgraph.class.php.

DolGraph::SetData (   $data)

Set data.

Parameters
array$dataData
Returns
void
See Also
draw_jflot() for syntax of data array

Definition at line 239 of file dolgraph.class.php.

References $data.

DolGraph::SetDataColor (   $datacolor)

Set data.

Parameters
array$datacolorData color array(array(R,G,B),array(R,G,B)...)
Returns
void

Definition at line 252 of file dolgraph.class.php.

DolGraph::SetHeight (   $h)

Set height.

Parameters
int$hHeight
Returns
void

Definition at line 355 of file dolgraph.class.php.

DolGraph::SetHideXGrid (   $bool)

Hide X grid.

Parameters
boolean$boolXGrid or not
Returns
boolean true

Definition at line 171 of file dolgraph.class.php.

DolGraph::SetHideYGrid (   $bool)

Hide Y grid.

Parameters
boolean$boolYGrid or not
Returns
boolean true

Definition at line 185 of file dolgraph.class.php.

DolGraph::SetHorizTickIncrement (   $xi)

Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2.

Parameters
float$xiXi
Returns
boolean True

Definition at line 129 of file dolgraph.class.php.

DolGraph::SetLabelInterval (   $x)

Set label interval to reduce number of labels.

Parameters
float$xLabel interval
Returns
boolean True

Definition at line 157 of file dolgraph.class.php.

DolGraph::SetLegend (   $legend)

Set legend.

Parameters
array$legendLegend. Example: array('seriename1','seriname2',...)
Returns
void

Definition at line 279 of file dolgraph.class.php.

DolGraph::SetLegendWidthMin (   $legendwidthmin)

Set min width.

Parameters
int$legendwidthminMin width
Returns
void

Definition at line 292 of file dolgraph.class.php.

DolGraph::SetMaxValue (   $max)

Set max value.

Parameters
int$maxMax value
Returns
void

Definition at line 305 of file dolgraph.class.php.

DolGraph::SetMinValue (   $min)

Set min value.

Parameters
int$minMin value
Returns
void

Definition at line 330 of file dolgraph.class.php.

DolGraph::SetNumXTicks (   $xt)

Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2.

Parameters
float$xtXt
Returns
boolean True

Definition at line 143 of file dolgraph.class.php.

DolGraph::SetShading (   $s)

Set shading.

Parameters
string$sShading
Returns
void

Definition at line 368 of file dolgraph.class.php.

DolGraph::setShowLegend (   $showlegend)

Show legend or not.

Parameters
int$showlegend1=Show legend (default), 0=Hide legend, 2=Show legend on right
Returns
void

Definition at line 427 of file dolgraph.class.php.

DolGraph::setShowPercent (   $showpercent)

Show percent or not.

Parameters
int$showpercent1=Show percent for each point, as tooltip or inline, 0=Hide percent (default)
Returns
void

Definition at line 449 of file dolgraph.class.php.

DolGraph::setShowPointValue (   $showpointvalue)

Show pointvalue or not.

Parameters
int$showpointvalue1=Show value for each point, as tooltip or inline (default), 0=Hide value
Returns
void

Definition at line 438 of file dolgraph.class.php.

DolGraph::SetTitle (   $title)

Set title.

Parameters
string$titleTitle
Returns
void

Definition at line 225 of file dolgraph.class.php.

DolGraph::SetType (   $type)

Set type.

Parameters
array$typeArray with type for each serie. Example: array('type1', 'type2', ...) where type can be: 'pie', 'piesemicircle', 'polar', 'lines', 'linesnopoint', 'bars', 'horizontalbars'...
Returns
void

Definition at line 266 of file dolgraph.class.php.

References type.

DolGraph::SetWidth (   $w)

Set width.

Parameters
int | string$wWidth (Example: 320 or '100')
Returns
boolean|null True

Definition at line 212 of file dolgraph.class.php.

DolGraph::SetYLabel (   $label)

Set y label.

Parameters
string$labelY label
Returns
boolean|null True

Definition at line 199 of file dolgraph.class.php.

DolGraph::show (   $shownographyet = 0)

Output HTML string to show graph.

Parameters
int | string$shownographyetShow graph to say there is not enough data or the message in $shownographyet if it is a string.
Returns
string HTML string to show graph

Definition at line 1333 of file dolgraph.class.php.

DolGraph::total ( )

Output HTML string to total value.

Returns
string HTML string to total value

Definition at line 1317 of file dolgraph.class.php.


The documentation for this class was generated from the following file: