dolibarr  19.0.0-dev
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...
 
 setHideXValues ($bool)
 Hide X Values. 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 color. More...
 
 setBorderColor ($bordercolor)
 Set border color. More...
 
 setBorderWidth ($borderwidth)
 Set border width. More...
 
 setTooltipsLabels ($tooltipsLabels)
 Set tooltips labels of the graph. More...
 
 setTooltipsTitles ($tooltipsTitles)
 Set tooltips titles of the graph. 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...
 
 setMirrorGraphValues ($mirrorGraphValues)
 Mirror Values of the graph. 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 among all values of all series. More...
 
 GetMinValueInData ()
 Return min value of all values of all series. 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

◆ __construct()

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

Constructor.

Parameters
string$library'auto' (default)

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

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

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

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

◆ GetCeilMaxValue()

DolGraph::GetCeilMaxValue ( )

Return max value of all data.

Returns
int Max value of all data

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

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

◆ GetFloorMinValue()

DolGraph::GetFloorMinValue ( )

Return min value of all data.

Returns
double Max value of all data

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

◆ GetMaxValue()

DolGraph::GetMaxValue ( )

Get max value.

Returns
int Max value

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

◆ GetMaxValueInData()

DolGraph::GetMaxValueInData ( )

Get max value among all values of all series.

Returns
int Max value

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

◆ GetMinValue()

DolGraph::GetMinValue ( )

Get min value.

Returns
int Max value

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

◆ isGraphKo()

DolGraph::isGraphKo ( )

Is graph ko.

Returns
string Error

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

◆ ResetBgColor()

DolGraph::ResetBgColor ( )

Reset bg color.

Returns
void

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

◆ ResetBgColorGrid()

DolGraph::ResetBgColorGrid ( )

Reset bgcolorgrid.

Returns
void

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

◆ ResetDataColor()

DolGraph::ResetDataColor ( )

Reset data color.

Returns
void

Definition at line 599 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 552 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 576 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 298 of file dolgraph.class.php.

◆ setBorderWidth()

DolGraph::setBorderWidth (   $borderwidth)

Set border width.

Parameters
int$borderwidthBorder Width
Returns
void

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

◆ SetCssPrefix()

DolGraph::SetCssPrefix (   $s)

Set shading.

Parameters
string$sShading
Returns
void

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

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

◆ SetHeight()

DolGraph::SetHeight (   $h)

Set height.

Parameters
int$hHeight
Returns
void

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

◆ SetHideXGrid()

DolGraph::SetHideXGrid (   $bool)

Hide X grid.

Parameters
boolean$boolXGrid or not
Returns
boolean true

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

◆ setHideXValues()

DolGraph::setHideXValues (   $bool)

Hide X Values.

Parameters
boolean$boolXValues or not
Returns
boolean true

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

◆ SetHideYGrid()

DolGraph::SetHideYGrid (   $bool)

Hide Y grid.

Parameters
boolean$boolYGrid or not
Returns
boolean true

Definition at line 219 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 151 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 179 of file dolgraph.class.php.

◆ SetLegend()

DolGraph::SetLegend (   $legend)

Set legend.

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

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

◆ SetLegendWidthMin()

DolGraph::SetLegendWidthMin (   $legendwidthmin)

Set min width.

Parameters
int$legendwidthminMin width
Returns
void

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

◆ SetMaxValue()

DolGraph::SetMaxValue (   $max)

Set max value.

Parameters
int$maxMax value
Returns
void

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

◆ SetMinValue()

DolGraph::SetMinValue (   $min)

Set min value.

Parameters
int$minMin value
Returns
void

Definition at line 408 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 495 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 165 of file dolgraph.class.php.

◆ SetShading()

DolGraph::SetShading (   $s)

Set shading.

Parameters
string$sShading
Returns
void

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

◆ 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 516 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 538 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 527 of file dolgraph.class.php.

◆ SetTitle()

DolGraph::SetTitle (   $title)

Set title.

Parameters
string$titleTitle
Returns
void

Definition at line 259 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 320 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 331 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 344 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 246 of file dolgraph.class.php.

◆ SetYLabel()

DolGraph::SetYLabel (   $label)

Set y label.

Parameters
string$labelY label
Returns
void

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

◆ total()

DolGraph::total ( )

Output HTML string to total value.

Returns
string HTML string to total value

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


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