This is a migrated thread and some comments may be shown as answers.

How to refresh chart

1 Answer 2105 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Bryon
Top achievements
Rank 1
Bryon asked on 25 Oct 2019, 08:40 PM

I have a parent component when contains a child component with a TelerikChart.  Using cascading parameters, when I change a value in the parent component it cascades to the child and I rerun queries to create the proper data for the chart.  Often times, but no all the time, a chart will rerender with some of the old data mixed in with some of the new data, even though the data model only contains the new data.

Is there a way to force the chart to totally clear out before rerendering?

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 28 Oct 2019, 07:59 AM

Hi Bryon,

Calling .StateHasChanged() after you change the data should re-render the charts and have them use the new data. Something like:

 

        chartData = await GetTheNewChartData();

        StateHasChanged()

 

If this does not help, you can also call the chart's .Refesh() method (perhaps after a small timeout). Something like:

 

        chartData = await GetTheNewChartData();

        await Task.Delay(20);

        //redraw the chart
        theChart.Refresh();

If neither of these helps, please post a simple example of what breaks so I can debug.

 

Regards,
Marin Bratanov
Progress Telerik

 UI for Blazor
Kevin
Top achievements
Rank 1
commented on 22 Jan 2022, 09:54 PM

hi, this doesn't solve for when you are using the chart as a child component and passing values through CascadingValue. 
Marin Bratanov
Telerik team
commented on 23 Jan 2022, 12:10 PM

Make sure the Data parameter of the chart gets a new references, not just a modified collection.

If this does not help, I recommend opening a ticket or a new thread to show the exact issue with an example, as I am not aware of such issues at the moment.

Tags
Charts
Asked by
Bryon
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or