TErrorSeries .OnClick Bug with ErrorWidth <> 100%
Posted: 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:
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).
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;
...