Refresh Blazor Chart with WebAPI data

I have an area chart which is linked to a web API:

<SfChart @ref="Chart1">

<SfDataManager Url="@urlGetChart" CrossDomain="true" Adaptor="Adaptors.WebApiAdaptor"></SfDataManager>

It loads and displays data fine but I cannot get it to refresh when the data changes.
I have tried the following but the api calls and returns the new data but the chart is blank.

Chart1.UpdateChartData();

await Chart1.RefreshAsync();


4 Replies

GV Gopalakrishnan Veeraraghavan Syncfusion Team August 4, 2023 12:46 PM UTC

Hi Keith,


We have analyzed your query, but we need further clarification regarding the issue that arises when attempting to refresh a chart with data from a Web API. From your query, we are unable to pinpoint the exact problem related to the usage of the SfDataManager property and the RefreshAsync method. To better assist you, could you please provide more detailed information about the dynamic data changes in the Web API?


As an alternative approach, we recommend considering the use of the "StateHasChanged" method instead of the "RefreshAsync" method. However, please note that even with this approach, you might encounter challenges. To facilitate a quicker resolution, we kindly request you to share a code snippet illustrating the dynamic data changes in the Web API URL. Providing a sample of the code would greatly aid us in offering a more prompt and accurate solution.


Regards,

Gopalakrishnan Veeraraghavan



KD Keith Darby August 4, 2023 04:57 PM UTC

Hi, 

Please find attached an example of the type of the code I am wanting to use.

A dialog is opened and a new value is added, when the dialog closes the API is getting called by the RefreshAsync and returns the updated data but the chart is blanked.

I have tried replacing RefreshAsync with StateHasChanged but then the API does not get called and nothing happens.


Attachment: Example_59f38d1f.zip


GV Gopalakrishnan Veeraraghavan Syncfusion Team August 7, 2023 03:16 PM UTC

Hi Keith Darby,


We have considered your reported issue as a bug and have logged a defect report for it. This fix will be available in our patch release, which is scheduled to be rolled out on August 16th, 2023. We appreciate your patience until then. You can keep track of the bug using the feedback link below.


Feedback Link: When refreshing WebAPI chart data, the chart can be rendered with empty data in Blazor | Feedback Portal (syncfusion.com)


If you have any more specification/precise replication procedure or a scenario to be tested, you can add it as a comment in the portal.


Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.”



Regards,

Gopalakrishnan Veeraraghavan



GV Gopalakrishnan Veeraraghavan Syncfusion Team August 16, 2023 10:45 AM UTC

Keith,


We are glad to announce that our v22.2.9
patch release is rolled out; we have added the fix for reported issue. You can use the latest Syncfusion.Blazor.Charts NuGet package.


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/RefreshIssueFix-1675228395.zip


NuGet Package: https://www.nuget.org/packages/Syncfusion.Blazor.Charts/


We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.


Regards,

Gopalakrishnan Veeraraghavan


Loader.
Up arrow icon