LayTec-AG / Plotly.Blazor

This library packages the well-known charting library plotly.js into a razor component that can be used in a Blazor project.
MIT License
346 stars 48 forks source link

Async Function chart.React() is awaitable but blocks UI #206

Closed Vkhark closed 1 year ago

Vkhark commented 2 years ago

Hi,

Im using Blazor with Telerik, but i wasn't a fan of their charts, so I decided to try these out. after asynchronysly loading the data i call "await chart.React()" so the Data in the chart is updated, Consequently my LoadingIcon is blocked and stops spinning for a couple of seconds until "chart.React" is finished.

Am I doing something wrong. Why is the chart not updates asynchronously, even if the function is awaitable.

Kind Regards, Vlad

sean-mcl commented 2 years ago

My first thought is that in the background the JavaScript library of plotly.js is accessed and accordingly the JS methods are called. To what extent is the behavior there, I can not judge.

If you want to add new data, then I recommend you to use chart.ExtendTraces(...). With this method you can extend the x and y values for multiple plots at once. If you want to replace the data completely, then you can set the limit to the number of new data to be added. This will automatically remove the old data. This method is much more efficient.

Vkhark commented 2 years ago

I have to initialize the chart once in a Popup and in some seldom cases it needs to get data again and reload with new Data (which most likely didnt even change).

I will give chart.ExtendTraces(....) a try. I'll let you know if it worked, once i get to it.

Thanks, Vlad

sean-mcl commented 2 years ago

I‘ve uploaded a live data example, which could be useful in this case.

https://delightful-pebble-00ab3ee10.1.azurestaticapps.net/live-data

sean-mcl commented 1 year ago

by the way, here is an open issue.

https://github.com/plotly/plotly.js/issues/1499

ldv-orbyta commented 4 months ago

I have to initialize the chart once in a Popup and in some seldom cases it needs to get data again and reload with new Data (which most likely didnt even change).

I will give chart.ExtendTraces(....) a try. I'll let you know if it worked, once i get to it.

Thanks, Vlad

It works?