From ce21fbac0b0085fe2bf40be91ea0a69be72ab12e Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Wed, 11 Sep 2013 19:55:50 -0400 Subject: [PATCH] Eliminate or hide bad data in the charts. --- xonstat/static/js/weaponCharts.js | 5 +++++ xonstat/templates/player_info.mako | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/xonstat/static/js/weaponCharts.js b/xonstat/static/js/weaponCharts.js index 4700488..8e32893 100644 --- a/xonstat/static/js/weaponCharts.js +++ b/xonstat/static/js/weaponCharts.js @@ -60,6 +60,9 @@ var drawAccuracyChart = function(data) { // the chart should fill the "accuracyChart" div var width = document.getElementById("accuracyChart").offsetWidth; + // get rid of empty values + data.weapon_stats = data.weapon_stats.filter(function(e){ return e.fired > 0; }); + // transform the dataset into something nvd3 can use var transformedData = d3.nest() .key(function(d) { return d.weapon_cd; }).entries(data.weapon_stats); @@ -84,6 +87,7 @@ var drawAccuracyChart = function(data) { .margin(margin) .width(width) .height(height) + .forceY([0,1]) .x(function(d) { return games[d.game_id] }) .y(function(d) { if(d.fired > 0) { @@ -100,6 +104,7 @@ var drawAccuracyChart = function(data) { .ticks(5) .tickFormat(function(d) { return data.games[d]; }); + var yScale = d3.scale.linear().domain([0,1]).range([0,height]); chart.yAxis .axisLabel('% Accuracy') .tickFormat(d3.format('2%')); diff --git a/xonstat/templates/player_info.mako b/xonstat/templates/player_info.mako index 1e75362..4b33ed8 100644 --- a/xonstat/templates/player_info.mako +++ b/xonstat/templates/player_info.mako @@ -34,6 +34,10 @@ $(function () { // weapon accuracy and damage charts d3.json("${request.route_url('player_weaponstats_data_json', id=player.player_id)}", function(err, data) { + if(data.games.length < 5) { + d3.select(".row #damageChartRow").remove(); + d3.select(".row #accuracyChartRow").remove(); + } drawDamageChart(data); drawAccuracyChart(data); }); @@ -198,7 +202,7 @@ Player Information ##### Weapon Accuracy Chart #### -
+

Weapon Accuracy

@@ -209,7 +213,7 @@ Player Information ##### Weapon Damage Chart #### -
+

Weapon Damage

-- 2.39.2