Apache-GDGraph

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

	- Fixed a possible misreading of the CacheSize parameter reported by
	  CPAN testers.

0.94	Thu Apr  3 21:06:14 PST 2003
	- Added compatibility with mod_perl for Apache2.
	- Made test skip in Apache2 (too lazy to fix it right now).

0.93	Sat Nov 17 14:59:03 PST 2001
	- Added relative path support for files/fonts etc. So that things like
	  ../fonts/arial.ttf will resolve relative to DocumentRoot. Or
	  to_file=../images/foo.png, etc.. Thanks to Joseph Pepin for the
	  suggestion.
	- Boxed captions in plain/dashed/dotted/whatever style.
	- Support builtin GD fonts Like gdSmallFont.
	- Cleaner code and misc. minor bugs fixed.

0.92	Tue Apr 24 11:36:19 PDT 2001
	- Previous versions couldn't handle more than 9 arguments because of a
	  silly string increment bug :) Thanks to Drew Degentesh for pointing
	  this out.

Changes  view on Meta::CPAN

	- Since 0.7, the default for the X axis is to NOT have any labels.
	- The "expires" parameter didn't really work, fixed.
	- The parameter cache=0 in the query string still hit the cache if the
	  image was already there, fixed.
	- Was checking for "Accepts" header, when needed to check for "Accept"
	  header.
	- Now checking for set_XXX methods as options, so methods like
	  set_legend(), set_font(), etc will work.

0.7	Wed Sep 14 18:47:27 PDT 2000
	- Added support for image types other than png via PerlSetVar
	  ImageType, and the image_type parameter, and via Accepts header
	  (Thanks to Scott Holdren for the idea and patch.)
	- Better parsing. Empty values in arrays (like [,foo,bar,,]) will work,
	  as well as quoted strings. (Thanks to Scott Holdren for the former.)
	- New argument "expires" allows configuration of Expires header on a
	  request basis.
	- New argument "cache" allows requests to not use the server-side
	  cache.
	- Improved error handling again.
	- Now know how to make graphs without axes, see man page.

README  view on Meta::CPAN


            <Location /chart>
            SetHandler      perl-script
            PerlHandler     +Apache::GD::Graph
            ## These are optional (defaults shown)
            ##                              In days:
            #PerlSetVar     Expires         30
            #
            ##                              In megs:
            #PerlSetVar     CacheSize       5242880
            #PerlSetVar     ImageType       png
            #PerlSetVar     JpegQuality     75 # 0 to 100
            #PerlSetVar     TTFFontPath     /usr/ttfonts:
            #/var/ttfonts:/usr/X11R6/lib/X11/fonts/ttf/:
            #/usr/X11R6/lib/X11/fonts/truetype/:
            #/usr/share/fonts/truetype
            </Location>

    Then send requests to:

            http://www.server.com/chart?type=lines&

README  view on Meta::CPAN

    the "background_image" option herein.

TEXT/CAPTIONS
    The following GD::Graph options control placing text on the graph:
    title, x_label and y_label. GD::Graph for those and related options.
    In addition, this modules allows you to use the captionN option(s),
    to draw arbitrary strings on the graph. See below.

IMPLEMENTATION
    This module is implemented as a simple Apache mod_perl handler that
    generates and returns a png format graph (using Martien Verbruggen's
    GD::Graph module) based on the arguments passed in via a query
    string. It responds with the content-type "image/png" (or whatever
    is set via "PerlSetVar ImageType"), and sends a Expires: header of
    30 days (or whatever is set via "PerlSetVar Expires", or expires in
    the query string, in days) ahead.

    In addition, it keeps a server-side cache in the file system using
    DeWitt Clinton's File::Cache module, whose size can be specified via
    "PerlSetVar CacheSize" in bytes.

OPTIONS
    type    Type of graph to generate, can be lines, bars, points,

README  view on Meta::CPAN

            GD::Graph::.

    width   Width of graph in pixels, 400 by default.

    height  Height of graph in pixels, 300 by default.

    expires Date of Expires header from now, in days. Same as
            "PerlSetVar Expires".

    image_type
            Same as "PerlSetVar ImageType". "png" by default, but can be
            anything supported by GD.

            If not specified via this option or in the config file, the
            image type can also be deduced from a single value in the
            'Accept' header of the request.

    jpeg_quality
            Same as "PerlSetVar JpegQuality". A number from 0 to 100
            that determines the jpeg quality and the size. If not set at
            all, the GD library will determine the optimal setting.

README  view on Meta::CPAN


    (one,two,3)
            This becomes a list, you can pass lists to set_SOMETHING
            methods of GD::Graph, if there is no corresponding set_
            method, the list will be silently converted to an anonymous
            array and used in an ordinary option.

    {one,1,two,2}
            Becomes a hash reference.

    http://somewhere/file.png
            Is pulled into a file and the file name is passed to the
            respective option. (Can be any scheme besides http:// that
            LWP::Simple supports.)

    ../fonts/arial.ttf
            Paths following this pattern will be interpreted as paths
            relative to DocumentRoot of the web server.

    gdSmallFont, gdLargeFont, gdMediumBoldFont, gdTinyFont, gdGiantFont,
    gdStyled, gdBrushed, gdStyledBrushed, gdTransparent

lib/Apache/GD/Graph.pm  view on Meta::CPAN


	<Location /chart>
	SetHandler	perl-script
	PerlHandler	+Apache::GD::Graph
	## These are optional (defaults shown)
	## 				In days:
	#PerlSetVar	Expires		30
	#
	##				In megs:
	#PerlSetVar	CacheSize	5242880
	#PerlSetVar	ImageType	png
	#PerlSetVar	JpegQuality	75 # 0 to 100
	#PerlSetVar	TTFFontPath	/usr/ttfonts:
	#/var/ttfonts:/usr/X11R6/lib/X11/fonts/ttf/:
	#/usr/X11R6/lib/X11/fonts/truetype/:
	#/usr/share/fonts/truetype
	</Location>

Then send requests to:

	http://www.server.com/chart?type=lines&

lib/Apache/GD/Graph.pm  view on Meta::CPAN

=head1 TEXT/CAPTIONS

The following GD::Graph options control placing text on the graph: title,
x_label and y_label. L<GD::Graph> for those and related options. In addition,
this modules allows you to use the captionN option(s), to draw arbitrary
strings on the graph. See below.

=head1 IMPLEMENTATION

This module is implemented as a simple Apache mod_perl handler that generates
and returns a png format graph (using Martien Verbruggen's GD::Graph module)
based on the arguments passed in via a query string. It responds with the
content-type "image/png" (or whatever is set via C<PerlSetVar ImageType>), and
sends a Expires: header of 30 days (or whatever is set via C<PerlSetVar
Expires>, or expires in the query string, in days) ahead.

In addition, it keeps a server-side cache in the file system using DeWitt
Clinton's File::Cache module, whose size can be specified via C<PerlSetVar
CacheSize> in bytes.

=head1 OPTIONS

=over 8

lib/Apache/GD/Graph.pm  view on Meta::CPAN

=item B<height>

Height of graph in pixels, 300 by default.

=item B<expires>

Date of Expires header from now, in days. Same as C<PerlSetVar Expires>.

=item B<image_type>

Same as C<PerlSetVar ImageType>. "png" by default, but can be anything
supported by GD.

If not specified via this option or in the config file, the image type can also
be deduced from a single value in the 'Accept' header of the request.

=item B<jpeg_quality>

Same as C<PerlSetVar JpegQuality>. A number from 0 to 100 that determines the
jpeg quality and the size. If not set at all, the GD library will determine the
optimal setting. Changing this value doesn't seem to do much as far as line

lib/Apache/GD/Graph.pm  view on Meta::CPAN

=item B<(one,two,3)>

This becomes a list, you can pass lists to set_SOMETHING methods of GD::Graph,
if there is no corresponding set_ method, the list will be silently converted
to an anonymous array and used in an ordinary option.

=item B<{one,1,two,2}>

Becomes a hash reference.

=item B<http://somewhere/file.png>

Is pulled into a file and the file name is passed to the respective option.
(Can be any scheme besides http:// that LWP::Simple supports.)

=item B<../fonts/arial.ttf>

Paths following this pattern will be interpreted as paths relative to
DocumentRoot of the web server.

=item B<gdSmallFont, gdLargeFont, gdMediumBoldFont, gdTinyFont, gdGiantFont,

lib/Apache/GD/Graph.pm  view on Meta::CPAN

use GD::Graph::colour qw(:convert);
use File::Cache;

use constant TRUE	=> 1;
use constant FALSE	=> 0;

use constant SECONDS_IN_DAY => 24 * 60 * 60;

use constant EXPIRES	=> 30;
use constant CACHE_SIZE	=> 5242880;
use constant IMAGE_TYPE => 'png';
use constant TTF_FONT_PATH	=> '/usr/ttfonts:/var/ttfonts:/usr/X11R6/lib/X11/fonts/ttf/:/usr/X11R6/lib/X11/fonts/truetype/:/usr/share/fonts/truetype';

use constant DEFAULT_TYPE	=> 'lines';
use constant DEFAULT_WIDTH	=> 400;
use constant DEFAULT_HEIGHT	=> 300;

use constant DEFAULT_CAPTION_BOX_OFFSET => 9;

use constant TYPE_UNDEF		=> 0;
use constant TYPE_SCALAR	=> 1;

lib/Apache/GD/Graph.pm  view on Meta::CPAN

# parse ($datum[, $tmp_dir])
#
# Parse a datum into a scalar, arrayref or hashref. Using the following semi
# perl-like syntax:
#
# undef			-- a real undef
# foo_bar		-- a scalar
# [1,2,undef,"foo",bar]	-- an array
# (3,4,undef,"baz")	-- a list
# {1,2,'3',foo}		-- a hash
# http://some/url.png	-- pull a URL into a file, returning that. The file
# will be relative to a directory given as the second parameter, or /tmp if not
# specified.
# ../some/file		-- a file relative to DocumentRoot
sub parse ($;$) {
	local $_ = shift;
	my $dir  = shift || '/tmp';

	return (TYPE_UNDEF, undef) if $_ eq 'undef';

	if (/^\[(.*)\]$/) {



( run in 2.525 seconds using v1.01-cache-2.11-cpan-df04353d9ac )