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

How to change category label name

1 Answer 205 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Bulut
Top achievements
Rank 1
Bulut asked on 20 Sep 2018, 11:44 PM

How can I change category axis label names. 

http://dojo.telerik.com/uxoJA

 

For example in this example I want to keep months same just change the display name. IE: instead of "January" - "Month One" , just for january. and "Month 4" for April

1 Answer, 1 is accepted

Sort by
0
Accepted
Tsvetomir
Telerik team
answered on 21 Sep 2018, 05:21 PM
Hi Bulut,

Thank you for the provided Dojo example. 

The labels inside the categoryAxis property can contain a template which accepts either a string or a function as a value. A function could be used to replace the original text in a label with a custom one. There are numerous approaches that could be used to replace the text. I have used an object to store the months and their respective numbers as follows:

var otherAlternativeMonthNames = { January: "Month 1", February: "Month 2", March: "Month 3", April: "Month 4"};

Their respective custom text could be accessed via the value of the argument passed to the function as follows:

$("#chart").kendoChart({
  categoryAxis: [{
    labels: {
      template: function(e){
       return otherAlternativeMonthNames[e.value];
      }
    },
    categories: months
  }]
});

For your convenience, I have modified the Dojo example to reflect the suggestions mentioned above - http://dojo.telerik.com/IXOSiCAM.

Regards,
Tsvetomir
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Charts
Asked by
Bulut
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
Share this question
or