hide columns from gnuplot graph
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 12 Aug 2012 16:52:44 +0000 (18:52 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 12 Aug 2012 16:52:44 +0000 (18:52 +0200)
lib/MojoFacets/Gnuplot.pm
templates/data/items.html.ep

index 961220b..fc79de5 100644 (file)
@@ -16,6 +16,12 @@ sub index {
        my $path    = $self->session('path')    || return $self->redirect_to('/data/load');
        my $with    = $self->param('with') || 'points';
 
+       my $hide_columns;
+       if ( $self->param('gnuplot_hide') ) {
+               $hide_columns->{$_}++ foreach $self->param('gnuplot_hide');
+               warn "## hide_columns ", dump $hide_columns;
+       }
+
 #      my $name = join('.', 'items', map { my $n = unac_string($_); $n =~ s/\W+/_/g; $n } @$columns );
        my $name = MojoFacets::Data::__export_path_name( $path, 'items', @$columns );
 
@@ -28,8 +34,9 @@ sub index {
 
                my @plot;
                foreach ( 1 .. $#$columns ) {
+                       my $title = $columns->[$_];
                        my $n = $_ + 1;
-                       push @plot, qq|"$dir/$url" using 1:$n title "$columns->[$_]" with $with|;
+                       push @plot, qq|"$dir/$url" using 1:$n title "$title" with $with| unless $hide_columns->{ $title };
                }
 
                my $g = qq|
index 9a885d8..8a73e01 100644 (file)
@@ -57,7 +57,18 @@ timefmt: <input name=timefmt value="<%= $timefmt %>" placeholder="%d.%m.%Y %H:%M
 % if ( $export ) {
 with:
 %= select_field with => [qw( points dots lines steps )]
-<img id=gnuplot src="/gnuplot?timefmt=<%= $timefmt %>&with=<%= param('with') %>">
+
+<div style="float: right">
+Hide from graph:
+<ul>
+%  foreach my $column ( @$columns ) {
+ <li><label><%= check_box gnuplot_hide => $column %><%= $column %></label></li>
+%  }
+</ul>
+</div>
+
+% my @hide = map { ( gnuplot_hide => $_ ) } param('gnuplot_hide');
+<img id=gnuplot src="<%= url_for( '/gnuplot' )->query( timefmt => $timefmt, @hide, with => param('with') ) %>">
 % }
 
 </form>