Duplicate pie slice colors?

Thread is closed for posting
7 posts, 1 answers
  1. Dan
    Dan avatar
    202 posts
    Member since:
    May 2006

    Posted 25 Sep 2009 Link to this post

    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
  2. Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 28 Sep 2009 Link to this post

    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> 

  3. Dan
    Dan avatar
    202 posts
    Member since:
    May 2006

    Posted 28 Sep 2009 Link to this post

    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
  4. Answer
    Ves
    Admin
    Ves avatar
    2926 posts

    Posted 30 Sep 2009 Link to this post

    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.
  5. Dan
    Dan avatar
    202 posts
    Member since:
    May 2006

    Posted 30 Sep 2009 Link to this post

    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); 
  6. John
    John avatar
    8 posts
    Member since:
    Mar 2009

    Posted 10 Feb 2010 Link to this post

    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
  7. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 12 Feb 2010 Link to this post

    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.
Back to Top