Bug in log axis........???

TeeChart for ActiveX, COM and ASP
Post Reply
John Morley
Newbie
Newbie
Posts: 1
Joined: Thu Apr 12, 2001 4:00 am

Bug in log axis........???

Post by John Morley » Thu Feb 05, 2004 3:47 pm

Hi,

I am using the following code in a VB6 application to generate a graph
with a logarithmic x-axis. The x-axis in this example goes from 10^3 to
10^4. The problem I am having is that the minor grid lines that are
generated by this code are not being positioned correctly. In my example,
minor grid lines are drawn at 2000, 4000, 6000 and 8000. In the case of
the 2000 line (for example), it should appear at a point on the graph that
is 30% of the total graph (log(1000) = 3.0, log(2000) = 3.3 and log(10000)
= 4, thus 2000 occurs 0.3 or 30% along the x-axis), but it really appears
at a point about 45% of the total graph. The problem does not change when I try a different number of minor ticks. A sample graph can be seen at http://www.analysistech.com/images/tchart.jpg to see what I mean! Am I doing something wrong, or is there a bug in the TeeChart code??

BTW, I'm using Teechart5.ocx version 5.0.3.1.

Thanks,

John


Example Code

'here is the Steema code (not working) to do this.....
.Axis.Bottom.Logarithmic = True
.Axis.Bottom.MinorGrid.Visible = True
.Axis.Bottom.SetMinMax 10 ^ xLoLog, 10 ^ xHiLog
.Axis.Bottom.MinorTicks.Visible = True
.Axis.Bottom.MinorTickCount = 4
.Axis.Bottom.Labels.ValueFormat = "0E-0"
.Axis.Bottom.Increment = 0

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Fri Feb 06, 2004 1:58 pm

Hi John,
A sample graph can be seen at http://www.analysistech.com/images/tchart.jpg to see what I mean! Am I
doing something wrong, or is there a bug in the TeeChart code??
The MinorGrids are drawn at every MinorTick specified and these MinorTicks are drawn in relation to the axes and not to the series points. For example, let's have a look at the code below:

Code: Select all

Private Sub Form_Load()
With TChart1
    .Aspect.View3D = False
    .AddSeries scLine
    For i = 1000 To 10000 Step 1000
        .Series(0).AddXY i, Rnd * 100, "", clTeeColor
    Next i

    .Axis.Bottom.Logarithmic = True
    .Axis.Bottom.Labels.Angle = 90

    .Axis.Bottom.Increment = 0
    .Axis.Bottom.MinorGrid.Visible = True
    .Axis.Bottom.MinorTickCount = 2
End With
End Sub
Here, the bottom axis minimum value is 1000 and the maximum 10000;
specifying a MinorTickCount of 2 will mean an internal calculation like
this:
10000 - 1000 = 9000 / 3 (i.e. two MinorTicks divides an axis into 3 equal
value regions) = 3000
So MinorTicks will be drawn at 4000 (1000 + 3000) and 7000 (4000 + 3000).

If we now run code like this:

Code: Select all

Dim Flag As Boolean

Private Sub Command1_Click()
With TChart1
    If Flag = True Then
        .Axis.Bottom.Increment = 1000
        .Axis.Bottom.MinorGrid.Visible = False
        Flag = False
    Else
        .Axis.Bottom.Increment = 0
        .Axis.Bottom.MinorGrid.Visible = True
        .Axis.Bottom.MinorTickCount = 8
        Flag = True
    End If
End With
End Sub

Private Sub Form_Load()
Flag = True
With TChart1
    .Aspect.View3D = False
    .AddSeries scLine
    For i = 1000 To 10000 Step 1000
        .Series(0).AddXY i, Rnd * 100, "", clTeeColor
    Next i

    .Axis.Bottom.Logarithmic = True
    .Axis.Bottom.Labels.Angle = 90
End With
End Sub
We can see how the MinorTicks/Grid are drawn correctly.
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Post Reply