Re: Auto-generating a graphs Y scale

From: Date: Mon, 25 Aug 2008 12:41:13 +0000
Subject: Re: Auto-generating a graphs Y scale
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-278654@lists.php.net to get a copy of this message
At 10:01 AM +0100 8/25/08, Richard Heyes wrote:
Can anyone give me some pointers for auto generating an appropriate Y scale for a graph (eg a bar/line graph). Much like JPGraph does. Thanks. -- Richard Heyes
Richard: First, the y scale is the one that runs up and down and not right to left. :-) Second, the physical length of the y scale should be static and whatever you want it to be (i.e., 5 inches, 10 inches, etc.). Third, to plot points along this axis simply take the maximum value found in their Y coordinate and divide that into the physical length of the Y scale, such as 10 inches/1500. That will give you a delta value by which you can multiply all values to get their position on the y scale. Do the same for x, and you have a scatter graph. Do the same for x, sort x, connect the dots and you have a line graph. Do the same for x and provide a range for x and you have a bar chart. Here's an example: http://webbytedd.com/aa/stdev/ At least I think that's what you're asking. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com

« previous php.general (#278654) next »