Thanks in advance.
4 Answers, 1 is accepted
In order to achieve the expected result I can suggest setting valueAxis min/max values dynamically via the setOptions() method. As an example:
//get reference to the chart widget
var
chart = $(
"#chart"
).data(
"kendoChart"
);
//set min / max options
chart.setOptions({valueAxis: {min: 0, max: 400}});
Regards,
Iliana Nikolova
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Actually I found a post
https://docs.telerik.com/kendo-ui/knowledge-base/change-the-min-value-of-the-valueaxis-dynamically
however, my chart is in MVC not created in Jquery so is there a way to set these after render? I tried setting in the render event, but it has no effect. And if I try to redraw() within that event, you get an infinite loop as redraw fires render event again.
Hello, Robert,
The DataBound event should provide you with the desired functionality. For example, if you wanted to set the valueAxis height to always be a quarter of the height of its bars, you could use a function like the one below:
.Events(events => events
.DataBound("calculateColumnsMax")
)
function calculateColumnsMax(e) {
var chart = this;
var volumeValueAxisMax = Math.max(...chart.dataSource.data().map(stock => stock.Volume)) * 4;
// set valueAxis max so the bars are always 1/4 of the chart height
chart.options.valueAxis[0].max = volumeValueAxisMax;
chart.redraw();
}
Give this a try and let us know in case of further questions.
Kind Regards,
Alex Hajigeorgieva
Progress Telerik