PDA

View Full Version : different label in pie legend and on pie label



ahsec
10 Oct 2012, 7:02 AM
Hello

I would like my pie's legend to contain a name of a field
and the matching cut on the pie to carry the percentile of that pie...

how can I separate the values?

I tried


width: 500, height: 350,
animate: true,
store: pie_store,
id:'pie_chart',
theme:'Browser',
series: [{
type: 'pie',
field: 'data',
tips: {
trackMouse: true,
width: 170,
height: 35,
renderer: function(storeItem, item) {
// calculate and display percentage on hover
var total = 0;
pie_store.each(function(rec) {
total += rec.get('data');
});
this.setTitle(storeItem.get('name') + ': ' + storeItem.get('data') );


}
},
highlight: {
segment: {
margin: 20
}
},
showInLegend: true,
label: {
field: 'percentage',
display: 'rotate',
contrast: true,
font: '15px Arial',


}
}],
legend:{
position:"right"
}

but now the legend and the cut both carry the "percentage" ...

any Idea anyone?

Thanks

hacocacyb
10 Oct 2012, 7:17 AM
See if the advice in this thread helps you:

http://www.sencha.com/forum/showthread.php?136068-ExtJS-4-Charts-Custom-Legends&p=613629&viewfull=1#post613629

ahsec
10 Oct 2012, 8:37 AM
but there, it's a static way, that is, you have to give a constant string as a label..I want it to take one index from the record of the store to appear in the legend and another one(from the same record of course) to appear as the title on the pie

something like

pie_store.add({field1:value1,field2:value2});

and that I'll see on the legend the color red with value1 and on the color red on the pie value2...

Thanks

hacocacyb
10 Oct 2012, 9:16 AM
Had you read to the last post and tried that too?

http://www.sencha.com/forum/showthread.php?136068-ExtJS-4-Charts-Custom-Legends&p=733648&viewfull=1#post733648

ahsec
14 Oct 2012, 12:46 AM
wrote it to fit my own code but it didnt work....

the renderer function only runs when hovering on the pie chart...why would it change the label of the pie slice?

I made the function that you referred me to so it would return the field that I want but thats all it does

Thanks