Page 1 of 1
Legend reordering
Posted: Mon Nov 28, 2011 12:17 pm
by 15659467
Hi Steema Support,
We are working on a project which is being created in Silverlight. For this we are using Tee-Chart for .NET 2010 Silverlight version. We want to know is there any possible way to reorder legend’s item in legend of any chart.
In following image we have describes what we are expecting.
- Legend Reordering.jpg (55.11 KiB) Viewed 5409 times
Any suggestion will be highly appreciated.
Thanks & Regards
Plano research
Re: Legend reordering
Posted: Tue Nov 29, 2011 2:33 pm
by 10050769
Hello Planoresearch,
Ok. I think you can do something as next code:
Code: Select all
private void InitializeChart()
{
Steema.TeeChart.Silverlight.Styles.Pie pie1 = new Steema.TeeChart.Silverlight.Styles.Pie(tChart1.Chart);
pie1.FillSampleValues(2);
}
private void button1_Click(object sender, RoutedEventArgs e)
{
string tmp,tmp1;
tmp = tChart1.Legend.Items[0].Text;
tmp1 = tChart1.Legend.Items[0].Text2;
tChart1.Legend.Items[0].Text = tChart1.Legend.Items[1].Text;
tChart1.Legend.Items[0].Text2 = tChart1.Legend.Items[1].Text2;
tChart1.Legend.Items[1].Text = tmp;
tChart1.Legend.Items[1].Text2 = tmp1;
}
How you see, previous code allow you to reorder the items text of legend. Moreover, I think should be useful for you, use event
OnSymbolDraw what allow modified the symbol of legend.
I hope will helps.
Thanks,
Re: Legend reordering
Posted: Wed Nov 30, 2011 3:20 pm
by 15659467
Hi Sandra,
Thanks for the quick reply and code you provided. The code is working fine for swapping only legend text. But here we want to change order of whole legend item (text with its symbol).
You have suggested me to use OnSymbolDraw event for this. We will try to explore this. Meanwhile if you find any sample code or related link to solve this problem then please let us know.
Thanks in advance.
Thanks & Regards
Plano research
Re: Legend reordering
Posted: Mon Dec 05, 2011 11:33 am
by narcis
Hello,
An alternative could be creating your own custom legend similar to the example Christopher Ireland posted on
this thread.