From: Ant Zucaro Date: Sun, 22 Sep 2013 12:56:29 +0000 (-0400) Subject: Show the number of games used to calculate accuracy in the chart. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=532ac51e74960c890004fd0d342c02406b6fe5e8;p=xonotic%2Fxonstat.git Show the number of games used to calculate accuracy in the chart. --- diff --git a/xonstat/static/js/weaponCharts.js b/xonstat/static/js/weaponCharts.js index 3586db7..dcd743e 100644 --- a/xonstat/static/js/weaponCharts.js +++ b/xonstat/static/js/weaponCharts.js @@ -1,4 +1,3 @@ -// weapons and their corresponding colors var weapons = ["laser", "shotgun", "uzi", "grenadelauncher", "minelayer", "electro", "crylink", "nex", "hagar", "rocketlauncher", "porto", "minstanex", "hook", "hlac", "seeker", "rifle", "tuba", "fireball"]; @@ -73,6 +72,15 @@ var drawAccuracyChart = function(data) { var transformedData = d3.nest() .key(function(d) { return d.weapon_cd; }).entries(data.weapon_stats); + var findNumGames = function(weapon) { + var numGames = transformedData.filter(function(e){return e.key == weapon})[0].values.length; + if(numGames !== undefined) { + return numGames; + } else { + return 0; + } + }; + // transform games list into a map such that games[game_id] = linear sequence var games = {}; data.games.forEach(function(v,i){ games[v] = i; }); @@ -102,7 +110,7 @@ var drawAccuracyChart = function(data) { } }) .tooltip(function(key, x, y, e, graph) { - return '

' + key + '

' + '

' + y + ' accuracy in game #' + x + '
' + data.averages[key] + '% average

'; + return '

' + key + '

' + '

' + y + ' accuracy in game #' + x + '
' + data.averages[key] + '% average over ' + findNumGames(key) + ' games

'; }) .color(keyColor);