Commit 2fb65060 authored by Alexander.Trofimov's avatar Alexander.Trofimov

support aboveAverage in conditional formatting

parent 5e226a9b
...@@ -180,6 +180,17 @@ ...@@ -180,6 +180,17 @@
} }
return res; return res;
}; };
CConditionalFormattingRule.prototype.getAverage = function(val, average) {
var res = false;
// ToDo stdDev
if (this.aboveAverage) {
res = val > average;
} else {
res = val < average;
}
res = res || (this.equalAverage && val == average);
return res;
};
function CColorScale () { function CColorScale () {
this.aCFVOs = []; this.aCFVOs = [];
......
...@@ -3498,7 +3498,7 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) { ...@@ -3498,7 +3498,7 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
var aRules, oRule; var aRules, oRule;
var oRuleElement = null; var oRuleElement = null;
var o; var o;
var i, j, l, cell, sqref, values, value, v, tmp, min, mid, max, dxf, compareFunction, nc; var i, j, l, cell, sqref, values, value, v, tmp, min, mid, max, dxf, compareFunction, nc, sum;
for (i = 0; i < aCFs.length; ++i) { for (i = 0; i < aCFs.length; ++i) {
sqref = aCFs[i].sqref; sqref = aCFs[i].sqref;
// ToDo убрать null === sqref когда научимся мультиселект обрабатывать (\\192.168.5.2\source\DOCUMENTS\XLSX\Matematika Quantum Sedekah.xlsx) // ToDo убрать null === sqref когда научимся мультиселект обрабатывать (\\192.168.5.2\source\DOCUMENTS\XLSX\Matematika Quantum Sedekah.xlsx)
...@@ -3510,7 +3510,6 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) { ...@@ -3510,7 +3510,6 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
for (j = 0; j < aRules.length; ++j) { for (j = 0; j < aRules.length; ++j) {
oRule = aRules[j]; oRule = aRules[j];
// ToDo aboveAverage,
// ToDo dataBar, expression, iconSet (page 2679) // ToDo dataBar, expression, iconSet (page 2679)
if (AscCommonExcel.ECfType.colorScale === oRule.type) { if (AscCommonExcel.ECfType.colorScale === oRule.type) {
if (1 !== oRule.aRuleElements.length) { if (1 !== oRule.aRuleElements.length) {
...@@ -3592,6 +3591,31 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) { ...@@ -3592,6 +3591,31 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
value.c.setConditionalFormattingStyle((o !== value.v && tmp < nc) ? (++tmp && oRule.dxf) : null); value.c.setConditionalFormattingStyle((o !== value.v && tmp < nc) ? (++tmp && oRule.dxf) : null);
} }
} }
} else if (AscCommonExcel.ECfType.aboveAverage === oRule.type) {
if (!oRule.dxf) {
continue;
}
values = this._getValuesForConditionalFormatting(sqref, false);
sum = 0;
nc = 0;
for (cell = 0; cell < values.length; ++cell) {
value = values[cell];
if (!value.c.isEmptyTextString(value.v)) {
++nc;
if (CellValueType.Number === value.c.getType() && !isNaN(tmp = parseFloat(value.v))) {
value.v = tmp;
sum += tmp;
} else {
value.v = null;
}
}
}
tmp = sum / nc;
for (cell = 0; cell < values.length; ++cell) {
value = values[cell];
value.c.setConditionalFormattingStyle((null !== value.v && oRule.getAverage(value.v, tmp)) ? oRule.dxf : null);
}
} else { } else {
if (!oRule.dxf) { if (!oRule.dxf) {
continue; continue;
......
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