Page 1 of 1
How to share the same grid between left and right axis
Posted: Fri Nov 03, 2006 5:53 am
by 9529132
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
Posted: Fri Nov 03, 2006 8:40 am
by narcis
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
Posted: Fri Nov 03, 2006 10:02 am
by 9529132
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
Posted: Fri Nov 03, 2006 12:14 pm
by narcis
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
Posted: Mon Nov 06, 2006 12:47 am
by 9529132
Yeah, it works this way. Thanks a lot!
David