10 Answers, 1 is accepted
Offsetting the lines themselves would not be possible as it would make their values incorrect in relation to their respective value axes. However, if you change the max value of one of the value axes, its scale will change and lines should not overlap. Here is an example where I change the max value dynamically, so you can see the difference:
It is very strange, but there is no max field.
var chart = $("#chart").data("kendoChart");
var options = chart.options.valueAxis;
var m = options.max;
I should admit, that your code work perfectly. Is something wrong with my chart? I have kendo version 2017.2.621
The max option would not be available if you had not set it explicitly beforehand. However, you can still get the min and max value of a value axis by using its range() method:
Here is an updated example which updates the axis current max value by adding 20 to it:
Your example is working perfectly fine, thank you. But there is a problem. After max value manually changed, it will not recalculate even if data changes. Even method redraw cannot fix it. I mean, redraw() actually redraws line affecting new data, but max value doesn't change any more.
I am not sure I understand the problem that you describe. Could you elaborate a bit more on what behavior you expect to see after changing the value axis max value? It looks to me like the value axis and series are redrawn correctly after the max value is increased. Or am I missing any detail out?
Sorry, if I wasn't clear. Please check attached images.
Capture-0.JPG - after script runs first time.
Capture-1.JPG - after Redraw button clicked. Chart automatically recalculates max value.
Capture-2.JPG - start over - Run script, then click Change max value button, then click Redraw button.
So, what happened, originally max value is not set, and it calculated automatically. Every time data is changes max property value is recalculated. After max value is set in a script, it doesn't change automatically anymore even if data was changed. My question is, how to enable automatic recalculating max value in a script? Because, in my case, after analyzing data I need to set max value or allow kendo chart to calculate it to avoid line overlapping.
Thank you, Ruben.
The Chart uses an automatic value only if there isn't a value set in the options. So, if you want the max to change after applying new data, you can:
- change it again based on the new data values
- remove the option, so the Chart can calculate it itself
In the context of the example we are working for, it would look like this:
Here is the example with the latter approach used:
Thank you, Ruben.