Re: Graphing project

From: Date: Sun, 06 Aug 2000 08:10:45 +0000
Subject: Re: Graphing project
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-10307@lists.php.net to get a copy of this message
Are you generating simple bar graphs or something more complex like lines, best fit, scatter diagrams, etc? If it's just bar or column charts, maybe this will help a little. The algorithm I use to scale the axes uses logarithms to calculate the order of magnitude of the maximum value. In PHP, for example, if the maximum value is $themax and let's say $themax=400 for this example then you would do: $z = floor(log10($themax)) + 1; /* get the integer portion (characteristic) of the logarithm, plus 1 */ /* $z is now = 3 */ $z = pow(10,$z); /* raise it to the power 10 */ /* $z is now = 1000 */ while ($z/2 > $themax) { $z = $z/2; } /* chop $z in half a few times until it's less than your maximum. */ /* $z will now be = 500 for this example. This will be the */ /* maximum value of your axis. */ Then you just have to size your bars or columns as a percentage of the maximum. I use this to chart page hits and banner clicks per thousand impressions (a decimal value) and it works great. Jeff Markus wrote: > > Hi, > > I'd need some hints on how to program a coordinate system. I've been > searching for tutorials all over the web but haven't managed to find any > (surprising, isn't it?) > > I'm not asking you to write the whole stuff, but to give me something useful > to get going. What I'm about to build allows the user to input minimum and > maximum values for x & y shown on the graph and also scale values etc. As I > have only little experience on graphics programming, this seems quite > difficult. > > Also if you know any tutorials on web (doesn't really matter what language, > Java, C/C++, Visual Basic goes fine too - as long as I get the idea). > > Thanks in advance, > Markus > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#10307) next »