dolibarr 20.0.0
DolGraph Class Reference

Class to build graphs. More...

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

 $data
 Array of data.
 

Private Member Functions

 draw_jflot ($file, $fileurl)
 Build a graph into ->stringtoshow using the JFlot library.
 
 draw_chart ($file, $fileurl)
 Build a graph using Chart library.
 

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 41 of file dolgraph.class.php.

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
string$library'auto' (default)

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

References getDolGlobalString().

Member Function Documentation

◆ draw()

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
mixed|boolean

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

References dol_syslog().

◆ draw_chart()

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)); // 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 1067 of file dolgraph.class.php.

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

◆ draw_jflot()

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

Build a graph into ->stringtoshow using the 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)); // 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 780 of file dolgraph.class.php.

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

◆ GetCeilMaxValue()

DolGraph::GetCeilMaxValue ( )

Return max value of all data.

Returns
int Max value of all data

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

References dol_strlen(), and GetMaxValueInData().

◆ getDefaultGraphSizeForStats()

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 1584 of file dolgraph.class.php.

◆ GetFloorMinValue()

DolGraph::GetFloorMinValue ( )

Return min value of all data.

Returns
double Max value of all data

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

References dol_strlen(), and GetMinValueInData().

◆ GetMaxValue()

DolGraph::GetMaxValue ( )

Get max value.

Returns
int Max value

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

◆ GetMaxValueInData()

DolGraph::GetMaxValueInData ( )

Get max value among all values of all series.

Returns
int Max value

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

Referenced by GetCeilMaxValue().

◆ GetMinValue()

DolGraph::GetMinValue ( )

Get min value.

Returns
int Max value

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

◆ GetMinValueInData()

DolGraph::GetMinValueInData ( )

Return min value of all values of all series.

Returns
int Min value of all data

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

Referenced by GetFloorMinValue().

◆ isGraphKo()

DolGraph::isGraphKo ( )

Is graph ko.

Returns
string Error

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

◆ ResetBgColor()

DolGraph::ResetBgColor ( )

Reset bg color.

Returns
void

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

◆ ResetBgColorGrid()

DolGraph::ResetBgColorGrid ( )

Reset bgcolorgrid.

Returns
void

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

◆ ResetDataColor()

DolGraph::ResetDataColor ( )

Reset data color.

Returns
void

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

◆ SetBgColor()

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 566 of file dolgraph.class.php.

◆ SetBgColorGrid()

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 590 of file dolgraph.class.php.

◆ setBorderColor()

DolGraph::setBorderColor ( $bordercolor)

Set border color.

Parameters
array$bordercolorBorder Color array(array(R,G,B),array(R,G,B)...) or array('#FFFFFF','#......'...)
Returns
void

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

◆ setBorderSkip()

DolGraph::setBorderSkip ( $borderskip)

Set border skip.

Parameters
int$borderskipCan be 'start' to skip start border, 'end' to skip end border, 'middle' to skip middle border, 'false' to not skip any border, 'true' to skip all border
Returns
void

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

◆ setBorderWidth()

DolGraph::setBorderWidth ( $borderwidth)

Set border width.

Parameters
int$borderwidthBorder Width
Returns
void

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

◆ SetCssPrefix()

DolGraph::SetCssPrefix ( $s)

Set shading.

Parameters
string$sShading
Returns
void

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

◆ SetData()

DolGraph::SetData ( $data)

Set data.

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

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

References $data.

◆ SetDataColor()

DolGraph::SetDataColor ( $datacolor)

Set data color.

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

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

◆ SetHeight()

DolGraph::SetHeight ( $h)

Set height.

Parameters
int | string$hHeight int or '90' or '10px'
Returns
void

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

◆ SetHideXGrid()

DolGraph::SetHideXGrid ( $bool)

Hide X grid.

Parameters
boolean$boolXGrid or not
Returns
boolean true

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

◆ setHideXValues()

DolGraph::setHideXValues ( $bool)

Hide X Values.

Parameters
boolean$boolXValues or not
Returns
boolean true

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

◆ SetHideYGrid()

DolGraph::SetHideYGrid ( $bool)

Hide Y grid.

Parameters
boolean$boolYGrid or not
Returns
boolean true

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

◆ SetHorizTickIncrement()

DolGraph::SetHorizTickIncrement ( $xi)

Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2.

Parameters
float$xiXi
Returns
boolean True

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

◆ SetLabelInterval()

DolGraph::SetLabelInterval ( $x)

Set label interval to reduce number of labels.

Parameters
float$xLabel interval
Returns
boolean True

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

◆ SetLegend()

DolGraph::SetLegend ( $legend)

Set legend.

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

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

◆ SetLegendWidthMin()

DolGraph::SetLegendWidthMin ( $legendwidthmin)

Set min width.

Parameters
int$legendwidthminMin width
Returns
void

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

◆ SetMaxValue()

DolGraph::SetMaxValue ( $max)

Set max value.

Parameters
int$maxMax value
Returns
void

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

◆ SetMinValue()

DolGraph::SetMinValue ( $min)

Set min value.

Parameters
int$minMin value
Returns
void

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

◆ setMirrorGraphValues()

DolGraph::setMirrorGraphValues ( $mirrorGraphValues)

Mirror Values of the graph.

Parameters
boolean$mirrorGraphValuesMirror Values if true and doesn't if false
Returns
void

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

◆ SetNumXTicks()

DolGraph::SetNumXTicks ( $xt)

Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2.

Parameters
float$xtXt
Returns
boolean True

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

References SetNumXTicks().

Referenced by SetNumXTicks().

◆ SetShading()

DolGraph::SetShading ( $s)

Set shading.

Parameters
string$sShading
Returns
void

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

References SetShading().

Referenced by SetShading().

◆ setShowLegend()

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 530 of file dolgraph.class.php.

◆ setShowPercent()

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 552 of file dolgraph.class.php.

◆ setShowPointValue()

DolGraph::setShowPointValue ( $showpointvalue)

Show pointvalue or not.

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

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

◆ SetTitle()

DolGraph::SetTitle ( $title)

Set title.

Parameters
string$titleTitle
Returns
void

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

◆ setTooltipsLabels()

DolGraph::setTooltipsLabels ( $tooltipsLabels)

Set tooltips labels of the graph.

Parameters
array$tooltipsLabelsTooltips Labels array('...','...'...)
Returns
void

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

◆ setTooltipsTitles()

DolGraph::setTooltipsTitles ( $tooltipsTitles)

Set tooltips titles of the graph.

Parameters
array$tooltipsTitlesTooltips Titles array('...','...'...)
Returns
void

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

◆ SetType()

DolGraph::SetType ( $type)

Set type.

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

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

References type.

◆ SetWidth()

DolGraph::SetWidth ( $w)

Set width.

Parameters
int | string$wWidth (Example: 320 or '100' or '10px')
Returns
void

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

◆ SetYLabel()

DolGraph::SetYLabel ( $label)

Set y label.

Parameters
string$labelY label
Returns
void

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

◆ show()

DolGraph::show ( $shownographyet = 0)

Output HTML string ->stringtoshow to show the 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 1557 of file dolgraph.class.php.

◆ total()

DolGraph::total ( )

Output HTML string to total value.

Returns
float|int HTML string to total value

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


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