RadChartView. How to use RadLegend??

3 posts, 1 answers
  1. srikanth
    srikanth avatar
    23 posts
    Member since:
    Jul 2012

    Posted 28 Mar 2013 Link to this post

    Hello. I'm using RadCartesianChart to show some data in Stacked Bar Series. I want to have dynamic number of series and for that i use
    RadCartesianChart.SeriesProvider. I want to bind legend to my chart but legend doesn't display at the window. Here is snippets of code that i use in XAML:

            <telerik1:RadCartesianChart x:Name="Chart"
                    <telerik1:CategoricalAxis />
                    <telerik1:LinearAxis />
                    <telerik1:CartesianChartGrid StripLinesVisibility="Y">
                            <SolidColorBrush Color="#F2F2F2" />
                            <SolidColorBrush Color="Transparent" />

                    <telerik1:ChartSeriesProvider Source="{Binding DailyDatas}">

                            <telerik1:CategoricalSeriesDescriptor CategoryPath="HourName"
                                    <Style TargetType="telerik1:BarSeries">
                                        <Setter Property="CombineMode" Value="Stack" />


            <telerik1:RadLegend Items="{Binding ElementName=Chart, Path=LegendItems}"/>

    DailyDatas is an ObservableCollection of DailyData:

        public class HourInfo
            public string HourName { get; set; }
            public double? Value { get; set; }

        public class DailyData
            public string RoleName { get; set; }
            public ObservableCollection<HourInfo> Data { get; set; }

    What am i doing wrong? Maybe there is another way to make dynamic number of stacked bar series?
    Suggest me please asap! Thank you in advance!
  2. Answer
    Petar Marchev
    Petar Marchev avatar
    996 posts

    Posted 01 Apr 2013 Link to this post

    Hello Srikanth,

    You can check our Browsers example where the described is achieved. I think you need to simply add a Setter targeting the LegendSettings property: 

    <Style TargetType="telerik1:BarSeries">
     <Setter Property="CombineMode" Value="Stack" />
     <Setter Property="LegendSettings">
      <telerik1:SeriesLegendSettings Title="{Binding RoleName}" />

    By default the series are created with no legend settings. This is the way to tell the chart not to produce legend a item for a series. When you need to have a legend item for a series you must set the LegendSettings property of the series in mind. Let us know if you need further help.

    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. srikanth
    srikanth avatar
    23 posts
    Member since:
    Jul 2012

    Posted 01 Apr 2013 Link to this post

    Thank you a lot! All is working correctly!
Back to Top