[SSE] Switch chart row/column from right panel

This commit is contained in:
Julia Radzhabova 2022-01-13 23:59:39 +03:00
parent 0cc5275625
commit abe351d408
3 changed files with 43 additions and 2 deletions

View file

@ -40,6 +40,11 @@
<div id="chart-btn-select-data" style="width:100%;"></div> <div id="chart-btn-select-data" style="width:100%;"></div>
</td> </td>
</tr> </tr>
<tr>
<td class="padding-small">
<div id="chart-btn-switch" style="width:100%;"></div>
</td>
</tr>
</table> </table>
<table cols="1" id="spark-panel-types"> <table cols="1" id="spark-panel-types">
<tr> <tr>

View file

@ -222,6 +222,10 @@ define([
this.btnRatio.toggle(value); this.btnRatio.toggle(value);
this._state.keepRatio=value; this._state.keepRatio=value;
} }
var chartSettings = this.api.asc_getChartObject(),
series = chartSettings ? chartSettings.getSeries() : null;
this.btnSwitch.setDisabled(!series || series.length<1 || !chartSettings || !chartSettings.getRange());
} else { //sparkline } else { //sparkline
this._originalProps = props; this._originalProps = props;
this.isChart = false; this.isChart = false;
@ -774,6 +778,19 @@ define([
this.btnSelectData.on('click', _.bind(this.onSelectData, this)); this.btnSelectData.on('click', _.bind(this.onSelectData, this));
this.lockedControls.push(this.btnSelectData); this.lockedControls.push(this.btnSelectData);
this.btnSwitch = new Common.UI.Button({
parentEl: $('#chart-btn-switch'),
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-select-range',
caption : this.textSwitch,
style : 'width: 100%;text-align: left;',
dataHint : '1',
dataHintDirection: 'left',
dataHintOffset: 'small'
});
this.btnSwitch.on('click', _.bind(this.onSwitch, this));
this.lockedControls.push(this.btnSwitch);
this.linkAdvanced = $('#chart-advanced-link'); this.linkAdvanced = $('#chart-advanced-link');
$(this.el).on('click', '#chart-advanced-link', _.bind(this.openAdvancedSettings, this)); $(this.el).on('click', '#chart-advanced-link', _.bind(this.openAdvancedSettings, this));
}, },
@ -1247,7 +1264,22 @@ define([
} }
Common.NotificationCenter.trigger('edit:complete', this); Common.NotificationCenter.trigger('edit:complete', this);
}, },
onSwitch: function() {
if (this.api){
var props = this.api.asc_getChartObject();
if (props) {
props.startEdit();
var res = props.switchRowCol();
if (res === Asc.c_oAscError.ID.MaxDataSeriesError) {
props.cancelEdit();
Common.UI.warning({msg: this.errorMaxRows, maxwidth: 600});
} else
props.endEdit();
}
}
},
setLocked: function (locked) { setLocked: function (locked) {
this._locked = locked; this._locked = locked;
}, },
@ -1286,7 +1318,9 @@ define([
textSelectData: 'Select Data', textSelectData: 'Select Data',
textRanges: 'Data Range', textRanges: 'Data Range',
textBorderSizeErr: 'The entered value is incorrect.<br>Please enter a value between 0 pt and 1584 pt.', textBorderSizeErr: 'The entered value is incorrect.<br>Please enter a value between 0 pt and 1584 pt.',
textChangeType: 'Change type' textChangeType: 'Change type',
textSwitch: 'Switch Row/Column',
errorMaxRows: 'The maximum number of data series per chart is 255.'
}, SSE.Views.ChartSettings || {})); }, SSE.Views.ChartSettings || {}));
}); });

View file

@ -1599,6 +1599,8 @@
"SSE.Views.ChartSettings.textStyle": "Style", "SSE.Views.ChartSettings.textStyle": "Style",
"SSE.Views.ChartSettings.textType": "Type", "SSE.Views.ChartSettings.textType": "Type",
"SSE.Views.ChartSettings.textWidth": "Width", "SSE.Views.ChartSettings.textWidth": "Width",
"SSE.Views.ChartSettings.textSwitch": "Switch Row/Column",
"SSE.Views.ChartSettings.errorMaxRows": "The maximum number of data series per chart is 255.",
"SSE.Views.ChartSettingsDlg.errorMaxPoints": "ERROR! The maximum number of points in series per chart is 4096.", "SSE.Views.ChartSettingsDlg.errorMaxPoints": "ERROR! The maximum number of points in series per chart is 4096.",
"SSE.Views.ChartSettingsDlg.errorMaxRows": "ERROR! The maximum number of data series per chart is 255", "SSE.Views.ChartSettingsDlg.errorMaxRows": "ERROR! The maximum number of data series per chart is 255",
"SSE.Views.ChartSettingsDlg.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.", "SSE.Views.ChartSettingsDlg.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.",