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

Spider Label Color

4 Answers 251 Views
This is a migrated thread and some comments may be shown as answers.
Cap
Top achievements
Rank 1
Cap asked on 20 Jul 2010, 12:48 PM
Hi, 

We are trying to set custom colors for Silces in a pie chart as given below .

private static Style CreateItemStyle(Control control, Style baseStyle, DataPoint dataPoint, DataSeries dataSeries)
        {
            if (control is ChartLegendItem)
                return baseStyle;

            if (dataPoint == null)
                return baseStyle;
            Style newStyle = new Style(baseStyle.TargetType);
            newStyle.BasedOn = baseStyle;
            if (control is BaseChartItem2D)
            {
                Brush brush = Utils.CustomDrawChart.Palette[ColorCount];
                newStyle.Setters.Add(new Setter(Shape.FillProperty, brush));
            }
            ColorCount++;
            return newStyle;
        }


But our spider labels are showing up in a different color( Obviously set by default rendering ) 
Any help on how to solve this?

Thanks 

Rosh

4 Answers, 1 is accepted

Sort by
0
Cap
Top achievements
Rank 1
answered on 21 Jul 2010, 07:24 AM
Helloooooooooooooo helloo.... (echo) 

Any little help here ? - admin? Vladimir ??

0
Sia
Telerik team
answered on 21 Jul 2010, 02:14 PM
Hi Cap,

You need to add another if condition concerning the labels in your code as follows:
if (control is SeriesItemLabel)
{
   Brush brush = new SolidColorBrush(Colors.Red);
   newStyle.Setters.Add(new Setter(SeriesItemLabel.FillProperty, brush));
   newStyle.Setters.Add(new Setter(SeriesItemLabel.StrokeProperty, brush));
}

Of course you need to use the same color as the one for the slices:
Brush brush = Utils.CustomDrawChart.Palette[ColorCount];

Regards,
Sia
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
0
Jeff Kershner
Top achievements
Rank 1
answered on 08 Sep 2010, 01:00 AM
I have a similar problem where I am using the chart.CreateItemStyleDelegate.  My spider lines and backgrounds are also the wrong colors. 

private Style BuildCustomItemStyle(Control item, Style style, DataPoint point, DataSeries dataSeries)
{
    if ((item as BaseChartItem) == null)
        return style;
  
    Style newStyle = new Style();
    newStyle.BasedOn = style;
  
    newStyle.TargetType = typeof(Shape);
  
    Brush brush;
  
    switch ((item as BaseChartItem).CurrentIndex % 7)
    {
        case 0:
            brush = new SolidColorBrush(Color.FromArgb(255, 2, 123, 8));
            break;
  
        case 1:
            brush = new SolidColorBrush(Color.FromArgb(255, 238, 192, 5));
            break;
  
        case 2:
            brush = new SolidColorBrush(Color.FromArgb(255, 238, 97, 6));
            break;
  
        case 3:
            brush = new SolidColorBrush(Color.FromArgb(255, 1, 240, 6));
            break;
  
        case 4:
            brush = new SolidColorBrush(Color.FromArgb(255, 238, 240, 6));
            break;
  
        case 5:
            brush = new SolidColorBrush(Color.FromArgb(255, 179, 181, 183));
            break;
  
        default://case 6:
            brush = new SolidColorBrush(Color.FromArgb(255, 237, 240, 242));
            break;
    }
  
    newStyle.Setters.Add(new Setter(Shape.FillProperty, brush));
    return newStyle;
}
0
Sia
Telerik team
answered on 10 Sep 2010, 08:35 AM
Hello Jeff Kershner,

Please check my answer here.

Greetings,
Sia
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
Cap
Top achievements
Rank 1
Answers by
Cap
Top achievements
Rank 1
Sia
Telerik team
Jeff Kershner
Top achievements
Rank 1
Share this question
or