class DolGraph (View source)

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);

Properties

string[] $type
string $mode
array<array<string|int|float>> $data
string $title
string $cssprefix
int|string $width
int|string $height
int $MaxValue
int $MinValue
int $SetShading
float $horizTickIncrement
float $SetNumXTicks
float $labelInterval
string $YLabel
bool $hideXGrid
bool $hideXValues
bool $hideYValues
bool $hideYGrid
string[] $Legend
float $LegendWidthMin
int<0, 1> $showlegend
int<0, 1> $showpointvalue
int<0, 1> $showpercent
float $combine
object $graph
bool $mirrorGraphValues
null|string[] $tooltipsTitles
null|string[] $tooltipsLabels
string $error
array<int<0, 2>, int>|array<int<0, 2>, array<int<0, 2>, int>> $bordercolor
?array<int<0, 2>, int> $bgcolor
?array<int<0, 2>, int> $bgcolorgrid
array<int<0, 2>, array<int<0, 2>, int>> $datacolor
float $borderwidth
string $borderskip

Methods

__construct(string $library = 'auto')

Constructor

bool
SetHorizTickIncrement(float $xi)

Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2

bool
SetNumXTicks(float $xt)

Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2

bool
SetLabelInterval(float $x)

Set label interval to reduce number of labels

bool
SetHideXGrid(bool $bool)

Hide X grid

bool
setHideXValues(bool $bool)

Hide X Values

bool
setHideYValues(bool $bool)

Hide Y Values

bool
SetHideYGrid(bool $bool)

Hide Y grid

void
SetYLabel(string $label)

Set y label

void
SetWidth(int|string $w)

Set width

void
SetTitle(string $title)

Set title

void
SetData(array<array{0: string|int, 1: float, 2?: float}> $data)

Set data

void
SetDataColor(array<int<0, 2>, array<int<0, 2>, int>|string> $datacolor)

Set data color

void
setBorderColor(array<int<0, 2>, array<int<0, 2>, int>|string> $bordercolor)

Set border color

void
setBorderWidth(int $borderwidth)

Set border width

void
setBorderSkip("start"|"end"|"middle"|"false"|"true" $borderskip)

Set border skip

void
setTooltipsLabels(string[] $tooltipsLabels)

Set tooltips labels of the graph

void
setTooltipsTitles(string[] $tooltipsTitles)

Set tooltips titles of the graph

void
SetType(string[] $type)

Set type

void
SetLegend(string[] $legend)

Set legend

void
SetLegendWidthMin(int $legendwidthmin)

Set min width

void
SetMaxValue(int $max)

Set max value

int
GetMaxValue()

Get max value

void
SetMinValue(int $min)

Set min value

int
GetMinValue()

Get min value

void
SetHeight(int|string $h)

Set height

void
SetShading(int $s)

Set shading

void
SetCssPrefix(string $s)

Set shading

void
ResetBgColor()

Reset bg color

void
ResetBgColorGrid()

Reset bgcolorgrid

void
setMirrorGraphValues(bool $mirrorGraphValues)

Mirror Values of the graph

string
isGraphKo()

Is graph ko

void
setShowLegend(int $showlegend)

Show legend or not

void
setShowPointValue(int $showpointvalue)

Show pointvalue or not

void
setShowPercent(int $showpercent)

Show percent or not

void
SetBgColor(array{0: int, 1: int, 2: int}|"onglet"|"default" $bg_color = array(255, 255, 255))

Define background color of complete image

void
SetBgColorGrid("onglet"|"default"|array<int<0, 2>, int> $bg_colorgrid = array(255, 255, 255))

Define background color of grid

void
ResetDataColor()

Reset data color

?float
GetMaxValueInData()

Get max value among all values of all series

?float
GetMinValueInData()

Return min value of all values of all series

int
GetCeilMaxValue()

Return max value of all data

float
GetFloorMinValue()

Return min value of all data

mixed|bool
draw(string $file, string $fileurl = '')

Build a graph into memory using correct library (may also be wrote on disk, depending on library used)

float|int
total()

Output HTML string to total value

string
show(int|string $shownographyet = 0)

Output HTML string ->stringtoshow to show the graph

static int
getDefaultGraphSizeForStats(string $direction, string $defaultsize = '')

getDefaultGraphSizeForStats

Details

__construct(string $library = 'auto')

Constructor

Parameters

string $library

'auto' (default)

bool SetHorizTickIncrement(float $xi)

Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2

Parameters

float $xi Xi

Return Value

bool True

bool SetNumXTicks(float $xt)

Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2

Parameters

float $xt Xt

Return Value

bool True

bool SetLabelInterval(float $x)

Set label interval to reduce number of labels

Parameters

float $x

Label interval

Return Value

bool True

bool SetHideXGrid(bool $bool)

Hide X grid

Parameters

bool $bool

XGrid or not

Return Value

bool true

bool setHideXValues(bool $bool)

Hide X Values

Parameters

bool $bool

XValues or not

Return Value

bool true

bool setHideYValues(bool $bool)

Hide Y Values

Parameters

bool $bool

YValues or not

Return Value

bool true

bool SetHideYGrid(bool $bool)

Hide Y grid

Parameters

bool $bool

YGrid or not

Return Value

bool true

void SetYLabel(string $label)

Set y label

Parameters

string $label

Y label

Return Value

void

void SetWidth(int|string $w)

Set width

Parameters

int|string $w

Width (Example: 320 or '100%' or '10px')

Return Value

void

void SetTitle(string $title)

Set title

Parameters

string $title Title

Return Value

void

void SetData(array<array{0: string|int, 1: float, 2?: float}> $data)

Set data

Parameters

array<array{0: string|int, 1: float, 2?: float}> $data Data

Return Value

void

See also

draw_jflot() for syntax of data array

void SetDataColor(array<int<0, 2>, array<int<0, 2>, int>|string> $datacolor)

Set data color

Parameters

array<int<0, 2>, array<int<0, 2>, int>|string> $datacolor

Data color array(array(R,G,B),array(R,G,B)...) or array('#......','#......'...)

Return Value

void

void setBorderColor(array<int<0, 2>, array<int<0, 2>, int>|string> $bordercolor)

Set border color

Parameters

array<int<0, 2>, array<int<0, 2>, int>|string> $bordercolor

Color array(array(R,G,B),array(R,G,B)...) or array('#FFFFFF','#......'...)

Return Value

void

void setBorderWidth(int $borderwidth)

Set border width

Parameters

int $borderwidth

Border Width

Return Value

void

void setBorderSkip("start"|"end"|"middle"|"false"|"true" $borderskip)

Set border skip

Parameters

"start"|"end"|"middle"|"false"|"true" $borderskip

Can 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

Return Value

void

void setTooltipsLabels(string[] $tooltipsLabels)

Set tooltips labels of the graph

Parameters

string[] $tooltipsLabels

Tooltips Labels array('...','...'...)

Return Value

void

void setTooltipsTitles(string[] $tooltipsTitles)

Set tooltips titles of the graph

Parameters

string[] $tooltipsTitles

Tooltips Titles array('...','...'...)

Return Value

void

void SetType(string[] $type)

Set type

Parameters

string[] $type

Array with type for each series. Example: array('type1', 'type2', ...) where type can be: 'pie', 'piesemicircle', 'polar', 'lines', 'linesnopoint', 'bars', 'horizontalbars'...

Return Value

void

void SetLegend(string[] $legend)

Set legend

Parameters

string[] $legend

Legend. Example: array('seriename1','seriname2',...)

Return Value

void

void SetLegendWidthMin(int $legendwidthmin)

Set min width

Parameters

int $legendwidthmin

Min width

Return Value

void

void SetMaxValue(int $max)

Set max value

Parameters

int $max

Max value

Return Value

void

int GetMaxValue()

Get max value

Return Value

int

Max value

void SetMinValue(int $min)

Set min value

Parameters

int $min

Min value

Return Value

void

int GetMinValue()

Get min value

Return Value

int

Max value

void SetHeight(int|string $h)

Set height

Parameters

int|string $h

Height int or '90%' or '10px'

Return Value

void

void SetShading(int $s)

Set shading

Parameters

int $s Shading

Return Value

void

void SetCssPrefix(string $s)

Set shading

Parameters

string $s

Css prefix

Return Value

void

void ResetBgColor()

Reset bg color

Return Value

void

void ResetBgColorGrid()

Reset bgcolorgrid

Return Value

void

void setMirrorGraphValues(bool $mirrorGraphValues)

Mirror Values of the graph

Parameters

bool $mirrorGraphValues

Mirror Values if true and doesn't if false

Return Value

void

string isGraphKo()

Is graph ko

Return Value

string Error

void setShowLegend(int $showlegend)

Show legend or not

Parameters

int $showlegend

1=Show legend (default), 0=Hide legend, 2=Show legend on right

Return Value

void

void setShowPointValue(int $showpointvalue)

Show pointvalue or not

Parameters

int $showpointvalue

1=Show value for each point, as tooltip or inline (default), 0=Hide value, 2=Show values for each series on same point

Return Value

void

void setShowPercent(int $showpercent)

Show percent or not

Parameters

int $showpercent

1=Show percent for each point, as tooltip or inline, 0=Hide percent (default)

Return Value

void

void SetBgColor(array{0: int, 1: int, 2: int}|"onglet"|"default" $bg_color = array(255, 255, 255))

Define background color of complete image

Parameters

array{0: int, 1: int, 2: int}|"onglet"|"default" $bg_color

array(R,G,B) ou 'onglet' ou 'default'

Return Value

void

void SetBgColorGrid("onglet"|"default"|array<int<0, 2>, int> $bg_colorgrid = array(255, 255, 255))

Define background color of grid

Parameters

"onglet"|"default"|array<int<0, 2>, int> $bg_colorgrid

array(R,G,B) ou 'onglet' ou 'default'

Return Value

void

void ResetDataColor()

Reset data color

Return Value

void

?float GetMaxValueInData()

Get max value among all values of all series

Return Value

?float

Max value

?float GetMinValueInData()

Return min value of all values of all series

Return Value

?float

Min value of all data

int GetCeilMaxValue()

Return max value of all data

Return Value

int

Max value of all data

float GetFloorMinValue()

Return min value of all data

Return Value

float

Max value of all data

mixed|bool draw(string $file, string $fileurl = '')

Build a graph into memory using correct library (may also be wrote on disk, depending on library used)

Parameters

string $file

Image file name to use to save onto disk (also used as javascript unique id)

string $fileurl

Url path to show image if saved onto disk

Return Value

mixed|bool

float|int total()

Output HTML string to total value

Return Value

float|int

HTML string to total value

string show(int|string $shownographyet = 0)

Output HTML string ->stringtoshow to show the graph

Parameters

int|string $shownographyet

Show graph to say there is not enough data or the message in $shownographyet if it is a string.

Return Value

string

HTML string to show graph

static int getDefaultGraphSizeForStats(string $direction, string $defaultsize = '')

getDefaultGraphSizeForStats

Parameters

string $direction

'width' or 'height'

string $defaultsize

Value we want as default size

Return Value

int

Value of width or height to use by default