Null values treated as zero in automatic scale

TeeChart for ActiveX, COM and ASP
Post Reply
Paul2
Newbie
Newbie
Posts: 7
Joined: Fri Feb 17, 2006 12:00 am

Null values treated as zero in automatic scale

Post by Paul2 » Sat Feb 25, 2006 1:15 am

I have a series for which some values are missing. I add them as nulls, which works fine. But the left axis for this series is set to automatic, and the nulls set the axis scale minimum to zero even though the rest of the data is in the range of 400-500. That totally ruins the scale of the graph.

Null values should not affect automatic scaling.

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Mar 01, 2006 5:02 pm

Hi,

a solution for this would be to loop through your series deleting the
Null points - the points before and after the Nulls will then automatically
join up, e.g.

Code: Select all

Private Sub Command1_Click()
With TChart1
    For i = 0 To .Series(0).Count - 1
        If .Series(0).IsNull(i) Then
            .Series(0).Delete i
        End If
    Next i
End With
End Sub

Private Sub Form_Load()
With TChart1.Series(0)
    .AddNull ""
    .AddXY 300, 10, "", clTeeColor
    .AddXY 350, 10, "", clTeeColor
    .AddXY 400, 10, "", clTeeColor
End With
End Sub

Paul2
Newbie
Newbie
Posts: 7
Joined: Fri Feb 17, 2006 12:00 am

Post by Paul2 » Thu Mar 02, 2006 2:07 pm

Thanks. However, I am using the stairstep option on this graph, so I do not want the points to join up. The data is missing, so I want it to appear missing.

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Mar 08, 2006 9:50 am

Hi Paul,

in that case you could use similar code to the following :

Code: Select all

Private Sub Form_Load()
With TChart1.Series(0)
    .AddNullXY 5, 0, ""
    .AddXY 300, 10, "", clTeeColor
    .AddXY 350, 20, "", clTeeColor
    .AddXY 400, 40, "", clTeeColor
End With

With TChart1
    vmin = .Series(0).YValues.Maximum
    For i = 0 To .Series(0).Count - 1
        If Not .Series(0).IsNull(i) Then
            If .Series(0).YValues.Value(i) < vmin Then
                vmin = .Series(0).YValues.Value(i)
            End If
        End If
    Next i
    .Axis.Left.SetMinMax vmin, .Series(0).YValues.Maximum
End With
End Sub

Post Reply