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] r101...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 606 of 694
Post > Topic >>

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

by spadkins@[EMAIL PROTECTED] Nov 1, 2007 at 01:15 PM

Author: spadkins
Date: Thu Nov  1 13:15:40 2007
New Revision: 10149

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

Log:
new changes from Cybage to fix labels that overlap by putting them at 45
degrees

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	Thu
Nov  1 13:15:40 2007
@[EMAIL PROTECTED]
 -269,7 +269,19 @[EMAIL PROTECTED]
         $left_margin = 20 + $y_label_len * 6;
         $left_margin += 20 if ($spec->{y_title});
     }
-    
+    my ($total_x_length, @[EMAIL PROTECTED]
);
+    if ($spec->{x_label_pos}) {
+        foreach (@[EMAIL PROTECTED]
){
+            $total_x_length += length($_) + 2; #Taking 2 as the gap value
 
+            push (@[EMAIL PROTECTED]
 length($_));
+        }
+        @[EMAIL PROTECTED]
 = sort { $a <=> $b} @[EMAIL PROTECTED]
        $self->{total_x_length} = $total_x_length;
+        $self->{width} = $width;   
+        if ($total_x_length > $width/8 && $x->[0] !~
/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/) {
+            $width += ($#$x) * ceil (3 * $#$x / 100 ) + 0.5 if ($#$x >
50);
+        }
+    }
     my $legend_pos = $spec->{legend_pos} || "default"; # Any one from
default, top or bottom
     my (@[EMAIL PROTECTED]
 $max_legend_length, $num_legend_columns,
$legend_width, $margin, $textsize, $number_legend_rows, $length_labels,
$length_labels_avg);
     my (@[EMAIL PROTECTED]
 $diff_largest_and_avg, $gap_legends);
@[EMAIL PROTECTED]
 -316,23 +328,42 @[EMAIL PROTECTED]
         if ($#{$spec->{y_labels}} <= 0) {
             $height = $spec->{height};  
         }
-    }   
+    }
+
+   
+    my $graph_height_increment = 0; 
+    my $fontsize = 10;
+    if ($spec->{x_label_pos}) {
+        if ($#$x > 30 && $total_x_length > $width/8 && $x->[0] !~
/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/) {
+            for (my $i = 30; $i <= $#$x; $i++ ) {
+                $fontsize = $fontsize - 0.1;
+                $fontsize = 1 if ($fontsize < 1);
+            }  
+            $fontsize += ceil(($width - $spec->{width})/$#$x) - 1 if
($#$x > 50);
+        }
+        $self->{fontsize} = $fontsize;
+        if ($total_x_length > $width/8  && $x->[0] !~
/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/) {
+            $graph_height_increment = 1/2 * $x_values[-1] * floor
($fontsize); 
+            $height += $graph_height_increment;   
+        }
+    }
+   
     my $c = new XYChart($width, $height);
-    
-    my $graph_adjusted_height = $height - $spec->{height};
+
+    my $graph_adjusted_height = $height -
$spec->{height}-$graph_height_increment;
     my ($top_margin_adjusted,$bottom_margin_adjusted);
 
     if ($legend_pos eq "top" ) {
         $top_margin_adjusted    = $top_margin+$graph_adjusted_height;
-        $bottom_margin_adjusted =
$height-$top_margin-$bottom_margin-$graph_adjusted_height;
+        $bottom_margin_adjusted =
$height-$top_margin-$bottom_margin-$graph_adjusted_height-$graph_height_increment;
     }
     elsif ($legend_pos eq "bottom") {
         $top_margin_adjusted    = $top_margin;
-        $bottom_margin_adjusted =
$height-$top_margin-$bottom_margin-$graph_adjusted_height;
+        $bottom_margin_adjusted =
$height-$top_margin-$bottom_margin-$graph_adjusted_height-$graph_height_increment;
     }
     else {
         $top_margin_adjusted    = $top_margin;
-        $bottom_margin_adjusted = $height-$top_margin-$bottom_margin;
+        $bottom_margin_adjusted =
$height-$top_margin-$bottom_margin-$graph_height_increment;
     }
     my $plot_area = $c->setPlotArea($left_margin , $top_margin_adjusted,
         $width-$left_margin-$right_margin,
@[EMAIL PROTECTED]
 -378,7 +409,12 @[EMAIL PROTECTED]
         my $graph_count = $spec->{graph_count} || 1; 
         $spec->{height} = $height if ($graph_count == 1);
     }
-    
+
+    if ($spec->{x_label_pos} && $total_x_length > $width/8  && $x->[0] !~
/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/) {
+        $spec->{height} = $height;
+        $spec->{width} = $width;
+    }
+        
     $c->yAxis()->setTitle($spec->{y_title}, "arial.ttf", 10,
hex($y_titlecolor)) if ($spec->{y_title});
     $c->setBackground(hex($bgcolor));
     $c->yAxis()->setLabelStyle("arial.ttf", 10, hex($y_labelcolor));
@[EMAIL PROTECTED]
 -670,6 +706,10 @[EMAIL PROTECTED]
             }
             else {
                 $chart->xAxis()->setLabels($x);
+                if ($spec->{x_label_pos}) {
+                    $chart->xAxis()->setLabels($x)->setFontAngle(45) if (
$self->{total_x_length} > $self->{width}/8 );
+                   
$chart->xAxis()->setLabels($x)->setFontSize($self->{fontsize}, 0) if ($#$x
> 30);
+                }
             } 
         }
     }




 1 Posts in Topic:
[svn:p5ee] r10149 - p5ee/trunk/App-Widget-ChartDirector/lib/App/
spadkins@[EMAIL PROTECTED  2007-11-01 13:15:42 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Tue May 13 6:11:08 CDT 2008.