You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by David Hofmann <mo...@hotmail.com> on 2005/05/06 21:34:18 UTC

Graphics / Pie Charts

In order to provided stat data on my companies website my boss has asked me 
to write a program that pulls stat data from our database and display it on 
a page in graphs and pie charts. He'd like the program to hand the abilty to 
up the minute request, so I have to generate them on the fly.

The database side I can do eaily. However I haven't ever played with graphs 
and charts.

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.

Thanks,

David

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/


Re: Graphics / Pie Charts

Posted by Hans Poo <ha...@opensource.cl>.
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@opensource.cl, F: 09-319.93.05
Consultor Linux, Desarrollo Web OpenSource.
Santiago, Chile


Re: Graphics / Pie Charts

Posted by Sam Tregar <sa...@tregar.com>.
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

Re: Graphics / Pie Charts

Posted by Tom Schindl <to...@gmx.at>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

1. Perl-based: Use SVG and then convert them using Image::LibRSVG to
generate PNGs
2. Use PHP and the great module Image_Graph module from
http://pear.veggerby.dk/samples/

Tom

David Hofmann schrieb:
| In order to provided stat data on my companies website my boss has asked
| me to write a program that pulls stat data from our database and display
| it on a page in graphs and pie charts. He'd like the program to hand the
| abilty to up the minute request, so I have to generate them on the fly.
|
| The database side I can do eaily. However I haven't ever played with
| graphs and charts.
|
| 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.
|
| Thanks,
|
| David
|
| _________________________________________________________________
| Don?t just search. Find. Check out the new MSN Search!
| http://search.msn.click-url.com/go/onm00200636ave/direct/01/
|
|

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCfL2UkVPeOFLgZFIRAvQhAKCZKxwSal9y8Psq1i3r7p6WUY6KvgCbB0P0
cD1dBsshvUxI2PaxczQGlkA=
=Ug6O
-----END PGP SIGNATURE-----

Re: Graphics / Pie Charts

Posted by Jay Scherrer <ja...@scherrer.com>.
Both GTK+ and Perl::TK work really well. Using Perl GTK+ can actually
manipulate graphics through the Gimp.

Jay Scherrer

On Fri, 2005-05-06 at 15:34 -0400, David Hofmann wrote:
> In order to provided stat data on my companies website my boss has asked me 
> to write a program that pulls stat data from our database and display it on 
> a page in graphs and pie charts. He'd like the program to hand the abilty to 
> up the minute request, so I have to generate them on the fly.
> 
> The database side I can do eaily. However I haven't ever played with graphs 
> and charts.
> 
> 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.
> 
> Thanks,
> 
> David
> 
> _________________________________________________________________
> Dont just search. Find. Check out the new MSN Search! 
> http://search.msn.click-url.com/go/onm00200636ave/direct/01/
> 


Re: Graphics / Pie Charts

Posted by Foo Ji-Haw <jh...@nexlabs.com>.
You can try ImageMagick. Very nicely done.

David Hofmann wrote:

> In order to provided stat data on my companies website my boss has 
> asked me to write a program that pulls stat data from our database and 
> display it on a page in graphs and pie charts. He'd like the program 
> to hand the abilty to up the minute request, so I have to generate 
> them on the fly.
>
> The database side I can do eaily. However I haven't ever played with 
> graphs and charts.
>
> 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.
>
> Thanks,
>
> David
>
> _________________________________________________________________
> Don’t just search. Find. Check out the new MSN Search! 
> http://search.msn.click-url.com/go/onm00200636ave/direct/01/
>

Re: Graphics / Pie Charts

Posted by Jeff Ambrosino <jb...@gmail.com>.
If, by chance, you also have use for a general purpose templating
system, I've had great luck with Template-Toolkit
(www.template-toolkit.org.)  Among [many] other things, it embeds GD
so you can write little templates that slurp in the data and produce
graphics with graphs, charts, etc.  The learning curve is heavier than
just getting a quick-and-dirty graphing module to work (ala something
you'd do in CGI), but worthwhile if you're looking to add other
functions over time.

cheers
Jeff


On 5/6/05, David Hofmann <mo...@hotmail.com> 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.