From 39447923ad65c10fc0e7864f5e0aca1476ef8eda Mon Sep 17 00:00:00 2001 From: Freeyorp Date: Sun, 31 Mar 2013 17:05:51 +1300 Subject: Map name mappings. Label map names on map chart. This closes #003. --- index.html | 1 + js/comp/makemap.sed | 17 ++++++++ js/comp/map.js | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++ js/mv.js | 12 ++---- 4 files changed, 136 insertions(+), 8 deletions(-) create mode 100755 js/comp/makemap.sed create mode 100644 js/comp/map.js diff --git a/index.html b/index.html index 2138f92..8c27089 100644 --- a/index.html +++ b/index.html @@ -105,6 +105,7 @@ + diff --git a/js/comp/makemap.sed b/js/comp/makemap.sed new file mode 100755 index 0000000..561530b --- /dev/null +++ b/js/comp/makemap.sed @@ -0,0 +1,17 @@ +#!/bin/sed -nf +# Usage: ./makemap.sed < map.in > map.js +1i\ +var map = function(){\ + var map = {};\ + var maps = { +/^Loading Maps/,/^Maps Loaded/ { + s/^Loading Maps \[\([0-9]\+\)\/[0-9]\+\]: data\\\(.*\)\.gat/ "\1": "\2",/p; +} +$i\ + };\ + map.nameByServerID = function(serverID, date) {\ + /* TODO: Merged output format suitable for converting records running under different data */\ + return maps[serverID];\ + }\ + return map;\ +}(); diff --git a/js/comp/map.js b/js/comp/map.js new file mode 100644 index 0000000..d845031 --- /dev/null +++ b/js/comp/map.js @@ -0,0 +1,114 @@ +var map = function(){ + var map = {}; + var maps = { + "0": "001-1", + "1": "001-2", + "2": "001-3", + "3": "002-1", + "4": "002-3", + "5": "002-4", + "6": "003-1", + "7": "003-2", + "8": "004-1", + "9": "004-2", + "10": "005-1", + "11": "005-3", + "12": "005-4", + "13": "006-1", + "14": "006-3", + "15": "007-1", + "16": "008-1", + "17": "009-1", + "18": "009-2", + "19": "009-3", + "20": "009-4", + "21": "009-5", + "22": "009-6", + "23": "010-1", + "24": "010-2", + "25": "011-1", + "26": "011-3", + "27": "011-4", + "28": "011-6", + "29": "012-1", + "30": "012-3", + "31": "012-4", + "32": "013-1", + "33": "013-2", + "34": "013-3", + "35": "014-1", + "36": "014-3", + "37": "015-1", + "38": "015-3", + "39": "016-1", + "40": "017-1", + "41": "017-2", + "42": "017-3", + "43": "017-4", + "44": "017-9", + "45": "018-1", + "46": "018-2", + "47": "018-3", + "48": "019-1", + "49": "019-3", + "50": "019-4", + "51": "020-1", + "52": "020-2", + "53": "020-3", + "54": "021-1", + "55": "021-2", + "56": "022-1", + "57": "024-1", + "58": "024-2", + "59": "024-3", + "60": "024-4", + "61": "025-1", + "62": "025-3", + "63": "025-4", + "64": "026-1", + "65": "027-1", + "66": "027-2", + "67": "027-3", + "68": "027-4", + "69": "028-1", + "70": "028-3", + "71": "029-1", + "72": "029-3", + "73": "030-1", + "74": "030-2", + "75": "031-1", + "76": "031-2", + "77": "031-3", + "78": "031-4", + "79": "032-1", + "80": "032-3", + "81": "033-1", + "82": "034-1", + "83": "041-1", + "84": "042-1", + "85": "042-2", + "86": "044-1", + "87": "044-3", + "88": "045-1", + "89": "046-1", + "90": "046-3", + "91": "047-1", + "92": "048-1", + "93": "048-2", + "94": "051-1", + "95": "051-3", + "96": "052-1", + "97": "052-2", + "98": "055-1", + "99": "055-3", + "100": "056-1", + "101": "056-2", + "102": "057-1", + "103": "botcheck", + }; + map.nameByServerID = function(serverID, date) { + /* TODO: Merged output format suitable for converting records running under different data */ + return maps[serverID]; + } + return map; +}(); diff --git a/js/mv.js b/js/mv.js index 27d5fcc..0730e15 100644 --- a/js/mv.js +++ b/js/mv.js @@ -94,7 +94,7 @@ var mv = {}; this.luk = luk; this.blvl = stat.minLevelForStats(str, agi, vit, int, dex, luk); } - Stat.prototype.valueOf = function() { return this.str * 1e15 + this.agi * 1e12 + this.vit * 1e9 + this.int * 1e6 + this.dex * 1e3 + this.luk; /*this.str + ":" + this.agi + ":" + this.vit + ":" + this.dex + ":" + this.int + ":" + this.luk*/; }; + Stat.prototype.valueOf = function() { return this.str * 1e15 + this.agi * 1e12 + this.vit * 1e9 + this.int * 1e6 + this.dex * 1e3 + this.luk; }; var nullstat = new Stat(0,0,0,0,0,0); function parseRecords(data) { var spl = data.split(/\r?\n/); @@ -102,12 +102,13 @@ var mv = {}; var d; d = e.match(/^(\d+\.\d+) PC(\d+) (\d+):(\d+),(\d+) GAINXP (\d+) (\d+) (\w+)/); if (d) { + var mapSID = parseInt(d[3]); var ts = new Date(0); ts.setUTCSeconds(d[1]); records.push({ date: ts, pc: parseInt(d[2]), - map: parseInt(d[3]), + map: map.nameByServerID(parseInt(d[3]), ts), x: parseInt(d[4]), y: parseInt(d[5]), e: parseInt(d[6]), @@ -167,10 +168,6 @@ var mv = {}; attrGroups[attrs[y]][attrs[x]] = attrDims[attrs[y]][attrs[x]].group().reduceCount(); } } -// for (var i = 0; i != attrs.length; ++i) { -// attrDims[attrs[i]] = cfdata.dimension(function(d) { return d.pcstat ? d.pcstat[attrs[i]] }); -// attrGroups[attrs[i]] = attrDims[attrs[i]].group().reduceCount(); -// } defDim = cfdata.dimension(function(d) { if (d.pcstat == nullstat) { return 0; } if (d.date <= fullyDefinedCutoff) { return 1; } return 2; }); defGroup = defDim.group().reduceCount(); /* @@ -258,8 +255,7 @@ var mv = {}; .margins({left: 60, right: 18, top: 5, bottom: 30}) .dimension(mapDim) .group(mapGroup) - .colorDomain(function(d) { return [mapDim.bottom(1)[0].map, mapDim.top(1)[0].map]; }) - .colorAccessor(function(d, i){ return d.key; }) + .colorCalculator(d3.scale.category20c()) /* X */ .keyAccessor(function(d) { return d.value.e + 1; }) /* Y */ -- cgit v1.2.3-60-g2f50