We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

A linear pie chart?

Thread ID:





150128 Dec 21,2019 02:41 PM UTC Jan 7,2020 07:09 AM UTC Xamarin.Forms 1
Tags: SfChart
Asked On December 21, 2019 02:41 PM UTC

I'm looking for a chart that binds like a pie or doughnut series but looks like a StackingBar100Series. 

Hemalatha Marikumar [Syncfusion]
Replied On January 7, 2020 07:09 AM UTC

Hi Kyle, 
Greetings from Syncfusion 
We have analyzed your requirement and it can be achieved by creating a custom class for SfChart with Itemsource, XBindingPath and YBindingPath properties. Please refer the below code.   
Code snippet[C#] [PieChartExt.cs] 
public class PieChartExt : SfChart 
        public static readonly BindableProperty ItemsSourceProperty = 
            BindableProperty.Create("ItemsSource"typeof(object), typeof(PieChartExt), null, BindingMode.Default, null, OnItemsSourceChanged); 
        public static readonly BindableProperty XBindingPathProperty = 
            BindableProperty.Create("XBindingPath"typeof(string), typeof(PieChartExt), "XValue", BindingMode.Default, null); 
        public static readonly BindableProperty YBindingPathProperty = 
                BindableProperty.Create(nameof(YBindingPath), typeof(string), typeof(PieChartExt), "YValue", BindingMode.Default, null); 
        public object ItemsSource 
            get { return (object)GetValue(ItemsSourceProperty); } 
            set { SetValue(ItemsSourceProperty, value); } 
        public string XBindingPath 
            get { return (string)GetValue(XBindingPathProperty); } 
            set { SetValue(XBindingPathProperty, value); } 
        public string YBindingPath 
            get { return (string)GetValue(YBindingPathProperty); } 
            set { SetValue(YBindingPathProperty, value); } 
        private static void OnItemsSourceChanged(BindableObject bindable, object oldValue, object newValue) 
            (bindable as PieChartExt).GenerateSeries(newValue); 
        private void GenerateSeries(object newValue) 
            if (ItemsSource != null) 
                var commonItemsSource = (ItemsSource as IEnumerable).GetEnumerator(); 
                if (newValue is INotifyCollectionChanged) 
                    (newValue as INotifyCollectionChanged).CollectionChanged += DataPoint_CollectionChanged; 
                while (commonItemsSource.MoveNext()) 
Code Snippet [XAML] (MainPage.xaml) 
<local:PieChartExt x:Name="Chart" ItemsSource="{Binding Data}" XBindingPath="Component" YBindingPath="Price" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"> 
                <chart:ChartTitle Text="A Linear PieChart"  /> 
                <local:ViewModel x:Name="viewModel" /> 
                <chart:CategoryAxis IsVisible="False" ShowMajorGridLines="False" > 
                    <chart:NumericalAxis IsVisible="False" ShowMajorGridLines="False"> 
                <chart:ChartColorModel Palette="Natural"/> 
You can also customize the dynamically added and removed series and Width property used to customize the size of StackingBar100Series.  we have prepared a sample based your requirement and you can download the sample from the below link.  
Please let us know if you have any other concern. 
Hemalatha M. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon