From 10142bba36de5f517bc4051db2d0948804626107 Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Wed, 17 Dec 2014 21:33:08 -0500 Subject: [PATCH] Add minimized version of the weapon charts JS. --- xonstat/static/js/weaponCharts.min.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 xonstat/static/js/weaponCharts.min.js diff --git a/xonstat/static/js/weaponCharts.min.js b/xonstat/static/js/weaponCharts.min.js new file mode 100644 index 0000000..e604e32 --- /dev/null +++ b/xonstat/static/js/weaponCharts.min.js @@ -0,0 +1 @@ +var weaponColors={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","Rifle");e.addColumn({type:"string",role:"tooltip"});var q=flatten(c);for(i in c.games){var f=c.games[i];var h=accuracyValue(q[f],"shotgun");var g=accuracyTooltip("shotgun",h,c.averages);var l=accuracyValue(q[f],"machinegun");var b=accuracyTooltip("machinegun",l,c.averages);var n=accuracyValue(q[f],"vortex");var o=accuracyTooltip("vortex",n,c.averages);var d=accuracyValue(q[f],"vaporizer");var k=accuracyTooltip("vaporizer",d,c.averages);var p=accuracyValue(q[f],"rifle");var a=accuracyTooltip("rifle",p,c.averages);e.addRow([f.toString(),h,g,l,b,n,o,d,k,p,a])}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.rifle}}};var m=new google.visualization.LineChart(document.getElementById("accuracyChart"));var j=function(u){var t=m.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(m,"select",j);m.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(q){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","Rifle");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"});var s=flatten(q);for(i in q.games){var p=q.games[i];var z=damageValue(s[p],"shotgun");var y=damageTooltip("shotgun",z);var x=damageValue(s[p],"machinegun");var b=damageTooltip("machinegun",x);var A=damageValue(s[p],"vortex");var m=damageTooltip("vortex",A);var u=damageValue(s[p],"vaporizer");var w=damageTooltip("vaporizer",u);var a=damageValue(s[p],"rifle");var t=damageTooltip("rifle",a);var o=damageValue(s[p],"mortar");var r=damageTooltip("mortar",o);var h=damageValue(s[p],"electro");var g=damageTooltip("electro",h);var c=damageValue(s[p],"crylink");var d=damageTooltip("crylink",c);var f=damageValue(s[p],"hagar");var j=damageTooltip("hagar",f);var k=damageValue(s[p],"devastator");var l=damageTooltip("devastator",k);B.addRow([p.toString(),z,y,x,b,A,m,a,t,o,r,h,g,c,d,f,j,k,l])}var e={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.rifle},4:{color:weaponColors.mortar},5:{color:weaponColors.electro},6:{color:weaponColors.crylink},7:{color:weaponColors.hagar},8:{color:weaponColors.devastator}}};var n=new google.visualization.ColumnChart(document.getElementById("damageChart"));var v=function(E){var D=n.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(n,"select",v);n.draw(B,e)}; \ No newline at end of file -- 2.39.2