diff --git a/MP.Stats/Pages/Test.razor b/MP.Stats/Pages/Test.razor index 03d01f64..1cdce18e 100644 --- a/MP.Stats/Pages/Test.razor +++ b/MP.Stats/Pages/Test.razor @@ -2,12 +2,28 @@ Test - + - +
+
+ +
+
+ +
+
+ +
+
+ +
+
@code { + PieChart pieChart; LineChart lineChart; + HorizontalBarChart barChartHoriz; + BarChart barChart; protected override async Task OnAfterRenderAsync(bool firstRender) { @@ -17,11 +33,66 @@ } } + object horizontalLineChartOptions = new + { + //Title = new + //{ + // Display = true, + // Text = "Line chart sample" + //}, + //Scales = new + //{ + // XAxes = new object[] + // { + // new { + // //ScaleLabel = new { + // //Display = true, LabelString = "value" }, + // Stacked = true + // } + // } + //}, + Tooltips = new + { + Mode = "nearest", + Intersect = false + }, + Hover = new + { + Mode = "nearest", + Intersect = false + }, + Legend = new + { + Display = true, + FullWidth = true + }, + AspectRatio = 2.5 + }; + async Task HandleRedraw() { - await lineChart.Clear(); + await pieChart.Clear(); + await pieChart.AddLabelsDatasetsAndUpdate(Labels, GetPieChartDataset()); + await lineChart.Clear(); await lineChart.AddLabelsDatasetsAndUpdate(Labels, GetLineChartDataset()); + + await barChart.Clear(); + await barChart.AddLabelsDatasetsAndUpdate(Labels, GetBarChartDataset()); + + await barChartHoriz.Clear(); + await barChartHoriz.AddLabelsDatasetsAndUpdate(Labels, GetHorizBarChartDataset()); + } + + PieChartDataset GetPieChartDataset() + { + return new PieChartDataset + { + Label = "# of randoms", + Data = RandomizeData(), + BackgroundColor = backgroundColors, + BorderColor = borderColors + }; } LineChartDataset GetLineChartDataset() @@ -38,6 +109,29 @@ }; } + BarChartDataset GetBarChartDataset() + { + return new BarChartDataset + { + Label = "# of randoms", + Data = RandomizeData(), + BackgroundColor = backgroundColors, + BorderColor = borderColors, + HoverBorderWidth = 5 + }; + } + BarChartDataset GetHorizBarChartDataset() + { + return new BarChartDataset + { + Label = "# of randoms", + Data = RandomizeData(), + BackgroundColor = backgroundColors, + BorderColor = borderColors, + HoverBorderWidth = 5 + }; + } + string[] Labels = { "Red", "Blue", "Yellow", "Green", "Purple", "Orange" }; List backgroundColors = new List { ChartColor.FromRgba(255, 99, 132, 0.2f), ChartColor.FromRgba(54, 162, 235, 0.2f), ChartColor.FromRgba(255, 206, 86, 0.2f), ChartColor.FromRgba(75, 192, 192, 0.2f), ChartColor.FromRgba(153, 102, 255, 0.2f), ChartColor.FromRgba(255, 159, 64, 0.2f) }; List borderColors = new List { ChartColor.FromRgba(255, 99, 132, 1f), ChartColor.FromRgba(54, 162, 235, 1f), ChartColor.FromRgba(255, 206, 86, 1f), ChartColor.FromRgba(75, 192, 192, 1f), ChartColor.FromRgba(153, 102, 255, 1f), ChartColor.FromRgba(255, 159, 64, 1f) }; @@ -46,6 +140,6 @@ { var r = new Random(DateTime.Now.Millisecond); - return new List { r.Next(3, 50) * r.NextDouble(), r.Next(3, 50) * r.NextDouble(), r.Next(3, 50) * r.NextDouble(), r.Next(3, 50) * r.NextDouble(), r.Next(3, 50) * r.NextDouble(), r.Next(3, 50) * r.NextDouble() }; + return new List { r.Next(3, 30) * r.NextDouble(), r.Next(3, 30) * r.NextDouble(), r.Next(3, 30) * r.NextDouble(), r.Next(3, 30) * r.NextDouble(), r.Next(3, 30) * r.NextDouble(), r.Next(3, 30) * r.NextDouble() }; } } \ No newline at end of file