google.load('visualization','1',{packages:['scatterchart']});$(function(){$.tablesorter.addParser({id:'commas',is:function(s){return false;},format:function(s){return s.replace(',','','g');},type:'numeric'});$('body').addClass('javascript');var tabs=$('ul#tabs li a').click(function(){$('ul#tabs li').removeClass('active');var self=$(this);var referenceTable=self.attr('href');$('div.tab').each(function(){var div=$(this);if('#'+div.attr('id')!=referenceTable){div.hide();}else{div.show();self.parent().addClass('active');}});return false;});$('#all').tablesorter({headers:{7:{sorter:'commas'}},sortList:[[4,0]]});$('#all').prev().append(' Click on any of the column headers to sort by that column.');$('#intro').append(' As an added bonus, the scatter plot below shows the relation between expenses claimed and distance from Westminster, based on the price per mile travelled (i.e. travel expenses claimed divided by distance from Parliament).');$('#chart').before('<p>You can click on individual plots on the chart to see more information, and order the table by any column by clicking on its header.</p>');$('#travel').tablesorter({sortList:[[6,1]]});var tableData=$('#travel tbody tr');var data=new google.visualization.DataTable();data.addColumn('number','Miles from Parliament');data.addColumn('number','Pounds per mile');data.addRows(tableData.length);var i=0;tableData.each(function(){var cells=$(this).children();var mpName=cells.eq(0).text();var mpParty=cells.eq(1).text();var mpConstituency=cells.eq(2).text();var mpAttendance=cells.eq(3).text();var mpDistance=parseFloat(cells.eq(5).text());var mpPPM=cells.eq(6).text();data.setCell(i,0,mpDistance,[mpName,' (',mpParty,')\n',mpDistance,' miles from Parliament'].join(''));data.setCell(i,1,parseFloat(mpPPM.replace('£','')),[mpPPM,' per mile (',mpAttendance,' attendance)'].join(''));i++;});var chart=new google.visualization.ScatterChart($('#chart').get(0));chart.draw(data,{axisColor:'#ccc',backgroundColor:'#fff',colors:['#333'],focusBorderColor:'#ccc',height:460,legend:'none',titleColor:'#666',titleX:'Miles from Parliament',titleY:'Pounds per mile',width:952});});