?
Solved

graph

Posted on 2004-10-24
3
Medium Priority
?
441 Views
Last Modified: 2006-11-17
hi,
i would like to know how can i generate a bar chart automatical using perl.
i've tried using Text::Graph module but the output is not really a bar chart.
and i've also tried Template::Plugin::GD::Graph::bars  however i do not know how to apply with perl.

does anyone know any other method to generate bar chart with perl?
OR
any other simpler method

Sample codes provided will be much appreciated

ps. the bar chart generated must have x & y axis. i am using debian linux 3.0 and perl 5.6.1

thanks
0
Comment
Question by:TPoly
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
windfall earned 750 total points
ID: 12403618
Here's an example of how we have done a chart using GD

Using Activestate and windows server....

Hope this helps..
#########################
#c:\perl\bin\perl
#call to escape unescape funny characters
use CGI qw/escape unescape/;
$sample_label = "Sample_CHART";
use GD;
use Chart::Bars;

#create an instance of CGI
$query = new CGI;

@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 -y
#could be read in from a database table etc
#example:
@records = ('21','32','76','33','13','23','87','67','56','45','23','34','21','23','32','34','32','23','34','34','76','21','2','33');#Number of requests per hour

@ave_min = ('15','32','12','23','2','5','9','10','34','21','23','54','67','67','78','5','23','0','32','45','7','56','44','3'); # deltas divided by conults


#Now make an associated array to build the image

@daily = ([@hours], [@records], [@ave_min]);

@labels = ("\# of entries for the hour","Average \# of minutes to room");# explanatory note for legend
# Makes the chart
$obj = Chart::Bars->new (600,400);# Set the size of the image
 $obj->set ('title' => "Values for Sample Chart");# Place the title of the chart
 $obj->set ('x_label' => 'Hours');# Label the x axis
 $obj->set ('y_label' => 'Label Up the Side!!');# 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
 $obj->set ('grid_lines' => 'true');# Places grid lines on the chart
 
 $obj->png (">D:/resource/www/images/pngchart/$sample_label.gif", \@daily );
 $obj->clear_data ();
 #$obj->set ('no_cache' => 'true');
 #$obj->cgi_png ( \@daily );

#create an instance of CGI
$query = new CGI;

print $query->header("-nph=>1");
print $query->start_html(-title => 'CHART');

print <<HTML;

<img src=/images/pngchart/$sample_label.gif>

<!--End Content here -->

HTML

print $query->end_html;


###############
Hope this helps
Windfall
0
 

Author Comment

by:TPoly
ID: 12418129
hi..
thanks for ur help..
jus want to know does this program able to generate the chart
in excel presenation chart format.

OR

do anyone know of any perl program/module that can do so.

thanks
0
 
LVL 2

Expert Comment

by:windfall
ID: 12421345
Here's a link that has some examples using Perl and Excel

Maybe this will help...

Windfall

http://www.xav.com/perl/faq/Windows/ActivePerl-Winfaq12.html
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question