Page 1 of 1

Sorting

Posted: Fri Mar 04, 2011 10:39 am
by 16558579
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 4067 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

Re: Sorting

Posted: Fri Mar 04, 2011 12:56 pm
by yeray
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.

Re: Sorting

Posted: Fri Mar 04, 2011 1:01 pm
by 16558579
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.

Re: Sorting

Posted: Fri Mar 04, 2011 5:09 pm
by yeray
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.

Re: Sorting

Posted: Mon Mar 07, 2011 7:59 am
by 16558579
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.

Re: Sorting

Posted: Mon Mar 07, 2011 10:49 am
by yeray
Hi Geerten,

You're welcome!