I don't know if it's too much for a posting but, i 've just build a module
under mod_perl to do just that, i call whenever i need a pie chart. You call
it like this:

First you put a handler in httpd.conf:
--------------------------------------
<Files grafico>
     SetHandler  perl-script
     PerlHandler UB::Grafico
</Files>

The calling url is:
-------------------
http://www.ubpf.cl:8080/grafico?labels=e,c,b;values=1,3,3;title=

the module is:
--------------
package UB::Grafico;
                                                                             
                                                                               
use Apache::Constants qw/OK/;
                                                                             
                                                                               
use CGI ':standard';
use GD::Graph::pie;
use strict;
                                                                             
                                                                               
sub handler {
                                                                             
                                                                               
my $r = shift;
                                                                             
                                                                               
$r->no_cache(1);
                                                                             
                                                                               
my @labels = split /,/, param("labels");
my @values = split /,/, param("values");
                                                                             
                                                                               
# Both the arrays should same number of entries.
my @data = ([EMAIL PROTECTED], [EMAIL PROTECTED]);
                                                                             
                                                                               
my $mygraph = GD::Graph::pie->new(80, 80);
$mygraph->set(
    title       => param("title"),
    '3d'          => 1,
) or warn $mygraph->error;
                                                                             
                                                                               
$mygraph->set_title_font(GD::gdTinyFont);
$mygraph->set_value_font(GD::gdTinyFont);
$mygraph->set(dclrs => [ qw(yellow red cyan) ] );
my $myimage = $mygraph->plot([EMAIL PROTECTED]) or die $mygraph->error;
                                                                             
                                                                               
$r->send_http_header("image/png");
print $myimage->png;
                                                                             
                                                                               
return OK;
                                                                             
                                                                               
                                                                             
                                                                               
}
                                                                             
                                                                               
1;


Good Luck
Hans

On Fri, 6 May 2005 15:40:40 -0400 (EDT), Sam Tregar wrote
> On Fri, 6 May 2005, David Hofmann wrote:
> 
> > Someone recommend that I use GDGraph-1.43. Looking at it there
> > hasn't been an update since 2003. So before I go play with it I
> > figure I ask here if anyone has done and graph stuff, and if there a
> > better module to use under mod perl.
> 
> I asked a similar question on PerlMonks recently:
> 
>   http://perlmonks.org/?node_id=452166
> 
> I ended up settling on GD::Graph3D but I'll be interested to see if
> someone here has a better idea.
> 
> -ssam


------------------------------------------------------------------------
El problema de fondo es diseñar soluciones elegantes e inteligentes, las 
herramientas sólo son las herramientas.

Hans Poo, http://hans.opensource.cl, [EMAIL PROTECTED], F: 09-319.93.05
Consultor Linux, Desarrollo Web OpenSource.
Santiago, Chile

Reply via email to