diff --git a/js/app/views/VisuUI.js b/js/app/views/VisuUI.js index b467896..e3af96b 100644 --- a/js/app/views/VisuUI.js +++ b/js/app/views/VisuUI.js @@ -14,9 +14,7 @@ Ext.define('amdaUI.VisuUI', { constructor: function(config) { this.init(config); - this.callParent(arguments); - - //if (this.object) this.loadObject(); + this.callParent(arguments); }, setObject : function (name,id) @@ -24,36 +22,31 @@ Ext.define('amdaUI.VisuUI', { // set object this.object.set('id',id); this.object.set('name',name); + // load object into view this.loadObject(); }, - - /** - * set params description into this.object - */ - setParamInfo : function(parameters) - { - var params = []; - Ext.Array.each(parameters, function(item, index) { - params[index] = item; - }, this); - - this.object.set('parameters', params); - }, - + updateCount : function() { -// this.object.set('nbIntervals',this.TTGrid.getStore().getTotalCount()); -// this.formPanel.getForm().findField('nbIntervals').setValue(this.object.get('nbIntervals')); + + this.formPanel.getForm().findField('nbIntervals').setValue(this.object.get('nbIntervals')); }, + reset : function() { + + this.parCombo.reset(); + this.parCombo1.reset(); + this.resetChart(); + + }, /** * load object catalog into this view */ loadObject : function() { - // load object into form - + + var me = this; var onAfterInit = function(result, e) @@ -84,18 +77,18 @@ Ext.define('amdaUI.VisuUI', { i++; }); + + if (me.chartStore) { + me.parList.removeAll(); + me.reset(); + me.chartStore = null; + } - var newStore = Ext.create('Ext.data.Store', { - fields : [ 'text', 'id'], - data : fields - }); - - me.parCombo.bindStore(newStore); - me.parCombo1.bindStore(newStore); + me.parList.add(fields); me.chartStore = Ext.create('Ext.data.Store', { - fields : fields, - autoDestroy: false, + fields : fields, + // autoDestroy: false, // pageSize : 200, // buffered : true, // purgePageCount: 0, @@ -120,29 +113,24 @@ Ext.define('amdaUI.VisuUI', { scope : me, load: function(store,records) { //TODO enable plot button + me.object.set('nbIntervals',me.chartStore.getTotalCount()); + + // load object into form + var formPanel = me.items.items[0].items.items[0]; + formPanel.getForm().loadRecord(me.object); } } }); me.chartStore.load(); - + } - - AmdaAction.initForChartFromTT(this.object.get('id'), 'catalog', onAfterInit); + + if (this.object.get('id')) + AmdaAction.initForChartFromTT(this.object.get('id'), 'catalog', onAfterInit); }, - /** - * updated object catalog into this view - */ - updateObject : function() - { - // load object into form - //this.formPanel.getForm().loadRecord(this.object); - - var me = this; - - }, /** * Check if changes were made before closing window @@ -152,19 +140,36 @@ Ext.define('amdaUI.VisuUI', { { return false; - }, + }, + + resetChart : function () { + + this.chartConfig.series[0].xField = ''; + this.chartConfig.series[0].yField = ''; + + this.chartConfig.axes[0].title = 'x axe'; + this.chartConfig.axes[1].title = 'y axe'; + + var chart = Ext.create('Ext.chart.Chart', this.chartConfig); + this.replaceChart(chart); + + }, plotChart : function () { - this.chartConfig.store=this.chartStore; + this.chartConfig.store=this.chartStore; + var chart = Ext.create('Ext.chart.Chart', this.chartConfig); + this.replaceChart(chart); + + }, + + replaceChart: function(chart) { - var chart = Ext.create('Ext.chart.Chart', this.chartConfig); - // chart.bindStore(this.chartStore); var chartPanel = this.items.items[0].items.items[1]; var oldChart = chartPanel.down('chart'); oldIndex = chartPanel.items.indexOf(oldChart); chartPanel.remove(oldChart); - chartPanel.insert(oldIndex, chart); + chartPanel.insert(oldIndex, chart); }, init : function (config) @@ -204,10 +209,10 @@ Ext.define('amdaUI.VisuUI', { xField: '', yField: '', label: { -// display: 'under', -// render: function(value) { -// return parseFloat(value); -// } +// display: 'under', +// renderer: function(value, label, storeItem, item, i, display, animate, index) { +// return storeItem.param3; +// } } }] } @@ -220,28 +225,29 @@ Ext.define('amdaUI.VisuUI', { ] }); - var parList = Ext.create('Ext.data.Store', { - fields: [], - autoload : false - }); - + this.parList = Ext.create('Ext.data.Store', { + fields : [ 'text', 'id'] + }); + var chart = Ext.create('Ext.chart.Chart', this.chartConfig); this.parCombo = Ext.create('Ext.form.ComboBox', { emptyText: 'select parameter', editable: false, - store: parList, + store: this.parList, queryMode: 'local', displayField: 'text', valueField: 'id', listeners : { scope : this, change : function(combo, newValue, oldValue) { - - this.chartConfig.axes[0].fields = [newValue]; - var rec = combo.findRecordByValue(newValue); - this.chartConfig.axes[0].title = rec.get('text'); - this.chartConfig.series[0].xField = newValue; + if (newValue) { + this.chartConfig.axes[0].fields = [newValue]; + var rec = combo.findRecordByValue(newValue); + + this.chartConfig.axes[0].title = rec.get('text'); + this.chartConfig.series[0].xField = newValue; + } } } }); @@ -249,18 +255,19 @@ Ext.define('amdaUI.VisuUI', { this.parCombo1 = Ext.create('Ext.form.ComboBox', { emptyText: 'select parameter', editable: false, - store: parList, + store: this.parList, queryMode: 'local', displayField: 'text', valueField: 'id', listeners : { scope : this, change : function(combo, newValue, oldValue) { - - this.chartConfig.axes[1].fields = [newValue]; - var rec = combo.findRecordByValue(newValue); - this.chartConfig.axes[1].title = rec.get('text'); - this.chartConfig.series[0].yField = newValue; + if (newValue) { + this.chartConfig.axes[1].fields = [newValue]; + var rec = combo.findRecordByValue(newValue); + this.chartConfig.axes[1].title = rec.get('text'); + this.chartConfig.series[0].yField = newValue; + } } } }); @@ -293,12 +300,26 @@ Ext.define('amdaUI.VisuUI', { flex : 1, bodyStyle: {background : '#dfe8f6'}, items: [ - { - xtype : 'fieldset', - title : 'X axis', - items : [ - this.parCombo, - { + { + xtype : 'fieldset', + items : [ + { + xtype: 'fieldcontainer', + layout: 'hbox', + items: [ + { xtype:'textfield', fieldLabel: 'Catalog Name', name: 'name', readOnly: true}, + { xtype: 'splitter' }, + { xtype:'textfield', fieldLabel: 'Intervals', name: 'nbIntervals', readOnly: true} + ] + } + ] + }, + { + xtype : 'fieldset', + title : 'X axis', + items : [ + this.parCombo, + { xtype : 'fieldcontainer', layout: 'hbox', items: [{ @@ -309,44 +330,44 @@ Ext.define('amdaUI.VisuUI', { }, { xtype: 'textfield', flex: 1 - }] + }] + }, + { xtype : 'checkbox' }, + { xtype : 'checkbox' } + ] + }, + { + xtype : 'fieldset', + title : 'Y axis', + items : [ + this.parCombo1, + { + xtype : 'fieldcontainer', + layout: 'hbox', + items: [{ + xtype: 'textfield', + flex: 1 + }, { + xtype: 'splitter' + }, { + xtype: 'textfield', + flex: 1 + } + ] }, { xtype : 'checkbox' }, { xtype : 'checkbox' } - ] - }, - { - xtype : 'fieldset', - title : 'Y axis', - items : [ - this.parCombo1, - { - xtype : 'fieldcontainer', - layout: 'hbox', - items: [{ - xtype: 'textfield', - flex: 1 - }, { - xtype: 'splitter' - }, { - xtype: 'textfield', - flex: 1 - } ] }, - { xtype : 'checkbox' }, - { xtype : 'checkbox' } - ] - }, - { - xtype : 'fieldset', - title : 'Plotting Options', - items : [ - plotTypeCombo - ] - } - ], - fbar:[ + { + xtype : 'fieldset', + title : 'Plotting Options', + items : [ + plotTypeCombo + ] + } + ], + fbar:[ { type: 'button', text: 'Plot', @@ -358,31 +379,31 @@ Ext.define('amdaUI.VisuUI', { text: 'Reset' } - ] - }, { - xtype: 'form', - // padding: '3', - flex: 2, - items : [ - chart + ] + }, { + xtype: 'form', + // padding: '3', + flex: 2, + items : [ + chart ], - fbar:[ - { - type: 'button', - text: 'Save Chart', - scope: this, - handler: function() { - var chartPanel = this.items.items[0].items.items[1]; - var chart = chartPanel.down('chart'); - chart.save({ - type: 'image/png' - }); - } - - } - ] - } - ] + fbar:[ + { + type: 'button', + text: 'Save Chart', + scope: this, + handler: function() { + var chartPanel = this.items.items[0].items.items[1]; + var chart = chartPanel.down('chart'); + chart.save({ + type: 'image/png' + }); + } + + } + ] + } + ] }); -- libgit2 0.21.2