RadChart CustomPalettes error using LoadFromXml()

Thread is closed for posting
2 posts, 0 answers
  1. Paul
    Paul avatar
    1 posts
    Member since:
    Oct 2011

    Posted 31 Oct 2011 Link to this post

    If you define a custom palette in RadChart and use the LoadFromXml() method, the control will throw an error in FillStyle.GetHashCode().  Basically, what I think is going on there is that the PalettesCollection.GetPalette() method is throwing an error because the "CustomPalettes" property has not yet loaded the custom palette that is defined declaratively in the control’s XML markup on the aspx page.


    Relevant code in Telerik.Charting.PalettesCollection.PalettesCollection.cs:


    public static Palette GetPalette(string name, Chart chart)


          if (!chart.CustomPalettes.Contains(name))


            throw new ChartException(string.Format("There is no Palette with name: {0}", name));



          return chart.CustomPalettes.GetPalette(name);



    Declarative definition sample in the aspx page:


                <telerik:Palette Name="CustomPaletteColorful">


                        <telerik:PaletteItem MainColor="0xff, 0xba, 0x4a" SecondColor="0xff, 0xf4, 0xe3">


                        <telerik:PaletteItem MainColor="0x15, 0xc5, 0x16" SecondColor="0xda, 0xf6, 0xda">


                        <telerik:PaletteItem MainColor="0xff, 0x5b, 0" SecondColor="0xff, 0xe5, 0xd7">




  2. Ves
    Ves avatar
    2926 posts

    Posted 03 Nov 2011 Link to this post

    Hi Paul,

    Please, find attached a small example with a suggestion for a workaround. Basically, it excludes the SeriesPalette property from the xml file, so that the chart is loaded correctly.

    Best regards,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top