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

"No data found" on navigating Back

1 Answer 28 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Matthias
Top achievements
Rank 1
Matthias asked on 03 Sep 2019, 08:44 AM

Hello,

I'm using the bar series in my UWP app:

The code behind:

        public class LineChartData
        {
            public int Value { get; set; }
            public string Name { get; set; }
        }

        public ObservableCollection<LineChartData> ParticipationData { get; set; } = new ObservableCollection<LineChartData>();

 

The XAML code:

                            <telerik:RadCartesianChart Name="dgrm_1" PaletteName="DefaultLight" Height="250">
                                <telerik:RadCartesianChart.HorizontalAxis>
                                    <telerik:CategoricalAxis/>
                                </telerik:RadCartesianChart.HorizontalAxis>
                                <telerik:RadCartesianChart.VerticalAxis>
                                    <telerik:LinearAxis/>
                                </telerik:RadCartesianChart.VerticalAxis>
                                <telerik:RadCartesianChart.Grid>
                                    <telerik:CartesianChartGrid MajorLinesVisibility="Y" StripLinesVisibility="Y"/>
                                </telerik:RadCartesianChart.Grid>
                                <telerik:BarSeries Name="dgrm_1_bar" ItemsSource="{x:Bind Path=ParticipationData}">
                                    <telerik:BarSeries.ValueBinding>
                                        <telerik:PropertyNameDataPointBinding PropertyName="Value"/>
                                    </telerik:BarSeries.ValueBinding>
                                    <telerik:BarSeries.CategoryBinding>
                                        <telerik:PropertyNameDataPointBinding PropertyName="Name"/>
                                    </telerik:BarSeries.CategoryBinding>
                                </telerik:BarSeries>
                            </telerik:RadCartesianChart>

 

When I'm loading this page the first time the chart is loading without problems. But if I navigate to another page and then back to the page with the chart there's no displayed but only the message "No data found".

But I've ensured that the data is loaded to the ObservableCollection "ParticipationData" and if I check the values of the ItemsSource of the BarSieries then I can see the data of the ObservableCollection. So I think that only the UI is not refreshed. I've also tried the "UpdateLayout"-method. But this also not works.

 

Does someone has an idea what I can do?

 

Thank you in forward.

 

Best regards

Matthias

1 Answer, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 04 Sep 2019, 03:06 PM

Hello Matthias,

I don't see anything wrong with the code. I've attached a demo using your code and it works as expected.

There are many reason why this could happen. The most common is the logic lifecycle with respect to data loading. If the page is not being cached, then you're getting a new instance of the page and if the data loading logic isn't used after re-instantiating ParticipationData, the it will be empty on all subsequent appearances.

Further Investigation

I recommend putting a breakpoint on that page's/viewmodel's data loading logic and navigation lifecycle. Inspect the contents of the ObservableCollection when navigating pack to the page. If the collection is indeed populated when the page is navigated back to, then please update my attached demo so that I can investigate directly.

Another thing you can try is to not use x:Bind and switch to traditional Binding. Alternatively set the x:Bind's binding Mode=OneWay (x:Bind's default is OneTime).

If this doesn't help, then the next likely problem is the timing of the data loading logic. Please update my attached example so that it replicates the problem (this is important to isolate the Telerik code's responsibility away from the rest of the unrelated application logic). Reply back with a link that I can use to download the project. With this, I can take a closer look and give you a definitive answer.

Regards,
Lance | Technical Support Engineer, Principal
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Chart
Asked by
Matthias
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
Share this question
or