Commit 95dbfcfdfd607ddf7fda6eeaca489c9302666a8a

Authored by elena
1 parent b36dff33

save chart

Showing 1 changed file with 38 additions and 23 deletions   Show diff stats
js/app/views/VisuUI.js
... ... @@ -73,6 +73,7 @@ Ext.define('amdaUI.VisuUI', {
73 73  
74 74 Ext.Array.each(result.parameters, function(obj)
75 75 {
  76 +
76 77 index = 'param'+(i+2).toString();
77 78 fields[i] = Ext.create('Ext.data.Field', { name : index, id: index, text : obj.name,
78 79 convert: function(value, record) {
... ... @@ -138,11 +139,8 @@ Ext.define('amdaUI.VisuUI', {
138 139 {
139 140 // load object into form
140 141 //this.formPanel.getForm().loadRecord(this.object);
141   -
142   -
143   - var me = this;
144   -
145   -
  142 +
  143 + var me = this;
146 144  
147 145 },
148 146  
... ... @@ -158,18 +156,6 @@ Ext.define('amdaUI.VisuUI', {
158 156  
159 157 plotChart : function () {
160 158  
161   - var x = this.parCombo.getValue( );
162   - var y = this.parCombo1.getValue( );
163   - var xRec = this.parCombo.findRecordByValue(x);
164   - var yRec = this.parCombo.findRecordByValue(y);
165   -
166   - this.chartConfig.axes[0].fields = [x];
167   - this.chartConfig.axes[0].title = xRec.get('text');
168   - this.chartConfig.axes[1].fields = [y];
169   - this.chartConfig.axes[1].title = yRec.get('text');
170   - this.chartConfig.series[0].xField = x;
171   - this.chartConfig.series[0].yField = y;
172   -
173 159 this.chartConfig.store=this.chartStore;
174 160  
175 161 var chart = Ext.create('Ext.chart.Chart', this.chartConfig);
... ... @@ -240,7 +226,17 @@ Ext.define('amdaUI.VisuUI', {
240 226 store: parList,
241 227 queryMode: 'local',
242 228 displayField: 'text',
243   - valueField: 'id'
  229 + valueField: 'id',
  230 + listeners : {
  231 + scope : this,
  232 + change : function(combo, newValue, oldValue) {
  233 +
  234 + this.chartConfig.axes[0].fields = [newValue];
  235 + var rec = combo.findRecordByValue(newValue);
  236 + this.chartConfig.axes[0].title = rec.get('text');
  237 + this.chartConfig.series[0].xField = newValue;
  238 + }
  239 + }
244 240 });
245 241  
246 242 this.parCombo1 = Ext.create('Ext.form.ComboBox', {
... ... @@ -249,7 +245,17 @@ Ext.define('amdaUI.VisuUI', {
249 245 store: parList,
250 246 queryMode: 'local',
251 247 displayField: 'text',
252   - valueField: 'id'
  248 + valueField: 'id',
  249 + listeners : {
  250 + scope : this,
  251 + change : function(combo, newValue, oldValue) {
  252 +
  253 + this.chartConfig.axes[1].fields = [newValue];
  254 + var rec = combo.findRecordByValue(newValue);
  255 + this.chartConfig.axes[1].title = rec.get('text');
  256 + this.chartConfig.series[0].yField = newValue;
  257 + }
  258 + }
253 259 });
254 260  
255 261  
... ... @@ -336,10 +342,19 @@ Ext.define('amdaUI.VisuUI', {
336 342 chart
337 343 ],
338 344 fbar:[
339   - {
340   - type: 'button',
341   - text: 'Save'
342   - }
  345 + {
  346 + type: 'button',
  347 + text: 'Save Chart',
  348 + scope: this,
  349 + handler: function() {
  350 + var chartPanel = this.items.items[0].items.items[1];
  351 + var chart = chartPanel.down('chart');
  352 + chart.save({
  353 + type: 'image/png'
  354 + });
  355 + }
  356 +
  357 + }
343 358 ]
344 359 }
345 360 ]
... ...