Skip to content

Instantly share code, notes, and snippets.

@kiranmaya
Last active July 5, 2022 18:38
Show Gist options
  • Save kiranmaya/22637b02774d39e71f0cb912d5a8c1f2 to your computer and use it in GitHub Desktop.
Save kiranmaya/22637b02774d39e71f0cb912d5a8c1f2 to your computer and use it in GitHub Desktop.
MudChart ChartType.Bar
@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