FFTCmpt.js 1.71 KB
Ext.define('amdaPlotComp.plotFunction.FFTCmpt', {
    extend: 'amdaPlotComp.plotFunction.BaseComponent', // This class extends from amdaPlotComp.plotFunction.BaseComponent
    title: "FFT Arguments", // The title of this component
    id: 'fftComboBox', // The id of this component

    /**
     * Initializes the component.
     * It creates a combo box with two options, 'Frequency' and 'Period', and adds it to the component.
     */
    initComponent: function () {
        const me = this;

        // Define combo box store
        const comboStore = Ext.create('Ext.data.Store', {
            fields: ['label', 'value'],
            data: [
                { label: 'Frequency', value: 'Frequency' },
                { label: 'Period', value: 'Period' }
            ]
        });

        // Create combo box
        const fftCombo = Ext.create('Ext.form.field.ComboBox', {
            itemId: me.id, // Add itemId here
            fieldLabel: 'Abscisse',
            store: comboStore,
            queryMode: 'local',
            displayField: 'label',
            valueField: 'value',
            editable: false,
            value: 'Frequency'
        });

        // Assign items to the component
        me.items = [fftCombo];

        // Call the parent class's initComponent method
        me.callParent(arguments);
    },

    /**
     * Retrieves the selected value from the combo box.
     * Returns an object with a property 'abscisse' set to the selected value.
     */
    getValues: function () {
        const fftComboBox = this.down('#' + this.id); // Retrieve ComboBox by itemId
        const selectedValue = fftComboBox.getValue(); // Get selected value

        return {
            abscisse: selectedValue
        };
    }
});