Author: spadkins
Date: Tue Jul 10 14:25:26 2007
New Revision: 9715
Modified:
p5ee/trunk/App-Widget-ChartDirector/lib/App/Widget/ChartDirector.pm
Log:
shortened months/years/dates on x-axis. don't scrunch.
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 Tue Jul
10 14:25:26 2007
@@ -630,7 +630,27 @@
$layer->setXData($x);
}
else {
- $chart->xAxis()->setLabels($x);
+ if ($x->[0] =~ /^[0-9]+\-[0-9]+$/) {
+ my %m = ("01"=>"Jan","02"=>"Feb","03"=>"Mar","04"=>"Apr",
+ "05"=>"May","06"=>"Jun","07"=>"Jul","08"=>"Aug",
+ "09"=>"Sep","10"=>"Oct","11"=>"Nov","12"=>"Dec");
+
+ for (my $i = 0; $i <= $#$x; $i++) {
+ if ($x->[$i] =~ /^([0-9]+)\-([0-9]+)$/){
+ my $yr = $1; my $month = $2;
+ $yr = substr($yr, 2, 2);
+ $x->[$i] = "$m{$month}$yr";
+ }
+ }
+ $chart->xAxis()->setLabels($x);
+ my $r = sprintf("%.0f", $#$x / 24);
+ my $w = sprintf("%.0f", (900 / $spec->{width}));
+ $r += $w;
+ $chart->xAxis()->setLabelStep($r);
+ }
+ else {
+ $chart->xAxis()->setLabels($x);
+ }
}
}
if ($spec->{graphtype} ne "pie" && $spec->{graphtype} ne "meter") {