home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / perl / lines.pm < prev    next >
Encoding:
Perl POD Document  |  2004-01-30  |  5.0 KB  |  179 lines

  1. #============================================================= -*-Perl-*-
  2. #
  3. # Template::Plugin::GD::Graph::lines
  4. #
  5. # DESCRIPTION
  6. #
  7. #   Simple Template Toolkit plugin interfacing to the GD::Graph::lines
  8. #   package in the GD::Graph.pm module.
  9. #
  10. # AUTHOR
  11. #   Craig Barratt   <craig@arraycomm.com>
  12. #
  13. # COPYRIGHT
  14. #   Copyright (C) 2001 Craig Barratt.  All Rights Reserved.
  15. #
  16. #   This module is free software; you can redistribute it and/or
  17. #   modify it under the same terms as Perl itself.
  18. #
  19. #----------------------------------------------------------------------------
  20. #
  21. # $Id: lines.pm,v 1.57 2004/01/13 16:20:56 abw Exp $
  22. #
  23. #============================================================================
  24.  
  25. package Template::Plugin::GD::Graph::lines;
  26.  
  27. require 5.004;
  28.  
  29. use strict;
  30. use GD::Graph::lines;
  31. use Template::Plugin;
  32. use base qw( GD::Graph::lines Template::Plugin );
  33. use vars qw( $VERSION );
  34.  
  35. $VERSION = sprintf("%d.%02d", q$Revision: 1.57 $ =~ /(\d+)\.(\d+)/);
  36.  
  37. sub new
  38. {
  39.     my $class   = shift;
  40.     my $context = shift;
  41.     return $class->SUPER::new(@_);
  42. }
  43.  
  44. sub set
  45. {
  46.     my $self = shift;
  47.  
  48.     push(@_, %{pop(@_)}) if ( @_ & 1 && ref($_[@_-1]) eq "HASH" );
  49.     $self->SUPER::set(@_);
  50. }
  51.  
  52.  
  53. sub set_legend
  54. {
  55.     my $self = shift;
  56.     
  57.     $self->SUPER::set_legend(ref $_[0] ? @{$_[0]} : @_);
  58. }
  59.  
  60. 1;
  61.  
  62. __END__
  63.  
  64.  
  65. #------------------------------------------------------------------------
  66. # IMPORTANT NOTE
  67. #   This documentation is generated automatically from source
  68. #   templates.  Any changes you make here may be lost.
  69. #   The 'docsrc' documentation source bundle is available for download
  70. #   from http://www.template-toolkit.org/docs.html and contains all
  71. #   the source templates, XML files, scripts, etc., from which the
  72. #   documentation for the Template Toolkit is built.
  73. #------------------------------------------------------------------------
  74.  
  75. =head1 NAME
  76.  
  77. Template::Plugin::GD::Graph::lines - Create line graphs with axes and legends
  78.  
  79. =head1 SYNOPSIS
  80.  
  81.     [% USE g = GD.Graph.lines(x_size, y_size); %]
  82.  
  83. =head1 EXAMPLES
  84.  
  85.     [% FILTER null;
  86.         USE g = GD.Graph.lines(300,200);
  87.         x = [1, 2, 3, 4];
  88.         y = [5, 4, 2, 3];
  89.         g.set(
  90.                 x_label => 'X Label',
  91.                 y_label => 'Y label',
  92.                 title => 'Title'
  93.         );
  94.         g.plot([x, y]).png | stdout(1);
  95.        END;
  96.     -%]
  97.  
  98.     [% FILTER null;
  99.         data = [
  100.             ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
  101.                                          "Sep", "Oct", "Nov", "Dec", ],
  102.             [-5, -4, -3, -3, -1,  0,  2,  1,  3,  4,  6,  7],
  103.             [4,   3,  5,  6,  3,1.5, -1, -3, -4, -6, -7, -8],
  104.             [1,   2,  2,  3,  4,  3,  1, -1,  0,  2,  3,  2],
  105.         ];
  106.         
  107.         USE my_graph = GD.Graph.lines();
  108.  
  109.         my_graph.set(
  110.                 x_label => 'Month',
  111.                 y_label => 'Measure of success',
  112.                 title => 'A Simple Line Graph',
  113.  
  114.                 y_max_value => 8,
  115.                 y_min_value => -8,
  116.                 y_tick_number => 16,
  117.                 y_label_skip => 2,
  118.                 box_axis => 0,
  119.                 line_width => 3,
  120.                 zero_axis_only => 1,
  121.                 x_label_position => 1,
  122.                 y_label_position => 1,
  123.  
  124.                 x_label_skip => 3,
  125.                 x_tick_offset => 2,
  126.  
  127.                 transparent => 0,
  128.         );
  129.         my_graph.set_legend("Us", "Them", "Others");
  130.         my_graph.plot(data).png | stdout(1);
  131.        END;
  132.     -%]
  133.  
  134. =head1 DESCRIPTION
  135.  
  136. The GD.Graph.lines plugin provides an interface to the GD::Graph::lines
  137. class defined by the GD::Graph module. It allows one or more (x,y) data
  138. sets to be plotted as y versus x lines with axes and legends.
  139.  
  140. See L<GD::Graph> for more details.
  141.  
  142. =head1 AUTHOR
  143.  
  144. Craig Barratt E<lt>craig@arraycomm.comE<gt>
  145.  
  146.  
  147. The GD::Graph module was written by Martien Verbruggen.
  148.  
  149.  
  150. =head1 VERSION
  151.  
  152. 1.57, distributed as part of the
  153. Template Toolkit version 2.13, released on 30 January 2004.
  154.  
  155. =head1 COPYRIGHT
  156.  
  157.  
  158. Copyright (C) 2001 Craig Barratt E<lt>craig@arraycomm.comE<gt>
  159.  
  160. GD::Graph is copyright 1999 Martien Verbruggen.
  161.  
  162. This module is free software; you can redistribute it and/or
  163. modify it under the same terms as Perl itself.
  164.  
  165. =head1 SEE ALSO
  166.  
  167. L<Template::Plugin|Template::Plugin>, L<Template::Plugin::GD|Template::Plugin::GD>, L<Template::Plugin::GD::Graph::lines3d|Template::Plugin::GD::Graph::lines3d>, L<Template::Plugin::GD::Graph::bars|Template::Plugin::GD::Graph::bars>, L<Template::Plugin::GD::Graph::bars3d|Template::Plugin::GD::Graph::bars3d>, L<Template::Plugin::GD::Graph::points|Template::Plugin::GD::Graph::points>, L<Template::Plugin::GD::Graph::linespoints|Template::Plugin::GD::Graph::linespoints>, L<Template::Plugin::GD::Graph::area|Template::Plugin::GD::Graph::area>, L<Template::Plugin::GD::Graph::mixed|Template::Plugin::GD::Graph::mixed>, L<Template::Plugin::GD::Graph::pie|Template::Plugin::GD::Graph::pie>, L<Template::Plugin::GD::Graph::pie3d|Template::Plugin::GD::Graph::pie3d>, L<GD::Graph|GD::Graph>
  168.  
  169. =cut
  170.  
  171. # Local Variables:
  172. # mode: perl
  173. # perl-indent-level: 4
  174. # indent-tabs-mode: nil
  175. # End:
  176. #
  177. # vim: expandtab shiftwidth=4:
  178.