replace _ with space in gnuplot title
[MojoFacets.git] / lib / MojoFacets / Gnuplot.pm
index fc79de5..ae8d5f3 100644 (file)
@@ -28,14 +28,21 @@ sub index {
        warn "# name $name\n";
 
        my $url = "/export/$path/$name";
-       my $dir = $self->app->home->rel_dir('public');
+       my $dir = $self->app->home->rel_file('public');
 
        if ( -e "$dir/$url" ) {
 
+               my $timefmt = $self->param('timefmt');
+
+               my $spaces = $timefmt;
+               $spaces =~ s/\S//g;
+               $spaces = length( $spaces );
+
                my @plot;
                foreach ( 1 .. $#$columns ) {
                        my $title = $columns->[$_];
-                       my $n = $_ + 1;
+                       $title =~ s/_/ /g;
+                       my $n = $_ + 1 + $spaces;
                        push @plot, qq|"$dir/$url" using 1:$n title "$title" with $with| unless $hide_columns->{ $title };
                }
 
@@ -46,7 +53,7 @@ set output '$dir/$url.png'
 
                |;
 
-               if ( my $timefmt = $self->param('timefmt') ) {
+               if ( $timefmt ) {
                        $g .= qq|
 
 set xdata time