Page 1 of 1

TErrorSeries .OnClick Bug with ErrorWidth <> 100%

Posted: Sun Jul 01, 2018 11:41 am
by 16582529
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).

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

Posted: Mon Jul 02, 2018 8:56 am
by yeray
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!