summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-03-10 18:54:43 +0100
committerDaniel Friesel <derf@finalrewind.org>2015-03-10 18:54:43 +0100
commit4e14b8714169e8f3869bffaded3bda9c9888e047 (patch)
treec0331441e9d8bda5b68d7448f2ec97e72af2512a
parent476b02157b9520f1c80a8393c86e7111508c90c7 (diff)
bargraph: set title
-rw-r--r--index.pl44
-rw-r--r--templates/bargraph.html.ep2
2 files changed, 41 insertions, 5 deletions
diff --git a/index.pl b/index.pl
index d938a4a..6a7805f 100644
--- a/index.pl
+++ b/index.pl
@@ -415,17 +415,53 @@ get '/all' => sub {
get '/bar' => sub {
my $self = shift;
- my $xsource = $self->param('xsource');
- my $ysource = $self->param('ysource');
- my $msgnum = $self->param('msgnum');
+ my $xsource = $self->param('xsource');
+ my $ysource = $self->param('ysource');
+ my $want_msg = $self->param('want_msg');
+ my $msgnum = $self->param('msgnum');
+ my ( $title, @title_filter_strings );
my %args = %{ $self->barplot_args };
- if ( $self->param('want_msg') ) {
+ if ($want_msg) {
$self->param( ysource => 'message_rate' );
$self->param( ylabel => $args{msg}{$msgnum}{desc} );
$self->param( yformat => '.1%' );
+ $title = sprintf( '"%s" pro %s',
+ $args{msg}{$msgnum}{desc},
+ $args{x}{$xsource}{desc} );
}
+ else {
+ $title = sprintf( '%s pro %s',
+ $args{y}{$ysource}{desc},
+ $args{x}{$xsource}{desc} );
+ }
+
+ if ( $self->param('filter_line') ) {
+ push( @title_filter_strings, 'Linie ' . $self->param('filter_line') );
+ }
+ if ( $self->param('filter_train_type') ) {
+ push( @title_filter_strings,
+ 'Zugtyp ' . $self->param('filter_train_type') );
+ }
+ if ( $self->param('filter_station') ) {
+ push(
+ @title_filter_strings,
+ 'in '
+ . Travel::Status::DE::IRIS::Stations::get_station(
+ $self->param('filter_station')
+ )->[1]
+ );
+ }
+ if ( $self->param('filter_destination') ) {
+ push( @title_filter_strings,
+ 'Züge nach ' . $self->param('filter_destination') );
+ }
+ if (@title_filter_strings) {
+ $title .= ' (' . join( ', ', @title_filter_strings ) . ')';
+ }
+
+ $self->param( title => $title );
if ( not $self->param('xlabel') ) {
$self->param( xlabel => $args{x}{$xsource}{label}
diff --git a/templates/bargraph.html.ep b/templates/bargraph.html.ep
index 5b6282d..f626fbd 100644
--- a/templates/bargraph.html.ep
+++ b/templates/bargraph.html.ep
@@ -3,7 +3,7 @@
%= javascript begin
show_bargraph('/2ddata.tsv?aggregate=<%= param('xsource') %>&metric=<%= param('ysource') %>&msgnum=<%= param('msgnum') %>&filter_line=<%= param('filter_line') %>&filter_train_type=<%= param('filter_train_type') %>&filter_station=<%= param('filter_station') %>&filter_destination=<%= param('filter_destination') %>&filter_delay_min=<%= param('filter_delay_min') %>&filter_delay_max=<%= param('filter_delay_max') %>',
- '<%= param('title') %>',
+ '<%== param('title') %>',
'<%= param('xlabel') %>', '<%= param('ylabel') %>', '<%= param('yformat') %>',
'<%= param('width') %>', '<%= param('height') %>');
% end