1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
use strict;
use warnings;
package Jifty::Plugin::Chart::Renderer;
use base qw/Jifty::Object/;
=head1 NAME
Jifty::Plugin::Chart::Renderer - Base class for chart rendering classes
=head1 SYNOPSIS
In your F<config.yml>:
Plugins:
- Chart:
DefaultRenderer: MyApp::Renderer
In F<lib/MyApp/Renderer.pm>:
package MyApp::Renderer;
use base qw/ Jifty::Plugin::Chart::Renderer /;
sub init {
my $self = shift;
# Handle any required initialization, like required CSS, JS, etc.
}
sub render {
my $self = shift;
my %args = @_;
# Output your chart
Jifty->web->out( #{ Output your chart here... } );
# You could also return it as a string...
return;
}
=head1 METHODS
Your renderer implementation must subclass this package and implement the following methods:
=head2 new
This is the constructor. Don't override this directly. Instead implement L</init>.
=cut
sub new {
my $class = shift;
my $self = bless {}, $class;
$self->init( @_ );
return $self;
}
=head2 init
$renderer->init();
This is called by C<new> immediately after constructing the object. It is passed a param hash from the config file. Subclasses should implement this method to do any required initialization such as letting Jifty know about required CSS files, JS files, etc.
=cut
sub init {}
=head2 render
Jifty->web->out($renderer->render(%args));
See L<Jifty::Plugin::Chart::Web> for the arguments. It must (at least) accept the arguments given to the L<Jifty::Plugin::Chart::Web/chart> method.
The C<render> method may either return it's output or print it out using L<Jifty::Web::out>.
=cut
sub render {}
=head1 SEE ALSO
L<Jifty::Plugin::Chart::Web>, L<Jifty::Plugin::Chart::Renderer::Chart>
=head1 AUTHOR
Andrew Sterling Hanenkamp C<< <andrew.hanenkamp@boomer.com> >>
=head1 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.
=cut
1;
|