Blame view

js/app/views/CatalogVisuScatter.js 11.9 KB
33705dc4   Benjamin Renard   Catalog visu rework
1
2
3
4
5
6
7
8
9
10
11
12
/**
 * 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',
536a676d   Erdogan Furkan   #10701 & #10702 Done
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
	requires: [
		'amdaPlotObj.PlotObjectConfig',
		'amdaPlotComp.PlotColorPicker'
	],

	availableSymbolsTypes: [
		{ 'key': 'circle', 'value': 'Dot' },
		{ 'key': 'cross-open', 'value': 'Plus' },
		{ 'key': 'circle-open', 'value': 'Circle' },
		{ 'key': 'x-open', 'value': 'Crux' },
		{ 'key': 'square-open', 'value': 'Square' },
		{ 'key': 'triangle-up-open', 'value': 'Triangle Up' },
		{ 'key': 'triangle-down-open', 'value': 'Triangle Down' },
		{ 'key': 'triangle-left-open', 'value': 'Triangle Left' },
		{ 'key': 'triangle-right-open', 'value': 'Triangle Right' },
		{ 'key': 'circle-cross-open', 'value': 'Crux in circle' },
		{ 'key': 'circle-open-dot', 'value': 'Dot in circle' },
		{ 'key': 'diamond', 'value': 'Diamond' },
		{ 'key': 'star-open', 'value': 'Star' },
4c5eec8c   Erdogan Furkan   Minor fixes
32
		{ 'key': 'hexagram-open', 'value': 'Hexagram' },
536a676d   Erdogan Furkan   #10701 & #10702 Done
33
34
35
		{ 'key': 'square', 'value': 'Full square' },
		{ 'key': 'star', 'value': 'Full star' }
	],
33705dc4   Benjamin Renard   Catalog visu rework
36
37
38
39
40
41

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

536a676d   Erdogan Furkan   #10701 & #10702 Done
42
  getChartConfig: function(catalogStore, isColorBar=true) {
1a0151a5   Benjamin Renard   wip
43
44
45
46
    var plotTypeField = Ext.getCmp('visu-scatter-type');
    var plotType = plotTypeField.getValue();

    var plotColorField = Ext.getCmp('visu-scatter-color');
536a676d   Erdogan Furkan   #10701 & #10702 Done
47
48
49
50
51
52
53
54
55
    var plotColor=plotColorField.ownerCt.colorDisplayer.value;

	var plotSizeField = Ext.getCmp('visu-scatter-size');
	var plotSize = plotSizeField.getValue();

	var plotSymbolField = Ext.getCmp('visu-scatter-symbol');
	var plotSymbol = plotSymbolField.getValue();	

	//plotColor = plotColorField.getValue();
903e5e09   Benjamin Renard   WIP
56
57
    var xAxisOpt = this.getAxisOptions('X');
    var yAxisOpt = this.getAxisOptions('Y');
536a676d   Erdogan Furkan   #10701 & #10702 Done
58
	var zAxisOpt = this.getAxisOptions('Z');
33705dc4   Benjamin Renard   Catalog visu rework
59

b0720b91   Benjamin Renard   Finalize catalog ...
60
    if ((!xAxisOpt.paramId) || (xAxisOpt.paramId == '')) {
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
61
      //myDesktopApp.errorMsg('Missing parameter selection for X axis');
b0720b91   Benjamin Renard   Finalize catalog ...
62
63
64
65
      return null;
    }

    if ((!yAxisOpt.paramId) || (yAxisOpt.paramId == '')) {
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
66
      //myDesktopApp.errorMsg('Missing parameter selection for Y axis');
b0720b91   Benjamin Renard   Finalize catalog ...
67
68
      return null;
    }
536a676d   Erdogan Furkan   #10701 & #10702 Done
69
70
71
72
73
	if ((!zAxisOpt.paramId) || (zAxisOpt.paramId == '')) {
		//myDesktopApp.errorMsg('Missing parameter selection for Y axis');
		isColorBar= false;
	}

3ccb373f   furkan   #6899 - Done
74
75
	var x=[];
	var y=[];
536a676d   Erdogan Furkan   #10701 & #10702 Done
76
	var z=[];
560766be   furkan   #6899- Last modif...
77
	var text=[];
3ccb373f   furkan   #6899 - Done
78
79
80
	catalogStore.each(function(item){
		x.push(item.get(xAxisOpt.paramId));
		y.push(item.get(yAxisOpt.paramId));
536a676d   Erdogan Furkan   #10701 & #10702 Done
81
82
83
		if (isColorBar){
			z.push(item.get(zAxisOpt.paramId));
		}
560766be   furkan   #6899- Last modif...
84
		text.push(''+item.get('start').toISOString()+'<br>'+item.get('stop').toISOString());
3ccb373f   furkan   #6899 - Done
85
	});
560766be   furkan   #6899- Last modif...
86
	
b0720b91   Benjamin Renard   Finalize catalog ...
87

3ccb373f   furkan   #6899 - Done
88
89
90
91
	var data =[{
	x: x,
	y: y,
	mode: (plotType=='line') ? 'lines+markers' : 'markers',
560766be   furkan   #6899- Last modif...
92
	text: text,
3ccb373f   furkan   #6899 - Done
93
	marker:{
536a676d   Erdogan Furkan   #10701 & #10702 Done
94
95
96
97
98
99
100
101
102
103
104
105
		color: (isColorBar) ? z : plotColor,
		colorbar:(isColorBar) ? {
			len:0.7,
			title: zAxisOpt.title,
			titleside:'right', 
			titlefont:{size:10},
		  } : null,
		colorscale: 'Jet',
		showscale:isColorBar,
		symbol: plotSymbol,
		size : plotSize,
	},
3ccb373f   furkan   #6899 - Done
106
	type: 'scatter'}];
1a0151a5   Benjamin Renard   wip
107

3ccb373f   furkan   #6899 - Done
108
109
	var layout = {
		margin: {l: 50,r: 40, b: 40,t: 40,pad: 5},
13374f3f   Erdogan Furkan   #10584 - Done
110
111
112
113
114
115
116
117
		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...
118
119
120
		hovermode: "closest",
		hoverlabel :{ font:{size:10}}	
	};
3ccb373f   furkan   #6899 - Done
121
122
	var result =  {data:data,layout:layout}
    return result;
33705dc4   Benjamin Renard   Catalog visu rework
123
124
  },

33705dc4   Benjamin Renard   Catalog visu rework
125
  getAxisOptions: function(axisName) {
903e5e09   Benjamin Renard   WIP
126
    var opt = {
1a0151a5   Benjamin Renard   wip
127
      paramId: '',
903e5e09   Benjamin Renard   WIP
128
129
      title: axisName+' axis'
    };
33705dc4   Benjamin Renard   Catalog visu rework
130

903e5e09   Benjamin Renard   WIP
131
132
133
134
135
    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 ...
136
        opt.paramId = paramField.get('id');
738e0997   Benjamin Renard   Draw histogram
137
				opt.title = paramField.get('name');
903e5e09   Benjamin Renard   WIP
138
139
      }
    }
33705dc4   Benjamin Renard   Catalog visu rework
140
141

    var axisTitleField = Ext.getCmp('visu-scatter-'+axisName+'-title');
903e5e09   Benjamin Renard   WIP
142
143
144
145
146
    var axisTitle = axisTitleField.getValue();
    if (axisTitle && (axisTitle != "")) {
      opt.title = axisTitle;
    }

1a0151a5   Benjamin Renard   wip
147
    var axisScalingField = Ext.getCmp('visu-scatter-'+axisName+'-scaling');
536a676d   Erdogan Furkan   #10701 & #10702 Done
148
149
150
151
	if (axisScalingField){
		var axisScaling = axisScalingField.getValue();	
	}
	if (axisScaling == 'manual') {
1a0151a5   Benjamin Renard   wip
152
153
154
155
156
157
158
159
160
      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
161

536a676d   Erdogan Furkan   #10701 & #10702 Done
162
163
164
	if (Ext.getCmp('visu-scatter-' + axisName + '-logbox')){
		opt.logscale = Ext.getCmp('visu-scatter-' + axisName + '-logbox').getValue();
	}
903e5e09   Benjamin Renard   WIP
165
    return opt;
33705dc4   Benjamin Renard   Catalog visu rework
166
167
  },

536a676d   Erdogan Furkan   #10701 & #10702 Done
168
	getAxisConfig: function(axisIndex, axisName, parametersStore, isColorbar = false) {
33705dc4   Benjamin Renard   Catalog visu rework
169
170
171
172
173
174
		var paramComboConfig = {
			xtype: 'combo',
			emptyText: 'select parameter',
			editable: false,
			store: parametersStore,
			queryMode: 'local',
b0720b91   Benjamin Renard   Finalize catalog ...
175
			displayField: 'name',
33705dc4   Benjamin Renard   Catalog visu rework
176
177
			valueField: 'id',
			axisIndex: axisIndex,
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
178
179
180
      		id: 'visu-scatter-' + axisName + '-param',
			listeners:{
				change:function(){
20c4ceb9   Erdogan Furkan   Fixed a bug on co...
181
182
					var isNotColorBar = Ext.getCmp('Zaxis-fieldset');
					this.visuUI.plotChart(!isNotColorBar.collapsed);
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
183
184
185
				},
				scope: this
			}
33705dc4   Benjamin Renard   Catalog visu rework
186
187
188
189
190
191
192
193
194
195
196
		};

		var comboRangeConfig = {
			xtype : 'combo',
			name:'scaling',
			valueField: 'scaling',
			queryMode:'local',
			store:['auto','manual'],
			forceSelection:true,
			value: 'auto',
			width: 80,
536a676d   Erdogan Furkan   #10701 & #10702 Done
197
      		id: 'visu-scatter-' + axisName + '-scaling',
33705dc4   Benjamin Renard   Catalog visu rework
198
199
200
201
202
203
204
205
206
207
208
209
210
211
			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
212
213
214
215
216
217
218
219
220
221
222
		var logbox={
				xtype: 'fieldcontainer',
				fieldLabel: 'Log Scale',
				defaultType: 'checkboxfield',
				items: [
					{
						name      : 'logscale',
						inputValue: false,
						id        : 'visu-scatter-' + axisName + '-logbox',
						listeners:{
						change:function(){
20c4ceb9   Erdogan Furkan   Fixed a bug on co...
223
224
							var isNotColorBar = Ext.getCmp('Zaxis-fieldset');
							this.visuUI.plotChart(!isNotColorBar.collapsed);
13374f3f   Erdogan Furkan   #10584 - Done
225
226
227
228
229
230
231
						},
						scope: this
						}
					}
				],
		  };

33705dc4   Benjamin Renard   Catalog visu rework
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
		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
250
							disabled: true,
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
251
252
253
              				id: 'visu-scatter-' + axisName + '-range-min',
							listeners:{
								change:function(){
20c4ceb9   Erdogan Furkan   Fixed a bug on co...
254
255
									var isNotColorBar = Ext.getCmp('Zaxis-fieldset');
									this.visuUI.plotChart(!isNotColorBar.collapsed);
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
256
257
258
								},
								scope: this
							}
33705dc4   Benjamin Renard   Catalog visu rework
259
260
261
262
263
264
265
266
						},
						{
							xtype: 'splitter'
						},
						{
							xtype: 'numberfield',
							hideTrigger: true,
							width: 50,
1a0151a5   Benjamin Renard   wip
267
							disabled: true,
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
268
269
270
             				id: 'visu-scatter-' + axisName + '-range-max',
							listeners:{
								change:function(){
20c4ceb9   Erdogan Furkan   Fixed a bug on co...
271
272
									var isNotColorBar = Ext.getCmp('Zaxis-fieldset');
									this.visuUI.plotChart(!isNotColorBar.collapsed);
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
273
274
275
								},
								scope: this
							}
13374f3f   Erdogan Furkan   #10584 - Done
276
						},
33705dc4   Benjamin Renard   Catalog visu rework
277
					]
13374f3f   Erdogan Furkan   #10584 - Done
278
				},
33705dc4   Benjamin Renard   Catalog visu rework
279
280
281
282
283
			]
		};

		return {
			xtype : 'fieldset',
4c5eec8c   Erdogan Furkan   Minor fixes
284
			id:axisName + 'axis-fieldset',
536a676d   Erdogan Furkan   #10701 & #10702 Done
285
286
287
288
			collapsed:isColorbar,
			collapsible:true,
			checkboxToggle:isColorbar,
			checkboxName:axisName + ' axis-checkbox',
33705dc4   Benjamin Renard   Catalog visu rework
289
			title : axisName + ' axis',
536a676d   Erdogan Furkan   #10701 & #10702 Done
290
			items : (isColorbar) ? [
33705dc4   Benjamin Renard   Catalog visu rework
291
				paramComboConfig,
33705dc4   Benjamin Renard   Catalog visu rework
292
293
294
				{
					xtype: 'textfield',
					fieldLabel: axisName + ' title',
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
295
296
297
298
299
300
          			id: 'visu-scatter-' + axisName + '-title',
					listeners:{
						change:function(){
							this.visuUI.plotChart();
						},
						scope: this
13374f3f   Erdogan Furkan   #10584 - Done
301
					},
536a676d   Erdogan Furkan   #10701 & #10702 Done
302
303
304
305
306
307
308
309
310
311
312
				}] :
				[
					paramComboConfig,
					axisRangeConfig,
					logbox,
					{
						xtype: 'textfield',
						fieldLabel: axisName + ' title',
						  id: 'visu-scatter-' + axisName + '-title',
						listeners:{
							change:function(){
20c4ceb9   Erdogan Furkan   Fixed a bug on co...
313
314
								var isNotColorBar = Ext.getCmp('Zaxis-fieldset');
								this.visuUI.plotChart(!isNotColorBar.collapsed);
536a676d   Erdogan Furkan   #10701 & #10702 Done
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
							},
							scope: this
						},
					}
				],
			listeners: (isColorbar) ? {
				collapse:function(){
					this.visuUI.plotChart(false);
					
				},
				expand : function(combo, newValue, oldValue){
					this.visuUI.plotChart();
				},
				scope: this
			}: null,
33705dc4   Benjamin Renard   Catalog visu rework
330
331
332
333
334
335
		};
	},

	getPlottingOptionConfig: function() {
		var plotTypeComboConfig = {
			xtype: 'combo',
536a676d   Erdogan Furkan   #10701 & #10702 Done
336
337
			fieldLabel:'Type',
			margin:'2 2 2 2',
33705dc4   Benjamin Renard   Catalog visu rework
338
339
340
341
342
343
			emptyText: 'select plot type',
			editable: false,
			store: ['scatter', 'line'],
			queryMode: 'local',
			valueField: 'type',
			value: 'scatter',
13374f3f   Erdogan Furkan   #10584 - Done
344
      		id: 'visu-scatter-type',
33705dc4   Benjamin Renard   Catalog visu rework
345
346
347
348
			listeners : {
				scope : this,
				change : function(combo, newValue, oldValue) {
					//this.chartConfig.series[0].type = newValue;
20c4ceb9   Erdogan Furkan   Fixed a bug on co...
349
					var isNotColorBar = Ext.getCmp('Zaxis-fieldset');
4c5eec8c   Erdogan Furkan   Minor fixes
350
					this.visuUI.plotChart(!isNotColorBar.collapsed);
33705dc4   Benjamin Renard   Catalog visu rework
351
				}
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
352
			},scope: this
33705dc4   Benjamin Renard   Catalog visu rework
353
		};
536a676d   Erdogan Furkan   #10701 & #10702 Done
354
355
		var plotThemeComboConfig = this.addColorsPicker('visu-scatter-color', 'Color', amdaPlotObj.PlotObjectConfig.availableColorsNew, 'standard');
		plotThemeComboConfig.add({id:'visu-scatter-color'});
536a676d   Erdogan Furkan   #10701 & #10702 Done
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376

		var comboStore = Ext.create('Ext.data.Store', {
			fields: [amdaPlotObj.PlotObjectConfig.fieldComboBox.key, amdaPlotObj.PlotObjectConfig.fieldComboBox.value],
			data: this.availableSymbolsTypes
		});
		var plotSymbolConfig = 
		{
			xtype: 'combo',
			store: comboStore,
			fieldLabel:'Symbol',
			editable:false,
			margin:'2 2 2 2',
			queryMode: 'local',
			displayField: 'value',
			valueField: 'key',
			value:'circle',
			id: 'visu-scatter-symbol',
			listeners: {
				scope : this,
				change : function(combo, newValue, oldValue) {
					//this.chartConfig.theme = newValue;
20c4ceb9   Erdogan Furkan   Fixed a bug on co...
377
					var isNotColorBar = Ext.getCmp('Zaxis-fieldset');
4c5eec8c   Erdogan Furkan   Minor fixes
378
					this.visuUI.plotChart(!isNotColorBar.collapsed);
536a676d   Erdogan Furkan   #10701 & #10702 Done
379
380
				}
			}
33705dc4   Benjamin Renard   Catalog visu rework
381
382
		};

536a676d   Erdogan Furkan   #10701 & #10702 Done
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
		var plotSizeNumber=
			{
				xtype: 'numberfield',
				layout:'hbox',
				hidden: true,
				width: 50,
				disabled: true,
				value: 5,
				id: 'visu-scatter-size'
			};
		
		var plotSizeConfig = {
					xtype: 'slider',
					fieldLabel: 'Size',
					layout:'hbox',
					margin:'2 2 2 2',
					width: 80,
					value: 5,
					increment: 1,
					minValue: 1,
					maxValue: 20,
					id: 'visu-scatter-size2',
					listeners: {
					  change: function ( slider, newValue, thumb, eOpts ) {
						var binValueField = Ext.getCmp('visu-scatter-size');
						binValueField.setValue(newValue);
					  },
					  changecomplete: function(){
20c4ceb9   Erdogan Furkan   Fixed a bug on co...
411
						var isNotColorBar = Ext.getCmp('Zaxis-fieldset');
4c5eec8c   Erdogan Furkan   Minor fixes
412
						this.visuUI.plotChart(!isNotColorBar.collapsed);
536a676d   Erdogan Furkan   #10701 & #10702 Done
413
414
415
416
417
418
					  },
					  scope: this
					}
			};


33705dc4   Benjamin Renard   Catalog visu rework
419
420
		return {
			xtype : 'fieldset',
536a676d   Erdogan Furkan   #10701 & #10702 Done
421
422
423
			collapsed:true,
			collapsible:true,
			layout:'fit',
33705dc4   Benjamin Renard   Catalog visu rework
424
425
426
			title : 'Plotting Options',
			items : [
				plotTypeComboConfig,
536a676d   Erdogan Furkan   #10701 & #10702 Done
427
428
429
430
				plotSymbolConfig,
				plotSizeConfig,
				plotSizeNumber,
				plotThemeComboConfig,
33705dc4   Benjamin Renard   Catalog visu rework
431
432
433
434
			]
		};
	},

536a676d   Erdogan Furkan   #10701 & #10702 Done
435
436
437
438
439
440
	addColorsPicker: function (name, label, availableColors, mode) {
		if (!mode) {
			mode = 'standard';
		}
		var me =this;
		return new amdaPlotComp.PlotColorPicker({name: name, label: label, mode: mode, colors: availableColors, onChange: function(name, newValue, oldValue) {
20c4ceb9   Erdogan Furkan   Fixed a bug on co...
441
			var isNotColorBar = Ext.getCmp('Zaxis-fieldset');
4c5eec8c   Erdogan Furkan   Minor fixes
442
			this.visuUI.plotChart(!isNotColorBar.collapsed);
536a676d   Erdogan Furkan   #10701 & #10702 Done
443
444
445
		}});
	},

33705dc4   Benjamin Renard   Catalog visu rework
446
447
448
	init : function (config)
	{
		var myConf = {
4c5eec8c   Erdogan Furkan   Minor fixes
449
			autoScroll:true,
33705dc4   Benjamin Renard   Catalog visu rework
450
451
452
			items: [
				this.getAxisConfig(0,'X', config.parametersStore),
				this.getAxisConfig(0,'Y', config.parametersStore),
536a676d   Erdogan Furkan   #10701 & #10702 Done
453
				this.getAxisConfig(0,'Z', config.parametersStore,true),
33705dc4   Benjamin Renard   Catalog visu rework
454
				this.getPlottingOptionConfig()
4c5eec8c   Erdogan Furkan   Minor fixes
455
			],
33705dc4   Benjamin Renard   Catalog visu rework
456
457
458
459
460
		};

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