|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-01-30 18:21 UTC] nlopess@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Jun 18 13:00:01 2026 UTC |
Description: ------------ To graph correctly from + or - zero the i variable must be changed to $i. Old ====> $min_x = $graph_x[i]; New ====> $min_x = $graph_x[$i]; Reproduce code: --------------- help at nanomc dot com 08-Nov-2005 02:29 // A simple XY graph <html> <head> <title>XY Graph</title> <h2>Practice XY Graph</h2> </head> <body> <?php $left = 0; $top = 0; $x_size = 400; $y_size = 400; $char_width = 8; $char_height = 11; $x_start = $x_left + 100; $y_start = $top + $char_height * 1.5; $x_end = $x_start + $x_size; $y_end = $y_start + $y_size; $right = $x_start + $x_size + 40; $bottom = $y_start + $y_size + $char_height * 1.5; $graph_n = 100; for($i = 0; $i < $graph_n; $i++ ) { $graph_x[$i] = $i; $graph_y[$i] = $i * $i; } $min_x = 9e99; $min_y = 9e99; $max_x = -9e99; $max_y = -9e99; $avg_y = 0.0; for($i = 0; $i < $graph_n; $i++ ) { if( $graph_x[$i] < $min_x ) New ======> $min_x = $graph_x[i];