From ee8e2f3eaedf842bde43276448c653d7322c9cc6 Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Sun, 22 Sep 2013 08:07:00 -0400 Subject: [PATCH] Use the same weapon colors in the charts as in-game. --- xonstat/static/js/weaponCharts.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/xonstat/static/js/weaponCharts.js b/xonstat/static/js/weaponCharts.js index f1066fa..3586db7 100644 --- a/xonstat/static/js/weaponCharts.js +++ b/xonstat/static/js/weaponCharts.js @@ -1,6 +1,13 @@ -var weapons = ["laser", "shotgun", "uzi", "grenadelauncher", "electro", "crylink", - "nex", "hagar", "rocketlauncher", "minstanex", "rifle", "fireball", - "minelayer", "seeker", "tuba", "hlac", "hook", "porto"]; +// 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"]; + +var weaponColors = ["#ff5933", "#b2b2b2", "#66e559", "#ff2600", "#bfbf00", "#597fff", + "#d83fff", "#00e5ff", "#d87f59", "#ffbf33", "#7fff7f", "#a5a5ff", "#a5ffd8", + "#ffa533", "#ff5959", "#d87f3f", "#d87f3f", "#33ff33"]; + +var colorScale = d3.scale.ordinal().domain(weapons).range(weaponColors); var drawDamageChart = function(data) { // the chart should fill the "damageChart" div @@ -21,8 +28,7 @@ var drawDamageChart = function(data) { width -= margin.left - margin.right; // colors - var colors = d3.scale.category20().domain(weapons); - keyColor = function(d, i) {return colors(d.key)}; + keyColor = function(d, i) {return colorScale(d.key)}; var chart; nv.addGraph(function() { @@ -78,8 +84,7 @@ var drawAccuracyChart = function(data) { width -= margin.left - margin.right; // colors - var colors = d3.scale.category20().domain(weapons); - keyColor = function(d, i) {return colors(d.key)}; + keyColor = function(d, i) {return colorScale(d.key)}; var chart; nv.addGraph(function() { -- 2.39.2