dolibarr  9.0.0
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='jflot')
 Constructor. More...
 
 SetPrecisionY ($which_prec)
 Set Y precision. 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...
 
 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. 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...
 
 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. More...
 
 GetMinValueInData ()
 Return min value of all data. 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...
 
 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_artichow ($file, $fileurl)
 Build a graph onto disk using Artichow library and return img string to it. More...
 
 draw_jflot ($file, $fileurl)
 Build a graph using JFlot 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(1); $dolgraph->setShowPercent(1); $dolgraph->SetType(array('pie')); $dolgraph->setWidth('100'); $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 = 'jflot')

Constructor.

Parameters
string$library'jflot' (default) or 'artichow' (no more supported)

Definition at line 91 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
integer|null

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

◆ draw_artichow()

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

Build a graph onto disk using Artichow library and return img string to it.

Parameters
string$fileImage file name to use if we save onto disk
string$fileurlUrl path to show image if saved onto disk
Returns
void

Definition at line 693 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)); // or 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'); or array('pie') $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 883 of file dolgraph.class.php.

◆ GetCeilMaxValue()

DolGraph::GetCeilMaxValue ( )

Return max value of all data.

Returns
int Max value of all data

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

◆ GetFloorMinValue()

DolGraph::GetFloorMinValue ( )

Return min value of all data.

Returns
double Max value of all data

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

◆ GetMaxValue()

DolGraph::GetMaxValue ( )

Get max value.

Returns
int Max value

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

◆ GetMaxValueInData()

DolGraph::GetMaxValueInData ( )

Get max value.

Returns
int Max value

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

◆ GetMinValue()

DolGraph::GetMinValue ( )

Get min value.

Returns
int Max value

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

◆ GetMinValueInData()

DolGraph::GetMinValueInData ( )

Return min value of all data.

Returns
int Min value of all data

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

◆ isGraphKo()

DolGraph::isGraphKo ( )

Is graph ko.

Returns
string Error

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

◆ ResetBgColor()

DolGraph::ResetBgColor ( )

Reset bg color.

Returns
void

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

◆ ResetBgColorGrid()

DolGraph::ResetBgColorGrid ( )

Reset bgcolorgrid.

Returns
void

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

◆ ResetDataColor()

DolGraph::ResetDataColor ( )

Reset data color.

Returns
void

Definition at line 544 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 485 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 515 of file dolgraph.class.php.

◆ SetCssPrefix()

DolGraph::SetCssPrefix (   $s)

Set shading.

Parameters
string$sShading
Returns
void

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

References $data.

◆ SetDataColor()

DolGraph::SetDataColor (   $datacolor)

Set data.

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

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

◆ SetHeight()

DolGraph::SetHeight (   $h)

Set height.

Parameters
int$hHeight
Returns
void

Definition at line 377 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.

◆ SetHideYGrid()

DolGraph::SetHideYGrid (   $bool)

Hide Y grid.

Parameters
boolean$boolYGrid or not
Returns
boolean true

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

◆ SetLegendWidthMin()

DolGraph::SetLegendWidthMin (   $legendwidthmin)

Set min width.

Parameters
int$legendwidthminMin width
Returns
void

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

◆ SetMaxValue()

DolGraph::SetMaxValue (   $max)

Set max value.

Parameters
int$maxMax value
Returns
void

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

◆ SetMinValue()

DolGraph::SetMinValue (   $min)

Set min value.

Parameters
int$minMin value
Returns
void

Definition at line 352 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.

◆ SetPrecisionY()

DolGraph::SetPrecisionY (   $which_prec)

Set Y precision.

Parameters
float$which_precPrecision
Returns
boolean

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

◆ SetShading()

DolGraph::SetShading (   $s)

Set shading.

Parameters
string$sShading
Returns
void

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

◆ setShowLegend()

DolGraph::setShowLegend (   $showlegend)

Show legend or not.

Parameters
int$showlegend1=Show legend (default), 0=Hide legend
Returns
void

Definition at line 449 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 471 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
Returns
void

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

◆ SetTitle()

DolGraph::SetTitle (   $title)

Set title.

Parameters
string$titleTitle
Returns
void

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

◆ SetType()

DolGraph::SetType (   $type)

Set type.

Parameters
array$typeArray with type for each serie. Example: array('pie'), array('lines',...,'bars')
Returns
void

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

References type.

◆ SetWidth()

DolGraph::SetWidth (   $w)

Set width.

Parameters
int$wWidth
Returns
boolean|null True

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

◆ SetYLabel()

DolGraph::SetYLabel (   $label)

Set y label.

Parameters
string$labelY label
Returns
boolean|null True

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

◆ show()

DolGraph::show (   $shownographyet = 0)

Output HTML string to show graph.

Parameters
int$shownographyetShow graph to say there is not enough data
Returns
string HTML string to show graph

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


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