]> git.imager.perl.org - imager-graph.git/commitdiff
calculate the y-axis tic-label widths based on the labels actually used
authorTony Cook <tony@develop-help.com>
Mon, 5 Jul 2010 11:14:47 +0000 (11:14 +0000)
committerTony Cook <tony@develop-help.com>
Mon, 5 Jul 2010 11:14:47 +0000 (11:14 +0000)
lib/Imager/Graph/Vertical.pm

index 8a2e38b249474aba9cf303f3f76aefa7dd0b79b9..d43253b37aaa7f3bc4e01a89d1205dd37da919d4 100644 (file)
@@ -1069,8 +1069,11 @@ sub _get_y_tic_width{
 
   my $max_width = 0;
   for my $count (0 .. $tic_count - 1) {
-    my $value = sprintf("%.2f", ($count*$interval)+$min);
+    my $value = ($count*$interval)+$min;
 
+    if ($interval < 1 || ($value != int($value))) {
+      $value = sprintf("%.2f", $value);
+    }
     my @box = $self->_text_bbox($value, 'legend');
     my $width = $box[2] - $box[0];