Legend reordering

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Planoresearch
Newbie
Newbie
Posts: 57
Joined: Thu Jun 02, 2011 12:00 am

Legend reordering

Post by Planoresearch » Mon Nov 28, 2011 12:17 pm

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
Legend Reordering.jpg (55.11 KiB) Viewed 5413 times
Any suggestion will be highly appreciated.
Thanks & Regards
Plano research

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Legend reordering

Post by Sandra » Tue Nov 29, 2011 2:33 pm

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Planoresearch
Newbie
Newbie
Posts: 57
Joined: Thu Jun 02, 2011 12:00 am

Re: Legend reordering

Post by Planoresearch » Wed Nov 30, 2011 3:20 pm

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Legend reordering

Post by Narcís » Mon Dec 05, 2011 11:33 am

Hello,

An alternative could be creating your own custom legend similar to the example Christopher Ireland posted on this thread.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply