// 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);
.margin(margin)
.width(width)
.height(height)
+ .forceY([0,1])
.x(function(d) { return games[d.game_id] })
.y(function(d) {
if(d.fired > 0) {
.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%'));
// 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);
});
##### Weapon Accuracy Chart ####
-<div class="row">
+<div class="row" id="accuracyChartRow">
<div class="span12">
<h3>Weapon Accuracy</h3>
<div id="accuracyChart">
##### Weapon Damage Chart ####
-<div class="row">
+<div class="row" id="damageChartRow">
<div class="span12">
<h3>Weapon Damage</h3>
<div id="damageChart">