Last active
July 5, 2022 18:38
-
-
Save kiranmaya/22637b02774d39e71f0cb912d5a8c1f2 to your computer and use it in GitHub Desktop.
MudChart ChartType.Bar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@namespace Components | |
<MudChart ChartType="ChartType.Bar" ChartSeries="@Series" | |
XAxisLabels="@XAxisLabels.ToArray()" | |
Width="100%" Height="350px" ChartOptions="chartOptions"></MudChart> | |
@code { | |
[Parameter] public string SeriesName { get; set; } | |
[Parameter] public List<StraddleOrder>? Orders { get; set; } | |
List<ChartSeries> Series; | |
List<string>? XAxisLabels ; | |
public ChartOptions chartOptions = new ChartOptions(); | |
protected override void OnInitialized() | |
{ | |
chartOptions.YAxisTicks =100; | |
XAxisLabels = new List<string>(); | |
Series = new List<ChartSeries>(); | |
List<double> finalPnlList = new List<double>(); | |
foreach( var ord in Orders ) | |
{ | |
finalPnlList.Add(ord.netPnl); | |
XAxisLabels.Add(ord.OrderName); | |
} | |
ChartSeries orderSeries = new ChartSeries() | |
{ | |
Name = SeriesName, | |
Data = finalPnlList.ToArray() | |
}; | |
Series.Add(orderSeries); | |
} | |
} | |
<ApexCharts.ApexChart ApexChart TItem="StraddleOrder" | |
Title=@SeriesName> | |
<ApexCharts.ApexPointSeries TItem="StraddleOrder" | |
Items="Orders" | |
Name="Gross Value" | |
XValue="@(e => e.OrderName)" | |
YValue="@(e =>(decimal) e.netPnl)" | |
SeriesType="ApexCharts.SeriesType.Bar"/> | |
</ApexCharts.ApexChart> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment