diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-10-30 15:26:09 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-10-30 15:26:09 +0000 |
commit | 27f305b1fdaa450323719c5d78765ca99d1142e1 (patch) | |
tree | 03738d94f092b6ba5cc2e8e2840dce2da63eb442 /app/controllers/public_body_controller.rb | |
parent | 5964dc79a0e6608529ccf610460d1928811e8ef0 (diff) | |
parent | 78b3f77968b3621f7f307b3f2764563f74c923c6 (diff) |
Merge remote-tracking branch 'origin/stats-graphs-improvements' into rails-3-develop
Diffstat (limited to 'app/controllers/public_body_controller.rb')
-rw-r--r-- | app/controllers/public_body_controller.rb | 20 |
1 files changed, 15 insertions, 5 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 |