CatalogVisuScatter.js
6.11 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
/**
* 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);
},
getChartConfig: function(catalogStore) {
var plotTypeField = Ext.getCmp('visu-scatter-type');
var plotType = plotTypeField.getValue();
var plotColorField = Ext.getCmp('visu-scatter-color');
plotColor = plotColorField.getValue();
var xAxisOpt = this.getAxisOptions('X');
var yAxisOpt = this.getAxisOptions('Y');
if ((!xAxisOpt.paramId) || (xAxisOpt.paramId == '')) {
myDesktopApp.errorMsg('Missing parameter selection for X axis');
return null;
}
if ((!yAxisOpt.paramId) || (yAxisOpt.paramId == '')) {
myDesktopApp.errorMsg('Missing parameter selection for Y axis');
return null;
}
var x=[];
var y=[];
var text=[];
catalogStore.each(function(item){
x.push(item.get(xAxisOpt.paramId));
y.push(item.get(yAxisOpt.paramId));
text.push(''+item.get('start').toISOString()+'<br>'+item.get('stop').toISOString());
});
var data =[{
x: x,
y: y,
mode: (plotType=='line') ? 'lines+markers' : 'markers',
text: text,
marker:{
color:plotColor},
type: 'scatter'}];
var layout = {
margin: {l: 50,r: 40, b: 40,t: 40,pad: 5},
xaxis: {title: xAxisOpt.title, range: !xAxisOpt.range ? null : [xAxisOpt.range.min,xAxisOpt.range.max]},
yaxis: {title: yAxisOpt.title, range: !yAxisOpt.range ? null : [yAxisOpt.range.min,yAxisOpt.range.max]},
hovermode: "closest",
hoverlabel :{ font:{size:10}}
};
var result = {data:data,layout:layout}
return result;
},
getAxisOptions: function(axisName) {
var opt = {
paramId: '',
title: axisName+' axis'
};
var axisParamField = Ext.getCmp('visu-scatter-' + axisName + '-param');
var paramFieldId = axisParamField.getValue();
if (paramFieldId && (paramFieldId != "")) {
var paramField = axisParamField.getStore().getById(axisParamField.getValue());
if (paramField) {
opt.paramId = paramField.get('id');
opt.title = paramField.get('name');
}
}
var axisTitleField = Ext.getCmp('visu-scatter-'+axisName+'-title');
var axisTitle = axisTitleField.getValue();
if (axisTitle && (axisTitle != "")) {
opt.title = axisTitle;
}
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
};
}
return opt;
},
getAxisConfig: function(axisIndex, axisName, parametersStore) {
var paramComboConfig = {
xtype: 'combo',
emptyText: 'select parameter',
editable: false,
store: parametersStore,
queryMode: 'local',
displayField: 'name',
valueField: 'id',
axisIndex: axisIndex,
id: 'visu-scatter-' + axisName + '-param'
};
var comboRangeConfig = {
xtype : 'combo',
name:'scaling',
valueField: 'scaling',
queryMode:'local',
store:['auto','manual'],
forceSelection:true,
value: 'auto',
width: 80,
id: 'visu-scatter-' + axisName + '-scaling',
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);
}
}
};
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,
disabled: true,
id: 'visu-scatter-' + axisName + '-range-min'
},
{
xtype: 'splitter'
},
{
xtype: 'numberfield',
hideTrigger: true,
width: 50,
disabled: true,
id: 'visu-scatter-' + axisName + '-range-max'
}
]
}
]
};
return {
xtype : 'fieldset',
title : axisName + ' axis',
items : [
paramComboConfig,
axisRangeConfig,
{
xtype: 'textfield',
fieldLabel: axisName + ' title',
id: 'visu-scatter-' + axisName + '-title'
}
]
};
},
getPlottingOptionConfig: function() {
var plotTypeComboConfig = {
xtype: 'combo',
emptyText: 'select plot type',
editable: false,
store: ['scatter', 'line'],
queryMode: 'local',
valueField: 'type',
value: 'scatter',
id: 'visu-scatter-type',
listeners : {
scope : this,
change : function(combo, newValue, oldValue) {
//this.chartConfig.series[0].type = newValue;
}
}
};
var plotThemeComboConfig = {
xtype: 'combo',
emptyText: 'select theme',
editable: false,
store: ['Base','Green','Sky','Red','Purple','Blue','Yellow'],
queryMode: 'local',
valueField: 'type',
value: 'Blue',
id: 'visu-scatter-color',
listeners : {
scope : this,
change : function(combo, newValue, oldValue) {
//this.chartConfig.theme = newValue;
}
}
};
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));
}
});