Page 1 of 1

Sorting Problem

Posted: Tue Dec 26, 2006 8:42 am
by 9638303
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

Posted: Wed Dec 27, 2006 9:38 am
by Chris
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);
    }