From f3ecb5b64229f5e566be3b8df3d7b87e9bb6dd75 Mon Sep 17 00:00:00 2001 From: Mark Longair Date: Tue, 15 Oct 2013 13:47:08 +0100 Subject: Make bars in public body statistics charts clickable Now if you click on the bar representing statistics for a particular public body, it will take you to that public body's page. In addition, the bars are highlighted when you hover over them. --- public/javascripts/stats-graphs.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'public/javascripts/stats-graphs.js') diff --git a/public/javascripts/stats-graphs.js b/public/javascripts/stats-graphs.js index f738427ae..7afbd20c1 100644 --- a/public/javascripts/stats-graphs.js +++ b/public/javascripts/stats-graphs.js @@ -56,6 +56,7 @@ $(document).ready(function() { } options = { + 'grid': { 'hoverable': true, 'clickable': true }, 'xaxis': { 'ticks': graph_data.x_ticks, 'rotateTicks': 90 @@ -84,5 +85,17 @@ $(document).ready(function() { plot = $.plot(graph_div, dataset, options); + + graph_div.bind("plotclick", function(event, pos, item) { + var i, pb, url, name; + if (item) { + i = item.dataIndex; + pb = graph_data.public_bodies[i]; + url = pb.url; + name = pb.name; + window.location.href = url; + } + }); + }); }); -- cgit v1.2.3