push @$sorted_items, $row;
}
- my $export_path = "public/export/$path/" . join('.', @columns);
- open(my $fh, '>', $export_path) || warn "ERROR: can't open $export_path: $!";
- foreach my $f ( 0 .. $#$filtered ) {
- print $fh join("\t", map {
- my $i = $data->{items}->[ $filtered->[$f] ];
- if ( ref $i->{$_} eq 'ARRAY' ) {
- join(',', @{ $i->{$_} });
- } else {
- dump $i->{$_};
- }
- } @columns),"\n";
+ if ( $self->param('export') ) {
+ my $export_path = "public/export/$path/" . join('.', @columns);
+ open(my $fh, '>', $export_path) || warn "ERROR: can't open $export_path: $!";
+ foreach my $f ( 0 .. $#$filtered ) {
+ print $fh join("\t", map {
+ my $i = $data->{items}->[ $filtered->[$f] ];
+ if ( ref $i->{$_} eq 'ARRAY' ) {
+ join(',', @{ $i->{$_} });
+ } else {
+ dump $i->{$_};
+ }
+ } @columns),"\n";
+ }
+ close($fh);
+ warn "export $export_path ", -s $export_path, " bytes\n";
}
- close($fh);
- warn "$export_path ", -s $export_path, " bytes\n";
warn "# test_changed ",dump( $test_changed );
my $c = { map { $_ => 1 } @columns };
my @plot;
foreach ( 1 .. $#$columns ) {
my $n = $_ + 1;
- push @plot, qq|"$dir/$url" using 1:$n title "$columns->[$_]" with linespoints|;
+ push @plot, qq|"$dir/$url" using 1:$n title "$columns->[$_]" with points|;
}
my $g = qq|
set terminal png
set output '$dir/$url.png'
+ |;
+
+ if ( my $timefmt = $self->session('timefmt') ) {
+ $g .= qq|
+
set xdata time
-set timefmt "%Y-%m-%d"
-#set format x "%d.%m."
-#set format x "%Y-%m-%d"
+set timefmt "$timefmt"
+set format x "$timefmt"
+
+ |;
+ }
+
#set xrange [ "2009-01-01":"2010-01-01" ]
#set yrange [ 0 : ]
-plot | . join(',', @plot) . "\n";
+ $g .= "\n\nplot " . join(',', @plot) . "\n";
warn "gnuplot $g";
<input type=submit value="refresh">
+% my $export = param('export') || session('export');
+% session('export', $export );
+<input type=checkbox name=export value=1 title="export" <%= $export ? 'checked' : '' %> >
+% my $timefmt = param('timefmt') || session('timefmt');
+% session('timefmt', $timefmt );
+timefmt: <input name=timefmt value="<%= $timefmt %>">
+
</form>
+% if ( $export ) {
<img id=gnuplot src="/gnuplot">
+% }
<%= include 'data/items/' . session('show') %>