/* * (c) Copyright Ascensio System SIA 2010-2024 * * This program is a free software product. You can redistribute it and/or * modify it under the terms of the GNU Affero General Public License (AGPL) * version 3 as published by the Free Software Foundation. In accordance with * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect * that Ascensio System SIA expressly excludes the warranty of non-infringement * of any third-party rights. * * This program is distributed WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html * * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish * street, Riga, Latvia, EU, LV-1050. * * The interactive user interfaces in modified source and object code versions * of the Program must display Appropriate Legal Notices, as required under * Section 5 of the GNU AGPL version 3. * * Pursuant to Section 7(b) of the License you must retain the original Product * logo when distributing the program. Pursuant to Section 7(e) we decline to * grant you any rights under trademark law for use of our trademarks. * * All the Product's GUI elements, including illustrations and icon sets, as * well as technical writing content are licensed under the terms of the * Creative Commons Attribution-ShareAlike 4.0 International. See the License * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ /** * ChartSettingsDlg.js * * Created on 4/04/14 * */ define([ 'text!spreadsheeteditor/main/app/template/ChartSettingsDlg.template', 'text!common/main/lib/template/ChartVertAxis.template', 'text!common/main/lib/template/ChartHorAxis.template', 'common/main/lib/view/AdvancedSettingsWindow', ], function (contentTemplate, vertTemplate, horTemplate) { 'use strict'; SSE.Views.ChartSettingsDlg = Common.Views.AdvancedSettingsWindow.extend(_.extend({ options: { contentWidth: 340, contentHeight: 460, toggleGroup: 'chart-settings-dlg-group', storageName: 'sse-chart-settings-adv-category' }, initialize : function(options) { _.extend(this.options, { title: this.textTitle, items: [ {panelId: 'id-chart-settings-dlg-style', panelCaption: this.textType}, {panelId: 'id-chart-settings-dlg-layout', panelCaption: this.textLayout}, {panelId: 'id-chart-settings-dlg-vert', panelCaption: this.textVertAxis}, {panelId: 'id-chart-settings-dlg-vert-sec', panelCaption: this.textVertAxisSec}, {panelId: 'id-chart-settings-dlg-hor', panelCaption: this.textHorAxis}, {panelId: 'id-chart-settings-dlg-hor-sec', panelCaption: this.textHorAxisSec}, {panelId: 'id-spark-settings-dlg-style', panelCaption: this.textTypeData}, {panelId: 'id-spark-settings-dlg-axis', panelCaption: this.textAxisOptions}, {panelId: 'id-chart-settings-dlg-snap', panelCaption: this.textSnap}, {panelId: 'id-chart-settings-dlg-alttext', panelCaption: this.textAlt} ], contentTemplate: _.template(contentTemplate)({ scope: this }) }, options); this.options.handler = function(result, value) { if ( result != 'ok' || this.isRangeValid() ) { if (options.handler) options.handler.call(this, result, value); return; } return true; }; Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); this._state = { ChartType: Asc.c_oAscChartTypeSettings.barNormal, SparkType: -1 }; this._noApply = true; this._changedProps = null; this._changedImageProps = null; this.api = this.options.api; this.chartSettings = this.options.chartSettings; this.imageSettings = this.options.imageSettings; this.sparklineStyles = this.options.sparklineStyles; this.isChart = this.options.isChart; this.isDiagramMode = !!this.options.isDiagramMode; this.vertAxisProps = []; this.vertAxisPropsIndexes = []; this.horAxisProps = []; this.horAxisPropsIndexes = []; this.currentAxisProps = []; this.dataRangeValid = ''; this.sparkDataRangeValid = ''; this.dataLocationRangeValid = ''; this.currentChartType = this._state.ChartType; this.storageName = (this.isChart) ? 'sse-chart-settings-adv-category' : 'sse-spark-settings-adv-category'; }, render: function() { Common.Views.AdvancedSettingsWindow.prototype.render.call(this); var me = this; var $window = this.getChild(); // Layout if (this.isDiagramMode) { this.btnChartType = new Common.UI.Button({ cls: 'btn-large-dataview', iconCls: 'svgicon chart-bar-normal', menu: new Common.UI.Menu({ style: 'width: 364px;', additionalAlign: this.menuAddAlign, items: [ {template: _.template('
')} ] }) }); this.btnChartType.on('render:after', function (btn) { me.mnuChartTypePicker = new Common.UI.DataView({ el: $('#id-chart-dlg-menu-type'), parentMenu: btn.menu, restoreHeight: 535, groups: new Common.UI.DataViewGroupStore(Common.define.chartData.getChartGroupData()), store: new Common.UI.DataViewStore(Common.define.chartData.getChartData()), itemTemplate: _.template('') }); }); this.btnChartType.render($('#chart-dlg-button-type')); this.mnuChartTypePicker.on('item:click', _.bind(this.onSelectType, this, this.btnChartType)); } this.cmbChartTitle = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-chart-title'), menuStyle: 'min-width: 100%;', editable: false, cls: 'input-group-nr', data: [ {value: Asc.c_oAscChartTitleShowSettings.none, displayValue: this.textNone}, {value: Asc.c_oAscChartTitleShowSettings.overlay, displayValue: this.textOverlay}, {value: Asc.c_oAscChartTitleShowSettings.noOverlay, displayValue: this.textNoOverlay} ], takeFocusOnClose: true }); this.cmbLegendPos = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-legend-pos'), menuStyle: 'min-width: 100%;', editable: false, cls: 'input-group-nr', data: [ {value: Asc.c_oAscChartLegendShowSettings.none, displayValue: this.textNone}, {value: Asc.c_oAscChartLegendShowSettings.bottom, displayValue: this.textLegendBottom}, {value: Asc.c_oAscChartLegendShowSettings.top, displayValue: this.textLegendTop}, {value: Asc.c_oAscChartLegendShowSettings.right, displayValue: this.textLegendRight}, {value: Asc.c_oAscChartLegendShowSettings.left, displayValue: this.textLegendLeft}, {value: Asc.c_oAscChartLegendShowSettings.leftOverlay, displayValue: this.textLeftOverlay}, {value: Asc.c_oAscChartLegendShowSettings.rightOverlay, displayValue: this.textRightOverlay} ], takeFocusOnClose: true }); this.cmbDataLabels = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-data-labels'), menuStyle: 'min-width: 100%;', editable: false, cls: 'input-group-nr', data: [ {value: Asc.c_oAscChartDataLabelsPos.none, displayValue: this.textNone}, {value: Asc.c_oAscChartDataLabelsPos.ctr, displayValue: this.textCenter}, {value: Asc.c_oAscChartDataLabelsPos.inBase, displayValue: this.textInnerBottom}, {value: Asc.c_oAscChartDataLabelsPos.inEnd, displayValue: this.textInnerTop}, {value: Asc.c_oAscChartDataLabelsPos.outEnd, displayValue: this.textOuterTop} ], takeFocusOnClose: true }); this.cmbDataLabels.on('selected', _.bind(me.onSelectDataLabels, this)); this.txtSeparator = new Common.UI.InputField({ el: $('#chart-dlg-txt-separator'), name: 'range', style: 'width: 100%;', allowBlank: true, blankError: this.txtEmpty }); this.chSeriesName = new Common.UI.CheckBox({ el: $('#chart-dlg-check-series'), labelText: this.textSeriesName }); this.chCategoryName = new Common.UI.CheckBox({ el: $('#chart-dlg-check-category'), labelText: this.textCategoryName }); this.chValue = new Common.UI.CheckBox({ el: $('#chart-dlg-check-value'), labelText: this.textValue }); this.cmbLines = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-lines'), menuStyle: 'min-width: 100%;', editable: false, cls: 'input-group-nr', data: [ {value: 0, displayValue: this.textNone}, {value: 1, displayValue: this.textStraight}, {value: 2, displayValue: this.textSmooth} ], takeFocusOnClose: true }).on('selected', _.bind(function (combo, record) { if (this.chartSettings) { this.chartSettings.putLine(record.value !== 0); if (record.value > 0) this.chartSettings.putSmooth(record.value == 2); } }, this)); this.chMarkers = new Common.UI.CheckBox({ el: $('#chart-dlg-check-markers'), labelText: this.textMarkers }).on('change', _.bind(function (checkbox, state) { if (this.chartSettings) this.chartSettings.putShowMarker(state == 'checked'); }, this)); this.lblLines = $('#chart-dlg-label-lines'); this.chShowEquation = new Common.UI.CheckBox({ el: $('#chart-dlg-chk-show-equation'), labelText: this.textShowEquation }).on('change', _.bind(function (checkbox, state) { if (this.chartSettings) this.chartSettings.putDisplayTrendlinesEquation(state==='checked'); }, this)); // Vertical Axis this.cmbMinType = []; this.spnMinValue = []; this.cmbMaxType = []; this.spnMaxValue = []; this.cmbVCrossType = []; this.spnVAxisCrosses = []; this.cmbUnits = []; this.chVReverse = []; this.cmbVMajorType = []; this.cmbVMinorType = []; this.cmbVLabelPos = []; this.cmbVertTitle = []; this.cmbVertGrid = []; this.chVertHide = []; this.btnVFormat = []; this.chVLogScale = []; this.spnBase = []; this._arrVertTitle = [ {value: Asc.c_oAscChartVertAxisLabelShowSettings.none, displayValue: me.textNone}, {value: Asc.c_oAscChartVertAxisLabelShowSettings.rotated, displayValue: me.textRotated}, {value: Asc.c_oAscChartVertAxisLabelShowSettings.horizontal, displayValue: me.textHorizontal} ]; // Horizontal Axis this.cmbHCrossType = []; this.cmbAxisPos = []; this.spnHAxisCrosses = []; this.chHReverse = []; this.cmbHMajorType = []; this.cmbHMinorType = []; this.spnMarksInterval = []; this.cmbHLabelPos = []; this.spnLabelDist = []; this.cmbLabelInterval = []; this.spnLabelInterval = []; this.cmbHorTitle = []; this.cmbHorGrid = []; this.chHorHide = []; this.btnHFormat = []; this._arrHorTitle = [ {value: Asc.c_oAscChartHorAxisLabelShowSettings.none, displayValue: me.textNone}, {value: Asc.c_oAscChartHorAxisLabelShowSettings.noOverlay, displayValue: me.textNoOverlay} ]; // Sparklines this.btnSparkType = new Common.UI.Button({ cls : 'btn-large-dataview', iconCls : 'svgicon chart-spark-column', menu : new Common.UI.Menu({ style: 'width: 167px;', additionalAlign: this.menuAddAlign, items: [ { template: _.template('') } ] }), takeFocusOnClose: true }); this.btnSparkType.on('render:after', function(btn) { me.mnuSparkTypePicker = new Common.UI.DataView({ el: $('#id-spark-dlg-menu-type'), parentMenu: btn.menu, restoreHeight: 120, groups: new Common.UI.DataViewGroupStore(Common.define.chartData.getSparkGroupData()), store: new Common.UI.DataViewStore(Common.define.chartData.getSparkData()), itemTemplate: _.template('') }); }); this.btnSparkType.render($('#spark-dlg-button-type')); this.mnuSparkTypePicker.on('item:click', _.bind(this.onSelectSparkType, this, this.btnSparkType)); this.cmbSparkStyle = new Common.UI.ComboDataView({ itemWidth: 50, itemHeight: 50, menuMaxHeight: 272, enableKeyEvents: true, cls: 'combo-spark-style', minWidth: 190 }); this.cmbSparkStyle.render($('#spark-dlg-combo-style')); this.cmbSparkStyle.on('click', _.bind(this.onSelectSparkStyle, this)); this.cmbSparkStyle.openButton.menu.on('show:after', function () { me.cmbSparkStyle.menuPicker.scroller.update({alwaysVisibleY: true}); }); /* this.radioGroup = new Common.UI.RadioBox({ el: $('#spark-dlg-radio-group'), labelText: this.textGroup, name: 'asc-radio-sparkline', checked: true }); this.radioSingle = new Common.UI.RadioBox({ el: $('#spark-dlg-radio-single'), labelText: this.textSingle, name: 'asc-radio-sparkline' }); this.txtSparkDataRange = new Common.UI.InputFieldBtn({ el : $('#spark-dlg-txt-range'), name : 'range', style : 'width: 100%;', btnHint : this.textSelectData, allowBlank : true, blankError : this.txtEmpty, validateOnChange: true }); this.txtSparkDataRange.on('button:click', _.bind(this.onSelectSparkData, this)); this.txtSparkDataLocation = new Common.UI.InputFieldBtn({ el : $('#spark-dlg-txt-location'), name : 'range', style : 'width: 100%;', btnHint : this.textSelectData, allowBlank : true, blankError : this.txtEmpty, validateOnChange: true }); this.txtSparkDataLocation.on('button:click', _.bind(this.onSelectLocationData, this)); */ this._arrEmptyCells = [ { value: Asc.c_oAscEDispBlanksAs.Gap, displayValue: this.textGaps }, { value: Asc.c_oAscEDispBlanksAs.Zero, displayValue: this.textZero }, { value: Asc.c_oAscEDispBlanksAs.Span, displayValue: this.textEmptyLine } ]; this.cmbEmptyCells = new Common.UI.ComboBox({ el : $('#spark-dlg-combo-empty'), menuStyle : 'min-width: 220px;', editable : false, cls : 'input-group-nr', takeFocusOnClose: true }); this.cmbEmptyCells.on('selected', _.bind(function(combo, record){ if (this._changedProps) { this._changedProps.asc_setDisplayEmpty(record.value); } }, this)); this.chShowEmpty = new Common.UI.CheckBox({ el: $('#spark-dlg-check-show-data'), labelText: this.textShowData }); this.chShowEmpty.on('change', _.bind(function(field, newValue, oldValue, eOpts){ if (this._changedProps) { this._changedProps.asc_setDisplayHidden(field.getValue()=='checked'); } }, this)); // Sparkline axis this.chShowAxis = new Common.UI.CheckBox({ el: $('#spark-dlg-check-show'), labelText: this.textShowSparkAxis }); this.chShowAxis.on('change', _.bind(function(field, newValue, oldValue, eOpts){ if (this._changedProps) { this._changedProps.asc_setDisplayXAxis(field.getValue()=='checked'); } }, this)); this.chReverse = new Common.UI.CheckBox({ el: $('#spark-dlg-check-reverse'), labelText: this.textReverseOrder }); this.chReverse.on('change', _.bind(function(field, newValue, oldValue, eOpts){ if (this._changedProps) { this._changedProps.asc_setRightToLeft(field.getValue()=='checked'); } }, this)); this.cmbSparkMinType = new Common.UI.ComboBox({ el : $('#spark-dlg-combo-mintype'), cls : 'input-group-nr', menuStyle : 'min-width: 100%;', editable : false, data : [ {displayValue: this.textAutoEach, value: Asc.c_oAscSparklineAxisMinMax.Individual}, {displayValue: this.textSameAll, value: Asc.c_oAscSparklineAxisMinMax.Group}, {displayValue: this.textFixed, value: Asc.c_oAscSparklineAxisMinMax.Custom} ], takeFocusOnClose: true }).on('selected', _.bind(function(combo, record) { this.spnSparkMinValue.setDisabled(record.value!==Asc.c_oAscSparklineAxisMinMax.Custom); if (this._changedProps) { this._changedProps.asc_setMinAxisType(record.value); } if (record.value==Asc.c_oAscSparklineAxisMinMax.Custom && _.isEmpty(this.spnSparkMinValue.getValue())) this.spnSparkMinValue.setValue(0); }, this)); this.spnSparkMinValue = new Common.UI.MetricSpinner({ el : $('#spark-dlg-input-min-value'), maxValue : 1000000, minValue : -1000000, step : 0.1, defaultUnit : "", defaultValue : 0, value : '' }).on('change', _.bind(function(field, newValue, oldValue) { if (this._changedProps) { this._changedProps.asc_setManualMin(field.getNumberValue()); } }, this)); this.cmbSparkMaxType = new Common.UI.ComboBox({ el : $('#spark-dlg-combo-maxtype'), cls : 'input-group-nr', menuStyle : 'min-width: 100px;', editable : false, data : [ {displayValue: this.textAutoEach, value: Asc.c_oAscSparklineAxisMinMax.Individual}, {displayValue: this.textSameAll, value: Asc.c_oAscSparklineAxisMinMax.Group}, {displayValue: this.textFixed, value: Asc.c_oAscSparklineAxisMinMax.Custom} ], takeFocusOnClose: true }).on('selected', _.bind(function(combo, record) { this.spnSparkMaxValue.setDisabled(record.value!==Asc.c_oAscSparklineAxisMinMax.Custom); if (this._changedProps) { this._changedProps.asc_setMaxAxisType(record.value); } if (record.value==Asc.c_oAscSparklineAxisMinMax.Custom && _.isEmpty(this.spnSparkMaxValue.getValue())) this.spnSparkMaxValue.setValue(0); }, this)); this.spnSparkMaxValue = new Common.UI.MetricSpinner({ el : $('#spark-dlg-input-max-value'), maxValue : 1000000, minValue : -1000000, step : 0.1, defaultUnit : "", defaultValue : 0, value : '' }).on('change', _.bind(function(field, newValue, oldValue) { if (this._changedProps) { this._changedProps.asc_setManualMax(field.getNumberValue()); } }, this)); // Snapping this.radioTwoCell = new Common.UI.RadioBox({ el: $('#chart-dlg-radio-twocell'), name: 'asc-radio-snap', labelText: this.textTwoCell, value: AscCommon.c_oAscCellAnchorType.cellanchorTwoCell }); this.radioTwoCell.on('change', _.bind(this.onRadioSnapChange, this)); this.radioOneCell = new Common.UI.RadioBox({ el: $('#chart-dlg-radio-onecell'), name: 'asc-radio-snap', labelText: this.textOneCell, value: AscCommon.c_oAscCellAnchorType.cellanchorOneCell }); this.radioOneCell.on('change', _.bind(this.onRadioSnapChange, this)); this.radioAbsolute = new Common.UI.RadioBox({ el: $('#chart-dlg-radio-absolute'), name: 'asc-radio-snap', labelText: this.textAbsolute, value: AscCommon.c_oAscCellAnchorType.cellanchorAbsolute }); this.radioAbsolute.on('change', _.bind(this.onRadioSnapChange, this)); // Alt Text this.inputAltTitle = new Common.UI.InputField({ el : $('#chart-advanced-alt-title'), allowBlank : true, validateOnBlur: false, style : 'width: 100%;' }).on('changed:after', function() { me.isAltTitleChanged = true; }); this.textareaAltDescription = this.$window.find('textarea'); this.textareaAltDescription.keydown(function (event) { if (event.keyCode == Common.UI.Keys.RETURN) { event.stopPropagation(); } me.isAltDescChanged = true; }); this.afterRender(); }, onCategoryClick: function(btn, index) { Common.Views.AdvancedSettingsWindow.prototype.onCategoryClick.call(this, btn, index); var me = this; setTimeout(function(){ switch (index) { case 1: me.cmbChartTitle.focus(); break; case 2: case 3: index -= 2; var ctrlIndex = me.vertAxisPropsIndexes[index]; me.onVCategoryClick(index); (me.vertAxisProps[index].getAxisType()===Asc.c_oAscAxisType.val) ? me.cmbMinType[ctrlIndex].focus() : (me.cmbHCrossType[ctrlIndex].isDisabled() ? me.btnHFormat[ctrlIndex].focus() : me.cmbHCrossType[ctrlIndex].focus() ); break; case 4: case 5: index -= 4; var ctrlIndex = me.horAxisPropsIndexes[index]; me.onHCategoryClick(index); (me.horAxisProps[index].getAxisType()===Asc.c_oAscAxisType.val) ? me.cmbMinType[ctrlIndex].focus() : (me.cmbHCrossType[ctrlIndex].isDisabled() ? me.btnHFormat[ctrlIndex].focus() : me.cmbHCrossType[ctrlIndex].focus()); break; case 6: me.btnSparkType.focus(); break; case 7: me.chShowAxis.focus(); break; case 8: me.radioTwoCell.focus(); break; case 9: me.inputAltTitle.focus(); break; } }, 10); }, afterRender: function() { this._setDefaults(this.chartSettings); this.setTitle((this.isChart) ? this.textTitle : this.textTitleSparkline); this.btnsCategory[0].setVisible(this.isDiagramMode); // hide type for charts if (this.isChart) { this.btnsCategory[6].setVisible(false); this.btnsCategory[7].setVisible(false); } else { this.btnsCategory[1].setVisible(false); this.btnsCategory[2].setVisible(false); this.btnsCategory[3].setVisible(false); this.btnsCategory[4].setVisible(false); this.btnsCategory[5].setVisible(false); this.btnsCategory[8].setVisible(false); this.btnsCategory[9].setVisible(false); } if (this.storageName) { var value = Common.localStorage.getItem(this.storageName); this.setActiveCategory((value!==null) ? parseInt(value) : 0); value = this.getActiveCategory(); if (value==2 || value==3) this.onVCategoryClick(value-2); else if (value==4 || value==5) this.onHCategoryClick(value-4); } }, addControlsV: function(parentEl) { var me = this, i = me.chVertHide.length, el = $(_.template(vertTemplate)({ scope: me, idx: i })); parentEl.append(el); me.chVertHide[i] = new Common.UI.CheckBox({ el: $('#chart-dlg-chk-vert-hide-' + i), labelText: me.textHideAxis }).on('change', _.bind(function (checkbox, state) { if (me.currentAxisProps[i]) me.currentAxisProps[i].putShow(state !== 'checked'); }, me)); Common.UI.FocusManager.add(this, me.chVertHide[i]); me.cmbVertTitle[i] = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-vert-title-' + i), menuStyle: 'min-width: 100%;', editable: false, cls: 'input-group-nr', data: me._arrVertTitle, takeFocusOnClose: true }).on('selected', _.bind(function (combo, record) { if (me.currentAxisProps[i]) me.currentAxisProps[i].putLabel(record.value); }, me)); Common.UI.FocusManager.add(this, me.cmbVertTitle[i]); me.cmbVertGrid[i] = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-vert-grid-' + i), menuStyle: 'min-width: 100%;', editable: false, cls: 'input-group-nr', data: [ {value: Asc.c_oAscGridLinesSettings.none, displayValue: me.textNone}, {value: Asc.c_oAscGridLinesSettings.major, displayValue: me.textMajor}, {value: Asc.c_oAscGridLinesSettings.minor, displayValue: me.textMinor}, {value: Asc.c_oAscGridLinesSettings.majorMinor, displayValue: me.textMajorMinor} ], takeFocusOnClose: true }).on('selected', _.bind(function (combo, record) { if (me.currentAxisProps[i]) me.currentAxisProps[i].putGridlines(record.value); }, me)); Common.UI.FocusManager.add(this, me.cmbVertGrid[i]); me.cmbMinType[i] = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-mintype-' + i), cls: 'input-group-nr', menuStyle: 'min-width: 100%;', editable: false, data: [ {displayValue: me.textAuto, value: Asc.c_oAscValAxisRule.auto}, {displayValue: me.textFixed, value: Asc.c_oAscValAxisRule.fixed} ], takeFocusOnClose: true }).on('selected', _.bind(function (combo, record) { if (me.currentAxisProps[i]) { me.currentAxisProps[i].putMinValRule(record.value); if (record.value == Asc.c_oAscValAxisRule.auto) { me.spnMinValue[i].setValue(me._originalAxisVValues[i].minAuto, true); } } }, me)); Common.UI.FocusManager.add(this, me.cmbMinType[i]); me.spnMinValue[i] = new Common.UI.MetricSpinner({ el: $('#chart-dlg-input-min-value-' + i), maxValue: 1000000, minValue: -1000000, step: 0.1, defaultUnit: "", defaultValue: 0, value: '' }).on('change', _.bind(function (field, newValue, oldValue) { me.cmbMinType[i].suspendEvents(); me.cmbMinType[i].setValue(Asc.c_oAscValAxisRule.fixed); me.cmbMinType[i].resumeEvents(); if (me.currentAxisProps[i]) { me.currentAxisProps[i].putMinValRule(Asc.c_oAscValAxisRule.fixed); me.currentAxisProps[i].putMinVal(field.getNumberValue()); } }, me)); Common.UI.FocusManager.add(this, me.spnMinValue[i]); me.cmbMaxType[i] = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-maxtype-' + i), cls: 'input-group-nr', menuStyle: 'min-width: 100%;', editable: false, data: [ {displayValue: me.textAuto, value: Asc.c_oAscValAxisRule.auto}, {displayValue: me.textFixed, value: Asc.c_oAscValAxisRule.fixed} ], takeFocusOnClose: true }).on('selected', _.bind(function (combo, record) { if (me.currentAxisProps[i]) { me.currentAxisProps[i].putMaxValRule(record.value); if (record.value == Asc.c_oAscValAxisRule.auto) { me.spnMaxValue[i].setValue(me._originalAxisVValues[i].maxAuto, true); } } }, me)); Common.UI.FocusManager.add(this, me.cmbMaxType[i]); me.spnMaxValue[i] = new Common.UI.MetricSpinner({ el: $('#chart-dlg-input-max-value-' + i), maxValue: 1000000, minValue: -1000000, step: 0.1, defaultUnit: "", defaultValue: 0, value: '' }).on('change', _.bind(function (field, newValue, oldValue) { me.cmbMaxType[i].suspendEvents(); me.cmbMaxType[i].setValue(Asc.c_oAscValAxisRule.fixed); me.cmbMaxType[i].resumeEvents(); if (me.currentAxisProps[i]) { me.currentAxisProps[i].putMaxValRule(Asc.c_oAscValAxisRule.fixed); me.currentAxisProps[i].putMaxVal(field.getNumberValue()); } }, me)); Common.UI.FocusManager.add(this, me.spnMaxValue[i]); me.cmbVCrossType[i] = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-v-crosstype-' + i), cls: 'input-group-nr', menuStyle: 'min-width: 100%;', editable: false, data: [ {displayValue: me.textAuto, value: Asc.c_oAscCrossesRule.auto}, {displayValue: me.textValue, value: Asc.c_oAscCrossesRule.value}, {displayValue: me.textMinValue, value: Asc.c_oAscCrossesRule.minValue}, {displayValue: me.textMaxValue, value: Asc.c_oAscCrossesRule.maxValue} ], takeFocusOnClose: true }).on('selected', _.bind(function (combo, record) { if (me.currentAxisProps[i]) { me.currentAxisProps[i].putCrossesRule(record.value); var value; switch (record.value) { case Asc.c_oAscCrossesRule.minValue: me.spnVAxisCrosses[i].setValue(me.spnMinValue[i].getNumberValue(), true); break; case Asc.c_oAscCrossesRule.maxValue: me.spnVAxisCrosses[i].setValue(me.spnMaxValue[i].getNumberValue(), true); break; case Asc.c_oAscCrossesRule.auto: me.spnVAxisCrosses[i].setValue(me._originalAxisVValues[i].crossesAuto, true); break; } } }, me)); Common.UI.FocusManager.add(this, me.cmbVCrossType[i]); me.spnVAxisCrosses[i] = new Common.UI.MetricSpinner({ el: $('#chart-dlg-input-v-axis-crosses-' + i), maxValue: 1000000, minValue: -1000000, step: 0.1, defaultUnit: "", defaultValue: 0, value: '' }).on('change', _.bind(function (field, newValue, oldValue) { me.cmbVCrossType[i].suspendEvents(); me.cmbVCrossType[i].setValue(Asc.c_oAscCrossesRule.value); me.cmbVCrossType[i].resumeEvents(); if (me.currentAxisProps[i]) { me.currentAxisProps[i].putCrossesRule(Asc.c_oAscCrossesRule.value); me.currentAxisProps[i].putCrosses(field.getNumberValue()); } }, me)); Common.UI.FocusManager.add(this, me.spnVAxisCrosses[i]); me.cmbUnits[i] = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-units-' + i), cls: 'input-group-nr', menuStyle: 'min-width: 100%;', editable: false, data: [ {displayValue: me.textNone, value: Asc.c_oAscValAxUnits.none}, {displayValue: me.textHundreds, value: Asc.c_oAscValAxUnits.HUNDREDS}, {displayValue: me.textThousands, value: Asc.c_oAscValAxUnits.THOUSANDS}, {displayValue: me.textTenThousands, value: Asc.c_oAscValAxUnits.TEN_THOUSANDS}, {displayValue: me.textHundredThousands, value: Asc.c_oAscValAxUnits.HUNDRED_THOUSANDS}, {displayValue: me.textMillions, value: Asc.c_oAscValAxUnits.MILLIONS}, {displayValue: me.textTenMillions, value: Asc.c_oAscValAxUnits.TEN_MILLIONS}, {displayValue: me.textHundredMil, value: Asc.c_oAscValAxUnits.HUNDRED_MILLIONS}, {displayValue: me.textBillions, value: Asc.c_oAscValAxUnits.BILLIONS}, {displayValue: me.textTrillions, value: Asc.c_oAscValAxUnits.TRILLIONS} ], takeFocusOnClose: true }).on('selected', _.bind(function (combo, record) { if (me.currentAxisProps[i]) { me.currentAxisProps[i].putDispUnitsRule(record.value); } }, me)); Common.UI.FocusManager.add(this, me.cmbUnits[i]); me.chVReverse[i] = new Common.UI.CheckBox({ el: $('#chart-dlg-check-v-reverse-' + i), labelText: me.textReverse }).on('change', _.bind(function (checkbox, state) { if (me.currentAxisProps[i]) { me.currentAxisProps[i].putInvertValOrder(state == 'checked'); } }, me)); Common.UI.FocusManager.add(this, me.chVReverse[i]); me.cmbVMajorType[i] = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-v-major-type-' + i), cls: 'input-group-nr', menuStyle: 'min-width: 100%;', editable: false, data: [ {displayValue: me.textNone, value: Asc.c_oAscTickMark.TICK_MARK_NONE}, {displayValue: me.textCross, value: Asc.c_oAscTickMark.TICK_MARK_CROSS}, {displayValue: me.textIn, value: Asc.c_oAscTickMark.TICK_MARK_IN}, {displayValue: me.textOut, value: Asc.c_oAscTickMark.TICK_MARK_OUT} ], takeFocusOnClose: true }).on('selected', _.bind(function (combo, record) { if (me.currentAxisProps[i]) { me.currentAxisProps[i].putMajorTickMark(record.value); } }, me)); Common.UI.FocusManager.add(this, me.cmbVMajorType[i]); me.cmbVMinorType[i] = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-v-minor-type-' + i), cls: 'input-group-nr', menuStyle: 'min-width: 100%;', editable: false, data: [ {displayValue: me.textNone, value: Asc.c_oAscTickMark.TICK_MARK_NONE}, {displayValue: me.textCross, value: Asc.c_oAscTickMark.TICK_MARK_CROSS}, {displayValue: me.textIn, value: Asc.c_oAscTickMark.TICK_MARK_IN}, {displayValue: me.textOut, value: Asc.c_oAscTickMark.TICK_MARK_OUT} ], takeFocusOnClose: true }).on('selected', _.bind(function (combo, record) { if (me.currentAxisProps[i]) { me.currentAxisProps[i].putMinorTickMark(record.value); } }, me)); Common.UI.FocusManager.add(this, me.cmbVMinorType[i]); me.cmbVLabelPos[i] = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-v-label-pos-' + i), cls: 'input-group-nr', menuStyle: 'min-width: 100%;', editable: false, data: [ {displayValue: me.textNone, value: Asc.c_oAscTickLabelsPos.TICK_LABEL_POSITION_NONE}, {displayValue: me.textLow, value: Asc.c_oAscTickLabelsPos.TICK_LABEL_POSITION_LOW}, {displayValue: me.textHigh, value: Asc.c_oAscTickLabelsPos.TICK_LABEL_POSITION_HIGH}, {displayValue: me.textNextToAxis, value: Asc.c_oAscTickLabelsPos.TICK_LABEL_POSITION_NEXT_TO} ], takeFocusOnClose: true }).on('selected', _.bind(function (combo, record) { if (me.currentAxisProps[i]) { me.currentAxisProps[i].putTickLabelsPos(record.value); } }, me)); Common.UI.FocusManager.add(this, me.cmbVLabelPos[i]); me.btnVFormat[i] = new Common.UI.Button({ el: $('#chart-dlg-btn-v-format-' + i) }).on('click', _.bind(me.openFormat, me, i)); Common.UI.FocusManager.add(this, me.btnVFormat[i]); me.chVLogScale[i] = new Common.UI.CheckBox({ el: $('#chart-dlg-check-v-logscale-' + i), labelText: me.textLogScale }).on('change', _.bind(function (checkbox, state) { if (me.currentAxisProps[i]) { me.currentAxisProps[i].putLogScale(state == 'checked'); (state == 'checked') && me.currentAxisProps[i].putLogBase(me.spnBase[i].getNumberValue()); } me.spnBase[i].setDisabled((state !== 'checked')); }, me)); Common.UI.FocusManager.add(this, me.chVLogScale[i]); me.spnBase[i] = new Common.UI.MetricSpinner({ el: $('#chart-dlg-input-base-' + i), maxValue: 1000, minValue: 2, step: 1, defaultUnit: "", value: 10 }).on('change', _.bind(function (field, newValue, oldValue) { if (me.currentAxisProps[i]) { me.currentAxisProps[i].putLogBase(field.getNumberValue()); } }, me)); Common.UI.FocusManager.add(this, me.spnBase[i]); return i; }, addControlsH: function(parentEl) { var me = this, i = me.chHorHide.length, el = $(_.template(horTemplate)({ scope: me, idx: i })); parentEl.append(el); me.chHorHide[i] = new Common.UI.CheckBox({ el: $('#chart-dlg-chk-hor-hide-' + i), labelText: me.textHideAxis }).on('change', _.bind(function (checkbox, state) { if (me.currentAxisProps[i]) me.currentAxisProps[i].putShow(state !== 'checked'); }, me)); Common.UI.FocusManager.add(this, me.chHorHide[i]); me.cmbHorTitle[i] = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-hor-title-' + i), menuStyle: 'min-width: 100%;', editable: false, cls: 'input-group-nr', data: me._arrHorTitle, takeFocusOnClose: true }).on('selected', _.bind(function (combo, record) { if (me.currentAxisProps[i]) me.currentAxisProps[i].putLabel(record.value); }, me)); Common.UI.FocusManager.add(this, me.cmbHorTitle[i]); me.cmbHorGrid[i] = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-hor-grid-' + i), menuStyle: 'min-width: 100%;', editable: false, cls: 'input-group-nr', data: [ {value: Asc.c_oAscGridLinesSettings.none, displayValue: me.textNone}, {value: Asc.c_oAscGridLinesSettings.major, displayValue: me.textMajor}, {value: Asc.c_oAscGridLinesSettings.minor, displayValue: me.textMinor}, {value: Asc.c_oAscGridLinesSettings.majorMinor, displayValue: me.textMajorMinor} ], takeFocusOnClose: true }).on('selected', _.bind(function (combo, record) { if (me.currentAxisProps[i]) me.currentAxisProps[i].putGridlines(record.value); }, me)); Common.UI.FocusManager.add(this, me.cmbHorGrid[i]); me.cmbHCrossType[i] = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-h-crosstype-' + i), cls: 'input-group-nr', menuStyle: 'min-width: 100%;', editable: false, data: [ {displayValue: me.textAuto, value: Asc.c_oAscCrossesRule.auto}, {displayValue: me.textValue, value: Asc.c_oAscCrossesRule.value}, {displayValue: me.textMinValue, value: Asc.c_oAscCrossesRule.minValue}, {displayValue: me.textMaxValue, value: Asc.c_oAscCrossesRule.maxValue} ], takeFocusOnClose: true }).on('selected', _.bind(function (combo, record) { if (me.currentAxisProps[i]) { me.currentAxisProps[i].putCrossesRule(record.value); if (record.value == Asc.c_oAscCrossesRule.auto) { me.spnHAxisCrosses[i].setValue(me._originalAxisHValues[i].crossesAuto, true); } else if (record.value == Asc.c_oAscCrossesRule.minValue) { me.spnHAxisCrosses[i].setValue(me._originalAxisHValues[i].minAuto, true); } else if (record.value == Asc.c_oAscCrossesRule.maxValue) { me.spnHAxisCrosses[i].setValue(me._originalAxisHValues[i].maxAuto, true); } } }, me)); Common.UI.FocusManager.add(this, me.cmbHCrossType[i]); me.spnHAxisCrosses[i] = new Common.UI.MetricSpinner({ el: $('#chart-dlg-input-h-axis-crosses-' + i), maxValue: 1000000, minValue: -1000000, step: 0.1, defaultUnit: "", defaultValue: 0, value: '' }).on('change', _.bind(function (field, newValue, oldValue) { me.cmbHCrossType[i].suspendEvents(); me.cmbHCrossType[i].setValue(Asc.c_oAscCrossesRule.value); me.cmbHCrossType[i].resumeEvents(); if (me.currentAxisProps[i]) { me.currentAxisProps[i].putCrossesRule(Asc.c_oAscCrossesRule.value); me.currentAxisProps[i].putCrosses(field.getNumberValue()); } }, me)); Common.UI.FocusManager.add(this, me.spnHAxisCrosses[i]); me.cmbAxisPos[i] = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-axis-pos-' + i), cls: 'input-group-nr', menuStyle: 'min-width: 100%;', editable: false, data: [ {displayValue: me.textOnTickMarks, value: Asc.c_oAscLabelsPosition.byDivisions}, {displayValue: me.textBetweenTickMarks, value: Asc.c_oAscLabelsPosition.betweenDivisions} ], takeFocusOnClose: true }).on('selected', _.bind(function (combo, record) { if (me.currentAxisProps[i]) { me.currentAxisProps[i].putLabelsPosition(record.value); } }, me)); Common.UI.FocusManager.add(this, me.cmbAxisPos[i]); me.chHReverse[i] = new Common.UI.CheckBox({ el: $('#chart-dlg-check-h-reverse-' + i), labelText: me.textReverse }).on('change', _.bind(function (checkbox, state) { if (me.currentAxisProps[i]) { me.currentAxisProps[i].putInvertCatOrder(state == 'checked'); } }, me)); Common.UI.FocusManager.add(this, me.chHReverse[i]); me.cmbHMajorType[i] = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-h-major-type-' + i), cls: 'input-group-nr', menuStyle: 'min-width: 100%;', editable: false, data: [ {displayValue: me.textNone, value: Asc.c_oAscTickMark.TICK_MARK_NONE}, {displayValue: me.textCross, value: Asc.c_oAscTickMark.TICK_MARK_CROSS}, {displayValue: me.textIn, value: Asc.c_oAscTickMark.TICK_MARK_IN}, {displayValue: me.textOut, value: Asc.c_oAscTickMark.TICK_MARK_OUT} ], takeFocusOnClose: true }).on('selected', _.bind(function (combo, record) { if (me.currentAxisProps[i]) { me.currentAxisProps[i].putMajorTickMark(record.value); } }, me)); Common.UI.FocusManager.add(this, me.cmbHMajorType[i]); me.cmbHMinorType[i] = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-h-minor-type-' + i), cls: 'input-group-nr', menuStyle: 'min-width: 100%;', editable: false, data: [ {displayValue: me.textNone, value: Asc.c_oAscTickMark.TICK_MARK_NONE}, {displayValue: me.textCross, value: Asc.c_oAscTickMark.TICK_MARK_CROSS}, {displayValue: me.textIn, value: Asc.c_oAscTickMark.TICK_MARK_IN}, {displayValue: me.textOut, value: Asc.c_oAscTickMark.TICK_MARK_OUT} ], takeFocusOnClose: true }).on('selected', _.bind(function (combo, record) { if (me.currentAxisProps[i]) { me.currentAxisProps[i].putMinorTickMark(record.value); } }, me)); Common.UI.FocusManager.add(this, me.cmbHMinorType[i]); me.spnMarksInterval[i] = new Common.UI.MetricSpinner({ el: $('#chart-dlg-input-marks-interval-' + i), width: 'auto', maxValue: 1000000, minValue: 1, step: 1, defaultUnit: "", value: '' }).on('change', _.bind(function (field, newValue, oldValue) { if (me.currentAxisProps[i]) { me.currentAxisProps[i].putIntervalBetweenTick(field.getNumberValue()); } }, me)); Common.UI.FocusManager.add(this, me.spnMarksInterval[i]); me.cmbHLabelPos[i] = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-h-label-pos-' + i), cls: 'input-group-nr', menuStyle: 'min-width: 100%;', editable: false, data: [ {displayValue: me.textNone, value: Asc.c_oAscTickLabelsPos.TICK_LABEL_POSITION_NONE}, {displayValue: me.textLow, value: Asc.c_oAscTickLabelsPos.TICK_LABEL_POSITION_LOW}, {displayValue: me.textHigh, value: Asc.c_oAscTickLabelsPos.TICK_LABEL_POSITION_HIGH}, {displayValue: me.textNextToAxis, value: Asc.c_oAscTickLabelsPos.TICK_LABEL_POSITION_NEXT_TO} ], takeFocusOnClose: true }).on('selected', _.bind(function (combo, record) { if (me.currentAxisProps[i]) { me.currentAxisProps[i].putTickLabelsPos(record.value); } }, me)); Common.UI.FocusManager.add(this, me.cmbHLabelPos[i]); me.spnLabelDist[i] = new Common.UI.MetricSpinner({ el: $('#chart-dlg-input-label-dist-' + i), width: 'auto', maxValue: 1000, minValue: 0, step: 1, defaultUnit: "", value: '' }).on('change', _.bind(function (field, newValue, oldValue) { if (me.currentAxisProps[i]) { me.currentAxisProps[i].putLabelsAxisDistance(field.getNumberValue()); } }, me)); Common.UI.FocusManager.add(this, me.spnLabelDist[i]); me.spnLabelInterval[i] = new Common.UI.MetricSpinner({ el: $('#chart-dlg-input-label-int-' + i), width: 60, maxValue: 1000000, minValue: 1, step: 1, defaultUnit: "", value: '' }).on('change', _.bind(function (field, newValue, oldValue) { me.cmbLabelInterval[i].suspendEvents(); me.cmbLabelInterval[i].setValue(Asc.c_oAscBetweenLabelsRule.manual); me.cmbLabelInterval[i].resumeEvents(); if (me.currentAxisProps[i]) { me.currentAxisProps[i].putIntervalBetweenLabelsRule(Asc.c_oAscBetweenLabelsRule.manual); me.currentAxisProps[i].putIntervalBetweenLabels(field.getNumberValue()); } }, me)); Common.UI.FocusManager.add(this, me.spnLabelInterval[i]); me.cmbLabelInterval[i] = new Common.UI.ComboBox({ el: $('#chart-dlg-combo-label-int-' + i), cls: 'input-group-nr', menuStyle: 'min-width: 100%;', editable: false, data: [ {displayValue: me.textAuto, value: Asc.c_oAscBetweenLabelsRule.auto}, {displayValue: me.textManual, value: Asc.c_oAscBetweenLabelsRule.manual} ], takeFocusOnClose: true }).on('selected', _.bind(function (combo, record) { if (me.currentAxisProps[i]) { me.currentAxisProps[i].putIntervalBetweenLabelsRule(record.value); if (record.value == Asc.c_oAscBetweenLabelsRule.auto) me.spnLabelInterval[i].setValue(1, true); } }, me)); Common.UI.FocusManager.add(this, me.cmbLabelInterval[i]); me.btnHFormat[i] = new Common.UI.Button({ el: $('#chart-dlg-btn-h-format-' + i) }).on('click', _.bind(me.openFormat, me, i)); Common.UI.FocusManager.add(this, me.btnHFormat[i]); return i; }, onSelectType: function(btn, picker, itemView, record) { if (this._noApply) return; var rawData = {}, isPickerSelect = _.isFunction(record.toJSON); if (isPickerSelect){ if (record.get('selected')) { rawData = record.toJSON(); } else { // record deselected return; } } else { rawData = record; } this.btnChartType.setIconCls('svgicon ' + 'chart-' + rawData.iconCls); this.chartSettings.changeType(rawData.type); this.updateAxisProps(rawData.type, true); this.vertAxisProps = this.chartSettings.getVertAxesProps(); this.horAxisProps = this.chartSettings.getHorAxesProps(); this.updateDataLabels(rawData.type, this.cmbDataLabels.getValue()); this.currentChartType = rawData.type; }, updateAxisProps: function(type, isDefault) { var value = (type == Asc.c_oAscChartTypeSettings.lineNormal || type == Asc.c_oAscChartTypeSettings.lineStacked || type == Asc.c_oAscChartTypeSettings.lineStackedPer || type == Asc.c_oAscChartTypeSettings.lineNormalMarker || type == Asc.c_oAscChartTypeSettings.lineStackedMarker || type == Asc.c_oAscChartTypeSettings.lineStackedPerMarker || type == Asc.c_oAscChartTypeSettings.scatter || type == Asc.c_oAscChartTypeSettings.scatterSmoothMarker || type == Asc.c_oAscChartTypeSettings.scatterSmooth || type == Asc.c_oAscChartTypeSettings.scatterLineMarker || type == Asc.c_oAscChartTypeSettings.scatterLine); this.chMarkers.setVisible(value); this.cmbLines.setVisible(value); this.lblLines.toggleClass('hidden', !value); this.lblLines.closest('tr').toggleClass('hidden', !value); if (value) { this.chMarkers.setValue(this.chartSettings.getShowMarker(), true); this.cmbLines.setValue(this.chartSettings.getLine() ? (this.chartSettings.getSmooth() ? 2 : 1) : 0); } value = (type == Asc.c_oAscChartTypeSettings.pie || type == Asc.c_oAscChartTypeSettings.doughnut || type == Asc.c_oAscChartTypeSettings.pie3d); this.btnsCategory[2].setDisabled(value); this.btnsCategory[3].setDisabled(value); this.btnsCategory[4].setDisabled(value); this.btnsCategory[5].setDisabled(value); this.btnsCategory[2].setVisible(this.vertAxisProps.length>0); this.btnsCategory[3].setVisible(this.vertAxisProps.length>1); this.btnsCategory[4].setVisible(this.horAxisProps.length>0); this.btnsCategory[5].setVisible(this.horAxisProps.length>1); value = (type == Asc.c_oAscChartTypeSettings.barNormal3d || type == Asc.c_oAscChartTypeSettings.barStacked3d || type == Asc.c_oAscChartTypeSettings.barStackedPer3d || type == Asc.c_oAscChartTypeSettings.hBarNormal3d || type == Asc.c_oAscChartTypeSettings.hBarStacked3d || type == Asc.c_oAscChartTypeSettings.hBarStackedPer3d || type == Asc.c_oAscChartTypeSettings.barNormal3dPerspective); for (var i=0; i