How to share the same grid between left and right axis

TeeChart for ActiveX, COM and ASP
Post Reply
David
Advanced
Posts: 203
Joined: Tue Nov 08, 2005 5:00 am

How to share the same grid between left and right axis

Post by David » Fri Nov 03, 2006 5:53 am

Hi,

I have to draw six lines, three using left axis and three using right axis. The problem is that the left and right axis both have seperate grid, which makes the chart look funny. Is there any way the left and right axis can share the same grid?

Thanks a lot!
David

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

Post by Narcís » Fri Nov 03, 2006 8:40 am

Hi David,

They would have the same grid if they shared the very same scale. This can be achieved doing something like this:

Code: Select all

Private Sub Form_Load()
    For i = 0 To TChart1.SeriesCount - 1
        TChart1.Series(i).FillSampleValues 10
    Next
    
    TChart1.Environment.InternalRepaint
End Sub

Private Sub TChart1_OnBeforeDrawAxes()
    Dim Min, Max As Double
    
    With TChart1.Axis
        Max = .Left.Maximum
        Min = .Left.Minimum
        
        If Max < .Right.Maximum Then
            Max = .Right.Maximum
        End If
        
        If Min > .Right.Minimum Then
            Min = .Right.Minimum
        End If
        
        .Left.SetMinMax Min, Max
        .Right.SetMinMax Min, Max
    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

David
Advanced
Posts: 203
Joined: Tue Nov 08, 2005 5:00 am

Post by David » Fri Nov 03, 2006 10:02 am

Hi, Narcís

But the left and right axis have different unit and their range is totally different. Can your method work in this case?

David

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

Post by Narcís » Fri Nov 03, 2006 12:14 pm

Hi David,

Yes, it can work but this may not be the effect you are looking for. Another easy option would be hidding one of the axes grid lines:

Code: Select all

    TChart1.Axis.Left.GridPen.Visible = False
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

David
Advanced
Posts: 203
Joined: Tue Nov 08, 2005 5:00 am

Post by David » Mon Nov 06, 2006 12:47 am

Yeah, it works this way. Thanks a lot!

David

Post Reply