Blame view

js/app/views/PlotComponents/plotFunction/Histogram.js 3.35 KB
afd835e1   Menouard AZIB   Refactoring of Pl...
1
Ext.define('amdaPlotComp.plotFunction.Histogram', {
5aa4ee37   Menouard AZIB   Add comments to H...
2
3
    extend: 'amdaPlotComp.plotFunction.BaseComponent', // This class extends from amdaPlotComp.plotFunction.BaseComponent
    title: "Histogram Arguments", // The title of this component
afd835e1   Menouard AZIB   Refactoring of Pl...
4

5aa4ee37   Menouard AZIB   Add comments to H...
5
    // Define the IDs for the function, bins, and xMin and xMax fields
e88b398e   Menouard AZIB   HistoPlot is now ...
6
7
8
9
    functionId: 'histo1d-function',
    binsId: 'histo1d-xbinnumber',
    xMinId: "histo1d-xmin",
    xMaxId: 'histo1d-xmax',
afd835e1   Menouard AZIB   Refactoring of Pl...
10

5aa4ee37   Menouard AZIB   Add comments to H...
11
12
13
14
    /**
     * Initializes the component.
     * It creates a combo box for selecting the density type and number fields for entering the xMin, xMax, and number of bins.
     */
e88b398e   Menouard AZIB   HistoPlot is now ...
15
    initComponent: function () {
6c264222   Menouard AZIB   Add comments to H...
16
        const self = this;
e88b398e   Menouard AZIB   HistoPlot is now ...
17

5aa4ee37   Menouard AZIB   Add comments to H...
18
        // Define combo box store
e88b398e   Menouard AZIB   HistoPlot is now ...
19
20
21
22
23
24
25
26
        const comboStore = Ext.create('Ext.data.Store', {
            fields: ['label', 'value'],
            data: [
                { value: 'density', label: 'Density' },
                { value: 'normdensity', label: 'Normalised Density' }
            ]
        });

5aa4ee37   Menouard AZIB   Add comments to H...
27
        // Create combo box for selecting the density type
e88b398e   Menouard AZIB   HistoPlot is now ...
28
        const densityTypeCombo = Ext.create('Ext.form.field.ComboBox', {
afd835e1   Menouard AZIB   Refactoring of Pl...
29
            fieldLabel: 'Density Type',
6c264222   Menouard AZIB   Add comments to H...
30
            name: self.functionId,
e88b398e   Menouard AZIB   HistoPlot is now ...
31
32
33
34
35
36
37
38
            store: comboStore,
            queryMode: 'local',
            displayField: 'label',
            valueField: 'value',
            editable: false,
            value: 'density'
        });

5aa4ee37   Menouard AZIB   Add comments to H...
39
        // Add items to the component
6c264222   Menouard AZIB   Add comments to H...
40
        Ext.apply(self, {
e88b398e   Menouard AZIB   HistoPlot is now ...
41
42
43
44
            items: [
                {
                    xtype: 'numberfield',
                    fieldLabel: 'X Min',
6c264222   Menouard AZIB   Add comments to H...
45
                    name: self.xMinId,
e88b398e   Menouard AZIB   HistoPlot is now ...
46
47
48
49
50
51
52
                    allowDecimals: true,
                    hideTrigger: true,
                    keyNavEnabled: false,
                },
                {
                    xtype: 'numberfield',
                    fieldLabel: 'X Max',
6c264222   Menouard AZIB   Add comments to H...
53
                    name: self.xMaxId,
e88b398e   Menouard AZIB   HistoPlot is now ...
54
55
56
57
58
59
60
                    allowDecimals: true,
                    hideTrigger: true,
                    keyNavEnabled: false,
                },
                {
                    xtype: 'numberfield',
                    fieldLabel: 'Number of Bins',
6c264222   Menouard AZIB   Add comments to H...
61
                    name: self.binsId,
e88b398e   Menouard AZIB   HistoPlot is now ...
62
63
64
65
66
67
68
69
70
                    minValue: 1,
                    value: 100,
                    allowDecimals: false,
                    keyNavEnabled: false,
                },
                densityTypeCombo
            ]
        });

5aa4ee37   Menouard AZIB   Add comments to H...
71
        // Call the parent class's initComponent method
6c264222   Menouard AZIB   Add comments to H...
72
        self.callParent(arguments);
e88b398e   Menouard AZIB   HistoPlot is now ...
73
    },
afd835e1   Menouard AZIB   Refactoring of Pl...
74

5aa4ee37   Menouard AZIB   Add comments to H...
75
76
77
78
    /**
     * Retrieves the selected values from the combo box and number fields.
     * Returns an object with properties set to these values.
     */
afd835e1   Menouard AZIB   Refactoring of Pl...
79
    getValues: function () {
e88b398e   Menouard AZIB   HistoPlot is now ...
80
81
82
83
84
        const densityTypeCombo = this.query('[name=' + this.functionId + ']')[0];
        const densityTypeValue = densityTypeCombo.getValue();

        const numBinsField = this.query('[name=' + this.binsId + ']')[0];
        const numBinsValue = numBinsField.getValue();
afd835e1   Menouard AZIB   Refactoring of Pl...
85

e88b398e   Menouard AZIB   HistoPlot is now ...
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
        const xMinField = this.query('[name=' + this.xMinId + ']')[0];
        const xMinValue = xMinField.getValue();

        const xMaxField = this.query('[name=' + this.xMaxId + ']')[0];
        const xMaxValue = xMaxField.getValue();

        let out = {};

        out[this.functionId] = densityTypeValue;
        out[this.binsId] = numBinsValue;
        out[this.xMinId] = xMinValue;
        out[this.xMaxId] = xMaxValue;

        return out;
    }
afd835e1   Menouard AZIB   Refactoring of Pl...
101
});