mgdude has asked for the wisdom of the Perl Monks concerning the following question:
Now lets say you want to allow the user to "zoom in" on an area of the graph. Pretend that after some CGI magic and some passed parameters, the min/max for the x and y axes are as follows and you insert this code where I have marked in the above script:use strict; use GD::Graph::lines; my @data = ( [1, 2, 3, 4, 5, 6, 7, 8, 9,], [ 8, 8.25, 8.5, 8.35, 8.76, 8.21, 8.6, 8.8, 8.5], [ 7.4, 7.6, 7.8, 7.9, 7.4, 8.5, 7, 7.87, 8.34], [ 4, 5, 6, 5.6, 5.5, 6.1, 6.3, 5.2, 5.6]); my $graph = new GD::Graph::lines (600, 400); $graph->set( title => "Blah, Blah, Blah", x_label => 'X axis label', y_label => 'Y axis label', boxclr => '#C0C0C0' ); ## Next code snippet goes here $graph->set_legend("data set 1", "data set 2", "data set 3"); print "Content-type: image/png\n\n"; binmode(STDOUT); print $graph->plot(\@data)->png();
The lines run off the edge of the x and y axes, the x_max_value does not appear to be properly set, etc. Am I dumb and have an error in the code somewhere or do you folks encounter the same problem? Could be a better looking graph, eh? Didn't find a fix for this in the documentation. So far it does this on my Linuxbox (forgot what flavor, I don't manage it), and a WinNT machine, both with what I think is the most recent module of GD::Graph. If this is a known problem and there is a fix, do let me know.$graph->set( y_min_value => 6, y_max_value => 10, x_min_value => 3, x_max_value => 7 );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: GD::Graph - data plotting off the charting area
by terra incognita (Pilgrim) on Apr 08, 2005 at 20:35 UTC |