[Bug report] "Crazy" cursor tool

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
bertrod
Advanced
Posts: 151
Joined: Wed Sep 07, 2005 4:00 am

[Bug report] "Crazy" cursor tool

Post by bertrod » Wed Dec 06, 2006 1:40 pm

Hello,

I've had a problem with the cursortool using fastlineseries with very large values.

When I was moving the CursorTool (cssBoth style), it was jumping everywhere. The problem is in the function TCursorTool.NearestPoint() :

Code: Select all

tmpDif:=Sqrt(Sqr(IXValue-XValues.Value[t])+Sqr(IYValue-YValues.Value[t]));
I guess calculating Sqr of very large numbers causes problems (maybe the result exceed the Double range or something.

I could correct this bug this way :

In the Function TCursorTool.SnapToPoint() :

CHANGED

Code: Select all

if Assigned(Series) and FSnap then result:=NearestPoint(FStyle,Difference)
INTO

Code: Select all

if Assigned(Series) and FSnap then result:=NearestPoint(cssVertical,Difference)
Of course the behaviour of the cursorTool is not exactly the same as it moves like if it was cssVertical, but at least it doesn't jump everywhere.


I'm sorry because I didn't have much time to really test this bug, but I wanted to report you this problem.

Yours.

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

Post by Pep » Thu Dec 07, 2006 8:15 pm

Hi bertrod,

do you have a code with which I can reproduce the problem here ?

bertrod
Advanced
Posts: 151
Joined: Wed Sep 07, 2005 4:00 am

Post by bertrod » Tue Dec 12, 2006 12:23 pm

Pep wrote:do you have a code with which I can reproduce the problem here ?
No, as it's not a code that produce the bug. I opened a series with Y Values between 10k and 70k and I was using the TCursorTool.

SteveP
Advanced
Posts: 132
Joined: Sun Sep 07, 2003 4:00 am

Post by SteveP » Tue Dec 12, 2006 1:28 pm

FollowMouse and Snap are set True.
for i := 0 to 100 do series1.AddY(10000 + random(60000));

As the cursor is moved say slightly up along the Y axis, the cursor's X position might jump far away from its current position. This is because there is another X,Y pair whose Y data value is nearer to the new cursor's value. It sounds like you might be wanting to move the cursor along the X axis and track only the X data value but show a horizontal line across the chart in order to visually determine the Y data value that corresponds to the X cursor location.

If this is what is wanted, you can use the cursortool's OnChange or OnSnapChange event to determine the data Y value. use another CursorTool with FollowMouse and Snap set false and Style set Horizontal or a ColorLine tool with Axis set to Left in order to draw or indicate the Y position :

charttool2.YValue := series1.YValue[ValueIndex];
charttool3.Value := series1.YValue[ValueIndex];
label1.caption := floattostr(series1.YValue[ValueIndex]);

I believe the CursorTool Color is XOR'd with existing colors so its color might not be what it is defined as. The ColorLine tool's color is not XOR'd and can be made to appeaar brighter than the CursorTool. Play with those aspects.

Steve

bertrod
Advanced
Posts: 151
Joined: Wed Sep 07, 2005 4:00 am

Post by bertrod » Tue Dec 12, 2006 3:04 pm

Hi Steve,

Thanks for your explanation. I think you're right, I can see the source of the problem now. It's also a good idea to use 2 cursors, but I guess I will keep my little correction :wink:

Post Reply