Custom Ordering of Pie Slices

2 posts, 0 answers
  1. Colter
    Colter avatar
    10 posts
    Member since:
    Apr 2013

    Posted 27 May 2013 Link to this post

    Hello Telerik,

    Is it possible to define the order that the Pie Slices in a RadPieChart will be drawn?  I've tried to order the set of data that I'm giving the chart series but to no avail.  

    var series = (RadChart as RadPieChart).Series.First();
    var orderedSet = DataSet.OrderBy(d => d.Series);
    series.ItemsSource = orderedSet;

    It looks like it is drawing the slices based on largest to smallest... which makes sense.  But what I'm trying to do is keep the individual slices (as I have attached other data of interest to each one) but get them grouped together when the pie chart draws them.  In the example image, each slice is a male and female population for a particular neighborhood respectively.  I want to be able to map from a pie slice to a neighborhood and vice versa.  Is there any way that this can be done?


  2. Petar Kirov
    Petar Kirov avatar
    425 posts

    Posted 30 May 2013 Link to this post

    Hi Colter,

    RadPieChart draws its slices in the same order as the corresponding data items appear in the ItemsSource. If you bind a ListBox to the same data, it should be ordered the same way. You can influence that order by reverting the pie direction. This is done by setting the PieSeries.AngleRange.SweepDirection property to Counterclockwise. If you want to order pie slices in a specific way, you just need to arrange the data items in the ItemsSource the same way.

    Given that you want to display male/female ratios for different neighborhoods, you may also consider using a different visualization, such as horizontal a Stacked100 Bar Chart. (See attached screenshot and sample project).

    I hope this helps.
    Petar Kirov

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top