PDA

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



adube
27 Feb 2012, 11:11 AM
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 :



{
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)http://docs.sencha.com/ext-js/4-0/#!/api/Ext.chart.series.Column
(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

mitchellsimoens
28 Feb 2012, 7:53 AM
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:


var me = this;

And then in the renderer you can use the me variable.

adube
28 Feb 2012, 8:16 AM
Mitchell, that did the trick.

Thanks a lot,

Alexandre

Daniil
17 Jul 2012, 11:40 PM
Hi Mitchell,

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

Daniil
6 Sep 2012, 4:04 AM
Here is the related thread. Please review if you have a chance.
http://www.sencha.com/forum/showthread.php?230990&p=856138

There was an update by @Animal.
http://www.sencha.com/forum/showthread.php?230990&p=883392&viewfull=1#post883392