summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-02-26 19:57:19 +0100
committerDaniel Friesel <derf@finalrewind.org>2015-02-26 19:57:19 +0100
commite1d5664f696a2f33a34a63e62aa8de05388f8574 (patch)
tree56bfa2699f4eff5f2429198f899a19348a085c47
parentab02b9ddec2c8fb6bc114ddcd1f37cac6a84a28d (diff)
plot messages by anything
-rw-r--r--index.pl15
-rw-r--r--templates/barform.html.ep10
-rw-r--r--templates/bargraph.html.ep2
3 files changed, 25 insertions, 2 deletions
diff --git a/index.pl b/index.pl
index 5ad92f5..6fb9832 100644
--- a/index.pl
+++ b/index.pl
@@ -28,6 +28,13 @@ app->attr(
helper barplot_args => sub {
my ( $self ) = @_;
+ my %translation = Travel::Status::DE::IRIS::Result::dump_message_codes();
+ my $messages;
+
+ for my $key (keys %translation) {
+ $messages->{$key} = { desc => $translation{$key} };
+ }
+
return {
x => {
hour => {
@@ -80,6 +87,7 @@ helper barplot_args => sub {
yformat => '.1%',
},
},
+ msg => $messages,
};
};
@@ -304,9 +312,16 @@ get '/bar' => sub {
my $xsource = $self->param('xsource');
my $ysource = $self->param('ysource');
+ my $msgnum = $self->param('msgnum');
my %args = %{$self->barplot_args};
+ if ($self->param('want_msg')) {
+ $self->param(ysource => 'message_rate');
+ $self->param(ylabel => $args{msg}{$msgnum}{desc});
+ $self->param(yformat => '.1%');
+ }
+
if (not $self->param('xlabel')) {
$self->param(xlabel => $args{x}{$xsource}{label} // $args{x}{$xsource}{desc});
}
diff --git a/templates/barform.html.ep b/templates/barform.html.ep
index 4d43f42..0e0c793 100644
--- a/templates/barform.html.ep
+++ b/templates/barform.html.ep
@@ -1,8 +1,16 @@
%= form_for bar => begin
-Bargraph:
+%= radio_button 'want_msg' => 0
+Allgemeiner Bargraph:
% my %yargs = %{$self->barplot_args->{y}};
% my @yarg_keys = sort keys %yargs;
%= select_field ysource => [map {[$yargs{$_}->{desc}, $_]} @yarg_keys]
+<br/>
+%= radio_button 'want_msg' => 1
+Meldungs-Bargraph:
+% %yargs = %{$self->barplot_args->{msg}};
+% @yarg_keys = sort keys %yargs;
+%= select_field msgnum => [map {[$yargs{$_}->{desc}, $_]} @yarg_keys]
+<br/>
aufgeteilt nach
% my %xargs = %{$self->barplot_args->{x}};
% my @xarg_keys = sort keys %xargs;
diff --git a/templates/bargraph.html.ep b/templates/bargraph.html.ep
index 3d5eda2..7e989e6 100644
--- a/templates/bargraph.html.ep
+++ b/templates/bargraph.html.ep
@@ -2,7 +2,7 @@
%= javascript begin
-show_bargraph('/2ddata.tsv?aggregate=<%= param('xsource') %>&metric=<%= param('ysource') %>',
+show_bargraph('/2ddata.tsv?aggregate=<%= param('xsource') %>&metric=<%= param('ysource') %>&msgnum=<%= param('msgnum') %>',
'<%= param('title') %>',
'<%= param('xlabel') %>', '<%= param('ylabel') %>', '<%= param('yformat') %>',
'<%= param('width') %>', '<%= param('height') %>');