Question

This is the ExtJS Shape Class:

Ext.define('Ext.chart.Shape', {

    singleton: true,

    circle: function (surface, opts) {
        return surface.add(Ext.apply({
            type: 'circle',
            x: opts.x,
            y: opts.y,
            stroke: null,
            radius: opts.radius
        }, opts));
    },
    ...
});

I want to add a method to this Class. For example:

myCircle: function (surface, opts) {
        return ...
},

How can I do this?

Was it helpful?

Solution

I found the answer. This is the solution if someone needs it:

Ext.define('MyShape', {
    override: 'Ext.chart.Shape',

    initialize: function() {
        this.callOverridden(arguments);
    },

    myCircle: function (surface, opts) {
        return ...
    }
});

OTHER TIPS

You can extend to add new functions, or override to change behaviour of existing functions on a class. Links below are for the details in the sencha documentation explaining how to use them.

Extend

Override

Sample implementation of extend:

Ext.define('yourCustomClassHere', {
    extend: 'Ext.chart.Shape',
    newFunctionName: function () {
       //your function here
    }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top