Deal with large numerical values in statistics - fixes #87
Change-Id: Iaaf95fe1dd6c87c693446706d2845a80bb2d257f
diff --git a/dev/js/spec/statSpec.js b/dev/js/spec/statSpec.js
index 93001bd..38d6f64 100644
--- a/dev/js/spec/statSpec.js
+++ b/dev/js/spec/statSpec.js
@@ -73,6 +73,14 @@
"paragraphs":45454545
};
+ var preDefinedStat2={
+ "documents":20216975,
+ "tokens": "5991667065",
+ "sentences":403923016,
+ "paragraphs":129385487
+ };
+
+
KorAP.API.getCorpStat = function(collQu, cb){
return cb(preDefinedStat);
};
@@ -213,6 +221,33 @@
expect(descL.children[1].children[1].firstChild.nodeValue).toEqual(new Number(2323).toLocaleString());
expect(descL.children[1].children[0].attributes[0].value).toEqual('tokens');
});
+
+
+ it('should be parsed in a statistic view and displayed as HTML Description List (2)', function(){
+ var stat = statClass.create(preDefinedStat2);
+ var descL = stat.element();
+ expect(descL.tagName).toEqual('DL');
+ expect(descL.children[0].tagName).toEqual('DIV');
+ expect(descL.children[0].children[0].tagName).toEqual('DT');
+ expect(descL.children[0].children[0].attributes[0].name).toEqual('title');
+ expect(descL.children[0].children[1].tagName).toEqual('DD');
+
+ expect(descL.children[0].children[0].firstChild.nodeValue).toEqual('documents');
+ expect(descL.children[0].children[1].firstChild.nodeValue).toEqual(new Number(20216975).toLocaleString());
+ expect(descL.children[0].children[0].attributes[0].value).toEqual('documents');
+
+ expect(descL.children[1].children[0].firstChild.nodeValue).toEqual('tokens');
+ expect(descL.children[1].children[1].firstChild.nodeValue).toEqual(new Number(5991667065).toLocaleString());
+ expect(descL.children[1].children[0].attributes[0].value).toEqual('tokens');
+
+ expect(descL.children[2].children[0].firstChild.nodeValue).toEqual('sentences');
+ expect(descL.children[2].children[1].firstChild.nodeValue).toEqual(new Number(403923016).toLocaleString());
+ expect(descL.children[2].children[0].attributes[0].value).toEqual('sentences');
+
+ expect(descL.children[3].children[0].firstChild.nodeValue).toEqual('paragraphs');
+ expect(descL.children[3].children[1].firstChild.nodeValue).toEqual(new Number(129385487).toLocaleString());
+ expect(descL.children[3].children[0].attributes[0].value).toEqual('paragraphs');
+ });
it('should display corpus statistic after creating a corpus statistic view', function(){
diff --git a/dev/js/src/vc/statistic.js b/dev/js/src/vc/statistic.js
index dd955b7..cd8d0ce 100644
--- a/dev/js/src/vc/statistic.js
+++ b/dev/js/src/vc/statistic.js
@@ -52,7 +52,7 @@
statDT.addT(k);
statDT.setAttribute('title', k);
statDD = statSp.addE('dd');
- statDD.addT(statistic[k].toLocaleString());
+ statDD.addT(new Number(statistic[k]).toLocaleString());
}
this._element = statDL;