var weaponColors={arc:"#7c9ceb",laser:"#f7717b",blaster:"#f7717b",shotgun:"#849ba8",uzi:"#81f13d",machinegun:"#81f13d",grenadelauncher:"#fd7865",mortar:"#fd7865",minelayer:"#fd7865",electro:"#6899f2",crylink:"#ea6ff9",nex:"#75c3d5",vortex:"#75c3d5",hagar:"#e39160",rocketlauncher:"#e9be57",devastator:"#e9be57",porto:"#6899f2",minstanex:"#978ed2",vaporizer:"#978ed2",hook:"#81f13d",hlac:"#e5965b",seeker:"#f7717b",rifle:"#e39160",tuba:"#e9be57",fireball:"#f0855f"};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"
"+h.point.weapon_cd+": "+Math.round(h.point.y*100)+"% ("+Math.round(a.averages[h.point.weapon_cd])+"% avg)
"});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="
"+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+="
";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})};