Sorting

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Geerten
Newbie
Newbie
Posts: 5
Joined: Wed Feb 16, 2011 12:00 am

Sorting

Post by Geerten » Fri Mar 04, 2011 10:39 am

Hi,

I have a question regarding the sorting of the x-axis.
With the following example:
I have a number for every week of the last year, so that's 11-53, for 2010, and 1-10 for 2011. I provide this data through a dataset, which is sorted on year, and than weeknumber. I want the serie to show the x-values as 11,12,13....52,53,1,2,3...9,10 (just as the sorting is in the dataset). However, if I disable the sorting for the x-axis, it is still sorted from 1-53, only I get the following result:
Chart.png
Chart.png (24.3 KiB) Viewed 4060 times
You see that the order of data is correct, however the x-axis is still sorted from low to high. How can I create the graph that I'm after? Or is this a bug?

Best regards,
Geerten Doornenbal

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Sorting

Post by Yeray » Fri Mar 04, 2011 12:56 pm

Hi Geerten,

The problem probably is on how you are adding the points. If you add the values with X and Y, the X values will indicate where the points will be drawn regardless of the order. So adding the values 1 to 10 (even if they are added after adding the values 11 to 53) they will be drawn in their position in the bottom axis.
Alternatively, you could:
- Add the values without X value (so they will be added sequentially 0, 1, 2,...) and with the number of week given as label.
- Add the values with the complete date as X value so the week 1/2011 is later than week 53/2011.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Geerten
Newbie
Newbie
Posts: 5
Joined: Wed Feb 16, 2011 12:00 am

Re: Sorting

Post by Geerten » Fri Mar 04, 2011 1:01 pm

Thanks for your reply.

The first solution is kind of reasonable, although I think the labels are not that nice as 'normal' notation below the axis.
The second solution I already thought of myself, but this seems to much work around the problem for me.

However, I still have a question:
What does the sorting option mean? It obviously means something else than I expected, because you don't mention it.

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Sorting

Post by Yeray » Fri Mar 04, 2011 5:09 pm

Hi Geerten,
Geerten wrote:The first solution is kind of reasonable, although I think the labels are not that nice as 'normal' notation below the axis.The second solution I already thought of myself, but this seems to much work around the problem for me.
Another possibility would be adding the points without X value, sequentially, and use OnGetAxisLabel to format the axis labels.
Geerten wrote:However, I still have a question: What does the sorting option mean? It obviously means something else than I expected, because you don't mention it.
As the help says:
TChartValueList.Order
TChartValueList

property Order: TChartListOrder;

Unit
TeEngine

Description
Run-time only.
The Order property determines if points will be automatically sorted or it they will remain always at their original positions.
This Order is used by default by the Series XValues to draw lines from Left to Right.
Setting the XValues.Order property to loNone will respect the points order at point creation.
This can be used to draw polygons.

See also Sort and FillSequence methods.

Note: Some series (like HorizBar series) have a default order of "none" for XValues. They set by default an ascending order to YValues instead of XValues.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Geerten
Newbie
Newbie
Posts: 5
Joined: Wed Feb 16, 2011 12:00 am

Re: Sorting

Post by Geerten » Mon Mar 07, 2011 7:59 am

I misunderstood the labels functionality also. I thought the labels where the sticker's at the top of the bar for example. So, the first solution is the solution is was looking for!

Thanks, and also thanks for the explanation of the sorting functionality.

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Sorting

Post by Yeray » Mon Mar 07, 2011 10:49 am

Hi Geerten,

You're welcome!
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply