Re: Graphics / Pie Charts

[prev] [thread] [next] [Date index for 2005/05/06]

From: Hans Poo
Subject: Re: Graphics / Pie Charts
Date: 21:01 on 06 May 2005
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 = (\@labels, \@values);
                                                                             
                                                                               
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(\@data) 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, hans@xxxxxxxxxx.xx, F: 09-319.93.05
Consultor Linux, Desarrollo Web OpenSource.
Santiago, Chile

(message missing)

[ANNOUNCE] mod_perl 2.0.0-RC6
Stas Bekman 06:26 on 04 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Octavian Rasnita 09:47 on 04 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Stas Bekman 02:34 on 10 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Steve Hay 10:36 on 04 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Markus Wichitill 13:44 on 04 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Stas Bekman 06:40 on 05 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Steve Hay 09:28 on 05 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Stas Bekman 14:35 on 05 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Markus Wichitill 14:47 on 05 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Randy Kobes 15:25 on 05 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Steve Hay 16:00 on 05 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Markus Wichitill 16:13 on 05 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Randy Kobes 16:54 on 05 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Steve Hay 17:08 on 05 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Stas Bekman 05:27 on 06 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Randy Kobes 05:40 on 06 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Markus Wichitill 10:11 on 06 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Steve Hay 10:31 on 06 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Randy Kobes 13:29 on 06 May 2005

Graphics / Pie Charts
David Hofmann 19:34 on 06 May 2005

Re: Graphics / Pie Charts
Sam Tregar 19:40 on 06 May 2005

Re: Graphics / Pie Charts
Hans Poo 21:01 on 06 May 2005

Re: Graphics / Pie Charts
Jeff Ambrosino 21:31 on 06 May 2005

Re: Graphics / Pie Charts
Jay Scherrer 23:57 on 06 May 2005

Re: Graphics / Pie Charts
Foo Ji-Haw 05:47 on 07 May 2005

Re: Graphics / Pie Charts
Tom Schindl 13:07 on 07 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Tom Williams 19:43 on 07 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Stas Bekman 07:16 on 08 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Tom Williams 14:21 on 08 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Stas Bekman 15:11 on 08 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Stas Bekman 02:00 on 10 May 2005

Re: [ANNOUNCE] mod_perl 2.0.0-RC6
Stas Bekman 06:50 on 07 May 2005

Generated at 06:57 on 17 May 2005 by mariachi v0.52