How to Sort Series

TeeChart for ActiveX, COM and ASP
Post Reply
Tom.K
Newbie
Newbie
Posts: 8
Joined: Tue Aug 30, 2005 4:00 am

How to Sort Series

Post by Tom.K » Wed Nov 30, 2005 9:30 pm

Hi,

In my cahrt I have two series. Series 0 and Series 1.

Series 0 is a line chart and series 1 is bar chart.

Series 1 is based on series 0 data and should be sorted in ascending or decending order on the fly by clicking on an option button "decending/ascending" by the end user.

How do I do this by code.

Thanks

Tom.K

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Dec 01, 2005 10:46 am

Hi Tom,

you can find one example which shows how to do this into the Features Demo project (included with the TeeChart Pro installation), just do a search for "Sort" and you will find an example named "Sort Order".

Tom.K
Newbie
Newbie
Posts: 8
Joined: Tue Aug 30, 2005 4:00 am

Post by Tom.K » Thu Dec 01, 2005 7:44 pm

Hi,

I was aware of this sample and have tested it and it is working when you are using database connectivity on your series. My series 1 is not database connected its source is series 0 which is database connected. Bassed on the series 0 data I do some calculations and
display the output in series 1 and then sort it (not label sort).
Series 1 is a bar chart.

Using this sample sort method to series 1 will not work. It only works for database connections.

I am using TChartax 7.005.

Regards,

Tom.K

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Fri Dec 02, 2005 6:36 pm

Hi Tom,

you should be able to sort the Bars without having a database connectivity, using for example the following code :

Code: Select all

Private Sub Command1_Click()
With TChart1
  .Series(0).XValues.Order = loDescending
  .Series(0).XValues.Sort
  .Series(0).XValues.FillSequence
  .Repaint
End With
End Sub

Tom.K
Newbie
Newbie
Posts: 8
Joined: Tue Aug 30, 2005 4:00 am

Post by Tom.K » Sun Dec 04, 2005 4:19 am

Hi Josep,

Thanks for your prompt reply. I created a simple TChart project with a bar series and used fillsamplevalues to populate the chart. I then added command button 1 and pasted your code behing it.

When I ran the charet and clicked command button 1, all it did was reverse the series order it did not sort the data in acending or decening order, which is what I am after.

Please, I am desperate surely this is a simple procedure. How do I accomplish the series sorting?

Kind regards,

Tom.K

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Fri Dec 09, 2005 11:23 am

Hi Tom,

sorry, I mistake me in the code. The following code works fine here :

Code: Select all


Private Sub Command1_Click()
With TChart1
  .Series(0).YValues.Order = loAscending
  .Series(0).YValues.Sort
  .Series(0).XValues.FillSequence
  .Repaint
End With

End Sub

Private Sub Form_Load()
TChart1.Series(0).FillSampleValues (5)
With TChart1
   .Series(0).XValues.Order = loNone
   .Series(0).YValues.Order = loNone
End With
End Sub

Post Reply