From d26ca9f7bd0b767239ca81b587c0ae28828a725f Mon Sep 17 00:00:00 2001 From: SmartRootsSrl Date: Mon, 8 Jun 2026 17:46:26 +0200 Subject: [PATCH] fix: correct Y-grid to 5 lines, add defensive date sort in GetChartPricesAsync --- .../Services/Implementations/FundDataService.cs | 1 + .../Services/Implementations/FundSkiaChartRenderer.cs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CertReports.Syncfusion/Services/Implementations/FundDataService.cs b/CertReports.Syncfusion/Services/Implementations/FundDataService.cs index d05628b..d5e0fa7 100644 --- a/CertReports.Syncfusion/Services/Implementations/FundDataService.cs +++ b/CertReports.Syncfusion/Services/Implementations/FundDataService.cs @@ -66,6 +66,7 @@ public class FundDataService : IFundDataService _logger.LogError(ex, "Errore GetChartPricesAsync per ISIN {Isin}", isin); throw; } + points.Sort((a, b) => a.Date.CompareTo(b.Date)); return points; } diff --git a/CertReports.Syncfusion/Services/Implementations/FundSkiaChartRenderer.cs b/CertReports.Syncfusion/Services/Implementations/FundSkiaChartRenderer.cs index 57d0f84..4e8383f 100644 --- a/CertReports.Syncfusion/Services/Implementations/FundSkiaChartRenderer.cs +++ b/CertReports.Syncfusion/Services/Implementations/FundSkiaChartRenderer.cs @@ -130,9 +130,9 @@ public static class FundSkiaChartRenderer var axisLabelFont = new SKFont(SKTypeface.Default, 10f); // 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); canvas.DrawLine(plotX, py, plotX + plotW, py, i == 0 ? axisPaint : gridPaint); canvas.DrawText($"{price:F2}", plotX - 5f, py + 4f,