Skip to content

Commit

Permalink
fixes #1601
Browse files Browse the repository at this point in the history
Related Work Items: #160
  • Loading branch information
beto-rodriguez committed Oct 12, 2024
1 parent b6ff86b commit a8c2249
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/LiveChartsCore/CartesianChart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ protected internal override void Measure()
IsZoomingOrPanning = false;
InvokeOnUpdateStarted();

if (_isToolTipOpen) DrawToolTip();
if (_isToolTipOpen) _ = DrawToolTip();
ThemeId = LiveCharts.DefaultSettings.CurrentThemeId;

Canvas.Invalidate();
Expand Down
13 changes: 9 additions & 4 deletions src/LiveChartsCore/Chart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,8 @@ protected void DrawLegend(ref float ts, ref float bs, ref float ls, ref float rs
/// <summary>
/// Draws the current tool tip, requires canvas invalidation after this call.
/// </summary>
protected void DrawToolTip()
/// <returns>A value indicating whether the tooltip was drawn.</returns>
protected bool DrawToolTip()
{
var x = _pointerPosition.X;
var y = _pointerPosition.Y;
Expand All @@ -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);
Expand All @@ -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)
Expand All @@ -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();
}
}));
Expand Down
2 changes: 1 addition & 1 deletion src/LiveChartsCore/PieChart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ protected internal override void Measure()

CollectVisuals();

if (_isToolTipOpen) DrawToolTip();
if (_isToolTipOpen) _ = DrawToolTip();
InvokeOnUpdateStarted();
_isFirstDraw = false;
ThemeId = LiveCharts.DefaultSettings.CurrentThemeId;
Expand Down

0 comments on commit a8c2249

Please sign in to comment.