This is a migrated thread and some comments may be shown as answers.

Doughnut 2D Label color

2 Answers 34 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Enill
Top achievements
Rank 1
Enill asked on 11 May 2010, 05:09 PM
I have a Doughnut 2D Chart where i applied texture on the different slices by using a palettes.

The problem is that the label also have this texture image in the background and with the white text font it is pretty much unreadable.

I want to keep the image in the background of the different labels but i would like to change the font color to bold black.

How can i achive that?

Thanks in advance!

2 Answers, 1 is accepted

Sort by
0
Enill
Top achievements
Rank 1
answered on 11 May 2010, 05:53 PM
Actually i was able to change the color for all the label by changing the value of the Foreground property.

I am more interested in changing the font AND to know how could i change the color of each label individually.

Thanks!
0
Dwight
Telerik team
answered on 14 May 2010, 09:37 AM
Hello Enill,

Here is a sample code, that will allow you to change the appearance of each element through the code-behind:
private Brush[] brushes = new Brush[] {
    new SolidColorBrush(Colors.Red),
    new SolidColorBrush(Color.FromArgb(64, 0, 255, 255)),
    new SolidColorBrush(Color.FromArgb(128, 255, 0, 255))
};
   
public MainPage()
{
    InitializeComponent();
   
    this.radChart1.CreateItemStyleDelegate = CustomItemStyle;
}
   
private Style CustomItemStyle(Control item, Style baseStyle, DataPoint dataPoint, DataSeries dataSeries)
{
    Style style = baseStyle;
   
    if (item is SeriesItemLabel)
    {
        SeriesItemLabel itemLabel = item as SeriesItemLabel;
        style = new Style(baseStyle.TargetType);
        style.BasedOn = baseStyle;
   
        Brush brush = brushes[dataSeries.IndexOf(dataPoint) % brushes.Length];
   
        style.Setters.Add(new Setter(SeriesItemLabel.FillProperty, brush));
    }
    return style;
}

The RadChart.CreateItemStyleDelegate is called for each chart item, each chart item's label, and each legend item.

You can use it together with the PaletteBrushes collection and the Appearance API.

Best wishes,
Joshua
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
Tags
Chart
Asked by
Enill
Top achievements
Rank 1
Answers by
Enill
Top achievements
Rank 1
Dwight
Telerik team
Share this question
or