Page 1 of 1

How to Sort Series

Posted: Wed Nov 30, 2005 9:30 pm
by 9528174
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

Posted: Thu Dec 01, 2005 10:46 am
by Pep
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".

Posted: Thu Dec 01, 2005 7:44 pm
by 9528174
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

Posted: Fri Dec 02, 2005 6:36 pm
by Pep
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

Posted: Sun Dec 04, 2005 4:19 am
by 9528174
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

Posted: Fri Dec 09, 2005 11:23 am
by Pep
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