Sort order of bar graphs using DBCrossTabSource

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
jon bondy
Newbie
Newbie
Posts: 9
Joined: Fri Nov 15, 2002 12:00 am

Sort order of bar graphs using DBCrossTabSource

Post by jon bondy » Mon May 20, 2013 1:08 pm

I am trying to maintain some code that I inherited, so I do not entirely understand what I am reading. In addition, I have been unable to find any documentation about DBCrossTabSource either online or in the Help that came with the product. Perhaps someone can point me at the documentation.

When I use DBCrossTabSource, I see a number of bar graphs, each with a title/label. Unfortunately, if labels exist for "A", "B", and "C", they often appear as "B", "C", and then "A". That is, they are not correctly sorted.

Is there any way to have the graphs appear in alphabetical order, instead of randomly?

I am using 7.12 for Delphi 2007

Thanks!

Jon

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

Re: Sort order of bar graphs using DBCrossTabSource

Post by Yeray » Tue May 21, 2013 7:58 am

Hi,

Try with SortByLabels function. Ie, for the first series in a chart:

Code: Select all

Chart1[0].SortByLabels(); 
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

jon bondy
Newbie
Newbie
Posts: 9
Joined: Fri Nov 15, 2002 12:00 am

Re: Sort order of bar graphs using DBCrossTabSource

Post by jon bondy » Tue May 21, 2013 9:45 pm

Thanks for your help! I tried this, but I'm using a DBChart, and the code that you suggested does not compile. That is "DBChart1.SortByLabels" does not work.

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

Re: Sort order of bar graphs using DBCrossTabSource

Post by Yeray » Wed May 22, 2013 8:10 am

Hi,

DBChart1.SortByLabels not! DBChart1[0].SortByLabels. DBChart1[0] is the first series in the DBChart1 chart.
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

jon bondy
Newbie
Newbie
Posts: 9
Joined: Fri Nov 15, 2002 12:00 am

Re: Sort order of bar graphs using DBCrossTabSource

Post by jon bondy » Wed May 22, 2013 1:02 pm

Thank you, again! That does compile, but the charts still appear in an un-sorted order, as can be seen in the attached screen shot. I would like the Quarters to ascend uniformly
Attachments
dbChart.PNG
dbChart.PNG (23.64 KiB) Viewed 7294 times

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

Re: Sort order of bar graphs using DBCrossTabSource

Post by Yeray » Thu May 23, 2013 9:02 am

Hi,

I'm not sure if this is how you are creating your charts:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;
  Chart1.Legend.Visible:=false;

  with Chart1.AddSeries(THorizBarSeries) as THorizBarSeries do
  begin
    Marks.Visible:=false;

    Add(1, 'Post-analytic');
    Add(14, 'Analytic');
    Add(18, 'No error, or not yet classified');
    Add(207, 'Pre-analytic');

    //SortByLabels(loDescending);
  end;
end;
With the above, I get this:
unsorted.png
unsorted.png (6.58 KiB) Viewed 7291 times
Then, if I uncomment the SortByLabels(loDescending) line in the code above, this is what I get:
sorted.png
sorted.png (6.6 KiB) Viewed 7281 times
Isn't it how it behaves for you?
If you still find problems with it, please try to arrange a simple example project we can run as-is to reproduce the problem here.
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

jon bondy
Newbie
Newbie
Posts: 9
Joined: Fri Nov 15, 2002 12:00 am

Re: Sort order of bar graphs using DBCrossTabSource

Post by jon bondy » Thu May 23, 2013 9:54 am

Thank you, again, for your help.

I am not trying to change the order of the bars within the charts. I am trying to change the order of the charts on the page.

The current order is

Quarter: 2005.1
Quarter: 2004.4
Quarter: 2003.1
Quarter: 2004.3

This order makes it difficult to find a particular chart, because the order appears to be random.

I imagine that the charts are in this order because they are sorted by Total Count, but I want the option of sorting them by their labels (Quarter: 2005.1)

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

Re: Sort order of bar graphs using DBCrossTabSource

Post by Yeray » Thu May 23, 2013 11:03 am

Hi,

Please, try to arrange a simple example project we can run as-is to reproduce the problem here.
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

jon bondy
Newbie
Newbie
Posts: 9
Joined: Fri Nov 15, 2002 12:00 am

Re: Sort order of bar graphs using DBCrossTabSource

Post by jon bondy » Thu May 23, 2013 6:02 pm

I did as you asked, and am now thinking that the problem is in some other code. Thank you for your time and help, but I doubt that the problem is in TeeChart.

Post Reply