X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=lib%2FMojoFacets%2FGnuplot.pm;h=95aafa2cb0ac9378c1ff7a798e61b8c90044bc6c;hb=8f8de78aeb5d3a808e0afef5704e5e4b149e4d32;hp=0fd8b6a3e51e705a0a45ad6f06b2ec06c5c94f00;hpb=399e08d6b0c2be47482f1a0c0b9f25b7cfc99769;p=MojoFacets.git diff --git a/lib/MojoFacets/Gnuplot.pm b/lib/MojoFacets/Gnuplot.pm index 0fd8b6a..95aafa2 100644 --- a/lib/MojoFacets/Gnuplot.pm +++ b/lib/MojoFacets/Gnuplot.pm @@ -19,10 +19,12 @@ sub index { if ( -e "$dir/$url" ) { my @plot; - push @plot, qq|"$dir/$url" using 1:2 with linespoints|; + foreach ( 1 .. $#$columns ) { + my $n = $_ + 1; + push @plot, qq|"$dir/$url" using 1:$n title "$columns->[$_]" with linespoints|; + } - open(my $gnuplot, '|-', 'gnuplot') || die "gnuplot $!"; - print $gnuplot qq| + my $g = qq| set terminal png set output '$dir/$url.png' @@ -34,7 +36,13 @@ set timefmt "%Y-%m-%d" #set xrange [ "2009-01-01":"2010-01-01" ] #set yrange [ 0 : ] -plot |, join(',', @plot); +plot | . join(',', @plot) . "\n"; + +warn "gnuplot $g"; + + open(my $gnuplot, '|-', 'gnuplot') || die "gnuplot $!"; + print $gnuplot $g; + close $gnuplot; $self->redirect_to( "$url.png" ); #$self->render_text( "$url.png" );