Commit fded4fcb1d0c8de324e882ea1019272862272458

Authored by elena
1 parent d0a99d97

reload corrected

Showing 1 changed file with 154 additions and 133 deletions   Show diff stats
js/app/views/VisuUI.js
... ... @@ -14,9 +14,7 @@ Ext.define('amdaUI.VisuUI', {
14 14 constructor: function(config)
15 15 {
16 16 this.init(config);
17   - this.callParent(arguments);
18   -
19   - //if (this.object) this.loadObject();
  17 + this.callParent(arguments);
20 18 },
21 19  
22 20 setObject : function (name,id)
... ... @@ -24,36 +22,31 @@ Ext.define('amdaUI.VisuUI', {
24 22 // set object
25 23 this.object.set('id',id);
26 24 this.object.set('name',name);
  25 +
27 26 // load object into view
28 27 this.loadObject();
29 28 },
30   -
31   - /**
32   - * set params description into this.object
33   - */
34   - setParamInfo : function(parameters)
35   - {
36   - var params = [];
37   - Ext.Array.each(parameters, function(item, index) {
38   - params[index] = item;
39   - }, this);
40   -
41   - this.object.set('parameters', params);
42   - },
43   -
  29 +
44 30 updateCount : function()
45 31 {
46   -// this.object.set('nbIntervals',this.TTGrid.getStore().getTotalCount());
47   -// this.formPanel.getForm().findField('nbIntervals').setValue(this.object.get('nbIntervals'));
  32 +
  33 + this.formPanel.getForm().findField('nbIntervals').setValue(this.object.get('nbIntervals'));
48 34 },
49 35  
  36 + reset : function() {
  37 +
  38 + this.parCombo.reset();
  39 + this.parCombo1.reset();
  40 + this.resetChart();
  41 +
  42 + },
50 43 /**
51 44 * load object catalog into this view
52 45 */
53 46 loadObject : function()
54 47 {
55   - // load object into form
56   -
  48 +
  49 +
57 50 var me = this;
58 51  
59 52 var onAfterInit = function(result, e)
... ... @@ -84,18 +77,18 @@ Ext.define('amdaUI.VisuUI', {
84 77  
85 78 i++;
86 79 });
  80 +
  81 + if (me.chartStore) {
  82 + me.parList.removeAll();
  83 + me.reset();
  84 + me.chartStore = null;
  85 + }
87 86  
88   - var newStore = Ext.create('Ext.data.Store', {
89   - fields : [ 'text', 'id'],
90   - data : fields
91   - });
92   -
93   - me.parCombo.bindStore(newStore);
94   - me.parCombo1.bindStore(newStore);
  87 + me.parList.add(fields);
95 88  
96 89 me.chartStore = Ext.create('Ext.data.Store', {
97   - fields : fields,
98   - autoDestroy: false,
  90 + fields : fields,
  91 + // autoDestroy: false,
99 92 // pageSize : 200,
100 93 // buffered : true,
101 94 // purgePageCount: 0,
... ... @@ -120,29 +113,24 @@ Ext.define('amdaUI.VisuUI', {
120 113 scope : me,
121 114 load: function(store,records) {
122 115 //TODO enable plot button
  116 + me.object.set('nbIntervals',me.chartStore.getTotalCount());
  117 +
  118 + // load object into form
  119 + var formPanel = me.items.items[0].items.items[0];
  120 + formPanel.getForm().loadRecord(me.object);
123 121 }
124 122 }
125 123 });
126 124  
127 125 me.chartStore.load();
128   -
  126 +
129 127 }
130   -
131   - AmdaAction.initForChartFromTT(this.object.get('id'), 'catalog', onAfterInit);
  128 +
  129 + if (this.object.get('id'))
  130 + AmdaAction.initForChartFromTT(this.object.get('id'), 'catalog', onAfterInit);
132 131  
133 132 },
134 133  
135   - /**
136   - * updated object catalog into this view
137   - */
138   - updateObject : function()
139   - {
140   - // load object into form
141   - //this.formPanel.getForm().loadRecord(this.object);
142   -
143   - var me = this;
144   -
145   - },
146 134  
147 135 /**
148 136 * Check if changes were made before closing window
... ... @@ -152,19 +140,36 @@ Ext.define('amdaUI.VisuUI', {
152 140 {
153 141  
154 142 return false;
155   - },
  143 + },
  144 +
  145 + resetChart : function () {
  146 +
  147 + this.chartConfig.series[0].xField = '';
  148 + this.chartConfig.series[0].yField = '';
  149 +
  150 + this.chartConfig.axes[0].title = 'x axe';
  151 + this.chartConfig.axes[1].title = 'y axe';
  152 +
  153 + var chart = Ext.create('Ext.chart.Chart', this.chartConfig);
  154 + this.replaceChart(chart);
  155 +
  156 + },
156 157  
157 158 plotChart : function () {
158 159  
159   - this.chartConfig.store=this.chartStore;
  160 + this.chartConfig.store=this.chartStore;
  161 + var chart = Ext.create('Ext.chart.Chart', this.chartConfig);
  162 + this.replaceChart(chart);
  163 +
  164 + },
  165 +
  166 + replaceChart: function(chart) {
160 167  
161   - var chart = Ext.create('Ext.chart.Chart', this.chartConfig);
162   - // chart.bindStore(this.chartStore);
163 168 var chartPanel = this.items.items[0].items.items[1];
164 169 var oldChart = chartPanel.down('chart');
165 170 oldIndex = chartPanel.items.indexOf(oldChart);
166 171 chartPanel.remove(oldChart);
167   - chartPanel.insert(oldIndex, chart);
  172 + chartPanel.insert(oldIndex, chart);
168 173 },
169 174  
170 175 init : function (config)
... ... @@ -204,10 +209,10 @@ Ext.define('amdaUI.VisuUI', {
204 209 xField: '',
205 210 yField: '',
206 211 label: {
207   -// display: 'under',
208   -// render: function(value) {
209   -// return parseFloat(value);
210   -// }
  212 +// display: 'under',
  213 +// renderer: function(value, label, storeItem, item, i, display, animate, index) {
  214 +// return storeItem.param3;
  215 +// }
211 216 }
212 217 }]
213 218 }
... ... @@ -220,28 +225,29 @@ Ext.define('amdaUI.VisuUI', {
220 225 ]
221 226 });
222 227  
223   - var parList = Ext.create('Ext.data.Store', {
224   - fields: [],
225   - autoload : false
226   - });
227   -
  228 + this.parList = Ext.create('Ext.data.Store', {
  229 + fields : [ 'text', 'id']
  230 + });
  231 +
228 232 var chart = Ext.create('Ext.chart.Chart', this.chartConfig);
229 233  
230 234 this.parCombo = Ext.create('Ext.form.ComboBox', {
231 235 emptyText: 'select parameter',
232 236 editable: false,
233   - store: parList,
  237 + store: this.parList,
234 238 queryMode: 'local',
235 239 displayField: 'text',
236 240 valueField: 'id',
237 241 listeners : {
238 242 scope : this,
239 243 change : function(combo, newValue, oldValue) {
240   -
241   - this.chartConfig.axes[0].fields = [newValue];
242   - var rec = combo.findRecordByValue(newValue);
243   - this.chartConfig.axes[0].title = rec.get('text');
244   - this.chartConfig.series[0].xField = newValue;
  244 + if (newValue) {
  245 + this.chartConfig.axes[0].fields = [newValue];
  246 + var rec = combo.findRecordByValue(newValue);
  247 +
  248 + this.chartConfig.axes[0].title = rec.get('text');
  249 + this.chartConfig.series[0].xField = newValue;
  250 + }
245 251 }
246 252 }
247 253 });
... ... @@ -249,18 +255,19 @@ Ext.define('amdaUI.VisuUI', {
249 255 this.parCombo1 = Ext.create('Ext.form.ComboBox', {
250 256 emptyText: 'select parameter',
251 257 editable: false,
252   - store: parList,
  258 + store: this.parList,
253 259 queryMode: 'local',
254 260 displayField: 'text',
255 261 valueField: 'id',
256 262 listeners : {
257 263 scope : this,
258 264 change : function(combo, newValue, oldValue) {
259   -
260   - this.chartConfig.axes[1].fields = [newValue];
261   - var rec = combo.findRecordByValue(newValue);
262   - this.chartConfig.axes[1].title = rec.get('text');
263   - this.chartConfig.series[0].yField = newValue;
  265 + if (newValue) {
  266 + this.chartConfig.axes[1].fields = [newValue];
  267 + var rec = combo.findRecordByValue(newValue);
  268 + this.chartConfig.axes[1].title = rec.get('text');
  269 + this.chartConfig.series[0].yField = newValue;
  270 + }
264 271 }
265 272 }
266 273 });
... ... @@ -293,12 +300,26 @@ Ext.define('amdaUI.VisuUI', {
293 300 flex : 1,
294 301 bodyStyle: {background : '#dfe8f6'},
295 302 items: [
296   - {
297   - xtype : 'fieldset',
298   - title : 'X axis',
299   - items : [
300   - this.parCombo,
301   - {
  303 + {
  304 + xtype : 'fieldset',
  305 + items : [
  306 + {
  307 + xtype: 'fieldcontainer',
  308 + layout: 'hbox',
  309 + items: [
  310 + { xtype:'textfield', fieldLabel: 'Catalog Name', name: 'name', readOnly: true},
  311 + { xtype: 'splitter' },
  312 + { xtype:'textfield', fieldLabel: 'Intervals', name: 'nbIntervals', readOnly: true}
  313 + ]
  314 + }
  315 + ]
  316 + },
  317 + {
  318 + xtype : 'fieldset',
  319 + title : 'X axis',
  320 + items : [
  321 + this.parCombo,
  322 + {
302 323 xtype : 'fieldcontainer',
303 324 layout: 'hbox',
304 325 items: [{
... ... @@ -309,44 +330,44 @@ Ext.define('amdaUI.VisuUI', {
309 330 }, {
310 331 xtype: 'textfield',
311 332 flex: 1
312   - }]
  333 + }]
  334 + },
  335 + { xtype : 'checkbox' },
  336 + { xtype : 'checkbox' }
  337 + ]
  338 + },
  339 + {
  340 + xtype : 'fieldset',
  341 + title : 'Y axis',
  342 + items : [
  343 + this.parCombo1,
  344 + {
  345 + xtype : 'fieldcontainer',
  346 + layout: 'hbox',
  347 + items: [{
  348 + xtype: 'textfield',
  349 + flex: 1
  350 + }, {
  351 + xtype: 'splitter'
  352 + }, {
  353 + xtype: 'textfield',
  354 + flex: 1
  355 + }
  356 + ]
313 357 },
314 358 { xtype : 'checkbox' },
315 359 { xtype : 'checkbox' }
316   - ]
317   - },
318   - {
319   - xtype : 'fieldset',
320   - title : 'Y axis',
321   - items : [
322   - this.parCombo1,
323   - {
324   - xtype : 'fieldcontainer',
325   - layout: 'hbox',
326   - items: [{
327   - xtype: 'textfield',
328   - flex: 1
329   - }, {
330   - xtype: 'splitter'
331   - }, {
332   - xtype: 'textfield',
333   - flex: 1
334   - }
335 360 ]
336 361 },
337   - { xtype : 'checkbox' },
338   - { xtype : 'checkbox' }
339   - ]
340   - },
341   - {
342   - xtype : 'fieldset',
343   - title : 'Plotting Options',
344   - items : [
345   - plotTypeCombo
346   - ]
347   - }
348   - ],
349   - fbar:[
  362 + {
  363 + xtype : 'fieldset',
  364 + title : 'Plotting Options',
  365 + items : [
  366 + plotTypeCombo
  367 + ]
  368 + }
  369 + ],
  370 + fbar:[
350 371 {
351 372 type: 'button',
352 373 text: 'Plot',
... ... @@ -358,31 +379,31 @@ Ext.define('amdaUI.VisuUI', {
358 379 text: 'Reset'
359 380  
360 381 }
361   - ]
362   - }, {
363   - xtype: 'form',
364   - // padding: '3',
365   - flex: 2,
366   - items : [
367   - chart
  382 + ]
  383 + }, {
  384 + xtype: 'form',
  385 + // padding: '3',
  386 + flex: 2,
  387 + items : [
  388 + chart
368 389 ],
369   - fbar:[
370   - {
371   - type: 'button',
372   - text: 'Save Chart',
373   - scope: this,
374   - handler: function() {
375   - var chartPanel = this.items.items[0].items.items[1];
376   - var chart = chartPanel.down('chart');
377   - chart.save({
378   - type: 'image/png'
379   - });
380   - }
381   -
382   - }
383   - ]
384   - }
385   - ]
  390 + fbar:[
  391 + {
  392 + type: 'button',
  393 + text: 'Save Chart',
  394 + scope: this,
  395 + handler: function() {
  396 + var chartPanel = this.items.items[0].items.items[1];
  397 + var chart = chartPanel.down('chart');
  398 + chart.save({
  399 + type: 'image/png'
  400 + });
  401 + }
  402 +
  403 + }
  404 + ]
  405 + }
  406 + ]
386 407 });
387 408  
388 409  
... ...