bug in OnDragPointToolDragPoint

TeeChart for ActiveX, COM and ASP
Post Reply
amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

bug in OnDragPointToolDragPoint

Post by amol » Thu Nov 02, 2006 4:01 pm

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Nov 02, 2006 4:18 pm

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
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

Post by amol » Thu Nov 02, 2006 5:34 pm

Narcis,

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

Thanks,

HH

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

Post by Pep » Tue Nov 07, 2006 5:24 pm

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

Post Reply