]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Eliminate or hide bad data in the charts.
authorAnt Zucaro <azucaro@gmail.com>
Wed, 11 Sep 2013 23:55:50 +0000 (19:55 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Wed, 11 Sep 2013 23:55:50 +0000 (19:55 -0400)
xonstat/static/js/weaponCharts.js
xonstat/templates/player_info.mako

index 470048822f09577dcb8e8309530b0923d05f9a6b..8e32893b99eb531a70cedcc9e9dc0b4a9dbd9069 100644 (file)
@@ -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%'));
index 1e7536269b8fe6114e7692c7de1c769e3ba7c32f..4b33ed8143534141fcd67b08b224dd9ece889f08 100644 (file)
@@ -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 ####
-<div class="row">
+<div class="row" id="accuracyChartRow">
   <div class="span12">
     <h3>Weapon Accuracy</h3>
     <div id="accuracyChart">
@@ -209,7 +213,7 @@ Player Information
 
 
 ##### Weapon Damage Chart ####
-<div class="row">
+<div class="row" id="damageChartRow">
   <div class="span12">
     <h3>Weapon Damage</h3>
     <div id="damageChart">