2016-12-12 15:13:46 +00:00
/ *
*
* ( c ) Copyright Ascensio System Limited 2010 - 2016
*
* 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 ] ;
} ,
sizeByValue : function ( value ) {
var index = 0 ;
_ . each ( _sizes , function ( size , idx ) {
if ( Math . abs ( size - value ) < 0.25 ) {
index = idx ;
}
} ) ;
return _sizes [ index ] ;
}
}
} ) ( ) ;
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 ) {
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-12 15:13:46 +00:00
} else if ( '#edit-chart-reorder' == pageId ) {
me . initReorderPage ( ) ;
} else {
$ ( '#chart-remove' ) . single ( 'click' , _ . bind ( me . onRemoveChart , me ) ) ;
}
} ,
// 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-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
var borderSize = shapeProperties . get _stroke ( ) . get _width ( ) * 72.0 / 25.4 ;
$ ( '#edit-chart-bordersize input' ) . val ( [ borderSizeTransform . sizeByIndex ( borderSize ) ] ) ;
$ ( '#edit-chart-bordersize .item-after' ) . text ( borderSizeTransform . sizeByValue ( borderSize ) + ' ' + _metricText ) ;
$ ( '#edit-chart-bordersize input' ) . single ( 'change touchend' , _ . buffered ( me . onBorderSize , 100 , me ) ) ;
$ ( '#edit-chart-bordersize input' ) . single ( 'input' , _ . bind ( me . onBorderSizeChanging , me ) ) ;
var stroke = shapeProperties . get _stroke ( ) ,
strokeType = stroke . get _type ( ) ;
if ( stroke && strokeType == Asc . c _oAscStrokeType . STROKE _COLOR ) {
_borderInfo . color = me . _sdkToThemeColor ( stroke . get _color ( ) ) ;
}
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 ) )
)
} ,
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
} ,
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 ( ) {
console . debug ( 'REMOVE CHART' )
} ,
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 ( ) ) ) ;
} ) ;
} ,
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 ( ) ,
currentShape = _shapeObject . get _ShapeProperties ( ) ,
image = new Asc . asc _CImgProperty ( ) ,
shape = new Asc . asc _CShapeProperty ( ) ,
stroke = new Asc . asc _CStroke ( ) ,
currentColor = Common . Utils . ThemeColor . getRgbColor ( '000000' ) ;
value = borderSizeTransform . sizeByIndex ( parseInt ( value ) ) ;
var currentStroke = currentShape . get _stroke ( ) ;
if ( currentStroke ) {
var currentStrokeType = currentStroke . get _type ( ) ;
if ( currentStrokeType == Asc . c _oAscStrokeType . STROKE _COLOR ) {
currentColor = currentStroke . get _color ( ) ;
}
}
if ( value < 0.01 ) {
stroke . put _type ( Asc . c _oAscStrokeType . STROKE _NONE ) ;
} else {
stroke . put _type ( Asc . c _oAscStrokeType . STROKE _COLOR ) ;
stroke . put _color ( currentColor ) ;
stroke . put _width ( value * 25.4 / 72.0 ) ;
}
shape . put _stroke ( stroke ) ;
image . put _ShapeProperties ( shape ) ;
me . api . asc _setGraphicObjectProps ( image ) ;
} ,
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 ) ) ) ;
if ( me . api && currentShape ) {
var image = new Asc . asc _CImgProperty ( ) ,
shape = new Asc . asc _CShapeProperty ( ) ,
stroke = new Asc . asc _CStroke ( ) ;
_borderInfo . color = Common . Utils . ThemeColor . getRgbColor ( color ) ;
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-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-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 ) {
chartObject [ propertyMethod ] ( parseInt ( value ) ) ;
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
textChart : 'Chart' ,
textLayout : 'Layout' ,
textLegendPos : 'Legend' ,
textHorTitle : 'Horizontal Axis Title' ,
textVertTitle : 'Vertical Axis Title' ,
textDataLabels : 'Data Labels' ,
textSeparator : 'Data Labels Separator' ,
textSeriesName : 'Series Name' ,
textCategoryName : 'Category Name' ,
textValue : 'Value' ,
textAxisOptions : 'Axis Options' ,
textMinValue : 'Minimum Value' ,
textMaxValue : 'Maximum Value' ,
textAxisCrosses : 'Axis Crosses' ,
textUnits : 'Display Units' ,
textTickOptions : 'Tick Options' ,
textMajorType : 'Major Type' ,
textMinorType : 'Minor Type' ,
textLabelOptions : 'Label Options' ,
textLabelPos : 'Label Position' ,
textReverse : 'Values in reverse order' ,
textVertAxis : 'Vertical Axis' ,
textHorAxis : 'Horizontal Axis' ,
textMarksInterval : 'Interval between Marks' ,
textLabelDist : 'Axis Label Distance' ,
textLabelInterval : 'Interval between Labels' ,
textAxisPos : 'Axis Position' ,
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' ,
textHorGrid : 'Horizontal Gridlines' ,
textVertGrid : 'Vertical Gridlines' ,
textLines : 'Lines' ,
textMarkers : 'Markers' ,
textMajor : 'Major' ,
textMinor : 'Minor' ,
textMajorMinor : 'Major and Minor' ,
textStraight : 'Straight' ,
textSmooth : 'Smooth' ,
textType : 'Type' ,
textTypeData : 'Type & Data' ,
textStyle : 'Style' ,
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.' ,
textAxisSettings : 'Axis Settings' ,
textGridLines : 'Gridlines' ,
textShow : 'Show' ,
textHide : 'Hide' ,
textLeft : 'Left' ,
textRight : 'Right' ,
textTop : 'Top' ,
textBottom : 'Bottom' ,
textFit : 'Fit Width'
2016-12-12 15:13:46 +00:00
}
} ) ( ) , SSE . Controllers . EditChart || { } ) )
} ) ;