Chart Unexpectedly changes color with mouse movement

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
VideoTrack
Newbie
Newbie
Posts: 5
Joined: Thu Jan 14, 2016 12:00 am

Chart Unexpectedly changes color with mouse movement

Post by VideoTrack » Mon Aug 01, 2016 2:42 pm

One of the IDE's I need to maintain is Delphi 6. I also have XE2, Seattle and Berlin 10.1

I recently upgraded to Steema TeeChartVCLFMXSOURCE-2016.18
The installation went ahead without issue, including the D6 build. All OK.

Now after recompiling my software that uses the D6 IDE, sometimes when I mouse move over a chart area it completely changes color, not always, but most times.
It's quite unpredictable, sometimes when the mouse is only over the chart grid area itself, sometimes when the mouse is anywhere over the chart it suddenly completely changes color.

There is a mouse-move event associated with the chart to draw cross-hairs. That procedure has been there untouched for a long time.

Code: Select all

//OnMouseMove Event code:

procedure TTTGraphPagesDlg.Estimated_TT_D2_ChartMouseMove(Sender: TObject;   Shift: TShiftState; X, Y: Integer);
{ This procedure draws the crosshair lines }
procedure DrawCross(AX,AY:Integer);
begin
  with Estimated_TT_D2_Chart,Canvas do
  begin
    Pen.Color:=CrossHairColor;
    Pen.Style:=CrossHairStyle;
    Pen.Mode:=pmXor;
    Pen.Width:=1;
    MoveTo(ax,Estimated_TT_D2_Chart.ChartRect.Top-Height3D);
    LineTo(ax,Estimated_TT_D2_Chart.ChartRect.Bottom-Height3D);
    MoveTo(Estimated_TT_D2_Chart.ChartRect.Left+Width3D,ay);
    LineTo(Estimated_TT_D2_Chart.ChartRect.Right+Width3D,ay);
  end;
end;
var
tmpX, tmpY : Double;
ix : Integer;
Lbl : ShortString;
ReturnedHMS : THrsMinSec;
{start of code}
begin
  if (C2OldX<>-1) then
  begin
    DrawCross(C2OldX,C2OldY);  { draw old crosshair }
    C2OldX:=-1;
  end;

  { check if mouse is inside Chart rectangle }
  if PtInRect( Estimated_TT_D2_Chart.ChartRect, Point(X-Estimated_TT_D2_Chart.Width3D,Y+Estimated_TT_D2_Chart.Height3D)  ) then
  begin
    DrawCross(x,y);  { draw crosshair at current position }
    { store old position }
    C2OldX:=x;
    C2OldY:=y;
    { set label text }
    With Estimated_TT_D2_Chart.Series[2] do
      begin
      GetCursorValues(tmpX,tmpY); { <-- get values under mouse cursor }
      ix := trunc(tmpx);
      Lbl := Format('%2.2d:%2.2d', [(ix div 60),(ix mod 60)]);
      ReturnedHMS := Extended2HrsMinSec(tmpY*60);
      end; {With Estimated_TT_D2_Chart.Series[2]}
  end {if PtInRect}
  else
  StatusBar2.simpleText:= '';

end; {procedure}
Please see attached images that show what happens to the chart display.

Any ideas what has caused this?
____________________________________________
Attachments
TeeChartNegativeFillColor_2.jpg
TeeChartNegativeFillColor_2.jpg (135.42 KiB) Viewed 14484 times
TeeChartNegativeFillColor_1.jpg
TeeChartNegativeFillColor_1.jpg (152.21 KiB) Viewed 14447 times
TeeChartNegativeFillColor.jpg
TeeChartNegativeFillColor.jpg (175.44 KiB) Viewed 14445 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Chart Unexpectedly changes color with mouse movement

Post by Sandra » Tue Aug 02, 2016 12:03 pm

Hello VideoTrack,

Many thanks for the code you have sent us.

Could you attach for us the complete project? Or could you arrange for us a simple project where the problem appears?
We need reproduce exactly the problem here.

Thanks for your help,
Best Regards,
Sandra Pazos / 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

VideoTrack
Newbie
Newbie
Posts: 5
Joined: Thu Jan 14, 2016 12:00 am

Re: Chart Unexpectedly changes color with mouse movement

Post by VideoTrack » Wed Aug 03, 2016 3:03 am

Hello Sandra

Thanks

I created a small project using all the same settings, and can get the problem to occur with this project, especially when moving the cursor near the scale graduation marks

It may be downloaded as a zip from this link:
https://www.dropbox.com/s/e0e3oaekzsm76 ... s.zip?dl=0

Thanks
Trevor
Attachments
2016-08-03_12-46-42.jpg
Entire chart colors unexpectedly change
2016-08-03_12-46-42.jpg (140.88 KiB) Viewed 14409 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Chart Unexpectedly changes color with mouse movement

Post by Sandra » Wed Aug 03, 2016 3:07 pm

Hello Trevor,

Many thanks for the project
We can reproduce the problem you experiencing here and we have found a fix for the problem, is only needed modify the Estimated_TT_D1_ChartMouseMove method in same way below:

Code: Select all

procedure DrawCross(AX,AY:Integer);
begin
  with Estimated_TT_D1_Chart,Canvas do
  begin
    Pen.Color:=CrossHairColor;
    Pen.Style:=CrossHairStyle;
    Pen.Color := clRed;
    Pen.Mode:=pmNotXor;
    Pen.Width:=1;
    MoveTo(ax,Estimated_TT_D1_Chart.ChartRect.Top-Height3D);
    LineTo(ax,Estimated_TT_D1_Chart.ChartRect.Bottom-Height3D);
    MoveTo(Estimated_TT_D1_Chart.ChartRect.Left+Width3D,ay);
    LineTo(Estimated_TT_D1_Chart.ChartRect.Right+Width3D,ay);
  end;
end;
As you see I have used as Pen.Mode pmNotXor instead of pmXor and I have set the Pen color to Red.

Could you tell us if it fix the problem in your end?

Hoping this helps you

Thanks in advance
Best Regards,
Sandra Pazos / 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

VideoTrack
Newbie
Newbie
Posts: 5
Joined: Thu Jan 14, 2016 12:00 am

Re: Chart Unexpectedly changes color with mouse movement

Post by VideoTrack » Mon Aug 08, 2016 1:18 pm

Thanks. I tried changing the value, but this made it worse?

Code: Select all

procedure DrawCross(AX,AY:Integer);
begin
  with Estimated_TT_D1_Chart,Canvas do
  begin
    Pen.Color:=CrossHairColor;
    Pen.Style:=CrossHairStyle;
    //Pen.Mode:=pmXor;
    Pen.Mode := pmNotXor;
    Pen.Width:=1;
    MoveTo(ax,Estimated_TT_D1_Chart.ChartRect.Top-Height3D);
    LineTo(ax,Estimated_TT_D1_Chart.ChartRect.Bottom-Height3D);
    MoveTo(Estimated_TT_D1_Chart.ChartRect.Left+Width3D,ay);
    LineTo(Estimated_TT_D1_Chart.ChartRect.Right+Width3D,ay);
  end;
end;
When the mouse was moved over the chart, the charts now went either yellow or pale green:
2016-08-08_23-08-56.jpg
2016-08-08_23-08-56.jpg (225.53 KiB) Viewed 14379 times
2016-08-08_23-10-03.jpg
2016-08-08_23-10-03.jpg (183.72 KiB) Viewed 14379 times
Incidentally, the code: Pen.Mode:=pmXor; has been there for about 10 years.

VideoTrack
Newbie
Newbie
Posts: 5
Joined: Thu Jan 14, 2016 12:00 am

Re: Chart Unexpectedly changes color with mouse movement

Post by VideoTrack » Mon Aug 08, 2016 1:29 pm

Incidentally, the color change definitely seems to be related to moving the mouse over an adjacent control first, e.g. some text or other graphics object:
2016-08-08_23-25-41.jpg
2016-08-08_23-25-41.jpg (63.31 KiB) Viewed 14388 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Chart Unexpectedly changes color with mouse movement

Post by Sandra » Tue Aug 09, 2016 11:40 am

Hello Trevor,

Many thanks for the information.
After, do some test I have realized you try to simulate a CursorTool.The same problem as you find the client there is in the thread below:
http://www.teechart.net/support/viewtop ... e4c#p50889

Therefore, I would like suggest you try to use a Cursor Tool for your requests and prevent possible problems.
Take a look at the examples under "All features\Welcome !\Tools\Cursor\". Also I have attached a simple example that Yeray made for the client of thread above.
MouseMoveUpdate.zip
(1.74 KiB) Downloaded 684 times
Could you tell us if it works in your end?

Thanks in advance
Best Regards,
Sandra Pazos / 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

VideoTrack
Newbie
Newbie
Posts: 5
Joined: Thu Jan 14, 2016 12:00 am

Re: Chart Unexpectedly changes color with mouse movement

Post by VideoTrack » Fri Aug 12, 2016 7:31 am

Thank you, that new code seems to work OK. Appreciate your assistance
Trevor

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Chart Unexpectedly changes color with mouse movement

Post by Sandra » Fri Aug 12, 2016 8:10 am

Hello Trevor,

I'm glad the code works for you :).

Feel free to contact us if you have more questions.
Thanks in advance
Best Regards,
Sandra Pazos / 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

Post Reply