From 18434237a01232addb632d49f69ac803d3e05a52 Mon Sep 17 00:00:00 2001 From: StuartFerguson Date: Mon, 6 Jul 2026 14:21:33 +0100 Subject: [PATCH 1/3] fix transaction mix navigation --- .../UIServices/ShellNavigationService.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/TransactionProcessor.Mobile/UIServices/ShellNavigationService.cs b/TransactionProcessor.Mobile/UIServices/ShellNavigationService.cs index 74b7a5a0..77e37887 100644 --- a/TransactionProcessor.Mobile/UIServices/ShellNavigationService.cs +++ b/TransactionProcessor.Mobile/UIServices/ShellNavigationService.cs @@ -191,6 +191,13 @@ public async Task GoToDailyPerformanceSummaryPage() public async Task GoToTransactionMixSummaryPage() { + TransactionMixPage? page = MauiProgram.Container.Services.GetService(typeof(TransactionMixPage)) as TransactionMixPage; + if (page is not null) + { + await this.NavigateTo(page); + return; + } + await this.NavigateTo(nameof(TransactionMixPage)); } From 2ae94213f1c2546898e7fac53be0e8462c2cdbff Mon Sep 17 00:00:00 2001 From: StuartFerguson Date: Mon, 6 Jul 2026 15:36:53 +0100 Subject: [PATCH 2/3] Improve transaction mix report chart --- .../TransactionMixPageViewModelTests.cs | 8 ++-- .../Reports/TransactionMixPageViewModel.cs | 40 ++++++------------- TransactionProcessor.Mobile/MauiProgram.cs | 10 +++-- .../Pages/Reports/TransactionMixPage.xaml | 18 +++++---- .../UIServices/ShellNavigationService.cs | 10 ++--- 5 files changed, 38 insertions(+), 48 deletions(-) diff --git a/TransactionProcessor.Mobile.BusinessLogic.Tests/ViewModelTests/Reports/TransactionMixPageViewModelTests.cs b/TransactionProcessor.Mobile.BusinessLogic.Tests/ViewModelTests/Reports/TransactionMixPageViewModelTests.cs index 8a029727..ab8a04d4 100644 --- a/TransactionProcessor.Mobile.BusinessLogic.Tests/ViewModelTests/Reports/TransactionMixPageViewModelTests.cs +++ b/TransactionProcessor.Mobile.BusinessLogic.Tests/ViewModelTests/Reports/TransactionMixPageViewModelTests.cs @@ -57,9 +57,11 @@ public async Task Initialise_LoadsDefaultTransactionMixSummary() this.ViewModel.Items.Count.ShouldBeGreaterThan(0); this.ViewModel.TopItems.Count.ShouldBeGreaterThan(0); this.ViewModel.HasChartData.ShouldBeTrue(); - this.ViewModel.ChartSeries.Length.ShouldBe(1); - this.ViewModel.ChartYAxes.Count.ShouldBe(1); - this.ViewModel.ChartXAxes.Count.ShouldBe(1); + this.ViewModel.ChartSeries.Length.ShouldBeGreaterThan(0); + this.ViewModel.ChartYAxes.Count.ShouldBe(0); + this.ViewModel.ChartXAxes.Count.ShouldBe(0); + this.ViewModel.ChartSubtitle.ShouldContain("Transaction Type"); + this.ViewModel.ChartSubtitle.ShouldContain("count"); this.ViewModel.IsLoading.ShouldBeFalse(); } } diff --git a/TransactionProcessor.Mobile.BusinessLogic/ViewModels/Reports/TransactionMixPageViewModel.cs b/TransactionProcessor.Mobile.BusinessLogic/ViewModels/Reports/TransactionMixPageViewModel.cs index 7d1756a7..f8caa8e4 100644 --- a/TransactionProcessor.Mobile.BusinessLogic/ViewModels/Reports/TransactionMixPageViewModel.cs +++ b/TransactionProcessor.Mobile.BusinessLogic/ViewModels/Reports/TransactionMixPageViewModel.cs @@ -172,6 +172,10 @@ public List ChartYAxes public bool HasChartData => this.ChartSeries.Length > 0; + public string ChartSubtitle => this.HasChartData + ? $"Top {this.TopItems.Count} {this.SelectedBreakdown.ToDisplayText()} categories by {this.SelectedMeasure.ToDisplayText().ToLowerInvariant()}" + : "No chart data available"; + public IReadOnlyList SelectedItemTransactions { get @@ -303,43 +307,25 @@ private void UpdateChart() return; } - List labels = topItems.Select(item => item.Label).ToList(); List values = topItems.Select(item => this.SelectedMeasure == TransactionMixMeasure.Value ? (double)item.Value : (double)item.Count).ToList(); - this.ChartSeries = new ISeries[] - { - new RowSeries - { - Values = values, - Name = this.SelectedMeasure.ToDisplayText(), - Stroke = null, - Fill = null, - } - }; - - this.ChartYAxes = new List + this.ChartSeries = topItems.Select((item, index) => { - new Axis + double value = values[index]; + return new PieSeries(new[] { value }) { - Labels = labels, - LabelsRotation = 0, - Name = this.SelectedBreakdown.ToDisplayText(), - } - }; + Name = item.Label, + }; + }).Cast().ToArray(); - this.ChartXAxes = new List - { - new Axis - { - Labeler = value => this.SelectedMeasure == TransactionMixMeasure.Value ? value.ToString("N2") : value.ToString("N0"), - Name = this.SelectedMeasure.ToDisplayText(), - } - }; + this.ChartYAxes = []; + this.ChartXAxes = []; this.OnPropertyChanged(nameof(this.ChartSeries)); this.OnPropertyChanged(nameof(this.ChartXAxes)); this.OnPropertyChanged(nameof(this.ChartYAxes)); this.OnPropertyChanged(nameof(this.HasChartData)); + this.OnPropertyChanged(nameof(this.ChartSubtitle)); } } diff --git a/TransactionProcessor.Mobile/MauiProgram.cs b/TransactionProcessor.Mobile/MauiProgram.cs index 7e7391dd..c3588019 100644 --- a/TransactionProcessor.Mobile/MauiProgram.cs +++ b/TransactionProcessor.Mobile/MauiProgram.cs @@ -1,14 +1,16 @@ -using CommunityToolkit.Maui; +using CommunityToolkit.Maui; +using LiveChartsCore.SkiaSharpView.Maui; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Maui.Controls.Hosting; using Microsoft.Maui.Hosting; +using SkiaSharp.Views.Maui.Controls.Hosting; using TransactionProcessor.Mobile.BusinessLogic.Common; using TransactionProcessor.Mobile.BusinessLogic.Logging; +using TransactionProcessor.Mobile.BusinessLogic.Serialisation; using TransactionProcessor.Mobile.BusinessLogic.UIServices; using TransactionProcessor.Mobile.Extensions; using TransactionProcessor.Mobile.UIServices; -using Microsoft.Extensions.DependencyInjection; -using TransactionProcessor.Mobile.BusinessLogic.Serialisation; namespace TransactionProcessor.Mobile { @@ -19,6 +21,8 @@ public static MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuilder(); builder.UseMauiApp() + .UseLiveCharts() + .UseSkiaSharp() .UseMauiCommunityToolkit() .ConfigureRequestHandlers() .ConfigurePages() diff --git a/TransactionProcessor.Mobile/Pages/Reports/TransactionMixPage.xaml b/TransactionProcessor.Mobile/Pages/Reports/TransactionMixPage.xaml index 1701640c..73664f47 100644 --- a/TransactionProcessor.Mobile/Pages/Reports/TransactionMixPage.xaml +++ b/TransactionProcessor.Mobile/Pages/Reports/TransactionMixPage.xaml @@ -152,23 +152,25 @@ FontAttributes="Bold" TextColor="{AppThemeBinding Light={StaticResource MidnightBlue}, Dark={StaticResource White}}" /> -