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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Show category in pie chart

Thread ID:

Created:

Updated:

Platform:

Replies:

126073 Sep 21,2016 06:18 PM UTC Sep 27,2016 12:31 PM UTC Xamarin.Android 5
loading
Tags: SfChart
Joseph Martinez
Asked On September 21, 2016 06:18 PM UTC

I am trying to make my pie chart show the categories (Cats, Dogs, etc. in my below code) instead of the numerical data, where the DataMarkers would be.  I can see the categories if I turn on the legend, but I prefer to see the categories in the pie itself, rather than in a separate legend

Here is the code I'm using:

            SfChart chart = new SfChart(this);

            CategoryAxis primaryAxis = new CategoryAxis();
            primaryAxis.Title.Text = "Animals";
            chart.PrimaryAxis = primaryAxis;

            NumericalAxis secondaryAxis = new NumericalAxis();
            secondaryAxis.Title.Text = "Number";
            chart.SecondaryAxis = secondaryAxis;

            ObservableArrayList Ratings = new ObservableArrayList();

            Ratings.Add(new ChartDataPoint("Cats", 3));
            Ratings.Add(new ChartDataPoint("Dogs", 5));
            Ratings.Add(new ChartDataPoint("Birds", 50));
            Ratings.Add(new ChartDataPoint("Fish", 20));
            Ratings.Add(new ChartDataPoint("Other", 120));

            PieSeries pieSeries = new PieSeries()
            {
                DataSource = Ratings,
            };

            chart.Series.Add(pieSeries);
            chart.Legend.Visibility = Visibility.Visible;


Yuvaraj Palanisamy [Syncfusion]
Replied On September 22, 2016 11:55 AM UTC

Hi Joseph Martinez, 
 
We have prepared a sample as per your requirement using DataMarkerLabelCreated event of ChartSeries. Please find the sample from the below location. 
 
  
Regards, 
Yuvaraj 


Joseph Martinez
Replied On September 24, 2016 06:06 AM UTC

Thanks!

Also, is it possible to show both the categories and the numerical data, with the categories on the outside of the pie, and the numerical values inside?

Yuvaraj Palanisamy [Syncfusion]
Replied On September 26, 2016 11:23 AM UTC

  
Hi Joseph Martinez,  
  
We have prepared a sample as per your requirement. Please find the sample from the below location.  
  
  
Regards,  
Yuvaraj  


Joseph Martinez
Replied On September 26, 2016 06:08 PM UTC

Thanks, that worked great!

Yuvaraj Palanisamy [Syncfusion]
Replied On September 27, 2016 12:31 PM UTC

Hi Joseph Martinez 
 
Thanks for the update. 
 
We are glad to know that the given solutions work. 
 
 
Regards, 
Yuvaraj 


CONFIRMATION

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.

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

;