Need to change Bar series Color

2 posts, 0 answers
  1. kanna
    kanna avatar
    28 posts
    Member since:
    Aug 2007

    Posted 07 Sep 2012 Link to this post

    Hi,

    I am using RadChart control for Silverlight.When i am creating Bar Series it is showing with the same color. I need to change each item with separate color. Please find My Xaml and C# code.
    Please help me to resolve the issue.

    Regards,
    Kannan S
    <telerik:RadChart x:Name="radChart" telerik:StyleManager.Theme="Windows7"><br>            <telerik:RadChart.SeriesMappings><br>                <telerik:SeriesMapping><br>                    <telerik:SeriesMapping.SeriesDefinition><br>                        <telerik:BarSeriesDefinition/><br>                    </telerik:SeriesMapping.SeriesDefinition><br>                    <telerik:SeriesMapping.ItemMappings><br>                        <telerik:ItemMapping DataPointMember="YValue" FieldName="Val"/><br>                        <telerik:ItemMapping DataPointMember="Label" FieldName="LabelString"/><br>                    </telerik:SeriesMapping.ItemMappings><br>                </telerik:SeriesMapping><br>            </telerik:RadChart.SeriesMappings><br>        </telerik:RadChart>
    public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
                var list = new List<SomeInfo>();
                Random r = new Random();
                list.Add(new SomeInfo() { Val = 1, LabelString = "Item 1" });
                list.Add(new SomeInfo() { Val = 2, LabelString = "Item 2" });
                list.Add(new SomeInfo() { Val = r.Next(0, 10), LabelString = "Item 3" });
                list.Add(new SomeInfo() { Val = r.Next(0, 10), LabelString = "Item 4" });
                list.Add(new SomeInfo() { Val = r.Next(0, 10), LabelString = "Item 5" });
                list.Add(new SomeInfo() { Val = r.Next(0, 10), LabelString = "Item 6" });
                list.Add(new SomeInfo() { Val = r.Next(0, 10), LabelString = "Item 7" });
                list.Add(new SomeInfo() { Val = r.Next(0, 10), LabelString = "Item 8" });
                list.Add(new SomeInfo() { Val = r.Next(0, 10), LabelString = "Item 9" });
     
     
                radChart.ItemsSource = list;
            }
        }
     
        public class SomeInfo
        {
            public int Val { get; set; }
            public string LabelString { get; set; }
     
        }
  2. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 10 Sep 2012 Link to this post

    Hi Kanna,

    You need to set the LegendDisplayMode to DataPointLabel:
    <telerik:BarSeriesDefinition LegendDisplayMode="DataPointLabel" />

    Kind regards,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
Back to Top