2016-12-12 15:13:46 +00:00
/ *
*
2017-01-23 09:59:54 +00:00
* ( c ) Copyright Ascensio System Limited 2010 - 2017
2016-12-12 15:13:46 +00:00
*
* 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 Lubanas st . 125 a - 25 , Riga , Latvia ,
* EU , LV - 1021.
*
* 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
*
* /
/ * *
* EditChart . js
* Spreadsheet Editor
*
* Created by Alexander Yuzhin on 12 / 12 / 16
* Copyright ( c ) 2016 Ascensio System SIA . All rights reserved .
*
* /
define ( [
'core' ,
'spreadsheeteditor/mobile/app/view/edit/EditChart' ,
'jquery' ,
'underscore' ,
'backbone' ,
'common/mobile/lib/component/ThemeColorPalette'
] , function ( core , view , $ , _ , Backbone ) {
'use strict' ;
SSE . Controllers . EditChart = Backbone . Controller . extend ( _ . extend ( ( function ( ) {
var _stack = [ ] ,
2016-12-13 13:37:13 +00:00
_chartObject = undefined ,
_shapeObject = undefined ,
2016-12-12 15:13:46 +00:00
_borderInfo = { color : '000000' , width : 1 } ,
2016-12-13 13:37:13 +00:00
_metricText = Common . Utils . Metric . getCurrentMetricName ( ) ,
2016-12-12 15:13:46 +00:00
_isEdit = false ;
2016-12-13 13:37:13 +00:00
var borderSizeTransform = ( function ( ) {
var _sizes = [ 0 , 0.5 , 1 , 1.5 , 2.25 , 3 , 4.5 , 6 ] ;
return {
sizeByIndex : function ( index ) {
if ( index < 1 ) return _sizes [ 0 ] ;
if ( index > _sizes . length - 1 ) return _sizes [ _sizes . length - 1 ] ;
return _sizes [ index ] ;
} ,
2017-04-11 11:05:56 +00:00
indexSizeByValue : function ( value ) {
2016-12-13 13:37:13 +00:00
var index = 0 ;
_ . each ( _sizes , function ( size , idx ) {
if ( Math . abs ( size - value ) < 0.25 ) {
index = idx ;
}
} ) ;
2017-04-11 11:05:56 +00:00
return index
} ,
sizeByValue : function ( value ) {
return _sizes [ this . indexSizeByValue ( value ) ] ;
2016-12-13 13:37:13 +00:00
}
}
} ) ( ) ;
2016-12-12 15:13:46 +00:00
return {
models : [ ] ,
collections : [ ] ,
views : [
'EditChart'
] ,
initialize : function ( ) {
Common . NotificationCenter . on ( 'editcontainer:show' , _ . bind ( this . initEvents , this ) ) ;
this . addListeners ( {
'EditChart' : {
'page:show' : this . onPageShow
}
} ) ;
} ,
setApi : function ( api ) {
var me = this ;
me . api = api ;
2016-12-13 11:20:50 +00:00
me . api . asc _registerCallback ( 'asc_onSelectionChanged' , _ . bind ( me . onApiSelectionChanged , me ) ) ;
2016-12-13 13:37:13 +00:00
me . api . asc _registerCallback ( 'asc_onFocusObject' , _ . bind ( me . onApiFocusObject , me ) ) ;
2016-12-13 11:20:50 +00:00
me . api . asc _registerCallback ( 'asc_onUpdateChartStyles' , _ . bind ( me . onApiUpdateChartStyles , me ) ) ;
2016-12-12 15:13:46 +00:00
// me.api.asc_registerCallback('asc_onSelectionChanged', _.bind(me.onApiSelectionChanged, me));
// me.api.asc_registerCallback('asc_onEditorSelectionChanged', _.bind(me.onApiEditorSelectionChanged, me));
// me.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(me.onApiInitEditorStyles, me)); // TODO: It does not work until the error in the SDK
} ,
setMode : function ( mode ) {
_isEdit = ( 'edit' === mode ) ;
} ,
onLaunch : function ( ) {
this . createView ( 'EditChart' ) . render ( ) ;
} ,
initEvents : function ( ) {
var me = this ;
me . initSettings ( ) ;
} ,
onPageShow : function ( view , pageId ) {
var me = this ;
me . initSettings ( pageId ) ;
} ,
initSettings : function ( pageId ) {
2016-12-16 11:17:40 +00:00
if ( $ ( '#edit-chart' ) . length < 1 ) {
return ;
}
2016-12-12 15:13:46 +00:00
var me = this ;
2016-12-13 11:20:50 +00:00
if ( '#edit-chart-style' == pageId ) {
me . initStylePage ( ) ;
2016-12-13 13:37:13 +00:00
} else if ( '#edit-chart-border-color-view' == pageId ) {
me . initBorderColorPage ( ) ;
2016-12-13 15:13:49 +00:00
} else if ( '#edit-chart-layout' == pageId ) {
me . initLayoutPage ( ) ;
2016-12-16 11:17:40 +00:00
} else if ( '#edit-chart-vertical-axis' == pageId ) {
me . initVertAxisPage ( ) ;
} else if ( '#edit-chart-horizontal-axis' == pageId ) {
me . initHorAxisPage ( ) ;
2016-12-12 15:13:46 +00:00
} else if ( '#edit-chart-reorder' == pageId ) {
me . initReorderPage ( ) ;
} else {
2016-12-16 11:17:40 +00:00
me . initRootPage ( ) ;
2016-12-12 15:13:46 +00:00
}
} ,
// Public
getStack : function ( ) {
return _stack ;
} ,
getChart : function ( ) {
2016-12-13 11:20:50 +00:00
return _chartObject ;
2016-12-12 15:13:46 +00:00
} ,
2016-12-16 11:17:40 +00:00
initRootPage : function ( ) {
$ ( '#chart-remove' ) . single ( 'click' , _ . bind ( this . onRemoveChart , this ) ) ;
2016-12-21 14:18:22 +00:00
if ( ! _ . isUndefined ( _chartObject ) ) {
this . updateAxisProps ( _chartObject . get _ChartProperties ( ) . getType ( ) ) ;
}
2016-12-16 11:17:40 +00:00
} ,
2016-12-13 11:20:50 +00:00
initStylePage : function ( ) {
var me = this ,
2016-12-13 13:37:13 +00:00
color ,
chartProperties = _chartObject . get _ChartProperties ( ) ,
shapeProperties = _shapeObject . get _ShapeProperties ( ) ;
2016-12-13 11:20:50 +00:00
// Type
var type = chartProperties . getType ( ) ;
$ ( '.chart-types li' ) . removeClass ( 'active' ) ;
$ ( '.chart-types li[data-type=' + type + ']' ) . addClass ( 'active' ) ;
$ ( '#tab-chart-type li' ) . single ( 'click' , _ . buffered ( me . onType , 100 , me ) ) ;
// Styles
_ . defer ( function ( ) {
me . _updateChartStyles ( me . api . asc _getChartPreviews ( _chartObject . get _ChartProperties ( ) . getType ( ) ) ) ;
} ) ;
2016-12-13 13:37:13 +00:00
// Fill
var paletteFillColor = new Common . UI . ThemeColorPalette ( {
el : $ ( '#tab-chart-fill' ) ,
transparent : true
} ) ;
paletteFillColor . on ( 'select' , _ . bind ( me . onFillColor , me ) ) ;
var fill = shapeProperties . asc _getFill ( ) ,
fillType = fill . asc _getType ( ) ;
if ( fillType == Asc . c _oAscFill . FILL _TYPE _SOLID ) {
color = me . _sdkToThemeColor ( fill . asc _getFill ( ) . asc _getColor ( ) ) ;
}
paletteFillColor . select ( color ) ;
// Init border
2017-04-11 11:05:56 +00:00
var borderSize = shapeProperties . get _stroke ( ) . get _width ( ) * 72.0 / 25.4 ,
borderType = shapeProperties . get _stroke ( ) . get _type ( ) ;
$ ( '#edit-chart-bordersize input' ) . val ( [ ( borderType == Asc . c _oAscStrokeType . STROKE _NONE ) ? 0 : borderSizeTransform . indexSizeByValue ( borderSize ) ] ) ;
$ ( '#edit-chart-bordersize .item-after' ) . text ( ( ( borderType == Asc . c _oAscStrokeType . STROKE _NONE ) ? 0 : borderSizeTransform . sizeByValue ( borderSize ) ) + ' ' + _metricText ) ;
2016-12-13 13:37:13 +00:00
$ ( '#edit-chart-bordersize input' ) . single ( 'change touchend' , _ . buffered ( me . onBorderSize , 100 , me ) ) ;
$ ( '#edit-chart-bordersize input' ) . single ( 'input' , _ . bind ( me . onBorderSizeChanging , me ) ) ;
2017-04-11 11:05:56 +00:00
// Init border color
me . _initBorderColorView ( ) ;
} ,
2016-12-13 13:37:13 +00:00
2017-04-11 11:05:56 +00:00
_initBorderColorView : function ( ) {
var me = this ,
stroke = _shapeObject . get _ShapeProperties ( ) . get _stroke ( ) ;
_borderInfo . color = ( stroke && stroke . get _type ( ) == Asc . c _oAscStrokeType . STROKE _COLOR ) ? me . _sdkToThemeColor ( stroke . get _color ( ) ) : 'transparent' ;
2016-12-13 13:37:13 +00:00
2016-12-13 15:13:49 +00:00
$ ( '#edit-chart-bordercolor .color-preview' ) . css ( 'background-color' ,
( 'transparent' == _borderInfo . color )
? _borderInfo . color
: ( '#' + ( _ . isObject ( _borderInfo . color ) ? _borderInfo . color . color : _borderInfo . color ) )
2017-04-11 11:05:56 +00:00
) ;
2016-12-13 15:13:49 +00:00
} ,
initLayoutPage : function ( ) {
var me = this ,
chartProperties = _chartObject . get _ChartProperties ( ) ,
2016-12-14 14:14:00 +00:00
chartType = chartProperties . getType ( ) ,
2016-12-13 15:13:49 +00:00
$layoutPage = $ ( '.page[data-page=edit-chart-layout]' ) ;
var setValue = function ( id , value ) {
var textValue = $layoutPage . find ( 'select[name=' + id + ']' )
. val ( value )
. find ( 'option[value=' + value + ']' )
. text ( ) ;
$layoutPage . find ( '#' + id + ' .item-after' ) . text ( textValue ) ;
} ;
2016-12-14 14:14:00 +00:00
// Init legend position values
var dataLabelPos = [
{ value : Asc . c _oAscChartDataLabelsPos . none , displayValue : me . textNone } ,
{ value : Asc . c _oAscChartDataLabelsPos . ctr , displayValue : me . textCenter }
] ;
if ( chartType == Asc . c _oAscChartTypeSettings . barNormal ||
chartType == Asc . c _oAscChartTypeSettings . hBarNormal ) {
dataLabelPos . push (
{ value : Asc . c _oAscChartDataLabelsPos . inBase , displayValue : me . textInnerBottom } ,
{ value : Asc . c _oAscChartDataLabelsPos . inEnd , displayValue : me . textInnerTop } ,
{ value : Asc . c _oAscChartDataLabelsPos . outEnd , displayValue : me . textOuterTop }
) ;
} else if ( chartType == Asc . c _oAscChartTypeSettings . barStacked ||
chartType == Asc . c _oAscChartTypeSettings . barStackedPer ||
chartType == Asc . c _oAscChartTypeSettings . hBarStacked ||
chartType == Asc . c _oAscChartTypeSettings . hBarStackedPer ) {
dataLabelPos . push (
{ value : Asc . c _oAscChartDataLabelsPos . inBase , displayValue : me . textInnerBottom } ,
{ value : Asc . c _oAscChartDataLabelsPos . inEnd , displayValue : me . textInnerTop }
) ;
} else if ( chartType == Asc . c _oAscChartTypeSettings . lineNormal ||
chartType == Asc . c _oAscChartTypeSettings . lineStacked ||
chartType == Asc . c _oAscChartTypeSettings . lineStackedPer ||
chartType == Asc . c _oAscChartTypeSettings . stock ||
chartType == Asc . c _oAscChartTypeSettings . scatter ) {
dataLabelPos . push (
{ value : Asc . c _oAscChartDataLabelsPos . l , displayValue : me . textLeft } ,
{ value : Asc . c _oAscChartDataLabelsPos . r , displayValue : me . textRight } ,
{ value : Asc . c _oAscChartDataLabelsPos . t , displayValue : me . textTop } ,
{ value : Asc . c _oAscChartDataLabelsPos . b , displayValue : me . textBottom }
) ;
} else if ( chartType == Asc . c _oAscChartTypeSettings . pie ||
chartType == Asc . c _oAscChartTypeSettings . pie3d ) {
dataLabelPos . push (
{ value : Asc . c _oAscChartDataLabelsPos . bestFit , displayValue : me . textFit } ,
{ value : Asc . c _oAscChartDataLabelsPos . inEnd , displayValue : me . textInnerTop } ,
{ value : Asc . c _oAscChartDataLabelsPos . outEnd , displayValue : me . textOuterTop }
) ;
}
$layoutPage . find ( 'select[name=chart-layout-data-labels]' ) . html ( ( function ( ) {
var options = [ ] ;
_ . each ( dataLabelPos , function ( position ) {
options . push ( Common . Utils . String . format ( '<option value="{0}">{1}</option>' , position . value , position . displayValue ) ) ;
} ) ;
return options . join ( '' ) ;
} ) ( ) ) ;
2016-12-13 15:13:49 +00:00
setValue ( 'chart-layout-title' , chartProperties . getTitle ( ) ) ;
setValue ( 'chart-layout-legend' , chartProperties . getLegendPos ( ) ) ;
setValue ( 'chart-layout-axis-title-horizontal' , chartProperties . getHorAxisLabel ( ) ) ;
setValue ( 'chart-layout-axis-title-vertical' , chartProperties . getVertAxisLabel ( ) ) ;
setValue ( 'chart-layout-gridlines-horizontal' , chartProperties . getHorGridLines ( ) ) ;
2016-12-14 14:14:00 +00:00
setValue ( 'chart-layout-gridlines-vertical' , chartProperties . getVertGridLines ( ) ) ;
setValue ( 'chart-layout-data-labels' , chartProperties . getDataLabelsPos ( ) || Asc . c _oAscChartDataLabelsPos . none ) ;
var disableSetting = (
chartType == Asc . c _oAscChartTypeSettings . pie ||
chartType == Asc . c _oAscChartTypeSettings . doughnut ||
chartType == Asc . c _oAscChartTypeSettings . pie3d
) ;
$ ( '#chart-layout-axis-title-horizontal' ) . toggleClass ( 'disabled' , disableSetting ) ;
$ ( '#chart-layout-axis-title-vertical' ) . toggleClass ( 'disabled' , disableSetting ) ;
$ ( '#chart-layout-gridlines-horizontal' ) . toggleClass ( 'disabled' , disableSetting ) ;
$ ( '#chart-layout-gridlines-vertical' ) . toggleClass ( 'disabled' , disableSetting ) ;
2016-12-15 08:43:29 +00:00
// Handlers
$ ( '#chart-layout-title select' ) . single ( 'change' , _ . bind ( me . onLayoutTitle , me ) ) ;
$ ( '#chart-layout-legend select' ) . single ( 'change' , _ . bind ( me . onLayoutLegend , me ) ) ;
$ ( '#chart-layout-axis-title-horizontal select' ) . single ( 'change' , _ . bind ( me . onLayoutAxisTitleHorizontal , me ) ) ;
$ ( '#chart-layout-axis-title-vertical select' ) . single ( 'change' , _ . bind ( me . onLayoutAxisTitleVertical , me ) ) ;
$ ( '#chart-layout-gridlines-horizontal select' ) . single ( 'change' , _ . bind ( me . onLayoutGridlinesHorizontal , me ) ) ;
$ ( '#chart-layout-gridlines-vertical select' ) . single ( 'change' , _ . bind ( me . onLayoutGridlinesVertical , me ) ) ;
$ ( '#chart-layout-data-labels select' ) . single ( 'change' , _ . bind ( me . onLayoutDataLabel , me ) ) ;
2016-12-12 15:13:46 +00:00
} ,
2016-12-16 11:17:40 +00:00
initVertAxisPage : function ( ) {
var me = this ,
$vertAxisPage = $ ( '.page[data-page=edit-chart-vertical-axis]' ) ,
chartProperty = me . api . asc _getChartObject ( ) ,
verAxisProps = chartProperty . getVertAxisProps ( ) ,
axisProps = ( verAxisProps . getAxisType ( ) == Asc . c _oAscAxisType . val ) ? verAxisProps : chartProperty . getHorAxisProps ( ) ;
var setValue = function ( id , value ) {
var textValue = $vertAxisPage . find ( 'select[name=' + id + ']' )
. val ( value )
. find ( 'option[value=' + value + ']' )
. text ( ) ;
$vertAxisPage . find ( '#' + id + ' .item-after' ) . text ( textValue ) ;
} ;
var setOptions = function ( selectName , options ) {
$vertAxisPage . find ( 'select[name=' + selectName + ']' ) . html ( ( function ( ) {
var _options = [ ] ;
_ . each ( options , function ( option ) {
_options . push ( Common . Utils . String . format ( '<option value="{0}">{1}</option>' , option . value , option . display ) ) ;
} ) ;
return _options . join ( '' ) ;
} ) ( ) ) ;
} ;
// Axis
$ ( '#edit-vertical-axis-min-val input' ) . val ( ( axisProps . getMinValRule ( ) == Asc . c _oAscValAxisRule . auto ) ? null : axisProps . getMinVal ( ) ) ;
$ ( '#edit-vertical-axis-max-val input' ) . val ( ( axisProps . getMaxValRule ( ) == Asc . c _oAscValAxisRule . auto ) ? null : axisProps . getMaxVal ( ) ) ;
// Cross
setOptions ( 'vertical-axis-cross' , [
{ display : this . textAuto , value : Asc . c _oAscCrossesRule . auto } ,
{ display : this . textValue , value : Asc . c _oAscCrossesRule . value } ,
{ display : this . textMinValue , value : Asc . c _oAscCrossesRule . minValue } ,
{ display : this . textMaxValue , value : Asc . c _oAscCrossesRule . maxValue }
] ) ;
var crossValue = axisProps . getCrossesRule ( ) ;
setValue ( 'vertical-axis-cross' , crossValue ) ;
if ( crossValue == Asc . c _oAscCrossesRule . value ) {
$ ( '#edit-vertical-axis-cross-value' ) . css ( 'display' , 'block' ) ;
$ ( '#edit-vertical-axis-cross-value input' ) . val ( axisProps . getCrosses ( ) ) ;
}
// Units
setOptions ( 'vertical-axis-display-units' , [
{ display : me . textNone , value : Asc . c _oAscValAxUnits . none } ,
{ display : me . textHundreds , value : Asc . c _oAscValAxUnits . HUNDREDS } ,
{ display : me . textThousands , value : Asc . c _oAscValAxUnits . THOUSANDS } ,
{ display : me . textTenThousands , value : Asc . c _oAscValAxUnits . TEN _THOUSANDS } ,
{ display : me . textHundredThousands , value : Asc . c _oAscValAxUnits . HUNDRED _THOUSANDS } ,
{ display : me . textMillions , value : Asc . c _oAscValAxUnits . MILLIONS } ,
{ display : me . textTenMillions , value : Asc . c _oAscValAxUnits . TEN _MILLIONS } ,
{ display : me . textHundredMil , value : Asc . c _oAscValAxUnits . HUNDRED _MILLIONS } ,
{ display : me . textBillions , value : Asc . c _oAscValAxUnits . BILLIONS } ,
{ display : me . textTrillions , value : Asc . c _oAscValAxUnits . TRILLIONS }
] ) ;
setValue ( 'vertical-axis-display-units' , axisProps . getDispUnitsRule ( ) ) ;
$ ( '#vertical-axis-in-reverse input' ) . prop ( 'checked' , axisProps . getInvertValOrder ( ) ) ;
// Tick
var tickOptions = [
{ display : this . textNone , value : Asc . c _oAscTickMark . TICK _MARK _NONE } ,
{ display : this . textCross , value : Asc . c _oAscTickMark . TICK _MARK _CROSS } ,
{ display : this . textIn , value : Asc . c _oAscTickMark . TICK _MARK _IN } ,
{ display : this . textOut , value : Asc . c _oAscTickMark . TICK _MARK _OUT }
] ;
setOptions ( 'vertical-axis-tick-major' , tickOptions ) ;
setOptions ( 'vertical-axis-tick-minor' , tickOptions ) ;
setValue ( 'vertical-axis-tick-major' , axisProps . getMajorTickMark ( ) ) ;
setValue ( 'vertical-axis-tick-minor' , axisProps . getMinorTickMark ( ) ) ;
// Label
setOptions ( 'vertical-axis-label-pos' , [
{ display : this . textNone , value : Asc . c _oAscTickLabelsPos . TICK _LABEL _POSITION _NONE } ,
{ display : this . textLow , value : Asc . c _oAscTickLabelsPos . TICK _LABEL _POSITION _LOW } ,
{ display : this . textHigh , value : Asc . c _oAscTickLabelsPos . TICK _LABEL _POSITION _HIGH } ,
{ display : this . textNextToAxis , value : Asc . c _oAscTickLabelsPos . TICK _LABEL _POSITION _NEXT _TO }
] ) ;
setValue ( 'vertical-axis-label-pos' , axisProps . getTickLabelsPos ( ) ) ;
2016-12-16 12:26:53 +00:00
me . updateAxisProps ( chartProperty . getType ( ) ) ;
2016-12-16 11:17:40 +00:00
// Handlers
$ ( '#edit-vertical-axis-min-val input' ) . single ( 'change' , _ . bind ( me . onVerAxisMinValue , me ) ) ;
$ ( '#edit-vertical-axis-max-val input' ) . single ( 'change' , _ . bind ( me . onVerAxisMaxValue , me ) ) ;
$ ( '#vertical-axis-cross select' ) . single ( 'change' , _ . bind ( me . onVerAxisCrossType , me ) ) ;
$ ( '#edit-vertical-axis-cross-value input' ) . single ( 'change' , _ . bind ( me . onVerAxisCrossValue , me ) ) ;
$ ( '#vertical-axis-display-units select' ) . single ( 'change' , _ . bind ( me . onVerAxisDisplayUnits , me ) ) ;
$ ( '#vertical-axis-in-reverse input' ) . single ( 'change' , _ . bind ( me . onVerAxisReverse , me ) ) ;
$ ( '#vertical-axis-tick-major select' ) . single ( 'change' , _ . bind ( me . onVerAxisTickMajor , me ) ) ;
$ ( '#vertical-axis-tick-minor select' ) . single ( 'change' , _ . bind ( me . onVerAxisTickMinor , me ) ) ;
$ ( '#vertical-axis-label-pos select' ) . single ( 'change' , _ . bind ( me . onVerAxisLabelPos , me ) ) ;
} ,
initHorAxisPage : function ( ) {
2016-12-16 12:26:53 +00:00
var me = this ,
$horAxisPage = $ ( '.page[data-page=edit-chart-horizontal-axis]' ) ,
chartProperty = me . api . asc _getChartObject ( ) ,
horAxisProps = chartProperty . getHorAxisProps ( ) ,
axisProps = ( horAxisProps . getAxisType ( ) == Asc . c _oAscAxisType . val ) ? chartProperty . getVertAxisProps ( ) : horAxisProps ;
2016-12-16 11:17:40 +00:00
2016-12-16 12:26:53 +00:00
var setValue = function ( id , value ) {
var textValue = $horAxisPage . find ( 'select[name=' + id + ']' )
. val ( value )
. find ( 'option[value=' + value + ']' )
. text ( ) ;
$horAxisPage . find ( '#' + id + ' .item-after' ) . text ( textValue ) ;
} ;
var setOptions = function ( selectName , options ) {
$horAxisPage . find ( 'select[name=' + selectName + ']' ) . html ( ( function ( ) {
var _options = [ ] ;
_ . each ( options , function ( option ) {
_options . push ( Common . Utils . String . format ( '<option value="{0}">{1}</option>' , option . value , option . display ) ) ;
} ) ;
return _options . join ( '' ) ;
} ) ( ) ) ;
} ;
// Cross
setOptions ( 'horizontal-axis-cross' , [
2016-12-22 10:41:12 +00:00
{ display : me . textAuto , value : Asc . c _oAscCrossesRule . auto } ,
{ display : me . textValue , value : Asc . c _oAscCrossesRule . value } ,
{ display : me . textMinValue , value : Asc . c _oAscCrossesRule . minValue } ,
{ display : me . textMaxValue , value : Asc . c _oAscCrossesRule . maxValue }
2016-12-16 12:26:53 +00:00
] ) ;
var crossValue = axisProps . getCrossesRule ( ) ;
setValue ( 'horizontal-axis-cross' , crossValue ) ;
if ( crossValue == Asc . c _oAscCrossesRule . value ) {
$ ( '#edit-horizontal-axis-cross-value' ) . css ( 'display' , 'block' ) ;
$ ( '#edit-horizontal-axis-cross-value input' ) . val ( axisProps . getCrosses ( ) ) ;
}
// Pos
setOptions ( 'horizontal-axis-position' , [
2016-12-22 10:41:12 +00:00
{ display : me . textOnTickMarks , value : Asc . c _oAscLabelsPosition . byDivisions } ,
{ display : me . textBetweenTickMarks , value : Asc . c _oAscLabelsPosition . betweenDivisions }
2016-12-16 12:26:53 +00:00
] ) ;
setValue ( 'horizontal-axis-position' , axisProps . getLabelsPosition ( ) ) ;
$ ( '#horizontal-axis-in-reverse input' ) . prop ( 'checked' , axisProps . getInvertCatOrder ( ) ) ;
2016-12-16 11:17:40 +00:00
2016-12-16 12:26:53 +00:00
// Tick
var tickOptions = [
2016-12-22 10:41:12 +00:00
{ display : me . textNone , value : Asc . c _oAscTickMark . TICK _MARK _NONE } ,
{ display : me . textCross , value : Asc . c _oAscTickMark . TICK _MARK _CROSS } ,
{ display : me . textIn , value : Asc . c _oAscTickMark . TICK _MARK _IN } ,
{ display : me . textOut , value : Asc . c _oAscTickMark . TICK _MARK _OUT }
2016-12-16 12:26:53 +00:00
] ;
setOptions ( 'horizontal-axis-tick-major' , tickOptions ) ;
setOptions ( 'horizontal-axis-tick-minor' , tickOptions ) ;
setValue ( 'horizontal-axis-tick-major' , axisProps . getMajorTickMark ( ) ) ;
setValue ( 'horizontal-axis-tick-minor' , axisProps . getMinorTickMark ( ) ) ;
// Label
setOptions ( 'horizontal-axis-label-pos' , [
2016-12-22 10:41:12 +00:00
{ display : me . textNone , value : Asc . c _oAscTickLabelsPos . TICK _LABEL _POSITION _NONE } ,
{ display : me . textLow , value : Asc . c _oAscTickLabelsPos . TICK _LABEL _POSITION _LOW } ,
{ display : me . textHigh , value : Asc . c _oAscTickLabelsPos . TICK _LABEL _POSITION _HIGH } ,
{ display : me . textNextToAxis , value : Asc . c _oAscTickLabelsPos . TICK _LABEL _POSITION _NEXT _TO }
2016-12-16 12:26:53 +00:00
] ) ;
setValue ( 'horizontal-axis-label-pos' , axisProps . getTickLabelsPos ( ) ) ;
me . updateAxisProps ( chartProperty . getType ( ) ) ;
// Handlers
$ ( '#horizontal-axis-cross select' ) . single ( 'change' , _ . bind ( me . onHorAxisCrossType , me ) ) ;
$ ( '#edit-horizontal-axis-cross-value input' ) . single ( 'change' , _ . bind ( me . onHorAxisCrossValue , me ) ) ;
$ ( '#horizontal-axis-position select' ) . single ( 'change' , _ . bind ( me . onHorAxisPos , me ) ) ;
$ ( '#horizontal-axis-in-reverse input' ) . single ( 'change' , _ . bind ( me . onHorAxisReverse , me ) ) ;
$ ( '#horizontal-axis-tick-major select' ) . single ( 'change' , _ . bind ( me . onHorAxisTickMajor , me ) ) ;
$ ( '#horizontal-axis-tick-minor select' ) . single ( 'change' , _ . bind ( me . onHorAxisTickMinor , me ) ) ;
$ ( '#horizontal-axis-label-pos select' ) . single ( 'change' , _ . bind ( me . onHorAxisLabelPos , me ) ) ;
2016-12-16 11:17:40 +00:00
} ,
2016-12-12 15:13:46 +00:00
initReorderPage : function ( ) {
$ ( '.page[data-page=edit-chart-reorder] a.item-link' ) . single ( 'click' , _ . bind ( this . onReorder , this ) ) ;
} ,
initBorderColorPage : function ( ) {
2016-12-13 13:37:13 +00:00
var me = this ,
palette = new Common . UI . ThemeColorPalette ( {
el : $ ( '.page[data-page=edit-chart-border-color] .page-content' )
} ) ;
if ( palette ) {
palette . select ( _borderInfo . color ) ;
palette . on ( 'select' , _ . bind ( me . onBorderColor , me ) ) ;
}
2016-12-12 15:13:46 +00:00
} ,
// Handlers
onRemoveChart : function ( ) {
2016-12-19 13:17:04 +00:00
this . api . asc _Remove ( ) ;
SSE . getController ( 'EditContainer' ) . hideModal ( ) ;
2016-12-12 15:13:46 +00:00
} ,
onReorder : function ( e ) {
var $target = $ ( e . currentTarget ) ,
type = $target . data ( 'type' ) ,
ascType ;
if ( type == 'all-up' ) {
ascType = Asc . c _oAscDrawingLayerType . BringToFront ;
} else if ( type == 'all-down' ) {
ascType = Asc . c _oAscDrawingLayerType . SendToBack ;
} else if ( type == 'move-up' ) {
ascType = Asc . c _oAscDrawingLayerType . BringForward ;
} else {
ascType = Asc . c _oAscDrawingLayerType . SendBackward ;
}
this . api . asc _setSelectedDrawingObjectLayer ( ascType ) ;
} ,
2016-12-13 11:20:50 +00:00
onType : function ( e ) {
var me = this ,
$target = $ ( e . currentTarget ) ,
type = $target . data ( 'type' ) ;
$ ( '.chart-types li' ) . removeClass ( 'active' ) ;
$target . addClass ( 'active' ) ;
_ . defer ( function ( ) {
var image = new Asc . asc _CImgProperty ( ) ,
chart = _chartObject . get _ChartProperties ( ) ;
chart . changeType ( type ) ;
image . put _ChartProperties ( chart ) ;
me . api . asc _setGraphicObjectProps ( image ) ;
// Force update styles
me . _updateChartStyles ( me . api . asc _getChartPreviews ( chart . getType ( ) ) ) ;
2016-12-16 11:17:40 +00:00
me . updateAxisProps ( type ) ;
2016-12-13 11:20:50 +00:00
} ) ;
} ,
onStyle : function ( e ) {
var me = this ,
$target = $ ( e . currentTarget ) ,
type = $target . data ( 'type' ) ;
var image = new Asc . asc _CImgProperty ( ) ,
chart = _chartObject . get _ChartProperties ( ) ;
chart . putStyle ( type ) ;
image . put _ChartProperties ( chart ) ;
me . api . asc _setGraphicObjectProps ( image ) ;
} ,
2016-12-12 15:13:46 +00:00
onFillColor : function ( palette , color ) {
2016-12-13 13:37:13 +00:00
var me = this ;
if ( me . api ) {
var image = new Asc . asc _CImgProperty ( ) ,
shape = new Asc . asc _CShapeProperty ( ) ,
fill = new Asc . asc _CShapeFill ( ) ;
if ( color == 'transparent' ) {
fill . put _type ( Asc . c _oAscFill . FILL _TYPE _NOFILL ) ;
fill . put _fill ( null ) ;
} else {
fill . put _type ( Asc . c _oAscFill . FILL _TYPE _SOLID ) ;
fill . put _fill ( new Asc . asc _CFillSolid ( ) ) ;
fill . get _fill ( ) . put _color ( Common . Utils . ThemeColor . getRgbColor ( color ) ) ;
}
shape . put _fill ( fill ) ;
image . put _ShapeProperties ( shape ) ;
me . api . asc _setGraphicObjectProps ( image ) ;
}
} ,
onBorderSize : function ( e ) {
var me = this ,
$target = $ ( e . currentTarget ) ,
value = $target . val ( ) ,
image = new Asc . asc _CImgProperty ( ) ,
shape = new Asc . asc _CShapeProperty ( ) ,
2017-04-11 11:05:56 +00:00
stroke = new Asc . asc _CStroke ( ) ;
2016-12-13 13:37:13 +00:00
value = borderSizeTransform . sizeByIndex ( parseInt ( value ) ) ;
if ( value < 0.01 ) {
stroke . put _type ( Asc . c _oAscStrokeType . STROKE _NONE ) ;
} else {
stroke . put _type ( Asc . c _oAscStrokeType . STROKE _COLOR ) ;
2017-04-11 11:05:56 +00:00
if ( _borderInfo . color == 'transparent' )
stroke . put _color ( Common . Utils . ThemeColor . getRgbColor ( { color : '000000' , effectId : 29 } ) ) ;
else
stroke . put _color ( Common . Utils . ThemeColor . getRgbColor ( Common . Utils . ThemeColor . colorValue2EffectId ( _borderInfo . color ) ) ) ;
2016-12-13 13:37:13 +00:00
stroke . put _width ( value * 25.4 / 72.0 ) ;
}
shape . put _stroke ( stroke ) ;
image . put _ShapeProperties ( shape ) ;
me . api . asc _setGraphicObjectProps ( image ) ;
2017-04-11 11:05:56 +00:00
me . _initBorderColorView ( ) ; // when select STROKE_NONE or change from STROKE_NONE to STROKE_COLOR
2016-12-13 13:37:13 +00:00
} ,
onBorderSizeChanging : function ( e ) {
var $target = $ ( e . currentTarget ) ;
$ ( '#edit-chart-bordersize .item-after' ) . text ( borderSizeTransform . sizeByIndex ( $target . val ( ) ) + ' ' + _metricText ) ;
} ,
onBorderColor : function ( palette , color ) {
var me = this ,
currentShape = _shapeObject . get _ShapeProperties ( ) ;
$ ( '#edit-chart-bordercolor .color-preview' ) . css ( 'background-color' , ( 'transparent' == color ) ? color : ( '#' + ( _ . isObject ( color ) ? color . color : color ) ) ) ;
2017-04-11 11:05:56 +00:00
_borderInfo . color = color ;
2016-12-13 13:37:13 +00:00
2017-04-11 11:05:56 +00:00
if ( me . api && currentShape && currentShape . get _stroke ( ) . get _type ( ) == Asc . c _oAscStrokeType . STROKE _COLOR ) {
2016-12-13 13:37:13 +00:00
var image = new Asc . asc _CImgProperty ( ) ,
shape = new Asc . asc _CShapeProperty ( ) ,
stroke = new Asc . asc _CStroke ( ) ;
if ( currentShape . get _stroke ( ) . get _width ( ) < 0.01 ) {
stroke . put _type ( Asc . c _oAscStrokeType . STROKE _NONE ) ;
} else {
stroke . put _type ( Asc . c _oAscStrokeType . STROKE _COLOR ) ;
stroke . put _color ( Common . Utils . ThemeColor . getRgbColor ( color ) ) ;
stroke . put _width ( currentShape . get _stroke ( ) . get _width ( ) ) ;
stroke . asc _putPrstDash ( currentShape . get _stroke ( ) . asc _getPrstDash ( ) ) ;
}
shape . put _stroke ( stroke ) ;
image . put _ShapeProperties ( shape ) ;
me . api . asc _setGraphicObjectProps ( image ) ;
}
2016-12-12 15:13:46 +00:00
} ,
2016-12-15 08:43:29 +00:00
onLayoutTitle : function ( e ) {
this . _setLayoutProperty ( 'putTitle' , e ) ;
} ,
onLayoutLegend : function ( e ) {
this . _setLayoutProperty ( 'putLegendPos' , e ) ;
} ,
onLayoutAxisTitleHorizontal : function ( e ) {
this . _setLayoutProperty ( 'putHorAxisLabel' , e ) ;
} ,
onLayoutAxisTitleVertical : function ( e ) {
this . _setLayoutProperty ( 'putVertAxisLabel' , e ) ;
} ,
onLayoutGridlinesHorizontal : function ( e ) {
this . _setLayoutProperty ( 'putHorGridLines' , e ) ;
} ,
onLayoutGridlinesVertical : function ( e ) {
this . _setLayoutProperty ( 'putVertGridLines' , e ) ;
} ,
onLayoutDataLabel : function ( e ) {
this . _setLayoutProperty ( 'putDataLabelsPos' , e ) ;
} ,
2016-12-16 11:17:40 +00:00
onVerAxisMinValue : function ( e ) {
var value = $ ( e . currentTarget ) . val ( ) ,
axisProps = this . _getVerticalAxisProp ( ) ,
axisRule = _ . isEmpty ( value ) ? Asc . c _oAscValAxisRule . auto : Asc . c _oAscValAxisRule . fixed ;
axisProps . putMinValRule ( axisRule ) ;
if ( axisRule == Asc . c _oAscValAxisRule . fixed ) {
axisProps . putMinVal ( parseInt ( value ) ) ;
}
this . _setVerticalAxisProp ( axisProps ) ;
} ,
onVerAxisMaxValue : function ( e ) {
var value = $ ( e . currentTarget ) . val ( ) ,
axisProps = this . _getVerticalAxisProp ( ) ,
axisRule = _ . isEmpty ( value ) ? Asc . c _oAscValAxisRule . auto : Asc . c _oAscValAxisRule . fixed ;
axisProps . putMaxValRule ( axisRule ) ;
if ( axisRule == Asc . c _oAscValAxisRule . fixed ) {
axisProps . putMaxVal ( parseInt ( value ) ) ;
}
this . _setVerticalAxisProp ( axisProps ) ;
} ,
onVerAxisCrossType : function ( e ) {
var value = parseInt ( $ ( e . currentTarget ) . val ( ) ) ,
axisProps = this . _getVerticalAxisProp ( ) ;
if ( value == Asc . c _oAscCrossesRule . value ) {
$ ( '#edit-vertical-axis-cross-value' ) . css ( 'display' , 'block' ) ;
$ ( '#edit-vertical-axis-cross-value input' ) . val ( axisProps . getCrosses ( ) ) ;
} else {
$ ( '#edit-vertical-axis-cross-value' ) . css ( 'display' , 'none' ) ;
}
axisProps . putCrossesRule ( value ) ;
this . _setVerticalAxisProp ( axisProps ) ;
} ,
onVerAxisCrossValue : function ( e ) {
var value = $ ( e . currentTarget ) . val ( ) ,
axisProps = this . _getVerticalAxisProp ( ) ;
axisProps . putCrossesRule ( Asc . c _oAscCrossesRule . value ) ;
axisProps . putCrosses ( parseInt ( value ) ) ;
this . _setVerticalAxisProp ( axisProps ) ;
} ,
onVerAxisDisplayUnits : function ( e ) {
var value = $ ( e . currentTarget ) . val ( ) ,
axisProps = this . _getVerticalAxisProp ( ) ;
axisProps . putDispUnitsRule ( parseInt ( value ) ) ;
this . _setVerticalAxisProp ( axisProps ) ;
} ,
onVerAxisReverse : function ( e ) {
var value = $ ( e . currentTarget ) . prop ( 'checked' ) ,
axisProps = this . _getVerticalAxisProp ( ) ;
axisProps . putInvertValOrder ( value ) ;
this . _setVerticalAxisProp ( axisProps ) ;
} ,
onVerAxisTickMajor : function ( e ) {
var value = $ ( e . currentTarget ) . val ( ) ,
axisProps = this . _getVerticalAxisProp ( ) ;
axisProps . putMajorTickMark ( parseInt ( value ) ) ;
this . _setVerticalAxisProp ( axisProps ) ;
} ,
onVerAxisTickMinor : function ( e ) {
var value = $ ( e . currentTarget ) . val ( ) ,
axisProps = this . _getVerticalAxisProp ( ) ;
axisProps . putMinorTickMark ( parseInt ( value ) ) ;
this . _setVerticalAxisProp ( axisProps ) ;
} ,
onVerAxisLabelPos : function ( e ) {
var value = $ ( e . currentTarget ) . val ( ) ,
axisProps = this . _getVerticalAxisProp ( ) ;
axisProps . putTickLabelsPos ( parseInt ( value ) ) ;
this . _setVerticalAxisProp ( axisProps ) ;
} ,
2016-12-16 12:26:53 +00:00
onHorAxisCrossType : function ( e ) {
var value = $ ( e . currentTarget ) . val ( ) ,
axisProps = this . _getHorizontalAxisProp ( ) ;
if ( value == Asc . c _oAscCrossesRule . value ) {
$ ( '#edit-horizontal-axis-cross-value' ) . css ( 'display' , 'block' ) ;
$ ( '#edit-horizontal-axis-cross-value input' ) . val ( axisProps . getCrosses ( ) ) ;
} else {
$ ( '#edit-horizontal-axis-cross-value' ) . css ( 'display' , 'none' ) ;
}
axisProps . putCrossesRule ( parseInt ( value ) ) ;
this . _setHorizontalAxisProp ( axisProps ) ;
} ,
onHorAxisCrossValue : function ( e ) {
var value = $ ( e . currentTarget ) . val ( ) ,
axisProps = this . _getHorizontalAxisProp ( ) ;
axisProps . putCrossesRule ( Asc . c _oAscCrossesRule . value ) ;
axisProps . putCrosses ( parseInt ( value ) ) ;
this . _setHorizontalAxisProp ( axisProps ) ;
} ,
onHorAxisPos : function ( e ) {
var value = $ ( e . currentTarget ) . val ( ) ,
axisProps = this . _getHorizontalAxisProp ( ) ;
axisProps . putLabelsPosition ( parseInt ( value ) ) ;
this . _setHorizontalAxisProp ( axisProps ) ;
} ,
onHorAxisReverse : function ( e ) {
var value = $ ( e . currentTarget ) . prop ( 'checked' ) ,
axisProps = this . _getHorizontalAxisProp ( ) ;
axisProps . putInvertCatOrder ( value ) ;
this . _setHorizontalAxisProp ( axisProps ) ;
} ,
onHorAxisTickMajor : function ( e ) {
var value = $ ( e . currentTarget ) . val ( ) ,
axisProps = this . _getHorizontalAxisProp ( ) ;
axisProps . putMajorTickMark ( parseInt ( value ) ) ;
this . _setHorizontalAxisProp ( axisProps ) ;
} ,
onHorAxisTickMinor : function ( e ) {
var value = $ ( e . currentTarget ) . val ( ) ,
axisProps = this . _getHorizontalAxisProp ( ) ;
axisProps . putMinorTickMark ( parseInt ( value ) ) ;
this . _setHorizontalAxisProp ( axisProps ) ;
} ,
onHorAxisLabelPos : function ( e ) {
var value = $ ( e . currentTarget ) . val ( ) ,
axisProps = this . _getHorizontalAxisProp ( ) ;
axisProps . putTickLabelsPos ( parseInt ( value ) ) ;
this . _setHorizontalAxisProp ( axisProps ) ;
} ,
2016-12-16 11:17:40 +00:00
updateAxisProps : function ( chartType ) {
// var value = (chartType == Asc.c_oAscChartTypeSettings.lineNormal || chartType == Asc.c_oAscChartTypeSettings.lineStacked ||
// chartType == Asc.c_oAscChartTypeSettings.lineStackedPer || chartType == Asc.c_oAscChartTypeSettings.scatter);
// this.chMarkers.setVisible(value);
// this.cmbLines.setVisible(value);
// this.lblLines.toggleClass('hidden', !value);
//
// if (value) {
// this.chMarkers.setValue(this.chartSettings.getShowMarker(), true);
// this.cmbLines.setValue(this.chartSettings.getLine() ? (this.chartSettings.getSmooth() ? 2 : 1) : 0);
// }
2016-12-16 12:26:53 +00:00
// Disable Axises
var disableEditAxis = (
chartType == Asc . c _oAscChartTypeSettings . pie ||
chartType == Asc . c _oAscChartTypeSettings . doughnut ||
chartType == Asc . c _oAscChartTypeSettings . pie3d
) ;
$ ( '#chart-vaxis, #chart-haxis' ) . toggleClass ( 'disabled' , disableEditAxis ) ;
var disableAxisPos = (
chartType == Asc . c _oAscChartTypeSettings . barNormal3d ||
chartType == Asc . c _oAscChartTypeSettings . barStacked3d ||
chartType == Asc . c _oAscChartTypeSettings . barStackedPer3d ||
chartType == Asc . c _oAscChartTypeSettings . hBarNormal3d ||
chartType == Asc . c _oAscChartTypeSettings . hBarStacked3d ||
chartType == Asc . c _oAscChartTypeSettings . hBarStackedPer3d ||
chartType == Asc . c _oAscChartTypeSettings . barNormal3dPerspective
) ;
$ ( '#horizontal-axis-position' ) . toggleClass ( 'disabled' , disableAxisPos ) ;
2016-12-16 11:17:40 +00:00
// Reverse Axises
var needReverse = (
chartType == Asc . c _oAscChartTypeSettings . hBarNormal ||
chartType == Asc . c _oAscChartTypeSettings . hBarStacked ||
chartType == Asc . c _oAscChartTypeSettings . hBarStackedPer ||
chartType == Asc . c _oAscChartTypeSettings . hBarNormal3d ||
chartType == Asc . c _oAscChartTypeSettings . hBarStacked3d ||
chartType == Asc . c _oAscChartTypeSettings . hBarStackedPer3d
) ;
$ ( '#chart-vaxis' ) . data ( 'page' , needReverse ? '#edit-chart-horizontal-axis' : '#edit-chart-vertical-axis' ) ;
$ ( '#chart-haxis' ) . data ( 'page' , ( needReverse || chartType == Asc . c _oAscChartTypeSettings . scatter ) ? '#edit-chart-vertical-axis' : '#edit-chart-horizontal-axis' ) ;
} ,
2016-12-15 08:43:29 +00:00
2016-12-12 15:13:46 +00:00
// API handlers
2016-12-13 11:20:50 +00:00
onApiUpdateChartStyles : function ( ) {
if ( this . api && _chartObject && _chartObject . get _ChartProperties ( ) ) {
this . _updateChartStyles ( this . api . asc _getChartPreviews ( _chartObject . get _ChartProperties ( ) . getType ( ) ) ) ;
2016-12-12 15:13:46 +00:00
}
} ,
2016-12-13 13:37:13 +00:00
onApiSelectionChanged : function ( info ) {
2016-12-12 15:13:46 +00:00
if ( ! _isEdit ) {
return ;
}
2016-12-13 13:37:13 +00:00
var me = this ,
selectedObjects = [ ] ,
selectType = info . asc _getFlags ( ) . asc _getSelectionType ( ) ;
if ( selectType == Asc . c _oAscSelectionType . RangeChart ) {
selectedObjects = me . api . asc _getGraphicObjectProps ( ) ;
}
me . onApiFocusObject ( selectedObjects ) ;
} ,
onApiFocusObject : function ( objects ) {
_stack = objects ;
if ( ! _isEdit ) {
return ;
}
2016-12-13 11:20:50 +00:00
2016-12-13 13:37:13 +00:00
var charts = [ ] ,
shapes = [ ] ;
2016-12-13 11:20:50 +00:00
2016-12-13 13:37:13 +00:00
_ . each ( _stack , function ( object ) {
if ( object . get _ObjectType ( ) == Asc . c _oAscTypeSelectElement . Image ) {
if ( object . get _ObjectValue ( ) && object . get _ObjectValue ( ) . get _ChartProperties ( ) ) {
charts . push ( object ) ;
}
if ( object . get _ObjectValue ( ) && object . get _ObjectValue ( ) . get _ShapeProperties ( ) ) {
shapes . push ( object ) ;
2016-12-13 11:20:50 +00:00
}
}
2016-12-13 13:37:13 +00:00
} ) ;
var getTopObject = function ( array ) {
if ( array . length > 0 ) {
var object = array [ array . length - 1 ] ; // get top
return object . get _ObjectValue ( ) ;
} else {
return undefined ;
}
} ;
_chartObject = getTopObject ( charts ) ;
_shapeObject = getTopObject ( shapes ) ;
2016-12-12 15:13:46 +00:00
} ,
// Helpers
2016-12-16 11:17:40 +00:00
_getVerticalAxisProp : function ( ) {
var chartObject = this . api . asc _getChartObject ( ) ,
verAxisProps = chartObject . getVertAxisProps ( ) ;
return ( verAxisProps . getAxisType ( ) == Asc . c _oAscAxisType . val ) ? verAxisProps : chartObject . getHorAxisProps ( ) ;
} ,
_setVerticalAxisProp : function ( axisProps ) {
var chartObject = this . api . asc _getChartObject ( ) ,
verAxisProps = chartObject . getVertAxisProps ( ) ;
if ( ! _ . isUndefined ( chartObject ) ) {
chartObject [ ( verAxisProps . getAxisType ( ) == Asc . c _oAscAxisType . val ) ? 'putVertAxisProps' : 'putHorAxisProps' ] ( axisProps ) ;
this . api . asc _editChartDrawingObject ( chartObject ) ;
}
} ,
2016-12-16 12:26:53 +00:00
_getHorizontalAxisProp : function ( ) {
2016-12-16 11:17:40 +00:00
var chartObject = this . api . asc _getChartObject ( ) ,
verHorProps = chartObject . getHorAxisProps ( ) ;
2016-12-16 12:26:53 +00:00
return ( verHorProps . getAxisType ( ) == Asc . c _oAscAxisType . val ) ? chartObject . getVertAxisProps ( ) : verHorProps ;
2016-12-16 11:17:40 +00:00
} ,
2016-12-16 12:26:53 +00:00
_setHorizontalAxisProp : function ( axisProps ) {
2016-12-16 11:17:40 +00:00
var chartObject = this . api . asc _getChartObject ( ) ,
verAxisProps = chartObject . getHorAxisProps ( ) ;
if ( ! _ . isUndefined ( chartObject ) ) {
2016-12-16 12:26:53 +00:00
chartObject [ ( verAxisProps . getAxisType ( ) == Asc . c _oAscAxisType . val ) ? 'putVertAxisProps' : 'putHorAxisProps' ] ( axisProps ) ;
2016-12-16 11:17:40 +00:00
this . api . asc _editChartDrawingObject ( chartObject ) ;
}
} ,
2016-12-15 08:43:29 +00:00
_setLayoutProperty : function ( propertyMethod , e ) {
var value = $ ( e . currentTarget ) . val ( ) ,
chartObject = this . api . asc _getChartObject ( ) ;
if ( ! _ . isUndefined ( chartObject ) && value && value . length > 0 ) {
2017-04-11 11:05:56 +00:00
var intValue = parseInt ( value ) ;
2016-12-15 08:43:29 +00:00
chartObject [ propertyMethod ] ( parseInt ( value ) ) ;
2017-04-11 11:05:56 +00:00
if ( "putDataLabelsPos" == propertyMethod && intValue != 0 )
chartObject [ "putShowVal" ] ( true ) ;
2016-12-15 08:43:29 +00:00
this . api . asc _editChartDrawingObject ( chartObject ) ;
}
} ,
2016-12-13 11:20:50 +00:00
_updateChartStyles : function ( styles ) {
this . getView ( 'EditChart' ) . renderStyles ( styles ) ;
$ ( '#tab-chart-style li' ) . single ( 'click' , _ . bind ( this . onStyle , this ) ) ;
} ,
2016-12-12 15:13:46 +00:00
_sdkToThemeColor : function ( color ) {
var clr = 'transparent' ;
if ( color ) {
if ( color . get _type ( ) == Asc . c _oAscColor . COLOR _TYPE _SCHEME ) {
clr = {
color : Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) ,
effectValue : color . get _value ( )
}
} else {
clr = Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) ;
}
}
return clr ;
} ,
2016-12-14 14:14:00 +00:00
textValue : 'Value' ,
textMinValue : 'Minimum Value' ,
textMaxValue : 'Maximum Value' ,
textLeftOverlay : 'Left Overlay' ,
textRightOverlay : 'Right Overlay' ,
textOverlay : 'Overlay' ,
textNoOverlay : 'No Overlay' ,
textRotated : 'Rotated' ,
textHorizontal : 'Horizontal' ,
textInnerBottom : 'Inner Bottom' ,
textInnerTop : 'Inner Top' ,
textOuterTop : 'Outer Top' ,
textNone : 'None' ,
textCenter : 'Center' ,
textFixed : 'Fixed' ,
textAuto : 'Auto' ,
textCross : 'Cross' ,
textIn : 'In' ,
textOut : 'Out' ,
textLow : 'Low' ,
textHigh : 'High' ,
textNextToAxis : 'Next to axis' ,
textHundreds : 'Hundreds' ,
textThousands : 'Thousands' ,
textTenThousands : '10 000' ,
textHundredThousands : '100 000' ,
textMillions : 'Millions' ,
textTenMillions : '10 000 000' ,
textHundredMil : '100 000 000' ,
textBillions : 'Billions' ,
textTrillions : 'Trillions' ,
textCustom : 'Custom' ,
textManual : 'Manual' ,
textBetweenTickMarks : 'Between Tick Marks' ,
textOnTickMarks : 'On Tick Marks' ,
errorMaxRows : 'ERROR! 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.' ,
textLeft : 'Left' ,
textRight : 'Right' ,
textTop : 'Top' ,
textBottom : 'Bottom' ,
textFit : 'Fit Width'
2016-12-12 15:13:46 +00:00
}
} ) ( ) , SSE . Controllers . EditChart || { } ) )
} ) ;