RadPieChart ItemSelections

3 posts, 0 answers
  1. Afife Betül
    Afife Betül avatar
    5 posts
    Member since:
    Jun 2013

    Posted 24 Jun 2013 Link to this post

    Requirements

    RadControls version
    .NET version
    Visual Studio 2012
    WPF
    browser support

    all browsers supported by RadControls


    Hello,

    I need a PieChart and I am trying to use RadPieChart. But I want to select item that is slice of my PieChart. So, I can show my users that select to want item to change OffsetFromCenter Value.

    Thank you for helping.
  2. Rosko
    Admin
    Rosko avatar
    137 posts

    Posted 27 Jun 2013 Link to this post

    Hello Afife Betül,

    It is a bit hard for me to understand your exact inquiry, so I will offer you two options.

    The first one, if you want to select one of the slices in runtime and it expands. You just need to add a selection behavior.
    <telerik:RadPieChart x:Name="PieChart" Grid.Row="1">
                <telerik:PieSeries ValueBinding="Value" RadiusFactor="0.77">
                </telerik:PieSeries>
                <telerik:RadPieChart.Behaviors>
                    <telerik:ChartSelectionBehavior SelectionChanged="ChartSelectionBehavior_SelectionChanged"/>
                </telerik:RadPieChart.Behaviors>
    </telerik:RadPieChart>

    The other one, I am thinking of is you want to have one of the slices expanded from the start. You can check how to achieve that in this online demo with source code.

    Regards,
    Rosko
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. kavosh
    kavosh avatar
    1 posts
    Member since:
    Mar 2011

    Posted 14 Jul 2013 Link to this post

    Hi Afife

    What you actually need is to use the event Rosko mentioned, but you have to add below code to the event handler to do what you need.

    private void ChartSelectionBehavior_SelectionChanged(object sender, ChartSelectionChangedEventArgs e)
            {
                var selectedPoints = e.AddedPoints;
                if (selectedPoints.Count > 0)
                {
                    PieDataPoint point = (PieDataPoint) selectedPoints[0];
                    point.OffsetFromCenter = 0.1;
                }
     
                var otherPoints = e.RemovedPoints;
                if (otherPoints.Count > 0)
                {
                    foreach (PieDataPoint otherPoint in otherPoints)
                    {
                        otherPoint.OffsetFromCenter = 0;
                    }
                }
            }

    Regards,
    Kavosh
Back to Top