Commit 6a638698 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Добавил в статистическую информацию min, max и countNumbers

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55824 954022d7-b5bf-4e40-9824-e11837661b57
parent dde9610f
......@@ -1246,15 +1246,21 @@
/** @constructor */
function asc_CSelectionMathInfo() {
this.count = 0;
this.countNumbers = 0;
this.sum = null;
this.average = null;
this.min = null;
this.max = null;
}
asc_CSelectionMathInfo.prototype = {
constructor: asc_CSelectionMathInfo,
asc_getCount: function () { return this.count; },
asc_getCountNumbers: function () { return this.countNumbers; },
asc_getSum: function () { return this.sum; },
asc_getAverage: function () { return this.average; }
asc_getAverage: function () { return this.average; },
asc_getMin: function () { return this.min; },
asc_getMax: function () { return this.max; }
};
/** @constructor */
......@@ -1444,8 +1450,11 @@
window["Asc"]["asc_CSelectionMathInfo"] = window["Asc"].asc_CSelectionMathInfo = asc_CSelectionMathInfo;
prot = asc_CSelectionMathInfo.prototype;
prot["asc_getCount"] = prot.asc_getCount;
prot["asc_getCountNumbers"] = prot.asc_getCountNumbers;
prot["asc_getSum"] = prot.asc_getSum;
prot["asc_getAverage"] = prot.asc_getAverage;
prot["asc_getMin"] = prot.asc_getMin;
prot["asc_getMax"] = prot.asc_getMax;
window["Asc"]["asc_CFindOptions"] = window["Asc"].asc_CFindOptions = asc_CFindOptions;
......
......@@ -6124,20 +6124,26 @@
var range = this.model.getRange3(ar.r1, ar.c1, ar.r2, ar.c2);
var tmp;
var oSelectionMathInfo = new asc_CSelectionMathInfo();
var sum = 0, countNumbers = 0;
var sum = 0;
range._setPropertyNoEmpty(null, null, function (c) {
++oSelectionMathInfo.count;
if (CellValueType.Number === c.getType() && false === c.isEmptyTextString()) {
tmp = parseFloat(c.getValueWithoutFormat());
if (isNaN(tmp))
return;
++countNumbers;
if (0 === oSelectionMathInfo.countNumbers)
oSelectionMathInfo.min = oSelectionMathInfo.max = tmp;
else {
oSelectionMathInfo.min = Math.min(oSelectionMathInfo.min, tmp);
oSelectionMathInfo.max = Math.max(oSelectionMathInfo.max, tmp);
}
++oSelectionMathInfo.countNumbers;
sum += tmp;
}
});
if (0 !== countNumbers) {
if (0 !== oSelectionMathInfo.countNumbers) {
oSelectionMathInfo.sum = sum;
oSelectionMathInfo.average = sum / countNumbers;
oSelectionMathInfo.average = sum / oSelectionMathInfo.countNumbers;
}
return oSelectionMathInfo;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment