[Bps-public-commit] r11231 - in WebChart/lib: WebChart

sunnavy at bestpractical.com sunnavy at bestpractical.com
Thu Mar 27 08:27:32 EDT 2008


Author: sunnavy
Date: Thu Mar 27 08:27:31 2008
New Revision: 11231

Modified:
   WebChart/lib/WebChart.pm
   WebChart/lib/WebChart/Renderer.pm

Log:
added width and height method

Modified: WebChart/lib/WebChart.pm
==============================================================================
--- WebChart/lib/WebChart.pm	(original)
+++ WebChart/lib/WebChart.pm	Thu Mar 27 08:27:31 2008
@@ -10,7 +10,7 @@
 use base qw/Class::Accessor::Fast/;
 
 __PACKAGE__->mk_accessors(
-    qw/renderer img_dir web_img_dir css_class/);
+    qw/renderer img_dir web_img_dir css_class width height/);
 
 =head2 new
 
@@ -18,8 +18,14 @@
 
 e.g.
 
-%args = ( renderer => 'WebChart::Renderer::Chart', img_dir => '/tmp', 
-       web_img_dir => '/charts', css_class => 'foo bar' )
+%args = (
+    renderer    => 'WebChart::Renderer::Chart',
+    img_dir     => '/tmp',
+    web_img_dir => '/charts',
+    css_class   => 'foo bar',
+    width       => 400,
+    height      => 300,
+  );
 
 =cut
 
@@ -60,15 +66,17 @@
     $self->web_img_dir( $args{web_img_dir} || '/charts' );
 
     $self->css_class( $args{css_class} );
+    $self->width( $args{width}   || 400 );
+    $self->height( $args{height} || 300 );
 }
 
 =head2 render
 
 render pictures.
 
-%args = ( width => 400, height => 300, data = [ ... ] )
-you can also supply img_dir, web_img_dir and css_class args to overwrite 
-things the WebChart object already have
+%args = ( type => 'bars', data = [ ... ] )
+you can also supply img_dir, web_img_dir, css_class, width and height args 
+to overwrite the default values.
 
 =cut
 
@@ -77,7 +85,8 @@
     return $self->renderer->render(
         (
             map { $_ => $self->$_ } (
-                qw/img_dir web_img_dir css_class/
+                qw/img_dir web_img_dir css_class width
+                  height/
             )
         ),
         @_,

Modified: WebChart/lib/WebChart/Renderer.pm
==============================================================================
--- WebChart/lib/WebChart/Renderer.pm	(original)
+++ WebChart/lib/WebChart/Renderer.pm	Thu Mar 27 08:27:31 2008
@@ -33,7 +33,6 @@
 
 sub render {
     my $self = shift;
-    my %args = ( width => 400, height => 300, @_ );
     for (qw/type data/) {
         croak "need $_ arg" unless $args{type};
     }



More information about the Bps-public-commit mailing list