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

Default series palette overrides custom palette

6 Answers 259 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Rayko
Top achievements
Rank 1
Rayko asked on 19 May 2010, 03:13 PM
Hello,
I'm trying to use a custom palette for the series in my bar chart because the Telerik-skin seems to contain only 6 default colors.
But when I create a custom palette the way shown below, the first 7 bar series are getting the default colors. Only series 8 and 9 are in the colors I created.
With a pie chart (1 series with 9 items) everything works fine.
Does anybody know this problem?

Best regards
Rayko

<body> 
    <form id="form1" runat="server"
     
    <telerik:RadChart ID="RadChart1" runat="server" Skin="DeepBlue" Width="700px" EnableViewState="false"/> 
         
    </form> 
</body> 

protected void Page_Load(object sender, EventArgs e) 
        { 
            if (!Page.IsPostBack) 
            { 
               CreateChart(); 
                 
            } 
        } 
         
         
 
        private void CreateChart() 
        { 
            RadChart1.Clear(); 
            RadChart1.PlotArea.XAxis.Clear(); 
             
            //CreatePie(); 
            CreateBar(); 
 
            SetSeriesColors(); 
        } 
 
        private void CreatePie() 
        { 
            ChartSeries series = new ChartSeries("PieSeries", ChartSeriesType.Pie); 
 
            for (int i = 1; i < 10; i++) 
            { 
                ChartSeriesItem newItem = new ChartSeriesItem(); 
                newItem.Name = "test"+i; 
                newItem.YValue = i; 
                series.Items.Add(newItem); 
 
            } 
 
            series.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels; 
             
            RadChart1.Series.Add(series); 
        } 
 
        private void CreateBar() 
        { 
            for (int i = 1; i < 10; i++) 
            { 
                ChartSeries series = new ChartSeries("test" + i, ChartSeriesType.Bar); 
                ChartSeriesItem newItem = new ChartSeriesItem(); 
                series.Name = "test" + i; 
                newItem.Name = "test" + i; 
                newItem.YValue = i; 
                 
                series.Items.Add(newItem); 
                series.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.SeriesName; 
 
                RadChart1.AddChartSeries(series); 
 
            } 
        } 
 
        private void SetSeriesColors() 
        { 
            Color[] seriesColors = new[] 
                                       { 
                                           Color.Red, 
                                           Color.Yellow, 
                                           Color.Black, 
                                           Color.Blue, 
                                           Color.White, 
                                           Color.Green, 
                                           Color.MediumPurple, 
                                           Color.Brown, 
                                           Color.Orange, 
                                           Color.Gray 
                                       }; 
 
            Palette seriesPalette = new Palette("seriesPalette", seriesColors, true); 
            RadChart1.CustomPalettes.Add(seriesPalette); 
            RadChart1.SeriesPalette = "seriesPalette"
 
             
        } 

6 Answers, 1 is accepted

Sort by
0
Dwight
Telerik team
answered on 21 May 2010, 02:52 PM
Hello Rayko,

You need to set
RadChart.SkinsOverrideStyles = false;

That should do the trick.

All the best,
Joshua
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
Rayko
Top achievements
Rank 1
answered on 25 May 2010, 03:28 PM
Hello Joshua,
Unfortunately that doesn't work. I've already tried it before.

Best regards
Rayko

ps: I'm using version 2010.1.309.35
0
Ves
Telerik team
answered on 27 May 2010, 09:20 AM
Hello Rayko,

Please, configure the series palette before creating the series. That is -- move the call to SetSeriesColors() method before the call to CreateBar().

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.
0
Rayko
Top achievements
Rank 1
answered on 27 May 2010, 09:51 AM
Hello Ves,

I've set SkinsOverrideStyles="false" and SetSeriesColors() before CreateBar(). With no effect. The first 7 colors of the bar chart are still from Telerik skin (7th same as first).

Best regards
Rayko
0
Accepted
Ves
Telerik team
answered on 01 Jun 2010, 01:12 PM
Hi Rayko,

Please, use this code:

ColorBlend[] seriesColors = new ColorBlend[] {
                new ColorBlend(new Color[] { Color.Red, Color.Red}),
                new ColorBlend(new Color[] { Color.Yellow, Color.Yellow}),
                new ColorBlend(new Color[] { Color.Black, Color.Black}),
                new ColorBlend(new Color[] { Color.Blue, Color.Blue}),
                new ColorBlend(new Color[] { Color.White, Color.White}),
                new ColorBlend(new Color[] { Color.Green, Color.Green}),
                new ColorBlend(new Color[] { Color.MediumPurple, Color.MediumPurple}),
                new ColorBlend(new Color[] { Color.Brown, Color.Brown}),
                new ColorBlend(new Color[] { Color.Orange, Color.Orange}),
                new ColorBlend(new Color[] { Color.Gray, Color.Gray})


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.
0
Rayko
Top achievements
Rank 1
answered on 02 Jun 2010, 09:40 AM
Hello Ves,
Thank you. That was it!
It doesn't matter if I set SkinsOverrideStyles or use SetSeriesColors() before CreateBar(). All I have to do is using ColorBlend ;-}

Best regards
Rayko
Tags
Chart (Obsolete)
Asked by
Rayko
Top achievements
Rank 1
Answers by
Dwight
Telerik team
Rayko
Top achievements
Rank 1
Ves
Telerik team
Share this question
or