Chart Data Not Showing

Data loaded from a API service not displaying in the chart. Chart shows but no data. Can confirm data is retrieved through debugging and locals. I have the correct script references in the App.razor.


This is a page on the client:

@page "/dispatch"

@rendermode InteractiveAuto

@inject IDispatchAPI DispatchAPI


<h3>Dispatch</h3>

<button class="btn btn-primary" @onclick="@GetData">Get Data</button>

<SfChart Title="Production Minutes">

    <ChartPrimaryXAxis Title="Date" ValueType="Syncfusion.Blazor.Charts.ValueType.DateTime"></ChartPrimaryXAxis>

    <ChartPrimaryYAxis Title="Prod Minutes"></ChartPrimaryYAxis>

    <ChartSeriesCollection>

        <ChartSeries DataSource="@prodMins" XName="completedDate" YName="totalProdMinutes" Type="ChartSeriesType.Line"></ChartSeries>

    </ChartSeriesCollection>


</SfChart>


@code {


    public List<ProductionMinutesByDay> prodMins { get; set; }


    protected override async Task OnInitializedAsync()

    {

        await base.OnInitializedAsync();

        prodMins = await DispatchAPI.GetProductionMinutesSeriesAsync("3500", DateTime.Parse("2023-01-01"), DateTime.Parse("2023-12-28"));

        StateHasChanged();

    }


    public async Task GetData()

    {

        prodMins = await DispatchAPI.GetProductionMinutesSeriesAsync("3500", DateTime.Parse("2023-01-01"), DateTime.Parse("2023-12-28"));

        StateHasChanged();

    }


}



Here is the App.razor on the server:

<!DOCTYPE html>

<html lang="en">


<head>

    <meta charset="utf-8" />

    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <base rel='nofollow' href="/" />

    <link rel='nofollow' href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />

    <link rel="stylesheet" rel='nofollow' href="bootstrap/bootstrap.min.css" />

    <link rel="stylesheet" rel='nofollow' href="app.css" />

    <link rel="stylesheet" rel='nofollow' href="Dispatch.styles.css" />

    <link rel="icon" type="image/png" rel='nofollow' href="favicon.png" />

    <script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js" type="text/javascript"></script>

    <HeadOutlet />

</head>


<body>

    <Routes />

    <script src="_framework/blazor.web.js"></script>

</body>


</html>


Here is model:

namespace Dispatch.Client.Models

{

public class ProductionMinutesByDay

{

public int totalProdMinutes { get; set; }

public DateTime completedDate { get; set; }

}



}






2 Replies

DT Daniel Tujo December 28, 2023 06:10 PM UTC

Breakpoint showing data in the objectImage_5365_1703786964170



DG Durga Gopalakrishnan Syncfusion Team December 30, 2023 02:20 AM UTC

Hi Daniel,


Greetings from Syncfusion.


We have ensured your reported scenario with your attached code snippet. Chart is rendered properly with both local and remote data. We have attached the tested sample and screenshots for your reference.


Local Data



Remote Data



Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/CRIssueProject-619117516.zip


If you are still facing, please try to replicate an issue in above sample or share us issue reproduced sample to validate this case further from our end. Kindly revert us if you have any concerns.


Regards,

Durga Gopalakrishnan.


Loader.
Up arrow icon