Sorting Problem

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Eric
Newbie
Newbie
Posts: 99
Joined: Wed Sep 14, 2005 4:00 am

Sorting Problem

Post by Eric » Tue Dec 26, 2006 8:42 am

Dear Sir

How do i sort multi-series correctly? for example
The Chart contain 2 bar series and value as below

TChart1.Series(0).Add(12, "A1", TChart1.Series(0).Color)
TChart1.Series(0).Add(65, "A2", TChart1.Series(0).Color)
TChart1.Series(0).Add(77, "A3", TChart1.Series(0).Color)
TChart1.Series(0).Add(242, "A4", TChart1.Series(0).Color)

TChart1.Series(1).Add(4, "A1", TChart1.Series(0).Color)
TChart1.Series(1).Add(76, "A2", TChart1.Series(0).Color)
TChart1.Series(1).Add(34, "A3", TChart1.Series(0).Color)
TChart1.Series(1).Add(2, "A4", TChart1.Series(0).Color)

How to i sort the TChart series as below the result

A4(242,2) , A2(65,76), A2(77,34), A1(12,4)

Eric

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Wed Dec 27, 2006 9:38 am

Hello!

You can use the SortByLabels() method, e.g.

Code: Select all

    Steema.TeeChart.Styles.Line line1;
    Steema.TeeChart.Styles.Line line2;

    private void InitializeChart()
    {
      tChart1.Series.Add(line1 = new Steema.TeeChart.Styles.Line());
      tChart1.Series.Add(line2 = new Steema.TeeChart.Styles.Line());

      line1.Add(12, "A1");
      line1.Add(65, "A2");
      line1.Add(77, "A3");
      line1.Add(242, "A4");

      line2.Add(4, "A1");
      line2.Add(76, "A2");
      line2.Add(34, "A3");
      line2.Add(2, "A4");
    }

    private void button1_Click(object sender, EventArgs e)
    {
      line1.SortByLabels(Steema.TeeChart.Styles.ValueListOrder.Descending);
      line2.SortByLabels(Steema.TeeChart.Styles.ValueListOrder.Descending);
    }
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Post Reply