2020-07-07 08:45:45 +00:00
/ *
*
* ( c ) Copyright Ascensio System SIA 2010 - 2020
*
* 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 20 A - 12 Ernesta Birznieka - Upisha
* 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
*
* /
/ * *
* ChartDataDialog . js
*
* Created by Julia Radzhabova on 06.07 . 2020
* Copyright ( c ) 2020 Ascensio System SIA . All rights reserved .
*
* /
define ( [
'common/main/lib/util/utils' ,
'common/main/lib/component/MetricSpinner' ,
'common/main/lib/component/ComboBox' ,
'common/main/lib/component/ListView' ,
'common/main/lib/view/AdvancedSettingsWindow'
] , function ( ) { 'use strict' ;
SSE . Views . ChartDataDialog = Common . Views . AdvancedSettingsWindow . extend ( _ . extend ( {
options : {
contentWidth : 370 ,
2020-07-07 12:10:48 +00:00
height : 490
2020-07-07 08:45:45 +00:00
} ,
initialize : function ( options ) {
var me = this ;
_ . extend ( this . options , {
title : this . textTitle ,
template : [
'<div class="box" style="height:' + ( me . options . height - 85 ) + 'px;">' ,
'<div class="content-panel" style="padding: 0 10px;"><div class="inner-content">' ,
'<div class="settings-panel active">' ,
'<table cols="1" style="width: 100%;">' ,
'<tr>' ,
'<td>' ,
2020-07-15 10:48:58 +00:00
'<label class="input-label">' , me . textData , '</label>' ,
2020-07-07 08:45:45 +00:00
'</td>' ,
'</tr>' ,
'<tr>' ,
'<td class="padding-small" width="200">' ,
'<div id="chart-dlg-txt-range" class="input-row" style=""></div>' ,
'</td>' ,
'</tr>' ,
'<tr>' ,
'<td class="padding-small">' ,
'<label class="input-label">' , me . textSeries , '</label>' ,
'<div id="chart-dlg-series-list" class="" style="width:100%; height: 93px;"></div>' ,
'</td>' ,
'</tr>' ,
'<tr>' ,
'<td class="padding-large">' ,
'<button type="button" class="btn btn-text-default auto" id="chart-dlg-btn-add" style="min-width: 70px;margin-right:5px;">' , me . textAdd , '</button>' ,
'<button type="button" class="btn btn-text-default auto" id="chart-dlg-btn-edit" style="min-width: 70px;margin-right:5px;">' , me . textEdit , '</button>' ,
'<button type="button" class="btn btn-text-default auto" id="chart-dlg-btn-delete" style="min-width: 70px;margin-right:5px;">' , me . textDelete , '</button>' ,
'<div style="display: inline-block; float: right;">' ,
2021-04-14 23:03:33 +00:00
'<div id="chart-dlg-btn-up" style="display: inline-block;margin-right: 2px;"></div>' ,
'<div id="chart-dlg-btn-down" style="display: inline-block;"></div>' ,
2020-07-07 08:45:45 +00:00
'</div>' ,
'</td>' ,
'</tr>' ,
'<tr>' ,
'<td class="padding-large">' ,
'<button type="button" class="btn btn-text-default auto" id="chart-dlg-btn-switch" style="min-width: 70px;margin-right:5px;">' , me . textSwitch , '</button>' ,
'</td>' ,
'</tr>' ,
'<tr>' ,
'<td class="padding-small">' ,
'<label class="input-label">' , me . textCategory , '</label>' ,
'<div id="chart-dlg-category-list" class="" style="width:100%; height: 93px;"></div>' ,
'</td>' ,
'</tr>' ,
'<tr>' ,
'<td class="padding-small">' ,
'<button type="button" class="btn btn-text-default auto" id="chart-dlg-btn-category-edit" style="min-width: 70px;margin-right:5px;">' , me . textEdit , '</button>' ,
'</td>' ,
'</tr>' ,
'</table>' ,
'</div></div>' ,
'</div>' ,
'</div>' ,
2020-07-07 12:10:48 +00:00
'<div class="separator horizontal"></div>'
2020-07-07 08:45:45 +00:00
] . join ( '' )
} , options ) ;
this . handler = options . handler ;
Common . Views . AdvancedSettingsWindow . prototype . initialize . call ( this , this . options ) ;
this . _noApply = true ;
this . _changedProps = null ;
this . api = this . options . api ;
this . chartSettings = this . options . chartSettings ;
this . currentChartType = Asc . c _oAscChartTypeSettings . barNormal ;
} ,
render : function ( ) {
Common . Views . AdvancedSettingsWindow . prototype . render . call ( this ) ;
var me = this ;
this . txtDataRange = new Common . UI . InputFieldBtn ( {
el : $ ( '#chart-dlg-txt-range' ) ,
name : 'range' ,
style : 'width: 100%;' ,
btnHint : this . textSelectData ,
2020-07-08 09:51:57 +00:00
allowBlank : true
// validateOnChange: true
2020-07-07 08:45:45 +00:00
} ) ;
2020-07-08 07:41:18 +00:00
this . txtDataRange . on ( 'button:click' , _ . bind ( this . onSelectData , this ) ) ;
2020-07-07 08:45:45 +00:00
this . txtDataRange . on ( 'changed:after' , function ( input , newValue , oldValue , e ) {
2020-07-08 07:41:18 +00:00
if ( newValue == oldValue ) return ;
me . changeChartRange ( newValue ) ;
2020-07-07 08:45:45 +00:00
} ) ;
// Chart data
this . seriesList = new Common . UI . ListView ( {
el : $ ( '#chart-dlg-series-list' , this . $window ) ,
store : new Common . UI . DataViewStore ( ) ,
emptyText : '' ,
2020-07-10 16:11:55 +00:00
scrollAlwaysVisible : true ,
2021-04-14 23:19:18 +00:00
itemTemplate : _ . template ( '<div id="<%= id %>" class="list-item" style="min-height: 15px;"><%= value %></div>' ) ,
tabindex : 1
2020-07-07 08:45:45 +00:00
} ) ;
this . seriesList . onKeyDown = _ . bind ( this . onListKeyDown , this , 'series' ) ;
this . seriesList . on ( 'item:select' , _ . bind ( this . onSelectSeries , this ) ) ;
2020-07-07 12:07:15 +00:00
this . seriesList . store . comparator = function ( rec ) {
return rec . get ( "order" ) ;
} ;
2020-07-07 08:45:45 +00:00
this . btnAdd = new Common . UI . Button ( {
el : $ ( '#chart-dlg-btn-add' )
} ) ;
this . btnAdd . on ( 'click' , _ . bind ( this . onAddSeries , this , false ) ) ;
this . btnDelete = new Common . UI . Button ( {
el : $ ( '#chart-dlg-btn-delete' )
} ) ;
2020-07-07 12:07:15 +00:00
this . btnDelete . on ( 'click' , _ . bind ( this . onDeleteSeries , this ) ) ;
2020-07-07 08:45:45 +00:00
this . btnEdit = new Common . UI . Button ( {
el : $ ( '#chart-dlg-btn-edit' )
} ) ;
this . btnEdit . on ( 'click' , _ . bind ( this . onEditSeries , this , false ) ) ;
this . btnUp = new Common . UI . Button ( {
parentEl : $ ( '#chart-dlg-btn-up' ) ,
2021-04-14 23:03:33 +00:00
cls : 'btn-toolbar bg-white' ,
2020-07-07 08:45:45 +00:00
iconCls : 'caret-up' ,
hint : this . textUp
} ) ;
2020-07-07 12:07:15 +00:00
this . btnUp . on ( 'click' , _ . bind ( this . onMoveClick , this , true ) ) ;
2020-07-07 08:45:45 +00:00
this . btnDown = new Common . UI . Button ( {
parentEl : $ ( '#chart-dlg-btn-down' ) ,
2021-04-14 23:03:33 +00:00
cls : 'btn-toolbar bg-white' ,
2020-07-07 08:45:45 +00:00
iconCls : 'caret-down' ,
hint : this . textDown
} ) ;
2020-07-07 12:07:15 +00:00
this . btnDown . on ( 'click' , _ . bind ( this . onMoveClick , this , false ) ) ;
2020-07-07 08:45:45 +00:00
this . btnSwitch = new Common . UI . Button ( {
el : $ ( '#chart-dlg-btn-switch' )
} ) ;
2020-07-08 09:51:57 +00:00
this . btnSwitch . on ( 'click' , _ . bind ( this . onSwitch , this ) ) ;
2020-07-07 08:45:45 +00:00
this . categoryList = new Common . UI . ListView ( {
el : $ ( '#chart-dlg-category-list' , this . $window ) ,
store : new Common . UI . DataViewStore ( ) ,
emptyText : '' ,
2020-07-10 16:11:55 +00:00
scrollAlwaysVisible : true ,
2021-04-14 23:19:18 +00:00
itemTemplate : _ . template ( '<div id="<%= id %>" class="list-item" style="min-height: 15px;"><%= value %></div>' ) ,
tabindex : 1
2020-07-07 08:45:45 +00:00
} ) ;
this . btnEditCategory = new Common . UI . Button ( {
el : $ ( '#chart-dlg-btn-category-edit' )
} ) ;
this . btnEditCategory . on ( 'click' , _ . bind ( this . onEditCategory , this , false ) ) ;
this . afterRender ( ) ;
} ,
2021-04-14 23:19:18 +00:00
getFocusedComponents : function ( ) {
return [ this . txtDataRange , this . seriesList , this . btnAdd , this . btnEdit , this . btnDelete , this . btnUp , this . btnDown , this . btnSwitch , this . categoryList , this . btnEditCategory ] ;
2020-07-07 08:45:45 +00:00
} ,
2021-04-14 23:19:18 +00:00
getDefaultFocusableComponent : function ( ) {
return this . txtDataRange ;
} ,
2020-07-07 08:45:45 +00:00
2021-04-14 23:19:18 +00:00
afterRender : function ( ) {
this . _setDefaults ( this . chartSettings ) ;
2020-07-07 08:45:45 +00:00
} ,
close : function ( ) {
this . api . asc _onCloseChartFrame ( ) ;
Common . Views . AdvancedSettingsWindow . prototype . close . apply ( this , arguments ) ;
} ,
_setDefaults : function ( props ) {
var me = this ;
if ( props ) {
this . chartSettings = props ;
this . currentChartType = props . getType ( ) ;
var value = props . getRange ( ) ;
this . txtDataRange . setValue ( ( value ) ? value : '' ) ;
this . txtDataRange . validation = function ( value ) {
2020-07-10 16:11:55 +00:00
return true ;
2020-07-07 08:45:45 +00:00
} ;
2020-07-07 12:07:15 +00:00
this . updateSeriesList ( props . getSeries ( ) , 0 ) ;
2020-07-08 07:41:18 +00:00
this . updateCategoryList ( props . getCatValues ( ) ) ;
2020-07-07 08:45:45 +00:00
}
2020-07-07 12:07:15 +00:00
this . updateButtons ( ) ;
2020-07-07 08:45:45 +00:00
} ,
getSettings : function ( ) {
return { chartSettings : this . chartSettings } ;
} ,
onDlgBtnClick : function ( event ) {
var state = ( typeof ( event ) == 'object' ) ? event . currentTarget . attributes [ 'result' ] . value : event ;
if ( state == 'ok' ) {
2020-07-08 07:41:18 +00:00
if ( ! this . isRangeValid ( ) ) return ;
2020-07-07 08:45:45 +00:00
this . handler && this . handler . call ( this , state , ( state == 'ok' ) ? this . getSettings ( ) : undefined ) ;
}
this . close ( ) ;
} ,
onPrimary : function ( ) {
this . onDlgBtnClick ( 'ok' ) ;
return false ;
} ,
isRangeValid : function ( ) {
var isvalid ;
2020-07-15 10:01:05 +00:00
isvalid = this . chartSettings . isValidRange ( this . txtDataRange . getValue ( ) ) ;
if ( isvalid === true || isvalid == Asc . c _oAscError . ID . No )
2020-07-07 08:45:45 +00:00
return true ;
2020-07-15 10:01:05 +00:00
var error = this . textInvalidRange ;
switch ( isvalid ) {
case Asc . c _oAscError . ID . StockChartError :
error = this . errorStockChart ;
break ;
case Asc . c _oAscError . ID . MaxDataSeriesError :
error = this . errorMaxRows ;
break ;
case Asc . c _oAscError . ID . MaxDataPointsError :
error = this . errorMaxPoints ;
break ;
case Asc . c _oAscError . ID . ErrorInFormula :
error = this . errorInFormula ;
break ;
case Asc . c _oAscError . ID . InvalidReference :
error = this . errorInvalidReference ;
break ;
case Asc . c _oAscError . ID . NoSingleRowCol :
error = this . errorNoSingleRowCol ;
break ;
case Asc . c _oAscError . ID . NoValues :
error = this . errorNoValues ;
break ;
2020-07-08 12:04:19 +00:00
}
2020-07-15 10:01:05 +00:00
Common . UI . warning ( { msg : error , maxwidth : 600 } ) ;
2020-07-07 08:45:45 +00:00
return false ;
} ,
2020-07-08 07:41:18 +00:00
changeChartRange : function ( settings ) {
2020-07-07 08:45:45 +00:00
var me = this ;
2020-07-08 07:41:18 +00:00
if ( me . isRangeValid ( settings ) ) {
me . txtDataRange . checkValidate ( ) ;
2020-07-15 10:01:05 +00:00
me . chartSettings . setRange ( settings ) ;
2020-07-08 07:41:18 +00:00
me . updateSeriesList ( me . chartSettings . getSeries ( ) , 0 ) ;
me . updateCategoryList ( me . chartSettings . getCatValues ( ) ) ;
me . updateButtons ( ) ;
2020-07-07 08:45:45 +00:00
}
} ,
2020-07-08 07:41:18 +00:00
onSelectData : function ( input ) {
2020-07-07 08:45:45 +00:00
var me = this ;
if ( me . api ) {
2020-07-08 07:41:18 +00:00
var handlerDlg = function ( dlg , result ) {
if ( result == 'ok' ) {
input . setValue ( dlg . getSettings ( ) ) ;
2020-07-10 16:11:55 +00:00
_ . delay ( function ( ) {
me . changeChartRange ( dlg . getSettings ( ) ) ;
} , 10 ) ;
2020-07-08 07:41:18 +00:00
}
} ;
2020-07-07 08:45:45 +00:00
var win = new SSE . Views . CellRangeDialog ( {
handler : handlerDlg
} ) . on ( 'close' , function ( ) {
me . show ( ) ;
} ) ;
var xy = me . $window . offset ( ) ;
me . hide ( ) ;
win . show ( xy . left + 160 , xy . top + 125 ) ;
win . setSettings ( {
api : me . api ,
2020-07-15 10:01:05 +00:00
range : me . txtDataRange . getValue ( ) ,
2020-07-10 16:11:55 +00:00
type : Asc . c _oAscSelectionDialogType . Chart ,
validation : function ( ) { return true ; }
2020-07-07 08:45:45 +00:00
} ) ;
}
} ,
onListKeyDown : function ( type , e , data ) {
2020-07-08 07:41:18 +00:00
var record = null , listView = this . seriesList ;
2020-07-07 08:45:45 +00:00
if ( listView . disabled ) return ;
if ( _ . isUndefined ( undefined ) ) data = e ;
2020-07-08 07:41:18 +00:00
if ( data . keyCode == Common . UI . Keys . DELETE && ! this . btnDelete . isDisabled ( ) ) {
2020-07-07 08:45:45 +00:00
// this.onDeleteSeries();
} else {
Common . UI . DataView . prototype . onKeyDown . call ( listView , e , data ) ;
}
} ,
onSelectSeries : function ( lisvView , itemView , record ) {
this . updateMoveButtons ( ) ;
} ,
2020-07-15 10:01:05 +00:00
updateRange : function ( ) {
this . txtDataRange . setValue ( this . chartSettings . getRange ( ) || '' ) ;
} ,
2020-07-07 12:07:15 +00:00
updateButtons : function ( ) {
this . btnEdit . setDisabled ( this . seriesList . store . length < 1 ) ;
this . btnDelete . setDisabled ( this . seriesList . store . length < 1 ) ;
2020-07-08 12:04:19 +00:00
this . btnSwitch . setDisabled ( this . seriesList . store . length < 1 || ! this . chartSettings . getRange ( ) ) ;
2020-07-07 12:07:15 +00:00
this . updateMoveButtons ( ) ;
} ,
2020-07-07 08:45:45 +00:00
updateMoveButtons : function ( ) {
var rec = this . seriesList . getSelectedRec ( ) ,
index = rec ? this . seriesList . store . indexOf ( rec ) : - 1 ;
this . btnUp . setDisabled ( index < 1 ) ;
this . btnDown . setDisabled ( index < 0 || index == this . seriesList . store . length - 1 ) ;
} ,
onAddSeries : function ( ) {
2020-11-19 17:05:50 +00:00
var me = this ;
2020-07-10 16:11:55 +00:00
me . chartSettings . startEditData ( ) ;
2020-11-19 17:05:50 +00:00
var series = me . chartSettings . addSeries ( ) ,
isScatter = series . asc _IsScatter ( ) ;
2020-07-07 08:45:45 +00:00
var handlerDlg = function ( dlg , result ) {
if ( result == 'ok' ) {
2020-07-15 10:01:05 +00:00
me . updateRange ( ) ;
2020-07-08 07:41:18 +00:00
me . updateSeriesList ( me . chartSettings . getSeries ( ) , me . seriesList . store . length - 1 ) ;
2020-07-17 10:51:13 +00:00
me . updateCategoryList ( me . chartSettings . getCatValues ( ) ) ;
2020-07-08 07:41:18 +00:00
me . updateButtons ( ) ;
2020-07-10 16:11:55 +00:00
me . chartSettings . endEditData ( ) ;
me . _isEditRanges = false ;
2020-07-07 08:45:45 +00:00
}
} ;
2020-07-08 07:41:18 +00:00
this . changeDataRange ( 1 , { series : series , isScatter : isScatter } , handlerDlg ) ;
2020-07-07 12:07:15 +00:00
} ,
onDeleteSeries : function ( ) {
var rec = this . seriesList . getSelectedRec ( ) ;
if ( rec ) {
var order = rec . get ( 'order' ) ;
2020-07-10 16:11:55 +00:00
rec . get ( 'series' ) . asc _Remove ( ) ;
2020-07-15 10:01:05 +00:00
this . updateRange ( ) ;
2020-07-07 12:07:15 +00:00
this . updateSeriesList ( this . chartSettings . getSeries ( ) , order ) ;
2020-07-17 10:51:13 +00:00
this . updateCategoryList ( this . chartSettings . getCatValues ( ) ) ;
2020-07-15 10:01:05 +00:00
this . updateButtons ( ) ;
2020-07-07 12:07:15 +00:00
}
2020-07-07 08:45:45 +00:00
} ,
onEditSeries : function ( ) {
2020-07-07 12:07:15 +00:00
var rec = this . seriesList . getSelectedRec ( ) ;
if ( rec ) {
var series = rec . get ( 'series' ) ,
2020-07-08 07:41:18 +00:00
isScatter = series . asc _IsScatter ( ) ,
me = this ;
2020-07-07 12:07:15 +00:00
var handlerDlg = function ( dlg , result ) {
if ( result == 'ok' ) {
2020-07-08 09:51:57 +00:00
rec . set ( 'value' , series . asc _getSeriesName ( ) ) ;
2020-07-15 10:01:05 +00:00
me . updateRange ( ) ;
2020-07-17 10:51:13 +00:00
me . updateCategoryList ( me . chartSettings . getCatValues ( ) ) ;
2020-07-15 10:01:05 +00:00
me . updateButtons ( ) ;
2020-07-10 16:11:55 +00:00
me . chartSettings . endEditData ( ) ;
me . _isEditRanges = false ;
2020-07-07 12:07:15 +00:00
}
} ;
2020-07-10 16:11:55 +00:00
me . chartSettings . startEditData ( ) ;
2020-07-08 07:41:18 +00:00
this . changeDataRange ( 1 , { series : series , isScatter : isScatter } , handlerDlg ) ;
2020-07-07 12:07:15 +00:00
}
2020-07-07 08:45:45 +00:00
} ,
onEditCategory : function ( ) {
2020-07-08 07:41:18 +00:00
var me = this ;
2020-07-07 08:45:45 +00:00
var handlerDlg = function ( dlg , result ) {
if ( result == 'ok' ) {
2020-07-08 09:51:57 +00:00
me . updateCategoryList ( me . chartSettings . getCatValues ( ) ) ;
2020-07-15 10:01:05 +00:00
me . updateRange ( ) ;
me . updateButtons ( ) ;
2020-07-10 16:11:55 +00:00
me . chartSettings . endEditData ( ) ;
me . _isEditRanges = false ;
2020-07-07 08:45:45 +00:00
}
} ;
2020-07-10 16:11:55 +00:00
me . chartSettings . startEditData ( ) ;
this . changeDataRange ( 0 , { category : this . chartSettings . getCatFormula ( ) , values : this . chartSettings . getCatValues ( ) } , handlerDlg ) ;
2020-07-07 08:45:45 +00:00
} ,
2020-07-08 07:41:18 +00:00
changeDataRange : function ( type , props , handlerDlg ) {
2020-07-07 08:45:45 +00:00
var me = this ;
var win = new SSE . Views . ChartDataRangeDialog ( {
type : type , //series
2020-07-07 12:07:15 +00:00
isScatter : ! ! props . isScatter ,
2020-07-07 08:45:45 +00:00
handler : handlerDlg
} ) . on ( 'close' , function ( ) {
2020-07-10 16:11:55 +00:00
me . _isEditRanges && me . chartSettings . cancelEditData ( ) ;
me . _isEditRanges = false ;
2020-07-07 08:45:45 +00:00
me . show ( ) ;
} ) ;
2020-07-10 16:11:55 +00:00
me . _isEditRanges = true ;
2020-07-07 08:45:45 +00:00
var xy = me . $window . offset ( ) ;
me . hide ( ) ;
win . show ( xy . left + 160 , xy . top + 125 ) ;
win . setSettings ( {
2020-07-07 12:07:15 +00:00
api : me . api ,
2020-07-08 07:41:18 +00:00
props : props ,
chartSettings : me . chartSettings
2020-07-07 08:45:45 +00:00
} ) ;
} ,
2020-07-07 12:07:15 +00:00
onMoveClick : function ( up ) {
var store = this . seriesList . store ,
length = store . length ,
rec = this . seriesList . getSelectedRec ( ) ;
if ( rec ) {
var index = store . indexOf ( rec ) ,
order = rec . get ( 'order' ) ,
newindex = up ? Math . max ( 0 , index - 1 ) : Math . min ( length - 1 , index + 1 ) ,
newrec = store . at ( newindex ) ,
neworder = newrec . get ( 'order' ) ;
store . add ( store . remove ( rec ) , { at : newindex } ) ;
rec . set ( 'order' , neworder ) ;
newrec . set ( 'order' , order ) ;
2020-07-10 16:11:55 +00:00
up ? rec . get ( 'series' ) . asc _MoveUp ( ) : rec . get ( 'series' ) . asc _MoveDown ( ) ;
2020-07-07 12:07:15 +00:00
this . seriesList . selectRecord ( rec ) ;
this . seriesList . scrollToRecord ( rec ) ;
2020-07-15 10:01:05 +00:00
this . updateRange ( ) ;
2020-07-17 10:51:13 +00:00
this . updateCategoryList ( this . chartSettings . getCatValues ( ) ) ;
2020-07-15 10:01:05 +00:00
this . updateButtons ( ) ;
2020-07-07 12:07:15 +00:00
}
} ,
updateSeriesList : function ( series , index ) {
2020-07-08 07:41:18 +00:00
this . btnEditCategory . setDisabled ( series && series . length > 0 ? series [ 0 ] . asc _IsScatter ( ) : false ) ;
2020-07-07 12:07:15 +00:00
var arr = [ ] ;
var store = this . seriesList . store ;
for ( var i = 0 , len = series . length ; i < len ; i ++ )
{
var item = series [ i ] ,
rec = new Common . UI . DataViewModel ( ) ;
rec . set ( {
2020-07-08 09:51:57 +00:00
value : item . asc _getSeriesName ( ) ,
2020-07-07 12:07:15 +00:00
index : item . asc _getIdx ( ) ,
order : item . asc _getOrder ( ) ,
series : item
} ) ;
arr . push ( rec ) ;
}
store . reset ( arr ) ;
( len > 0 ) && this . seriesList . selectByIndex ( Math . min ( index || 0 , store . length - 1 ) ) ;
} ,
2020-07-08 07:41:18 +00:00
updateCategoryList : function ( categories ) {
var arr = [ ] ;
var store = this . categoryList . store ;
for ( var i = 0 , len = categories . length ; i < len ; i ++ )
{
var item = categories [ i ] ,
rec = new Common . UI . DataViewModel ( ) ;
rec . set ( {
value : item
} ) ;
arr . push ( rec ) ;
}
store . reset ( arr ) ;
( len > 0 ) && this . categoryList . selectByIndex ( 0 ) ;
} ,
2020-07-08 09:51:57 +00:00
onSwitch : function ( ) {
2020-11-24 09:07:57 +00:00
var res = this . chartSettings . switchRowCol ( ) ;
if ( res === Asc . c _oAscError . ID . MaxDataSeriesError )
Common . UI . warning ( { msg : this . errorMaxRows , maxwidth : 600 } ) ;
else {
this . updateSeriesList ( this . chartSettings . getSeries ( ) , 0 ) ;
this . updateCategoryList ( this . chartSettings . getCatValues ( ) ) ;
this . updateRange ( ) ;
this . updateButtons ( ) ;
}
2020-07-08 09:51:57 +00:00
} ,
2020-07-07 08:45:45 +00:00
textTitle : 'Chart Data' ,
2020-07-08 12:04:19 +00:00
textInvalidRange : 'Invalid cells range' ,
2020-07-07 08:45:45 +00:00
textSelectData : 'Select data' ,
2020-07-08 12:04:19 +00:00
errorMaxRows : 'The maximum number of data series per chart is 255.' ,
2020-07-07 08:45:45 +00:00
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.' ,
2020-07-08 12:04:19 +00:00
errorMaxPoints : 'The maximum number of points in series per chart is 4096.' ,
2020-07-07 08:45:45 +00:00
textSeries : 'Legend Entries (Series)' ,
textAdd : 'Add' ,
textEdit : 'Edit' ,
textDelete : 'Remove' ,
textSwitch : 'Switch Row/Column' ,
textCategory : 'Horizontal (Category) Axis Labels' ,
textUp : 'Up' ,
textDown : 'Down' ,
2020-07-15 10:48:58 +00:00
textData : 'Chart data range' ,
2020-07-15 10:01:05 +00:00
errorInFormula : "There's an error in formula you entered." ,
errorInvalidReference : 'The reference is not valid. Reference must be to an open worksheet.' ,
errorNoSingleRowCol : 'The reference is not valid. References for titles, values, sizes, or data labels must be a single cell, row, or column.' ,
errorNoValues : 'To create a chart, the series must contain at least one value.'
} , SSE . Views . ChartDataDialog || { } ) )
2020-07-07 08:45:45 +00:00
} ) ;