[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now



Posted on 2004-10-24
Medium Priority
Last Modified: 2006-11-17
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?
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

Question by:TPoly
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

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..
#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
@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 -->


print $query->end_html;

Hope this helps

Author Comment

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


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


Expert Comment

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

Maybe this will help...



Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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

649 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