Solved

graph

Posted on 2004-10-24
434 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
Question by:TPoly
    3 Comments
     
    LVL 2

    Accepted Solution

    by:
    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
    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
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
    A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
    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…
    This video Micro Tutorial is the first in a two-part series that shows how to create and use custom scanning profiles in Nuance's PaperPort 14.5 (http://www.experts-exchange.com/articles/17490/). But the ability to create custom scanning profiles al…

    933 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

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now