Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Cvs P5ee > [svn:p5ee] r103...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 627 of 694
Post > Topic >>

[svn:p5ee] r10350 - p5ee/trunk/App-Widget-ChartDirector/lib/App/Widget

by spadkins@[EMAIL PROTECTED] Dec 3, 2007 at 08:34 AM

Author: spadkins
Date: Mon Dec  3 08:34:39 2007
New Revision: 10350

Modified:
   p5ee/trunk/App-Widget-ChartDirector/lib/App/Widget/ChartDirector.pm

Log:
Fix for scrunched labels

Modified:
p5ee/trunk/App-Widget-ChartDirector/lib/App/Widget/ChartDirector.pm
==============================================================================
---
p5ee/trunk/App-Widget-ChartDirector/lib/App/Widget/ChartDirector.pm	(original)
+++
p5ee/trunk/App-Widget-ChartDirector/lib/App/Widget/ChartDirector.pm	Mon
Dec  3 08:34:39 2007
@[EMAIL PROTECTED]
 -368,7 +368,13 @[EMAIL PROTECTED]
     my $plot_area = $c->setPlotArea($left_margin , $top_margin_adjusted,
         $width-$left_margin-$right_margin,
         $bottom_margin_adjusted);
- 
+
+    $spec->{plot_area_x}      = $left_margin;
+    $spec->{plot_area_y}      = $top_margin_adjusted;
+    $spec->{plot_area_width}  = $width - $left_margin - $right_margin;
+    $spec->{plot_area_height} = $bottom_margin_adjusted;
+    $spec->{plot_bgcolor}     = $plot_bgcolor;
+
     $plot_area->setBackground(hex($plot_bgcolor), hex($plot_bgcolor));
 
     $c->addTitle($spec->{title}, "arialbd.ttf", 12, hex($titlecolor)) if
($spec->{title});
@[EMAIL PROTECTED]
 -566,6 +572,53 @[EMAIL PROTECTED]
     return($c);
 }
 
+sub modify_plot_area {
+    &App::sub_entry if ($App::trace);
+    my ($self, $spec, $x, $c) = @[EMAIL PROTECTED]
    my $PIX_PER_CHAR     = 15.5;
+    my $MAX_LABEL_LENGTH = 3;
+    my $plot_area_x      = $spec->{plot_area_x};
+    my $plot_area_y      = $spec->{plot_area_y};
+    my $plot_area_width  = $spec->{plot_area_width};
+    my $plot_area_height = $spec->{plot_area_height};
+
+    #print STDERR "plot_area_x      = [$plot_area_x]\n";
+    #print STDERR "plot_area_y      = [$plot_area_y]\n";
+    #print STDERR "plot_area_width  = [$plot_area_width]\n";
+    #print STDERR "plot_area_height = [$plot_area_height]\n";
+
+    my $max_length_x   = 0;
+    my $total_length_x = 0;
+    for (my $i = 0; $i <= $#$x; $i++) {
+        if (length($x->[$i]) > $max_length_x) {
+            $max_length_x = length($x->[$i]);
+        }
+        $total_length_x = $total_length_x + length($x->[$i]);
+    }
+
+    #print STDERR "max_length_x   = [$max_length_x]\n";
+    #print STDERR "total_length_x = [$total_length_x]\n";
+    #print STDERR "tlx * $PIX_PER_CHAR = [",$total_length_x *
$PIX_PER_CHAR,"]\n";
+    
+    if ($total_length_x * $PIX_PER_CHAR > $plot_area_width && $x->[0] !~
/^\d+-\d+/) {
+        if ($max_length_x > $MAX_LABEL_LENGTH) {
+
+            $c->xAxis()->setLabels($spec->{y_labels})->setFontAngle(45);
+
+            my $mod_plot_area_height = $plot_area_height -
ceil($max_length_x * 4.8);
+            #print STDERR "mod_plot_area_height   =
[$mod_plot_area_height]\n";
+
+            my $plot_area = $c->setPlotArea($plot_area_x, $plot_area_y,
+                                    $plot_area_width,
$mod_plot_area_height);
+
+            $plot_area->setBackground(hex($spec->{plot_bgcolor}),
hex($spec->{plot_bgcolor}));
+        }
+    }
+
+    &App::sub_exit() if ($App::trace);
+}
+
 sub write_bar_graph_image {
     &App::sub_entry if ($App::trace);
     my ($self, $spec) = @[EMAIL PROTECTED]
 -575,6 +628,10 @[EMAIL PROTECTED]
     my ($layer);
     my $data_set_colors;
 
+    if ($spec->{module_cd} eq 'D') {
+        $self->modify_plot_area($spec, $x, $c);
+    }
+
     if ($spec->{data_set_colors}) {
        foreach my $color ( split(/,(?:\s+)?/, $spec->{data_set_colors}) )
{
            $color =~ s/^#//;




 1 Posts in Topic:
[svn:p5ee] r10350 - p5ee/trunk/App-Widget-ChartDirector/lib/App/
spadkins@[EMAIL PROTECTED  2007-12-03 08:34:40 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu May 15 1:19:11 CDT 2008.