1package Template::Plugin::GD::Graph::lines; 2 3use strict; 4use warnings; 5use base qw( GD::Graph::lines Template::Plugin ); 6 7our $VERSION = sprintf("%d.%02d", q$Revision: 1.58 $ =~ /(\d+)\.(\d+)/); 8 9sub new { 10 my $class = shift; 11 my $context = shift; 12 return $class->SUPER::new(@_); 13} 14 15sub set { 16 my $self = shift; 17 push(@_, %{pop(@_)}) if ( @_ & 1 && ref($_[@_-1]) eq "HASH" ); 18 $self->SUPER::set(@_); 19} 20 21 22sub set_legend { 23 my $self = shift; 24 $self->SUPER::set_legend(ref $_[0] ? @{$_[0]} : @_); 25} 26 271; 28 29__END__ 30 31 32=head1 NAME 33 34Template::Plugin::GD::Graph::lines - Create line graphs with axes and legends 35 36=head1 SYNOPSIS 37 38 [% USE g = GD.Graph.lines(x_size, y_size); %] 39 40=head1 EXAMPLES 41 42 [% FILTER null; 43 USE g = GD.Graph.lines(300,200); 44 x = [1, 2, 3, 4]; 45 y = [5, 4, 2, 3]; 46 g.set( 47 x_label => 'X Label', 48 y_label => 'Y label', 49 title => 'Title' 50 ); 51 g.plot([x, y]).png | stdout(1); 52 END; 53 -%] 54 55 [% FILTER null; 56 data = [ 57 ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", 58 "Sep", "Oct", "Nov", "Dec", ], 59 [-5, -4, -3, -3, -1, 0, 2, 1, 3, 4, 6, 7], 60 [4, 3, 5, 6, 3,1.5, -1, -3, -4, -6, -7, -8], 61 [1, 2, 2, 3, 4, 3, 1, -1, 0, 2, 3, 2], 62 ]; 63 64 USE my_graph = GD.Graph.lines(); 65 66 my_graph.set( 67 x_label => 'Month', 68 y_label => 'Measure of success', 69 title => 'A Simple Line Graph', 70 71 y_max_value => 8, 72 y_min_value => -8, 73 y_tick_number => 16, 74 y_label_skip => 2, 75 box_axis => 0, 76 line_width => 3, 77 zero_axis_only => 1, 78 x_label_position => 1, 79 y_label_position => 1, 80 81 x_label_skip => 3, 82 x_tick_offset => 2, 83 84 transparent => 0, 85 ); 86 my_graph.set_legend("Us", "Them", "Others"); 87 my_graph.plot(data).png | stdout(1); 88 END; 89 -%] 90 91=head1 DESCRIPTION 92 93The GD.Graph.lines plugin provides an interface to the GD::Graph::lines 94class defined by the GD::Graph module. It allows one or more (x,y) data 95sets to be plotted as y versus x lines with axes and legends. 96 97See L<GD::Graph> for more details. 98 99=head1 AUTHOR 100 101Thomas Boutell wrote the GD graphics library. 102 103Lincoln D. Stein wrote the Perl GD modules that interface to it. 104 105Martien Verbruggen wrote the GD::Graph module. 106 107Craig Barratt E<lt>craig@arraycomm.comE<gt> wrote the original GD 108plugins for the Template Toolkit (2001). 109 110Andy Wardley E<lt>abw@cpan.orgE<gt> extracted them from the TT core 111into a separate distribution for TT version 2.15. 112 113=head1 COPYRIGHT 114 115Copyright (C) 2001 Craig Barratt E<lt>craig@arraycomm.comE<gt>, 1162006 Andy Wardley E<lt>abw@cpan.orgE<gt>. 117 118GD::Graph is copyright 1999 Martien Verbruggen. 119 120This module is free software; you can redistribute it and/or 121modify it under the same terms as Perl itself. 122 123=head1 SEE ALSO 124 125L<Template::Plugin::GD>, L<Template::Plugin::GD::Graph::lines3d>, L<Template::Plugin::GD::Graph::bars>, L<Template::Plugin::GD::Graph::bars3d>, L<Template::Plugin::GD::Graph::points>, L<Template::Plugin::GD::Graph::linespoints>, L<Template::Plugin::GD::Graph::area>, L<Template::Plugin::GD::Graph::mixed>, L<Template::Plugin::GD::Graph::pie>, L<Template::Plugin::GD::Graph::pie3d>, L<GD> 126 127=cut 128 129# Local Variables: 130# mode: perl 131# perl-indent-level: 4 132# indent-tabs-mode: nil 133# End: 134# 135# vim: expandtab shiftwidth=4: 136