X-Git-Url: http://git.rot13.org/?p=MojoFacets.git;a=blobdiff_plain;f=lib%2FMojoFacets%2FGnuplot.pm;fp=lib%2FMojoFacets%2FGnuplot.pm;h=eebf68c9d4bc81969b96cb44b6063f709fea7760;hp=ae8d5f385a5d9d640872cab89caf4be1941c83a0;hb=6ed3ddb8eeaade11c9566a827954192f60abb789;hpb=dc8ecd633f534d4021e18d1f394a3607913409c0 diff --git a/lib/MojoFacets/Gnuplot.pm b/lib/MojoFacets/Gnuplot.pm index ae8d5f3..eebf68c 100644 --- a/lib/MojoFacets/Gnuplot.pm +++ b/lib/MojoFacets/Gnuplot.pm @@ -8,6 +8,7 @@ use base 'Mojolicious::Controller'; use Data::Dump qw(dump); use Digest::MD5 qw(md5_hex); use Text::Unaccent::PurePerl; +use MojoFacets::Data; sub index { my $self = shift; @@ -16,11 +17,11 @@ sub index { my $path = $self->session('path') || return $self->redirect_to('/data/load'); my $with = $self->param('with') || 'points'; + my $gnuplot_hide = $self->every_param('gnuplot_hide'); + warn "## gnuplot_hide=",dump( $gnuplot_hide ); my $hide_columns; - if ( $self->param('gnuplot_hide') ) { - $hide_columns->{$_}++ foreach $self->param('gnuplot_hide'); - warn "## hide_columns ", dump $hide_columns; - } + $hide_columns->{$_}++ foreach @$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 ); @@ -41,6 +42,7 @@ sub index { my @plot; foreach ( 1 .. $#$columns ) { my $title = $columns->[$_]; + next if $hide_columns->{$title}; $title =~ s/_/ /g; my $n = $_ + 1 + $spaces; push @plot, qq|"$dir/$url" using 1:$n title "$title" with $with| unless $hide_columns->{ $title }; @@ -67,8 +69,9 @@ set format x "$timefmt" #set yrange [ 0 : ] $g .= "\n\nplot " . join(',', @plot) . "\n"; + $g =~ s/\n\n+/\n/sg; -warn "gnuplot $g"; +#warn "gnuplot $g"; open(my $gnuplot, '|-', 'gnuplot') || die "gnuplot $!"; print $gnuplot $g;