Page 1 of 1

Axis, calculate the increment property

Posted: Fri Mar 31, 2006 4:56 am
by 9530613
Hello,

I want to calculate increment in the following way:

Code: Select all

        With sourceChart.Axis
            Dim min, max As Double
            
            .Left.Visible = True
            .Left.Automatic = True

            min = .Left.Minimum
            max = .Left.Maximum
            .Left.Increment = (max - min) / 5
        End With
but TChart show labels as as if Increment property is equal zero.
But if to set the breakpoint on line 'min = .Left.Minimum' (in VBA editor) when the Increment property is calculating correctly.

What is it and what it would be necessary to make that the increment was calculated always ?

Best regards, Rustam.

Posted: Fri Mar 31, 2006 8:44 am
by narcis
Hi Rustam,

When are you running this code? The problem may be that the original axis scales are still not calculated because the chart is not drawn yet. You could do several events combinations to achieve that but using the code below, which uses InternalRepaint to force the chart being drawn, works fine here.

Code: Select all

Private Sub Form_Load()
    TChart1.Series(0).FillSampleValues 100
    
    TChart1.Environment.InternalRepaint

    With TChart1.Axis
        Dim min, max As Double

        .Left.Visible = True
        .Left.Automatic = True

        min = .Left.Minimum
        max = .Left.Maximum
        .Left.Increment = (max - min) / 5
    End With
End Sub

Posted: Fri Mar 31, 2006 10:21 am
by 9530613
Thanks. It has helped me.