ultimix
graph_1_0_0 Class Reference

Public Member Functions

 set ($Field, $Value)
 draw_y_labels ($Labels, $Color=0x000000)
 draw_x_labels ($DataX, $Color=0x000000, $Labels=false)
 get_total_client_width ($DataX)
 draw_graph ($DataY, $DataX, $Color=0xff0000)
 __construct ()
 draw_graph_data (&$Options)

Data Fields

 $Img = false
 $ClientWidth = 0
 $ClientHeight = 0
 $ClientX = 0
 $ClientY = 0
 $CoordX = 0
 $CoordY = 0
 $DrawGrid = true
 $StepsX = 8
 $StepsY = 6
 $MarginTop = 10
 $MarginBottom = 10
 $MarginLeft = 10
 $MarginRight = 10
 $GraphCore = false
 $GraphUtilities = false
 $Security = false

Detailed Description

Working with graphs.

Author
Dodonov A.A.

Definition at line 26 of file graph.php.

Constructor & Destructor Documentation

__construct ( )

Constructor.

Author
Dodonov A.A.

Definition at line 551 of file graph.php.

{
try
{
$this->GraphCore = get_package( 'graph::graph_core' , 'last' , __FILE__ );
$this->GraphUtilities = get_package( 'graph::graph_utilities' , 'last' , __FILE__ );
$this->Security = get_package( 'security' , 'last' , __FILE__ );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Member Function Documentation

draw_graph (   $DataY,
  $DataX,
  $Color = 0xff0000 
)

Function draws graph.

Parameters
$DataY- Data for the graph.
$DataX- Data for the graph.
$Color- Color of the graph.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 499 of file graph.php.

{
try
{
$Color = $this->GraphCore->get_color_from_hex( $this->Img , $Color );
list( $dX , $dY ) = $this->get_scales( $DataX , $DataY );
$OX = $this->ClientX + $this->CoordX - min( $DataX ) * $dX + $this->MarginLeft;
$OY = $this->Height - $this->ClientY - $this->CoordY + min( $DataY ) * $dY - $this->MarginBottom;
for( $i = 0 ; $i < count( $DataX ) - 1 ; $i++ )
{
$x1 = $OX + $DataX[ $i + 0 ] * $dX;
$x2 = $OX + $DataX[ $i + 1 ] * $dX;
$y1 = $OY - $DataY[ $i + 0 ] * $dY;
$y2 = $OY - $DataY[ $i + 1 ] * $dY;
$this->draw_graph_part( $x1 , $x2 , $y1 , $y2 , $Color );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
draw_graph_data ( $Options)

Component's view.

Parameters
$Options- Settings.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 618 of file graph.php.

{
try
{
$this->GraphUtilities->prepare_graph_area( $this );
list( $DataX , $DataY ) = $this->get_graph_data();
$Color = $this->Security->get_gp( 'color' , 'integer' , 0xff0000 );
$this->draw_graph( $DataY , $DataX , $Color );
$DataYLabels = $this->GraphCore->compile_labels_from_data( $DataY , $this->StepsY );
$this->draw_y_labels( $DataYLabels );
$DataXLabels = $this->Security->get_gp( 'data_x_labels' , 'string' , false );
$DataXLabels = $DataXLabels === false ? false : explode( ',' , $DataXLabels );
$this->draw_x_labels( $DataX , 0x000000 , $DataXLabels );
$this->GraphCore->output( $Options , $this->Img );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
draw_x_labels (   $DataX,
  $Color = 0x000000,
  $Labels = false 
)

Function draws labels.

Parameters
$DataX- Äàòà.
$Color- Labels color.
$Labels- Labels.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 288 of file graph.php.

{
try
{
$Color = $this->GraphCore->get_color_from_hex( $this->Img , $Color );
$Labels = $Labels === false ? $DataX : $Labels;
list( $dX , $dY ) = $this->get_scales( $DataX , false );
$Font = dirname( __FILE__ ).'/res/font/arial.ttf';
$Count = count( $DataX );
for( $i = 0 ; $i < $Count ; $i++ )
{
list( $Width , $Height ) = $this->GraphCore->string_width_height( $Font , 10 , $Labels[ $i ] );
$d = ( $DataX[ $i ] - min( $DataX ) ) * $dX;
list( $x , $y ) = $this->get_x_y( $d , $Width , $Height );
imagettftext( $this->Img , 10 , 0 , $x , $y , $Color , $Font , $Labels[ $i ] );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
draw_y_labels (   $Labels,
  $Color = 0x000000 
)

Function draws labels.

Parameters
$Labels- Labels.
$Color- Grid color.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 190 of file graph.php.

{
try
{
$Color = $this->GraphCore->get_color_from_hex( $this->Img , $Color );
list( $GlobalCenterY , $dy ) = $this->get_draw_y_labels_params();
$Font = dirname( __FILE__ ).'/res/font/arial.ttf';
$Size = 10;
for( $i = 0 ; $i <= $this->StepsY ; $i++ )
{
list( $Width , $Height ) = $this->GraphCore->string_width_height( $Font , $Size , $Labels[ $i ] );
imagettftext(
$this->Img , $Size , 0 , $this->ClientX - $Width - 10 ,
$GlobalCenterY - $dy * $i - $Height / 2 , $Color , $Font , $Labels[ $i ]
);
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_total_client_width (   $DataX)

Function calcuates client area's width.

Parameters
$DataX- Data for the graph.
Returns
Width of the client area.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 337 of file graph.php.

{
try
{
$c = count( $DataY );
if( $DataX === false )
{
$DataX = array();
for( $i = 0 ; $i < $c ; $i++ )
{
$DataX [] = $i;
}
$TotalClientWidth = $this->ClientWidth - $this->CoordX;
}
else
{
$TotalClientWidth = $this->ClientWidth;
}
return( $TotalClientWidth );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
set (   $Field,
  $Value 
)

Function sets field.

Author
Dodonov A.A.

Definition at line 129 of file graph.php.

{
$this->$Field = $Value;
}

Field Documentation

$ClientHeight = 0

Definition at line 51 of file graph.php.

$ClientWidth = 0

Size of the client area.

Author
Dodonov A.A.

Definition at line 50 of file graph.php.

$ClientX = 0

Ñoordinate of the client area.

Author
Dodonov A.A.

Definition at line 63 of file graph.php.

$ClientY = 0

Definition at line 64 of file graph.php.

$CoordX = 0

Coordinate center.

Author
Dodonov A.A.

Definition at line 76 of file graph.php.

$CoordY = 0

Definition at line 77 of file graph.php.

$DrawGrid = true

Should we draw grid.

Author
Dodonov A.A.

Definition at line 89 of file graph.php.

$GraphCore = false

Cached objects.

Author
Dodonov A.A.

Definition at line 537 of file graph.php.

$GraphUtilities = false

Definition at line 538 of file graph.php.

$Img = false

Object of the graph picture.

Author
Dodonov A.A.

Definition at line 38 of file graph.php.

$MarginBottom = 10

Definition at line 115 of file graph.php.

$MarginLeft = 10

Definition at line 116 of file graph.php.

$MarginRight = 10

Definition at line 117 of file graph.php.

$MarginTop = 10

Padding for the graph.

Author
Dodonov A.A.

Definition at line 114 of file graph.php.

$Security = false

Definition at line 539 of file graph.php.

$StepsX = 8

Count of grid's steps.

Author
Dodonov A.A.

Definition at line 101 of file graph.php.

$StepsY = 6

Definition at line 102 of file graph.php.


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