NAME

Image::Magick::BarChart::Bar - Bar objects used by the BarChart module

DESCRIPTION

Image::Magick::BarChart::Bar is an object used by the BarChart package to represent individual bars within a given chart. Essentially, the BarChart package acts as a collector/controller of these objects. Most of the attributes that affect a given bar will be set through calls to the BarChart package [through parameters to addBar()]. Instances of this package can also be created and passed to addBar() directly.

See the documentation for Image::Magick::BarChart for more details about the method addBar.

METHODS

This package offers only two public methods: new(), which is a constructor, and draw(), which paints the object on a canvas. As with the main BarChart package, most of the functionality is implemented through parameters to the constructor. Most parameters are instance variables that apply to the current bar only. If this is not the case, it will be noted. The parameters are as follows:

number

number sets one of two values. If the bar is being drawn using square units, this number represents how many units will be drawn. If the bar is being drawn as a percentage, this number is the number which will be divided by maximum to arrive at that percentage (assuming the default comparison function is being used).

maximum

maximum sets the maximum number used in percentage calculation. In other words, this number is equal to 100%. Note that if this parameter is set, the bar will be drawn using the percentage method. If it is not set, the unit method will be used.

comparison

comparison is a subroutine reference that calculates the percentage filled by a given bar. When the class calls it, it is passed number and maximum. It is assumed to return a numeric value. The default comparison routine returns number/maximum. This is a class variable, and applies to all bars in the current graph.

maxPixels

maxPixels is the largest amount of pixels filled by bars in the current graph. In other words, maxPixels will be the length or height of a bar if it is filled 100%. If the bar is being drawn in units instead of through the percentage method, this parameter will not be used. This is a class variable, and applies to all bars in the current graph.

unitSize

unitSize sets the number of pixels in height and width a unit will consist of when drawing the current bar. For example, a value of 20 will result in 20x20 square units being used to draw the bar.

color

color is the fill color used for the current bar. This value is passed directly to Image::Magick, and can take any form accepted by that module. This includes text names for various common colors, such as 'red', as well as RGB values, such as #FF0000.

vertical

vertical is a boolean value which, if set, results in bars being drawn from the bottom of the canvas to the top, instead of left to right.

font

font is another parameter that gets passed directly to Image::Magick. Obviously enough, it is the font to be used when associating text with any bar. The format of this value is as required by Image::Magick. This is a class variable, and applies to all bars in the current graph.

fontSize

fontSize is quite obviously the size of the font used when associating text with a bar. This is given in number of pixels. This is a class variable, and applies to all bars in the current graph.

text

text is the text description associated with the current bar.

textSpace

textSpace is the number of pixels reserved on the canvas for text. This open area will be placed immediately above the bar, in the case of a vertical graph, or after it, in the case of horizontal. The default is 100 pixels.

skip

skip is the number of pixels of space used to distance the text associated with a bar from the actual bar itself. By default, this is 2 pixels. Note that if a negative value is passed in, it is possible to position the text inside of the bar itself.

barStartX

barStartX is the starting X coordinate for the current bar.

barStartY

barStartY is the starting Y coordinate for the current bar.

debug

debug is a boolean flag that, if given a true value, tells the module to print basic diagnostic messages as work is performed. These messages will appear on STDERR.

AUTHOR

Alexander Christian Westholm, <awestholm@verizon.net>

SEE ALSO

Image::Magick, Image::Magick::BarChart

COPYRIGHT

Copyright 2004, Alexander Christian Westholm.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.