Page 1 of 1
Null values treated as zero in automatic scale
Posted: Sat Feb 25, 2006 1:15 am
by 9530362
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.
Posted: Wed Mar 01, 2006 5:02 pm
by Pep
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
Posted: Thu Mar 02, 2006 2:07 pm
by 9530362
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.
Posted: Wed Mar 08, 2006 9:50 am
by Pep
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