This is a migrated thread and some comments may be shown as answers.

Custom BarChart y-axis labels

1 Answer 184 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Courtney
Top achievements
Rank 1
Courtney asked on 16 Jun 2014, 05:30 PM
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:
 
<Series>        
    <telerik:BarSeries Name="CategoryText"  DataFieldY="SeriesValue" >
        <LabelsAppearance Visible="true" DataField="SeriesValueFormatted"  />                            
    </telerik:BarSeries>
</Series>

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? 

Courtney

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?



















1 Answer, 1 is accepted

Sort by
0
Accepted
Danail Vasilev
Telerik team
answered on 18 Jun 2014, 09:43 AM
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:

http://demos.telerik.com/aspnet-ajax/htmlchart/examples/functionality/clienttemplates/defaultcs.aspx

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

Regards,
Danail Vasilev
Telerik
 

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.

 
Tags
Chart (HTML5)
Asked by
Courtney
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Share this question
or