Page 1 of 1

Keeping of aspect ratio while zooming

Posted: Fri Jan 11, 2008 11:32 am
by 15046980
Hi,

I want to keep aspect ratio while zooming. How can I do this using VBScript?

Thanks in advance,
Danila.

Posted: Fri Jan 11, 2008 11:37 am
by narcis
Hi Danila,

You could try doing something as in the Isometric Axis example at All Features\Welcome!\Axes in the features demo available at TeeChart's program group.

Posted: Fri Jan 11, 2008 12:46 pm
by 15046980
Hi NarcĂ­s,

thank you for the fast reply. I have tested this example, but it does not work like zoom tool.

I want just "freeze one degree of freedom" of zoom tool (to make proportional X and Y). Is it possible with standart mechanisms of teechart?

Thanks in advance,
Danila.

Posted: Fri Jan 11, 2008 2:07 pm
by narcis
Hello Danila,

Sorry but I don't what are you trying to achieve exactly. Could you please give us some more details?

Thanks in advance.

Posted: Fri Jan 11, 2008 2:15 pm
by 15046980

Posted: Fri Jan 11, 2008 2:33 pm
by narcis
Hi Danila,

In that case you can do something like this:

Code: Select all

Option Explicit

Dim XRatio As Double

Private Sub Form_Load()
    TChart1.Series(0).FillSampleValues 10
    
    TChart1.Environment.InternalRepaint
    
    XRatio = GetXRatio()
End Sub

Private Function GetXRatio() As Double
    GetXRatio = ((TChart1.Axis.Bottom.Maximum - TChart1.Axis.Bottom.Minimum) _
                / (TChart1.Axis.Left.Maximum - TChart1.Axis.Left.Minimum))
End Function


Private Sub TChart1_OnZoom()
    Dim CurrentXRatio As Double
    
    CurrentXRatio = GetXRatio()
    
    If (CurrentXRatio <> XRatio) Then
        TChart1.Axis.Left.Maximum = (TChart1.Axis.Bottom.Maximum - TChart1.Axis.Bottom.Minimum + _
                                    (TChart1.Axis.Left.Minimum * XRatio)) / XRatio
    End If
End Sub
Hope this helps!