CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Chart in perl : different color codes

 



ishaan
Novice

Jun 22, 2011, 12:02 PM

Post #1 of 4 (3054 views)
Chart in perl : different color codes Can't Post

I am doing a chart in perl with X-axis ( Item Name) and Y-axis ( Percentage) and am able to display the chart in horizontal bars. Currently all the bars are showing the same color code and my requirement is to tag the data with certain color code.

Item Name Percent
Item 1 80 (Yellow)
Item 2 100 ( Green)
Item 3 60 (red)

I want to display the chart with different color codes for each of the item.

Can this be possible?


miller
User

Jun 22, 2011, 1:49 PM

Post #2 of 4 (3052 views)
Re: [ishaan] Chart in perl : different color codes [In reply to] Can't Post

Where's your code?

What are you currently using to generate a chart?

- Miller


ishaan
Novice

Jun 22, 2011, 2:38 PM

Post #3 of 4 (3049 views)
Re: [miller] Chart in perl : different color codes [In reply to] Can't Post

I am using the sample listed at:

http://linuxgazette.net/issue83/padala.html

use CGI ':standard';
use GD::Graph::bars;
use strict;

my @itemdata = (["Item1", "Item2", "Item3"],
[80,90,100]);
my $mygraph = GD::Graph::bars->new(500, 300);
$mygraph->set(
x_label => 'Item Data',
y_label => 'Item Name',
title => 'Sample Graph'
)

# Set colors for datasets
dclrs => ['blue'],
my $myimage = $mygraph->plot(\@itemdata) or die $mygraph->error;

print "Content-type: image/png\n\n";
print $myimage->png;

It sets the color to blue for all the items. What I am looking for is if I can set different color code to the data in the dataset ?

For example:

80 Red
90 Red
100 Green

Can this be possible even? Is there any other module that can support this?


miller
User

Jun 22, 2011, 3:06 PM

Post #4 of 4 (3046 views)
Re: [ishaan] Chart in perl : different color codes [In reply to] Can't Post

Read the documentation. It'll tell you more than any of us can:

GD::Graph #colours

- Miller

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives