Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@

Result<MerchantDetailsModel> merchantDetails = await merchantService.GetMerchantDetails(cancellationToken);

//merchantDetails.Data.MerchantReportingId = 1;

Check notice on line 83 in TransactionProcessor.Mobile.BusinessLogic/RequestHandlers/MerchantRequestHandler.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

TransactionProcessor.Mobile.BusinessLogic/RequestHandlers/MerchantRequestHandler.cs#L83

Remove this commented out code.
if (merchantDetails.IsSuccess) {
this.ApplicationCache.SetMerchantDetails(merchantDetails.Data, BuildCacheEntryOptions());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ public List<ICartesianAxis> 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<TransactionMixDrillDownTransactionModel> SelectedItemTransactions
{
get
Expand Down Expand Up @@ -303,43 +307,25 @@ private void UpdateChart()
return;
}

List<string> labels = topItems.Select(item => item.Label).ToList();
List<double> values = topItems.Select(item => this.SelectedMeasure == TransactionMixMeasure.Value ? (double)item.Value : (double)item.Count).ToList();

this.ChartSeries = new ISeries[]
{
new RowSeries<double>
{
Values = values,
Name = this.SelectedMeasure.ToDisplayText(),
Stroke = null,
Fill = null,
}
};

this.ChartYAxes = new List<ICartesianAxis>
this.ChartSeries = topItems.Select((item, index) =>
{
new Axis
double value = values[index];
return new PieSeries<double>(new[] { value })
{
Labels = labels,
LabelsRotation = 0,
Name = this.SelectedBreakdown.ToDisplayText(),
}
};
Name = item.Label,
};
}).Cast<ISeries>().ToArray();

this.ChartXAxes = new List<ICartesianAxis>
{
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));
}
}

Expand Down
10 changes: 7 additions & 3 deletions TransactionProcessor.Mobile/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -19,6 +21,8 @@ public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder.UseMauiApp<App>()
.UseLiveCharts()
.UseSkiaSharp()
.UseMauiCommunityToolkit()
.ConfigureRequestHandlers()
.ConfigurePages()
Expand Down
18 changes: 10 additions & 8 deletions TransactionProcessor.Mobile/Pages/Reports/TransactionMixPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,23 +152,25 @@
FontAttributes="Bold"
TextColor="{AppThemeBinding Light={StaticResource MidnightBlue}, Dark={StaticResource White}}" />

<Label Text="Top categories chart"
<Label Text="Transaction mix"
FontSize="16"
FontAttributes="Bold"
TextColor="{AppThemeBinding Light={StaticResource MidnightBlue}, Dark={StaticResource White}}" />
<Label Text="{Binding ChartSubtitle}"
FontSize="12"
Opacity="0.8"
TextColor="{AppThemeBinding Light={StaticResource MidnightBlue}, Dark={StaticResource White}}" />
<Frame Style="{StaticResource TransactionFormCard}"
BackgroundColor="{DynamicResource salesAnalysisCardBackgroundColor}"
BorderColor="{DynamicResource salesAnalysisCardBorderColor}"
Padding="12"
Padding="8"
CornerRadius="14"
HasShadow="False"
Margin="0">
<lvc:CartesianChart AutomationId="TransactionMixChart"
Series="{Binding ChartSeries}"
XAxes="{Binding ChartXAxes}"
YAxes="{Binding ChartYAxes}"
HeightRequest="240"
HorizontalOptions="FillAndExpand" />
<lvc:PieChart AutomationId="TransactionMixChart"
Series="{Binding ChartSeries}"
HeightRequest="260"
HorizontalOptions="FillAndExpand" />
</Frame>

<HorizontalStackLayout Spacing="12">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ private async Task NavigateTo(String route) {
}
catch(Exception e) {
Logger.LogError($"Error navigating to {route}", e);
throw;
}
}

Expand All @@ -219,6 +220,7 @@ private async Task NavigateTo(String route,IDictionary<String,Object> parameters
catch (Exception e)
{
Logger.LogError($"Error navigating to {route} (String route,IDictionary<String,Object> parameters)", e);
throw;
}
}

Expand All @@ -230,6 +232,7 @@ private async Task NavigateTo(ContentPage page){
catch (Exception e)
{
Logger.LogError($"Error navigating to page (ContentPage page))", e);
throw;
}
}

Expand Down
Loading