[SSE] Check chart data
This commit is contained in:
parent
15dd23ba04
commit
ad9cce3946
|
@ -123,7 +123,6 @@ define([
|
|||
|
||||
this.api = this.options.api;
|
||||
this.chartSettings = this.options.chartSettings;
|
||||
this.dataRangeValid = '';
|
||||
this.currentChartType = Asc.c_oAscChartTypeSettings.barNormal;
|
||||
},
|
||||
|
||||
|
@ -238,16 +237,9 @@ define([
|
|||
|
||||
var value = props.getRange();
|
||||
this.txtDataRange.setValue((value) ? value : '');
|
||||
this.dataRangeValid = value;
|
||||
|
||||
this.txtDataRange.validation = function(value) {
|
||||
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);
|
||||
|
@ -261,7 +253,6 @@ define([
|
|||
},
|
||||
|
||||
onDlgBtnClick: function(event) {
|
||||
var me = this;
|
||||
var state = (typeof(event) == 'object') ? event.currentTarget.attributes['result'].value : event;
|
||||
if (state == 'ok') {
|
||||
if (!this.isRangeValid()) return;
|
||||
|
@ -278,31 +269,43 @@ define([
|
|||
|
||||
isRangeValid: function() {
|
||||
var isvalid;
|
||||
if (!_.isEmpty(this.txtDataRange.getValue())) {
|
||||
isvalid = this.chartSettings.isValidRange(this.txtDataRange.getValue());
|
||||
if (isvalid === true || isvalid == Asc.c_oAscError.ID.No)
|
||||
return true;
|
||||
} else
|
||||
isvalid = this.chartSettings.isValidRange(this.txtDataRange.getValue());
|
||||
if (isvalid === true || isvalid == Asc.c_oAscError.ID.No)
|
||||
return true;
|
||||
|
||||
if (isvalid == Asc.c_oAscError.ID.StockChartError) {
|
||||
Common.UI.warning({msg: this.errorStockChart});
|
||||
} else if (isvalid == Asc.c_oAscError.ID.MaxDataSeriesError) {
|
||||
Common.UI.warning({msg: this.errorMaxRows});
|
||||
} else if (isvalid == Asc.c_oAscError.ID.MaxDataPointsError)
|
||||
Common.UI.warning({msg: this.errorMaxPoints});
|
||||
else {
|
||||
Common.UI.warning({msg: this.textInvalidRange});
|
||||
var error = this.textInvalidRange;
|
||||
switch (isvalid) {
|
||||
case Asc.c_oAscError.ID.StockChartError:
|
||||
error = this.errorStockChart;
|
||||
break;
|
||||
case Asc.c_oAscError.ID.MaxDataSeriesError:
|
||||
error = this.errorMaxRows;
|
||||
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;
|
||||
},
|
||||
|
||||
changeChartRange: function(settings) {
|
||||
var me = this;
|
||||
if (me.isRangeValid(settings)) {
|
||||
me.dataRangeValid = settings;
|
||||
me.txtDataRange.checkValidate();
|
||||
me.chartSettings.setRange(me.dataRangeValid);
|
||||
me.chartSettings.setRange(settings);
|
||||
|
||||
me.updateSeriesList(me.chartSettings.getSeries(), 0);
|
||||
me.updateCategoryList(me.chartSettings.getCatValues());
|
||||
|
@ -333,7 +336,7 @@ define([
|
|||
win.show(xy.left + 160, xy.top + 125);
|
||||
win.setSettings({
|
||||
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,
|
||||
validation: function() {return true;}
|
||||
});
|
||||
|
@ -357,6 +360,10 @@ define([
|
|||
this.updateMoveButtons();
|
||||
},
|
||||
|
||||
updateRange: function() {
|
||||
this.txtDataRange.setValue(this.chartSettings.getRange() || '');
|
||||
},
|
||||
|
||||
updateButtons: function() {
|
||||
this.btnEdit.setDisabled(this.seriesList.store.length<1);
|
||||
this.btnDelete.setDisabled(this.seriesList.store.length<1);
|
||||
|
@ -385,6 +392,7 @@ define([
|
|||
}
|
||||
var handlerDlg = function(dlg, result) {
|
||||
if (result == 'ok') {
|
||||
me.updateRange();
|
||||
me.updateSeriesList(me.chartSettings.getSeries(), me.seriesList.store.length-1);
|
||||
me.updateButtons();
|
||||
me.chartSettings.endEditData();
|
||||
|
@ -399,10 +407,10 @@ define([
|
|||
if (rec) {
|
||||
var order = rec.get('order');
|
||||
rec.get('series').asc_Remove();
|
||||
this.txtDataRange.setValue(this.chartSettings.getRange() || '');
|
||||
this.updateRange();
|
||||
this.updateSeriesList(this.chartSettings.getSeries(), order);
|
||||
this.updateButtons();
|
||||
}
|
||||
this.updateButtons();
|
||||
},
|
||||
|
||||
onEditSeries: function() {
|
||||
|
@ -414,6 +422,8 @@ define([
|
|||
var handlerDlg = function(dlg, result) {
|
||||
if (result == 'ok') {
|
||||
rec.set('value', series.asc_getSeriesName());
|
||||
me.updateRange();
|
||||
me.updateButtons();
|
||||
me.chartSettings.endEditData();
|
||||
me._isEditRanges = false;
|
||||
}
|
||||
|
@ -428,6 +438,8 @@ define([
|
|||
var handlerDlg = function(dlg, result) {
|
||||
if (result == 'ok') {
|
||||
me.updateCategoryList(me.chartSettings.getCatValues());
|
||||
me.updateRange();
|
||||
me.updateButtons();
|
||||
me.chartSettings.endEditData();
|
||||
me._isEditRanges = false;
|
||||
}
|
||||
|
@ -475,8 +487,9 @@ define([
|
|||
up ? rec.get('series').asc_MoveUp() : rec.get('series').asc_MoveDown();
|
||||
this.seriesList.selectRecord(rec);
|
||||
this.seriesList.scrollToRecord(rec);
|
||||
this.updateRange();
|
||||
this.updateButtons();
|
||||
}
|
||||
this.updateMoveButtons();
|
||||
},
|
||||
|
||||
updateSeriesList: function(series, index) {
|
||||
|
@ -520,6 +533,7 @@ define([
|
|||
this.chartSettings.switchRowCol();
|
||||
this.updateSeriesList(this.chartSettings.getSeries(), 0);
|
||||
this.updateCategoryList(this.chartSettings.getCatValues());
|
||||
this.updateRange();
|
||||
this.updateButtons();
|
||||
},
|
||||
|
||||
|
@ -539,6 +553,11 @@ define([
|
|||
textCategory: 'Horizontal (Category) Axis Labels',
|
||||
textUp: 'Up',
|
||||
textDown: 'Down',
|
||||
textData: 'Data'
|
||||
}, SSE.Views.ChartDataDialog || {}))
|
||||
textData: 'Data',
|
||||
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) {
|
||||
var isvalid;
|
||||
if (!_.isEmpty(value)) {
|
||||
switch (type) {
|
||||
case 1:
|
||||
if (this.props.series) {
|
||||
isvalid = this.props.series.asc_IsValidName(value);
|
||||
} else {
|
||||
isvalid = this.chartSettings.isValidCatFormula(value);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (this.props.isScatter) {
|
||||
isvalid = this.props.series.asc_IsValidXValues(value);
|
||||
} else {
|
||||
isvalid = this.props.series.asc_IsValidValues(value);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
isvalid = this.props.series.asc_IsValidYValues(value);
|
||||
break;
|
||||
}
|
||||
if (isvalid === true || isvalid == Asc.c_oAscError.ID.No)
|
||||
return true;
|
||||
} else
|
||||
switch (type) {
|
||||
case 1:
|
||||
if (this.props.series) {
|
||||
isvalid = this.props.series.asc_IsValidName(value);
|
||||
} else {
|
||||
isvalid = this.chartSettings.isValidCatFormula(value);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (this.props.isScatter) {
|
||||
isvalid = this.props.series.asc_IsValidXValues(value);
|
||||
} else {
|
||||
isvalid = this.props.series.asc_IsValidValues(value);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
isvalid = this.props.series.asc_IsValidYValues(value);
|
||||
break;
|
||||
}
|
||||
if (isvalid === true || isvalid == Asc.c_oAscError.ID.No)
|
||||
return true;
|
||||
|
||||
if (isvalid == Asc.c_oAscError.ID.StockChartError) {
|
||||
Common.UI.warning({msg: this.errorStockChart});
|
||||
} else if (isvalid == Asc.c_oAscError.ID.MaxDataSeriesError) {
|
||||
Common.UI.warning({msg: this.errorMaxRows});
|
||||
} else if (isvalid == Asc.c_oAscError.ID.MaxDataPointsError)
|
||||
Common.UI.warning({msg: this.errorMaxPoints});
|
||||
else
|
||||
Common.UI.warning({msg: this.textInvalidRange});
|
||||
var error = this.textInvalidRange;
|
||||
switch (isvalid) {
|
||||
case Asc.c_oAscError.ID.StockChartError:
|
||||
error = this.errorStockChart;
|
||||
break;
|
||||
case Asc.c_oAscError.ID.MaxDataSeriesError:
|
||||
error = this.errorMaxRows;
|
||||
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;
|
||||
},
|
||||
|
||||
|
@ -334,8 +348,8 @@ define([
|
|||
if (this.options.handler) {
|
||||
if (state == 'ok') {
|
||||
if (!this.isRangeValid(1, this.inputRange1.getValue())) return;
|
||||
if (this.type==1 && !this.isRangeValid(2, this.inputRange1.getValue())) return;
|
||||
if (this.type==1 && this.isScatter && !this.isRangeValid(3, 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.inputRange3.getValue())) return;
|
||||
}
|
||||
if (this.options.handler.call(this, this, state))
|
||||
return;
|
||||
|
@ -358,7 +372,11 @@ define([
|
|||
textError: 'ERROR!',
|
||||
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.',
|
||||
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 || {}))
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue