Page 1 of 1

bug in OnDragPointToolDragPoint

Posted: Thu Nov 02, 2006 4:01 pm
by 9526439
Dear support,

In my application, I used a horizontal series and one drag point tool. When the values (x axis values) change the drag point tool works fine. But when the values are constant, the chart becomes erratic when I drag one point with the following code. Apprently the teechart code found the wrong index.

for(i=0;i<10;i++)
{
m_Chart1.Series(0).Add(1000,"",clTeeColor);
}

void aaa::OnOnDragPointToolDragPointTchart1(long Index)
{
// TODO: Add your control notification handler code here
double Data=m_Chart1.Series(0).GetPointValue(Index);
if(Data<0)
m_Chart1.Series(0).SetPointValue(Index,0);
//GetPointValue(Index);

}
if I change the value from 1000 to 1, the code seems works fine.

Thanks,

hh

Posted: Thu Nov 02, 2006 4:18 pm
by narcis
Hi bchatt,

I could reproduce this problem here. This is because the left axis only has one value. This implies that the left axis minimum and maximum values are the same and has no scale and this makes the chart behave like this when dragging a point. A solution to it is manually setting left axis minimum and maximum values:

Code: Select all

Private Sub Form_Load()
    With TChart1.Series(0)
        For i = 0 To 9
            .Add 1000, "", clTeeColor
        Next
        
        TChart1.Axis.Left.SetMinMax .YValues.Minimum - 100, .YValues.Maximum + 100
    End With
End Sub

Private Sub TChart1_OnDragPointToolDragPoint(ByVal Index As Long)
    Dim Data As Double
    
    Data = TChart1.Series(0).PointValue(Index)
    
    If Data < 0 Then
        TChart1.Series(0).PointValue(Index) = 0
    End If
End Sub

Posted: Thu Nov 02, 2006 5:34 pm
by 9526439
Narcis,

The solution you provided doesn't work when user wants to drag to a larger number. You can see what happens.

Thanks,

HH

Posted: Tue Nov 07, 2006 5:24 pm
by Pep
Hi,

yes, you're correct, it is a bug, it happens with horiz. point Series, I've added down our defect list and a fix for it will be considered to inclusion for the next maintenance releases.
In meantime a workaround is to change the Axis min and max manually :

Code: Select all

Private Sub Form_Load()
    With TChart1.Series(0)
        For i = 0 To 9
            .Add 1000, "", clTeeColor
        Next
        TChart1.Axis.Bottom.SetMinMax .XValues.Minimum - 100, .XValues.Maximum + 100
    End With
End Sub

Private Sub TChart1_OnDragPointToolDragPoint(ByVal Index As Long)
    Dim Data As Double
    
    If TChart1.Series(0).XValues.Value(Index) > TChart1.Axis.Bottom.Maximum Then
        TChart1.Axis.Bottom.Maximum = TChart1.Series(0).XValues.Value(Index)
    End If
    If TChart1.Series(0).XValues.Value(Index) < TChart1.Axis.Bottom.Minimum Then
        TChart1.Axis.Bottom.Minimum = TChart1.Series(0).XValues.Value(Index)
    End If
    
    Data = TChart1.Series(0).PointValue(Index)
    
    If Data < 0 Then
        TChart1.Series(0).PointValue(Index) = 0
    End If
End Sub