dolibarr 21.0.0-beta
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
 

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
string$library'auto' (default)

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

References $conf, and 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 839 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 1164 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 877 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 781 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 1691 of file dolgraph.class.php.

◆ GetFloorMinValue()

DolGraph::GetFloorMinValue ( )

Return min value of all data.

Returns
double Max value of all data

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

References dol_strlen(), and GetMinValueInData().

◆ GetMaxValue()

DolGraph::GetMaxValue ( )

Get max value.

Returns
int Max value

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

◆ GetMaxValueInData()

DolGraph::GetMaxValueInData ( )

Get max value among all values of all series.

Returns
?float Max value

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

Referenced by GetCeilMaxValue().

◆ GetMinValue()

DolGraph::GetMinValue ( )

Get min value.

Returns
int Max value

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

◆ GetMinValueInData()

DolGraph::GetMinValueInData ( )

Return min value of all values of all series.

Returns
?float Min value of all data

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

Referenced by GetFloorMinValue().

◆ isGraphKo()

DolGraph::isGraphKo ( )

Is graph ko.

Returns
string Error

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

◆ ResetBgColor()

DolGraph::ResetBgColor ( )

Reset bg color.

Returns
void

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

◆ ResetBgColorGrid()

DolGraph::ResetBgColorGrid ( )

Reset bgcolorgrid.

Returns
void

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

◆ ResetDataColor()

DolGraph::ResetDataColor ( )

Reset data color.

Returns
void

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

◆ SetBgColor()

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

Define background color of complete image.

Parameters
array{0:int,1:int,2:int}|'onglet'|'default'$bg_color array(R,G,B) ou 'onglet' ou 'default'
Returns
void

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

◆ SetBgColorGrid()

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

Define background color of grid.

Parameters
'onglet'|'default'|array<int<0,2>,int>$bg_colorgrid array(R,G,B) ou 'onglet' ou 'default'
Returns
void

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

◆ setBorderColor()

DolGraph::setBorderColor ( $bordercolor)

Set border color.

Parameters
array<int<0,2>,array<int<0,2>,int>|string>$bordercolor Color array(array(R,G,B),array(R,G,B)...) or array('#FFFFFF','#......'...)
Returns
void

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

◆ setBorderSkip()

DolGraph::setBorderSkip ( $borderskip)

Set border skip.

Parameters
'start'|'end'|'middle'|'false'|'true'$borderskip Can 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 419 of file dolgraph.class.php.

◆ setBorderWidth()

DolGraph::setBorderWidth ( $borderwidth)

Set border width.

Parameters
int$borderwidthBorder Width
Returns
void

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

◆ SetCssPrefix()

DolGraph::SetCssPrefix ( $s)

Set shading.

Parameters
string$sCss prefix
Returns
void

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

◆ SetData()

DolGraph::SetData ( $data)

Set data.

Parameters
array<array{0:string,1:float,2:float}>$data Data
Returns
void
See also
draw_jflot() for syntax of data array

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

◆ SetDataColor()

DolGraph::SetDataColor ( $datacolor)

Set data color.

Parameters
array<int<0,2>,array<int<0,2>,int>|string>$datacolor Data color array(array(R,G,B),array(R,G,B)...) or array('#......','#......'...)
Returns
void

Definition at line 384 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 543 of file dolgraph.class.php.

◆ SetHideXGrid()

DolGraph::SetHideXGrid ( $bool)

Hide X grid.

Parameters
boolean$boolXGrid or not
Returns
boolean true

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

◆ setHideXValues()

DolGraph::setHideXValues ( $bool)

Hide X Values.

Parameters
bool$boolXValues or not
Returns
bool true

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

◆ SetHideYGrid()

DolGraph::SetHideYGrid ( $bool)

Hide Y grid.

Parameters
boolean$boolYGrid or not
Returns
boolean true

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

◆ SetHorizTickIncrement()

DolGraph::SetHorizTickIncrement ( $xi)

Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2.

Parameters
float$xiXi
Returns
bool True

Definition at line 249 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 277 of file dolgraph.class.php.

◆ SetLegend()

DolGraph::SetLegend ( $legend)

Set legend.

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

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

◆ SetLegendWidthMin()

DolGraph::SetLegendWidthMin ( $legendwidthmin)

Set min width.

Parameters
int$legendwidthminMin width
Returns
void

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

◆ SetMaxValue()

DolGraph::SetMaxValue ( $max)

Set max value.

Parameters
int$maxMax value
Returns
void

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

◆ SetMinValue()

DolGraph::SetMinValue ( $min)

Set min value.

Parameters
int$minMin value
Returns
void

Definition at line 518 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 605 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 263 of file dolgraph.class.php.

References SetNumXTicks().

Referenced by SetNumXTicks().

◆ SetShading()

DolGraph::SetShading ( $s)

Set shading.

Parameters
int$sShading
Returns
void

Definition at line 556 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 626 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 648 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 637 of file dolgraph.class.php.

◆ SetTitle()

DolGraph::SetTitle ( $title)

Set title.

Parameters
string$titleTitle
Returns
void

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

◆ setTooltipsLabels()

DolGraph::setTooltipsLabels ( $tooltipsLabels)

Set tooltips labels of the graph.

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

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

◆ setTooltipsTitles()

DolGraph::setTooltipsTitles ( $tooltipsTitles)

Set tooltips titles of the graph.

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

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

◆ SetType()

DolGraph::SetType ( $type)

Set type.

Parameters
string[]$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 454 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 344 of file dolgraph.class.php.

◆ SetYLabel()

DolGraph::SetYLabel ( $label)

Set y label.

Parameters
string$labelY label
Returns
void

Definition at line 331 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 1664 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 1649 of file dolgraph.class.php.


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