Series sorting like values

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
elby
Newbie
Newbie
Posts: 11
Joined: Fri Sep 10, 2010 12:00 am

Series sorting like values

Post by elby » Tue Jun 21, 2011 5:33 pm

We discovered some unexpected behavior when sorting series values.
SeriesSortOrder is our own enum type for specifying what to sort by.

For example if our X has sets of equivalent values the problem occurs where are Y is also sorted.

A snap shot of the data data is below X and Y1 (before sort) and Y2 (after sort). This is where our enum option is XAscending.

After we perform the sort only on X the Y values were sorted (unnecessarily) as the X was the same. You will notice that if Y1 was acending before, it is now descending and vice versa.

******************************
X Y1 Y2
0 1200 1200
250 1199.515 1199.515
500 1199.024 1499.024
500 1499.024 1199.024
750 1498.661 1498.661
1000 1498.293 2097.611
1000 2097.611 1498.293
1250 2097.224 2097.224
1500 2096.832 2096.832
1500 2096.832 2096.832
1500 2096.832 2096.832
1750 2096.821 2096.821
2000 2096.801 22096.8
2000 22096.8 2096.801
2250 22096.8 22096.8
2500 22096.8 21846.8
2500 21846.8 22096.8

Are we doing something wrong here. What is happening? Our plots of course come out very different.


Here is our use.....
series.Add(xValues, yValues);

switch (seriesDef.SortOrder)
{
case SeriesSortOrder.XAscending:
{
series.XValues.Order = ValueListOrder.Ascending;
series.XValues.Sort();
}
break;
case SeriesSortOrder.XDescending:
{
series.XValues.Order = ValueListOrder.Descending;
series.XValues.Sort();
}
break;
case SeriesSortOrder.YAscending:
{
series.YValues.Order = ValueListOrder.Ascending;
series.YValues.Sort();
}
break;
case SeriesSortOrder.YDescending:
{
series.YValues.Order = ValueListOrder.Descending;
series.YValues.Sort();
}
break;
default:
break;
}

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

Re: Series sorting like values

Post by Sandra » Wed Jun 22, 2011 11:58 am

Hello ebdy,

Could you please check, if changing position of method series.add(xValues,yValues) for code where you order your data, code works as you expected? You can do next:

Code: Select all

switch (seriesDef.SortOrder)
{
case SeriesSortOrder.XAscending:
{
series.XValues.Order = ValueListOrder.Ascending;
series.XValues.Sort();
}
break;
case SeriesSortOrder.XDescending:
{
series.XValues.Order = ValueListOrder.Descending;
series.XValues.Sort();
}
break;
case SeriesSortOrder.YAscending:
{
series.YValues.Order = ValueListOrder.Ascending;
series.YValues.Sort();
}
break;
case SeriesSortOrder.YDescending:
{
series.YValues.Order = ValueListOrder.Descending;
series.YValues.Sort();
}
break;
default:
break;
} 

series.Add(xValues, yValues);
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

Post Reply