Custom BarChart y-axis labels

2 posts, 1 answers
  1. Courtney
    Courtney avatar
    13 posts
    Member since:
    Apr 2007

    Posted 16 Jun 2014 Link to this post

    In our RadHtmlChart BarSeries we are providing custom series labels as you can see highlighted in green in the attached picture.

    We are doing this by simply setting the series LabelAppearance DataField property to a different database field which has the series data formatted the way we want to display it:
        <telerik:BarSeries Name="CategoryText"  DataFieldY="SeriesValue" >
            <LabelsAppearance Visible="true" DataField="SeriesValueFormatted"  />                            

    Basically the SeriesValueFormatted field is taking numbers in the thousands, dividing them by 1000, and showing a "K" on the end.  Numbers in the millions are divided by a million and displayed with an "M" on the end, and so on. (See green highlighted values on the attached picture).

    We need to do the same thing for the y-axis labels (See the yellow highlighted area on the attached picture).  In this example, our y-axis labels would be "0.00M", "4.00M", "8.00M", "12.00M", and "16.00M".  

     I do not see a DataField property in the y-axis LablesAppearance tag (as exists in the BarSeries) nor do I see a way of providing a custom template OR a way to call a method as the y-axis is being built/bound.

    How can we go about doing this? 


    p.s.  I THINKsomeone was trying to ask the same question 2 years ago:
    YAxis DataLabelsField?
    But it seems there was no resolution at the time but the support rep did same this would be added in the future.  2 years later is this now possible?

  2. Answer
    Danail Vasilev
    Danail Vasilev avatar
    1476 posts

    Posted 18 Jun 2014 Link to this post

    Hi Courtney,

    What actually the LabelsAppearance.DataField property does is to set #=dataItem.myDataSourceField# template for the labels, where myDataSourceField is a custom field from the data source. In order to format labels from a custom data source field you can also use templates. More information is available in the following resources:

    You can use templates for the axes too by setting them through the chartObject, as illustrated in this feedback item.

    Danail Vasilev

    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.

  3. DevCraft R3 2016 release webinar banner
Back to Top