TChartSeries SortByLabels() - upper case before lower case?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
marder
Advanced
Posts: 115
Joined: Thu May 29, 2008 12:00 am

TChartSeries SortByLabels() - upper case before lower case?

Post by marder » Mon Feb 16, 2009 4:27 pm

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!

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

Post by Yeray » Tue Feb 17, 2009 8:58 am

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).
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

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

Post by Yeray » Tue Feb 17, 2009 9:23 am

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.
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

marder
Advanced
Posts: 115
Joined: Thu May 29, 2008 12:00 am

Post by marder » Tue Feb 17, 2009 10:28 am

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!

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

Post by Yeray » Tue Feb 17, 2009 10:58 am

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.
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

marder
Advanced
Posts: 115
Joined: Thu May 29, 2008 12:00 am

Post by marder » Tue Feb 17, 2009 11:43 am

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!

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

Post by Yeray » Tue Feb 17, 2009 12:45 pm

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.
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

marder
Advanced
Posts: 115
Joined: Thu May 29, 2008 12:00 am

Post by marder » Tue Feb 17, 2009 3:52 pm

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!

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Feb 17, 2009 4:51 pm

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.
Best Regards,
Narcís Calvet / 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

marder
Advanced
Posts: 115
Joined: Thu May 29, 2008 12:00 am

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

Post by marder » Fri Nov 11, 2011 10:13 am

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.

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

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

Post by Yeray » Tue Nov 15, 2011 9:59 am

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.
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

marder
Advanced
Posts: 115
Joined: Thu May 29, 2008 12:00 am

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

Post by marder » Tue Nov 15, 2011 10:53 am

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.

Bert B.
Newbie
Newbie
Posts: 69
Joined: Fri Jun 15, 2007 12:00 am

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

Post by Bert B. » Tue Nov 15, 2011 12:20 pm

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

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

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

Post by Yeray » Tue Nov 15, 2011 3:43 pm

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.
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

marder
Advanced
Posts: 115
Joined: Thu May 29, 2008 12:00 am

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

Post by marder » Tue Nov 15, 2011 4:55 pm

Hello Yeray.

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

Best regards.

Post Reply