diff options
author | Daniel Friesel <derf@finalrewind.org> | 2015-02-25 16:16:35 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2015-02-25 16:16:35 +0100 |
commit | 87fc996ecf568d6d73a57c3233e28421352057c1 (patch) | |
tree | 821d6d31b469b4fa95a853118a92f9e06d85f4ea /index.pl | |
parent | 4d17f9167fa57d14576fe96f580123805cdf1100 (diff) |
parametric bargraph is parametric
Diffstat (limited to 'index.pl')
-rw-r--r-- | index.pl | 67 |
1 files changed, 67 insertions, 0 deletions
@@ -25,6 +25,54 @@ app->attr( } ); +helper barplot_args => sub { + my ( $self ) = @_; + + return { + x => { + hour => { + desc => 'Stunde', + label => 'Angebrochene Stunde', + }, + line => { + desc => 'Linie', + }, + station => { + desc => 'Bahnhof', + }, + train_type => { + desc => 'Zugtyp', + }, + weekday => { + desc => 'Wochentag', + }, + weekhour => { + desc => 'Wochentag und Stunde', + label => 'Wochentag und angebrochene Stunde', + }, + }, + y => { + cancel_num => { + desc => 'Anzahl Zugausfälle', + label => 'Zugausfälle', + }, + cancel_rate => { + desc => 'Zugausfälle', + yformat => '.1%', + }, + delay => { + desc => 'Durchschnittliche Verspätung', + label => 'Minuten', + yformat => '.1f', + }, + realtime_rate => { + desc => 'Echtzeitdaten vorhanden', + yformat => '.1%', + }, + }, + }; +}; + helper count_unique_column => sub { my ( $self, $column ) = @_; my $dbh = $self->app->dbh; @@ -231,6 +279,25 @@ get '/all' => sub { get '/bar' => sub { my $self = shift; + + my $xsource = $self->param('xsource'); + my $ysource = $self->param('ysource'); + + my %args = %{$self->barplot_args}; + + if (not $self->param('xlabel')) { + $self->param(xlabel => $args{x}{$xsource}{label} // $args{x}{$xsource}{desc}); + } + if (not $self->param('ylabel')) { + $self->param(ylabel => $args{y}{$ysource}{label} // $args{y}{$ysource}{desc}); + } + if (not $self->param('xformat') and $args{x}{$xsource}{xformat}) { + $self->param(xformat => $args{x}{$xsource}{xformat}); + } + if (not $self->param('yformat') and $args{y}{$ysource}{yformat}) { + $self->param(yformat => $args{y}{$ysource}{yformat}); + } + $self->render('bargraph'); return; }; |