PieChart how to hide Legend area

4 posts, 0 answers
  1. qwer
    qwer avatar
    18 posts
    Member since:
    Oct 2010

    Posted 10 Jan 2011 Link to this post

    Hi all,

    I set LegendDisplayMode="None", but I can still see the Legend Colum. (above pie chart in my uploaded picture)
    <telerik:PieSeriesDefinition ShowItemToolTips="True" LegendDisplayMode="None">
    I want to hide the whole Legend Area as I want to show as (below pie chart in my uploaded picture).
    And I don't want to show ItemLabelFormat which is 0.00%.

    Please advise for my requirements.

    I'm using MVVM approach, so no code behind file.

    Thanks in advance.
    qwer
  2. Evgenia
    Admin
    Evgenia avatar
    1437 posts

    Posted 13 Jan 2011 Link to this post

    Hi,

    To make the chart Legend invisible set the Visibility property to Collapsed:
    radChart.DefaultView.ChartLegend.Visibility = System.Windows.Visibility.Collapsed;
    To disable the Percentage appearance of the pie labels just remove the ItemLabelFormat code line.

    I hope this helps.

    Kind regards,
    Evgenia
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. qwer
    qwer avatar
    18 posts
    Member since:
    Oct 2010

    Posted 13 Jan 2011 Link to this post

    Thanks for reply
    and invisible for Legend is working.

    For ItemLabelFormat, I want to show ItemLabel % when value is greater than 0, I don't want to show ItemLabel% when which is equal to 0%. Any Advise?

    thanks
  4. Evgenia
    Admin
    Evgenia avatar
    1437 posts

    Posted 18 Jan 2011 Link to this post

    Hello,

    To be able to show Percentage format for those pie slices that are not 0 you can use this approach:
    Subscribe to ItemDataBound event of the chart. Then set Percentage LabelFormat property if DataPoint's YValue is not 0 like this:
    private void radChart1_ItemDataBound(object sender, ChartItemDataBoundEventArgs e)
            {
                if (e.DataPoint.YValue != 0)
                {
                    e.DataPoint.LabelFormat = "#%{p}";
                }
            }

    Kind regards,
    Evgenia
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Back to Top