dolibarr  20.0.0-alpha
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...
 
 setBorderSkip ($borderskip)
 Set border skip. 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 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.

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.

◆ 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.

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

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ SetShading()

DolGraph::SetShading (   $s)

Set shading.

Parameters
string$sShading
Returns
void

Definition at line 460 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 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 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 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: