fixed category count

This commit is contained in:
javi 2015-11-10 15:14:39 +01:00
parent e0606ee295
commit 1ec2324b83

View File

@ -24,12 +24,14 @@ var Profiler = require('../profiler');
this._filters = {};
// category mapping for each column
this.categoryMapping = {}
this.categoryMappingSize = {}
// generate the mapping, global for all the tiles
var fields = this.options.fields;
for (var i = 0 ; i < fields.length; ++i) {
if (fields[i].type === 'cat') {
this.categoryMapping[fields[i].name] = {}
this.categoryMappingSize[fields[i].name] = 0;
}
}
@ -112,12 +114,17 @@ var Profiler = require('../profiler');
if (this.options.fields[j].type === 'cat') {
var mapping = this.categoryMapping[this.options.fields[j].name];
var m = mapping[v]
var count = Object.keys(mapping).length
if (!m && count < 100) {
mapping[v] = 0;
if (!m) {
var count = this.categoryMappingSize[this.options.fields[j].name];
if (count < 100) {
++this.categoryMappingSize[this.options.fields[j].name];
v = mapping[v] = count;
} else {
v = 0;
}
} else {
v = m;
}
mapping[v] += 1;
v = m
}
rr.push([r, v]);
}