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

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

Constructor.

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

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

Member Function Documentation

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

References dol_syslog().

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

References dol_escape_htmltag(), dol_strlen(), dol_syslog(), SetShading(), and type.

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

References $data, dol_escape_htmltag(), dol_escape_js(), dol_print_error(), dol_string_nospecial(), dol_string_unaccent(), dol_syslog(), if, print, and type.

DolGraph::GetCeilMaxValue ( )

Return max value of all data.

Returns
int Max value of all data

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

References dol_strlen(), and GetMaxValueInData().

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

DolGraph::GetFloorMinValue ( )

Return min value of all data.

Returns
double Max value of all data

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

References dol_strlen(), and GetMinValueInData().

DolGraph::GetMaxValue ( )

Get max value.

Returns
int Max value

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

DolGraph::GetMaxValueInData ( )

Get max value.

Returns
int Max value

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

Referenced by GetCeilMaxValue().

DolGraph::GetMinValue ( )

Get min value.

Returns
int Max value

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

DolGraph::GetMinValueInData ( )

Return min value of all data.

Returns
int Min value of all data

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

Referenced by GetFloorMinValue().

DolGraph::isGraphKo ( )

Is graph ko.

Returns
string Error

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

DolGraph::ResetBgColor ( )

Reset bg color.

Returns
void

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

DolGraph::ResetBgColorGrid ( )

Reset bgcolorgrid.

Returns
void

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

DolGraph::ResetDataColor ( )

Reset data color.

Returns
void

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

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

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

DolGraph::SetCssPrefix (   $s)

Set shading.

Parameters
string$sShading
Returns
void

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

DolGraph::SetData (   $data)

Set data.

Parameters
array$dataData
Returns
void
See also
draw_jflot for syntax of data array

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

References $data.

DolGraph::SetDataColor (   $datacolor)

Set data.

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

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

DolGraph::SetHeight (   $h)

Set height.

Parameters
int$hHeight
Returns
void

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

DolGraph::SetHideXGrid (   $bool)

Hide X grid.

Parameters
boolean$boolXGrid or not
Returns
boolean true

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

DolGraph::SetHideYGrid (   $bool)

Hide Y grid.

Parameters
boolean$boolYGrid or not
Returns
boolean true

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

DolGraph::SetHorizTickIncrement (   $xi)

Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2.

Parameters
float$xiXi
Returns
boolean True

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

DolGraph::SetLabelInterval (   $x)

Set label interval to reduce number of labels.

Parameters
float$xLabel interval
Returns
boolean True

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

DolGraph::SetLegend (   $legend)

Set legend.

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

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

DolGraph::SetLegendWidthMin (   $legendwidthmin)

Set min width.

Parameters
int$legendwidthminMin width
Returns
void

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

DolGraph::SetMaxValue (   $max)

Set max value.

Parameters
int$maxMax value
Returns
void

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

DolGraph::SetMinValue (   $min)

Set min value.

Parameters
int$minMin value
Returns
void

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

DolGraph::SetNumXTicks (   $xt)

Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2.

Parameters
float$xtXt
Returns
boolean True

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

DolGraph::SetPrecisionY (   $which_prec)

Set Y precision.

Parameters
float$which_precPrecision
Returns
boolean

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

DolGraph::SetShading (   $s)

Set shading.

Parameters
string$sShading
Returns
void

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

Referenced by draw_artichow().

DolGraph::setShowLegend (   $showlegend)

Show legend or not.

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

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

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

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

DolGraph::SetTitle (   $title)

Set title.

Parameters
string$titleTitle
Returns
void

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

DolGraph::SetType (   $type)

Set type.

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

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

References type.

DolGraph::SetWidth (   $w)

Set width.

Parameters
int$wWidth
Returns
boolean|null True

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

DolGraph::SetYLabel (   $label)

Set y label.

Parameters
string$labelY label
Returns
boolean|null True

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

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


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