From d61851df1d5696b982797dde6a1aad68aad4a433 Mon Sep 17 00:00:00 2001 From: wp_xyz Date: Tue, 5 Mar 2024 22:46:44 +0100 Subject: [PATCH] TAChart: Avoid drawing no candlestick box when open and close prices in a TOpenHighLowCloseSeries are equal. (cherry picked from commit 12e9db2f31dcc0d3af2c821621854a48cb9e20f0) --- components/tachart/tamultiseries.pas | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/components/tachart/tamultiseries.pas b/components/tachart/tamultiseries.pas index 288f64aec5..021156b705 100644 --- a/components/tachart/tamultiseries.pas +++ b/components/tachart/tamultiseries.pas @@ -1687,14 +1687,24 @@ procedure TOpenHighLowCloseSeries.Draw(ADrawer: IChartDrawer); ADrawer.Line(MaybeRotate(AX1, AY1), MaybeRotate(AX2, AY2)); end; + procedure NoZeroRect(var R: TRect); + begin + if IsRotated then + begin + if R.Left = R.Right then inc(R.Right); + end else + begin + if R.Top = R.Bottom then inc(R.Bottom); + end; + end; + procedure DoRect(AX1, AY1, AX2, AY2: Double); var r: TRect; begin - with ParentChart do begin - r.TopLeft := MaybeRotate(AX1, AY1); - r.BottomRight := MaybeRotate(AX2, AY2); - end; + r.TopLeft := MaybeRotate(AX1, AY1); + r.BottomRight := MaybeRotate(AX2, AY2); + NoZeroRect(r); ADrawer.FillRect(r.Left, r.Top, r.Right, r.Bottom); ADrawer.Rectangle(r); end;