Apache-GDGraph
view release on metacpan or search on metacpan
purple, dpurple, lorange, orange, pink, dpink, marine, cyan, lbrown,
dbrown.
IMAGES
You can place a logo in any corner of the graph using the "logo",
"logo_resize" and "logo_position" options. See GD::Graph. If you
just want a background image that is resized to fit your graph, see
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,
linespoints, area, mixed, pie. For a description of these,
see GD::Graph(3). Can also be one of the 3d types if
GD::Graph3d is installed, or anything else with prefix
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.
Changing this value doesn't seem to do much as far as line
graphs go, but YMMV.
background_image
Set an image as the background for the graph. You are
responsible for choosing a sane image to go with your graph,
the background should be either transparent or the same
color you will use. This is the same as using the "logo"
parameter with an image of the same size as the graph,
except this option will resize the image if necessary,
making it more convenient for this purpose. The file or URL
can be of any type your copy of GD supports.
captionN
Draws a character string using a TrueType font at an
arbitrary location. Takes an array of
"($fgcolor,$fontname,$ptsize,$angle,$x,$y,$string[,$box_colo
r,$box_offset])" where $fgcolor is the foreground color,
$fontname is the name of a TTF font see "FONTS" , $ptsize is
the point size, $x and $y are the coordinates, and $string
is the actual characters to draw.
$box_color and $box_offset are optional parameters, if set
the caption will be drawn with a box around it in that color
and that distance from the caption string. The default
offset of 9 should work well in most cases.
N is an integer from 1 onward, like for the dataN option.
This lets you specify multiple strings to draw.
Note: you cannot use builtin GD fonts like gdTinyFont for
captions, you have to use a real TTF font.
This uses the GD stringTTF method, see GD. Colour names are
indexed using the GD::Graph::colour builtins (see above),
fonts are resolved by font path or relative to DocumentRoot,
parameters are processed as per "DATA TYPES".
Angle is in degrees, you will primarily use angle 0 for
normal left-to-right text. $x and $y are pixel coordinates
from the upper left corner. $fontname is the name of a
true-type font that will be found in the font path "FONTS".
Example:
http://isis/chart?data1=[1,2,3,4,5]&
caption1=(1,arial.ttf,9,0,30,30,Hello,red)
To draw the box around the caption as a dashed or dotted
line use:
gd_set_style
This option sets the style for the special gdStyled color
index. It's simply a list of colors that becomes the pattern
for lines and such drawn with it. For example, to get a
dashed red line:
gd_set_style=(red,red,red,red,red,red,
gdTransparent,gdTransparent,
gdTransparent,gdTransparent);
The list can be arbitrarily long.
Note: at this time, the only place where you can use colors
of this style is for the box around a caption. Just specify
"gdStyled" as the color.
cache Boolean value which determines whether or not the image will
( run in 1.634 second using v1.01-cache-2.11-cpan-39bf76dae61 )