Blame view

js/app/views/CatalogVisuScatter.js 7.19 KB
33705dc4   Benjamin Renard   Catalog visu rework
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
 * Project       AMDA-NG
 * Name          CatalogVisuScatter.js
 * @class 	   amdaUI.CatalogVisuScatter
 * @extends      Ext.container.Container
 * @brief	   Scatter Visualization Module UI definition (View)
 * @author 	  elena
 */

Ext.define('amdaUI.CatalogVisuScatter', {
	extend: 'Ext.form.Panel',
	alias: 'widget.panelCatalogVisuScatter',

	constructor: function(config) {
		this.init(config);
		this.callParent(arguments);
	},

b0720b91   Benjamin Renard   Finalize catalog ...
19
  getChartConfig: function(catalogStore) {
1a0151a5   Benjamin Renard   wip
20
21
22
23
24
    var plotTypeField = Ext.getCmp('visu-scatter-type');
    var plotType = plotTypeField.getValue();

    var plotColorField = Ext.getCmp('visu-scatter-color');
    plotColor = plotColorField.getValue();
903e5e09   Benjamin Renard   WIP
25
26
    var xAxisOpt = this.getAxisOptions('X');
    var yAxisOpt = this.getAxisOptions('Y');
33705dc4   Benjamin Renard   Catalog visu rework
27

b0720b91   Benjamin Renard   Finalize catalog ...
28
    if ((!xAxisOpt.paramId) || (xAxisOpt.paramId == '')) {
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
29
      //myDesktopApp.errorMsg('Missing parameter selection for X axis');
b0720b91   Benjamin Renard   Finalize catalog ...
30
31
32
33
      return null;
    }

    if ((!yAxisOpt.paramId) || (yAxisOpt.paramId == '')) {
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
34
      //myDesktopApp.errorMsg('Missing parameter selection for Y axis');
b0720b91   Benjamin Renard   Finalize catalog ...
35
36
      return null;
    }
3ccb373f   furkan   #6899 - Done
37
38
	var x=[];
	var y=[];
560766be   furkan   #6899- Last modif...
39
	var text=[];
3ccb373f   furkan   #6899 - Done
40
41
42
	catalogStore.each(function(item){
		x.push(item.get(xAxisOpt.paramId));
		y.push(item.get(yAxisOpt.paramId));
560766be   furkan   #6899- Last modif...
43
		text.push(''+item.get('start').toISOString()+'<br>'+item.get('stop').toISOString());
3ccb373f   furkan   #6899 - Done
44
	});
560766be   furkan   #6899- Last modif...
45
	
b0720b91   Benjamin Renard   Finalize catalog ...
46

3ccb373f   furkan   #6899 - Done
47
48
49
50
	var data =[{
	x: x,
	y: y,
	mode: (plotType=='line') ? 'lines+markers' : 'markers',
560766be   furkan   #6899- Last modif...
51
	text: text,
3ccb373f   furkan   #6899 - Done
52
53
54
	marker:{
		color:plotColor},
	type: 'scatter'}];
1a0151a5   Benjamin Renard   wip
55

3ccb373f   furkan   #6899 - Done
56
57
	var layout = {
		margin: {l: 50,r: 40, b: 40,t: 40,pad: 5},
13374f3f   Erdogan Furkan   #10584 - Done
58
59
60
61
62
63
64
65
		xaxis: {
			title: xAxisOpt.title, range: !xAxisOpt.range ? null : [xAxisOpt.range.min,xAxisOpt.range.max],
			type: xAxisOpt.logscale ? 'log' : null
		},
		yaxis: {
			title: yAxisOpt.title, range: !yAxisOpt.range ? null : [yAxisOpt.range.min,yAxisOpt.range.max],
			type: yAxisOpt.logscale ? 'log' : null
		},
560766be   furkan   #6899- Last modif...
66
67
68
		hovermode: "closest",
		hoverlabel :{ font:{size:10}}	
	};
3ccb373f   furkan   #6899 - Done
69
70
	var result =  {data:data,layout:layout}
    return result;
33705dc4   Benjamin Renard   Catalog visu rework
71
72
  },

33705dc4   Benjamin Renard   Catalog visu rework
73
  getAxisOptions: function(axisName) {
903e5e09   Benjamin Renard   WIP
74
    var opt = {
1a0151a5   Benjamin Renard   wip
75
      paramId: '',
903e5e09   Benjamin Renard   WIP
76
77
      title: axisName+' axis'
    };
33705dc4   Benjamin Renard   Catalog visu rework
78

903e5e09   Benjamin Renard   WIP
79
80
81
82
83
    var axisParamField = Ext.getCmp('visu-scatter-' + axisName + '-param');
    var paramFieldId = axisParamField.getValue();
    if (paramFieldId && (paramFieldId != "")) {
      var paramField = axisParamField.getStore().getById(axisParamField.getValue());
      if (paramField) {
b0720b91   Benjamin Renard   Finalize catalog ...
84
        opt.paramId = paramField.get('id');
738e0997   Benjamin Renard   Draw histogram
85
				opt.title = paramField.get('name');
903e5e09   Benjamin Renard   WIP
86
87
      }
    }
33705dc4   Benjamin Renard   Catalog visu rework
88
89

    var axisTitleField = Ext.getCmp('visu-scatter-'+axisName+'-title');
903e5e09   Benjamin Renard   WIP
90
91
92
93
94
    var axisTitle = axisTitleField.getValue();
    if (axisTitle && (axisTitle != "")) {
      opt.title = axisTitle;
    }

1a0151a5   Benjamin Renard   wip
95
96
97
98
99
100
101
102
103
104
105
106
    var axisScalingField = Ext.getCmp('visu-scatter-'+axisName+'-scaling');
    var axisScaling = axisScalingField.getValue();
    if (axisScaling == 'manual') {
      var axisRangeMinField = Ext.getCmp('visu-scatter-' + axisName + '-range-min');
      var axisRangeMin = axisRangeMinField.getValue();
      var axisRangeMaxField = Ext.getCmp('visu-scatter-' + axisName + '-range-max');
      var axisRangeMax = axisRangeMaxField.getValue();
      opt.range = {
        'min' : axisRangeMin,
        'max' : axisRangeMax
      };
    }
13374f3f   Erdogan Furkan   #10584 - Done
107
108
109

	opt.logscale = Ext.getCmp('visu-scatter-' + axisName + '-logbox').getValue();

903e5e09   Benjamin Renard   WIP
110
    return opt;
33705dc4   Benjamin Renard   Catalog visu rework
111
112
113
114
115
116
117
118
119
  },

	getAxisConfig: function(axisIndex, axisName, parametersStore) {
		var paramComboConfig = {
			xtype: 'combo',
			emptyText: 'select parameter',
			editable: false,
			store: parametersStore,
			queryMode: 'local',
b0720b91   Benjamin Renard   Finalize catalog ...
120
			displayField: 'name',
33705dc4   Benjamin Renard   Catalog visu rework
121
122
			valueField: 'id',
			axisIndex: axisIndex,
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
123
124
125
126
127
128
129
      		id: 'visu-scatter-' + axisName + '-param',
			listeners:{
				change:function(){
					this.visuUI.plotChart();
				},
				scope: this
			}
33705dc4   Benjamin Renard   Catalog visu rework
130
131
132
133
134
135
136
137
138
139
140
		};

		var comboRangeConfig = {
			xtype : 'combo',
			name:'scaling',
			valueField: 'scaling',
			queryMode:'local',
			store:['auto','manual'],
			forceSelection:true,
			value: 'auto',
			width: 80,
1a0151a5   Benjamin Renard   wip
141
      id: 'visu-scatter-' + axisName + '-scaling',
33705dc4   Benjamin Renard   Catalog visu rework
142
143
144
145
146
147
148
149
150
151
152
153
154
155
			listeners : {
				scope : this,
				change : function(combo, newValue, oldValue) {
					var minValue = combo.next().next();
					var maxValue  = minValue.next().next();
					var disabled = newValue == "auto";
					minValue.reset();
					maxValue.reset();
					minValue.setDisabled(disabled);
					maxValue.setDisabled(disabled);
				}
			}
		};

13374f3f   Erdogan Furkan   #10584 - Done
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
		var logbox={
				xtype: 'fieldcontainer',
				fieldLabel: 'Log Scale',
				defaultType: 'checkboxfield',
				items: [
					{
						name      : 'logscale',
						inputValue: false,
						id        : 'visu-scatter-' + axisName + '-logbox',
						listeners:{
						change:function(){
							this.visuUI.plotChart();
						},
						scope: this
						}
					}
				],
		  };

33705dc4   Benjamin Renard   Catalog visu rework
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
		var axisRangeConfig = {
			xtype : 'fieldcontainer',
			layout: 'hbox',
			items: [
				{
					xtype:'fieldset',
					title: axisName + ' Range',
					border: false,
					layout: 'hbox',
					items: [
						comboRangeConfig,
						{
							xtype: 'splitter'
						},
						{
							xtype: 'numberfield',
							hideTrigger: true,
							width: 50,
1a0151a5   Benjamin Renard   wip
193
							disabled: true,
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
194
195
196
197
198
199
200
              				id: 'visu-scatter-' + axisName + '-range-min',
							listeners:{
								change:function(){
									this.visuUI.plotChart();
								},
								scope: this
							}
33705dc4   Benjamin Renard   Catalog visu rework
201
202
203
204
205
206
207
208
						},
						{
							xtype: 'splitter'
						},
						{
							xtype: 'numberfield',
							hideTrigger: true,
							width: 50,
1a0151a5   Benjamin Renard   wip
209
							disabled: true,
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
210
211
212
213
214
215
216
             				id: 'visu-scatter-' + axisName + '-range-max',
							listeners:{
								change:function(){
									this.visuUI.plotChart();
								},
								scope: this
							}
13374f3f   Erdogan Furkan   #10584 - Done
217
						},
33705dc4   Benjamin Renard   Catalog visu rework
218
					]
13374f3f   Erdogan Furkan   #10584 - Done
219
				},
33705dc4   Benjamin Renard   Catalog visu rework
220
221
222
223
224
225
226
227
228
			]
		};

		return {
			xtype : 'fieldset',
			title : axisName + ' axis',
			items : [
				paramComboConfig,
				axisRangeConfig,
13374f3f   Erdogan Furkan   #10584 - Done
229
				logbox,
33705dc4   Benjamin Renard   Catalog visu rework
230
231
232
				{
					xtype: 'textfield',
					fieldLabel: axisName + ' title',
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
233
234
235
236
237
238
          			id: 'visu-scatter-' + axisName + '-title',
					listeners:{
						change:function(){
							this.visuUI.plotChart();
						},
						scope: this
13374f3f   Erdogan Furkan   #10584 - Done
239
					},
33705dc4   Benjamin Renard   Catalog visu rework
240
241
242
243
244
245
246
247
248
249
250
251
252
253
				}
			]
		};
	},

	getPlottingOptionConfig: function() {
		var plotTypeComboConfig = {
			xtype: 'combo',
			emptyText: 'select plot type',
			editable: false,
			store: ['scatter', 'line'],
			queryMode: 'local',
			valueField: 'type',
			value: 'scatter',
13374f3f   Erdogan Furkan   #10584 - Done
254
      		id: 'visu-scatter-type',
33705dc4   Benjamin Renard   Catalog visu rework
255
256
257
258
			listeners : {
				scope : this,
				change : function(combo, newValue, oldValue) {
					//this.chartConfig.series[0].type = newValue;
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
259
					this.visuUI.plotChart();
33705dc4   Benjamin Renard   Catalog visu rework
260
				}
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
261
			},scope: this
33705dc4   Benjamin Renard   Catalog visu rework
262
263
264
265
266
267
268
269
270
271
		};

		var plotThemeComboConfig = {
			xtype: 'combo',
			emptyText: 'select theme',
			editable: false,
			store: ['Base','Green','Sky','Red','Purple','Blue','Yellow'],
			queryMode: 'local',
			valueField: 'type',
			value: 'Blue',
13374f3f   Erdogan Furkan   #10584 - Done
272
      		id: 'visu-scatter-color',
33705dc4   Benjamin Renard   Catalog visu rework
273
274
275
276
			listeners : {
				scope : this,
				change : function(combo, newValue, oldValue) {
					//this.chartConfig.theme = newValue;
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
277
					this.visuUI.plotChart();
33705dc4   Benjamin Renard   Catalog visu rework
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
				}
			}
		};

		return {
			xtype : 'fieldset',
			title : 'Plotting Options',
			items : [
				plotTypeComboConfig,
				plotThemeComboConfig
			]
		};
	},

	init : function (config)
	{
		var myConf = {
			items: [
				this.getAxisConfig(0,'X', config.parametersStore),
				this.getAxisConfig(0,'Y', config.parametersStore),
				this.getPlottingOptionConfig()
			]
		};

		Ext.apply (this, Ext.apply(arguments, myConf));
    }
});