diff --git a/Aaru.Server/Components/Pages/Statistics/Filesystems.razor b/Aaru.Server/Components/Pages/Statistics/Filesystems.razor index 037385b1..1be2ffe9 100644 --- a/Aaru.Server/Components/Pages/Statistics/Filesystems.razor +++ b/Aaru.Server/Components/Pages/Statistics/Filesystems.razor @@ -1,6 +1,6 @@ @using Aaru.Server.Database @using Aaru.Server.Database.Models -@using Blazorise.Charts +@using BlazorBootstrap @using Blazorise.DataGrid @rendermode InteractiveServer @@ -10,7 +10,8 @@

All filesystems found...

- + \ No newline at end of file diff --git a/Aaru.Server/Components/Pages/Statistics/Filesystems.razor.cs b/Aaru.Server/Components/Pages/Statistics/Filesystems.razor.cs index 828d3169..cd7307cb 100644 --- a/Aaru.Server/Components/Pages/Statistics/Filesystems.razor.cs +++ b/Aaru.Server/Components/Pages/Statistics/Filesystems.razor.cs @@ -1,5 +1,5 @@ using Aaru.Server.Database.Models; -using Blazorise.Charts; +using BlazorBootstrap; using Microsoft.EntityFrameworkCore; using DbContext = Aaru.Server.Database.DbContext; @@ -7,9 +7,9 @@ namespace Aaru.Server.Components.Pages.Statistics; public partial class Filesystems { - PieChart? _filesystemsChart; - List _filesystemsCounts = []; - string[] _filesystemsLabels = []; + PieChart _filesystemsChart; + List _filesystemsCounts = []; + List _filesystemsLabels = []; bool _isAlreadyInitialized; List FilesystemsList { get; set; } = []; @@ -34,31 +34,40 @@ public partial class Filesystems _filesystemsLabels = await ctx.Filesystems.OrderByDescending(static o => o.Count) .Take(10) .Select(static v => v.Name) - .ToArrayAsync(); + .ToListAsync(); _filesystemsCounts = await ctx.Filesystems.OrderByDescending(static o => o.Count) .Take(10) - .Select(static x => x.Count) + .Select(static x => (double?)x.Count) .ToListAsync(); - if(_filesystemsLabels.Length >= 10) + if(_filesystemsLabels.Count >= 10) { _filesystemsLabels[9] = "Other"; _filesystemsCounts[9] = ctx.Filesystems.Sum(static o => o.Count) - _filesystemsCounts.Take(9).Sum(); } -#pragma warning disable CS8604 // Possible null reference argument. - await Common.HandleRedrawAsync(_filesystemsChart, _filesystemsLabels, GetFilesystemsChartDataset); -#pragma warning restore CS8604 // Possible null reference argument. - } + PieChartOptions pieChartOptions = new() + { + Responsive = true + }; - PieChartDataset GetFilesystemsChartDataset() => new() - { - Label = $"Top {_filesystemsLabels.Length} filesystems found", - Data = _filesystemsCounts, - BackgroundColor = Common.BackgroundColors, - BorderColor = Common.BorderColors, - BorderWidth = 1 - }; + pieChartOptions.Plugins.Title.Text = $"Top {_filesystemsLabels.Count} filesystems found"; + pieChartOptions.Plugins.Title.Display = true; + + var chartData = new ChartData + { + Labels = _filesystemsLabels, + Datasets = + [ + new PieChartDataset + { + Data = _filesystemsCounts + } + ] + }; + + await _filesystemsChart.InitializeAsync(chartData, pieChartOptions); + } } \ No newline at end of file diff --git a/Aaru.Server/Components/Pages/Stats.razor b/Aaru.Server/Components/Pages/Stats.razor index 13b301e5..5309cb9e 100644 --- a/Aaru.Server/Components/Pages/Stats.razor +++ b/Aaru.Server/Components/Pages/Stats.razor @@ -39,7 +39,7 @@ - +