diff options
author | Freeyorp <TheFreeYorp@NOSPAM.G.m.a.i.l.replace> | 2013-04-23 15:26:48 +1200 |
---|---|---|
committer | Freeyorp <TheFreeYorp@NOSPAM.G.m.a.i.l.replace> | 2013-04-23 15:26:48 +1200 |
commit | a7da1fafe2ca8c9115ce76f99a903e1b3da692a3 (patch) | |
tree | ee4465cbebc54cd937f69ede32b2b99513dd76a0 /js/mv/heap.js | |
parent | f12d953786784ca8e8b8e9db146ce494b30f6647 (diff) | |
download | manavis-a7da1fafe2ca8c9115ce76f99a903e1b3da692a3.tar.gz manavis-a7da1fafe2ca8c9115ce76f99a903e1b3da692a3.tar.bz2 manavis-a7da1fafe2ca8c9115ce76f99a903e1b3da692a3.tar.xz manavis-a7da1fafe2ca8c9115ce76f99a903e1b3da692a3.zip |
Add initial stat trellis chart
This should now be implemented efficiently enough for everything else to
still work.
This currently does not allow filtering, but the dimensions are prepared in
a manner that makes this a simple addition.
Diffstat (limited to 'js/mv/heap.js')
-rw-r--r-- | js/mv/heap.js | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/js/mv/heap.js b/js/mv/heap.js index bd1d583..a0a69be 100644 --- a/js/mv/heap.js +++ b/js/mv/heap.js @@ -1,19 +1,47 @@ var mv = function(mv) { mv.heap = function() { var heap = {}; + var statGran = 10; heap.init = function() { - function a(p, d) { return { e: p.e + d.e, j: p.j + d.j, r: p.r + 1 }; } - function s(p, d) { return { e: p.e - d.e, j: p.j - d.j, r: p.r - 1 }; } - function z(p, d) { return { e: 0, j: 0, r: 0 }; } + function ea(p, d) { p.e += d.e; p.j += d.j; p.r++; return p; } + function es(p, d) { p.e -= d.e; p.j -= d.j; p.r--; return p; } + function ez(p, d) { return { e: 0, j: 0, r: 0 }; } heap.cfdata = crossfilter(mv.parser.records); - heap.all = heap.cfdata.groupAll().reduce(a, s, z); + heap.all = heap.cfdata.groupAll().reduce(ea, es, ez); monoGroup("date", function(d) { return d3.time.hour.round(d.date); }); monoGroup("pc", function(d) { return d.pc; }); - monoGroup("map", function(d) { return d.map; }).reduce(a, s, z); + monoGroup("map", function(d) { return d.map; }).reduce(ea, es, ez); monoGroup("blvl", function(d) { return d.pcstat ? d.pcstat.blvl : 0; }); monoGroup("type", function(d) { return d.type; }); monoGroup("target", function(d) { return d.target; }); - monoGroup("wpn", function(d) { return d.wpn; }) + monoGroup("wpn", function(d) { return d.wpn; }); + function sa(p, d) { + if (!d.pcstat) return p; + p.str[d.pcstat.str]++ || (p.str[d.pcstat.str] = 1); + p.agi[d.pcstat.agi]++ || (p.agi[d.pcstat.agi] = 1); + p.vit[d.pcstat.vit]++ || (p.vit[d.pcstat.vit] = 1); + p.dex[d.pcstat.dex]++ || (p.dex[d.pcstat.dex] = 1); + p.int[d.pcstat.int]++ || (p.int[d.pcstat.int] = 1); + p.luk[d.pcstat.luk]++ || (p.luk[d.pcstat.luk] = 1); + return p; + } + function ss(p, d) { + if (!d.pcstat) return p; + --p.str[d.pcstat.str] || (p.str[d.pcstat.str] = undefined); + --p.agi[d.pcstat.agi] || (p.agi[d.pcstat.agi] = undefined); + --p.vit[d.pcstat.vit] || (p.vit[d.pcstat.vit] = undefined); + --p.dex[d.pcstat.dex] || (p.dex[d.pcstat.dex] = undefined); + --p.int[d.pcstat.int] || (p.int[d.pcstat.int] = undefined); + --p.luk[d.pcstat.luk] || (p.luk[d.pcstat.luk] = undefined); + return p; + } + function sz(p, d) { return { str: [], agi: [], vit: [], dex: [], int: [], luk: [] }; } + monoGroup("str", function(d) { return d.pcstat ? d.pcstat.str : 0; }).reduce(sa, ss, sz); + monoGroup("agi", function(d) { return d.pcstat ? d.pcstat.agi : 0; }).reduce(sa, ss, sz); + monoGroup("vit", function(d) { return d.pcstat ? d.pcstat.vit : 0; }).reduce(sa, ss, sz); + monoGroup("dex", function(d) { return d.pcstat ? d.pcstat.dex : 0; }).reduce(sa, ss, sz); + monoGroup("int", function(d) { return d.pcstat ? d.pcstat.int : 0; }).reduce(sa, ss, sz); + monoGroup("luk", function(d) { return d.pcstat ? d.pcstat.luk : 0; }).reduce(sa, ss, sz); /* Debugging group */ /* * How well defined a record is. |