View Full Version : Ext JS 4 Pie Chart Labels: Field name and value

4 Sep 2011, 11:41 PM
How can I print both the pie chart field name and value? The label config only allows one field to be defined and the renderer only has one argument (the field name). I can set tooltip messages with the info I want:

this.setTitle(storeItem.get('name') + ': ' + storeItem.get('count') + ' (' + Math.round(storeItem.get('count') / total * 100) + '%)');

But there is no obvious way to set the label:

label: {
field: 'name',
display: 'rotate',
contrast: true,
font: '12px Verdana',

I end up with a pie chart showing the relative distribution but with no context.

5 Sep 2011, 7:10 PM
Can't you just use a closure to capture the store in the renderer? So long as the value passed to the renderer uniquely identifies the record you should then be able to look it up in the store and pull out whatever you need.

6 Sep 2011, 9:41 AM
Thanks for the response. Yes, I suppose finding the record from the store is possible. I was assuming that the renderer would have this built in as it seems like it would be a common scenario.

The following is what I ended up using:

renderer: function(item) {
var storeItem = store.findRecord('fieldname', item);
return storeItem.get('fieldname') + '\n ' + storeItem.get('count');