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.
Unfortunately, activation email could not send to your email. Please try again.

Show category in pie chart

Thread ID:

Created:

Updated:

Platform:

Replies:

126073 Sep 21,2016 02:18 PM Sep 27,2016 08:31 AM Xamarin.Android 5
loading
Tags: SfChart
Joseph Martinez
Asked On September 21, 2016 02:18 PM

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 07:55 AM

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 02:06 AM

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 07:23 AM

  
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 02:08 PM

Thanks, that worked great!

Yuvaraj Palanisamy [Syncfusion]
Replied On September 27, 2016 08:31 AM

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.

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.

;