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

Duplicate pie slice colors?

6 Answers 269 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 2
Dan asked on 25 Sep 2009, 02:34 PM
I have several pie charts developed within the Telerik Reporting component.  These pie charts are using the default slice colors.  The problem is that the chart is generating two adjacent slices with the same color.  This seems to be happening when there are 7 slices, and two of the slices next to each other are both blue.

Is this unusual?  Is there a solution other than setting my own colors in the code-behind?

Thanks.
Dan

6 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 28 Sep 2009, 01:31 PM
If you go above 7 slices do all of the new slices become the same blue? Do any other colors repeat? It would seem that there are a default of 6 colors, and the first and last slice start the color "cycle" anew. If these charts are defined in your asp page after you developed them in Reporting you could always define colors within the asp declaration of the control:

            <telerik:ChartSeries DataYColumn="yColumn" Name="myColumn"
                <Appearance> 
                    <FillStyle FillType="ComplexGradient" MainColor="222, 202, 155"
                        <FillSettings> 
                            <ComplexGradient> 
                                <telerik:GradientElement Color="222, 202, 152" /> 
                                <telerik:GradientElement Color="211, 185, 123" Position="0.5" /> 
                                <telerik:GradientElement Color="183, 154, 84" Position="1" /> 
                            </ComplexGradient> 
                        </FillSettings> 
                    </FillStyle> 
                    <TextAppearance TextProperties-Color="159, 159, 159"
                    </TextAppearance> 
                    <Border Color="187, 149, 58" /> 
                </Appearance> 
            </telerik:ChartSeries> 

0
Dan
Top achievements
Rank 2
answered on 28 Sep 2009, 02:53 PM
Yes, it appears that the pie chart has 6 colors.  Slice 7 is the same color as slice 1.  Slice 8 is the same color as slice 2.

Does anyone know offhand.  Do all pie charts have a default of 6 colors, or would changing skins perhaps give me a different result?

Dan
0
Accepted
Ves
Telerik team
answered on 30 Sep 2009, 07:39 AM
Hi Dan,  Schlurk

I would suggest implementing a custom palette here:

Color[] colors = new Color[] { Color.Red, Color.Pink, Color.Plum, Color.Blue, Color.Brown, Color.Violet, Color.Beige }; 
        Palette pal = new Palette(); 
        foreach (var color in colors) 
        { 
            pal.Items.Add(new PaletteItem(color, color)); 
        } 
        pal.Name = "MyPalette"
        radChart1.CustomPalettes.Add(pal); 
        radChart1.SeriesPalette = "MyPalette"

This way you can have as many colors as you need.

Kind regards,
Ves
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Dan
Top achievements
Rank 2
answered on 30 Sep 2009, 01:43 PM
Thanks for the palette coding example.  I wondered how to do that.

I ended up just resetting the slice 7 color in my code thus:

int iCount = 0;  
                foreach (DataRowView rowView in table.DefaultView)  
                {  
                    seriesItem = new Telerik.Reporting.Charting.ChartSeriesItem((double)rowView["Value"]);  
                    seriesItem.Name = (string)rowView["Rxtype"];  
                    seriesItem.Label.TextBlock.Text = (string)rowView["Rxtype"] + " - " + String.Format("{0:C}", rowView["Value"]);  
                    seriesItem.Label.TextBlock.Appearance.TextProperties.Color = Color.Black;  
                    iCount += 1;  
                    if (iCount == 7)  
                    {  
                        seriesItem.Appearance.FillStyle.MainColor = Color.CornflowerBlue;  
                        seriesItem.Appearance.FillStyle.SecondColor = Color.CornflowerBlue;  
                    }  
                    series.AddItem(seriesItem);  
                }  
 
                chartDef.Series.Clear();  
                chartDef.Series.Add(series); 
0
John
Top achievements
Rank 1
answered on 10 Feb 2010, 03:43 PM
Thanks for the Pallete idea.

I currently have a problem where my stacked bar chart does not change bar colors unless i use Solid... ie:

cs.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Solid;

Otherwise, the color does not change when I do this:

cs.Appearance.FillStyle.MainColor = Color.Yellow

Is this by design or something I am doing wrong?

Thanks,
John
0
Ves
Telerik team
answered on 12 Feb 2010, 09:25 AM
Hello John,

If you need to use a gradient set fill type to gradient and provide a value for SecondColor too. If that does not seem to help - please send us the code.

Best regards,
Ves
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 (Obsolete)
Asked by
Dan
Top achievements
Rank 2
Answers by
Schlurk
Top achievements
Rank 2
Dan
Top achievements
Rank 2
Ves
Telerik team
John
Top achievements
Rank 1
Share this question
or