PieChart / OffsetFromCenter not working when set on databound items

2 posts, 0 answers
  1. Lars-Erik
    Lars-Erik avatar
    4 posts
    Member since:
    Aug 2011

    Posted 10 Dec 2012 Link to this post

    Hi, I'm having trouble getting the OffsetFromCenter property working when using databound items instead of static. 

      <telerik:RadPieChart x:Name="TestChart">
                <telerik:PieSeries ValueBinding="Value" RadiusFactor="0.77">
                        <telerik:AngleRange StartAngle="270" SweepAngle="360" />
                        <Style TargetType="Path">
                            <Setter Property="Fill" Value="#D95921" />
                            <Setter Property="Stroke" Value="#FFFFFF" />

     private void LoadDataPoints()
                var series = new PieSeries();
                for (var i = 0; i < 10; i++)
                    series.DataPoints.Add(new PieDataPoint
                            Value = 10,
                            OffsetFromCenter = (i == 1? 0.07 : 0),
                            IsSelected = (i == 1)
                TestChart.Series[0].ItemsSource = series.DataPoints;

    Still renders the chart with each datapoint having the same distance from center. 

    br, Lars-Erik
  2. Nikolay
    Nikolay avatar
    384 posts

    Posted 13 Dec 2012 Link to this post

    Hi Lars-Erik,

    The OffsetFromCenter property in your sample does not have any effect because it is not a part of the business object DataPoint, to which you have bound your chart.

    In order to set it dynamically you can subscribe to the DataBindingComplete event in the following manner :
    <telerik:PieSeries ValueBinding="Value" RadiusFactor="0.77"  DataBindingComplete="PieSeries_DataBindingComplete">
    private void PieSeries_DataBindingComplete(object sender, EventArgs e)
                (sender as PieSeries).DataPoints[1].OffsetFromCenter = 0.07;
                (sender as PieSeries).DataPoints[1].IsSelected = true;

    Hope this helps.

    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
Back to Top