how can we sorting chart

TeeChart for ActiveX, COM and ASP
Post Reply
Aravind
Newbie
Newbie
Posts: 75
Joined: Fri Nov 15, 2002 12:00 am

how can we sorting chart

Post by Aravind » Mon Jun 05, 2006 1:15 pm

i need to sort chart by series but labelvalues on the x-axis has to be changed according to sort..

i used this code

TChart1.series(i).YValues.Order = loDescending
TChart1.series(i).YValues.Sort
TChart1.series(i).XValues.FillSequence

series was sorted but on the bottom is showing for wrong label

ie,

on x-axis i have plotted 2008,2009,2010
on y-axis volume

and have 5 series and i need to sort on the last series descending

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 Jun 06, 2006 8:36 am

Hi Aravind,

This is because the axes labels drawn correspond to the first series. You should try chaning your last series to first series:

Code: Select all

ExchangeSeries(Series1, Series2: Integer);
This method changes the Series order, swapping one Series Z position with another. The Chart repaints to reflect the new Series order. It accesses TChart.SeriesList property.
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

Aravind
Newbie
Newbie
Posts: 75
Joined: Fri Nov 15, 2002 12:00 am

while sorting some data marks visible outside the graph

Post by Aravind » Wed Jun 07, 2006 10:13 am

while sorting , some data marks are appearing outside the graph

i used following code

For i = 0 To TChart1.SeriesCount - 1
TChart1.series(i).XValues.Order = loNone
TChart1.series(i).YValues.Order = loDescending
TChart1.series(i).YValues.Sort
TChart1.series(i).XValues.FillSequence
Next i
TChart1.Repaint

tchart1.Page.MaxPointsPerPage=5

i have enclosed tee file in your newsgroup

pls advise me on this

aravind

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

Post by Narcís » Wed Jun 07, 2006 10:58 am

Hi Aravind,

You can clip them using this code:

Code: Select all

Private Sub TChart1_OnBeforeDrawSeries()
    TChart1.Canvas.ClipRectangle TChart1.Axis.Left.Position, _
                                TChart1.Axis.Top.Position - TChart1.Aspect.Height3D, _
                                TChart1.Axis.Right.Position + TChart1.Aspect.Width3D, _
                                TChart1.Axis.Bottom.Position
End Sub
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

Aravind
Newbie
Newbie
Posts: 75
Joined: Fri Nov 15, 2002 12:00 am

still some part of the bar inside is shown on the corners

Post by Aravind » Wed Jun 07, 2006 11:25 am

still some part of the bar is shown inside the chart

for example :

i have kept the max no of points is 5 , do sorting then ur masked code works fine trim outter area but the 6th point is shown half on the corner of the chart ( half bar is visible )

aravind

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

Post by Pep » Fri Jun 09, 2006 8:24 am

Hi aravind,

it works fine here using the following code, could you please check if it works fine for you ? :

Code: Select all

Private Sub Form_Load()
With TChart1
    .Series(0).FillSampleValues (10)
    For i = 0 To TChart1.SeriesCount - 1
        .Series(i).YValues.Order = loDescending
        .Series(i).YValues.Sort
        .Series(i).XValues.FillSequence
    Next i

    .Page.MaxPointsPerPage = 5
End With
End Sub

Aravind
Newbie
Newbie
Posts: 75
Joined: Fri Nov 15, 2002 12:00 am

there is another issue

Post by Aravind » Fri Jun 09, 2006 12:11 pm

when i used the code which you have given , the page number ,data table are masked too ... apart from the outer region ...

how can we avoid this issue pls advise me
thanks
aravind

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

Post by Narcís » Mon Jun 12, 2006 11:09 am

Hi Aravind,

There's a simpler solution then, which is using TChart1.Series(i).Marks.Clip=True:

Code: Select all

Private Sub Form_Load()
    ChartPageNavigator1.Chart = TChart1
    With TChart1
        For i = 0 To 4
            .AddSeries scLine
            .Series(i).FillSampleValues (10)
            .Series(i).Marks.Visible = True
        Next
        
        For i = 0 To TChart1.SeriesCount - 1
            .Series(i).YValues.Order = loDescending
            .Series(i).YValues.Sort
            .Series(i).XValues.FillSequence
            .Series(i).Marks.Clip = True
        Next i
    
        .Page.MaxPointsPerPage = 5
    End With
End Sub
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

Post Reply