Pie Chart Labels/Values

5 posts, 0 answers
  1. Xavier Soares
    Xavier Soares avatar
    39 posts
    Member since:
    Jun 2008

    Posted 15 Sep 2008 Link to this post

    Hello,

    Is it possible in pie chart show the slice name and correspondent value?

    I only can show or one or other.

    Thank you.
    LM

  2. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 16 Sep 2008 Link to this post

    Hi Luis,

    Thank you for contacting us. There are two solutions to the problem:
    1. Handle the ItemDataBound event and set the corresponding label's text to the one you want. Through the event arguments you can access the data item that is currently binding to the ChartItem.
    2. If your data source is DataTable, create a new expression column, which concatenates the label and the value. Then use this column as source for the pie chart's labels.
    Should you need further assistance, do not hestitate to write us back.

    Regards,
    Evtim
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Xavier Soares
    Xavier Soares avatar
    39 posts
    Member since:
    Jun 2008

    Posted 16 Sep 2008 Link to this post

    Hello,

    The second option don't seems to help because I need to show the name and the corresponding percentage, not the value.

    Can you give an hand with the first option?

    By the way, the sample that is in the RadChart help is what I need (Mailbox Space in Rad Chart Basics).

    Thank You.
    LM
  5. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 19 Sep 2008 Link to this post

    Hello Luis,

    This approach requires you to handle the ItemDataBound event. Here is a sample handler method:
    1 void radChart1_ItemDataBound(object sender, ChartItemDataBoundEventArgs e) 
    2
    3     DataRowView row = e.DataItem as DataRowView; 
    4     e.SeriesItem.Label.TextBlock.Text = string.Format("{0}, value = #%", row["Text"]); 
    5
    Note, that the current example assumes the data source is DataTable and the data item supplied is DataRowView. The #% in the string tells the chart that it should put percentage at that place in the string.

    Regards,
    Evtim
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Xavier Soares
    Xavier Soares avatar
    39 posts
    Member since:
    Jun 2008

    Posted 19 Sep 2008 Link to this post

    Worked! Thank You.

    LM
Back to Top
UI for WinForms is Visual Studio 2017 Ready