Question : GD::Graph - values on numerical X axis

I used GD::Graph package from CPAN. It helps me a lot but I have a problem.
I want to show on my image an evolution in time of some values. I did that by using the X axis with numerical values and with the help of "x_number_format" function.
My problem is that I want to show on the X axis only SOME values, not all the values that my package plotted on the chart. Why that? Because I need to show the X values for some important points and the chart couldn't show me (I have too many points in graphic and only few of them are interested for me as coordinates.)
Thanks!

Answer : GD::Graph - values on numerical X axis

I hope I understood the question correctly...
Here is a sample code that only prints every other hour on the chart/graphic....
Hope it helps-
windfall

btw...Note that by saving as .gif  file, it wil display in page right away, whereas if I saved as .png
it would not display in my Netscape 4.6 browser correctly....

#####
#c:\perl\bin\perl
#she-bang line for cross-platform ease

########################################
#This script is called:Z_MAKECHART_SAMPLE.pl
#This script purpose:make a bar chart
#This script reads from tables:
#This script writes to tables:
########################################
#it uses DBI
#it uses CGI
########################################
#These can be uncommented during development to assist in de-bugging
#use strict;
#use diagnostics;
########################################
#Standard DBI initial variable calls
use vars qw($query,$dbhndl,$sql,$sth,@row);
use DBI;
#call to escape unescape funny characters
use CGI qw/escape unescape/;
use Date::Manip;

use GD;
use Chart::Bars;
$Now = &UnixDate("today","%q");


@hours = ();#make an array of titles for the "x" axis
# To make a "time of day chart"
#e.g. this will give an array of hours for the "x" axis - midnite => 23:00
foreach $i(0..23){
push (@hours, "$i:00");
}

#make some arrays of values for the various bars of the chart
#could be read in from a database table etc
#example:
@nurses = (9,9,9,9,9,9,11,11,14,14,16,17,19,23,23,23,22,17,16,16,17,11,9,9);
@doctors = (1,1,1,1,1,1,1,2,2,2,2,2,3,3,4,4,4,4,2,2,2,2,1,1);
@patients = (10,10,8,12,6,4,8,14,20,24,26,26,28,16,14,12,24,23,15,12,13,20,13,10); # make another dataset for compound chart


#Now make an associated array to build the image
@daily = ([@hours], [@nurses], [@doctors],[@patients]);

@labels = ("\# of Nurses","\# of Doctors","\# of Patients");# explanatory note for legend
# Makes the chart
$obj = Chart::Bars->new (600,400);# Set the size of the image
 $obj->set ('title' => 'Values by Hour');# Place the title of the chart
 $obj->set ('x_label' => 'Hours');# Label the x axis
 $obj->set ('y_label' => 'Activity');# Label the y axis
 $obj->set ('legend' => 'bottom');# places the legend on the bottom
 $obj->set ('legend_labels' => \@labels);# describes the various colors of bars in the legend
 $obj->set ('skip_x_ticks' => '2');##### Skips over some of the x axis labels for viewing clarity ####
 #$obj->set ('x_ticks' => 'vertical');####x axis labels for viewing clarity up and down rather than horizontal
 $obj->set ('grid_lines' => 'true');# Places grid lines on the chart
 
 $obj->png (">D:/resource/www/images/pngchart/$Now.gif", \@daily );
 $obj->clear_data ();
 #$obj->set ('no_cache' => 'true');
 #$obj->cgi_png ( \@daily );

 
 
 
 
$query = new CGI;
#send MIME and HTML headers
print $query->header("-nph=>1");
print $query->start_html(-title => 'CHART SAMPLE');
#stupid little thing
@a=(Lbzjoftt,Inqbujfodf,Hvcsjt);
$b="Lbssz Wbmm";
$b =~ y/b-z/a-z/ ;
$c = " Tif ". @a ." hsfbu wj"."suvft pg b qsphsbnnfs". ":\n";
$c =~y/b-y/a-z/;

print"\n\n$c ";

for($i=0;$i<@a; $i++) {
     $a[$i] =~y/b-y/a-z/;
     if($a[$i]eq$a[-1]){
          print"and $a[$i].";
          }else{
               print"$a[$i], ";
                     }
                     
               }
print"\n\t\t--$b\n\n";
#######################
print <

Sample Chart


w.gif>
HTML
print $query->end_html;



Random Solutions  
 
programming4us programming4us