[SSE] Check chart data
This commit is contained in:
parent
15dd23ba04
commit
ad9cce3946
|
@ -123,7 +123,6 @@ define([
|
||||||
|
|
||||||
this.api = this.options.api;
|
this.api = this.options.api;
|
||||||
this.chartSettings = this.options.chartSettings;
|
this.chartSettings = this.options.chartSettings;
|
||||||
this.dataRangeValid = '';
|
|
||||||
this.currentChartType = Asc.c_oAscChartTypeSettings.barNormal;
|
this.currentChartType = Asc.c_oAscChartTypeSettings.barNormal;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -238,16 +237,9 @@ define([
|
||||||
|
|
||||||
var value = props.getRange();
|
var value = props.getRange();
|
||||||
this.txtDataRange.setValue((value) ? value : '');
|
this.txtDataRange.setValue((value) ? value : '');
|
||||||
this.dataRangeValid = value;
|
|
||||||
|
|
||||||
this.txtDataRange.validation = function(value) {
|
this.txtDataRange.validation = function(value) {
|
||||||
return true;
|
return true;
|
||||||
if (_.isEmpty(value)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, value, false);
|
|
||||||
return (isvalid==Asc.c_oAscError.ID.DataRangeError) ? (me.textError + ' ' + me.textInvalidRange) : true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.updateSeriesList(props.getSeries(), 0);
|
this.updateSeriesList(props.getSeries(), 0);
|
||||||
|
@ -261,7 +253,6 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
onDlgBtnClick: function(event) {
|
onDlgBtnClick: function(event) {
|
||||||
var me = this;
|
|
||||||
var state = (typeof(event) == 'object') ? event.currentTarget.attributes['result'].value : event;
|
var state = (typeof(event) == 'object') ? event.currentTarget.attributes['result'].value : event;
|
||||||
if (state == 'ok') {
|
if (state == 'ok') {
|
||||||
if (!this.isRangeValid()) return;
|
if (!this.isRangeValid()) return;
|
||||||
|
@ -278,31 +269,43 @@ define([
|
||||||
|
|
||||||
isRangeValid: function() {
|
isRangeValid: function() {
|
||||||
var isvalid;
|
var isvalid;
|
||||||
if (!_.isEmpty(this.txtDataRange.getValue())) {
|
isvalid = this.chartSettings.isValidRange(this.txtDataRange.getValue());
|
||||||
isvalid = this.chartSettings.isValidRange(this.txtDataRange.getValue());
|
if (isvalid === true || isvalid == Asc.c_oAscError.ID.No)
|
||||||
if (isvalid === true || isvalid == Asc.c_oAscError.ID.No)
|
|
||||||
return true;
|
|
||||||
} else
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (isvalid == Asc.c_oAscError.ID.StockChartError) {
|
var error = this.textInvalidRange;
|
||||||
Common.UI.warning({msg: this.errorStockChart});
|
switch (isvalid) {
|
||||||
} else if (isvalid == Asc.c_oAscError.ID.MaxDataSeriesError) {
|
case Asc.c_oAscError.ID.StockChartError:
|
||||||
Common.UI.warning({msg: this.errorMaxRows});
|
error = this.errorStockChart;
|
||||||
} else if (isvalid == Asc.c_oAscError.ID.MaxDataPointsError)
|
break;
|
||||||
Common.UI.warning({msg: this.errorMaxPoints});
|
case Asc.c_oAscError.ID.MaxDataSeriesError:
|
||||||
else {
|
error = this.errorMaxRows;
|
||||||
Common.UI.warning({msg: this.textInvalidRange});
|
break;
|
||||||
|
case Asc.c_oAscError.ID.MaxDataPointsError:
|
||||||
|
error = this.errorMaxPoints;
|
||||||
|
break;
|
||||||
|
case Asc.c_oAscError.ID.ErrorInFormula:
|
||||||
|
error = this.errorInFormula;
|
||||||
|
break;
|
||||||
|
case Asc.c_oAscError.ID.InvalidReference:
|
||||||
|
error = this.errorInvalidReference;
|
||||||
|
break;
|
||||||
|
case Asc.c_oAscError.ID.NoSingleRowCol:
|
||||||
|
error = this.errorNoSingleRowCol;
|
||||||
|
break;
|
||||||
|
case Asc.c_oAscError.ID.NoValues:
|
||||||
|
error = this.errorNoValues;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
Common.UI.warning({msg: error, maxwidth: 600});
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
changeChartRange: function(settings) {
|
changeChartRange: function(settings) {
|
||||||
var me = this;
|
var me = this;
|
||||||
if (me.isRangeValid(settings)) {
|
if (me.isRangeValid(settings)) {
|
||||||
me.dataRangeValid = settings;
|
|
||||||
me.txtDataRange.checkValidate();
|
me.txtDataRange.checkValidate();
|
||||||
me.chartSettings.setRange(me.dataRangeValid);
|
me.chartSettings.setRange(settings);
|
||||||
|
|
||||||
me.updateSeriesList(me.chartSettings.getSeries(), 0);
|
me.updateSeriesList(me.chartSettings.getSeries(), 0);
|
||||||
me.updateCategoryList(me.chartSettings.getCatValues());
|
me.updateCategoryList(me.chartSettings.getCatValues());
|
||||||
|
@ -333,7 +336,7 @@ define([
|
||||||
win.show(xy.left + 160, xy.top + 125);
|
win.show(xy.left + 160, xy.top + 125);
|
||||||
win.setSettings({
|
win.setSettings({
|
||||||
api : me.api,
|
api : me.api,
|
||||||
range : (!_.isEmpty(me.txtDataRange.getValue()) && (me.txtDataRange.checkValidate()==true)) ? me.txtDataRange.getValue() : me.dataRangeValid,
|
range : me.txtDataRange.getValue(),
|
||||||
type : Asc.c_oAscSelectionDialogType.Chart,
|
type : Asc.c_oAscSelectionDialogType.Chart,
|
||||||
validation: function() {return true;}
|
validation: function() {return true;}
|
||||||
});
|
});
|
||||||
|
@ -357,6 +360,10 @@ define([
|
||||||
this.updateMoveButtons();
|
this.updateMoveButtons();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateRange: function() {
|
||||||
|
this.txtDataRange.setValue(this.chartSettings.getRange() || '');
|
||||||
|
},
|
||||||
|
|
||||||
updateButtons: function() {
|
updateButtons: function() {
|
||||||
this.btnEdit.setDisabled(this.seriesList.store.length<1);
|
this.btnEdit.setDisabled(this.seriesList.store.length<1);
|
||||||
this.btnDelete.setDisabled(this.seriesList.store.length<1);
|
this.btnDelete.setDisabled(this.seriesList.store.length<1);
|
||||||
|
@ -385,6 +392,7 @@ define([
|
||||||
}
|
}
|
||||||
var handlerDlg = function(dlg, result) {
|
var handlerDlg = function(dlg, result) {
|
||||||
if (result == 'ok') {
|
if (result == 'ok') {
|
||||||
|
me.updateRange();
|
||||||
me.updateSeriesList(me.chartSettings.getSeries(), me.seriesList.store.length-1);
|
me.updateSeriesList(me.chartSettings.getSeries(), me.seriesList.store.length-1);
|
||||||
me.updateButtons();
|
me.updateButtons();
|
||||||
me.chartSettings.endEditData();
|
me.chartSettings.endEditData();
|
||||||
|
@ -399,10 +407,10 @@ define([
|
||||||
if (rec) {
|
if (rec) {
|
||||||
var order = rec.get('order');
|
var order = rec.get('order');
|
||||||
rec.get('series').asc_Remove();
|
rec.get('series').asc_Remove();
|
||||||
this.txtDataRange.setValue(this.chartSettings.getRange() || '');
|
this.updateRange();
|
||||||
this.updateSeriesList(this.chartSettings.getSeries(), order);
|
this.updateSeriesList(this.chartSettings.getSeries(), order);
|
||||||
|
this.updateButtons();
|
||||||
}
|
}
|
||||||
this.updateButtons();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onEditSeries: function() {
|
onEditSeries: function() {
|
||||||
|
@ -414,6 +422,8 @@ define([
|
||||||
var handlerDlg = function(dlg, result) {
|
var handlerDlg = function(dlg, result) {
|
||||||
if (result == 'ok') {
|
if (result == 'ok') {
|
||||||
rec.set('value', series.asc_getSeriesName());
|
rec.set('value', series.asc_getSeriesName());
|
||||||
|
me.updateRange();
|
||||||
|
me.updateButtons();
|
||||||
me.chartSettings.endEditData();
|
me.chartSettings.endEditData();
|
||||||
me._isEditRanges = false;
|
me._isEditRanges = false;
|
||||||
}
|
}
|
||||||
|
@ -428,6 +438,8 @@ define([
|
||||||
var handlerDlg = function(dlg, result) {
|
var handlerDlg = function(dlg, result) {
|
||||||
if (result == 'ok') {
|
if (result == 'ok') {
|
||||||
me.updateCategoryList(me.chartSettings.getCatValues());
|
me.updateCategoryList(me.chartSettings.getCatValues());
|
||||||
|
me.updateRange();
|
||||||
|
me.updateButtons();
|
||||||
me.chartSettings.endEditData();
|
me.chartSettings.endEditData();
|
||||||
me._isEditRanges = false;
|
me._isEditRanges = false;
|
||||||
}
|
}
|
||||||
|
@ -475,8 +487,9 @@ define([
|
||||||
up ? rec.get('series').asc_MoveUp() : rec.get('series').asc_MoveDown();
|
up ? rec.get('series').asc_MoveUp() : rec.get('series').asc_MoveDown();
|
||||||
this.seriesList.selectRecord(rec);
|
this.seriesList.selectRecord(rec);
|
||||||
this.seriesList.scrollToRecord(rec);
|
this.seriesList.scrollToRecord(rec);
|
||||||
|
this.updateRange();
|
||||||
|
this.updateButtons();
|
||||||
}
|
}
|
||||||
this.updateMoveButtons();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
updateSeriesList: function(series, index) {
|
updateSeriesList: function(series, index) {
|
||||||
|
@ -520,6 +533,7 @@ define([
|
||||||
this.chartSettings.switchRowCol();
|
this.chartSettings.switchRowCol();
|
||||||
this.updateSeriesList(this.chartSettings.getSeries(), 0);
|
this.updateSeriesList(this.chartSettings.getSeries(), 0);
|
||||||
this.updateCategoryList(this.chartSettings.getCatValues());
|
this.updateCategoryList(this.chartSettings.getCatValues());
|
||||||
|
this.updateRange();
|
||||||
this.updateButtons();
|
this.updateButtons();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -539,6 +553,11 @@ define([
|
||||||
textCategory: 'Horizontal (Category) Axis Labels',
|
textCategory: 'Horizontal (Category) Axis Labels',
|
||||||
textUp: 'Up',
|
textUp: 'Up',
|
||||||
textDown: 'Down',
|
textDown: 'Down',
|
||||||
textData: 'Data'
|
textData: 'Data',
|
||||||
}, SSE.Views.ChartDataDialog || {}))
|
errorInFormula: "There's an error in formula you entered.",
|
||||||
|
errorInvalidReference: 'The reference is not valid. Reference must be to an open worksheet.',
|
||||||
|
errorNoSingleRowCol: 'The reference is not valid. References for titles, values, sizes, or data labels must be a single cell, row, or column.',
|
||||||
|
errorNoValues: 'To create a chart, the series must contain at least one value.'
|
||||||
|
|
||||||
|
}, SSE.Views.ChartDataDialog || {}))
|
||||||
});
|
});
|
||||||
|
|
|
@ -256,39 +256,53 @@ define([
|
||||||
|
|
||||||
isRangeValid: function(type, value) {
|
isRangeValid: function(type, value) {
|
||||||
var isvalid;
|
var isvalid;
|
||||||
if (!_.isEmpty(value)) {
|
switch (type) {
|
||||||
switch (type) {
|
case 1:
|
||||||
case 1:
|
if (this.props.series) {
|
||||||
if (this.props.series) {
|
isvalid = this.props.series.asc_IsValidName(value);
|
||||||
isvalid = this.props.series.asc_IsValidName(value);
|
} else {
|
||||||
} else {
|
isvalid = this.chartSettings.isValidCatFormula(value);
|
||||||
isvalid = this.chartSettings.isValidCatFormula(value);
|
}
|
||||||
}
|
break;
|
||||||
break;
|
case 2:
|
||||||
case 2:
|
if (this.props.isScatter) {
|
||||||
if (this.props.isScatter) {
|
isvalid = this.props.series.asc_IsValidXValues(value);
|
||||||
isvalid = this.props.series.asc_IsValidXValues(value);
|
} else {
|
||||||
} else {
|
isvalid = this.props.series.asc_IsValidValues(value);
|
||||||
isvalid = this.props.series.asc_IsValidValues(value);
|
}
|
||||||
}
|
break;
|
||||||
break;
|
case 3:
|
||||||
case 3:
|
isvalid = this.props.series.asc_IsValidYValues(value);
|
||||||
isvalid = this.props.series.asc_IsValidYValues(value);
|
break;
|
||||||
break;
|
}
|
||||||
}
|
if (isvalid === true || isvalid == Asc.c_oAscError.ID.No)
|
||||||
if (isvalid === true || isvalid == Asc.c_oAscError.ID.No)
|
|
||||||
return true;
|
|
||||||
} else
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (isvalid == Asc.c_oAscError.ID.StockChartError) {
|
var error = this.textInvalidRange;
|
||||||
Common.UI.warning({msg: this.errorStockChart});
|
switch (isvalid) {
|
||||||
} else if (isvalid == Asc.c_oAscError.ID.MaxDataSeriesError) {
|
case Asc.c_oAscError.ID.StockChartError:
|
||||||
Common.UI.warning({msg: this.errorMaxRows});
|
error = this.errorStockChart;
|
||||||
} else if (isvalid == Asc.c_oAscError.ID.MaxDataPointsError)
|
break;
|
||||||
Common.UI.warning({msg: this.errorMaxPoints});
|
case Asc.c_oAscError.ID.MaxDataSeriesError:
|
||||||
else
|
error = this.errorMaxRows;
|
||||||
Common.UI.warning({msg: this.textInvalidRange});
|
break;
|
||||||
|
case Asc.c_oAscError.ID.MaxDataPointsError:
|
||||||
|
error = this.errorMaxPoints;
|
||||||
|
break;
|
||||||
|
case Asc.c_oAscError.ID.ErrorInFormula:
|
||||||
|
error = this.errorInFormula;
|
||||||
|
break;
|
||||||
|
case Asc.c_oAscError.ID.InvalidReference:
|
||||||
|
error = this.errorInvalidReference;
|
||||||
|
break;
|
||||||
|
case Asc.c_oAscError.ID.NoSingleRowCol:
|
||||||
|
error = this.errorNoSingleRowCol;
|
||||||
|
break;
|
||||||
|
case Asc.c_oAscError.ID.NoValues:
|
||||||
|
error = this.errorNoValues;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Common.UI.warning({msg: error, maxwidth: 600});
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -334,8 +348,8 @@ define([
|
||||||
if (this.options.handler) {
|
if (this.options.handler) {
|
||||||
if (state == 'ok') {
|
if (state == 'ok') {
|
||||||
if (!this.isRangeValid(1, this.inputRange1.getValue())) return;
|
if (!this.isRangeValid(1, this.inputRange1.getValue())) return;
|
||||||
if (this.type==1 && !this.isRangeValid(2, this.inputRange1.getValue())) return;
|
if (this.type==1 && !this.isRangeValid(2, this.inputRange2.getValue())) return;
|
||||||
if (this.type==1 && this.isScatter && !this.isRangeValid(3, this.inputRange1.getValue())) return;
|
if (this.type==1 && this.isScatter && !this.isRangeValid(3, this.inputRange3.getValue())) return;
|
||||||
}
|
}
|
||||||
if (this.options.handler.call(this, this, state))
|
if (this.options.handler.call(this, this, state))
|
||||||
return;
|
return;
|
||||||
|
@ -358,7 +372,11 @@ define([
|
||||||
textError: 'ERROR!',
|
textError: 'ERROR!',
|
||||||
errorMaxRows: 'The maximum number of data series per chart is 255.',
|
errorMaxRows: 'The maximum number of data series per chart is 255.',
|
||||||
errorStockChart: 'Incorrect row order. To build a stock chart place the data on the sheet in the following order:<br> opening price, max price, min price, closing price.',
|
errorStockChart: 'Incorrect row order. To build a stock chart place the data on the sheet in the following order:<br> opening price, max price, min price, closing price.',
|
||||||
errorMaxPoints: 'The maximum number of points in series per chart is 4096.'
|
errorMaxPoints: 'The maximum number of points in series per chart is 4096.',
|
||||||
|
errorInFormula: "There's an error in formula you entered.",
|
||||||
|
errorInvalidReference: 'The reference is not valid. Reference must be to an open worksheet.',
|
||||||
|
errorNoSingleRowCol: 'The reference is not valid. References for titles, values, sizes, or data labels must be a single cell, row, or column.',
|
||||||
|
errorNoValues: 'To create a chart, the series must contain at least one value.'
|
||||||
|
|
||||||
}, SSE.Views.ChartDataRangeDialog || {}))
|
}, SSE.Views.ChartDataRangeDialog || {}))
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue