Commit 655c0e4d authored by Alexander.Trofimov's avatar Alexander.Trofimov

update conditional formatting

parent e9c672ef
...@@ -3477,9 +3477,7 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) { ...@@ -3477,9 +3477,7 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
var aCFs = this.aConditionalFormatting; var aCFs = this.aConditionalFormatting;
var aRules, oRule; var aRules, oRule;
var oRuleElement = null; var oRuleElement = null;
var min = Number.MAX_VALUE; var aValues = [], aCells = [];
var max = -Number.MAX_VALUE;
var arrayCells = [];
var tmp, i, j, cell, sqref; var tmp, i, j, cell, sqref;
for (i = 0; i < aCFs.length; ++i) { for (i = 0; i < aCFs.length; ++i) {
sqref = aCFs[i].sqref; sqref = aCFs[i].sqref;
...@@ -3491,6 +3489,18 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) { ...@@ -3491,6 +3489,18 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
aRules = aCFs[i].aRules; aRules = aCFs[i].aRules;
for (j = 0; j < aRules.length; ++j) { for (j = 0; j < aRules.length; ++j) {
oRule = aRules[j]; oRule = aRules[j];
this.getRange3(sqref.r1, sqref.c1, sqref.r2, sqref.c2)._setPropertyNoEmpty(null, null, function(c) {
if (CellValueType.Number === c.getType() && false === c.isEmptyTextString()) {
tmp = parseFloat(c.getValueWithoutFormat());
if (isNaN(tmp)) {
return;
}
aCells.push(c);
aValues.push(tmp);
}
});
// ToDo aboveAverage, beginsWith, cellIs, containsBlanks, containsErrors, // ToDo aboveAverage, beginsWith, cellIs, containsBlanks, containsErrors,
// ToDo containsText, dataBar, duplicateValues, endsWith, expression, iconSet, notContainsBlanks, // ToDo containsText, dataBar, duplicateValues, endsWith, expression, iconSet, notContainsBlanks,
// ToDo notContainsErrors, notContainsText, timePeriod, top10, uniqueValues (page 2679) // ToDo notContainsErrors, notContainsText, timePeriod, top10, uniqueValues (page 2679)
...@@ -3504,36 +3514,25 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) { ...@@ -3504,36 +3514,25 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
break; break;
} }
this.getRange3(sqref.r1, sqref.c1, sqref.r2, sqref.c2)._setPropertyNoEmpty(null, null, function(c) {
if (CellValueType.Number === c.getType() && false === c.isEmptyTextString()) {
tmp = parseFloat(c.getValueWithoutFormat());
if (isNaN(tmp)) {
return;
}
arrayCells.push({cell: c, val: tmp});
min = Math.min(min, tmp);
max = Math.max(max, tmp);
}
});
// ToDo CFVO Type (formula, max, min, num, percent, percentile) (page 2681) // ToDo CFVO Type (formula, max, min, num, percent, percentile) (page 2681)
// ToDo support 3 colors in rule // ToDo support 3 colors in rule
if (0 < arrayCells.length && 2 === oRuleElement.aColors.length) { if (0 < aCells.length && 2 === oRuleElement.aColors.length) {
oGradient = new AscCommonExcel.CGradient(oRuleElement.aColors[0], oRuleElement.aColors[1]); oGradient = new AscCommonExcel.CGradient(oRuleElement.aColors[0], oRuleElement.aColors[1]);
oGradient.init(min, max); oGradient.init(Math.min.apply(Math, aValues), Math.max.apply(Math, aValues));
for (cell = 0; cell < arrayCells.length; ++cell) { for (cell = 0; cell < aCells.length; ++cell) {
var dxf = new AscCommonExcel.CellXfs(); var dxf = new AscCommonExcel.CellXfs();
dxf.fill = new AscCommonExcel.Fill({bg: oGradient.calculateColor(arrayCells[cell].val)}); dxf.fill = new AscCommonExcel.Fill({bg: oGradient.calculateColor(aValues[cell])});
arrayCells[cell].cell.setConditionalFormattingStyle(dxf); aCells[cell].setConditionalFormattingStyle(dxf);
} }
} }
break;
arrayCells.length = 0; case Asc.ECfType.uniqueValues:
min = Number.MAX_VALUE;
max = -Number.MAX_VALUE;
break; break;
} }
aCells.length = 0;
aValues.length = 0;
} }
} }
} }
......
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