TErrorSeries .OnClick Bug with ErrorWidth <> 100%

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Whookie
Newbie
Newbie
Posts: 1
Joined: Tue Dec 12, 2017 12:00 am

TErrorSeries .OnClick Bug with ErrorWidth <> 100%

Post by Whookie » Sun Jul 01, 2018 11:41 am

I found a bug with TErrorSeries.OnClick event. Run the attached demo application (ErrorWidth is set to 30% on startup) and try klicking one of the ErrorSeries points. You will notice that the click position is somewhat shiftet to the left (while using 100% is working as expected).

I temporary fixed this for the configuration I use, by changing TCustomErrorSeries.Clicked(x, y: Integer) in ErrorBar.pas near line 666:

Code: Select all

..
    else
    if FErrorWidthUnits=ewuPercent then
    begin
       tmpWidth:=Round(1.0*FErrorWidth*tmpBarWidth*0.01);
       tmpXOffs:=Round(1.0*(100.0-FErrorWidth)*tmpBarWidth*0.01) Div 2;           //<------ Calc half of with at 100%
    end
    else
       tmpWidth:=FErrorWidth;

      if checkTop then
      begin
        if ClickedHorizontal(P, CalcXPos(t)+tmpXOffs, CalcXPos(t) + tmpWidth + tmpXOffs,   //<---- adjust x position using tmpXOffs
                            CalcYPosValue(YValues[t] + tmpError))
           or
           ClickedVertical(P, CalcXPos(t) + tmpXOffs + tmpWidth div 2, CalcYPos(t),    //<---- adjust x position using tmpXOffs
                            CalcYPosValue(YValues[t] + tmpError)) then
        begin
          result:=t;
          exit;
        end;
      end;

      if checkBottom then
      begin
        if ClickedHorizontal(P, CalcXPos(t)+tmpXOffs, CalcXPos(t) + tmpWidth + tmpXOffs,    //<---- adjust x position using tmpXOffs
                            CalcYPosValue(YValues[t] - tmpError))
           or
           ClickedVertical(P, CalcXPos(t) + tmpXOffs + tmpWidth div 2, CalcYPos(t),    //<---- adjust x position using tmpXOffs
                            CalcYPosValue(YValues[t] - tmpError)) then
        begin
          result:=t;
          exit;
        end;
      end;
    ...
NOTE: I did not check if this is working with other configurations (ewuPixels, different fErrorStyles or orientation or FMX) so I leave that up for you to fix. I have enclosed the patched unit and thus the attatched file is password protected (please use my current subscription passwort to un7zip).
Attachments
ErrorSeries.7z
(12.12 KiB) Downloaded 675 times

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TErrorSeries .OnClick Bug with ErrorWidth <> 100%

Post by Yeray » Mon Jul 02, 2018 8:56 am

Hello,

I've been ale to reproduce the problem here so I've added it to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=2051

Thanks for reporting it, and for the fix proposal!
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply