Results 1 to 5 of 5

Thread: How to get the scope inside the renderer method of a label in an axe (chart)

  1. #1
    Sencha User
    Join Date
    Dec 2008
    Posts
    19
    Answers
    2

    Question Answered: How to get the scope inside the renderer method of a label in an axe (chart)

    Hi,

    I use the "renderer" method of the "label" property of my axe I define in a chart to define a custom value to return as such :

    Code:
    {
        type: 'Category',
        position: 'bottom',
        fields: ['flow'],
        label: {
            renderer: function(value) {
                return (value == "upstream") ? "Upstream" : "Downstream";
            }
        },
        title: this.bottomAxeTitleText
    }
    That does the trick, but I normally avoid setting such values deep inside the code. I use "xxxText" public properties for that, which can then be internationalized as well.

    Problem is, inside the renderer method, I don't have any scope to the axe instance. Looking at the doc doesn't reveal any such property either.

    http://docs.sencha.com/ext-js/4-0/#!/api/Ext.chart.series.Column

    Is there any way to accomplish this ? I'm thinking of setting these as static properties but I'm not sure if that's the right way to do so.

    Thanks,

    Alexandre

  2. I'm assuming you are doing this within a class definition?

    I would setup a variable at the start of the method you are in:

    Code:
    var me = this;
    And then in the renderer you can use the me variable.

  3. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,448
    Answers
    3997

    Default

    I'm assuming you are doing this within a class definition?

    I would setup a variable at the start of the method you are in:

    Code:
    var me = this;
    And then in the renderer you can use the me variable.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  4. #3
    Sencha User
    Join Date
    Dec 2008
    Posts
    19
    Answers
    2

    Default

    Mitchell, that did the trick.

    Thanks a lot,

    Alexandre

  5. #4
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    1,018
    Answers
    1

    Default

    Hi Mitchell,

    Here is the related thread. Please review if you have a chance.
    http://www.sencha.com/forum/showthre...30990&p=856138

  6. #5
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    1,018
    Answers
    1

    Default

    Quote Originally Posted by Daniil View Post
    Here is the related thread. Please review if you have a chance.
    http://www.sencha.com/forum/showthre...30990&p=856138
    There was an update by @Animal.
    http://www.sencha.com/forum/showthre...l=1#post883392

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •