Blame view

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

Ext.define('amdaUI.CatalogVisuHistogram', {
	extend: 'Ext.form.Panel',
	alias: 'widget.panelCatalogVisuHistogram',
738e0997   Benjamin Renard   Draw histogram
13
	histogramStore: null,
560766be   furkan   #6899- Last modif...
14
  visuUI:null,
33705dc4   Benjamin Renard   Catalog visu rework
15
16
17
18
19
	constructor: function(config) {
		this.init(config);
		this.callParent(arguments);
	},

536a676d   Erdogan Furkan   #10701 & #10702 Done
20
  getChartConfig: function(catalogStore,isColorBar=false) {
738e0997   Benjamin Renard   Draw histogram
21
22
		var paramOpt = {
			paramId: '',
738e0997   Benjamin Renard   Draw histogram
23
			title: 'Parameter'
3ccb373f   furkan   #6899 - Done
24
		}; 
738e0997   Benjamin Renard   Draw histogram
25
26
27
28
29
30

		var paramField = Ext.getCmp('visu-histo-param');
		var paramFieldId = paramField.getValue();
		if (paramFieldId && (paramFieldId != "")) {
			var paramField = paramField.getStore().getById(paramFieldId);
			if (paramField) {
b0720b91   Benjamin Renard   Finalize catalog ...
31
				paramOpt.paramId = paramField.get('id');
738e0997   Benjamin Renard   Draw histogram
32
				paramOpt.title = paramField.get('name');
738e0997   Benjamin Renard   Draw histogram
33
34
			}
		}
b0720b91   Benjamin Renard   Finalize catalog ...
35
    else {
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
36
      //myDesktopApp.errorMsg('Missing parameter selection');
b0720b91   Benjamin Renard   Finalize catalog ...
37
38
      return null;
    }
738e0997   Benjamin Renard   Draw histogram
39
40
41
42
43
44
45
46
47
48
49
50
51

		var paramTitleField = Ext.getCmp('visu-histo-title');
		var paramTitle = paramTitleField.getValue();
		if (paramTitle && (paramTitle != "")) {
			paramOpt.title = paramTitle;
		}

    var nbBinsField = Ext.getCmp('visu-histo-bin-slider');
    var nbBinsValue = nbBinsField.getValue();
		if (nbBinsValue <= 0) {
			nbBinsValue = 1
		}

738e0997   Benjamin Renard   Draw histogram
52
53
54
55
56
57
58
		var minValue = null;
		var maxValue = null;
		catalogStore.each(function (item) {
			minValue = (minValue == null) ? item.get(paramOpt.paramId) : Math.min(minValue, item.get(paramOpt.paramId));
			maxValue = (maxValue == null) ? item.get(paramOpt.paramId) : Math.max(maxValue, item.get(paramOpt.paramId));
		});

b0c34835   Benjamin Renard   Fix #8304
59
60
    if ((minValue == null) || (maxValue == null) || (minValue == maxValue)) {
      myDesktopApp.errorMsg('Not enough data or constant data');
b0720b91   Benjamin Renard   Finalize catalog ...
61
62
      return null;
    }
3c7ba0d9   Erdogan Furkan   #10702/10701 - Lo...
63
64
    var isLogScaleX = Ext.getCmp('visu-histo-logbox-X').getValue();
    var isLogScaleY = Ext.getCmp('visu-histo-logbox-Y').getValue();
3ccb373f   furkan   #6899 - Done
65
66
67
68
		var binSize = (maxValue-minValue) / (nbBinsValue);
    var x=[];
    catalogStore.each(function (item) {
			x.push(item.get(paramOpt.paramId));
738e0997   Benjamin Renard   Draw histogram
69
		});
738e0997   Benjamin Renard   Draw histogram
70

3ccb373f   furkan   #6899 - Done
71
72
73
    var trace = {
      x: x,
      type: 'histogram',
560766be   furkan   #6899- Last modif...
74
      histnorm: Ext.getCmp('normalizedCheckbox').getValue() ? 'probability': null,
3ccb373f   furkan   #6899 - Done
75
76
77
78
79
      xbins: { end: maxValue, size: binSize, start: minValue }
    };
   
    var data = [trace];
    var layout = {
560766be   furkan   #6899- Last modif...
80
      margin: {l: 60,r: 40, b: 40,t: 40,pad: 5},
13374f3f   Erdogan Furkan   #10584 - Done
81
82
      yaxis: {
        title: Ext.getCmp('normalizedCheckbox').getValue() ? 'Frequency': 'Events',
3c7ba0d9   Erdogan Furkan   #10702/10701 - Lo...
83
        type: isLogScaleY ? 'log' : null
13374f3f   Erdogan Furkan   #10584 - Done
84
      },
3c7ba0d9   Erdogan Furkan   #10702/10701 - Lo...
85
86
87
      xaxis: {
        title: paramOpt.title,
        type: isLogScaleX ? 'log' : null},
13374f3f   Erdogan Furkan   #10584 - Done
88
    };
3ccb373f   furkan   #6899 - Done
89
90
91
		
      var result =  {data:data,layout:layout}
    return result;
738e0997   Benjamin Renard   Draw histogram
92
93
  },

3c7ba0d9   Erdogan Furkan   #10702/10701 - Lo...
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
  generateLogBox: function(axis){
    return {xtype: 'fieldcontainer',
    fieldLabel: axis+' Log Scale',
    defaultType: 'checkboxfield',
    items: [
      {
        name      : 'logscale'+axis,
        inputValue: false,
        id        : 'visu-histo-logbox-'+axis,
        listeners:{
        change:function(){
          this.visuUI.plotChart();
        },
        scope: this
        }
      }
    ],}
  },

738e0997   Benjamin Renard   Draw histogram
113
114
115
116
117
118
119
  getHistoConfig: function(parametersStore) {
    var paramComboConfig = {
      xtype: 'combo',
      emptyText: 'select parameter',
      editable: false,
      store: parametersStore,
      queryMode: 'local',
b0720b91   Benjamin Renard   Finalize catalog ...
120
      displayField: 'name',
738e0997   Benjamin Renard   Draw histogram
121
      valueField: 'id',
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
122
123
124
125
126
127
128
      id: 'visu-histo-param',
      listeners:{
        change:function(){
          this.visuUI.plotChart();
        },
        scope: this
      }
738e0997   Benjamin Renard   Draw histogram
129
    };
13374f3f   Erdogan Furkan   #10584 - Done
130
    var normalizedbox={
560766be   furkan   #6899- Last modif...
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
      xtype: 'fieldcontainer',
            fieldLabel: 'Normalized',
            defaultType: 'checkboxfield',
            items: [
                {
                    name      : 'normalized',
                    inputValue: false,
                    id        : 'normalizedCheckbox',
                    listeners:{
                      change:function(){
                        this.visuUI.plotChart();
                      },
                      scope: this
                    }
                }
            ],
    };
738e0997   Benjamin Renard   Draw histogram
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
    var sliderConfig = {
      xtype : 'fieldcontainer',
      layout: 'hbox',
      items: [
        {
          xtype:'fieldset',
          title: 'Nb. bins',
          border: false,
          layout: 'hbox',
          items: [
            {
              xtype: 'slider',
              width: 150,
              value: 10,
              increment: 1,
              minValue: 2,
              maxValue: 100,
b0720b91   Benjamin Renard   Finalize catalog ...
165
166
167
168
169
170
              id: 'visu-histo-bin-slider',
              listeners: {
                change: function ( slider, newValue, thumb, eOpts ) {
                  var binValueField = Ext.getCmp('visu-histo-bin-value');
                  binValueField.setValue(newValue);
                },
560766be   furkan   #6899- Last modif...
171
172
173
                changecomplete: function(){
                  this.visuUI.plotChart();
                },
b0720b91   Benjamin Renard   Finalize catalog ...
174
175
                scope: this
              }
738e0997   Benjamin Renard   Draw histogram
176
177
178
179
180
181
182
183
184
            },
            {
              xtype: 'splitter'
            },
            {
              xtype: 'numberfield',
              hideTrigger: true,
              width: 50,
              disabled: true,
b0720b91   Benjamin Renard   Finalize catalog ...
185
              value: 10,
738e0997   Benjamin Renard   Draw histogram
186
187
188
189
190
191
192
193
194
195
196
197
198
              id: 'visu-histo-bin-value'
            }
        ]
      }
      ]
     };

    return {
      xtype : 'fieldset',
      title : 'Histogram axis',
      items : [
        paramComboConfig,
        sliderConfig,
13374f3f   Erdogan Furkan   #10584 - Done
199
        normalizedbox,
3c7ba0d9   Erdogan Furkan   #10702/10701 - Lo...
200
201
        this.generateLogBox('X'),
        this.generateLogBox('Y'),
738e0997   Benjamin Renard   Draw histogram
202
203
204
        {
          xtype: 'textfield',
          fieldLabel: 'Title',
57eb5d17   Erdogan Furkan   #6899 - Asked mod...
205
206
207
208
209
210
211
          id: 'visu-histo-title',
          listeners: {
            change: function(){
              this.visuUI.plotChart();
            },
            scope: this
          }
738e0997   Benjamin Renard   Draw histogram
212
213
214
215
        }
      ]
    };
  },
33705dc4   Benjamin Renard   Catalog visu rework
216
217
218
219

	init : function (config)
	{
		var myConf = {
33705dc4   Benjamin Renard   Catalog visu rework
220
			items: [
738e0997   Benjamin Renard   Draw histogram
221
222
          this.getHistoConfig(config.parametersStore)
      ]
33705dc4   Benjamin Renard   Catalog visu rework
223
		};
560766be   furkan   #6899- Last modif...
224
    this.visuUI= config.visuUI;
33705dc4   Benjamin Renard   Catalog visu rework
225
226
227
		Ext.apply (this, Ext.apply(arguments, myConf));
    }
});