Page 1 of 2

TChartSeries SortByLabels() - upper case before lower case?

Posted: Mon Feb 16, 2009 4:27 pm
by 10049140
Hi.

I noticed that the function SortByLabels() of TChartSeries sorts not correct alphabetically:
Image

All labels that starts with an upper case char will be sorted before any lower case chars. That means "Zap" will be located before "apple"!

I am using TeeChart V8.04.

Is this a known issue?
Can you provide a solution for this behavior.

Thanks!

Posted: Tue Feb 17, 2009 8:58 am
by yeray
Hi marder,

Well, as you probably know, "A" and "a" have different ascii codes and that's why they are considered as different characters.

Anyway, I've added it to the wish list to be studied as a possible enhancement for further releases (TV52013868).

Posted: Tue Feb 17, 2009 9:23 am
by yeray
Hi again marder,

For now, the only thing I think you could do would be forcing all the labels to start with uppercase or downcase, as you prefer.

Posted: Tue Feb 17, 2009 10:28 am
by 10049140
Hi Yeray
Well, as you probably know, "A" and "a" have different ascii codes and that's why they are considered as different characters.
Yes, I am aware of that, but I would expect a correct alphabetic sorting like this:
"airport", "Austarlia", "bag", "Berlin"

Your chart does it like this:
"Austarlia", "Berlin", "airport", "bag"
which is not really usable.
For now, the only thing I think you could do would be forcing all the labels to start with uppercase or downcase, as you prefer.
I use the chart to show files of a file system, which can ether start with a lower or upper case. It is no solution for me to modify the file names before adding them to the chart!

Is there no other way to sort the values correctly?
Maybe with a custom compare function for chart values?

Thanks!

Posted: Tue Feb 17, 2009 10:58 am
by yeray
Hi marder,

No, you don't need to change your file names, only the chart labels. For example:

Code: Select all

  for i:=0 to Series1.Count-1 do
    Series1.Labels[i]:=LowerCase(Series1.Labels[i]);
I hope it helps.

Posted: Tue Feb 17, 2009 11:43 am
by 10049140
Hi Yeray.
No, you don't need to change your file names, only the chart labels.
I know what you mean. I got this.
With my post before I meant that it is now solution for me to show modified file names (not actually modify the file names physically).
Sorry if my post was unclear.

The problem is:
1. The user will wonder why all his files are shown in lower case.
2. Not all file systems are case insensitive (e.g. Unix/Linux). When I try to trigger any action (e.g.: Open the file when double click on the slice) the application will not be able to detect the file based on the labels.

So, are there any other alternatives for this issue?

Thanks for you time!

Posted: Tue Feb 17, 2009 12:45 pm
by yeray
Hi marder,

Well, while the enhancement isn't implemented, you always can:

1. Do a copy of the original filenames in a array of strings.

2. Change the labels to downcase as suggested before to achieve your desired order.

3. Show the text from your array using OnGetMarkText.

Posted: Tue Feb 17, 2009 3:52 pm
by 10049140
Ok.

Do you think that this enhancement will be implemented in one of the next releases?
Do you have any idea when this release will be public?

Thanks and best regards!

Posted: Tue Feb 17, 2009 4:51 pm
by narcis
Hi marder,
Do you think that this enhancement will be implemented in one of the next releases?
We can not guarantee that, it's too early. It has just been reported today, it's a quite specific need and there's a workaround available.
Do you have any idea when this release will be public?


A date hasn't been fixed yet but I think a new maintenance release could be available by the end of this quarter or beginning of 2nd quarter.

Re: TChartSeries SortByLabels() - upper case before lower case?

Posted: Fri Nov 11, 2011 10:13 am
by 10049140
Hi again.

I am currently updating to Delphi XE2 and within this process I did update TeeChart Pro to V2011.
I am very sad to see, that "SortByLabels" still sorts incorrectly.

Could you please tell me why this function was not corrected in the last 2 years?
Is there now a way to do use a custom compare function of to obtain a comparer object to the series?

Thanks and best regards.

Re: TChartSeries SortByLabels() - upper case before lower case?

Posted: Tue Nov 15, 2011 9:59 am
by yeray
Hello marder,

I've checked it and added a new property Labels.IgnoreCase, false by default. Setting it to true makes the SortByLabels function to be case sensitive.
For example, this code shows the bars in the "AaBb" order:

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.AddSeries(TBarSeries);
  Chart1[0].Add(1,'a');
  Chart1[0].Add(2,'A');
  Chart1[0].Add(3,'b');
  Chart1[0].Add(4,'B');

  Chart1[0].Labels.IgnoreCase:=true;
  Chart1[0].SortByLabels(loAscending);
end;
And calling SortByLabels(loDescending) shows the bars in the contrary order "bBaA".
This will be available with the next maintenance release.

Re: TChartSeries SortByLabels() - upper case before lower case?

Posted: Tue Nov 15, 2011 10:53 am
by 10049140
Dear Yeary.

That’s exactly what I was looking for!
Thanks for the fast reply and the prompt implementation!

Do you have any idea when this release will be available (Later this year?)?
Is there a chance to get a prerelease version?

Best regards.

Re: TChartSeries SortByLabels() - upper case before lower case?

Posted: Tue Nov 15, 2011 12:20 pm
by 9350556
Hello,

If the following change hasn't been sent to customers already,

Code: Select all

Chart1[0].Labels.IgnoreCase:=true;
I would suggest to call the property CaseSensitive, like the property of TStringList.

Regards,
Bert

Re: TChartSeries SortByLabels() - upper case before lower case?

Posted: Tue Nov 15, 2011 3:43 pm
by yeray
Hello,
marder wrote:Do you have any idea when this release will be available (Later this year?)?
Is there a chance to get a prerelease version?
I'm afraid I can't tell you a date for the next maintenance release. But I think as soon as we'll have finished fixing the problems the support for XE2 presented.
If you are a source code customer we can send you the units modified. But I think you aren't, so I'm afraid you'll have to wait for the next maintenance release, hopefully not so long.
Bert B. wrote:I would suggest to call the property CaseSensitive, like the property of TStringList.
Right, it's more consistent. Just modified.
The editor will also have a checkbox to the series editor to access it.

Re: TChartSeries SortByLabels() - upper case before lower case?

Posted: Tue Nov 15, 2011 4:55 pm
by 10049140
Hello Yeray.

I actually updated to source code edition a few weeks ago (when updating to TeeChart V2011).

Best regards.