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

Show category in pie chart

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.Legend.Visibility = Visibility.Visible;

5 Replies

YP Yuvaraj Palanisamy Syncfusion Team 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. 

JM Joseph Martinez September 24, 2016 06:06 AM UTC


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?

YP Yuvaraj Palanisamy Syncfusion Team 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.  

JM Joseph Martinez September 26, 2016 06:08 PM UTC

Thanks, that worked great!

YP Yuvaraj Palanisamy Syncfusion Team September 27, 2016 12:31 PM UTC

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

Live Chat Icon For mobile
Up arrow icon