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

Dynamically set majorUnit

2 Answers 118 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 07 Jan 2014, 01:26 PM
Hello,

I'm trying to implement a functionality that defines total number of  axis divisions (by setting majorUnit dynamically) for Kendo chart. 
In order to implement this functionality, I have to calculate the maximum value of the chart and divide this value by an integer number. This methodology is used for both drawing the chart and clicking on the legend items. There is a function that is called from dataBound function for drawing the chart and from onLegendClick for reading the max value according to the changes of chart.

In order to read the max value I have to read this value from $(chartID).data("kendoChart")._model._plotArea.children[0].charts[0].valueAxisRanges.undefined.max.
My first question question is that if there is a better way to get this maximum value of the chart?
My second question is that I have to use setTimeout function in order to read the value otherwise I'll get error so is there any other way of retrieving this maximum value without using timeout function? 

I've created a sample project that is located at: http://jsfiddle.net/saes/8v8VT/

Thanks in advance,
Sam

2 Answers, 1 is accepted

Sort by
0
Accepted
T. Tsonev
Telerik team
answered on 09 Jan 2014, 02:00 PM
Hello,

This is really a case where we can make things a lot easier with just a simple property (e.g. axis.maxDivisions).
Sorry about that! We're taking notice.

The axis range can be obtained through an internal "range tracker" instance:
maxAxisValue = plotArea.valueAxisRangeTracker.query().max;

I've applied this and cleaned up the code here:
http://jsbin.com/OquzEKI/1/edit

The setTimeout call is necessary for the moment. We need a new event that fires right after the series are populated.

A lot of this is obviously internal and subject to change, but I consider it to be stable in the mid-term.
Any changes will focus in exposing this functionality.

Regards,
T. Tsonev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Sam
Top achievements
Rank 1
answered on 10 Jan 2014, 09:09 AM
Hello,

Thank you very much for your answer. 

Best Regards,
Sam
Tags
Charts
Asked by
Sam
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Sam
Top achievements
Rank 1
Share this question
or