How to choose a different background color for a chart label

6 posts, 1 answers
  1. developer10214
    developer10214 avatar
    4 posts
    Member since:
    Feb 2012

    Posted 09 Dec 2012 Link to this post

    Hello,

    I have pie chart and assigned a custom palette with 4 colors (red, green, orange and blue), only first fill color, no additional setting. This works well so far. I also want to display the according labels. This works also, but all the labels have the same background color as it corrensponding data point/segment. That I would like to change.
    When I don't use any palette than each segement has its own color but the all the labels have white background.

    Is there a way to change the background color of the labels?
  2. Answer
    Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 12 Dec 2012 Link to this post

    Hello,

    Thank you for writing.

    You can use the LableFormatting event of RadChartView to style lables. Here is an example which demonstrates how to make all labels with white back color:
    private void radChartView1_LabelFormatting(object sender, ChartViewLabelFormattingEventArgs e)
    {
      e.LabelElement.BackColor = Color.Red;
    }

    I hope this will help. Should you have further questions, I would be glad to help. 
     
    Kind regards,
    Ivan Petrov
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. developer10214
    developer10214 avatar
    4 posts
    Member since:
    Feb 2012

    Posted 13 Dec 2012 Link to this post

    Thank you for your answer. It works.
    Is there a chance that the Appearance-Properties as they where in the RadChart will be available in RadChartView too?

  5. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 18 Dec 2012 Link to this post

    Hi,

    Thank you for writing.

    RadChartView elements can be accessed and styled like every other control. You can access a label element using the following code:
    this.radChartView1.Series[0].Children[0].Children[0]
    In this example the series element has a collection of child elements which are the individual data points elements. Each data point element has a child element which is the label element.
    All elements in the chart view element hierarchy derive from UIChartElement. This is an element which has style properties and can be drawn within the chart control.

    I hope this is useful. Feel free to write back, should you need further assistance or more information.
     
    Kind regards,
    Ivan Petrov
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  6. Gokul
    Gokul avatar
    1 posts
    Member since:
    Aug 2015

    Posted 25 Aug 2015 in reply to developer10214 Link to this post

    can anyone give a clarification to a problem in this link

    http://www.telerik.com/forums/pie-chart-default-colours-so-similar#LidchSH-bUOZVpwvLZ1-oA

  7. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 25 Aug 2015 Link to this post

    Hi,

    The link you have posted is from our UI for ASP.NET AJAX forum, while the forum here concerns UI for WinForms. Please make sure you are posting in the proper forum to get proper answer. 
    Regards,
    Stefan
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WinForms is Visual Studio 2017 Ready