- Home
- Forum
- Xamarin.Forms
- smart labels config
smart labels config
Hi, I develop cross-platform App using sfchart and sometimes I get zero (0) value data (of course from my db) to bind into pie chart. after activate smartlabel (EnableSmartLabels="true" ), all data, including zero value also appear on chart. My question is, any suggestion to hide zero value in label?
(I attached the picture of chart)
Thank you
SIGN IN To post a reply.
3 Replies
MK
Muneesh Kumar G
Syncfusion Team
September 2, 2019 10:18 AM UTC
Hi Ronanobelta Syakura,
Greetings from Syncfusion.
Query: How to hide the 0 value from DataMarker Label.
Your requirement can be achieved by excluding the zero value from the bound ItemsSource of PieSeries using Converter.
Please have code examples,
Chart XAML:
|
<chart:PieSeries x:Name="pieSeries" ItemsSource="{Binding Data,Converter={StaticResource ExcludeZeroConverter}}" EnableSmartLabels = "true" XBindingPath="Name" YBindingPath="Height"> <chart:PieSeries.DataMarker> <chart:ChartDataMarker ShowLabel="True"/> </chart:PieSeries.DataMarker> </chart:PieSeries> |
ExcludeZeroConverter:
|
public class ExcludeZeroConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var collection = value as List<Person>; return collection != null ? collection.Where(x => x.Height != 0).ToList() : value; } ....... } |
Here, Height is the YBindingPath property.
Please download the attached sample from below link
Thanks,
Muneesh Kumar G
RS
Ronanobelta Syakura
September 6, 2019 12:44 AM UTC
Works as expected. Thank you for your help
MK
Muneesh Kumar G
Syncfusion Team
September 6, 2019 05:11 AM UTC
Hi Ronanobelta Syakura,
Thanks for the update.
We are glad to know that the given solution works. Please let us know if you need any further assistance.
Thanks,
Muneesh Kumar G.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
RS Ronanobelta Syakura
- Aug 30, 2019 10:12 AM UTC
- Sep 6, 2019 05:11 AM UTC