-var weaponColors={arc:"#b8e9ff",laser:"#ff5933",blaster:"#ff5933",shotgun:"#1f77b4",uzi:"#b9e659",machinegun:"#b9e659",grenadelauncher:"#ff2600",mortar:"#ff2600",minelayer:"#bfbf00",electro:"#597fff",crylink:"#d940ff",nex:"#00e6ff",vortex:"#00e6ff",hagar:"#d98059",rocketlauncher:"#ffbf33",devastator:"#ffbf33",porto:"#7fff7f",minstanex:"#d62728",vaporizer:"#d62728",hook:"#a5ffd8",hlac:"#ffa533",seeker:"#ff5959",rifle:"#9467bd",tuba:"#d87f3f",fireball:"#33ff33"};var flatten=function(a){flattened={};a.games.forEach(function(c,b){flattened[c]={}});a.weapon_stats.forEach(function(c,b){flattened[c.game_id][c.weapon_cd]=c});return flattened};function accuracyValue(b,c){if(b[c]==undefined){return null}var a=b[c];var d=a.fired>0?Math.round((a.hit/a.fired)*100):0;return d}function accuracyTooltip(b,d,a){if(d==null){return null}var c=b+": "+d.toString()+"%";if(a[b]!=undefined){return c+" ("+a[b].toString()+"% average)"}return c}function drawAccuracyChart(c){var e=new google.visualization.DataTable();e.addColumn("string","X");e.addColumn("number","Shotgun");e.addColumn({type:"string",role:"tooltip"});e.addColumn("number","MG");e.addColumn({type:"string",role:"tooltip"});e.addColumn("number","Vortex");e.addColumn({type:"string",role:"tooltip"});e.addColumn("number","Vaporizer");e.addColumn({type:"string",role:"tooltip"});e.addColumn("number","Arc");e.addColumn({type:"string",role:"tooltip"});var q=flatten(c);for(i in c.games){var g=c.games[i];var j=accuracyValue(q[g],"shotgun");var h=accuracyTooltip("shotgun",j,c.averages);var m=accuracyValue(q[g],"machinegun");var a=accuracyTooltip("machinegun",m,c.averages);var o=accuracyValue(q[g],"vortex");var p=accuracyTooltip("vortex",o,c.averages);var d=accuracyValue(q[g],"vaporizer");var l=accuracyTooltip("vaporizer",d,c.averages);var b=accuracyValue(q[g],"arc");var f=accuracyTooltip("arc",b,c.averages);e.addRow([g.toString(),j,h,m,a,o,p,d,l,b,f])}var r={backgroundColor:{fill:"transparent"},lineWidth:2,legend:{textStyle:{color:"#666"}},hAxis:{title:"Games",textPosition:"none",titleTextStyle:{color:"#666"}},vAxis:{title:"Percentage",titleTextStyle:{color:"#666"},minValue:0,maxValue:100,baselineColor:"#333",gridlineColor:"#333",ticks:[20,40,60,80,100]},series:{0:{color:weaponColors.shotgun},1:{color:weaponColors.machinegun},2:{color:weaponColors.vortex},3:{color:weaponColors.vaporizer},4:{color:weaponColors.arc}}};var n=new google.visualization.LineChart(document.getElementById("accuracyChart"));var k=function(u){var t=n.getSelection()[0];if(t!=null&&t.row!=null){var s=e.getFormattedValue(t.row,0);window.location.href="http://stats.xonotic.org/game/"+s.toString()}};google.visualization.events.addListener(n,"select",k);n.draw(e,r)}function damageValue(a,b){if(a[b]==undefined){return null}return a[b].actual}function damageTooltip(b,a){if(a==null){return null}return b+": "+a.toString()+" HP damage"}function drawDamageChart(r){var B=new google.visualization.DataTable();B.addColumn("string","X");B.addColumn("number","Shotgun");B.addColumn({type:"string",role:"tooltip"});B.addColumn("number","Machine Gun");B.addColumn({type:"string",role:"tooltip"});B.addColumn("number","Vortex");B.addColumn({type:"string",role:"tooltip"});B.addColumn("number","Mortar");B.addColumn({type:"string",role:"tooltip"});B.addColumn("number","Electro");B.addColumn({type:"string",role:"tooltip"});B.addColumn("number","Crylink");B.addColumn({type:"string",role:"tooltip"});B.addColumn("number","Hagar");B.addColumn({type:"string",role:"tooltip"});B.addColumn("number","Devastator");B.addColumn({type:"string",role:"tooltip"});B.addColumn("number","Arc");B.addColumn({type:"string",role:"tooltip"});var t=flatten(r);for(i in r.games){var q=r.games[i];var z=damageValue(t[q],"shotgun");var y=damageTooltip("shotgun",z);var x=damageValue(t[q],"machinegun");var a=damageTooltip("machinegun",x);var A=damageValue(t[q],"vortex");var n=damageTooltip("vortex",A);var u=damageValue(t[q],"vaporizer");var w=damageTooltip("vaporizer",u);var p=damageValue(t[q],"mortar");var s=damageTooltip("mortar",p);var h=damageValue(t[q],"electro");var g=damageTooltip("electro",h);var b=damageValue(t[q],"crylink");var c=damageTooltip("crylink",b);var e=damageValue(t[q],"hagar");var k=damageTooltip("hagar",e);var l=damageValue(t[q],"devastator");var m=damageTooltip("devastator",l);var f=damageValue(t[q],"arc");var j=damageTooltip("arc",f);B.addRow([q.toString(),z,y,x,a,A,n,p,s,h,g,b,c,e,k,l,m,f,j])}var d={backgroundColor:{fill:"transparent"},legend:{position:"top",maxLines:3,textStyle:{color:"#666"}},vAxis:{title:"HP Damage",titleTextStyle:{color:"#666"},baselineColor:"#333",gridlineColor:"#333",},hAxis:{title:"Games",textPosition:"none",titleTextStyle:{color:"#666"},},isStacked:true,series:{0:{color:weaponColors.shotgun},1:{color:weaponColors.machinegun},2:{color:weaponColors.vortex},3:{color:weaponColors.mortar},4:{color:weaponColors.electro},5:{color:weaponColors.crylink},6:{color:weaponColors.hagar},7:{color:weaponColors.devastator},8:{color:weaponColors.arc}}};var o=new google.visualization.ColumnChart(document.getElementById("damageChart"));var v=function(E){var D=o.getSelection()[0];if(D!=null&&D.row!=null){var C=B.getFormattedValue(D.row,0);window.location.href="http://stats.xonotic.org/game/"+C.toString()}};google.visualization.events.addListener(o,"select",v);o.draw(B,d)};
\ No newline at end of file
+var weaponColors={arc:"#b8e9ff",laser:"#ff5933",blaster:"#ff5933",shotgun:"#1f77b4",uzi:"#b9e659",machinegun:"#b9e659",grenadelauncher:"#ff2600",mortar:"#ff2600",minelayer:"#bfbf00",electro:"#597fff",crylink:"#d940ff",nex:"#00e6ff",vortex:"#00e6ff",hagar:"#d98059",rocketlauncher:"#ffbf33",devastator:"#ffbf33",porto:"#7fff7f",minstanex:"#d62728",vaporizer:"#d62728",hook:"#a5ffd8",hlac:"#ffa533",seeker:"#ff5959",rifle:"#9467bd",tuba:"#d87f3f",fireball:"#33ff33"};var damageWeapons=new Set(["vortex","machinegun","shotgun","arc","uzi","nex","minstanex","rifle","grenadelauncher","minelayer","rocketlauncher","hlac","seeker","fireball","mortar","electro","crylink","hagar","devastator"]);var accuracyWeapons=new Set(["vortex","machinegun","shotgun","vaporizer","arc","uzi","nex","minstanex","rifle"]);function drawAccuracyChart(f,a){var e={};a.games.forEach(function(g,h){e[g]=h});function d(g){return g.fired!=0}function c(g){return accuracyWeapons.has(g.weapon_cd)}var b=d3.nest().key(function(g){return g.weapon_cd}).entries(a.weapon_stats.filter(c).filter(d));nv.addGraph(function(){var g=nv.models.lineChart().useInteractiveGuideline(false).forceY([0,1]).showLegend(true).showYAxis(true).showXAxis(true).color(function(h){return weaponColors[h.key]}).x(function(h){return e[h.game_id]}).y(function(h){return h.fired>0?h.hit/h.fired:0});g.tooltip.contentGenerator(function(h,k,j,i){return"<table><tr><td>"+h.point.weapon_cd+": "+Math.round(h.point.y*100)+"% ("+Math.round(a.averages[h.point.weapon_cd])+"% avg)</td></tr></table>"});g.lines.dispatch.on("elementClick",function(h){window.location.href="http://stats.xonotic.org/game/"+h.point.game_id.toString()});g.yAxis.axisLabel("Accuracy").tickFormat(d3.format("2%"));g.xAxis.axisLabel("Games").tickFormat(function(h){return""});d3.select("#accuracyChartSVG").datum(b).call(g);nv.utils.windowResize(function(){g.update()});return g})}function drawDamageChart(e,b){var d={};b.games.forEach(function(f,g){d[f]=g});function a(f){return damageWeapons.has(f.weapon_cd)}var c=d3.nest().key(function(f){return f.weapon_cd}).entries(b.weapon_stats.filter(a));nv.addGraph(function(){var f=nv.models.multiBarChart().reduceXTicks(true).rotateLabels(0).showControls(true).groupSpacing(0.1).showXAxis(true).stacked(true).color(function(g){return weaponColors[g.key]}).x(function(g){return d[g.game_id]}).y(function(g){return g.actual});f.tooltip.contentGenerator(function(h,k,j,i){var g="<table><tr><td>"+h.data.weapon_cd+": "+h.data.actual+" HP damage";if(h.data.frags>0){if(h.data.frags>1){g+=" ("+h.data.frags+" frags)"}else{g+=" ("+h.data.frags+" frag)"}}g+="</td></tr></table>";return g});f.multibar.dispatch.on("elementClick",function(g){window.location.href="http://stats.xonotic.org/game/"+g.data.game_id.toString()});f.xAxis.axisLabel("Games").tickFormat(function(g){return""});f.yAxis.axisLabel("Damage (HP)").tickFormat(d3.format(",d"));d3.select("#damageChartSVG").datum(c).call(f);nv.utils.windowResize(f.update);return f})};
\ No newline at end of file