PDA

View Full Version : Newbie question - labelFunction in stacked bar chart?



mcoker
3 Feb 2010, 12:09 PM
Hiya, I'm new to extJS, and I was hoping to apply a labelfunction to my Y axis on a 'stackedbarchart'

Here's the code I'm using:



Ext.onReady(function(){
var store = foobar_datastore;
new Ext.Panel({
width: 600,
height: 400,
renderTo: 'container',
title: 'Testing 123',
items: {
xtype: 'stackedbarchart',
store: store,
yField: 'name',
xAxis: new Ext.chart.NumericAxis({
stackingEnabled: true
}),
yAxis: {
labelFunction: function(val)
{
console.log('asdf');
}
},
series: [{
xField: 'value',
displayName: 'Foo'
},{
xField: 'sub_value',
displayName: 'Bar'
}]
}
});
});


The labelFunction doesn't seem to be called, as I see nothing in my console log. Everything else seems to work fine. Anyone know what I need to do differently?

tobiu
3 Feb 2010, 1:44 PM
i never tried out an axis without an xtype, this could be a problem.

i would try something like:


,yAxis : new Ext.chart.NumericAxis({
roundMajorUnit : true
,labelRenderer : function(val){...}
})

i am using the latest version of yui-charts, there it is called labelRenderer instead of labelFunction, not sure how it is in the ext-version.

play around with it a bit ;)

kind regards,
tobiu

mcoker
4 Feb 2010, 9:03 AM
Thank you, figured it out:



var truncate = function(val)
{
val = val.substr(11,20);
return val + '...';
}

(...)

yAxis: new Ext.chart.CategoryAxis({
labelRenderer : truncate
}),