From 4a5bdcd45aaece82b9ebf780a87bc464a8a60d44 Mon Sep 17 00:00:00 2001 From: Howon Lee Date: Tue, 25 Jun 2024 17:46:43 +0900 Subject: [PATCH] Reset _stepCount when it should be Fixed an issue where _stepCount was not being reset, causing ThrowInfiniteSeparators() to be triggered as _stepCount accumulated over time, even though the actual step count did not exceed 10,000. (https://github.com/beto-rodriguez/LiveCharts2/issues/1076#issuecomment-1967245178) Now, _stepCount is reset to 0 before each relevant logic check. This resolved the exception that occurred about 10 minutes after the chart was displayed. --- src/LiveChartsCore/CoreAxis.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/LiveChartsCore/CoreAxis.cs b/src/LiveChartsCore/CoreAxis.cs index 848d59fd8..d667b21df 100644 --- a/src/LiveChartsCore/CoreAxis.cs +++ b/src/LiveChartsCore/CoreAxis.cs @@ -1,4 +1,4 @@ -// The MIT License(MIT) +// The MIT License(MIT) // // Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors // @@ -307,8 +307,6 @@ public LvcColor? CrosshairLabelsBackground /// public override void Invalidate(Chart chart) { - _stepCount = 0; - var cartesianChart = (CartesianChart)chart; var controlSize = cartesianChart.ControlSize; @@ -496,6 +494,7 @@ NamePadding is not null || SeparatorsPaint is not null || LabelsPaint is not nul var start = Math.Truncate(min / s) * s; + _stepCount = 0; foreach (var i in EnumerateSeparators(start, max, s)) { var separatorKey = Labelers.SixRepresentativeDigits(i - 1d + 1d); @@ -879,6 +878,7 @@ public virtual LvcSize GetPossibleSize(Chart chart) var h = 0f; var r = (float)LabelsRotation; + _stepCount = 0; foreach (var i in EnumerateSeparators(start, max, s)) { var textGeometry = new TTextGeometry @@ -1031,6 +1031,7 @@ private LvcSize GetPossibleMaxLabelSize() if (max - min == 0) return maxLabelSize; + _stepCount = 0; foreach (var i in EnumerateSeparators(min, max, s)) { var textGeometry = new TTextGeometry