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

Using Several palettes

1 Answer 52 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Marcelo
Top achievements
Rank 1
Marcelo asked on 07 Dec 2012, 10:09 AM
Hi,

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.

Regards,
Marcelo

1 Answer, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 10 Dec 2012, 03:17 PM
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,
Evgenia
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ChartView
Asked by
Marcelo
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Share this question
or