Setting Individual Offset for Each Pie Slice

To set the offset for each pie slice, use the following code:

var ds = new DataSeries() { ValuesSource = new double[] { 1, 2, 2, 1, 2, 1, 2 } };
ds.PlotElementLoaded += (s, e) =>
{
var slice = s as PieSlice;
if (slice != null)
{
// add offset for even slices
if ((slice.DataPoint.PointIndex % 2) == 0)
slice.Offset = 15;
}
};

chart.Data.Children.Add(ds);
chart.ChartType = ChartType.Pie;


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.