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

How to conditionally set chart axis title

1 Answer 100 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Xiaoyi
Top achievements
Rank 1
Xiaoyi asked on 12 Jan 2016, 11:24 AM

Hi, i am using MVC CHART CONTROL.  Is it possible set the categoryAxis title according to a dropdown list's selected value.

 when the user click the update button, It will call

 

 var ochart = $("#chart").data("kendoChart");
 ochart.dataSource.read();

 

that works well and chart area will be updated accoriding settings. based on it, I would like to change the axis title as well. but if i tried to

ochart.options.categoryAxis.title = "something else";

the title just disappeared.

I have spent a few hours on it. please anyone can give me a hand?

 

thanks

1 Answer, 1 is accepted

Sort by
0
Dimiter Topalov
Telerik team
answered on 13 Jan 2016, 03:56 PM
Hi Xiaoyi,

The text property that you are referring to is one of the properties of the category-axis title object (you can get a reference to it by using "ochart.options.categoryAxis.title.text" instead of "ochart.options.categoryAxis.title").

In order to set a new value to this property, you need to pass an object, containing the new options, to the setOptions method of the Kendo UI Chart:

// in the handler of the submit button click event:
ochart.setOptions({
categoryAxis: [
    {
title: {
    text:
"Some text"
}
    }
]
});

If you would like to modify other properties of category axis title, you can just list them in the title object with their corresponding new values.

I hope this helps.

Regards,
Dimiter Topalov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Chart
Asked by
Xiaoyi
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Share this question
or