NAME
Jifty::Plugin::Chart::Web - Base class to add to Jifty::Web's ISA
DESCRIPTION
When the Jifty::Plugin::Chart is loaded, this class is added as a base class for Jifty::Web to add the "chart" method to that class.
METHODS
chart
Jifty->web->out(Jifty->web->chart(%args));
The arguments passed in %args
may include:
- type
-
This will be one of the following scalar values indicating the kind of chart. A given renderer may not support every type listed here. A renderer might support others in addition to these, but if it supports these it should use these names.
- points
-
This is the default value. A scatter plot with each dataset represented using differnet dot styles.
- lines
-
A line plot with each dataset presented as separate line.
- bars
-
A bar chart with each dataset set side-by-side.
- stackedbars
-
A bar chart with each dataset stacked on top of each other.
- pie
-
A pie chart with a single dataset representing the values for different pieces of the pie.
- horizontalbars
-
A bar chart turned sideways.
- area
-
An area chart uses lines to represent each dataset, but the lines are stacked on top of each other with filled areas underneath.
- width
-
This is the width the chart should take when rendered. This may be a number, indicating the width in pixels. It may also be any value that would be appropriate for the
width
CSS property.Defaults to
undef
, which indicates that the chart will take on whatever size the box it is in will be. See "CSS FOR CHARTS". - height
-
This is the height the chart should take when rendered. This may be a number, indicating the height in pixels. It may also be any value that would be appropriate for the
height
CSS property.Defaults to
undef
, which indicates that the chart will take on whatever size the box it is in will be. See "CSS FOR CHARTS". - data
-
An array of arrays containing the data. The first array in the parent array is a list of labels. Each following array is the set of data points matching each label in the first array.
Defaults to no data (i.e., it must be given if anything useful is to happen).
- class
-
This allows you to associated an additional class or classes to the element containing the chart. This can be a string containing on or more class names separated by spaces or an array of class names.
- renderer
-
This allows you to use a different renderer than the one configured in config.yml. Give the renderer as a class name, which will be initialized for you.
- options
-
This is a hash containing additional options to pass to the renderer and are renderer specific. This may include anything that is not otherwise set by one of the other options above.
Here's an example:
<% Jifty->web->chart(
type => 'Pie',
width => '100%',
height => '300px',
data => sub {
[
[ 2004, 2005, 2006, 2007 ],
[ 26, 37, 12, 42 ]
];
},
class => 'visualizeronimicon',
) %>
Be sure to output anything returned by the method (unless it returns undef).
CSS FOR CHARTS
The chart API allows you to build the charts without explicit pixel widths and heights. In fact, you can not specify width
and height
and perform the styling in your regular CSS stylesheets by using the "chart" class associated with every chart or by using custom classes with the class
argument.
See your renderer class documentation for further details.
JAVASCRIPT FOR CHARTS
Charts typically require JavaScript to render properly. If the client does not have JavaScript available, the chart may not work or could look very bad.
If you are using one of the image based renderers like Jifty::Plugin::Chart::Renderer::Chart, it is recommended that you stick with pixel widths if you expect clients with limited or no JavaScript support.
SEE ALSO
Jifty::Plugin::Chart, Jifty::Plugin::Chart::Renderer
AUTHOR
Andrew Sterling Hanenkamp <andrew.hanenkamp@boomer.com>
COPYRIGHT AND LICENSE
Copyright 2007 Boomer Consulting, Inc.
This is free software and may be modified and distributed under the same terms as Perl itself.