[SSE] Optimization of category list in Chart data

This commit is contained in:
JuliaSvinareva
2023-01-31 18:04:31 +03:00
parent 30789f83df
commit 134a3e32c8

View File

@ -125,12 +125,16 @@ define([
this.api = this.options.api;
this.chartSettings = this.options.chartSettings;
this.currentChartType = Asc.c_oAscChartTypeSettings.barNormal;
this._isOpen = false;
},
render: function() {
Common.Views.AdvancedSettingsWindow.prototype.render.call(this);
var me = this;
this.on('animate:after', _.bind(this.onAnimateAfter, this));
this.txtDataRange = new Common.UI.InputFieldBtn({
el : $('#chart-dlg-txt-range'),
name : 'range',
@ -225,6 +229,13 @@ define([
this._setDefaults(this.chartSettings);
},
onAnimateAfter: function () {
if (this.chartSettings) {
this.updateCategoryList(this.chartSettings.getCatValues(), true);
this._isOpen = true;
}
},
close: function () {
this.api.asc_onCloseChartFrame();
Common.Views.AdvancedSettingsWindow.prototype.close.apply(this, arguments);
@ -513,20 +524,37 @@ define([
(len>0) && this.seriesList.selectByIndex(Math.min(index || 0, store.length-1));
},
updateCategoryList: function(categories) {
var arr = [];
var store = this.categoryList.store;
for (var i = 0, len = categories.length; i < len; i++)
{
var item = categories[i],
rec = new Common.UI.DataViewModel();
rec.set({
value: item
});
arr.push(rec);
updateCategoryList: function(categories, afterAnimate) {
var store = this.categoryList.store,
len = categories.length;
var getModels = function (data) {
var models = [];
for (var i = 0, len = data.length; i < len; i++) {
var item = data[i],
rec = new Common.UI.DataViewModel();
rec.set({
value: item
});
models.push(rec);
}
return models;
}
if (!afterAnimate) {
if (categories.length < 10) {
store.reset(getModels(categories));
} else {
store.reset(getModels(categories.slice(0, 9)));
if (this._isOpen) {
_.defer(function () {
store.add(getModels(categories.slice(10)));
}, 0);
}
}
(len>0) && this.categoryList.selectByIndex(0);
} else if (len > store.length) {
store.add(getModels(categories.slice(10)));
}
store.reset(arr);
(len>0) && this.categoryList.selectByIndex(0);
},
onSwitch: function() {