Hi Christopher,
Thank you for writing again.
Please have a look at this implementation of the layout strategy. You can use it as a basis for further tweaking.
public partial class MainPage : PhoneApplicationPage
{
public MainPage()
{
InitializeComponent();
this.chart.Series[0].ItemsSource = new int[] { 1,1,1,1 };
PieChartLabelStrategy strategy = new PieChartLabelStrategy(this.chart);
ChartSeriesLabelDefinition definition = new ChartSeriesLabelDefinition();
definition.Strategy = strategy;
this.chart.Series[0].LabelDefinitions.Add(definition);
}
}
public class PieChartLabelStrategy : ChartSeriesLabelStrategy
{
RadPieChart chart;
public PieChartLabelStrategy(RadPieChart chart)
{
this.chart = chart;
}
public override LabelStrategyOptions Options
{
get
{
return LabelStrategyOptions.Arrange;
}
}
public override RadRect GetLabelLayoutSlot(DataPoint point, FrameworkElement visual, int labelIndex)
{
PieDataPoint piePoint = (PieDataPoint)point;
IChartView view = this.chart as IChartView;
Point center = new Point(view.ViewportWidth / 2, view.ViewportHeight / 2);
double radius = (Math.Min(view.ViewportWidth , view.ViewportHeight) / 2) * 0.5;
visual.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
Size pointSize = new Size(visual.ActualWidth, visual.ActualHeight);
RadRect result = RadRect.Empty;
double angle = Math.Round(piePoint.StartAngle + piePoint.SweepAngle / 2) * 0.0174532925;
result.X = (center.X + radius * Math.Cos(angle)) - pointSize.Width / 2;
result.Y = (center.Y + radius * Math.Sin(angle)) - pointSize.Height / 2;
result.Width = pointSize.Width;
result.Height = pointSize.Height;
return result;
}
}
Please write again if you need further assistance.
Regards,
Victor
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>