[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GT] SVN Commit r582 - trunk/GT/Graphics



Author: thomas
Date: 2008-03-21 00:32:53 +0100 (Fri, 21 Mar 2008)
New Revision: 582

Modified:
   trunk/GT/Graphics/Tools.pm
Log:
Add handling of space parameter when building axis.

Modified: trunk/GT/Graphics/Tools.pm
===================================================================
--- trunk/GT/Graphics/Tools.pm	2008-03-20 19:30:45 UTC (rev 581)
+++ trunk/GT/Graphics/Tools.pm	2008-03-20 23:32:53 UTC (rev 582)
@@ -66,7 +66,7 @@
 
 =cut
 sub build_axis_for_timeframe {
-    my ($prices, $timeframe, $put_label, $period) = @_;
+    my ($prices, $timeframe, $put_label, $period, $space) = @_;
     $period    = 1 if (! defined($period));
     $put_label = 1 if (! defined($put_label));
 
@@ -98,6 +98,16 @@
 
     # Remove the labels if we don't want labels
     if (! $put_label) { foreach (@axis) { $_->[1] = ""; } }
+    my $skip = 0;
+    if ( $space ) {
+      if ($space < 15) {
+	foreach (@axis) { $_->[1] = "" if ($skip%6); $skip++;  }
+      } elsif ($space < 20) {
+	foreach (@axis) { $_->[1] = "" if ($skip%3); $skip++;  }
+      } elsif ($space < 30) { 
+	foreach (@axis) { $_->[1] = "" if ($skip%2); $skip++;  }
+      }
+    }
 
     return \
AT
axis;
 }
@@ -141,6 +151,7 @@
     } else {
 	$interval = ($max - $min) / 4;
     }
+    # Due to rounding small interval may show up negative?
     my $log = ($interval != 0) ? log($interval) / log(10) : 0;
     my $power = int($log - (($log < 0) ? 1.5 : 0.5));
     my $inc = 10 ** $power;