Using Several palettes

2 posts, 0 answers
  1. Marcelo
    Marcelo avatar
    14 posts
    Member since:
    Jun 2011

    Posted 07 Dec 2012 Link to this post


    In my page I have a pie ChartView, and I am using the palette = "Windows8".
    If this graph has more than 8(number of colors in palette) DataPoints, will repeat the colors.

    To avoid this I am using a class to generate colors, but are left with a very different tone.

    public class RandomPastelColorGenerator
            private readonly Random _random;
            public RandomPastelColorGenerator()
                const int RandomSeed = 2;
                _random = new Random(RandomSeed);
            public SolidColorBrush GetNextBrush()
                SolidColorBrush brush = new SolidColorBrush(GetNext());
                return brush;
            public Color GetNext()
                byte[] colorBytes = new byte[3];
                colorBytes[0] = (byte)(_random.Next(0 , 245) + 127);
                colorBytes[1] = (byte)(_random.Next(91, 223) + 127);
                colorBytes[2] = (byte)(_random.Next(0 , 169) + 127);
                Color color = new Color();
                color.A = 255;
                color.R = colorBytes[0];
                color.B = colorBytes[1];
                color.G = colorBytes[2];
                return color;

    It would be possible to use more than one pallet, ie the element 9 would be a different color palette.

    Thank you.

  2. Evgenia
    Evgenia avatar
    1437 posts

    Posted 10 Dec 2012 Link to this post

    Hi Marcelo,

     Please refer to this forum post where it is demonstrated how you may create Custom Palette for RadChartView (the number of brushes in it is all up to you). If you need your custom palette to include the 8 colors from some of our predefined palettes, just let me know the Palette name and I will provide them.

    Kind regards,
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top