RadHTMLChart (Single Bar/Column Series) Datasource Legend?

Thread is closed for posting
4 posts, 0 answers
  1. Adam
    Adam avatar
    7 posts
    Member since:
    Sep 2013

    Posted 16 Sep 2013 Link to this post

    Hi All, quick question, I've gone through all the demo pages for the RadHTMLChart, gone through Google and here and not found anything that would work with how I've done my Data source...

    I've passed a list of 2 columns to my RadHTMLChart Bar or Column series chart, 1st column is the name of the row and the 2nd column is the value to be plotted... I've done this with a single Series and it plots all the data fine, I then set the XAxis DataLabelsField to the Name column and all the labels display correctly for each column/bar...

    My question is this: -

    How do I get a Legend to show up? The way I see it, the legend will only appear if there are multiple Series set on the ASPX page, but as the series gets populated from code no legend appears... I've tried creating a Legend programmatically and failed miserably, There just doesn't seem to be a property to add an item to the legend or at least set the Legend source to the Name column of the Data source?

    If I switch this all the to the Pie Chart I then get a property to set the NameField on the series which if I set this to the Name column, the Legend works tip-top!

    Any way of getting this 'NameField' property to be available on the Bar Series / Column Series also?

    Thanks, Adam.
  2. Stamo Gochev
    Stamo Gochev avatar
    188 posts

    Posted 19 Sep 2013 Link to this post


    As the main purpose of RadHtmlChart's Legend is to show information which is connected with the displayed data, there is no property which allows populating custom legend items.

    The NameField property is specific for PieSeries, DonutSeries and BubbleSeries, but you can achieve the same appearance in BarSeries and ColumnSeries by setting their Name property:

    <telerik:ColumnSeries DataFieldY="yValue" Name="column series"></telerik:ColumnSeries>
    Specifying a Name property for a series creates an "item" in the legend. Note that this property is used for setting series' names explicitly and the NameField property is its equivalent in a databind scenario.

    I also attach a sample page where I have databound a ColumnSeries and set its Name property, so you can check my suggestions. Feel free to contact me if you need any further assistance.

    Stamo Gochev
    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 the blog feed now.
  3. Shane
    Shane avatar
    1 posts
    Member since:
    Mar 2011

    Posted 17 Apr 2014 Link to this post

    Hi Stamo,

    Your reply doesn't seem to cover a scenario that I'm running into. I have 1 column series with different elements in the series. Each of these elements has it's own color and I'd like to display them in the legend instead of in the DataLabelsField. I can't see a way to do this as currently the legend will only display 1 item per series for a columnseries. chart. Is there any way around this?


    - Shane
  4. Stamo Gochev
    Stamo Gochev avatar
    188 posts

    Posted 22 Apr 2014 Link to this post

    Hi Shane,

    The purpose of the legend in RadHtmlChart is to display data from different sources, i.e. multiple series, pie chart segments, etc. This means that you cannot create individual legend items for each of the items in the Column/Bar series (as this should be done with separate series). That is why we do not provide any functionality for adding or removing custom legend elements.

    Stamo Gochev

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top