Commit e88b398e0b4b8157731125c19b95e30c3ad459c7
1 parent
afd835e1
Exists in
master
and in
16 other branches
HistoPlot is now added to plotFunction and everything works well.
Showing
3 changed files
with
85 additions
and
288 deletions
Show diff stats
js/app/views/PlotComponents/plotFunction/FunctionType copy.js deleted
... | ... | @@ -1,247 +0,0 @@ |
1 | -/** | |
2 | - * Un composant de 'PlotFunction' qui permet à l'utilisateur de séléctionner le type de fonction à appliquer : FFT, SUM, ... | |
3 | - */ | |
4 | -Ext.define('amdaPlotComp.plotFunction.FunctionType', { | |
5 | - extend: 'Ext.form.Panel', | |
6 | - | |
7 | - plotFunctionItems: { | |
8 | - type: { | |
9 | - name: "type", | |
10 | - field: "Function Type", | |
11 | - values: { | |
12 | - fft: "FFT", | |
13 | - dft: "DFT", | |
14 | - sum: "SUM", | |
15 | - avg: "AVG", | |
16 | - hist: "Histogram" | |
17 | - }, | |
18 | - labels: { | |
19 | - fft: "FFT (Magnitude^2)", | |
20 | - dft: "DFT (Magnitude^2)", | |
21 | - sum: "SUM", | |
22 | - avg: "AVG", | |
23 | - hist: "Histogram Plot" | |
24 | - } | |
25 | - }, | |
26 | - scale: { | |
27 | - name: "scale_abscisse", | |
28 | - field: "X-Axis Scale", | |
29 | - values: { | |
30 | - log: "logarithmic", | |
31 | - linear: "linear", | |
32 | - inherits: "Inherits" | |
33 | - } | |
34 | - }, | |
35 | - abscisse: { | |
36 | - name: "abscisse", | |
37 | - field: "Abscisse", | |
38 | - values: { | |
39 | - frequency: "Frequency", | |
40 | - period: "Period" | |
41 | - } | |
42 | - }, | |
43 | - scale_ordonnee: { | |
44 | - name: "scale_ordonnee", | |
45 | - field: "Y-Axis Scale" | |
46 | - }, | |
47 | - // For histogram plot | |
48 | - histogram: { | |
49 | - x_min: { | |
50 | - name: "x_min", | |
51 | - filed:"X Min" | |
52 | - }, | |
53 | - x_max: { | |
54 | - name: "x_max", | |
55 | - filed:"X Max" | |
56 | - }, | |
57 | - bins: { | |
58 | - name: "bins", | |
59 | - filed:"Nb. of bins" | |
60 | - }, | |
61 | - function:{ | |
62 | - name: "function", | |
63 | - filed: "Function to apply", | |
64 | - values: { | |
65 | - density: "density", | |
66 | - normalised_density: "normalised_density" | |
67 | - }, | |
68 | - labels: { | |
69 | - density: "Density", | |
70 | - normalised_density: "Normalised Density" | |
71 | - } | |
72 | - } | |
73 | - | |
74 | - | |
75 | - | |
76 | - } | |
77 | - }, | |
78 | - | |
79 | - initComponent: function () { | |
80 | - const key_ = "key"; | |
81 | - const name_ = "name"; | |
82 | - | |
83 | - //Combobox to choose the type of fucntion to be applied | |
84 | - const data_function_type = []; | |
85 | - let item_type = {}; | |
86 | - item_type[key_] = this.plotFunctionItems.type.values.fft; | |
87 | - item_type[name_] = this.plotFunctionItems.type.labels.fft; | |
88 | - data_function_type.push(item_type); | |
89 | - item_type = {}; | |
90 | - item_type[key_] = this.plotFunctionItems.type.values.dft; | |
91 | - item_type[name_] = this.plotFunctionItems.type.labels.dft; | |
92 | - // Disbale DFT momentarily | |
93 | - data_function_type.push(item_type); | |
94 | - | |
95 | - item_type = {}; | |
96 | - item_type[key_] = this.plotFunctionItems.type.values.sum; | |
97 | - item_type[name_] = this.plotFunctionItems.type.labels.sum; | |
98 | - data_function_type.push(item_type); | |
99 | - item_type = {}; | |
100 | - item_type[key_] = this.plotFunctionItems.type.values.avg; | |
101 | - item_type[name_] = this.plotFunctionItems.type.labels.avg; | |
102 | - data_function_type.push(item_type); | |
103 | - | |
104 | - const function_type = Ext.create('Ext.data.Store', { | |
105 | - fields: [key_, name_], | |
106 | - data: data_function_type | |
107 | - }); | |
108 | - | |
109 | - //Combo to choose type of scaling | |
110 | - const data_ = []; | |
111 | - const item_inherits = {}; | |
112 | - item_inherits[key_] = this.plotFunctionItems.scale.values.inherits; | |
113 | - item_inherits[name_] = this.plotFunctionItems.scale.values.inherits; | |
114 | - // Disbale inherits momentarily | |
115 | - //data_.push(item_inherits); | |
116 | - | |
117 | - const item_log = {}; | |
118 | - item_log[key_] = this.plotFunctionItems.scale.values.log; | |
119 | - item_log[name_] = this.plotFunctionItems.scale.values.log; | |
120 | - data_.push(item_log); | |
121 | - | |
122 | - const item_linear = {}; | |
123 | - item_linear[key_] = this.plotFunctionItems.scale.values.linear; | |
124 | - item_linear[name_] = this.plotFunctionItems.scale.values.linear; | |
125 | - data_.push(item_linear); | |
126 | - | |
127 | - const scale = Ext.create('Ext.data.Store', { | |
128 | - fields: [key_, name_], | |
129 | - data: data_ | |
130 | - }); | |
131 | - | |
132 | - //Combo to choose x type data of FFT | |
133 | - const data__ = []; | |
134 | - const item_frequency = {}; | |
135 | - item_frequency[key_] = this.plotFunctionItems.abscisse.values.frequency; | |
136 | - item_frequency[name_] = this.plotFunctionItems.abscisse.values.frequency; | |
137 | - data__.push(item_frequency); | |
138 | - | |
139 | - const item_period = {}; | |
140 | - item_period[key_] = this.plotFunctionItems.abscisse.values.period; | |
141 | - item_period[name_] = this.plotFunctionItems.abscisse.values.period; | |
142 | - data__.push(item_period); | |
143 | - | |
144 | - const abscisse = Ext.create('Ext.data.Store', { | |
145 | - fields: [key_, name_], | |
146 | - data: data__ | |
147 | - }); | |
148 | - | |
149 | - const me = this; | |
150 | - | |
151 | - var tabParams = Ext.create('Ext.form.FieldSet', { | |
152 | - collapsible: false, | |
153 | - layout: { | |
154 | - type: 'vbox', | |
155 | - pack: 'start', | |
156 | - align: 'stretch', | |
157 | - }, | |
158 | - bodyStyle: 'background: none', | |
159 | - items: [ | |
160 | - { | |
161 | - xtype: 'combo', | |
162 | - fieldLabel: this.plotFunctionItems.type.field, | |
163 | - store: function_type, | |
164 | - queryMode: 'local', | |
165 | - displayField: name_, | |
166 | - valueField: key_, | |
167 | - editable: false, | |
168 | - value: this.plotFunctionItems.type.values.sum, | |
169 | - name: this.plotFunctionItems.type.name, | |
170 | - listeners: { | |
171 | - change: function (combo, value) { | |
172 | - if (value === me.plotFunctionItems.type.values.fft || value === me.plotFunctionItems.type.values.dft) { | |
173 | - me.getForm().findField(me.plotFunctionItems.abscisse.name).setVisible(true); | |
174 | - } | |
175 | - else { | |
176 | - me.getForm().findField(me.plotFunctionItems.abscisse.name).setVisible(false); | |
177 | - } | |
178 | - } | |
179 | - } | |
180 | - }, | |
181 | - { | |
182 | - xtype: 'combo', | |
183 | - fieldLabel: this.plotFunctionItems.scale.field, | |
184 | - store: scale, | |
185 | - queryMode: 'local', | |
186 | - displayField: name_, | |
187 | - valueField: key_, | |
188 | - editable: false, | |
189 | - value: this.plotFunctionItems.scale.values.log, | |
190 | - name: this.plotFunctionItems.scale.name | |
191 | - }, | |
192 | - { | |
193 | - xtype: 'combo', | |
194 | - fieldLabel: this.plotFunctionItems.abscisse.field, | |
195 | - store: abscisse, | |
196 | - queryMode: 'local', | |
197 | - displayField: name_, | |
198 | - valueField: key_, | |
199 | - editable: false, | |
200 | - hidden: true, | |
201 | - value: this.plotFunctionItems.abscisse.values.frequency, | |
202 | - name: this.plotFunctionItems.abscisse.name | |
203 | - }, | |
204 | - { | |
205 | - xtype: 'combo', | |
206 | - fieldLabel: this.plotFunctionItems.scale_ordonnee.field, | |
207 | - store: scale, | |
208 | - queryMode: 'local', | |
209 | - displayField: name_, | |
210 | - valueField: key_, | |
211 | - editable: false, | |
212 | - value: this.plotFunctionItems.scale.values.log, | |
213 | - name: this.plotFunctionItems.scale_ordonnee.name | |
214 | - } | |
215 | - ] | |
216 | - }); | |
217 | - | |
218 | - const config = | |
219 | - { | |
220 | - title: 'Function Type', | |
221 | - bodyStyle: { background: '#dfe8f6' }, | |
222 | - items: [tabParams] | |
223 | - }; | |
224 | - | |
225 | - Ext.apply(this, config); | |
226 | - this.callParent(arguments); | |
227 | - }, | |
228 | - | |
229 | - /** | |
230 | - * Retournes les valeurs des comboboxes associées à ce composant | |
231 | - * @returns les valeurs des comboboxes se forme d'un dictionnaire | |
232 | - */ | |
233 | - getValues: function () { | |
234 | - const value_scale = this.getForm().findField(this.plotFunctionItems.scale.name).getValue(); | |
235 | - const value_abscisse = this.getForm().findField(this.plotFunctionItems.abscisse.name).getValue(); | |
236 | - const value_scale_ordonnee = this.getForm().findField(this.plotFunctionItems.scale_ordonnee.name).getValue(); | |
237 | - const type_function = this.getForm().findField(this.plotFunctionItems.type.name).getValue(); | |
238 | - | |
239 | - let out = {}; | |
240 | - out[this.plotFunctionItems.type.name] = type_function; | |
241 | - out[this.plotFunctionItems.abscisse.name] = value_abscisse; | |
242 | - out[this.plotFunctionItems.scale.name] = value_scale; | |
243 | - out[this.plotFunctionItems.scale_ordonnee.name] = value_scale_ordonnee; | |
244 | - | |
245 | - return out; | |
246 | - } | |
247 | -}); | |
248 | 0 | \ No newline at end of file |
js/app/views/PlotComponents/plotFunction/FunctionType.js
... | ... | @@ -19,7 +19,7 @@ Ext.define('amdaPlotComp.plotFunction.FunctionType', { |
19 | 19 | dft: { label: "DFT (Magnitude^2)", value: "DFT" }, |
20 | 20 | sum: { label: "SUM", value: "SUM" }, |
21 | 21 | avg: { label: "AVG", value: "AVG" }, |
22 | - hist: { label: "Histogram Plot", value: "histogram_plot" } | |
22 | + hist: { label: "Histogram Plot 1D", value: 'histoPlot' } | |
23 | 23 | }, |
24 | 24 | |
25 | 25 | createFunctionComboBox: function (defaultSelection) { |
... | ... | @@ -129,12 +129,13 @@ Ext.define('amdaPlotComp.plotFunction.FunctionType', { |
129 | 129 | out[this.x_axis.value] = xAxisScale; |
130 | 130 | out[this.y_axis.value] = yAxisScale; |
131 | 131 | |
132 | - const values = this.currentModule.getValues(); | |
133 | - | |
134 | - // Adding values to out | |
135 | - Object.assign(out, values); | |
136 | - console.log(out); | |
137 | 132 | |
133 | + if (this.currentModule) { | |
134 | + const values = this.currentModule.getValues(); | |
135 | + // Adding values to out | |
136 | + Object.assign(out, values); | |
137 | + } | |
138 | + | |
138 | 139 | return out; |
139 | 140 | } |
140 | 141 | }); |
141 | 142 | \ No newline at end of file | ... | ... |
js/app/views/PlotComponents/plotFunction/Histogram.js
... | ... | @@ -2,44 +2,87 @@ Ext.define('amdaPlotComp.plotFunction.Histogram', { |
2 | 2 | extend: 'amdaPlotComp.plotFunction.BaseComponent', |
3 | 3 | title: "Histogram Arguments", |
4 | 4 | |
5 | + functionId: 'histo1d-function', | |
6 | + binsId: 'histo1d-xbinnumber', | |
7 | + xMinId: "histo1d-xmin", | |
8 | + xMaxId: 'histo1d-xmax', | |
5 | 9 | |
6 | - items: [ | |
7 | - { | |
8 | - xtype: 'numberfield', | |
9 | - fieldLabel: 'X Min', | |
10 | - name: 'xMin', | |
11 | - allowDecimals: true, // This allows decimal numbers | |
12 | - hideTrigger: true, // Hides the spinner buttons | |
13 | - keyNavEnabled: false, // Disables keyboard navigation for precision | |
14 | - }, | |
15 | - { | |
16 | - xtype: 'numberfield', | |
17 | - fieldLabel: 'X Max', | |
18 | - name: 'xMax', | |
19 | - allowDecimals: true, // This allows decimal numbers | |
20 | - hideTrigger: true, // Hides the spinner buttons | |
21 | - keyNavEnabled: false, // Disables keyboard navigation for precision | |
22 | - }, | |
23 | - { | |
24 | - xtype: 'numberfield', | |
25 | - fieldLabel: 'Number of Bins', | |
26 | - name: 'numBins', | |
27 | - minValue: 1, | |
28 | - value: 100, | |
29 | - allowDecimals: false, // This ensures only integers are allowed | |
30 | - keyNavEnabled: false, // Disables keyboard navigation for precision | |
31 | - }, | |
32 | - { | |
33 | - xtype: 'combo', | |
10 | + initComponent: function () { | |
11 | + const me = this; | |
12 | + | |
13 | + const comboStore = Ext.create('Ext.data.Store', { | |
14 | + fields: ['label', 'value'], | |
15 | + data: [ | |
16 | + { value: 'density', label: 'Density' }, | |
17 | + { value: 'normdensity', label: 'Normalised Density' } | |
18 | + ] | |
19 | + }); | |
20 | + | |
21 | + const densityTypeCombo = Ext.create('Ext.form.field.ComboBox', { | |
34 | 22 | fieldLabel: 'Density Type', |
35 | - name: 'densityType', | |
36 | - store: ['Density', 'Normalized Density'], | |
37 | - value: 'Density' // Set 'Density' as default | |
38 | - } | |
39 | - ], | |
23 | + name: me.functionId, | |
24 | + store: comboStore, | |
25 | + queryMode: 'local', | |
26 | + displayField: 'label', | |
27 | + valueField: 'value', | |
28 | + editable: false, | |
29 | + value: 'density' | |
30 | + }); | |
31 | + | |
32 | + Ext.apply(me, { | |
33 | + items: [ | |
34 | + { | |
35 | + xtype: 'numberfield', | |
36 | + fieldLabel: 'X Min', | |
37 | + name: me.xMinId, | |
38 | + allowDecimals: true, | |
39 | + hideTrigger: true, | |
40 | + keyNavEnabled: false, | |
41 | + }, | |
42 | + { | |
43 | + xtype: 'numberfield', | |
44 | + fieldLabel: 'X Max', | |
45 | + name: me.xMaxId, | |
46 | + allowDecimals: true, | |
47 | + hideTrigger: true, | |
48 | + keyNavEnabled: false, | |
49 | + }, | |
50 | + { | |
51 | + xtype: 'numberfield', | |
52 | + fieldLabel: 'Number of Bins', | |
53 | + name: me.binsId, | |
54 | + minValue: 1, | |
55 | + value: 100, | |
56 | + allowDecimals: false, | |
57 | + keyNavEnabled: false, | |
58 | + }, | |
59 | + densityTypeCombo | |
60 | + ] | |
61 | + }); | |
62 | + | |
63 | + me.callParent(arguments); | |
64 | + }, | |
40 | 65 | |
41 | 66 | getValues: function () { |
42 | - | |
43 | - } | |
67 | + const densityTypeCombo = this.query('[name=' + this.functionId + ']')[0]; | |
68 | + const densityTypeValue = densityTypeCombo.getValue(); | |
69 | + | |
70 | + const numBinsField = this.query('[name=' + this.binsId + ']')[0]; | |
71 | + const numBinsValue = numBinsField.getValue(); | |
44 | 72 | |
73 | + const xMinField = this.query('[name=' + this.xMinId + ']')[0]; | |
74 | + const xMinValue = xMinField.getValue(); | |
75 | + | |
76 | + const xMaxField = this.query('[name=' + this.xMaxId + ']')[0]; | |
77 | + const xMaxValue = xMaxField.getValue(); | |
78 | + | |
79 | + let out = {}; | |
80 | + | |
81 | + out[this.functionId] = densityTypeValue; | |
82 | + out[this.binsId] = numBinsValue; | |
83 | + out[this.xMinId] = xMinValue; | |
84 | + out[this.xMaxId] = xMaxValue; | |
85 | + | |
86 | + return out; | |
87 | + } | |
45 | 88 | }); | ... | ... |