dolibarr 19.0.3
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 to show 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 using 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 40 of file dolgraph.class.php.

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
string$library'auto' (default)

Definition at line 107 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 741 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 1066 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 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)); // 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 779 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 684 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 1569 of file dolgraph.class.php.

◆ GetFloorMinValue()

DolGraph::GetFloorMinValue ( )

Return min value of all data.

Returns
double Max value of all data

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

References dol_strlen(), and GetMinValueInData().

◆ GetMaxValue()

DolGraph::GetMaxValue ( )

Get max value.

Returns
int Max value

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

◆ GetMaxValueInData()

DolGraph::GetMaxValueInData ( )

Get max value among all values of all series.

Returns
int Max value

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

Referenced by GetCeilMaxValue().

◆ GetMinValue()

DolGraph::GetMinValue ( )

Get min value.

Returns
int Max value

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

Referenced by GetFloorMinValue().

◆ isGraphKo()

DolGraph::isGraphKo ( )

Is graph ko.

Returns
string Error

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

◆ ResetBgColor()

DolGraph::ResetBgColor ( )

Reset bg color.

Returns
void

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

◆ ResetBgColorGrid()

DolGraph::ResetBgColorGrid ( )

Reset bgcolorgrid.

Returns
void

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

◆ ResetDataColor()

DolGraph::ResetDataColor ( )

Reset data color.

Returns
void

Definition at line 612 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 565 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 589 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 299 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 322 of file dolgraph.class.php.

◆ setBorderWidth()

DolGraph::setBorderWidth ( $borderwidth)

Set border width.

Parameters
int$borderwidthBorder Width
Returns
void

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

◆ SetCssPrefix()

DolGraph::SetCssPrefix ( $s)

Set shading.

Parameters
string$sShading
Returns
void

Definition at line 472 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 274 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 287 of file dolgraph.class.php.

◆ SetHeight()

DolGraph::SetHeight ( $h)

Set height.

Parameters
int$hHeight
Returns
void

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

◆ SetHideXGrid()

DolGraph::SetHideXGrid ( $bool)

Hide X grid.

Parameters
boolean$boolXGrid or not
Returns
boolean true

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

◆ setHideXValues()

DolGraph::setHideXValues ( $bool)

Hide X Values.

Parameters
boolean$boolXValues or not
Returns
boolean true

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

◆ SetHideYGrid()

DolGraph::SetHideYGrid ( $bool)

Hide Y grid.

Parameters
boolean$boolYGrid or not
Returns
boolean true

Definition at line 220 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 152 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 180 of file dolgraph.class.php.

◆ SetLegend()

DolGraph::SetLegend ( $legend)

Set legend.

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

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

◆ SetLegendWidthMin()

DolGraph::SetLegendWidthMin ( $legendwidthmin)

Set min width.

Parameters
int$legendwidthminMin width
Returns
void

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

◆ SetMaxValue()

DolGraph::SetMaxValue ( $max)

Set max value.

Parameters
int$maxMax value
Returns
void

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

◆ SetMinValue()

DolGraph::SetMinValue ( $min)

Set min value.

Parameters
int$minMin value
Returns
void

Definition at line 421 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 508 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 166 of file dolgraph.class.php.

References SetNumXTicks().

Referenced by SetNumXTicks().

◆ SetShading()

DolGraph::SetShading ( $s)

Set shading.

Parameters
string$sShading
Returns
void

Definition at line 459 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 529 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 551 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 serie on same point
Returns
void

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

◆ SetTitle()

DolGraph::SetTitle ( $title)

Set title.

Parameters
string$titleTitle
Returns
void

Definition at line 260 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 333 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 344 of file dolgraph.class.php.

◆ SetType()

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

References type.

◆ SetWidth()

DolGraph::SetWidth ( $w)

Set width.

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

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

◆ SetYLabel()

DolGraph::SetYLabel ( $label)

Set y label.

Parameters
string$labelY label
Returns
void

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

◆ show()

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

◆ total()

DolGraph::total ( )

Output HTML string to total value.

Returns
string HTML string to total value

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


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