Bar Chat with date in Axis X C# BLaZor

sblb 1,231 Reputation points
2021-11-25T10:46:13.647+00:00

Hi,
I can't get the months of January to December on the X axis.
The only month that is good is where I have data ie in my case November.
How can I do this?

152583-capture.png

The code of API :

   public IActionResult RevenueByMonth()  
        {  
            var result = context.Developers  
                                 .Where(opportunity => opportunity.Statut == "Closed")  
                                 .ToList()  
                                 .GroupBy(opportunity => new DateTime(opportunity.DateSolde.Year, opportunity.DateSolde.Month, 1))  
                                 .Select(group => new  
                                 {  
                                     Revenue = group.Count(),  
                                     Month = group.Key  
                                 });  
                                     
            return Ok(JsonSerializer.Serialize(result, new JsonSerializerOptions  
            {  
                PropertyNamingPolicy = null  
            }));  
        }  

In razor page

<RadzenFieldset Text="Graphique">  
                    <RadzenChart>  
                        <RadzenColumnSeries Data="@graphSales" CategoryProperty="Month" ValueProperty="Revenue" LineType="LineType.Dashed" />  
                                                <RadzenColumnOptions Radius="5" />  
                        <RadzenCategoryAxis Padding="20" FormatString="{0:MMM}" />  
                        <RadzenValueAxis>  
                            <RadzenGridLines Visible="true" />  
                            <RadzenAxisTitle Text="Quantité" />  
                        </RadzenValueAxis>  
                    </RadzenChart>  
  
                </RadzenFieldset>  
  
  
@code {  
  
    private IEnumerable<RevenueByMonth> graphSales;  
  
    protected override async Task OnInitializedAsync()  
    {  
         
        graphSales = await RevenueByMonth();  
    }  
}  

I use the class

public class RevenueByMonth
{
public DateTime Month { get; set; }
public int Revenue { get; set; }
}

Thanks in advance to your help!

Developer technologies | .NET | Blazor
Developer technologies | C#
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.