Hello,
We'd like only show whole numbers in the valueAxis - see example: http://dojo.telerik.com/ElobA/16
So, to solve this we added 'majorUnit: 1', which works fine.
However, we don't always know the data we are going to receive, and sometimes the values can be quite large.
If majorUnit is set to '1' with large values it will crash the browser. See example (uncomment majorUnit for crash): http://dojo.telerik.com/ElobA/13.
Is there a better recommended way of handling this? Or is it possible to set a value that determines the 'minimumMajorUnit' that won't crash the chart with large values?
Thanks for your help.
--Jeff
10 Answers, 1 is accepted
There is no minimumMajorUnit option available in Kendo UI Chart. What I would suggest as workaround is dynamically setting the majorUnit depending on the data:
var
chart = $(
'#chartTest'
).data(
"kendoChart"
);
chart.setOptions({
valueAxis: {
majorUnit: 1
}
})
Regards,
Iliana Nikolova
Telerik
Ok, thanks Iliana.
Is there a way to clear out the majorUnit, so it reverts to default behavior?
We can set it to 1, but then if the chart is updated with newer data we'd like not to have to calculate each time.
Or, if we do have to calculate, is there a way to rely on kendo's formula?
Thanks,
Jeff
Setting valueAxis majorUnit to null should help to achieve this:
chart.setOptions({valueAxis: { majorUnit:
null
}});
Regards,
Iliana Nikolova
Telerik
Hi Iliana,
I tried that, it seems to crash the browser when setting it to null, see example: http://dojo.telerik.com/ElobA/25.
Click 'update major unit' to test.
Thanks,
Jeff
Thank you for pointed our attention to this issue - it appears that if valueAxis.max is not explicitly set the majorUnit cannot be cleared via the setOptions method. I forwarded this case to the developers for further investigation and consideration.
Meanwhile, the only solution which I could suggest is changing it via the chart.options and redrawing the chart (updated dojo).
Regards,
Iliana Nikolova
Telerik
Ok, however, this solution doesn't seem to work when we need to update the data, which is the only reason we'd want to change the majorUnit.
See dojo - http://dojo.telerik.com/oFeki/3
After the redraw if we want to update the data the majorUnit will go back to what it was set to originally. Any thoughts?
Thanks,
Jeff
You should change the majorUnit after updating the data - updated dojo.
Regards,
Iliana Nikolova
Telerik
Updating the data first crashes the browser, which was the original issue.
In this case you could try setting the new data via the dataSource data method (updated example).
Regards,
Iliana Nikolova
Telerik by Progress