129 function set( $Field , $Value )
131 $this->$Field = $Value;
152 private function get_draw_y_labels_params()
156 $GlobalCenterY = $this->Height - $this->ClientY -
$this->CoordY;
160 return( array( $GlobalCenterY , $dy ) );
162 catch( Exception $e )
194 $Color = $this->GraphCore->get_color_from_hex( $this->Img , $Color );
195 list( $GlobalCenterY , $dy ) = $this->get_draw_y_labels_params();
197 $Font = dirname( __FILE__ ).
'/res/font/arial.ttf';
202 list( $Width , $Height ) = $this->GraphCore->string_width_height( $Font , $Size , $Labels[ $i ] );
205 $this->Img , $Size , 0 , $this->ClientX - $Width - 10 ,
206 $GlobalCenterY - $dy * $i - $Height / 2 , $Color , $Font , $Labels[ $i ]
210 catch( Exception $e )
246 private function get_x_y( $d , $Width , $Height )
250 $x = $this->ClientX + $this->CoordX + $d + $this->MarginLeft - $Width / 2 ;
252 $y = $this->Height - $this->ClientY + $Height + 5;
254 return( array( $x , $y ) );
256 catch( Exception $e )
292 $Color = $this->GraphCore->get_color_from_hex( $this->Img , $Color );
294 $Labels = $Labels ===
false ? $DataX : $Labels;
296 list( $dX , $dY ) = $this->get_scales( $DataX ,
false );
297 $Font = dirname( __FILE__ ).
'/res/font/arial.ttf';
299 $Count = count( $DataX );
301 for( $i = 0 ; $i < $Count ; $i++ )
303 list( $Width , $Height ) = $this->GraphCore->string_width_height( $Font , 10 , $Labels[ $i ] );
304 $d = ( $DataX[ $i ] - min( $DataX ) ) * $dX;
305 list( $x , $y ) = $this->get_x_y( $d , $Width , $Height );
306 imagettftext( $this->Img , 10 , 0 , $x , $y , $Color , $Font , $Labels[ $i ] );
309 catch( Exception $e )
341 $c = count( $DataY );
343 if( $DataX ===
false )
346 for( $i = 0 ; $i < $c ; $i++ )
357 return( $TotalClientWidth );
359 catch( Exception $e )
391 private function get_scales( $DataX , $DataY )
396 if( $DataX !==
false )
398 $MDW = max( $DataX ) - min( $DataX );
399 $MDW = $MDW ? $MDW : 1;
402 if( $DataY !==
false )
404 $MDH = max( $DataY ) - min( $DataY );
405 $MDH = $MDH ? $MDH : 1;
412 $this->MarginBottom = $this->ClientHeight / 2;
415 return( array( $dX , $dY ) );
417 catch( Exception $e )
457 private function draw_graph_part( $x1 , $x2 , $y1 , $y2 , $Color )
461 $this->GraphCore->imagelinethick( $this->Img , $x1 , $y1 , $x2 , $y2 , $Color , 2 );
463 imagefilledellipse( $this->Img , $x1 , $y1 , 9 , 9 , $Color );
465 imagefilledellipse( $this->Img , $x2 , $y2 , 9 , 9 , $Color );
467 catch( Exception $e )
503 $Color = $this->GraphCore->get_color_from_hex( $this->Img , $Color );
505 list( $dX , $dY ) = $this->get_scales( $DataX , $DataY );
508 $OY = $this->Height - $this->ClientY - $this->CoordY + min( $DataY ) * $dY -
$this->MarginBottom;
510 for( $i = 0 ; $i < count( $DataX ) - 1 ; $i++ )
512 $x1 = $OX + $DataX[ $i + 0 ] * $dX;
513 $x2 = $OX + $DataX[ $i + 1 ] * $dX;
515 $y1 = $OY - $DataY[ $i + 0 ] * $dY;
516 $y2 = $OY - $DataY[ $i + 1 ] * $dY;
518 $this->draw_graph_part( $x1 , $x2 , $y1 , $y2 , $Color );
521 catch( Exception $e )
555 $this->GraphCore =
get_package(
'graph::graph_core' ,
'last' , __FILE__ );
556 $this->GraphUtilities =
get_package(
'graph::graph_utilities' ,
'last' , __FILE__ );
557 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
559 catch( Exception $e )
583 private function get_graph_data()
589 explode(
',' , $this->Security->get_gp(
'data_x' ,
'string' ,
'1,2' ) ) ,
590 explode(
',' , $this->Security->get_gp(
'data_y' ,
'string' ,
'1,2' ) )
594 catch( Exception $e )
622 $this->GraphUtilities->prepare_graph_area( $this );
624 list( $DataX , $DataY ) = $this->get_graph_data();
625 $Color = $this->Security->get_gp(
'color' ,
'integer' , 0xff0000 );
626 $this->
draw_graph( $DataY , $DataX , $Color );
627 $DataYLabels = $this->GraphCore->compile_labels_from_data( $DataY , $this->StepsY );
629 $DataXLabels = $this->Security->get_gp(
'data_x_labels' ,
'string' ,
false );
630 $DataXLabels = $DataXLabels ===
false ?
false : explode(
',' , $DataXLabels );
633 $this->GraphCore->output( $Options , $this->Img );
635 catch( Exception $e )