CatalogVisuHistogram.js
5.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/**
* 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',
histogramStore: null,
visuUI:null,
constructor: function(config) {
this.init(config);
this.callParent(arguments);
},
getChartConfig: function(catalogStore) {
var paramOpt = {
paramId: '',
title: 'Parameter'
};
var paramField = Ext.getCmp('visu-histo-param');
var paramFieldId = paramField.getValue();
if (paramFieldId && (paramFieldId != "")) {
var paramField = paramField.getStore().getById(paramFieldId);
if (paramField) {
paramOpt.paramId = paramField.get('id');
paramOpt.title = paramField.get('name');
}
}
else {
//myDesktopApp.errorMsg('Missing parameter selection');
return null;
}
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
}
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));
});
if ((minValue == null) || (maxValue == null) || (minValue == maxValue)) {
myDesktopApp.errorMsg('Not enough data or constant data');
return null;
}
var isLogScale = Ext.getCmp('visu-scatter-logbox').getValue();
var binSize = (maxValue-minValue) / (nbBinsValue);
var x=[];
catalogStore.each(function (item) {
x.push(item.get(paramOpt.paramId));
});
var trace = {
x: x,
type: 'histogram',
histnorm: Ext.getCmp('normalizedCheckbox').getValue() ? 'probability': null,
xbins: { end: maxValue, size: binSize, start: minValue }
};
var data = [trace];
var layout = {
margin: {l: 60,r: 40, b: 40,t: 40,pad: 5},
yaxis: {
title: Ext.getCmp('normalizedCheckbox').getValue() ? 'Frequency': 'Events',
type: isLogScale ? 'log' : null
},
xaxis: {title: paramOpt.title},
};
var result = {data:data,layout:layout}
return result;
},
getHistoConfig: function(parametersStore) {
var paramComboConfig = {
xtype: 'combo',
emptyText: 'select parameter',
editable: false,
store: parametersStore,
queryMode: 'local',
displayField: 'name',
valueField: 'id',
id: 'visu-histo-param',
listeners:{
change:function(){
this.visuUI.plotChart();
},
scope: this
}
};
var logbox={
xtype: 'fieldcontainer',
fieldLabel: 'Log Scale',
defaultType: 'checkboxfield',
items: [
{
name : 'logscale',
inputValue: false,
id : 'visu-scatter-logbox',
listeners:{
change:function(){
this.visuUI.plotChart();
},
scope: this
}
}
],
};
var normalizedbox={
xtype: 'fieldcontainer',
fieldLabel: 'Normalized',
defaultType: 'checkboxfield',
items: [
{
name : 'normalized',
inputValue: false,
id : 'normalizedCheckbox',
listeners:{
change:function(){
this.visuUI.plotChart();
},
scope: this
}
}
],
};
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,
id: 'visu-histo-bin-slider',
listeners: {
change: function ( slider, newValue, thumb, eOpts ) {
var binValueField = Ext.getCmp('visu-histo-bin-value');
binValueField.setValue(newValue);
},
changecomplete: function(){
this.visuUI.plotChart();
},
scope: this
}
},
{
xtype: 'splitter'
},
{
xtype: 'numberfield',
hideTrigger: true,
width: 50,
disabled: true,
value: 10,
id: 'visu-histo-bin-value'
}
]
}
]
};
return {
xtype : 'fieldset',
title : 'Histogram axis',
items : [
paramComboConfig,
sliderConfig,
normalizedbox,
logbox,
{
xtype: 'textfield',
fieldLabel: 'Title',
id: 'visu-histo-title',
listeners: {
change: function(){
this.visuUI.plotChart();
},
scope: this
}
}
]
};
},
init : function (config)
{
var myConf = {
items: [
this.getHistoConfig(config.parametersStore)
]
};
this.visuUI= config.visuUI;
Ext.apply (this, Ext.apply(arguments, myConf));
}
});