summaryrefslogtreecommitdiff
path: root/js/mv/heap.js
diff options
context:
space:
mode:
authorFreeyorp <TheFreeYorp@NOSPAM.G.m.a.i.l.replace>2013-04-13 18:10:51 +1200
committerFreeyorp <TheFreeYorp@NOSPAM.G.m.a.i.l.replace>2013-04-13 18:20:57 +1200
commit8f34d7e6ce1142af2171d9ec31e20e9738c8223f (patch)
tree3469c004607cac366bda99d40365dbb8295b8029 /js/mv/heap.js
parent35209fb4ddf117fa0cbde1eef4cff1fb45dfc24f (diff)
downloadmanavis-8f34d7e6ce1142af2171d9ec31e20e9738c8223f.tar.gz
manavis-8f34d7e6ce1142af2171d9ec31e20e9738c8223f.tar.bz2
manavis-8f34d7e6ce1142af2171d9ec31e20e9738c8223f.tar.xz
manavis-8f34d7e6ce1142af2171d9ec31e20e9738c8223f.zip
Refactor mv.js into distinct modules
There are five modules, as follows: load.js handles initialisation and management of files parse.js handles initialisation and management of records heap.js handles initialisation and management of dimensions chart.js handles initialisation and management of charts main.js manages the other modules and status Status and file loading have been decoupled; file loading no longer directly updates the status of the progress bars. This makes the limitations of the current status system more apparent, and should make the system also easier to maintain, as progress bars are now updated at more logical times. The parser remains mostly unchanged. It will need to be altered into a full stateful parser, but this can happen later. Dimension management is now simplified, due to the addition of monoGroup. Most dimension/groups consisted of a single dimension and a group reduced by count. This convenience function combines these and unifies their access, beyond mere naming convention. Charting management is also greatly simplified, adding in chain helpers to categorise types of charts, by aspects such as being wide, being thin, being short, as well as helpers to establish common properties for bar and pie charts. There is now also a helper to take advantage of the unified monoGroup accessors.
Diffstat (limited to 'js/mv/heap.js')
-rw-r--r--js/mv/heap.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/js/mv/heap.js b/js/mv/heap.js
new file mode 100644
index 0000000..bd1d583
--- /dev/null
+++ b/js/mv/heap.js
@@ -0,0 +1,34 @@
+var mv = function(mv) {
+ mv.heap = function() {
+ var heap = {};
+ 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 }; }
+ heap.cfdata = crossfilter(mv.parser.records);
+ heap.all = heap.cfdata.groupAll().reduce(a, s, z);
+ 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("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; })
+ /* Debugging group */
+ /*
+ * How well defined a record is.
+ * 0 -> Record contains undefined data
+ * 1 -> Record is defined, but undefined records follow and may impede validity of findings
+ * 2 -> Record and all succeeding records are well defined
+ */
+ monoGroup("def", function(d) { if (d.pcstat == undefined) { return 0; } if (d.date <= mv.parser.fullyDefinedCutoff()) { return 1; } return 2; });
+ heap.def.dim.filterExact(2);
+ }
+ function monoGroup(name, mapping) {
+ heap[name] = {};
+ return heap[name].group = (heap[name].dim = heap.cfdata.dimension(mapping)).group();
+ }
+ return heap;
+ }();
+ return mv;
+}(mv || {});