Default series palette overrides custom palette

Thread is closed for posting
7 posts, 1 answers
  1. Rayko
    Rayko avatar
    27 posts
    Member since:
    Jul 2012

    Posted 19 May 2010 Link to this post

    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"
     
                 
            } 
  2. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 21 May 2010 Link to this post

    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.
  3. Rayko
    Rayko avatar
    27 posts
    Member since:
    Jul 2012

    Posted 25 May 2010 Link to this post

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

    Posted 27 May 2010 Link to this post

    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.
  5. Rayko
    Rayko avatar
    27 posts
    Member since:
    Jul 2012

    Posted 27 May 2010 Link to this post

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

    Posted 01 Jun 2010 Link to this post

    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.
  7. Rayko
    Rayko avatar
    27 posts
    Member since:
    Jul 2012

    Posted 02 Jun 2010 Link to this post

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