diff options
author | Mark Longair <mhl@pobox.com> | 2013-10-15 13:47:08 +0100 |
---|---|---|
committer | Mark Longair <mhl@pobox.com> | 2013-10-15 13:57:45 +0100 |
commit | f3ecb5b64229f5e566be3b8df3d7b87e9bb6dd75 (patch) | |
tree | 7cecaed74c9f30ad3c3c1df8f3cde434ab37f51c /public/javascripts/stats-graphs.js | |
parent | 7e1ed07ea7f6448b1fada769e04b0369fdd0a222 (diff) |
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.
Diffstat (limited to 'public/javascripts/stats-graphs.js')
-rw-r--r-- | public/javascripts/stats-graphs.js | 13 |
1 files changed, 13 insertions, 0 deletions
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; + } + }); + }); }); |