Reputation: 1497
I am trying to set max value dynamically of the largest number. I am not sure, where I am doing wrong...
Any help please?
Expected:
What I am getting:
PS: I want to find max value (Eg: 100 in this example) and show that as first yAxisLabel and next values should be minus (-) 20 etc...
Chart 1 values [39, 35, 19, 38, 39, 48, 56, 57]
Chart 2 values [39, 35, 19, 38, 39, 48, 56, 57]
Tried options without luck:
yAxis: {
min: 0,
max: 100,
tickInterval: 20,
},
and
yAxis: {
tickInterval: 20,
tickPositioner: function(min,max){
var act = min,
ticks = [];
console.log(this);
while(act <= max){
ticks.push(act);
act+= this.tickInterval;
}
return ticks;
},
min: 0,
max: 100,
},
Thanks to @Kacper Madej who has given below code which resulted
Upvotes: 1
Views: 1528
Reputation: 7896
It is possible to use tockPositioner
and set ticks there like:
showLastLabel: false,
tickPositioner: function(min, max) {
var ticks = [],
tick = min,
step = Math.round((max - min) / 7);
while (tick < max - step / 2) {
ticks.push(Math.round(tick));
tick += step;
}
ticks.push(Math.round(max));
ticks.push(Math.round(max+step)); //hidden - added for top padding
return ticks;
}
Example: http://jsfiddle.net/e6har510/
Upvotes: 2