fix: correct Y-grid to 5 lines, add defensive date sort in GetChartPricesAsync

This commit is contained in:
2026-06-08 17:46:26 +02:00
parent 7dbcb8ab16
commit d26ca9f7bd
2 changed files with 3 additions and 2 deletions

View File

@@ -66,6 +66,7 @@ public class FundDataService : IFundDataService
_logger.LogError(ex, "Errore GetChartPricesAsync per ISIN {Isin}", isin); _logger.LogError(ex, "Errore GetChartPricesAsync per ISIN {Isin}", isin);
throw; throw;
} }
points.Sort((a, b) => a.Date.CompareTo(b.Date));
return points; return points;
} }

View File

@@ -130,9 +130,9 @@ public static class FundSkiaChartRenderer
var axisLabelFont = new SKFont(SKTypeface.Default, 10f); var axisLabelFont = new SKFont(SKTypeface.Default, 10f);
// Y grid (5 horizontal lines) // Y grid (5 horizontal lines)
for (int i = 0; i <= 5; i++) for (int i = 0; i < 5; i++)
{ {
decimal price = yMin + (yMax - yMin) * i / 5; decimal price = yMin + (yMax - yMin) * i / 4;
float py = PriceToY(price, yMin, yMax, plotY, plotH); float py = PriceToY(price, yMin, yMax, plotY, plotH);
canvas.DrawLine(plotX, py, plotX + plotW, py, i == 0 ? axisPaint : gridPaint); canvas.DrawLine(plotX, py, plotX + plotW, py, i == 0 ? axisPaint : gridPaint);
canvas.DrawText($"{price:F2}", plotX - 5f, py + 4f, canvas.DrawText($"{price:F2}", plotX - 5f, py + 4f,