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

Kendo Chart - Y Axis step range problem

6 Answers 566 Views
Chart
This is a migrated thread and some comments may be shown as answers.
aykut
Top achievements
Rank 1
aykut asked on 15 Jan 2015, 03:18 PM
I have this problem, with Kendo Chart's y axis. I have two different data on it, one varies little, and has a range between 0-20, whereas other value has a way greater difference towards negative side of the y axis. You can see this problem on the included image. I do not get this issue when I have a large difference of the second data type towards positive side of the y axis, but when it is directed to the negative side, the ranges between steps and the number of steps of y-axis gets crazy.

You can see the difference on the images I have attached.

I couldn't find any solution to this problem, please help me with this.
Thanks

6 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 19 Jan 2015, 01:12 PM
Hi,

I couldn't quite reproduce quite the same output in a simplified sample in the dojo.
It looks like the automatic setting of yAxis.majorUnit doesn't behave very well, but I can't confirm.

Can you please share the chart configuration and test data?

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
aykut
Top achievements
Rank 1
answered on 03 Feb 2015, 11:40 AM
Hi there,

Sorry for the late reply,

I am too busy to implement this problem on a sample, but the following is my axis configuration;

axisOpts: {
    majorGridLines: {
        step: 2
    },
    labels: {
        step: 2
    },
    axisCrossingValue: -Number.MAX_VALUE
}
Problem only happens when the data is varying between a large negative value and with any positive value in that same source, you can see that on the images I have attached to the first post. I need a solution for this asap. 
Thanks!










0
aykut
Top achievements
Rank 1
answered on 03 Feb 2015, 12:42 PM
I should also add that we have been using this code snippet for a while;

kendo.dataviz.NumericAxis.fn.initDefaults = function() {
            var defaults = initDefaults.apply(this, arguments);
            defaults.max = Math.max(10, defaults.max);
            defaults.majorUnit = defaults.max / 10;

            return defaults;
};
0
T. Tsonev
Telerik team
answered on 05 Feb 2015, 01:03 PM
Hello,

Try removing this snippet. Does it make any difference?

Perhaps you can fine tune the majorUnit calculation in the snippet if you decide to use it.

I hope this helps.

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
aykut
Top achievements
Rank 1
answered on 05 Feb 2015, 03:02 PM
Hello again,

When I remove this snippet, it does fix my issue, but I have remembered why have I used this code. 
It is to fix the issue that can be seen on the image that I have attached on this post. 
I either get this bug, or the one in my first post. How can I get rid of them both?    

Thanks

p.s. The issue with the attached image is that I have zero valued data sources, but still have full length bars, with really problematic looking axis with five zeroes on it.
0
T. Tsonev
Telerik team
answered on 09 Feb 2015, 12:36 PM
Hi,

Perhaps what you're seeing is the last screenshot is data points withing 0-1 the range.
If the labels are formatted as "N" the fractional digits will be truncated and you'll only see zeroes on the axis.

The snippets gets around this by limiting the max value to 10 and the label step (major unit) to 1.
We can fine tune this to avoid selecting too small major unit:
kendo.dataviz.NumericAxis.fn.initDefaults = function() {
    var defaults = initDefaults.apply(this, arguments);
    defaults.max = Math.max(10, defaults.max);
    defaults.majorUnit = Math.max(10, defaults.max / 10);

    return defaults;
};


You can take this further and insert more complex logic here.
Try it with different data set to see how it looks.

I hope this helps.

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Chart
Asked by
aykut
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
aykut
Top achievements
Rank 1
Share this question
or