- Home
- Forum
- Xamarin.Forms
- Charts within a listview correctly display on 1st occurence - when refreshed they are not being displayed
Charts within a listview correctly display on 1st occurence - when refreshed they are not being displayed
I have a custom Item template within a listview which actually includes a graph (pie chart). The xaml is as follows
Attachment: ChartProb_9b259b86.zip
<ListView x:Name="List1">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal" >
<chart:SfChart>
<chart:SfChart.BackgroundColor>
<Color>Gray</Color>
</chart:SfChart.BackgroundColor>
<chart:DoughnutSeries ItemsSource ="{Binding MyProperty}" XBindingPath="Item" YBindingPath="Value">
<chart:DoughnutSeries.ColorModel>
<chart:ChartColorModel Palette="Custom" CustomBrushes="{StaticResource Colors}"/>
</chart:DoughnutSeries.ColorModel>
</chart:DoughnutSeries>
</chart:SfChart>
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Horizontal" >
<!--<Label Text="StartTime"></Label>-->
<Label FontSize="Small" Text="{Binding StartTime}"></Label>
<!--<Label Text="COunt"></Label>-->
<Label FontSize="Small" Text="{Binding QuestionCount}"></Label>
</StackLayout>
<StackLayout Orientation="Horizontal" >
<Label Text="Correct"></Label>
<Label FontSize="Small" Text="{Binding Correct}"></Label>
<Label FontSize="Small" Text="Incorrect"></Label>
<Label FontSize="Small" Text="{Binding Incorrect}"></Label>
<Label FontSize="Small" Text="Skipped"></Label>
<Label FontSize="Small" Text="{Binding Skipped}"></Label>
</StackLayout>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
When the pae is loaded the following code is run
QuizResults = GetTestHistory();
if (QuizResults.Count() != 0)
{
Data1 = new ObservableCollection<VmQuizData>();
//Lets use this to display the list
foreach (var item in QuizResults)
{
Data1.Add(new VmQuizData()
{
ID = item.Id,
Correct = item.Correct,
Incorrect = item.Incorrect,
Skipped = item.Skipped
});
}
List1.ItemsSource = Data1;
//List1.ItemsSource = QuizResults;
LblNoHistory.IsVisible = false;
List1.IsVisible = true;
}
else
{
LblNoHistory.IsVisible = true;
List1.IsVisible = false;
}
This displays the pie charts correctly and they are displayed for each item.
However, there is a refresh button which when clicked and should redisplay the data results in the correct values in the labels being displayed however the graphs are just shown as blank dark squares where the pie charts were previously displayed.
I'm not sure why the charts are not subsequently displaying despite the data showing correctly - or the way to remedy.
Attachment: ChartProb_9b259b86.zip
SIGN IN To post a reply.
3 Replies
SJ
Suyamburaja Jayakumar
Syncfusion Team
March 11, 2020 10:47 AM UTC
Hi Spotty,
Greetings from Syncfusion.
We have analyzed the provided code snippet and you can resolve by setting the HorizontalOptions and VerticalOptions for chart. Please refer the below code snippet for more details.
XAML:
|
<ListView x:Name="List1">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal" >
<chart:SfChart HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
. . . . . .
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView> |
Please let us know if you need any further assistance on this.
Regards,
Suyamburaja J.
SP
Spotty
March 11, 2020 04:03 PM UTC
Could you elaborate on why they display initially, but on the refresh don't.
SJ
Suyamburaja Jayakumar
Syncfusion Team
March 12, 2020 02:09 PM UTC
Hi Spotty,
We would like to let you know what is reported in a DoughtSeries issue is a bug, and we have already logged this bug internally. We have planned to move this fix forward in our upcoming Volume 1 2020 release, which is expected to be rolled out by the end of March 2020.
Previously provided solution is just a workaround to resolve that reported issue.
Regards,
Suyamburaja J.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
SP Spotty
- Mar 10, 2020 04:22 PM UTC
- Mar 12, 2020 02:09 PM UTC