Search code examples
c#teechart

TeeChart: Can I have unsorted values on the bottom axis?


I have a problem when I plot values in TeeChart in C#. The data depends on an angle and hence it is possible to select different domains (0-360 degrees, -180 - 180 degrees, -90 - 270 degrees, etc).

Due to different reasons, I would like to express the domain on the Bottom axis in my TeeChart plot as

[180, 181, 182, ..., 358, 359, 0, 1, 2, 3, ..., 178, 179]

When I add this data to the TeeChart plot, the array automatically (and quite naturally) gets sorted:

[0, 1, 2, ..., 357, 358, 359]

I would like to override the automatic sorting. Is it possible?

Thanx in advance.


Solution

  • Yes, you can achieve that customizing point labels. Additionally you can set series' XValues not to be sorted, they are sorted in ascending mode by default. An example illustrates that much better:

      tChart1.Aspect.View3D = false;
    
      Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
    
      line1.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.None;
    
      Random y = new Random();
    
      for (int i = 0; i < 360; i++)
      {
        double tmp = (i + 180) % 360;
        string label = i.ToString();
    
        line1.Add(tmp, y.Next(), label);
      }