55 $this->GraphCore =
get_package(
'graph::graph_core' ,
'last' , __FILE__ );
56 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
78 private function set_width_height( &$Graph )
82 $Width = $this->Security->get_gp(
'width' ,
'integer' , 640 );
83 $Height = $this->Security->get_gp(
'height' ,
'integer' , 480 );
85 $Graph->set(
'Width' , $Width );
86 $Graph->set(
'Height' , $Height );
112 private function prepare_canvas( &$Graph )
116 $Graph->Img = imagecreatetruecolor( $Graph->Width , $Graph->Height );
118 if( $Graph->Img ===
false )
120 throw(
new Exception(
'An error occured while image creation' ) );
123 catch( Exception $e )
163 private function compile_client_width_height( $Graph , $ClientX = 20 , $ClientY = 20 ,
164 $Width = 0 , $Height = 0 )
168 $Graph->ClientX = intval( $ClientX );
169 $Graph->ClientY = intval( $ClientY );
173 $Graph->ClientWidth = $Graph->Width - 2 * $Graph->ClientX;
177 $Graph->ClientWidth = intval( $Width );
182 $Graph->ClientHeight = $Graph->Height - 2 * $Graph->ClientY;
186 $Graph->ClientHeight = intval( $Height );
189 catch( Exception $e )
213 private function init_client_area( &$Graph )
217 $ClientX = $this->Security->get_gp(
'client_x' ,
'integer' , 50 );
218 $ClientY = $this->Security->get_gp(
'client_y' ,
'integer' , 20 );
220 $ClientWidth = $this->Security->get_gp(
'client_width' ,
'integer' , $Graph->Width - 70 );
221 $ClientHeight = $this->Security->get_gp(
'client_height' ,
'integer' , $Graph->Height - 40 );
223 $this->compile_client_width_height( $Graph , $ClientX , $ClientY , $ClientWidth , $ClientHeight );
225 catch( Exception $e )
257 $GraphAreaColor = intval( $GraphAreaColor );
259 $GraphAreaColor = $this->GraphCore->get_color_from_hex( $Graph->Img , $GraphAreaColor );
261 $Res = imagefilledrectangle(
262 $Graph->Img , $Graph->ClientX , $Graph->Height - $Graph->ClientY ,
263 $Graph->ClientX + $Graph->ClientWidth , $Graph->Height - $Graph->ClientHeight - $Graph->ClientY ,
269 throw(
new Exception(
'An error occured while filling client area' ) );
272 catch( Exception $e )
300 private function draw_vertical_grid_lines( $Graph , $Color )
304 $dx = ( $Graph->ClientWidth - $Graph->MarginLeft - $Graph->MarginRight ) / $Graph->StepsX;
305 for( $i = 0 ; $i <= $Graph->StepsX ; $i++ )
308 $Graph->Img , $Graph->ClientX + $dx * $i + $Graph->MarginLeft ,
309 $Graph->Height - $Graph->ClientY , $Graph->MarginLeft + $Graph->ClientX + $dx * $i ,
310 $Graph->Height - $Graph->ClientY - $Graph->ClientHeight , $Color
314 catch( Exception $e )
342 private function draw_horizontal_grid_lines( $Graph , $Color )
346 $dy = ( $Graph->ClientHeight - $Graph->MarginTop - $Graph->MarginBottom ) / $Graph->StepsY;
347 for( $i = 0 ; $i <= $Graph->StepsY ; $i++ )
350 $Graph->Img , $Graph->ClientX , $Graph->MarginTop + $Graph->ClientY + $dy * $i ,
351 $Graph->ClientX + $Graph->ClientWidth , $Graph->MarginTop + $Graph->ClientY + $dy * $i , $Color
355 catch( Exception $e )
387 $Color = $this->GraphCore->get_color_from_hex( $Graph->Img , $Color );
389 $this->draw_vertical_grid_lines( $Graph , $Color );
391 $this->draw_horizontal_grid_lines( $Graph , $Color );
393 catch( Exception $e )
429 if( $Graph->Img ===
false )
431 $Graph->draw_client_area();
434 $Graph->CoordX = $X = intval( $X );
435 $Graph->CoordY = $Y = intval( $Y );
437 $BlackColor = imagecolorallocate( $Graph->Img , 0 , 0 , 0 );
440 $Graph->Img , $Graph->ClientX , $Graph->Height - $Graph->ClientY - $Y ,
441 $Graph->ClientX + $Graph->ClientWidth , $Graph->Height - $Graph->ClientY - $Y , $BlackColor
445 $Graph->Img , $Graph->ClientX + $X , $Graph->Height - $Graph->ClientY , $Graph->ClientX + $X ,
446 $Graph->Height - $Graph->ClientY - $Graph->ClientHeight , $BlackColor
449 catch( Exception $e )
473 $this->set_width_height( $Graph );
475 $this->prepare_canvas( $Graph );
477 $BackgroundColor = $this->Security->get_gp(
'background_color' ,
'integer' , 0xeeeeee );
478 $this->GraphCore->fill_background( $Graph->Img , $BackgroundColor );
480 $this->init_client_area( $Graph );
482 $GraphAreaColor = $this->Security->get_gp(
'graph_area_color' ,
'integer' , 0xffffff );
488 catch( Exception $e )