Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Chart > Pie Chart : Combine DataLabelsColumn and DefaultLabelValue
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered Pie Chart : Combine DataLabelsColumn and DefaultLabelValue

Feed from this thread
  • MisterG avatar

    Posted on May 5, 2011 (permalink)

    Hi,

    I'm tryiing to combine those two parameters without success (DataLabelsColumn, DefaultLabelValue) .

    Here is my data :

    State                       Total
    California                    120
    Nevada                        250
    Arizona                        40

    I'm trying to display for each part of the pie the name of the state and the percentage next to it without a legend for the chart.
    Ex: California (29%), Nevada (61%), Arizona (10%)
    When I specify DataLabelsColumn, I only see the name of the state.

    Do you have any idea if it is possible or not ?

    Thank you for your help,

    MisterG

  • Yavor Yavor admin's avatar

    Posted on May 10, 2011 (permalink)

    Hello MisterG,

    You can listen to ItemDataBound event and change the text for each SeriesItem Label like this:

    void RadChart2_ItemDataBound(object sender, ChartItemDataBoundEventArgs e)
    {
        e.SeriesItem.Label.TextBlock.Text = string.Format("{0} (#%)", (e.DataItem as DataRowView)["State"]);
    }
    Notice the #% string above. It gives you the percentage that this item represents when compared to others. I have attached the complete source code of a sample project that visualizes your data. Feel free to modify it as you please.

    Hope this helps!

    Greetings,
    Yavor Ivanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

    Attached files

  • MisterG avatar

    Posted on May 10, 2011 (permalink)

    Hi Yavor,

    Great ! That's what I was looking for.

    Thank you very much.

    Regards,

    MisterG

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Chart > Pie Chart : Combine DataLabelsColumn and DefaultLabelValue