[COMMIT LOGREPORT] service/all/lib/Lire ChartType.pm,1.15,1.16
Joost van Baal
vanbaal at users.sourceforge.net
Sat Jul 29 20:00:18 CEST 2006
Update of /cvsroot/logreport/service/all/lib/Lire
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv31821
Modified Files:
ChartType.pm
Log Message:
Patch contributed by Stefan Schuermans in a message to Francis J. Lacoste,
Thursday 27 July 2006:
If ploticus is feeded with a single row containing a large Y-value (e.g.
"foobar 1100000000") after having done "#set yrange 0" the value is
interpreted as negative value. I've fixed this in Lire by adding some
code to get the maximum value and do "#set yrange 0 <maximum>". Then
ploticus works.
Index: ChartType.pm
===================================================================
RCS file: /cvsroot/logreport/service/all/lib/Lire/ChartType.pm,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ChartType.pm 23 Jul 2006 13:16:27 -0000 1.15
+++ ChartType.pm 29 Jul 2006 18:00:16 -0000 1.16
@@ -147,8 +147,6 @@
croak ref shift, "::get_vars unimplemented";
}
-=pod
-
=head2 write_parameters( $chart_config, $fh )
This method is used to write parameters to the ploticus file handle.
@@ -162,7 +160,7 @@
sub write_parameters {
my ( $self, $chart_config, $fh ) = @_;
- print $fh "#set x = 1\n#set yrange 0\n";
+ print $fh "#set x = 1\n";
my $title = $chart_config->get( 'title' )->as_value();
print $fh "#set title = $title\n" if $title;
my $xlabel = $chart_config->get( 'xlabel' )->as_value();
@@ -189,6 +187,10 @@
uses the get_vars() method to obtain the numerical variables that
should be written to the stream and the encode_value() method to
marshall values before writing them.
+Before any data is written to $fh the maximum value on the Y axis
+is determined and output as a ploticus setting. (ploticus fails if
+this is not set, a single bar is drawn and the value is greater than
+1.1e9.)
=cut
@@ -200,11 +202,31 @@
print $fh join( "\t", map { $_->name() } @vars ), "\n";
my @slice = map { $_->col_start() } @vars;
+ my @rows = ();
for ( my $i=0; $i < $subreport->nrows(); $i++ ) {
my $row = $subreport->getrow_by_idx( $i );
next unless defined $row->[ $case_var->col_start() ];
- print $fh join( "\t", map { $self->encode_value( $_ ) }
- @{$row}[@slice] ), "\n";
+ push @rows, [ map { $self->encode_value( $_ ) }
+ @{$row}[@slice] ];
+ }
+
+ my $yrange = -1;
+ foreach my $ro (@rows) {
+ my ($x, @values) = @{$ro};
+ foreach my $value (@values) {
+ $yrange = $value
+ if( $value =~ /^[+-]?[0-9]+\.?[0-9]*(e[+-]?[0-9]+)?$/
+ && $value > $yrange );
+ }
+ }
+ if( $yrange > 0 ) {
+ print $fh "#set yrange 0 $yrange\n";
+ } else {
+ print $fh "#set yrange 0\n";
+ }
+
+ foreach my $r (@rows) {
+ print $fh join( "\t", @{$r} ), "\n";
}
return ;
}
--
To UNSUBSCRIBE, email to commit-request at logreport.org with a subject of
"unsubscribe". Trouble? Send an email with subject "help" to
commit-request at logreport.org
More information about the Commit
mailing list