From a8c224944c02215d8be2b9e560c8ff76d2250744 Mon Sep 17 00:00:00 2001 From: beto rodriguez Date: Fri, 11 Oct 2024 18:41:05 -0600 Subject: [PATCH] fixes #1601 Related Work Items: #160 --- src/LiveChartsCore/CartesianChart.cs | 2 +- src/LiveChartsCore/Chart.cs | 13 +++++++++---- src/LiveChartsCore/PieChart.cs | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/LiveChartsCore/CartesianChart.cs b/src/LiveChartsCore/CartesianChart.cs index 7ed3abd90..2e563aab1 100644 --- a/src/LiveChartsCore/CartesianChart.cs +++ b/src/LiveChartsCore/CartesianChart.cs @@ -861,7 +861,7 @@ protected internal override void Measure() IsZoomingOrPanning = false; InvokeOnUpdateStarted(); - if (_isToolTipOpen) DrawToolTip(); + if (_isToolTipOpen) _ = DrawToolTip(); ThemeId = LiveCharts.DefaultSettings.CurrentThemeId; Canvas.Invalidate(); diff --git a/src/LiveChartsCore/Chart.cs b/src/LiveChartsCore/Chart.cs index 76ba2b539..0df6109f3 100644 --- a/src/LiveChartsCore/Chart.cs +++ b/src/LiveChartsCore/Chart.cs @@ -635,7 +635,8 @@ protected void DrawLegend(ref float ts, ref float bs, ref float ls, ref float rs /// /// Draws the current tool tip, requires canvas invalidation after this call. /// - protected void DrawToolTip() + /// A value indicating whether the tooltip was drawn. + protected bool DrawToolTip() { var x = _pointerPosition.X; var y = _pointerPosition.Y; @@ -644,7 +645,7 @@ protected void DrawToolTip() x < DrawMarginLocation.X || x > DrawMarginLocation.X + DrawMarginSize.Width || y < DrawMarginLocation.Y || y > DrawMarginLocation.Y + DrawMarginSize.Height) { - return; + return false; } var points = FindHoveredPointsBy(_pointerPosition); @@ -660,10 +661,12 @@ protected void DrawToolTip() CleanHoveredPoints(o); - if (isEmpty) return; + if (isEmpty) return true; Tooltip?.Show(points, this); _isToolTipOpen = true; + + return true; } private void CleanHoveredPoints(object comparer) @@ -687,7 +690,9 @@ private Task TooltipThrottlerUnlocked() #if NET5_0_OR_GREATER if (_isTooltipCanceled) return; #endif - DrawToolTip(); + var tooltipDrawn = DrawToolTip(); + if (!tooltipDrawn) return; + Canvas.Invalidate(); } })); diff --git a/src/LiveChartsCore/PieChart.cs b/src/LiveChartsCore/PieChart.cs index b02c23d63..aaae079e5 100644 --- a/src/LiveChartsCore/PieChart.cs +++ b/src/LiveChartsCore/PieChart.cs @@ -234,7 +234,7 @@ protected internal override void Measure() CollectVisuals(); - if (_isToolTipOpen) DrawToolTip(); + if (_isToolTipOpen) _ = DrawToolTip(); InvokeOnUpdateStarted(); _isFirstDraw = false; ThemeId = LiveCharts.DefaultSettings.CurrentThemeId;