feat: tanks data grid scale added

This commit is contained in:
Mikhail Shabanov committed 2021-07-15 13:57:09 +02:00
1 parent 8b2c0daa27
commit 3093b5ce38
3 files changed
+53 -10

No files matched your search

@@ -1,7 +1,14 @@
namespace WotBlitzStatisticsPro.Blazor.Helpers using System;
namespace WotBlitzStatisticsPro.Blazor.Helpers
{ {
public static class ScaleHelper public static class ScaleHelper
{ {
public static string ScaleColor(this decimal winRate)
{
var intWinRate = Convert.ToInt32(winRate);
return intWinRate.ScaleColor();
}
public static string ScaleColor(this int winRate) public static string ScaleColor(this int winRate)
{ {
return winRate switch return winRate switch
@@ -17,5 +24,23 @@
_ => Constants.ScaleSuperUnicumColor _ => Constants.ScaleSuperUnicumColor
}; };
} }
public static string Wn7ScaleColor(this double wn7)
{
return wn7 switch
{
( > 0 ) and ( < 500) => Constants.ScaleVeryBadColor,
( >= 500) and ( < 700) => Constants.ScaleBadColor,
( >= 700) and ( < 900) => Constants.ScaleBelowAverageColor,
( >= 900) and ( < 1100) => Constants.ScaleAverageColor,
( >= 1100) and ( < 1350) => Constants.ScaleGoodColor,
( >= 1350) and ( < 1550) => Constants.ScaleVeryGoodColor,
( >= 1550) and ( < 1850) => Constants.ScaleGreatColor,
( >= 1850) and ( < 2050) => Constants.ScaleUnicumColor,
_ => Constants.ScaleSuperUnicumColor
};
}
} }
} }
@@ -13,22 +13,22 @@
ColumnWidth="300px" ColumnWidth="300px"
LogicalFilterOperator="LogicalFilterOperator.Or"> LogicalFilterOperator="LogicalFilterOperator.Or">
<Columns> <Columns>
<RadzenDataGridColumn TItem="ITank" Filterable="false" Sortable="false" Title="" Frozen="true" Width="34px" TextAlign="TextAlign.Center"> <RadzenDataGridColumn TItem="ITank" Property="Tier" Filterable="false" Sortable="true" Title="" Frozen="true" Width="34px" TextAlign="TextAlign.Center">
<Template Context="data"> <Template Context="data">
<b>@data.Tier.RomanNumber()</b> <b>@data.Tier.RomanNumber()</b>
</Template> </Template>
</RadzenDataGridColumn> </RadzenDataGridColumn>
<RadzenDataGridColumn TItem="ITank" Filterable="false" Sortable="false" Title="" Frozen="true" Width="34px" TextAlign="TextAlign.Center"> <RadzenDataGridColumn TItem="ITank" Property="TankTypeId" Filterable="false" Sortable="true" Title="" Frozen="true" Width="34px" TextAlign="TextAlign.Center">
<Template Context="data"> <Template Context="data">
<RadzenImage Path="@data.TankTypeId.TankTypeAsset(data.IsPremium)" MouseEnter="@(args => ShowTooltip(args, data.TankType) )" style="width: 24px; height: 24px;" /> <RadzenImage Path="@data.TankTypeId.TankTypeAsset(data.IsPremium)" MouseEnter="@(args => ShowTooltip(args, data.TankType) )" style="width: 24px; height: 24px;" />
</Template> </Template>
</RadzenDataGridColumn> </RadzenDataGridColumn>
<RadzenDataGridColumn TItem="ITank" Filterable="false" Sortable="false" Title="" Frozen="true" Width="50px" TextAlign="TextAlign.Center"> <RadzenDataGridColumn TItem="ITank" Property="TankNationId" Filterable="false" Sortable="true" Title="" Frozen="true" Width="50px" TextAlign="TextAlign.Center">
<Template Context="data"> <Template Context="data">
<RadzenImage Path="@data.TankNationId.NationAsset()" MouseEnter="@(args => ShowTooltip(args, data.TankNation) )" style="width: 35px; height: 23px; border-radius: 4px;" /> <RadzenImage Path="@data.TankNationId.NationAsset()" MouseEnter="@(args => ShowTooltip(args, data.TankNation) )" style="width: 35px; height: 23px; border-radius: 4px;" />
</Template> </Template>
</RadzenDataGridColumn> </RadzenDataGridColumn>
<RadzenDataGridColumn TItem="ITank" Filterable="false" Sortable="false" Title="" Frozen="true" Width="34px" TextAlign="TextAlign.Center"> <RadzenDataGridColumn TItem="ITank" Property="MarkOfMastery" Filterable="false" Sortable="true" Title="" Frozen="true" Width="34px" TextAlign="TextAlign.Center">
<Template Context="data"> <Template Context="data">
<RadzenImage Path="@data.MarkOfMastery.IconAsset()" style="width: 24px; height: 24px;" /> <RadzenImage Path="@data.MarkOfMastery.IconAsset()" style="width: 24px; height: 24px;" />
</Template> </Template>
@@ -46,8 +46,12 @@
Title="🏳" Title="🏳"
Frozen="false" Frozen="false"
Width="50px" Width="50px"
TextAlign="TextAlign.Center" TextAlign="TextAlign.Center">
FormatString="{0:N0}%"/> <Template Context="data">
@data.WinRate.ToString("N0")%
<div style="background-color: @data.WinRate.ScaleColor(); width: 100%; height: 5px; margin-left: 2px; margin-right: 2px;"></div>
</Template>
</RadzenDataGridColumn>
<RadzenDataGridColumn TItem="ITank" Property="Wn7" <RadzenDataGridColumn TItem="ITank" Property="Wn7"
Filterable="false" Filterable="false"
Sortable="true" Sortable="true"
@@ -55,7 +59,12 @@
Frozen="false" Frozen="false"
Width="80px" Width="80px"
TextAlign="TextAlign.Center" TextAlign="TextAlign.Center"
FormatString="{0:N0}"/> >
<Template Context="data">
@data.Wn7.ToString("N0")
<div style="background-color: @data.Wn7.Wn7ScaleColor(); width: 100%; height: 5px; margin-left: 2px; margin-right: 2px;"></div>
</Template>
</RadzenDataGridColumn>
<RadzenDataGridColumn TItem="ITank" Property="AvgDamage" <RadzenDataGridColumn TItem="ITank" Property="AvgDamage"
Filterable="false" Filterable="false"
Sortable="true" Sortable="true"
@@ -95,7 +104,8 @@
Frozen="false" Frozen="false"
Width="100px" Width="100px"
TextAlign="TextAlign.Center" TextAlign="TextAlign.Center"
FormatString="{0:d}"/> FormatString="{0:d}"
SortOrder="SortOrder.Descending"/>
</Columns> </Columns>
</RadzenDataGrid> </RadzenDataGrid>
@@ -104,4 +114,12 @@
public IEnumerable<ITank> TanksList { get; set; } public IEnumerable<ITank> TanksList { get; set; }
void ShowTooltip(ElementReference elementReference, string message, TooltipOptions options = null) => TooltipService.Open(elementReference, message, options); void ShowTooltip(ElementReference elementReference, string message, TooltipOptions options = null) => TooltipService.Open(elementReference, message, options);
void OnChange()
{
// Filter - dropdown with multiselect
// https://blazor.radzen.com/datagrid-filter-template
// TanksList = TanksList.Where(e => currentTOC >= 0 ? e.TitleOfCourtesy == currentTOC : true);
}
} }
@@ -118,7 +118,7 @@ namespace WotBlitzStatisticsPro.Blazor.Services.Mock
faker.Name.LastName(), faker.Name.LastName(),
nation.nation, nation.nation,
nation.nationName, nation.nationName,
faker.Random.Number(10), faker.Random.Number(1, 10),
vehicleType.vehicleType, vehicleType.vehicleType,
vehicleType.vehicleTypeName, vehicleType.vehicleTypeName,
faker.Random.Bool(), faker.Random.Bool(),