diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/public_body_controller.rb | 20 | ||||
-rw-r--r-- | app/views/public_body/statistics.html.erb | 6 |
2 files changed, 18 insertions, 8 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index 1f7032eed..505325df3 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -201,7 +201,7 @@ class PublicBodyController < ApplicationController raise ActiveRecord::RecordNotFound.new("Page not enabled") end - per_graph = 8 + per_graph = 10 minimum_requests = AlaveteliConfiguration::minimum_requests_for_statistics # Make sure minimum_requests is > 0 to avoid division-by-zero minimum_requests = [minimum_requests, 1].max @@ -251,17 +251,27 @@ class PublicBodyController < ApplicationController minimum_requests) end - data_to_draw = { + # We just need the URL and name of each public body: + data['public_bodies'].map! { |pb| + {'name' => pb.name, 'url' => public_body_path(pb)} + } + + data_to_draw = Hash.new { |h, k| h[k] = [] } + data_to_draw.update({ 'id' => "#{column}-#{highest ? 'highest' : 'lowest'}", 'x_axis' => _('Public Bodies'), 'y_axis' => graph_properties[:y_axis], 'errorbars' => percentages, - 'title' => graph_properties[:title]} + 'title' => graph_properties[:title] + }) if data data_to_draw.update(data) - data_to_draw['x_values'] = data['public_bodies'].each_with_index.map { |pb, i| i } - data_to_draw['x_ticks'] = data['public_bodies'].each_with_index.map { |pb, i| [i, pb.name] } + data['public_bodies'].each_with_index { |pb, i| + data_to_draw['x_values'].push i + data_to_draw['x_ticks'].push [i, pb['name']] + data_to_draw['tooltips'].push pb['name'] + } end @graph_list.push data_to_draw diff --git a/app/views/public_body/statistics.html.erb b/app/views/public_body/statistics.html.erb index 840af0c10..6ea253260 100644 --- a/app/views/public_body/statistics.html.erb +++ b/app/views/public_body/statistics.html.erb @@ -52,9 +52,9 @@ are due to him.") %></p> </tr> </thead> <tbody> - <% graph_data['x_ticks'].each_with_index do |pb_and_index, i| %> + <% graph_data['public_bodies'].each_with_index do |pb, i| %> <tr> - <td><%= pb_and_index[1] %></td> + <td><%= link_to pb['name'], pb['url'] %></td> <td class="statistic"><%= graph_data['y_values'][i].round %></td> </tr> <% end %> @@ -70,6 +70,6 @@ are due to him.") %></p> var graphs_data = <%= @graph_list.to_json.html_safe %>; </script> <!--[if lte IE 8]><%= javascript_include_tag 'excanvas.min.js' %><![endif]--> -<%= javascript_include_tag 'jquery.flot.min.js', 'jquery.flot.errorbars.min.js', 'jquery.flot.axislabels.js', 'stats-graphs.js' %> +<%= javascript_include_tag 'jquery.flot.min.js', 'jquery.flot.errorbars.min.js', 'jquery.flot.tickrotor.min.js', 'jquery.flot.axislabels.min.js', 'stats-graphs.js' %> </div> |