Commit 22c543df authored by GoshaZotov's avatar GoshaZotov Committed by Alexander.Trofimov

add functions for top10 filter

parent bb9f5934
......@@ -5369,6 +5369,7 @@ FilterColumn.prototype.createFilter = function(obj) {
}
case c_oAscAutoFilterTypes.Top10:
{
this.Top10 = obj.filter.filter.clone();
break;
}
case c_oAscAutoFilterTypes.Filters:
......@@ -5396,9 +5397,12 @@ FilterColumn.prototype.init = function(range) {
//добавляем данные, которые не передаются из меню при примененни а/ф(в данном случае только DynamicFilter)
if(null !== this.DynamicFilter)
{
var res = null;
this.DynamicFilter.init(range);
}
else if(null !== this.Top10)
{
this.Top10.init(range);
}
};
......@@ -6129,9 +6133,76 @@ Top10.prototype.clone = function() {
return res;
};
Top10.prototype.isHideValue = function(val, top10Length) {
return;
var res = false;
if(null !== this.filterVal)
{
if(this.Top)
{
if(val < this.FilterVal)
{
res = true;
}
}
else
{
if(val > this.FilterVal)
{
res = true;
}
}
}
return res;
};
Top10.prototype.init = function(range, reWrite){
var res = null;
var t = this;
if(null === this.FilterVal || true === reWrite)
{
if(range)
{
var arr = [];
var alreadyAddValues = {};
range._foreach2(function(cell){
var val = parseFloat(cell.getValue());
if(!isNaN(val) && !alreadyAddValues[val])
{
arr.push(val);
alreadyAddValues[val] = 1;
}
});
if(arr.length)
{
arr.sort(function(a, b){
var res;
if(t.Top)
{
res = b - a;
}
else
{
res = a - b;
}
return res;
});
res = arr[this.Val - 1];
}
}
}
if(null !== res)
{
this.FilterVal = res;
}
};
Top10.prototype.asc_getFilterVal = function () { return this.FilterVal; };
Top10.prototype.asc_getPercent = function () { return this.Percent; };
Top10.prototype.asc_getTop = function () { return this.Top; };
......
......@@ -12655,7 +12655,7 @@
if(filters && filters.ColorFilter)
{
filterObj.type = c_oAscAutoFilterTypes.ColorFilter;
filterObj.filter = filters.ColorFilter;
filterObj.filter = filters.ColorFilter.clone();
}
else if(filters && filters.CustomFiltersObj && filters.CustomFiltersObj.CustomFilters)
{
......@@ -12665,12 +12665,12 @@
else if(filters && filters.DynamicFilter)
{
filterObj.type = c_oAscAutoFilterTypes.DynamicFilter;
filterObj.filter = filters.DynamicFilter;
filterObj.filter = filters.DynamicFilter.clone();
}
else if(filters && filters.Top10)
{
filterObj.type = c_oAscAutoFilterTypes.Top10;
filterObj.filter = filters.Top10;
filterObj.filter = filters.Top10.clone();
}
else if(filters)
{
......
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